[Linpha-cvs] SF.net SVN: linpha: [4539] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-04-16 16:31:12
|
Revision: 4539 Author: fangehrn Date: 2006-04-16 09:30:56 -0700 (Sun, 16 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4539&view=rev Log Message: ----------- * changed way of selecting and saving paths during install (all folder paths are always stores without ending slash) * fixed some notices in installer * finished basket checkout features Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/lib.install.php trunk/linpha2/install/lib.requirements.php trunk/linpha2/install/step4_selectdirectories.php trunk/linpha2/install/step5_getlogin.php trunk/linpha2/install/step6_selectdatabase.php trunk/linpha2/install/step9_createtables.php trunk/linpha2/lib/classes/archiver.class.php trunk/linpha2/lib/classes/linpha.filesys.class.php trunk/linpha2/lib/include/basket_build_mail.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/ChangeLog 2006-04-16 16:30:56 UTC (rev 4539) @@ -1,3 +1,9 @@ +2006-04-16 flo + * changed way of selecting and saving paths during install + (all folder paths are always stores without ending slash) + * fixed some notices in installer + * finished basket checkout features + 2006-04-15 flo * finished implementing basket checkout features (download, print, mail) print and mail works quite smooth Modified: trunk/linpha2/install/lib.install.php =================================================================== --- trunk/linpha2/install/lib.install.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/install/lib.install.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -104,7 +104,7 @@ } } -function get_PATH($array_path) +function linInstallget_PATH($array_path) { /** * use the path variable instead of own array @@ -335,7 +335,8 @@ while(strlen($http_accept_language)) { - if(preg_match( "/$eachbit/", $http_accept_language, $m=Array())) + $m = Array(); // do not this directly in preg_match() ! + if(preg_match( "/$eachbit/", $http_accept_language, $m)) { $tag = $m[1]; $quality = $m[2]; Modified: trunk/linpha2/install/lib.requirements.php =================================================================== --- trunk/linpha2/install/lib.requirements.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/install/lib.requirements.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -27,8 +27,8 @@ } else { $convert = 'convert'; } - $array_path = get_PATH('PATH'); - $array_lookfor = get_PATH(Array('/bin','/usr/bin','/usr/local/bin','/sw/bin')); + $array_path = linInstallget_PATH('PATH'); + $array_lookfor = linInstallget_PATH(Array('/bin','/usr/bin','/usr/local/bin','/sw/bin')); /** * need a special check if safe_mode is on @@ -44,8 +44,8 @@ if( !isset($array) ) { //echo $value.'<br />'; - - exec($value.'/'.$convert.' -help',$arr=array(),$return_var=''); + $arr=array(); $return_var=''; // do not this directly in exec() ! + exec($value.'/'.$convert.' -help',$arr,$return_var); //print_r($arr); @@ -61,6 +61,7 @@ { if( !isset($array) ) { + $arr=array(); $return_var=''; // do not this directly in exec() ! exec($value.'/'.$convert.' -help',$arr,$return_var); if(isset($return_var) && $return_var == 0) Modified: trunk/linpha2/install/step4_selectdirectories.php =================================================================== --- trunk/linpha2/install/step4_selectdirectories.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/install/step4_selectdirectories.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -27,9 +27,9 @@ include_once(LINPHA_DIR.'/install/header.php'); $album_dir = (isset($_SESSION['album_dir']) ? $_SESSION['album_dir'] : 'albums'); -$sql_dir = (isset($_SESSION['sql_dir']) ? $_SESSION['sql_dir_parent'] : 'var/'); -$cache_dir = (isset($_SESSION['cache_dir']) ? $_SESSION['cache_dir_parent'] : 'var/'); -$tmp_dir = (isset($_SESSION['tmp_dir']) ? $_SESSION['tmp_dir_parent'] : 'var/'); +$sql_dir = (isset($_SESSION['sql_dir']) ? $_SESSION['sql_dir'] : 'var/sql'); +$cache_dir = (isset($_SESSION['cache_dir']) ? $_SESSION['cache_dir'] : 'var/cache'); +$tmp_dir = (isset($_SESSION['tmp_dir']) ? $_SESSION['tmp_dir'] : 'var/tmp'); /** @@ -81,7 +81,7 @@ <input class="boxalignelement" type="text" id="check02" onKeyup="checkForm()" name="sql_dir" size="30" value="<?php echo $sql_dir; ?>"> </div> -(-> <?php echo linpha_realpath( get_full_path($sql_dir) ); ?>/sql) +(-> <?php echo linpha_realpath( get_full_path($sql_dir) ); ?>) <br /><br /> <div class="boxalign"> @@ -89,7 +89,7 @@ <input class="boxalignelement" type="text" id="check03" onKeyup="checkForm()" name="cache_dir" size="30" value="<?php echo $cache_dir; ?>"> </div> -(-> <?php echo linpha_realpath( get_full_path($cache_dir) ); ?>/cache) +(-> <?php echo linpha_realpath( get_full_path($cache_dir) ); ?>) <br /><br /> <div class="boxalign"> @@ -97,7 +97,7 @@ <input class="boxalignelement" type="text" id="check04" onKeyup="checkForm()" name="tmp_dir" size="30" value="<?php echo $tmp_dir; ?>"> </div> -(-> <?php echo linpha_realpath( get_full_path($tmp_dir) ); ?>/tmp) +(-> <?php echo linpha_realpath( get_full_path($tmp_dir) ); ?>) <br /><br /> <?php Modified: trunk/linpha2/install/step5_getlogin.php =================================================================== --- trunk/linpha2/install/step5_getlogin.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/install/step5_getlogin.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -53,40 +53,26 @@ $array = array('album', 'sql','cache','tmp'); foreach($array AS $value) { - if( isset( $_POST[$value.'_dir'] ) ) + /** + * remove '/' if not already done + */ + $len = strlen( $_POST[$value.'_dir'] ); + $lastsign = substr( $_POST[$value.'_dir'], $len-1); + if($lastsign == '/' && $lastsign == '\\') { - /** - * save correctly in session - */ - /** - * append '/' if not already done - */ - $len = strlen( $_POST[$value.'_dir'] ); - $lastsign = substr( $_POST[$value.'_dir'], $len-1); - if($lastsign != '/' && $lastsign != '\\') - { - $_POST[$value.'_dir'] .= '/'; - } - - /** - * save current value and append correct dir names - */ - $_SESSION[$value.'_dir_parent'] = $_POST[$value.'_dir']; - switch($value) - { - case 'album': $_SESSION[$value.'_dir'] = $_POST[$value.'_dir']; break; - case 'sql': $_SESSION[$value.'_dir'] = $_POST[$value.'_dir'].'sql/'; break; - case 'cache': $_SESSION[$value.'_dir'] = $_POST[$value.'_dir'].'cache/'; break; - case 'tmp': $_SESSION[$value.'_dir'] = $_POST[$value.'_dir'].'tmp/'; break; - } + $_POST[$value.'_dir'] = substr($_POST[$value.'_dir'],0,$len-1); } + + /** + * save current value and append correct dir names + */ + $_SESSION[$value.'_dir'] = $_POST[$value.'_dir']; /** * get correct dir names (take care of relativ and absolute paths, add * LINPHA_DIR if necessary) */ $dirs[$value] = get_full_path( $_SESSION[$value.'_dir'] ); - $dirs[$value.'_parent'] = get_full_path( $_SESSION[$value.'_dir_parent'] ); } /** @@ -105,7 +91,10 @@ * validate writable directories */ echo "<h2>".tr("Checking Directory Permissions")."</h2><br />"; - + +/** + * checking album directory + */ echo tr("Album Directory")."... "; if( is_dir( $dirs['album'] ) ) { @@ -127,30 +116,24 @@ echo '<br /> ('.$_SESSION['album_dir'].')'; echo "<br />".tr("No Valid Directory Found")."!"; } - - $array = array('sql','cache','tmp'); - foreach($array AS $value) + +/** + * checking sql, cache and tmp directory + */ + try { - echo "<br /><br />Checking ".$value." Directory... "; - if(! is_dir( $dirs[$value.'_parent'] ) ) + $array = array('sql','cache','tmp'); + foreach($array AS $value) { - echo warning_msg(); - echo "<br />".tr("Directory ".$dirs[$value.'_parent']." Doesnt Exists - Trying To Create")."... "; - if( mkdir_p( $dirs[$value.'_parent'] ) ) + echo "<br /><br />".tr("Checking Directory").": ".$value."..."; + + if( file_exists( $dirs[$value] ) ) { - echo success_msg(); - } - else - { - echo failed_msg(); - } - } - - if( is_dir( $dirs[$value.'_parent'] ) ) - { - if( is_writable( $dirs[$value.'_parent'] ) ) - { - if( file_exists( $dirs[$value] ) ) + /** + * oh oh, pay attention, only try to delete the folder on default values! + * if the users choose wrongly the albums folder, all images would be deleted.!!!! + */ + if( $_SESSION[$value.'_dir'] == 'var/'.$value) { echo warning_msg(); echo "<br />".tr("Directory Already Exists - Trying To Delete")."... "; @@ -160,44 +143,43 @@ } else { - echo failed_msg(); - echo "<br />".tr("Please Delete Folder Manually").""; - $error_nr = 2; + throw new Exception(failed_msg()."<br />".tr("Please Delete Folder Manually")); } } else { - echo success_msg(); + throw new Exception(failed_msg()."<br />".tr("Please Delete Folder Manually")); } - echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.linpha_realpath( $dirs[$value.'_parent'] ).'/'.$value.')'; } + + echo "<br /> ".tr("Trying To Create Directory")."... "; + if( mkdir_p( $dirs[$value] ) ) + { + echo success_msg(); + + if( ! is_writable( $dirs[$value] ) ) + { + echo "<br />".tr("No Write Permissions. Please Change Permissions Manually!"); + } + } else { - echo failed_msg(); - echo "<br />".tr("No Write Permissions. Please Change Permissions Or Choose Another Directory")."!"; - echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.linpha_realpath( $dirs[$value.'_parent'] ).'/'.$value.')'; - $error_nr = 1; + throw new Exception(failed_msg()."<br />".tr("Cannot create folder, please check permissions!")); } + + echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.linpha_realpath( $dirs[$value] ).')<br />'; } - else - { - echo failed_msg(); - echo "<br />".tr("Directory Doesn't Exist")."!"; - echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.$dirs[$value.'_parent'].'/'.$value.')'; // no realpath() because if dir does not exists realpath will show something strange... - $error_nr = 1; - } - } - - echo '<br /><br />'; - - if(isset($error_nr)) + catch(Exception $error) { + echo "Error: ".$error -> getMessage(); + $show_next_button = false; include_once(LINPHA_DIR.'/install/footer.php'); exit(); } ?> +<br /><br /> <hr /> <h1><?php echo tr("$title_str[$key]"); ?></h1> <br /> Modified: trunk/linpha2/install/step6_selectdatabase.php =================================================================== --- trunk/linpha2/install/step6_selectdatabase.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/install/step6_selectdatabase.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -214,7 +214,7 @@ if($_SESSION['allowed_to_create_db'] == false AND !isset($database)) { - if($_SESSION['sql_dbname'] == 'oci8po') + if($_SESSION['sql_dbtype'] == 'oci8po') { echo tr("Name Of Database To Use, this is usually \"XE\" For Oracle Express Edition"); } Modified: trunk/linpha2/install/step9_createtables.php =================================================================== --- trunk/linpha2/install/step9_createtables.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/install/step9_createtables.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -57,7 +57,7 @@ /** * finally create tables */ - echo tr("Creating Tables")."...<br /> "; + echo tr("Creating Tables")."... "; $translation_array = array_keys($linpha_tables); // only used in error case while( list($key,$query) = each($sql_tables) ) @@ -76,8 +76,7 @@ */ if($_SESSION['sql_dbtype'] == 'oci8po') { - - echo tr("Creating Sequences")."...<br /> "; + echo tr("Creating Sequences")."...<br /> "; /** * create sequences @@ -155,21 +154,10 @@ /** * create cache directories */ - echo "<br /><br />".tr("Creating Directories")."... "; - @mkdir(get_full_path( $_SESSION['cache_dir'] ), 0700 ); - @mkdir(get_full_path( $_SESSION['cache_dir'] ).'img', 0700); - @mkdir(get_full_path( $_SESSION['cache_dir'] ).'thumb', 0700); + echo "<br /><br />".tr("Creating Cache Directories")."... "; + mkdir(get_full_path( $_SESSION['cache_dir'] ).'/img', 0700); + mkdir(get_full_path( $_SESSION['cache_dir'] ).'/thumb', 0700); - /** - * create tmp dirs - */ - @mkdir( get_full_path( $_SESSION['tmp_dir'] ), 0700 ); - - /** - * create sql dir - */ - @mkdir( get_full_path( $_SESSION['sql_dir'] ), 0700 ); - echo success_msg(); /** @@ -210,7 +198,7 @@ * create config.sql.php file */ echo "<br />".tr("Writing config.sql.php File")."... "; - $fp = fopen( get_full_path( $_SESSION['sql_dir'] )."config.sql.php","w+" ); + $fp = fopen( get_full_path( $_SESSION['sql_dir'] )."/config.sql.php","w+" ); if($fp) { $comment[1] = ''; @@ -226,7 +214,7 @@ fwrite( $fp, $str ); fclose($fp); - if( !@chmod( get_full_path( $_SESSION['sql_dir'] )."config.sql.php", 0600 ) ) + if( !@chmod( get_full_path( $_SESSION['sql_dir'] )."/config.sql.php", 0600 ) ) { echo warning_msg().'<br />'; echo tr("Chmod Failed For config.sql.php")."<br />"; Modified: trunk/linpha2/lib/classes/archiver.class.php =================================================================== --- trunk/linpha2/lib/classes/archiver.class.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/lib/classes/archiver.class.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -36,7 +36,6 @@ var $sleeptime; var $ziptype; var $apps; -var $md5sums; /** * constructor @@ -55,6 +54,7 @@ $this->tmpname = LinFilesys::linTempnam( 'linpha_download', // prefix '.'.$this->apps->apps[$this->ziptype]['file_ext'] // suffix + ,$use_absolutepath=true // need absolute path because we use chdir()! ); } @@ -126,6 +126,7 @@ return false; } + $array_output=array(); $return_value=''; // do not this directly in exec() ! exec($command,$array_output=Array(),$return_value=0); /** Modified: trunk/linpha2/lib/classes/linpha.filesys.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/lib/classes/linpha.filesys.class.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -28,6 +28,30 @@ { /** + * realpath() doesnt work somtimes if path is absolute + * linRealpath takes care of this + */ +function linRealpath( $path) +{ + if( ! LinFilesys::isAbsolutePath( $path ) ) + { + $path = realpath( $path ); + } + + /** + * remove ending '/' if exists + */ + $len = strlen( $path ); + $lastsign = substr( $path, $len-1); + if($lastsign == '/' OR $lastsign == '\\') + { + $path = substr($path,0,$len-1); + } + + return $path; +} + +/** * returns a unique filename, but different to tempnam() the file doesn't exists * * @author flo @@ -38,9 +62,15 @@ * * http://ch.php.net/manual/de/function.uniqid.php */ -function linTempnam($prefix,$suffix) +function linTempnam($prefix,$suffix,$use_absolutepath=false) { $tmp_dir = LinSql::getPath('tmp'); + + if($use_absolutepath) + { + $tmp_dir = LinFilesys::LinRealpath($tmp_dir); + } + if(!is_writable($tmp_dir)) { error_log("linpha_tempnam: tmp_dir ($tmp_dir) isn't writable! Using /tmp instead"); $tmp_dir = '/tmp'; Modified: trunk/linpha2/lib/include/basket_build_mail.php =================================================================== --- trunk/linpha2/lib/include/basket_build_mail.php 2006-04-15 17:58:34 UTC (rev 4538) +++ trunk/linpha2/lib/include/basket_build_mail.php 2006-04-16 16:30:56 UTC (rev 4539) @@ -63,23 +63,24 @@ return $available_mem; } -if( empty($_POST['mail_address']) OR empty($_POST['sender_address']) OR empty($_POST['subject']) ) + +try { - linSysLog(i18n("Please Fill In All Fields!")); - $error = true; -} + if( empty($_POST['mail_address']) OR empty($_POST['sender_address']) OR empty($_POST['subject']) ) + { + throw new Exception(i18n("Please Fill In All Fields!")); + } -if(!isset($error)) -{ + $tmp_folder = LinFilesys::createTmpFolder('mail'); /** * create temporary folder containing all images */ + reset($_SESSION['basket_ids']); while(list($key, $image_id) = each($_SESSION['basket_ids'])) { $data = $GLOBALS['linpha']->db->GetRow("SELECT img_type FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes( $image_id )."'"); - if(isset($data['img_type']) && LinIdentify::isSupportedImage( $data['img_type'] ) ) { $at_least_one_image = true; @@ -118,24 +119,19 @@ */ if(!$at_least_one_image) { - echo linSysLog(i18n("No Images Available! Videos are currently not supported.")); - $error = true; + throw new Exception(i18n("No Images Available! Videos are currently not supported.")); } - elseif( - ($real_mail_size > $max_mail_size ) // only overhead of base64 (33%) - OR - ( !$no_mem_limit AND $real_mail_size > get_available_mem()) - ) + + + /** + * check if mail is getting to big + */ + if( + ($real_mail_size > $max_mail_size ) // only overhead of base64 (33%) + OR + ( !$no_mem_limit AND $real_mail_size > get_available_mem()) + ) { - linSysLog( - i18n("Error: The E-Mail is too big."). - "<br /><br />". - sprintf(i18n("Allowed size: %sBytes. Your selected images use %sBytes."),$max_mail_size,$real_mail_size). - "<br /><br />". - i18n("Remove some images or use the download zipped albums feature!") - ); - $error = true; - /** * but still delete images */ @@ -152,87 +148,95 @@ * delete temporary folder */ rmdir($tmp_folder); + + throw new Exception( + i18n("Error: The E-Mail is too big."). + "<br /><br />". + sprintf(i18n("Allowed size: %sBytes. Your selected images use %sBytes."),$max_mail_size,$real_mail_size). + "<br /><br />". + i18n("Remove some images or use the download zipped albums feature!") + ); } - if(!isset($error)) + include_once(LINPHA_DIR.'/lib/classes/phpmailer.class.php'); + + $mail = new PHPMailer(); + + $mail->IsSmtp(); + $mail->Host = "localhost"; + $mail->From = $_POST['sender_address']; + $mail->FromName = $_POST['sender_address']; // otherwise, a default name like "Root User" is taken + $mail->AddAddress($_POST['mail_address']); + $mail->Subject = $_POST['subject']; + $mail->Body = $_POST['text_message']; + + $d = dir($tmp_folder); + while (false !== ($entry = $d->read())) { - include_once(LINPHA_DIR.'/lib/classes/phpmailer.class.php'); - - $mail = new PHPMailer(); - - $mail->IsSmtp(); - $mail->Host = "localhost"; - $mail->From = $_POST['sender_address']; - $mail->FromName = $_POST['sender_address']; // otherwise, a default name like "Root User" is taken - $mail->AddAddress($_POST['mail_address']); - $mail->Subject = $_POST['subject']; - $mail->Body = $_POST['text_message']; - - $d = dir($tmp_folder); - while (false !== ($entry = $d->read())) + if($entry != '.' && $entry != '..') { - if($entry != '.' && $entry != '..') + if($_POST['mail_mode'] == "txt") { - if($_POST['mail_mode'] == "txt") - { - $handle = fopen($tmp_folder.'/'.$entry,"rb"); - $file_content = fread( $handle, filesize( $tmp_folder.'/'.$entry ) ); - fclose($handle); - - $mail->AddStringAttachment("$file_content", "$entry"); + $handle = fopen($tmp_folder.'/'.$entry,"rb"); + $file_content = fread( $handle, filesize( $tmp_folder.'/'.$entry ) ); + fclose($handle); - unlink($tmp_folder.'/'.$entry); - } - else - { - $image_filename = "$tmp_folder/$entry"; - - $mail->AddAttachment("$image_filename", "$entry", "base64", "image/jpeg"); - - /** - * We have to delete tmp files later, as AddAttachment() - * just adds a reference to the images and unlink would delete - * them before they were send out... - */ - $array_files[] = $image_filename; - } + $mail->AddStringAttachment("$file_content", "$entry"); + + unlink($tmp_folder.'/'.$entry); } + else + { + $image_filename = "$tmp_folder/$entry"; + + $mail->AddAttachment("$image_filename", "$entry", "base64", "image/jpeg"); + + /** + * We have to delete tmp files later, as AddAttachment() + * just adds a reference to the images and unlink would delete + * them before they were send out... + */ + $array_files[] = $image_filename; + } } - $d->close(); + } + $d->close(); + + if($_POST['mail_mode'] == "html") + { + $mail->IsHTML(true); + } - if($_POST['mail_mode'] == "html") + if(!$mail->Send()) + { + /** + * no exception, because we still need to delete the images + */ + linSysLog(i18n("Error: E-Mail couldn't be sent. Contact the Administrator.")); + } + + $mail->ClearAddresses(); + $mail->ClearAttachments(); + + /** + * delete temporary folder + */ + if($_POST['mail_mode'] == "html") + { + foreach($array_files as $filename) { - $mail->IsHTML(true); + unlink($filename); } - - if(!$mail->Send()) - { - linSysLog(i18n("Error: E-Mail couldn't be sent. Contact the Administrator.")); - $error = true; - } + } + rmdir($tmp_folder); - $mail->ClearAddresses(); - $mail->ClearAttachments(); - - /** - * delete temporary folder - */ - if($_POST['mail_mode'] == "html") - { - foreach($array_files as $filename) - { - unlink($filename); - } - } - rmdir($tmp_folder); - } -} - -if(!isset($error)) -{ linSysLog( i18n("Email Sent To").': '.$_POST['mail_address']. - '<br /><br />'.i18n("Size Of E-Mail").": ".niceFilesize($real_mail_size,1) + '<br />'.i18n("Size Of E-Mail").": ".niceFilesize($real_mail_size,1) ); } +catch(Exception $error) +{ + linSysLog("Error: ".$error -> getMessage()); +} ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |