diff --git a/setup.php b/setup.php index d9c25938..e157bcac 100644 --- a/setup.php +++ b/setup.php @@ -26,7 +26,7 @@ define('POSTFIXADMIN', 1); # checked in included files require_once("languages/en.lang"); -require_once("functions.inc.php"); +require_once('common.php'); $CONF['show_header_text'] = 'NO'; $CONF['theme_logo'] = 'images/logo-default.png'; @@ -74,7 +74,7 @@ if ($f_phpversion == 1) } else { - print "
  • Unable to check for PHP version. (missing function: phpversion())
  • \n"; + print "
  • Unable to check for PHP version. (missing function: phpversion())
  • \n"; } // @@ -82,13 +82,13 @@ else // if ($f_apache_get_version == 1) { - print "
  • " . apache_get_version() . "
  • \n"; + print "
  • " . apache_get_version() . "
  • \n"; } else { - # not running on Apache. - # However postfixadmin _is_ running, so obviously we are on a supported webserver ;-)) - # No need to confuse the user with a warning. + # not running on Apache. + # However postfixadmin _is_ running, so obviously we are on a supported webserver ;-)) + # No need to confuse the user with a warning. } print ""; @@ -100,18 +100,18 @@ print ""; if ($error != 0) { - print "

    Please fix the errors listed above.

    "; + print "

    Please fix the errors listed above.

    "; } else { print "

    Everything seems fine... attempting to create/update database structure

    \n"; require_once('upgrade.php'); - $pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text']; - $pAdminCreate_admin_password_text = ""; - $tUsername = ''; - $tMessage = ''; - - - if ($_SERVER['REQUEST_METHOD'] == "POST") - { - if (isset ($_POST['fUsername'])) $fUsername = escape_string ($_POST['fUsername']); - if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']); - if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); - - // XXX need to ensure domains table includes an 'ALL' entry. - $table_domain = table_by_key('domain'); - $r = db_query("SELECT * FROM $table_domain WHERE domain = 'ALL'"); - if($r['rows'] == 0) { - db_insert($table_domain, array('domain' => 'ALL')); // all other fields should default through the schema. - } - - list ($error, $tMessage, $pAdminCreate_admin_username_text, $pAdminCreate_admin_password_text) = create_admin($fUsername, $fPassword, $fPassword2, array('ALL'), TRUE); - if ($error != 0) { - if (isset ($_POST['fUsername'])) $tUsername = escape_string ($_POST['fUsername']); - } else { - print "

    $tMessage

    "; - echo "

    Delete (or rename) setup.php, and then click here to login.

    "; - } - } - - if ($_SERVER['REQUEST_METHOD'] == "GET" || $error != 0) - { - ?> + $pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text']; + $pAdminCreate_admin_password_text = ""; + $tUsername = ''; + $tMessage = ''; + + + if ($_SERVER['REQUEST_METHOD'] == "POST") + { + // ensure password is correct. + if(!isset($_POST['setup_password'])) { + $error += 1; + $tMessage = "Setup password must be specified"; + } + if($_POST['setup_password'] != $CONF['setup_password']) { + $error += 1; + $tMessage = "Setup password not specified correctly"; + } + + if($error == 0) { + if (isset ($_POST['fUsername'])) $fUsername = escape_string ($_POST['fUsername']); + if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']); + if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); + + // XXX need to ensure domains table includes an 'ALL' entry. + $table_domain = table_by_key('domain'); + $r = db_query("SELECT * FROM $table_domain WHERE domain = 'ALL'"); + if($r['rows'] == 0) { + db_insert($table_domain, array('domain' => 'ALL')); // all other fields should default through the schema. + } + + list ($error, $tMessage, $pAdminCreate_admin_username_text, $pAdminCreate_admin_password_text) = create_admin($fUsername, $fPassword, $fPassword2, array('ALL'), TRUE); + if ($error != 0) { + if (isset ($_POST['fUsername'])) $tUsername = escape_string ($_POST['fUsername']); + } else { + print "

    $tMessage

    "; + } + } + else { + print "

    $tMessage

    "; + } + + } + + if ($_SERVER['REQUEST_METHOD'] == "GET" || $error != 0) + { +?>
    - + + + + + @@ -364,11 +383,11 @@ else - Make sure you delete this setup.php file!
    \n"; - print "Also check the config.inc.php file for any settings that you might need to change!
    \n"; + print "Since version 2.3 there is no requirement to delete setup.php!
    \n"; + print "Check the config.inc.php file for any other settings that you might need to change!
    \n"; } ?>

    Create superadmin account

    Setup password (see config.inc.php)