This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/sakura.php

85 lines
2 KiB
PHP
Raw Normal View History

2015-04-01 15:35:27 +00:00
<?php
/*
2016-07-26 17:29:53 +00:00
* Community Management System
2016-02-02 21:04:15 +00:00
* (c) 2013-2016 Julian van de Groep <http://flash.moe>
2015-04-01 15:35:27 +00:00
*/
// Declare namespace
namespace Sakura;
// Define Sakura version
2016-07-26 17:29:53 +00:00
define('SAKURA_VERSION', 20160726);
2015-04-01 15:35:27 +00:00
// Define Sakura Path
define('ROOT', __DIR__ . '/');
2015-04-01 15:35:27 +00:00
2015-12-04 14:19:10 +00:00
// Turn error reporting on for the initial startup sequence
error_reporting(-1);
2015-04-01 15:35:27 +00:00
2016-01-26 18:09:18 +00:00
// Override expiration variables
ignore_user_abort(true);
set_time_limit(0);
2015-07-05 00:03:15 +00:00
// Set internal encoding method
mb_internal_encoding('utf-8');
2016-03-27 22:15:51 +00:00
// Stop the execution if the PHP Version is older than 7.0.0
if (version_compare(phpversion(), '7.0.0', '<')) {
2016-04-25 02:01:14 +00:00
throw new Exception('Sakura requires at least PHP 7.0.0, please upgrade to a newer PHP version.');
2015-08-23 22:08:36 +00:00
}
2016-02-27 16:46:16 +00:00
// Check if the composer autoloader exists
if (!file_exists(ROOT . 'vendor/autoload.php')) {
2016-04-25 02:01:14 +00:00
throw new Exception('Autoloader not found, did you run composer install?');
}
2016-02-27 16:46:16 +00:00
// Require composer libraries
require_once ROOT . 'vendor/autoload.php';
// Load the local configuration
Config::init(ROOT . 'config/config.ini');
2015-05-29 19:27:45 +00:00
2016-04-01 21:44:31 +00:00
// Set Error handler
set_error_handler('error_handler');
2015-12-04 14:19:10 +00:00
// Change error reporting according to the dev configuration
2016-07-26 17:29:53 +00:00
error_reporting(config('dev.show_errors') ? -1 : 0);
2015-12-04 14:19:10 +00:00
2016-02-25 16:06:29 +00:00
// Create a new database capsule
2016-07-26 17:29:53 +00:00
$capsule = new DB;
2016-02-25 16:06:29 +00:00
// Add the connection
2016-07-26 17:29:53 +00:00
$capsule->addConnection(config('database'));
2016-02-25 16:06:29 +00:00
// Make the capsule globally accessible
$capsule->setAsGlobal();
2015-05-29 19:27:45 +00:00
// Start output buffering
2016-07-26 17:29:53 +00:00
ob_start(config('performance.compression') ? 'ob_gzhandler' : null);
2015-04-01 15:35:27 +00:00
2016-01-30 00:18:23 +00:00
// Initialise the router
Router::init();
// Include routes file
include_once ROOT . 'routes.php';
2016-03-31 20:03:25 +00:00
// Initialise the current session
2016-07-26 17:29:53 +00:00
$cookiePrefix = config('cookie.prefix');
// ActiveUser::init(
// intval($_COOKIE["{$cookiePrefix}id"] ?? 0),
// $_COOKIE["{$cookiePrefix}session"] ?? ''
// );
// Start templating engine
Template::set(config('general.design'));
// Set base page rendering data
Template::vars([
'get' => $_GET,
'user' => ActiveUser::$user,
'post' => $_POST,
'server' => $_SERVER,
'request' => $_REQUEST,
//'session' => $_SESSION,
]);