[Linpha-cvs] SF.net SVN: linpha: [4554] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <bz...@us...> - 2006-07-09 18:46:35
|
Revision: 4554 Author: bzrudi Date: 2006-07-09 11:46:23 -0700 (Sun, 09 Jul 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4554&view=rev Log Message: ----------- fixed bug in sqlite install Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/install/lib.install.php trunk/linpha2/install/sql/sql.sqlite.php trunk/linpha2/install/step4_selectdirectories.php trunk/linpha2/install/step5_getlogin.php trunk/linpha2/install/step7_selectprefix.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-29 22:13:09 UTC (rev 4553) +++ trunk/linpha2/ChangeLog 2006-07-09 18:46:23 UTC (rev 4554) @@ -1,3 +1,12 @@ +2006-07-09 bzrudi + * install: fixed bug in sqlite install - $_SESSION vars not inited and initial + directories (sql/tmp/cache) under /var not created. Moved some functions to + lib.install.php as we need them in different places. + This was caused because we skipped step 5+6 during install if using SQLlite + where vars and directories are inited... + * fixed bug in sql.sqlite.php (parse error, tables not created) + * tested install under MySQL 5.0.18 -> worked! :-) + 2006-04-29 flo * filemanager: implementing upload only images and videos, escape filenames correct (-> create a folder and file called "<script>" and you will find things which needs to be escaped) Modified: trunk/linpha2/install/lib.install.php =================================================================== --- trunk/linpha2/install/lib.install.php 2006-04-29 22:13:09 UTC (rev 4553) +++ trunk/linpha2/install/lib.install.php 2006-07-09 18:46:23 UTC (rev 4554) @@ -199,7 +199,7 @@ { if( ! installIsAbsolutePath( $path ) ) { - $path = realpath( $path ); + $path = str_ireplace("../", " ", $path ); } /** @@ -248,7 +248,8 @@ function installIsAbsolutePath($path) { if(substr($path,0,1) == '/' OR // string begins with a '/' -> absolut path - ((strpos($path, ':') !== false) AND (strpos( PHP_OS, 'WIN' ) !== FALSE)) // we are on windows and the string contains a ':' -> absolut path (c:/..) + ((strpos($path, ':') !== false) AND (strpos( PHP_OS, 'WIN' ) !== FALSE)) + // we are on windows and the string contains a ':' -> absolut path (c:/..) ) { // absolut path return true; } else { @@ -407,7 +408,117 @@ return $str; } +/** + * As we need this twice make it a method. This is because we skip steps + * 5+6 when using sqlite but still need to init values + * @author bzrudi + * @param none + * @return array $dirs + * @package filesys + */ +function initSessionValues() +{ +/** + * save settings from previous page into global $_SESSION var + */ + $array = array('album','sql','cache','tmp'); + foreach($array AS $value) + { + /** + * remove '/' if not already done + */ + $len = strlen( $_POST[$value.'_dir'] ); + $lastsign = substr( $_POST[$value.'_dir'], $len-1); + if($lastsign == '/' && $lastsign == '\\') + { + $_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] = installGetFullPath( $_SESSION[$value.'_dir'] ); + } +return $dirs; +} +/** + * As we need this twice make it a method. This is because we skip steps + * 5+6 when using sqlite but still need to init directories below /var + * @author bzrudi + * @param none + * @return true|false + * @package filesys + */ +function initInitialDirectories($dirs) +{ +$init_ok = true; +echo tr("Creating Required Directories")."... "; + try + { + $array = array('sql','cache','tmp'); + foreach($array AS $value) + { + echo "<br /><br />".tr("Checking Directory").": ".$value."..."; + + 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")."... "; + if( installRm_rf( $dirs[$value] ) ) + { + echo success_msg(); + } + else + { + throw new Exception(failed_msg()."<br />".tr("Please Delete Folder Manually")); + } + } + else + { + throw new Exception(failed_msg()."<br />".tr("Please Delete Folder Manually")); + } + } + + echo "<br /> ".tr("Trying To Create Directory")."... "; + if( installMkdir_p( $dirs[$value] ) ) + { + echo success_msg(); + + if( ! is_writable( $dirs[$value] ) ) + { + echo "<br />".tr("No Write Permissions. Please Change Permissions Manually!"); + } + } + else + { + throw new Exception(failed_msg()."<br />".tr("Cannot create folder, please check permissions!")); + } + + echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.installLinRealpath( $dirs[$value] ).')<br />'; + } + } + catch(Exception $error) + { + echo "Error: ".$error -> getMessage(); + $init_ok = false; + } + +return $init_ok; +} + + ?> \ No newline at end of file Modified: trunk/linpha2/install/sql/sql.sqlite.php =================================================================== --- trunk/linpha2/install/sql/sql.sqlite.php 2006-04-29 22:13:09 UTC (rev 4553) +++ trunk/linpha2/install/sql/sql.sqlite.php 2006-07-09 18:46:23 UTC (rev 4554) @@ -35,8 +35,8 @@ "password VARCHAR(32) NOT NULL default '' , " . "user_email VARCHAR(255) NOT NULL default '' , " . "display_name VARCHAR(255) NOT NULL default '' , " . - "stats_downloads INTEGER NOT NULL default '0'' , " . - "stats_downloads_size INTEGER NOT NULL default '0'' " . + "stats_downloads INTEGER NOT NULL default '0' , " . + "stats_downloads_size INTEGER NOT NULL default '0' " . ")", "CREATE TABLE ".$linpha_tables['groups']." ( ". "id INTEGER PRIMARY KEY, " . Modified: trunk/linpha2/install/step4_selectdirectories.php =================================================================== --- trunk/linpha2/install/step4_selectdirectories.php 2006-04-29 22:13:09 UTC (rev 4553) +++ trunk/linpha2/install/step4_selectdirectories.php 2006-07-09 18:46:23 UTC (rev 4554) @@ -70,7 +70,7 @@ <input class="boxalignelement" type="text" id="check01" onKeyup="checkForm()" name="album_dir" size="30" value="<?php echo $album_dir; ?>"> </div> -(-> <?php echo installLinRealpath( installGetFullPath($album_dir) ); ?>) +(-> <?php echo installLinRealpath( installGetFullPath($album_dir) ) ?>) <br /><br /> <h2><?php echo tr("Warning: All Existing Subdirectories Will Be Deleted"); ?></h2> @@ -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 installLinRealpath( installGetFullPath($sql_dir) ); ?>) +(-> <?php echo installLinRealpath( installGetFullPath($sql_dir) );?>) <br /><br /> <div class="boxalign"> Modified: trunk/linpha2/install/step5_getlogin.php =================================================================== --- trunk/linpha2/install/step5_getlogin.php 2006-04-29 22:13:09 UTC (rev 4553) +++ trunk/linpha2/install/step5_getlogin.php 2006-07-09 18:46:23 UTC (rev 4554) @@ -47,34 +47,11 @@ exit(); } -/** - * save settings from previous page - */ - $array = array('album', 'sql','cache','tmp'); - foreach($array AS $value) - { - /** - * remove '/' if not already done - */ - $len = strlen( $_POST[$value.'_dir'] ); - $lastsign = substr( $_POST[$value.'_dir'], $len-1); - if($lastsign == '/' && $lastsign == '\\') - { - $_POST[$value.'_dir'] = substr($_POST[$value.'_dir'],0,$len-1); - } + /** + * save settings from previous page + */ + $dirs = initSessionValues(); - /** - * 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] = installGetFullPath( $_SESSION[$value.'_dir'] ); - } - /** * goto manual mode */ @@ -120,60 +97,8 @@ /** * checking sql, cache and tmp directory */ - try + if(initInitialDirectories($dirs) != true) { - $array = array('sql','cache','tmp'); - foreach($array AS $value) - { - echo "<br /><br />".tr("Checking Directory").": ".$value."..."; - - 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")."... "; - if( installRm_rf( $dirs[$value] ) ) - { - echo success_msg(); - } - else - { - throw new Exception(failed_msg()."<br />".tr("Please Delete Folder Manually")); - } - } - else - { - throw new Exception(failed_msg()."<br />".tr("Please Delete Folder Manually")); - } - } - - echo "<br /> ".tr("Trying To Create Directory")."... "; - if( installMkdir_p( $dirs[$value] ) ) - { - echo success_msg(); - - if( ! is_writable( $dirs[$value] ) ) - { - echo "<br />".tr("No Write Permissions. Please Change Permissions Manually!"); - } - } - else - { - throw new Exception(failed_msg()."<br />".tr("Cannot create folder, please check permissions!")); - } - - echo '<br /> ('.$_SESSION[$value.'_dir'].' => '.installLinRealpath( $dirs[$value] ).')<br />'; - } - } - catch(Exception $error) - { - echo "Error: ".$error -> getMessage(); - $show_next_button = false; include_once(LINPHA_DIR.'/install/footer.php'); exit(); Modified: trunk/linpha2/install/step7_selectprefix.php =================================================================== --- trunk/linpha2/install/step7_selectprefix.php 2006-04-29 22:13:09 UTC (rev 4553) +++ trunk/linpha2/install/step7_selectprefix.php 2006-07-09 18:46:23 UTC (rev 4554) @@ -130,43 +130,11 @@ } break; case "sqlite": + $dirs = initSessionValues(); + initInitialDirectories($dirs); echo tr("Testing File Connection")."<br /><br />"; echo tr("Connecting SQLite Database")."... "; - /** - * save settings from previous page - * this is required for sqlite only as we skip step 4-6 and therefore - * need to init values again here - */ - $array = array('album', 'sql','cache','tmp'); - foreach($array AS $value) - { - if( isset( $_POST[$value.'_dir'] ) ) - { - /** - * 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'] = $_POST[$value.'_dir']; - } - - /** - * get correct dir names (take care of relativ and absolute paths, add - * LINPHA_DIR if necessary) - */ - $dirs[$value] = installGetFullPath( $_SESSION[$value.'_dir'] ); - } + if(file_exists(LINPHA_DIR.'/'.$_SESSION['sql_dir'].'/'.$_SESSION['sql_dbname'])) { echo failed_msg(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |