if (isset($_POST['proceed']) || $configured) { // If not DB information not defined, prompt the user to download the plog-config.php file if (!defined('PLOGGER_DB_HOST')) { echo "\n\t" . '<h1>' . plog_tr('Plogger Configuration Complete') . '</h1>'; echo "\n\n\t" . '<form action="_install.php" method="post">'; echo "\n\n\t\t" . '<p>' . plog_tr('Configuration setup is now complete.') . '</p>'; echo "\n\n\t\t" . '<p>' . plog_tr('Click <strong>Install</strong> to complete the installation.') . '</p>'; if (!empty($_SESSION['plogger_config'])) { echo "\n\n\t\t" . '<p>' . sprintf(plog_tr('Before you can proceed, please %s to download configuration file for your gallery, then upload it to your webhost (into the same directory where you installed Plogger itself).'), '<input type="submit" class="submit-inline" name="dlconfig" value="' . plog_tr('click here') . '" />') . '</p>'; } echo "\n\n\t\t" . '<p><input type="submit" class="submit" name="proceed" id="proceed" value="' . plog_tr('Install') . '" /></p>'; echo "\n\n\t" . '</form>' . "\n"; // Otherwise, do the install } else { $errors = array(); $sql = check_pdo(PLOGGER_DB_TYPE, PLOGGER_DB_HOST, PLOGGER_DB_USER, PLOGGER_DB_PW, PLOGGER_DB_NAME, PLOGGER_DB_PORT); if (count($sql) == 0) { create_tables(PLOGGER_DB_TYPE); configure_plogger($_SESSION['install_values']); // undefined index install_values include_once PLOGGER_DIR . 'plog-load-config.php'; // If open permissions, have Plogger fix them if (isset($_SESSION['plogger_close_perms'])) { fix_open_perms($_SESSION['plogger_close_perms'], 'delete'); } $col = add_collection(plog_tr('Plogger Test Collection'), plog_tr('Feel free to delete it')); // Only attempt to create an album if the collection was created - sloppy fix for multiple installs if (!empty($col['id'])) { $alb = add_album(plog_tr('Plogger Test Album'), plog_tr('Feel free to delete it'), $col['id']); } } else {
function check_pdo_pgsql() { global $loaded_extensions; if (!check_pdo()) { return new CheckResult(false); } return new CheckResult(isset($loaded_extensions['pdo_pgsql'])); }
function do_install($form) { $form = array_map('stripslashes', $form); $form = array_map('trim', $form); // First check the requirements $errors = check_requirements(); if (sizeof($errors) > 0) { echo "\t" . '<p class="errors">' . plog_tr('Plogger cannot be installed until the following problems are resolved') . ':</p>'; echo "\n\n\t\t" . '<ul class="info">'; foreach ($errors as $error) { echo "\n\t\t\t" . '<li class="margin-5">' . $error . '</li>'; } echo "\n\t\t" . '</ul>'; echo "\n\n\t" . '<form method="get" action="' . $_SERVER['REQUEST_URI'] . '"> <p><input class="submit" type="submit" value="' . plog_tr('Try again') . '" /></p> </form>' . "\n"; return false; } $ok = false; $errors = array(); // If we've already defined the database information, pass the values and skip them on the form if (defined('PLOGGER_DB_HOST')) { $pdocheck = check_pdo(PLOGGER_DB_TYPE, PLOGGER_DB_HOST, PLOGGER_DB_USER, PLOGGER_DB_PW, PLOGGER_DB_NAME, PLOGGER_DB_PORT); if (count($pdocheck) > 0) { $sql_fail = true; } else { unset($_SESSION['plogger_config']); } // Set the form values equal to config values if already set if (empty($form['db_host'])) { $form['db_host'] = PLOGGER_DB_HOST; } if (empty($form['db_user'])) { $form['db_user'] = PLOGGER_DB_USER; } if (empty($form['db_pass'])) { $form['db_pass'] = PLOGGER_DB_PW; } if (empty($form['db_name'])) { $form['db_name'] = PLOGGER_DB_NAME; } if (empty($form['db_type'])) { $form['db_type'] = PLOGGER_DB_TYPE; } if (empty($form['db_port'])) { $form['db_port'] = PLOGGER_DB_PORT; } } if (isset($form['action']) && $form['action'] == 'install') { if (!defined('PLOGGER_DB_HOST') || isset($sql_fail)) { $sql_form_check = check_sql_form($form); if (!empty($sql_form_check)) { $errors = array_merge($errors, $sql_form_check); } } if (empty($form['gallery_name'])) { $errors[] = plog_tr('Please enter the name for your gallery.'); } if (empty($form['admin_email'])) { $errors[] = plog_tr('Please enter your email address.'); } if (empty($form['admin_username'])) { $errors[] = plog_tr('Please enter a username.'); } if (empty($form['admin_password'])) { $errors[] = plog_tr('Please enter a password.'); } if ($form['admin_password'] != $form['admin_password_confirm']) { $errors[] = plog_tr('Your passwords do not match. Please try again.'); } if (is_safe_mode()) { // If safe_mode enabled, check the FTP information form inputs $ftp_form_check = check_ftp_form($form); $form = $ftp_form_check['form']; if (!empty($ftp_form_check['form']['errors'])) { $errors = array_merge($errors, $ftp_form_check['form']['errors']); } } if (empty($errors)) { $sql_errors = check_pdo($form['db_type'], $form['db_host'], $form['db_user'], $form['db_pass'], $form['db_name'], $form['db_port']); if (is_safe_mode()) { $ftp_errors = check_ftp($form['ftp_host'], $form['ftp_user'], $form['ftp_pass'], $form['ftp_path']); } else { $ftp_errors = array(); } $errors = array_merge($sql_errors, $ftp_errors); $ok = empty($errors); } if (!$ok) { echo '<ul class="errors" style="background-image: none;">' . "\n\t" . '<li class="margin-5">'; echo join("</li>\n\t<li class=\"margin-5\">", $errors); echo "</li>\n</ul>\n\n"; } else { $_SESSION['install_values'] = array('gallery_name' => $form['gallery_name'], 'admin_email' => $form['admin_email'], 'admin_password' => $form['admin_password'], 'admin_username' => $form['admin_username']); if (is_safe_mode()) { $_SESSION['ftp_values'] = array('ftp_host' => $form['ftp_host'], 'ftp_user' => $form['ftp_user'], 'ftp_pass' => $form['ftp_pass'], 'ftp_path' => $form['ftp_path']); } if (!defined('PLOGGER_DB_HOST') || isset($sql_fail)) { // Serve the config file and ask user to upload it to webhost $_SESSION['plogger_config'] = create_config_file($form['db_host'], $form['db_user'], $form['db_pass'], $form['db_name'], $form['db_type'], $form['db_port']); } return true; } } include PLOGGER_DIR . 'plog-admin/includes/install-form-setup.php'; return false; }