refactor setup.php, jeroen@
This commit is contained in:
parent
5fb606b818
commit
d056a32d57
193
setup.php
193
setup.php
|
@ -1,150 +1,47 @@
|
||||||
<?php
|
<?php
|
||||||
//
|
/**
|
||||||
// OpenSMTPD Admin
|
* OpenSMTPD Admin Refactor
|
||||||
// by Mischa Peters <mischa at high5 dot nl>
|
* by Jeroen Janssen <jeroen at laylo dot io>
|
||||||
// Copyright (c) 2022 High5!
|
* Copyright (c) 2022 LAYLO
|
||||||
// License Info: LICENSE.TXT
|
*/
|
||||||
//
|
|
||||||
// File: index.php
|
// Check whether the configuration file exists - bail if that is the case
|
||||||
//
|
if (file_exists(realpath("./config.inc.php"))) {
|
||||||
// Template File: -none-
|
print 'It seems that config.inc.php is already configured. Please delete setup.php to continue.';
|
||||||
//
|
die();
|
||||||
// Template Variables:
|
}
|
||||||
//
|
// Define the app specifics
|
||||||
// -none-
|
DEFINE('APP_NAME', 'OpenSMTPD Admin Setup Checker');
|
||||||
//
|
DEFINE('VERSION', '1.1');
|
||||||
// Form POST \ GET Variables:
|
|
||||||
//
|
// Start generating the HTML output
|
||||||
// -none-
|
$html = '<html>';
|
||||||
//
|
$html .= '<head>';
|
||||||
|
$html .= '<title></title>';
|
||||||
|
$html .= '</head>';
|
||||||
|
$html .= '<body>';
|
||||||
|
$html .= '<img id="login_header_logo" src="images/postbox.png" />';
|
||||||
|
$html .= '<img id="login_header_logo" height="30px" src="images/opensmtpdadmin.png" />';
|
||||||
|
$html .= '<h1>' . APP_NAME . ' v' . VERSION . '</h1>';
|
||||||
|
$html .= '<p>It seems that you are running this version of OpenSMTPD Admin for the first time.</p>';
|
||||||
|
$html .= '<table>';
|
||||||
|
$html .= '<tr>';
|
||||||
|
$html .= '<td><strong>PHP version:</strong></td>';
|
||||||
|
$html .= (version_compare(PHP_VERSION, '7.4.0') >= 0) ? '<td><span style="color:green;">' . phpversion() . '</td>' : '<td><span style="color:red;">' . phpversion() . '</span></td>';
|
||||||
|
$html .= '</tr><tr>';
|
||||||
|
$html .= '<td><strong>SQL support:</strong></td>';
|
||||||
|
$html .= (extension_loaded('mysqli')) ? '<td><span style="color:green;">MySQL/MariaDB</span>' : '<td><span style="color:red;">MySQL/MariaDB</span>';
|
||||||
|
$html .= (extension_loaded('pgsql')) ? ' - <span style="color:green;">PostgreSQL</span> (change the database_type if you want to use PostgreSQL)</td>' : ' - <span style="color:red;">PostgreSQL</span></td>';
|
||||||
|
$html .= '</tr><tr>';
|
||||||
|
$html .= '<td><strong>Functions:</strong></td>';
|
||||||
|
$html .= (extension_loaded('pcre')) ? '<td><span style="color:green;">pcre</span>' : '<td><span style="color:red;">pcre</span>';
|
||||||
|
$html .= (function_exists('get_magic_quotes_gpc')) ? ' - <span style="color:green;">get_magic_quotes_gpc</span>' : ' - <span style="color:red;">get_magic_quotes_gpc</span>';
|
||||||
|
$html .= (function_exists('session_start')) ? ' - <span style="color:green;">session_start</span></td>' : ' - <span style="color:red;">session_start</span></td>';
|
||||||
|
$html .= '</tr>';
|
||||||
|
$html .= '</table>';
|
||||||
|
$html .= '</body>';
|
||||||
|
$html .= '</html>';
|
||||||
|
|
||||||
|
print $html;
|
||||||
|
die();
|
||||||
?>
|
?>
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>OpenSMTPD Admin Setup Checker</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<img id="login_header_logo" src="images/postbox.png" />
|
|
||||||
<img id="login_header_logo" height="30px" src="images/opensmtpdadmin.png" />
|
|
||||||
<h1>Welcome to OpenSMTPD Admin</h1>
|
|
||||||
<h2>OpenSMTPD Admin Setup Checker 1.0</h2>
|
|
||||||
It seems that you are running this version of OpenSMTPD Admin for the first time.<br />
|
|
||||||
<p />
|
|
||||||
This will tell you if all functions are available for OpenSMTPD Admin to run.<br />
|
|
||||||
<p />
|
|
||||||
If you still encounter any problems please check the documentation and website for more information.<br />
|
|
||||||
<p />
|
|
||||||
Running software:<br />
|
|
||||||
<p />
|
|
||||||
<?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");
|
|
||||||
|
|
||||||
$file_config = file_exists(realpath("./config.inc.php"));
|
|
||||||
|
|
||||||
$error = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check for PHP version
|
|
||||||
//
|
|
||||||
if ($f_phpversion == 1) {
|
|
||||||
if (phpversion() < 8) $phpversion = 7;
|
|
||||||
if (phpversion() >= 8) $phpversion = 8;
|
|
||||||
print "- PHP version " . phpversion() . "<br />\n";
|
|
||||||
} else {
|
|
||||||
print "<li><b>Unable to check for PHP version. (missing function: phpversion())</b><br />\n";
|
|
||||||
}
|
|
||||||
print "<p />\n";
|
|
||||||
print "Checking for dependencies:<br />\n";
|
|
||||||
print "<p />\n";
|
|
||||||
|
|
||||||
//
|
|
||||||
// Check for config.inc.php
|
|
||||||
//
|
|
||||||
if ($file_config == 1) {
|
|
||||||
print "- Depends on: presence config.inc.php - OK<br />\n";
|
|
||||||
} else {
|
|
||||||
print "<li><b>Error: Depends on: presence config.inc.php - NOT FOUND</b><br />\n";
|
|
||||||
print "Create the file.<br />";
|
|
||||||
print "For example:<br />\n";
|
|
||||||
print "<pre>% cp config.inc.php.sample config.inc.php</pre>\n";
|
|
||||||
$error =+ 1;
|
|
||||||
}
|
|
||||||
print "<p />\n";
|
|
||||||
|
|
||||||
//
|
|
||||||
// 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 MariaDB 10 support on OpenBSD:<br />\n";
|
|
||||||
print "% pkg_add php-mysqli</pre>\n";
|
|
||||||
print "To install PostgreSQL support on OpenBSD:<br />\n";
|
|
||||||
print "% pkg_add php-pgsql</pre>\n";
|
|
||||||
$error =+ 1;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// MariaDB functions
|
|
||||||
//
|
|
||||||
if ($f_mysqli_connect == 1) {
|
|
||||||
print "- Depends on: MariaDB - OK<br />\n";
|
|
||||||
}
|
|
||||||
print "<p />\n";
|
|
||||||
|
|
||||||
//
|
|
||||||
// PostgreSQL functions
|
|
||||||
//
|
|
||||||
if ($f_pg_connect == 1) {
|
|
||||||
print "- Depends on: PostgreSQL - OK (change the database_type in config.inc.php!!)<br />\n";
|
|
||||||
}
|
|
||||||
print "<p />\n";
|
|
||||||
|
|
||||||
//
|
|
||||||
// Session functions
|
|
||||||
//
|
|
||||||
if ($f_session_start == 1) {
|
|
||||||
print "- Depends on: session - OK<br />\n";
|
|
||||||
} else {
|
|
||||||
print "<li><b>Error: Depends on: session - NOT FOUND</b><br />\n";
|
|
||||||
print "To install session support on FreeBSD:<br />\n";
|
|
||||||
print "<pre>% cd /usr/ports/www/php$phpversion-session/\n";
|
|
||||||
print "% make clean install\n";
|
|
||||||
print " - or with portupgrade -\n";
|
|
||||||
print "% portinstall php$phpversion-session</pre>\n";
|
|
||||||
$error =+ 1;
|
|
||||||
}
|
|
||||||
print "<p />\n";
|
|
||||||
|
|
||||||
//
|
|
||||||
// PCRE functions
|
|
||||||
//
|
|
||||||
if ($f_preg_match == 1) {
|
|
||||||
print "- Depends on: pcre - OK<br />\n";
|
|
||||||
} else {
|
|
||||||
print "<li><b>Error: Depends on: pcre - NOT FOUND</b><br />\n";
|
|
||||||
print "To install pcre support on FreeBSD:<br />\n";
|
|
||||||
print "<pre>% cd /usr/ports/devel/php$phpversion-pcre/\n";
|
|
||||||
print "% make clean install\n";
|
|
||||||
print " - or with portupgrade -\n";
|
|
||||||
print "% portinstall php$phpversion-pcre</pre>\n";
|
|
||||||
$error =+ 1;
|
|
||||||
}
|
|
||||||
print "<p />\n";
|
|
||||||
|
|
||||||
if ($error == 0) {
|
|
||||||
print "Everything seems fine... you are ready to rock & roll!</br>\n";
|
|
||||||
print "<b>Make sure you delete this setup.php file!</b><br />\n";
|
|
||||||
print "Also check the config.inc.php file for any settings that you might need to change!<br />\n";
|
|
||||||
print "Click here to go to the <a href=\"admin/index.php\">admin section</a> (make sure that your .htaccess is setup properly)\n";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
Loading…
Reference in New Issue