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')) {
        $mysql = check_mysql(PLOGGER_DB_HOST, PLOGGER_DB_USER, PLOGGER_DB_PW, PLOGGER_DB_NAME);
        if (!empty($mysql)) {
            $mysql_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 (isset($form['action']) && $form['action'] == 'install') {
        if (!defined('PLOGGER_DB_HOST') || isset($mysql_fail)) {
            $mysql_form_check = check_mysql_form($form);
            if (!empty($mysql_form_check)) {
                $errors = array_merge($errors, $mysql_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)) {
            $mysql_errors = check_mysql($form['db_host'], $form['db_user'], $form['db_pass'], $form['db_name']);
            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($mysql_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($mysql_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']);
            }
            return true;
        }
    }
    include PLOGGER_DIR . 'plog-admin/includes/install-form-setup.php';
    return false;
}
Пример #2
0
 // If installed, check for safe_mode and if enabled, check for FTP workaround
 if (is_safe_mode()) {
     // Set up the FTP workaround information if prompted
     if (isset($_POST['ftp_host'])) {
         $ftp_errors = array();
         $form = array_map('stripslashes', $_POST);
         $form = array_map('trim', $_POST);
         // Check the form input values
         $ftp_form_check = check_ftp_form($form);
         $form = $ftp_form_check['form'];
         if (!empty($ftp_form_check['form']['errors'])) {
             $ftp_errors = $ftp_form_check['form']['errors'];
         }
         // If no ftp errors so far, check the ftp information
         if (empty($ftp_errors)) {
             $ftp_check = check_ftp($form['ftp_host'], $form['ftp_user'], $form['ftp_pass'], $form['ftp_path']);
         }
         // If still no ftp errors, add the information to the database
         if (empty($ftp_check)) {
             configure_ftp($form);
             $config['ftp_host'] = $form['ftp_host'];
             $config['ftp_user'] = $form['ftp_user'];
             $config['ftp_pass'] = $form['ftp_pass'];
             $config['ftp_path'] = $form['ftp_path'];
         } else {
             // Otherwise, set up the errors for display later
             $ftp_errors = $ftp_check;
         }
     }
     if (!isset($config['ftp_host'])) {
         // Do we need an upgrade for people who used SVN only code that stored