removed lampath session variable

This commit is contained in:
Roland Gruber 2010-04-01 18:12:07 +00:00
parent 5141547a97
commit dc4fe124bc
9 changed files with 26 additions and 34 deletions

View File

@ -39,10 +39,10 @@ $Id$
* @return array list of shell names * @return array list of shell names
*/ */
function getshells() { function getshells() {
if (!isset($_SESSION['lampath'])) return array(); $shellPath = dirname(__FILE__) . '/../config/shells';
// Load shells from file // Load shells from file
if (file_exists($_SESSION['lampath'] . 'config/shells')) { if (file_exists($shellPath)) {
$shells = file($_SESSION['lampath'] . 'config/shells'); $shells = file($shellPath);
$i = 0; $i = 0;
while (count($shells) > $i) { while (count($shells) > $i) {
// remove whitespaces // remove whitespaces

View File

@ -63,7 +63,7 @@ class lamPDF extends UFPDF {
*/ */
function __construct($page_definitions = array(),$fontName) { function __construct($page_definitions = array(),$fontName) {
$this->fontName = $fontName; $this->fontName = $fontName;
define('FPDF_FONTPATH', $_SESSION['lampath'] . "lib/" . 'font/'); define('FPDF_FONTPATH', dirname(__FILE__) . '/font/');
// Call constructor of superclass // Call constructor of superclass
$this->FPDF('P','mm','A4'); $this->FPDF('P','mm','A4');

View File

@ -186,15 +186,14 @@ class Ldap{
// change random number // change random number
mt_srand($this->rand + (microtime() * 1000000)); mt_srand($this->rand + (microtime() * 1000000));
$this->rand = mt_rand(); $this->rand = mt_rand();
// delete PDF files which are older than 10 min // delete PDF files and images which are older than 10 min
if (isset($_SESSION['lampath'])) { $tmpDir = dirname(__FILE__) . '/../tmp/';
$relpath = $_SESSION['lampath'] . 'tmp/';
$time = time(); $time = time();
$dir = @opendir($relpath); $dir = @opendir($tmpDir);
$file = @readdir($dir); $file = @readdir($dir);
while ($file) { while ($file) {
if ((substr($file, -4) == '.pdf') || (substr($file, -4) == '.jpg')) { if ((substr($file, -4) == '.pdf') || (substr($file, -4) == '.jpg')) {
$path = $relpath . $file; $path = $tmpDir . $file;
if ($time - filemtime($path) > 600) { if ($time - filemtime($path) > 600) {
@unlink($path); @unlink($path);
} }
@ -203,7 +202,6 @@ class Ldap{
} }
@closedir($dir); @closedir($dir);
} }
}
/** /**
* Calculates a new value for rand * Calculates a new value for rand

View File

@ -1152,7 +1152,7 @@ class inetOrgPerson extends baseModule implements passwordService {
$noPhoto = true; $noPhoto = true;
if (isset($this->attributes['jpegPhoto'][0])) { if (isset($this->attributes['jpegPhoto'][0])) {
$jpeg_filename = 'jpg' . $_SESSION['ldap']->new_rand() . '.jpg'; $jpeg_filename = 'jpg' . $_SESSION['ldap']->new_rand() . '.jpg';
$outjpeg = @fopen($_SESSION['lampath'] . 'tmp/' . $jpeg_filename, "wb"); $outjpeg = @fopen(dirname(__FILE__) . '/../../tmp/' . $jpeg_filename, "wb");
fwrite($outjpeg, $this->attributes['jpegPhoto'][0]); fwrite($outjpeg, $this->attributes['jpegPhoto'][0]);
fclose ($outjpeg); fclose ($outjpeg);
$photoFile = '../../tmp/' . $jpeg_filename; $photoFile = '../../tmp/' . $jpeg_filename;

View File

@ -142,12 +142,8 @@ function createModulePDF($accounts,$pdf_structure="default") {
// Close PDF // Close PDF
$pdf->Close(); $pdf->Close();
// Get relative url path
$fullpath = realpath('.');
$subdirs = explode('/', str_replace($_SESSION['lampath'], '', $fullpath));
for ($i=0; $i<count($subdirs); $i++ ) $filename .= '../';
// use timestamp and random number from ldap.inc as filename so it should be unique. // use timestamp and random number from ldap.inc as filename so it should be unique.
$filename .= 'tmp/' . $_SESSION['ldap']->new_rand() . time() .'.pdf'; $filename .= '../../tmp/' . $_SESSION['ldap']->new_rand() . time() .'.pdf';
// Save PDF // Save PDF
$pdf->Output($filename); $pdf->Output($filename);
// Output meta refresh to pdf-file // Output meta refresh to pdf-file

View File

@ -46,7 +46,7 @@ include_once("ldap.inc");
*/ */
function getPDFStructureDefinitions($scope = "user") { function getPDFStructureDefinitions($scope = "user") {
$return = array(); $return = array();
$path = $_SESSION['lampath'] . 'config/pdf/'; $path = dirname(__FILE__) . '/../config/pdf/';
if(is_dir($path)) { if(is_dir($path)) {
$dirHandle = opendir($path); $dirHandle = opendir($path);
while($file = readdir($dirHandle)) { while($file = readdir($dirHandle)) {
@ -71,7 +71,7 @@ function getPDFStructureDefinitions($scope = "user") {
*/ */
function loadPDFStructureDefinitions($scope='user',$pdf_structure='default') { function loadPDFStructureDefinitions($scope='user',$pdf_structure='default') {
$parser = new xmlParser(); $parser = new xmlParser();
$file = $_SESSION['lampath'] . 'config/pdf/' . $pdf_structure . '.' . $scope . '.xml'; $file = dirname(__FILE__) . '/../config/pdf/' . $pdf_structure . '.' . $scope . '.xml';
$xml = $parser->parse($file); $xml = $parser->parse($file);
$border = array(); $border = array();
$structure = array(); $structure = array();
@ -100,8 +100,8 @@ function loadPDFStructureDefinitions($scope='user',$pdf_structure='default') {
function savePDFStructureDefinitions($scope,$definition) { function savePDFStructureDefinitions($scope,$definition) {
if (!preg_match('/[a-zA-Z0-9\-\_]+/',$definition)) return 'no perms'; if (!preg_match('/[a-zA-Z0-9\-\_]+/',$definition)) return 'no perms';
if (!preg_match('/[a-zA-Z]+/',$scope)) return 'no perms'; if (!preg_match('/[a-zA-Z]+/',$scope)) return 'no perms';
$struct_file = ($_SESSION['lampath'] . 'config/pdf/' . $definition . '.' . $scope . '.xml'); $struct_file = dirname(__FILE__) . '/../config/pdf/' . $definition . '.' . $scope . '.xml';
if(!is_writable($_SESSION['lampath'] . 'config/pdf/')) { if(!is_writable(dirname(__FILE__) . '/../config/pdf/')) {
return 'no perms'; return 'no perms';
} }
else { else {
@ -158,7 +158,7 @@ function savePDFStructureDefinitions($scope,$definition) {
function deletePDFStructureDefinition($scope, $definition) { function deletePDFStructureDefinition($scope, $definition) {
if (!preg_match('/[a-zA-Z0-9\-\_]+/',$definition)) return false; if (!preg_match('/[a-zA-Z0-9\-\_]+/',$definition)) return false;
if (!preg_match('/[a-zA-Z]+/',$scope)) return false; if (!preg_match('/[a-zA-Z]+/',$scope)) return false;
$file = $_SESSION['lampath'] . 'config/pdf/' . $definition . '.' . $scope . '.xml'; $file = dirname(__FILE__) . '/../config/pdf/' . $definition . '.' . $scope . '.xml';
if(is_file($file) && is_writable($file)) { if(is_file($file) && is_writable($file)) {
return unlink($file); return unlink($file);
} }
@ -175,7 +175,7 @@ function deletePDFStructureDefinition($scope, $definition) {
*/ */
function getAvailableLogos() { function getAvailableLogos() {
$return = array(); $return = array();
$dirPath = $_SESSION['lampath'] . '/config/pdf/logos/'; $dirPath = dirname(__FILE__) . '/../config/pdf/logos/';
$dirHandle = opendir($dirPath); $dirHandle = opendir($dirPath);
while($file = readdir($dirHandle)) { while($file = readdir($dirHandle)) {
if(!is_dir($file) && $file != '.' && $file != '..' && preg_match('/\\.(jpg|png)$/',$file)) { if(!is_dir($file) && $file != '.' && $file != '..' && preg_match('/\\.(jpg|png)$/',$file)) {

View File

@ -1149,7 +1149,7 @@ function get_enc_type( $user_password )
function draw_jpeg_photos( $dn, $attr_name='jpegPhoto', $draw_delete_buttons=false, function draw_jpeg_photos( $dn, $attr_name='jpegPhoto', $draw_delete_buttons=false,
$draw_bytes_and_size=true, $table_html_attrs='align="left"', $img_html_attrs='' ) $draw_bytes_and_size=true, $table_html_attrs='align="left"', $img_html_attrs='' )
{ {
$jpeg_temp_dir = $_SESSION['lampath'] . 'tmp'; $jpeg_temp_dir = dirname(__FILE__) . '/../tmp';
$conn = $_SESSION['ldap']->server(); $conn = $_SESSION['ldap']->server();
$search_result = ldap_read( $conn, $dn, 'objectClass=*', array( $attr_name ) ); $search_result = ldap_read( $conn, $dn, 'objectClass=*', array( $attr_name ) );

View File

@ -206,7 +206,7 @@ class lamUserList extends lamList {
} }
$imgNumber = $_SESSION['ldap']->new_rand(); $imgNumber = $_SESSION['ldap']->new_rand();
$jpeg_filename = 'jpg' . $imgNumber . '.jpg'; $jpeg_filename = 'jpg' . $imgNumber . '.jpg';
$outjpeg = @fopen($_SESSION['lampath'] . 'tmp/' . $jpeg_filename, "wb"); $outjpeg = @fopen(dirname(__FILE__) . '/../../tmp/' . $jpeg_filename, "wb");
fwrite($outjpeg, $entry[$attribute][0]); fwrite($outjpeg, $entry[$attribute][0]);
fclose ($outjpeg); fclose ($outjpeg);
$photoFile = '../../tmp/' . $jpeg_filename; $photoFile = '../../tmp/' . $jpeg_filename;

View File

@ -60,8 +60,6 @@ if(isset($_POST['profile'])) {
} }
// init some session variables // init some session variables
$_SESSION['lampath'] = realpath('../') . "/"; // Save full path to lam in session
$default_Config = new LAMCfgMain(); $default_Config = new LAMCfgMain();
$_SESSION["cfgMain"] = $default_Config; $_SESSION["cfgMain"] = $default_Config;
$default_Profile = $default_Config->default; $default_Profile = $default_Config->default;