Explorar o código

#73 - maintenance mode

Alex Trofimov %!s(int64=12) %!d(string=hai) anos
pai
achega
7f2b93edf5
Modificáronse 1 ficheiros con 19 adicións e 14 borrados
  1. 19 14
      install/patterns/header.inc.php

+ 19 - 14
install/patterns/header.inc.php

@@ -89,26 +89,30 @@ define('BX_PROFILE_STATUS_PENDING', 'pending'); ///< profile status - pending, d
 
 define('BX_DOL_SECRET', '%SECRET%');
 
+if (file_exists(BX_DIRECTORY_PATH_ROOT . '.bx_maintenance') && !defined('BX_DOL_UPGRADING')) {
+    header('HTTP/1.0 503 Service Unavailable', true, 503);
+    header('Retry-After: 600');
+    if (file_exists(BX_DIRECTORY_PATH_ROOT . 'bx_maintenance.php'))
+        include(BX_DIRECTORY_PATH_ROOT . 'bx_maintenance.php');
+    else
+        echo 'Site is temporarily unavailable due to scheduled maintenance, please try again in a minute.';
+    exit;
+}
+
 define('CHECK_DOLPHIN_REQUIREMENTS', 1);
 if (defined('CHECK_DOLPHIN_REQUIREMENTS')) {
     $aErrors = array();
-    $aErrors[] = (ini_get('register_globals') == 0) ? '' : '<font color="red">register_globals is On (warning, you should have this param in Off state, or your site will unsafe)</font>';
-    $aErrors[] = (ini_get('safe_mode') == 0) ? '' : '<font color="red">safe_mode is On, disable it</font>';
-    $aErrors[] = (version_compare(PHP_VERSION, '5.2.0', '<')) ? '<font color="red">PHP version too old, please update to PHP 5.2.0 at least</font>' : '';
-    $aErrors[] = (!extension_loaded( 'mbstring')) ? '<font color="red">mbstring extension not installed. <b>Warning!</b> Dolphin cannot work without <b>mbstring</b> extension.</font>' : '';
-    if (version_compare(phpversion(), "5.2", ">") == 1) {
-        $aErrors[] = (ini_get('allow_url_include') == 0) ? '' : '<font color="red">allow_url_include is On (warning, you should have this param in Off state, or your site will unsafe)</font>';
-    };
+
+    $aErrors[] = (ini_get('register_globals') == 0) ? '' : '<b>register_globals</b> is on (you need to disable it, or your site will be unsafe)';
+    $aErrors[] = (ini_get('safe_mode') == 0) ? '' : '<b>safe_mode</b> is on (you need to disable it)';
+    $aErrors[] = (version_compare(PHP_VERSION, '5.2.0', '<')) ? 'PHP version is too old (please update to <b>PHP 5.2.0</b> at least)' : '';
+    $aErrors[] = (!extension_loaded( 'mbstring')) ? '<b>mbstring</b> extension not installed (Dolphin cannot work without it)' : '';
+    $aErrors[] = (ini_get('allow_url_include') == 0) ? '' : '<b>allow_url_include</b> is on (you need to disable it, or your site will be unsafe)';
 
     $aErrors = array_diff($aErrors, array('')); // delete empty
-    if (count($aErrors)) {
+    if (!empty($aErrors)) {
         $sErrors = implode(" <br /> ", $aErrors);
-        echo <<<EOF
-{$sErrors} <br />
-Please go to the <br />
-<a href="http://www.boonex.com/trac/dolphin/wiki/GenDolTShooter">Dolphin Troubleshooter</a> <br />
-and solve the problem.
-EOF;
+        echo '<p style="color:red;">' . $sErrors . '</p><p><a href="https://github.com/boonex/dolphin/wiki">Dolphin Wiki</a></p>';
         exit;
     }
 }
@@ -131,6 +135,7 @@ error_reporting(E_ALL);
 ini_set('magic_quotes_sybase', 0);
 mb_internal_encoding('UTF-8');
 mb_regex_encoding('UTF-8');
+date_default_timezone_set('UTC');
 
 // include files necessary for basic functionality
 require_once(BX_DIRECTORY_PATH_CLASSES . "BxDol.php");