예제 #1
0
 case 0:
 case '0':
     display_header("aMember Setup: Step " . ($step + 1) . " of 4");
     check_for_writeable();
     display_main_config();
     break;
 case 1:
 case '1':
     display_header("aMember Setup: Step " . ($step + 1) . " of 4");
     check_main_config();
     display_mysql_form();
     break;
 case 2:
 case '2':
     display_header("aMember Setup: Step " . ($step + 1) . " of 4");
     check_mysql_form($db_installed);
     if ($db_installed) {
         $step = 3;
         display_plugins_form();
         break;
     }
     display_db_install_query();
     break;
 case 3:
 case '3':
     commit_changes();
     break;
 case 5:
 case '5':
     display_header("aMember Setup: Step " . ($step - 1) . " of 4");
     display_thanks();
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;
}