Changeset 517
- Timestamp:
- 03/31/08 23:28:57 (8 months ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
admin/plog-admin-functions.php (modified) (4 diffs)
-
lib/plogger/form_setup.php (modified) (2 diffs)
-
lib/plogger/install_functions.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/plog-admin-functions.php
r509 r517 12 12 // Make sure the file exists 13 13 if($file != "." && $file != ".." && $file[0] != '.') { 14 // If it's a direct iry, list all files within it14 // If it's a directory, list all files within it 15 15 if(is_dir($directory . "/" . $file)) { 16 16 $tmp2 = get_files($directory . "/" . $file); … … 308 308 // a new row into collections table, otherwise the collection will not be usable 309 309 // anyway 310 $create_path = $config["basedir"] . " /images/".$collection_folder;310 $create_path = $config["basedir"] . "images/".$collection_folder; 311 311 312 312 // create directory … … 513 513 // first try to create the directory to hold the images, if that fails, then the album 514 514 // will be unusable anyway 515 $create_path = $config["basedir"] . " /images/".$row["collection_path"]."/".$album_folder;515 $create_path = $config["basedir"] . "images/".$row["collection_path"]."/".$album_folder; 516 516 517 517 if (!makeDirs($create_path, 0777)) { … … 878 878 function makeDirs($strPath, $mode = 0777) //creates directory tree recursively 879 879 { 880 return is_dir($strPath) or ( makeDirs(dirname($strPath), $mode) and mkdir($strPath, $mode) ); 880 if (ini_get('safe_mode')==1){ 881 return is_dir($strPath) or ( makeDirs(dirname($strPath), $mode) and FTP_makeDirs($strPath) ); 882 }else{ 883 return is_dir($strPath) or ( makeDirs(dirname($strPath), $mode) and mkdir($strPath, $mode) ); 884 } 885 } 886 887 function FTP_makeDirs($strPath){ 888 global $config; 889 890 $ftpserver = PLOGGER_FTP_HOST; 891 $ftpuser = PLOGGER_FTP_USER; 892 $ftppass = PLOGGER_FTP_PW; 893 894 $ftppath = str_replace($config["basedir"], '', $strPath); 895 $ftpDir = dirname($ftppath); 896 $ftpnewDir = str_replace($ftpDir."/", '', $ftppath); 897 898 // create connection 899 $ftpconnection = ftp_connect($ftpserver); 900 // login to ftp server 901 $ftpresult = ftp_login($ftpconnection, $ftpuser, $ftppass); 902 903 // check if connection was made 904 if ((!$ftpconnection) || (!$ftpresult)) { 905 return false; 906 }else{ 907 ftp_chdir($ftpconnection, PLOGGER_FTP_PATH.$ftpDir); // go to destination dir 908 $ftpcreatedir = @ftp_mkdir($ftpconnection, $ftpnewDir); // create directory 909 if ($ftpcreatedir == true){ 910 $ftpexecdir = @ftp_site($ftpconnection, 'chmod 0777 '.$ftpnewDir.'/'); 911 }else{ 912 return false; 913 } 914 if ($ftpexecdir == true){ 915 return true; 916 }else{ 917 return false; 918 } 919 ftp_close($ftpconnection); // close connection 920 } 881 921 } 882 922 -
trunk/lib/plogger/form_setup.php
r433 r517 13 13 <div id="navcontainer"> 14 14 <h1>Database Setup</h1> 15 </div> 15 16 </td> 16 17 </tr> … … 48 49 <td class="form_input"><input type="text" name="admin_email" id="email" value="<?=$form['admin_email']?>" /></td> 49 50 </tr> 51 <?php 52 //if server is safe_mode enabled, prompt user for FTP info for FTP workaround 53 if (ini_get('safe_mode')==1){?> 54 <tr> 55 <td colspan="2"> 56 <div id="navcontainer"> 57 <h1>Safe_mode FTP workaround</h1> 58 <br/>Safe mode has been detected on your server. FTP access is needed to allow Plogger to work correctly with safe_mode=on. 59 </div> 60 </td> 61 </tr> 50 62 <tr> 63 <td class="form_label"><label for="ftp_host">FTP Host:</label></td> 64 <td class="form_input"><input type="text" name="ftp_host" id="ftp_host" value="<?=$form['ftp_host']?>" /></td> 65 </tr> 66 <tr> 67 <td class="form_label"><label for="ftp_user">FTP Username:</label></td> 68 <td class="form_input"><input type="text" name="ftp_user" id="ftp_user" value="<?=$form['ftp_user']?>" /></td> 69 </tr> 70 <tr> 71 <td class="form_label"><label for="ftp_password">FTP Password:</label></td> 72 <td class="form_input"><input type="password" name="ftp_pass" id="ftp_pass" value="<?=$form['ftp_pass']?>" /></td> 73 </tr> 74 <tr> 75 <td class="form_label"><label for="ftp_name">FTP Path to Plogger Folder (from FTP login):</label></td> 76 <td class="form_input"><input type="text" name="ftp_path" id="ftp_path" value="<?=$form['ftp_path']?>" /></td> 77 </tr> 78 <?php } //end safe_mode workaround ?> 79 <tr> 51 80 <td class="submitButtonRow" colspan="2"> 52 81 <input type="submit" name="submit" id="submit" value="Install" /> -
trunk/lib/plogger/install_functions.php
r509 r517 54 54 if (empty($form['admin_email'])) { 55 55 $errors[] = 'Please enter your e-mail address.'; 56 }; 57 58 if (ini_get('safe_mode')==1) { 59 //if safe_mode enabled, check the FTP information form inputs 60 if (empty($form['ftp_host'])) { 61 $errors[] = 'Please enter the name of your FTP host.'; 62 }; 63 64 if (empty($form['ftp_user'])) { 65 $errors[] = 'Please enter the FTP username.'; 66 }; 67 68 if (empty($form['ftp_pass'])) { 69 $errors[] = 'Please enter the FTP password.'; 70 } 71 72 if (!empty($form['ftp_path'])) { 73 if (substr($form['ftp_path'],0,1)!="/"){ 74 $form['ftp_path']="/".$form['ftp_path']; 75 }; 76 if (substr($form['ftp_path'],-1)!="/"){ 77 $form['ftp_path']=$form['ftp_path']."/"; 78 }; 79 } 56 80 }; 57 81 … … 74 98 ); 75 99 76 $conf = create_config_file($form['db_host'],$form['db_user'],$form['db_pass'],$form['db_name'] );100 $conf = create_config_file($form['db_host'],$form['db_user'],$form['db_pass'],$form['db_name'],$form['ftp_host'],$form['ftp_user'],$form['ftp_pass'],$form['ftp_path']); 77 101 // if configuration file is writable, then set the values 78 102 // otherwise serve the config file to user and ask her to … … 92 116 $form['db_host'] = 'localhost'; 93 117 }; 94 95 $init_vars = array('db_user','db_pass','db_name','gallery_name','admin_email'); 118 if (empty($form['ftp_host'])) { 119 $form['ftp_host'] = 'localhost'; 120 }; 121 122 $init_vars = array('db_user','db_pass','db_name','gallery_name','admin_email','ftp_user','ftp_pass','ftp_path'); 96 123 foreach($init_vars as $var) { 97 124 if (empty($form[$var])) { … … 299 326 } 300 327 301 function create_config_file($db_host,$db_user,$db_pass,$db_name ) {328 function create_config_file($db_host,$db_user,$db_pass,$db_name,$ftp_host,$ftp_user,$ftp_pass,$ftp_path) { 302 329 $cfg_file = "<?php\n"; 303 330 $cfg_file .= '// this is the file used to connect to your database.'."\n"; … … 310 337 $cfg_file .= '// define("PLOGGER_EMBEDDED",""); // 1/0 (True/False) if set will overrule automatic check'."\n"; 311 338 $cfg_file .= '// define("PLOGGER_LOCALE",""); // da_DK de et fr pl ro_RO tr ...etc.'."\n"; 339 if (ini_get('safe_mode')==1) { 340 //if safe_mode enabled, write the FTP workaround information to plog-config.php with db information 341 $cfg_file .= "\n"; 342 $cfg_file .= '// these values are used to connect via FTP.'."\n"; 343 $cfg_file .= 'define("PLOGGER_FTP_HOST","'.$ftp_host.'");'."\n"; 344 $cfg_file .= 'define("PLOGGER_FTP_USER","'.$ftp_user.'");'."\n"; 345 $cfg_file .= 'define("PLOGGER_FTP_PW","'.$ftp_pass.'");'."\n"; 346 $cfg_file .= 'define("PLOGGER_FTP_PATH","'.$ftp_path.'");'."\n"; 347 }; 312 348 313 349 $cfg_file .= "?>\n";
