Merge branch 'extended-cookie'
[scuttle] / header.inc.php
index de56c846196626b5bac800fd2a512689f1740a6c..9c23c12ddfa6c80b51b65415df1ed4aadb10b1f7 100644 (file)
@@ -1,35 +1,42 @@
 <?php
-ini_set('display_errors', '1');
-ini_set('mysql.trace_mode', '0');
-
-error_reporting(E_ALL ^ E_NOTICE);
-
-define('DEBUG', true);
 session_start();
 
-require_once(dirname(__FILE__) .'/services/servicefactory.php');
-require_once(dirname(__FILE__) .'/config.inc.php');
-require_once(dirname(__FILE__) .'/functions.inc.php');
+require_once dirname(__FILE__) .'/services/servicefactory.php';
+require_once dirname(__FILE__) .'/config.inc.php';
+require_once dirname(__FILE__) .'/functions.inc.php';
 
 // Determine the base URL
 if (!isset($root)) {
-    $pieces = explode('/', $_SERVER['SCRIPT_NAME']);
-    $root = '/';
-    foreach($pieces as $piece) {
-        if ($piece != '' && !strstr($piece, '.php')) {
-            $root .= $piece .'/';
-        }
-    }
-    if (($root != '/') && (substr($root, -1, 1) != '/')) {
-        $root .= '/';
+  $pieces = explode('/', $_SERVER['SCRIPT_NAME']);
+  $root   = '/';
+  foreach ($pieces as $piece) {
+    if ($piece != '' && !strstr($piece, '.php')) {
+      $root .= $piece .'/';
     }
-    $path = $root;
-    $root = 'http://'. $_SERVER['HTTP_HOST'] . $root;
+  }
+  if (($root != '/') && (substr($root, -1, 1) != '/')) {
+    $root .= '/';
+  }
+  $path = $root;
+
+  $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
+  $root     = $protocol .'://'. $_SERVER['HTTP_HOST'] . $root;
 }
 
-// Error codes
-define('GENERAL_MESSAGE', 200);
-define('GENERAL_ERROR', 202);
+define('GENERAL_MESSAGE',  200);
+define('GENERAL_ERROR',    202);
 define('CRITICAL_MESSAGE', 203);
-define('CRITICAL_ERROR', 204);
-?>
\ No newline at end of file
+define('CRITICAL_ERROR',   204);
+
+if (defined('SCUTTLE_DEBUG') && SCUTTLE_DEBUG) {
+  ini_set('display_errors',   '1');
+  ini_set('mysql.trace_mode', '1');
+  error_reporting(E_ALL);
+}
+else {
+  ini_set('display_errors',   '0');
+  ini_set('mysql.trace_mode', '0');
+  error_reporting(E_ALL);
+  //PHP5.4 PHP Notice:  Undefined variable:  PHP7 STOP deprecated and Warning
+  error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_USER_WARNING);
+}
\ No newline at end of file

Benjamin Mako Hill || Want to submit a patch?