diff --git a/lam/lib/account.inc b/lam/lib/account.inc index e1d3d20e..b9f0d4c9 100644 --- a/lam/lib/account.inc +++ b/lam/lib/account.inc @@ -39,10 +39,10 @@ $Id$ * @return array list of shell names */ function getshells() { - if (!isset($_SESSION['lampath'])) return array(); + $shellPath = dirname(__FILE__) . '/../config/shells'; // Load shells from file - if (file_exists($_SESSION['lampath'] . 'config/shells')) { - $shells = file($_SESSION['lampath'] . 'config/shells'); + if (file_exists($shellPath)) { + $shells = file($shellPath); $i = 0; while (count($shells) > $i) { // remove whitespaces diff --git a/lam/lib/lamPDF.inc b/lam/lib/lamPDF.inc index 0c9a42fd..f99b36d6 100644 --- a/lam/lib/lamPDF.inc +++ b/lam/lib/lamPDF.inc @@ -63,7 +63,7 @@ class lamPDF extends UFPDF { */ function __construct($page_definitions = array(),$fontName) { $this->fontName = $fontName; - define('FPDF_FONTPATH', $_SESSION['lampath'] . "lib/" . 'font/'); + define('FPDF_FONTPATH', dirname(__FILE__) . '/font/'); // Call constructor of superclass $this->FPDF('P','mm','A4'); diff --git a/lam/lib/ldap.inc b/lam/lib/ldap.inc index 34075ee6..fa12cbd3 100644 --- a/lam/lib/ldap.inc +++ b/lam/lib/ldap.inc @@ -186,23 +186,21 @@ class Ldap{ // change random number mt_srand($this->rand + (microtime() * 1000000)); $this->rand = mt_rand(); - // delete PDF files which are older than 10 min - if (isset($_SESSION['lampath'])) { - $relpath = $_SESSION['lampath'] . 'tmp/'; - $time = time(); - $dir = @opendir($relpath); - $file = @readdir($dir); - while ($file) { - if ((substr($file, -4) == '.pdf') || (substr($file, -4) == '.jpg')) { - $path = $relpath . $file; - if ($time - filemtime($path) > 600) { - @unlink($path); - } + // delete PDF files and images which are older than 10 min + $tmpDir = dirname(__FILE__) . '/../tmp/'; + $time = time(); + $dir = @opendir($tmpDir); + $file = @readdir($dir); + while ($file) { + if ((substr($file, -4) == '.pdf') || (substr($file, -4) == '.jpg')) { + $path = $tmpDir . $file; + if ($time - filemtime($path) > 600) { + @unlink($path); } - $file = @readdir($dir); } - @closedir($dir); + $file = @readdir($dir); } + @closedir($dir); } /** diff --git a/lam/lib/modules/inetOrgPerson.inc b/lam/lib/modules/inetOrgPerson.inc index 35cd7910..3bf0683f 100644 --- a/lam/lib/modules/inetOrgPerson.inc +++ b/lam/lib/modules/inetOrgPerson.inc @@ -1152,7 +1152,7 @@ class inetOrgPerson extends baseModule implements passwordService { $noPhoto = true; if (isset($this->attributes['jpegPhoto'][0])) { $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]); fclose ($outjpeg); $photoFile = '../../tmp/' . $jpeg_filename; diff --git a/lam/lib/pdf.inc b/lam/lib/pdf.inc index b9ad0795..893c117f 100644 --- a/lam/lib/pdf.inc +++ b/lam/lib/pdf.inc @@ -142,12 +142,8 @@ function createModulePDF($accounts,$pdf_structure="default") { // Close PDF $pdf->Close(); - // Get relative url path - $fullpath = realpath('.'); - $subdirs = explode('/', str_replace($_SESSION['lampath'], '', $fullpath)); - for ($i=0; $inew_rand() . time() .'.pdf'; + $filename .= '../../tmp/' . $_SESSION['ldap']->new_rand() . time() .'.pdf'; // Save PDF $pdf->Output($filename); // Output meta refresh to pdf-file diff --git a/lam/lib/pdfstruct.inc b/lam/lib/pdfstruct.inc index 29664655..01aa8650 100644 --- a/lam/lib/pdfstruct.inc +++ b/lam/lib/pdfstruct.inc @@ -46,7 +46,7 @@ include_once("ldap.inc"); */ function getPDFStructureDefinitions($scope = "user") { $return = array(); - $path = $_SESSION['lampath'] . 'config/pdf/'; + $path = dirname(__FILE__) . '/../config/pdf/'; if(is_dir($path)) { $dirHandle = opendir($path); while($file = readdir($dirHandle)) { @@ -71,7 +71,7 @@ function getPDFStructureDefinitions($scope = "user") { */ function loadPDFStructureDefinitions($scope='user',$pdf_structure='default') { $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); $border = array(); $structure = array(); @@ -100,8 +100,8 @@ function loadPDFStructureDefinitions($scope='user',$pdf_structure='default') { function savePDFStructureDefinitions($scope,$definition) { if (!preg_match('/[a-zA-Z0-9\-\_]+/',$definition)) return 'no perms'; if (!preg_match('/[a-zA-Z]+/',$scope)) return 'no perms'; - $struct_file = ($_SESSION['lampath'] . 'config/pdf/' . $definition . '.' . $scope . '.xml'); - if(!is_writable($_SESSION['lampath'] . 'config/pdf/')) { + $struct_file = dirname(__FILE__) . '/../config/pdf/' . $definition . '.' . $scope . '.xml'; + if(!is_writable(dirname(__FILE__) . '/../config/pdf/')) { return 'no perms'; } else { @@ -158,7 +158,7 @@ function savePDFStructureDefinitions($scope,$definition) { function deletePDFStructureDefinition($scope, $definition) { if (!preg_match('/[a-zA-Z0-9\-\_]+/',$definition)) 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)) { return unlink($file); } @@ -175,7 +175,7 @@ function deletePDFStructureDefinition($scope, $definition) { */ function getAvailableLogos() { $return = array(); - $dirPath = $_SESSION['lampath'] . '/config/pdf/logos/'; + $dirPath = dirname(__FILE__) . '/../config/pdf/logos/'; $dirHandle = opendir($dirPath); while($file = readdir($dirHandle)) { if(!is_dir($file) && $file != '.' && $file != '..' && preg_match('/\\.(jpg|png)$/',$file)) { diff --git a/lam/lib/tree.inc b/lam/lib/tree.inc index 4a293935..cafcc3a9 100644 --- a/lam/lib/tree.inc +++ b/lam/lib/tree.inc @@ -1149,7 +1149,7 @@ function get_enc_type( $user_password ) 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='' ) { - $jpeg_temp_dir = $_SESSION['lampath'] . 'tmp'; + $jpeg_temp_dir = dirname(__FILE__) . '/../tmp'; $conn = $_SESSION['ldap']->server(); $search_result = ldap_read( $conn, $dn, 'objectClass=*', array( $attr_name ) ); diff --git a/lam/lib/types/user.inc b/lam/lib/types/user.inc index ea67b6c6..acdf798f 100644 --- a/lam/lib/types/user.inc +++ b/lam/lib/types/user.inc @@ -206,7 +206,7 @@ class lamUserList extends lamList { } $imgNumber = $_SESSION['ldap']->new_rand(); $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]); fclose ($outjpeg); $photoFile = '../../tmp/' . $jpeg_filename; diff --git a/lam/templates/login.php b/lam/templates/login.php index d0d50bad..6d1ff989 100644 --- a/lam/templates/login.php +++ b/lam/templates/login.php @@ -60,8 +60,6 @@ if(isset($_POST['profile'])) { } // init some session variables -$_SESSION['lampath'] = realpath('../') . "/"; // Save full path to lam in session - $default_Config = new LAMCfgMain(); $_SESSION["cfgMain"] = $default_Config; $default_Profile = $default_Config->default;