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 "\n";
//
if ($f_get_magic_quotes_gpc == 1)
{
- if (get_magic_quotes_gpc () == 0)
- {
- print "- Magic Quotes: Disabled - OK
\n";
- }
- else
- {
- print "- Warning: Magic Quotes: ON (internal workaround used)
\n";
- }
+ if (get_magic_quotes_gpc () == 0)
+ {
+ print "- Magic Quotes: Disabled - OK
\n";
+ }
+ else
+ {
+ print "- Warning: Magic Quotes: ON (internal workaround used)
\n";
+ }
}
else
{
- print "- Unable to check for Magic Quotes. (missing function: get_magic_quotes_gpc())
\n";
+ print "- Unable to check for Magic Quotes. (missing function: get_magic_quotes_gpc())
\n";
}
//
@@ -120,27 +120,27 @@ else
$config_loaded = 0;
if ($file_config == 1)
{
- print "- Depends on: presence config.inc.php - OK
\n";
- require_once('config.inc.php');
- $config_loaded = 1;
-
- require('config.inc.php');
- if(isset($CONF['configured'])) {
- if($CONF['configured'] == TRUE) {
- print "- Checking \$CONF['configured'] - OK\n";
- } else {
- print "
- Warning: \$CONF['configured'] is 'false'.
\n";
- print "You must edit your config.inc.php and change this to true (this indicates you've created the database and user)\n";
- }
- }
+ print " - Depends on: presence config.inc.php - OK
\n";
+ require_once('config.inc.php');
+ $config_loaded = 1;
+
+ require('config.inc.php');
+ if(isset($CONF['configured'])) {
+ if($CONF['configured'] == TRUE) {
+ print "- Checking \$CONF['configured'] - OK\n";
+ } else {
+ print "
- Warning: \$CONF['configured'] is 'false'.
\n";
+ print "You must edit your config.inc.php and change this to true (this indicates you've created the database and user)\n";
+ }
+ }
}
else
{
- print " - Error: Depends on: presence config.inc.php - NOT FOUND
\n";
- print "Create the file, and edit as appropriate (e.g. select database type etc)
";
- print "For example:
\n";
- print "cp config.inc.php.sample config.inc.php
\n";
- $error =+ 1;
+ print "- Error: Depends on: presence config.inc.php - NOT FOUND
\n";
+ print "Create the file, and edit as appropriate (e.g. select database type etc)
";
+ print "For example:
\n";
+ print "cp config.inc.php.sample config.inc.php
\n";
+ $error =+ 1;
}
//
@@ -148,33 +148,33 @@ else
//
if (($f_mysql_connect == 0) and ($f_mysqli_connect == 0) and ($f_pg_connect == 0))
{
- print "- Error: There is no database support in your PHP setup
\n";
- print "To install MySQL 3.23 or 4.0 support on FreeBSD:
\n";
- print "% cd /usr/ports/databases/php$phpversion-mysql/\n";
- print "% make clean install\n";
- print " - or with portupgrade -\n";
- print "% portinstall php$phpversion-mysql
\n";
- if ($phpversion >= 5)
- {
- print "To install MySQL 4.1 support on FreeBSD:
\n";
- print "% cd /usr/ports/databases/php5-mysqli/\n";
- print "% make clean install\n";
- print " - or with portupgrade -\n";
- print "% portinstall php5-mysqli
\n";
- }
- print "To install PostgreSQL support on FreeBSD:
\n";
- print "% cd /usr/ports/databases/php$phpversion-pgsql/\n";
- print "% make clean install\n";
- print " - or with portupgrade -\n";
- print "% portinstall php$phpversion-pgsql
\n";
- $error =+ 1;
+ print "- Error: There is no database support in your PHP setup
\n";
+ print "To install MySQL 3.23 or 4.0 support on FreeBSD:
\n";
+ print "% cd /usr/ports/databases/php$phpversion-mysql/\n";
+ print "% make clean install\n";
+ print " - or with portupgrade -\n";
+ print "% portinstall php$phpversion-mysql
\n";
+ if ($phpversion >= 5)
+ {
+ print "To install MySQL 4.1 support on FreeBSD:
\n";
+ print "% cd /usr/ports/databases/php5-mysqli/\n";
+ print "% make clean install\n";
+ print " - or with portupgrade -\n";
+ print "% portinstall php5-mysqli
\n";
+ }
+ print "To install PostgreSQL support on FreeBSD:
\n";
+ print "% cd /usr/ports/databases/php$phpversion-pgsql/\n";
+ print "% make clean install\n";
+ print " - or with portupgrade -\n";
+ print "% portinstall php$phpversion-pgsql
\n";
+ $error =+ 1;
}
//
// MySQL 3.23, 4.0 functions
//
if ($f_mysql_connect == 1)
{
- print "- Depends on: MySQL 3.23, 4.0 - OK
\n";
+ print "- Depends on: MySQL 3.23, 4.0 - OK
\n";
}
//
@@ -182,14 +182,14 @@ if ($f_mysql_connect == 1)
//
if ($phpversion >= 5)
{
- if ($f_mysqli_connect == 1)
- {
- print "- Depends on: MySQL 4.1 - OK\n";
- if ( !($config_loaded && $CONF['database_type'] == 'mysqli') ) {
- print "(change the database_type to 'mysqli' in config.inc.php!!)\n";
- }
- print "
";
- }
+ if ($f_mysqli_connect == 1)
+ {
+ print "- Depends on: MySQL 4.1 - OK\n";
+ if ( !($config_loaded && $CONF['database_type'] == 'mysqli') ) {
+ print "(change the database_type to 'mysqli' in config.inc.php!!)\n";
+ }
+ print "
";
+ }
}
//
@@ -197,26 +197,26 @@ if ($phpversion >= 5)
//
if ($f_pg_connect == 1)
{
- print "- Depends on: PostgreSQL - OK \n";
- if ( !($config_loaded && $CONF['database_type'] == 'pgsql') ) {
- print "(change the database_type to 'pgsql' in config.inc.php!!)\n";
- }
- print "
";
+ print "- Depends on: PostgreSQL - OK \n";
+ if ( !($config_loaded && $CONF['database_type'] == 'pgsql') ) {
+ print "(change the database_type to 'pgsql' in config.inc.php!!)\n";
+ }
+ print "
";
}
//
// Database connection
//
if ($config_loaded) {
- list ($link, $error_text) = db_connect(TRUE);
- if ($error_text == "") {
- print "- Testing database connection - OK - {$CONF['database_type']}://{$CONF['database_user']}:xxxxx@{$CONF['database_host']}/{$CONF['database_name']}
";
- } else {
- print "- Error: Can't connect to database
\n";
- print "Please edit the \$CONF['database_*'] parameters in config.inc.php.\n";
- print "$error_text \n";
- $error ++;
- }
+ list ($link, $error_text) = db_connect(TRUE);
+ if ($error_text == "") {
+ print "- Testing database connection - OK - {$CONF['database_type']}://{$CONF['database_user']}:xxxxx@{$CONF['database_host']}/{$CONF['database_name']}
";
+ } else {
+ print "- Error: Can't connect to database
\n";
+ print "Please edit the \$CONF['database_*'] parameters in config.inc.php.\n";
+ print "$error_text \n";
+ $error ++;
+ }
}
//
@@ -224,17 +224,17 @@ if ($config_loaded) {
//
if ($f_session_start == 1)
{
- print "- Depends on: session - OK
\n";
+ print "- Depends on: session - OK
\n";
}
else
{
- print "- Error: Depends on: session - NOT FOUND
\n";
- print "To install session support on FreeBSD:
\n";
- print "% cd /usr/ports/www/php$phpversion-session/\n";
- print "% make clean install\n";
- print " - or with portupgrade -\n";
- print "% portinstall php$phpversion-session
\n";
- $error =+ 1;
+ print "- Error: Depends on: session - NOT FOUND
\n";
+ print "To install session support on FreeBSD:
\n";
+ print "% cd /usr/ports/www/php$phpversion-session/\n";
+ print "% make clean install\n";
+ print " - or with portupgrade -\n";
+ print "% portinstall php$phpversion-session
\n";
+ $error =+ 1;
}
//
@@ -242,17 +242,17 @@ else
//
if ($f_preg_match == 1)
{
- print "- Depends on: pcre - OK
\n";
+ print "- Depends on: pcre - OK
\n";
}
else
{
- print "- Error: Depends on: pcre - NOT FOUND
\n";
- print "To install pcre support on FreeBSD:
\n";
- print "% cd /usr/ports/devel/php$phpversion-pcre/\n";
- print "% make clean install\n";
- print " - or with portupgrade -\n";
- print "% portinstall php$phpversion-pcre
\n";
- $error =+ 1;
+ print "- Error: Depends on: pcre - NOT FOUND
\n";
+ print "To install pcre support on FreeBSD:
\n";
+ print "% cd /usr/ports/devel/php$phpversion-pcre/\n";
+ print "% make clean install\n";
+ print " - or with portupgrade -\n";
+ print "% portinstall php$phpversion-pcre
\n";
+ $error =+ 1;
}
//
@@ -260,13 +260,13 @@ else
//
if ( $f_mb_encode_mimeheader == 1 )
{
- print "- Depends on: multibyte string - OK
\n";
+ print "- Depends on: multibyte string - OK
\n";
}
else
{
- print "- Error: Depends on: multibyte string - NOT FOUND
\n";
- print "To install multibyte string support, install php$phpversion-mbstring \n";
- $error =+ 1;
+ print "- Error: Depends on: multibyte string - NOT FOUND
\n";
+ print "To install multibyte string support, install php$phpversion-mbstring \n";
+ $error =+ 1;
}
@@ -275,14 +275,14 @@ else
//
if ( $f_imap_open == 1)
{
- print "- Depends on: IMAP functions - OK
\n";
+ print "- Depends on: IMAP functions - OK
\n";
}
else
{
- print "- Warning: Depends on: IMAP functions - NOT FOUND
\n";
- print "To install IMAP support, install php$phpversion-imap
\n";
- print "Without IMAP support, you won't be able to create subfolders when creating mailboxes. \n";
-# $error =+ 1;
+ print "- Warning: Depends on: IMAP functions - NOT FOUND
\n";
+ print "To install IMAP support, install php$phpversion-imap
\n";
+ print "Without IMAP support, you won't be able to create subfolders when creating mailboxes. \n";
+ # $error =+ 1;
}
@@ -294,51 +294,70 @@ 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)
+ {
+?>