Postfix Admin Setup Checker
Running software:
= 5) $phpversion = 5;
print "- PHP version " . phpversion () . "\n";
}
else
{
print "
- Unable to check for PHP version. (missing function: phpversion())\n";
}
//
// Check for Apache version
//
if ($f_apache_get_version == 1)
{
print "
- " . apache_get_version() . "\n";
}
else
{
print "
- Unable to check for Apache version. (missing function: apache_get_version())\n";
}
print "
";
print "Checking for dependencies:\n";
print "
\n";
//
// Check for Magic Quotes
//
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";
}
}
else
{
print "
- Unable to check for Magic Quotes. (missing function: get_magic_quotes_gpc())\n";
}
//
// Check for config.inc.php
//
$config_loaded = 0;
if ($file_config == 1)
{
print "
- Depends on: presence config.inc.php - OK\n";
require_once('config.inc.php');
$config_loaded = 1;
}
else
{
print "
- Error: Depends on: presence config.inc.php - NOT FOUND
\n";
print "Create the file.
";
print "For example:
\n";
print "% cp config.inc.php.sample config.inc.php
\n";
$error =+ 1;
}
//
// Check if there is support for at least 1 database
//
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;
}
//
// MySQL 3.23, 4.0 functions
//
if ($f_mysql_connect == 1)
{
print " - Depends on: MySQL 3.23, 4.0 - OK\n";
}
//
// MySQL 4.1 functions
//
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";
}
}
}
//
// PostgreSQL functions
//
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";
}
}
//
// Database connection
//
if ($config_loaded) {
list ($link, $error_text) = db_connect(TRUE);
if ($error_text == "") {
print "
- Testing database connection - OK";
} 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 ++;
}
}
//
// Session functions
//
if ($f_session_start == 1)
{
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;
}
//
// PCRE functions
//
if ($f_preg_match == 1)
{
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 "
";
if ($error != 0)
{
print "Please fix the errors listed above.
";
}
else
{
print "Everything seems fine... you are ready to rock & roll!
\n";
$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']);
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 "You can now log in to Postfix Admin.
";
}
}
if ($_SERVER['REQUEST_METHOD'] == "GET" || $error != 0)
{
?>
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 "Click here to go to the admin section (make sure that your .htaccess is setup properly)\n";
}
?>