diff --git a/setup.php b/setup.php index 98b3a8c..1cc1dc7 100644 --- a/setup.php +++ b/setup.php @@ -1,150 +1,47 @@ -// Copyright (c) 2022 High5! -// License Info: LICENSE.TXT -// -// File: index.php -// -// Template File: -none- -// -// Template Variables: -// -// -none- -// -// Form POST \ GET Variables: -// -// -none- -// +/** + * OpenSMTPD Admin Refactor + * by Jeroen Janssen + * Copyright (c) 2022 LAYLO + */ + +// Check whether the configuration file exists - bail if that is the case +if (file_exists(realpath("./config.inc.php"))) { + print 'It seems that config.inc.php is already configured. Please delete setup.php to continue.'; + die(); +} +// Define the app specifics +DEFINE('APP_NAME', 'OpenSMTPD Admin Setup Checker'); +DEFINE('VERSION', '1.1'); + +// Start generating the HTML output +$html = ''; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= '

' . APP_NAME . ' v' . VERSION . '

'; +$html .= '

It seems that you are running this version of OpenSMTPD Admin for the first time.

'; +$html .= ''; +$html .= ''; +$html .= ''; +$html .= (version_compare(PHP_VERSION, '7.4.0') >= 0) ? '' : ''; +$html .= ''; +$html .= ''; +$html .= (extension_loaded('mysqli')) ? '' : ' - PostgreSQL'; +$html .= ''; +$html .= ''; +$html .= (extension_loaded('pcre')) ? '' : ' - session_start'; +$html .= ''; +$html .= '
PHP version:' . phpversion() . '' . phpversion() . '
SQL support:MySQL/MariaDB' : 'MySQL/MariaDB'; +$html .= (extension_loaded('pgsql')) ? ' - PostgreSQL (change the database_type if you want to use PostgreSQL)
Functions:pcre' : 'pcre'; +$html .= (function_exists('get_magic_quotes_gpc')) ? ' - get_magic_quotes_gpc' : ' - get_magic_quotes_gpc'; +$html .= (function_exists('session_start')) ? ' - session_start
'; +$html .= ''; +$html .= ''; + +print $html; +die(); ?> - - -OpenSMTPD Admin Setup Checker - - - - -

Welcome to OpenSMTPD Admin

-

OpenSMTPD Admin Setup Checker 1.0

-It seems that you are running this version of OpenSMTPD Admin for the first time.
-

-This will tell you if all functions are available for OpenSMTPD Admin to run.
-

-If you still encounter any problems please check the documentation and website for more information.
-

-Running software:
-

-= 8) $phpversion = 8; - print "- PHP version " . phpversion() . "
\n"; -} else { - print "

  • Unable to check for PHP version. (missing function: phpversion())
    \n"; -} -print "

    \n"; -print "Checking for dependencies:
    \n"; -print "

    \n"; - -// -// Check for config.inc.php -// -if ($file_config == 1) { - print "- Depends on: presence config.inc.php - OK
    \n"; -} 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; -} -print "

    \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 "

  • Error: There is no database support in your PHP setup
    \n"; - print "To install MariaDB 10 support on OpenBSD:
    \n"; - print "% pkg_add php-mysqli\n"; - print "To install PostgreSQL support on OpenBSD:
    \n"; - print "% pkg_add php-pgsql\n"; - $error =+ 1; -} -// -// MariaDB functions -// -if ($f_mysqli_connect == 1) { - print "- Depends on: MariaDB - OK
    \n"; -} -print "

    \n"; - -// -// PostgreSQL functions -// -if ($f_pg_connect == 1) { - print "- Depends on: PostgreSQL - OK (change the database_type in config.inc.php!!)
    \n"; -} -print "

    \n"; - -// -// 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; -} -print "

    \n"; - -// -// 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 "

    \n"; - -if ($error == 0) { - print "Everything seems fine... you are ready to rock & roll!
    \n"; - print "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"; -} -?> - -