]> git.agnieray.net Git - galette.git/blobdiff - galette/includes/galette.inc.php
Bump version
[galette.git] / galette / includes / galette.inc.php
index 1841ec3e7e004b68434332a9e59b1b7c5e066e29..a31bf6b2467456373374af2b90411363e4cc7f8d 100644 (file)
@@ -7,7 +7,7 @@
  *
  * PHP version 5
  *
- * Copyright © 2009-2018 The Galette Team
+ * Copyright © 2009-2021 The Galette Team
  *
  * This file is part of Galette (http://galette.tuxfamily.org).
  *
@@ -28,9 +28,8 @@
  * @package   Galette
  *
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2007-2018 The Galette Team
+ * @copyright 2007-2021 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
- * @version   SVN: $Id$
  * @link      http://galette.tuxfamily.org
  * @since     Available since 0.7-dev - 2007-10-07
  */
@@ -69,36 +68,27 @@ $installed = file_exists(GALETTE_CONFIG_PATH . 'config.inc.php');
 if (!$installed && !$installer) {
     header('location: ./installer.php');
     die();
+} else if ($installed) {
+    include_once GALETTE_CONFIG_PATH . 'config.inc.php';
 }
 
-if (file_exists(GALETTE_CONFIG_PATH . 'behavior.inc.php')
+if (
+    file_exists(GALETTE_CONFIG_PATH . 'behavior.inc.php')
     && !defined('GALETTE_TESTS') && !$cron
 ) {
     include_once GALETTE_CONFIG_PATH . 'behavior.inc.php';
 }
 
-if (isset($installer) && $installer !== true) {
-    //If we're not working from installer
-    include_once GALETTE_CONFIG_PATH . 'config.inc.php';
-}
-
 use Analog\Analog;
 use Analog\Handler;
 use Analog\Handler\LevelName;
 use Galette\Core;
 
-/*
-BREAKS as of Galette 0.9-dev
-// To help the built-in PHP dev server, check if the request was actually for
-// something which should probably be served as a static file
-if (PHP_SAPI === 'cli-server' && $_SERVER['SCRIPT_FILENAME'] !== __FILE__) {
-    return false;
-}*/
-
 require GALETTE_ROOT . '/vendor/autoload.php';
 
 //start profiling
-if (defined('GALETTE_XHPROF_PATH')
+if (
+    defined('GALETTE_XHPROF_PATH')
     && function_exists('xhprof_enable')
 ) {
     include_once __DIR__ . '/../lib/Galette/Common/XHProf.php';
@@ -107,51 +97,53 @@ if (defined('GALETTE_XHPROF_PATH')
 }
 
 define('GALETTE_NIGHTLY', false);
-define('GALETTE_VERSION', 'v0.9.4-dev');
+define('GALETTE_VERSION', 'v0.9.5.2');
 
 //Version to display
 if (!defined('GALETTE_HIDE_VERSION')) {
     define('GALETTE_DISPLAY_VERSION', \Galette\Core\Galette::gitVersion(false));
 }
 
-define('GALETTE_COMPAT_VERSION', '0.9.2');
-define('GALETTE_DB_VERSION', '0.940');
+define('GALETTE_COMPAT_VERSION', '0.9.5');
+define('GALETTE_DB_VERSION', '0.950');
 if (!defined('GALETTE_MODE')) {
-    define('GALETTE_MODE', 'PROD'); //DEV, PROD, MAINT or DEMO
+    define('GALETTE_MODE', \Galette\Core\Galette::MODE_PROD);
 }
 
 if (!isset($_COOKIE['show_galette_dashboard'])) {
     setcookie(
         'show_galette_dashboard',
         true,
-        time() + 31536000 //valid for a year
+        [
+            'expires'   => time() + 31536000, //valid for a year
+            'path'      => '/'
+        ]
     );
 }
 
 if (!defined('GALETTE_DISPLAY_ERRORS')) {
-    if (GALETTE_MODE === 'DEV') {
+    if (GALETTE_MODE === \Galette\Core\Galette::MODE_DEV) {
         define('GALETTE_DISPLAY_ERRORS', 1);
     } else {
         define('GALETTE_DISPLAY_ERRORS', 0);
     }
 }
-ini_set('display_errors', 0);
-
-set_include_path(
-    GALETTE_ZEND_PATH . PATH_SEPARATOR .
-    GALETTE_PHP_MAILER_PATH . PATH_SEPARATOR .
-    GALETTE_SMARTY_PATH . PATH_SEPARATOR .
-    get_include_path()
-);
+ini_set('display_errors', (defined('GALETTE_TESTS') ? '1' : '0'));
 
 /*------------------------------------------------------------------------------
 Logger stuff
 ------------------------------------------------------------------------------*/
 
+error_reporting(E_ALL);
+set_error_handler(function ($severity, $message, $file, $line) {
+    if (error_reporting() & $severity) {
+        throw new \ErrorException($message, 0, $severity, $file, $line);
+    }
+});
+
 //change default format so the 3rd param is a string for level name
 Analog::$format = "%s - %s - %s - %s\n";
 $galette_run_log = null;
-$galette_debug_log = Handler\Ignore::init();
 
 if (!defined('GALETTE_LOG_LVL')) {
     if (GALETTE_MODE === 'DEV') {
@@ -167,59 +159,33 @@ if (defined('GALETTE_TESTS')) {
     $log_path = GALETTE_LOGS_PATH . 'tests.log';
     $galette_run_log = LevelName::init(Handler\File::init($log_path));
 } else {
-    if ((!$installer || ($installer && defined('GALETTE_LOGGER_CHECKED'))) && !$cron) {
-        if (GALETTE_LOG_LVL >= Analog::INFO) {
-            $now = new \DateTime();
-            $dbg_log_path = GALETTE_LOGS_PATH . 'galette_debug_' .
-                $now->format('Y-m-d') . '.log';
-            $galette_debug_log = LevelName::init(Handler\File::init($dbg_log_path));
-        } else {
-            $galette_debug_log = Handler\Ignore::init();
-        }
-    }
     $galette_log_var = null;
 
-    if (defined('GALETTE_SYS_LOG') && GALETTE_SYS_LOG === true) {
-        //logs everything in PHP logs (per chance /var/log/http/error_log or /var/log/php-fpm/error.log)
-        $galette_run_log = Handler\Syslog::init('galette', 'user');
-    } else {
-        if (!$installer || ($installer && defined('GALETTE_LOGGER_CHECKED'))) {
-            //logs everything in galette log file
-            if (!isset($logfile)) {
-                //if no filename has been setted (ie. from install), set default one
-                $logfile = 'galette_run';
-            }
-            $log_path = GALETTE_LOGS_PATH . $logfile . '.log';
-            $galette_run_log = LevelName::init(Handler\File::init($log_path));
-        } else {
-            $galette_run_log = LevelName::init(Handler\Variable::init($galette_log_var));
+    if (!$installer || ($installer && defined('GALETTE_LOGGER_CHECKED'))) {
+        //logs everything in galette log file
+        if (!isset($logfile)) {
+            //if no filename has been setted (ie. from install), set default one
+            $logfile = 'galette';
         }
+        $log_path = GALETTE_LOGS_PATH . $logfile . '.log';
+        $galette_run_log = LevelName::init(Handler\File::init($log_path));
+    } else {
+        $galette_run_log = LevelName::init(Handler\Variable::init($galette_log_var));
     }
     if (!$installer) {
         Core\Logs::cleanup();
     }
 }
 
-Analog::handler(
-    Handler\Multi::init(
-        array(
-            Analog::NOTICE  => Handler\Threshold::init(
-                $galette_run_log,
-                GALETTE_LOG_LVL
-            ),
-            Analog::DEBUG   => $galette_debug_log
-        )
-    )
-);
+Analog::handler($galette_run_log);
 
 require_once GALETTE_ROOT . 'includes/functions.inc.php';
 
-if (!$installer and !defined('GALETTE_TESTS')) {
-    //If we're not working from installer nor from tests
-    include_once GALETTE_CONFIG_PATH . 'config.inc.php';
+//If we're not working from tests
+if ($installed && !defined('GALETTE_TESTS')) {
 
     /**
-     * Database instanciation
+     * Database instantiation
      */
     $zdb = new Core\Db();
 
@@ -255,3 +221,7 @@ if (!$installer and !defined('GALETTE_TESTS')) {
         $needs_update = true;
     }
 }
+
+$plugins = new Galette\Core\Plugins();
+//make sure plugins autoload is called before session start
+$plugins->autoload(GALETTE_PLUGINS_PATH);