Changeset 533
- Timestamp:
- 04/24/08 16:31:41 (7 months ago)
- Location:
- trunk
- Files:
-
- 5 modified
-
_install.php (modified) (2 diffs)
-
lib/plogger/form_setup.php (modified) (3 diffs)
-
lib/plogger/form_setup_complete.php (modified) (2 diffs)
-
lib/plogger/install_functions.php (modified) (17 diffs)
-
plog-functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/_install.php
r494 r533 13 13 }; 14 14 15 // try to proceed to the admin interface. Only succeeds if the configuration is set 15 // Create the SQL tables and try to proceed to the admin interface. 16 // Only proceeds if the configuration is set. 16 17 if (!empty($_POST['proceed']) && defined('PLOGGER_DB_HOST')) { 17 18 $mysql = check_mysql(PLOGGER_DB_HOST,PLOGGER_DB_USER,PLOGGER_DB_PW,PLOGGER_DB_NAME); … … 22 23 connect_db(); 23 24 $col = add_collection(plog_tr("Plogger test collection"),plog_tr("Feel free to delete it")); 24 $alb = add_album(plog_tr("Plogger test album"),plog_tr("feel free to delete it"),$col["id"]); // undefined index id 25 // only attempt to create an album if the collection was created - sloppy fix for multiple installs 26 if (!empty($col['id'])) { 27 $alb = add_album(plog_tr("Plogger test album"),plog_tr("feel free to delete it"),$col['id']); 28 } 25 29 unset($_SESSION["plogger_config"]); 26 30 unset($_SESSION["install_values"]); -
trunk/lib/plogger/form_setup.php
r527 r533 4 4 }; 5 5 ?> 6 <h1>Plogger Installation</h1>7 <p>To install, simply fill out the following form. If there are any problems, you will be notified and asked to fix them before the installation will continue. After the installation has finished, you will be redirected to your Plogger homepage.</p>6 <h1>Plogger Configuration Setup</h1> 7 <p>To install, simply fill out the following form. If there are any problems, you will be notified and asked to fix them before the installation will continue. After the installation has finished, you will be redirected to the Plogger admin page.</p> 8 8 <form action="_install.php" method="post"> 9 9 <input type="hidden" name="action" value="install" /> … … 73 73 </tr> 74 74 <tr> 75 <td class="form_label"><label for="ftp_path">FTP Path to Plogger Folder (from FTP login):</label></td>75 <td class="form_label"><label for="ftp_path">FTP Path to Plogger Base Folder (from FTP login):</label></td> 76 76 <td class="form_input"><input type="text" name="ftp_path" id="ftp_path" value="<?=$form['ftp_path']?>" /></td> 77 77 </tr> … … 79 79 <tr> 80 80 <td class="submitButtonRow" colspan="2"> 81 <input type="submit" name="submit" id="submit" value=" Install" />81 <input type="submit" name="submit" id="submit" value="Proceed" /> 82 82 </td> 83 83 </tr> -
trunk/lib/plogger/form_setup_complete.php
r422 r533 4 4 }; 5 5 ?> 6 <h1>Plogger Install</h1> 6 7 <form method="POST"> 7 <p> Setup is now complete</p>8 <p>Configuration setup is now complete.<br/>Click 'Install' to finish installation.</p> 8 9 <p>Your username is <?=$_SESSION['install_values']['admin_username']?> and your password is `<?=$_SESSION['install_values']['admin_password']?>`</p> 9 10 <?php if (!empty($_SESSION["plogger_config"])) { ?> … … 11 12 <?php } ?> 12 13 <p> 13 <input type="submit" name="proceed" value=" Proceed"/>14 <input type="submit" name="proceed" value="Install"/> 14 15 </p> 15 16 </form> -
trunk/lib/plogger/install_functions.php
r530 r533 13 13 foreach($errors as $error) { 14 14 print '<li>' . $error . '</li>'; 15 } ;15 } 16 16 print '</ul>'; 17 17 print '<form method="GET" action="_install.php"><input type="submit" value="Try again"/></form>'; 18 18 return false; 19 } ;19 } 20 20 21 21 if (defined('PLOGGER_DB_HOST')) { … … 25 25 print '<p>Plogger is already installed!</p>'; 26 26 return false; 27 } ;28 } ;27 } 28 } 29 29 30 30 $ok = false; … … 34 34 if (empty($form['db_host'])) { 35 35 $errors[] = 'Please enter the name of your MySQL host.'; 36 } ;36 } 37 37 38 38 if (empty($form['db_user'])) { 39 39 $errors[] = 'Please enter the MySQL username.'; 40 } ;40 } 41 41 42 42 if (empty($form['db_pass'])) { 43 $errors[] = 'Please enter the MySQL password.';44 }43 $errors[] = 'Please enter the MySQL password.'; 44 } 45 45 46 46 if (empty($form['db_name'])) { 47 47 $errors[] = 'Please enter the MySQL database name.'; 48 } ;48 } 49 49 50 50 if (empty($form['gallery_name'])) { 51 51 $errors[] = 'Please enter the name for your gallery.'; 52 } ;52 } 53 53 54 54 if (empty($form['admin_email'])) { 55 55 $errors[] = 'Please enter your e-mail address.'; 56 } ;56 } 57 57 58 if (ini_get('safe_mode')==1) {59 //if safe_mode enabled, check the FTP information form inputs58 if (ini_get('safe_mode')==1) { 59 //if safe_mode enabled, check the FTP information form inputs 60 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 }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 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 }80 } ;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 } 80 } 81 81 82 82 if (empty($errors)) { 83 $errors = check_mysql($form['db_host'],$form['db_user'],$form['db_pass'],$form['db_name']); 83 $mysql_errors = check_mysql($form['db_host'],$form['db_user'],$form['db_pass'],$form['db_name']); 84 if (ini_get('safe_mode')==1) { 85 $ftp_errors = check_FTP($form['ftp_host'], $form['ftp_user'], $form['ftp_pass'], $form['ftp_path']); 86 }else{ 87 $ftp_errors = array(); 88 } 89 $errors = array_merge($mysql_errors, $ftp_errors); 84 90 $ok = empty($errors); 85 } ;91 } 86 92 87 93 if (!$ok) { … … 106 112 } else { 107 113 $_SESSION["plogger_config"] = $conf; 108 } ;114 } 109 115 require(PLOGGER_DIR . 'lib/plogger/form_setup_complete.php'); 110 116 return true; 111 } ;112 } ;117 } 118 } 113 119 114 120 // most of the time it's probably running on localhost 115 121 if (empty($form['db_host'])) { 116 122 $form['db_host'] = 'localhost'; 117 } ;123 } 118 124 if (empty($form['ftp_host'])) { 119 125 $form['ftp_host'] = 'localhost'; 120 } ;126 } 121 127 122 128 $init_vars = array('db_user','db_pass','db_name','gallery_name','admin_email','ftp_user','ftp_pass','ftp_path'); … … 124 130 if (empty($form[$var])) { 125 131 $form[$var] = ""; 126 } ;127 } ;132 } 133 } 128 134 require(PLOGGER_DIR . 'lib/plogger/form_setup.php'); 129 135 } … … 139 145 if (1 == version_compare($mysql_version,$mysql_charset_support)) { 140 146 $default_charset = "DEFAULT CHARACTER SET UTF8"; 141 } ;147 } 142 148 143 149 maybe_add_table( … … 283 289 VALUES('$key','$long_ago','$size')"; 284 290 mysql_query($sql); 285 } ;291 } 286 292 287 293 $config['default_theme_dir'] = PLOGGER_DIR . 'themes/default/'; … … 293 299 294 300 $config = array_map('mysql_real_escape_string',$config); 295 296 $query = "INSERT INTO `".TABLE_PREFIX."config` 297 (`theme_dir`, 298 `compression`, 299 `max_thumbnail_size`, 300 `max_display_size`, 301 `thumb_num`, 302 `admin_username`, 303 `admin_email`, 304 `admin_password`, 305 `date_format`, 306 `feed_title`, 307 `gallery_name`, 308 `gallery_url`) 309 VALUES 310 ('${config['default_theme_dir']}', 311 75, 312 100, 313 500, 314 20, 315 '${config['admin_username']}', 316 '${config['admin_email']}', 317 MD5('${config['admin_password']}'), 318 'n.j.Y', 319 'Plogger Photo Feed', 320 '${config['gallery_name']}', 321 '${config['baseurl']}')"; 301 302 $row_exist = mysql_query("SELECT * FROM `".TABLE_PREFIX."config`"); 303 $row_exist_num = mysql_num_rows($row_exist); 304 305 if ($row_exist_num == 0) { 306 $query = "INSERT INTO `".TABLE_PREFIX."config` 307 (`theme_dir`, 308 `compression`, 309 `max_thumbnail_size`, 310 `max_display_size`, 311 `thumb_num`, 312 `admin_username`, 313 `admin_email`, 314 `admin_password`, 315 `date_format`, 316 `feed_title`, 317 `gallery_name`, 318 `gallery_url`) 319 VALUES 320 ('${config['default_theme_dir']}', 321 75, 322 100, 323 500, 324 20, 325 '${config['admin_username']}', 326 '${config['admin_email']}', 327 MD5('${config['admin_password']}'), 328 'n.j.Y', 329 'Plogger Photo Feed', 330 '${config['gallery_name']}', 331 '${config['baseurl']}')"; 332 } else { 333 $query = "UPDATE `".TABLE_PREFIX."config` SET 334 `theme_dir` = '${config['default_theme_dir']}', 335 `compression` = 75, 336 `max_thumbnail_size` = 100, 337 `max_display_size` = 500, 338 `thumb_num` = 20, 339 `admin_username` = '${config['admin_username']}', 340 `admin_email` = '${config['admin_email']}', 341 `admin_password` = MD5('${config['admin_password']}'), 342 `date_format` = 'n.j.Y', 343 `feed_title` = 'Plogger Photo Feed', 344 `gallery_name` = '${config['gallery_name']}', 345 `gallery_url` = '${config['baseurl']}'"; 346 } 322 347 323 348 mysql_query($query) or die(mysql_error().'<br /><br />'. $query); 324 349 325 mail($config['admin_email'],"Your new gallery","You have successfully installed your new Plogger gallery. You can manage it at ${config['baseurl']} /admin Username is ${config['admin_username']} and password ${config['admin_password']}.");350 mail($config['admin_email'],"Your new gallery","You have successfully installed your new Plogger gallery. You can manage it at ${config['baseurl']}admin Username is ${config['admin_username']} and password ${config['admin_password']}."); 326 351 } 327 352 … … 332 357 $cfg_file .= 'define("PLOGGER_DB_HOST","'.$db_host.'");'."\n"; 333 358 $cfg_file .= 'define("PLOGGER_DB_USER","'.$db_user.'");'."\n"; 334 $cfg_file .= 'define("PLOGGER_DB_PW","'. $db_pass.'");'."\n";359 $cfg_file .= 'define("PLOGGER_DB_PW","'.addcslashes($db_pass, '\\$"').'");'."\n"; // escape certain password characters stored in double quotes (\) ($) (") 335 360 $cfg_file .= 'define("PLOGGER_DB_NAME","'.$db_name.'");'."\n"; 336 361 $cfg_file .= ''."\n"; 337 362 $cfg_file .= '// define("PLOGGER_EMBEDDED",""); // 1/0 (True/False) if set will overrule automatic check'."\n"; 338 363 $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 information341 $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 }; 364 if (ini_get('safe_mode')==1) { 365 //if safe_mode enabled, write the FTP workaround information to plog-config.php with db information 366 $cfg_file .= "\n"; 367 $cfg_file .= '// these values are used to connect via FTP.'."\n"; 368 $cfg_file .= 'define("PLOGGER_FTP_HOST","'.$ftp_host.'");'."\n"; 369 $cfg_file .= 'define("PLOGGER_FTP_USER","'.$ftp_user.'");'."\n"; 370 $cfg_file .= 'define("PLOGGER_FTP_PW","'.addcslashes($ftp_pass, '\\$"').'");'."\n"; // escape certain password characters stored in double quotes (\) ($) (") 371 $cfg_file .= 'define("PLOGGER_FTP_PATH","'.$ftp_path.'");'."\n"; 372 } 348 373 349 374 $cfg_file .= "?>\n"; … … 358 383 while($row = mysql_fetch_array($res,MYSQL_NUM)) { 359 384 if ($row[0] == $column) $found = true; 360 } ;385 } 361 386 if (!$found) { 362 387 mysql_query("ALTER TABLE $table ADD `$column` ". $add_sql); … … 364 389 } else { 365 390 return "<li>$column already present in database."; 366 } ;391 } 367 392 } 368 393 … … 373 398 while($row = mysql_fetch_array($res,MYSQL_NUM)) { 374 399 if ($row[0] == $column) $found = true; 375 } ;400 } 376 401 if ($found) { 377 402 $sql = "ALTER TABLE $table DROP `$column`"; … … 380 405 } else { 381 406 //print "$column does not exist<br/>"; 382 } ;407 } 383 408 } 384 409 … … 391 416 if (mysql_error()) { 392 417 var_dump(mysql_error()); 393 } ;418 } 394 419 } else { 395 420 return "<li>Table `$table` already exists, ignoring."; 396 } ;421 } 397 422 } 398 423 … … 407 432 if (gd_missing()) { 408 433 $errors[] = "PHP GD module was not detected."; 409 } ;434 } 410 435 411 436 if (!function_exists('mysql_connect')) { 412 437 $errors[] = "PHP MySQL module was not detected."; 413 } ;438 } 414 439 415 440 $files_to_read = array("./","./admin","./css","./images","./lib","./thumbs","./uploads"); … … 437 462 $errors[] = "Cannot connect to MySQL with the information provided. MySQL error: " 438 463 . mysql_error(); 439 } ;440 } ;464 } 465 } 441 466 $select = @mysql_select_db($database); 442 467 if (!$select) { 443 468 $errors[] = "Couldn't find the database $database. MySQL error: " . mysql_error(); 444 469 445 }; 470 } 471 return $errors; 472 } 473 474 function check_FTP($host, $user, $pass, $path) { 475 $errors = array(); 476 477 $connection = @ftp_connect($host); 478 if (!$connection) { 479 $errors[] = "Couldn't connect to FTP host \"$host\". Please check your FTP Host:"; 480 } else { 481 $login = @ftp_login($connection, $user, $pass); 482 if (!$login) { 483 $errors[] = "Couldn't login to FTP host \"$host\" with username \"$user\" and password \"$pass\". Please check your FTP Username: and FTP Password:"; 484 } else { 485 $checkdir = @ftp_chdir($connection, $path."images/"); // check to see if the images/ folder is accessible 486 if (!$checkdir) { 487 $errors[] = "Couldn't find the Plogger images\ folder along the path \"$path\". Please check your FTP Path to Plogger Base Folder (from FTP login):"; 488 } 489 } 490 } 491 @ftp_close($connection); 446 492 return $errors; 447 493 } … … 457 503 if (file_exists($cf)) { 458 504 return is_writable($cf); 459 } ;505 } 460 506 return is_writable(PLOGGER_DIR); 461 507 } -
trunk/plog-functions.php
r531 r533 1093 1093 $pic = get_picture_by_id($id); 1094 1094 $album = $pic["parent_album"]; 1095 $rv = $config["baseurl"].s ubstr(SmartStripSlashes($pic['path']), 0, -4);1095 $rv = $config["baseurl"].str_replace("%2F", "/", rawurlencode(substr(SmartStripSlashes($pic['path']), 0, -4))); 1096 1096 } 1097 1097 } else {
