/**
* Postfix Admin
*
* LICENSE
* This source file is subject to the GPL license that is bundled with
* this package in the file LICENSE.TXT.
*
* Further details on the project are available at :
* http://www.postfixadmin.com or http://postfixadmin.sf.net
*
* @version $Id: setup.php 1405 2012-06-30 11:07:57Z christian_boltz $
* @license GNU GPL v2 or later.
*
* File: setup.php
* Used to help ensure a server is setup appropriately during installation/setup
.
* After setup, it should be renamed or removed.
*
* Template File: -none-
*
* Template Variables: -none-
*
* Form POST \ GET Variables: -none-
*/
define('POSTFIXADMIN', 1); # by defining it here, common.php will not start a se
ssion.
require_once(dirname(__FILE__).'/common.php'); # make sure correct common.php is
used.
$CONF['show_header_text'] = 'NO';
$CONF['theme_logo'] = 'images/logo-default.png';
$CONF['theme_css'] = 'css/default.css';
require($incpath.'/templates/header.php');
?>
<div class='setup'>
<h2>Postfix Admin Setup Checker</h2>
<p>Running software:
<ul>
<?php
//
// Check for availablilty functions
//
$f_phpversion = function_exists ("phpversion");
$f_apache_get_version = function_exists ("apache_get_version");
$f_get_magic_quotes_gpc = function_exists ("get_magic_quotes_gpc");
$f_mysql_connect = function_exists ("mysql_connect");
$f_mysqli_connect = function_exists ("mysqli_connect");
$f_pg_connect = function_exists ("pg_connect");
$f_session_start = function_exists ("session_start");
$f_preg_match = function_exists ("preg_match");
$f_mb_encode_mimeheader = function_exists ("mb_encode_mimeheader");
$f_imap_open = function_exists ("imap_open");
$file_config = file_exists (realpath ("./config.inc.php"));
$error = 0;
//
// Check for PHP version
//
if ($f_phpversion == 1)
{
if (phpversion() < 5) {
print "<li><b>Error: Depends on: PHP v5</b>
</li>\n";
$error += 1;
}
if (phpversion() >= 5) {
$phpversion = 5;
print "<li>PHP version " . phpversion () . "</li>\n";
}
}
else
{
print "<li><b>Unable to check for PHP version. (missing function: phpversion
())</b></li>\n";
}
//
// Check for Apache version
//
if ($f_apache_get_version == 1)
{
print "<li>" . apache_get_version() . "</li>\n";
}
else
{
# not running on Apache.
# However postfixadmin _is_ running, so obviously we are on a supported webs
erver ;-))
# No need to confuse the user with a warning.
}
print "</ul>";
print "<p>Checking for dependencies:\n";
print "<ul>\n";
//
// Check for Magic Quotes
//
if ($f_get_magic_quotes_gpc == 1)
{
if (get_magic_quotes_gpc () == 0)
{
print "<li>Magic Quotes: Disabled - OK</li>\n";
}
else
{
print "<li><b>Warning: Magic Quotes: ON (internal workaround used)</b></
li>\n";
}
}
else
{
print "<li><b>Unable to check for Magic Quotes. (missing function: get_magic
_quotes_gpc())</b></li>\n";
}
//
// Check for config.inc.php
//
$config_loaded = 0;
if ($file_config == 1)
{
print "<li>Depends on: presence config.inc.php - OK</li>\n";
require_once($incpath.'/config.inc.php');
$config_loaded = 1;
if(isset($CONF['configured'])) {
if($CONF['configured'] === TRUE) {
print "<li>Checking \$CONF['configured'] - OK\n";
} else {
print "<li><b>Warning: \$CONF['configured'] is 'false'.
\n";
print "You must edit your config.inc.php and change this to true (th
is indicates you've created the database and user)</b>\n";
}
}
}
else
{
print "<li><b>Error: Depends on: presence config.inc.php - NOT FOUND</b>
</li>\n";
print "Create the file, and edit as appropriate (e.g. select database type e
tc)
";
print "For example:
\n";
print "<code><pre>cp config.inc.php.sample config.inc.php</pre></code>\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 "<li><b>Error: There is no database support in your PHP setup</b><br /
>\n";
print "To install MySQL 3.23 or 4.0 support on FreeBSD:
\n";
print "<pre>% cd /usr/ports/databases/php$phpversion-mysql/\n";
print "% make clean install\n";
print " - or with portupgrade -\n";
print "% portinstall php$phpversion-mysql</pre>\n";
if ($phpversion >= 5)
{
print "To install MySQL 4.1 support on FreeBSD:
\n";
print "<pre>% cd /usr/ports/databases/php5-mysqli/\n";
print "% make clean install\n";
print " - or with portupgrade -\n";
print "% portinstall php5-mysqli</pre>\n";
}
print "To install PostgreSQL support on FreeBSD:
\n";
print "<pre>% cd /usr/ports/databases/php$phpversion-pgsql/\n";
print "% make clean install\n";
print " - or with portupgrade -\n";
print "% portinstall php$phpversion-pgsql</pre></li>\n";
$error =+ 1;
}
//
// MySQL 3.23, 4.0 functions
//
if ($f_mysql_connect == 1)
{
print "<li>Depends on: MySQL 3.23, 4.0 - OK</li>\n";
}
//
// MySQL 4.1 functions
//
if ($phpversion >= 5)
{
if ($f_mysqli_connect == 1)
{
print "<li>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 "</li>";
}
}
//
// PostgreSQL functions
//
if ($f_pg_connect == 1)
{
print "<li>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 "</li>";
}
//
// Database connection
//
if ($config_loaded) {
list ($link, $error_text) = db_connect(TRUE);
if ($error_text == "") {
print "<li>Testing database connection - OK - {$CONF['database_type']}:/
/{$CONF['database_user']}:xxxxx@{$CONF['database_host']}/{$CONF['database_name']
}</li>";
} else {
print "<li><b>Error: Can't connect to database</b>
\n";
print "Please edit the \$CONF['database_*'] parameters in config.inc.php
$error =+ 1;
}
} elseif ($pass == $setuppw && $lostpw_mode == 0) { # correct passsword (and
not asking for a new password)
$result = "pass_OK";
$error = 0;
} else {
$pass = encrypt_setup_password($password, generate_setup_password_salt()
);
$result = "";
if ($lostpw_mode == 1) {
$error = 0; # non-matching password is expected when the user asks f
or a new password
} else {
$result = '<p><b>Setup password not specified correctly</b></p>';
}
$result .= '<p>If you want to use the password you entered as setup pass
word, edit config.inc.php and set</p>';
$result .= "<pre>\$CONF['setup_password'] = '$pass';</pre>";
}
return array ($error, $result);
}
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
?>