diff --git a/public/setup.php b/public/setup.php
index c3cdd9bd..d6dee3f8 100644
--- a/public/setup.php
+++ b/public/setup.php
@@ -64,21 +64,18 @@ $errormsg = array();
$phpversion = 'unknown-version';
if ($f_phpversion == 1) {
- if (phpversion() < 5) {
+ if (version_compare(phpversion(), '5', '<')) {
print "
Error: Depends on: PHP v5+
\n";
$error += 1;
- } elseif (version_compare(phpversion(), '5.2.3') < 0) {
- # smarty uses htmlentities() with 4 parameters, the 4th parameter was introduced in PHP 5.2.3
- # older PHP versions will cause warnings
+ } elseif (version_compare(phpversion(), '7.0') < 0) {
$phpversion = 5;
- print "Recommended PHP version: >= 5.2.3, you have " . phpversion() . "\n";
+ print "Recommended PHP version: >= 7.0, you have " . phpversion() . "; you should upgrade.\n";
} else {
- $phpversion = 5;
- print "PHP version " . phpversion() . "\n";
+ print "PHP version " . phpversion() . " - Good\n";
}
- # TODO: check for PHP >= 5.2.3 - smarty uses htmlentities with 4 parameters. The forth parameter was added in PHP 5.2.3, older versions will give a warning
} else {
- print "Unable to check for PHP version. (missing function: phpversion())\n";
+ print "DANGER Unable to check for PHP version. (missing function: phpversion())\n";
+ $error++;
}
//
@@ -93,7 +90,7 @@ if ($f_apache_get_version == 1) {
}
print "";
-print "Checking for dependencies:\n";
+print "
Checking environment:\n";
print "
\n";
//
@@ -103,42 +100,16 @@ 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";
+ print "- Warning: Magic Quotes: ON (internal work around to disable is in place)
\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(dirname(__FILE__) .'/../config.inc.php');
- $config_loaded = 1;
-
- 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.local.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;
-}
//
// Check for config.local.php
//
if ($file_local_config == 1) {
- print "- Depends on: presence config.local.php - OK
\n";
+ print "- Depends on: presence config.local.php - Found
\n";
} else {
print "- Warning: config.local.php - NOT FOUND
\n";
print "It's Recommended to store your own settings in config.local.php instead of editing config.inc.php
";
@@ -169,59 +140,61 @@ if (($f_mysql_connect == 0) and ($f_mysqli_connect == 0) and ($f_pg_connect == 0
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.local.php if you want to use MySQL)\n";
- }
- print " ";
+if ($f_mysqli_connect == 1) {
+ print "- Database - MySQL (mysqli_ functions) - Found\n";
+ if (Config::read_string('database_type') != 'mysqli') {
+ print "
(change the database_type to 'mysqli' in config.local.php if you want to use MySQL)\n";
}
+ print " ";
+}
+else {
+ print "- Database - MySQL (mysqli_ functions) - Not found
";
+}
+
+
+if(Config::read_string('database_type') == 'mysql') {
+ print "- Warning: your configured database_type 'mysql' is deprecated; you must move to use 'mysqli' in your config.local.php.
\n";
+ $error++;
}
//
// PostgreSQL functions
//
if ($f_pg_connect == 1) {
- print "- Depends on: PostgreSQL - OK \n";
- if (!($config_loaded && $CONF['database_type'] == 'pgsql')) {
+ print "
- Database : PostgreSQL support (pg_ functions) - Found\n";
+ if (Config::read_string('database_type') != 'pgsql') {
print "
(change the database_type to 'pgsql' in config.local.php if you want to use PostgreSQL)\n";
}
print " ";
}
+else {
+ print "- Database - PostgreSQL (pg_ functions) - Not found
";
+}
if ($f_sqlite_open == 1) {
- print "- Depends on: SQLite - OK \n";
- if (!($config_loaded && db_sqlite())) {
+ print "
- Database : SQLite support (SQLite3) - Found \n";
+ if (Config::read_string('database_type') != 'sqlite') {
print "
(change the database_type to 'sqlite' in config.local.php if you want to use SQLite)\n";
}
print " ";
}
+else {
+ print "- Database - SQLite (SQLite3) - Not found
";
+}
//
// Database connection
//
-if ($config_loaded) {
- list($link, $error_text) = db_connect_with_errors();
+list($link, $error_text) = db_connect_with_errors();
- if (!empty($link) && $error_text == "") {
- print "- Testing database connection (using {$CONF['database_type']}) - OK
";
- } else {
- print "- Error: Can't connect to database
\n";
- print "Please check the \$CONF['database_*'] parameters in config.local.php.\n";
- print "$error_text \n";
- $error ++;
- }
+if (!empty($link) && $error_text == "") {
+ print "- Testing database connection (using {$CONF['database_type']}) - Success
";
+} else {
+ print "- Error: Can't connect to database
\n";
+ print "Please check the \$CONF['database_*'] parameters in config.local.php.\n";
+ print "$error_text \n";
+ $error ++;
}
//
@@ -243,7 +216,7 @@ if ($f_session_start == 1) {
// PCRE functions
//
if ($f_preg_match == 1) {
- print "- Depends on: pcre - OK
\n";
+ print "- Depends on: pcre - Found
\n";
} else {
print "- Error: Depends on: pcre - NOT FOUND
\n";
print "To install pcre support on FreeBSD:
\n";
@@ -258,7 +231,7 @@ if ($f_preg_match == 1) {
// Multibyte functions
//
if ($f_mb_encode_mimeheader == 1) {
- print " - Depends on: multibyte string - OK
\n";
+ print "- Depends on: multibyte string - Found
\n";
} else {
print "- Error: Depends on: multibyte string - NOT FOUND
\n";
print "To install multibyte string support, install php$phpversion-mbstring \n";
@@ -270,9 +243,9 @@ if ($f_mb_encode_mimeheader == 1) {
// Imap functions
//
if ($f_imap_open == 1) {
- print "- Depends on: IMAP functions - OK
\n";
+ print "- IMAP functions - Found
\n";
} else {
- print "- Warning: Depends on: IMAP functions - NOT FOUND
\n";
+ print " - Warning: May depend 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";
}
@@ -282,12 +255,11 @@ if ($f_imap_open == 1) {
// If PHP <7.0, require random_compat works. Currently we bundle it via the Phar extension.
//
-if (version_compare($phpversion, "7.0", '<')
+if (version_compare(phpversion(), "7.0", '<')
&& !extension_loaded('Phar')
- && $config_loaded
&& $CONF['configured']
&& $CONF['encrypt'] == 'php_crypt') {
- print "- Requires 'Phar' extension support for secure random_int() function fallback";
+ print "
- PHP before 7.0 requires 'Phar' extension support for secure random_int() function fallback";
print "
Either enable the 'Phar' extension, or install the random_compat library files from https://github.com/paragonie/random_compat and include/require them from functions.inc.php";
print "
PostfixAdmin has bundled lib/random_compat.phar but it's not usable on your installation due to the missing Phar extension. ";
$error += 1;
@@ -430,8 +402,8 @@ if ($error != 0) {
- Since version 2.3 there is no requirement to delete setup.php!
- Check the config.inc.php file for any other settings that you might need to change!
+ Since version 2.3 there is no requirement to delete setup.php
+ Check the config.inc.php file for any other settings that you may need to change.