r20160215

This commit is contained in:
flash 2016-02-15 22:20:46 +01:00
parent ee0fa1906c
commit bbfd22d14d
14 changed files with 248 additions and 548 deletions

View file

@ -51,7 +51,7 @@ class BBcode
$emotes = Database::fetch('emoticons'); $emotes = Database::fetch('emoticons');
// Parse all emoticons // Parse all emoticons
foreach($emotes as $emote) { foreach ($emotes as $emote) {
$image = "<img src='{$emote['emote_path']}' alt='{$emote['emote_string']}' class='emoticon' />"; $image = "<img src='{$emote['emote_path']}' alt='{$emote['emote_string']}' class='emoticon' />";
$icon = preg_quote($emote['emote_string'], '#'); $icon = preg_quote($emote['emote_string'], '#');
$text = preg_replace("#$icon#", $image, $text); $text = preg_replace("#$icon#", $image, $text);

View file

@ -23,7 +23,7 @@ class Config
private static $local = []; private static $local = [];
/** /**
* Container for the configuration stored in the database. * Cache for the configuration stored in the database.
* *
* @var array * @var array
*/ */
@ -36,7 +36,6 @@ class Config
*/ */
public static function init($local) public static function init($local)
{ {
// Check if the configuration file exists // Check if the configuration file exists
if (!file_exists($local)) { if (!file_exists($local)) {
trigger_error('Local configuration file does not exist', E_USER_ERROR); trigger_error('Local configuration file does not exist', E_USER_ERROR);
@ -58,27 +57,6 @@ class Config
} }
} }
/**
* Fetch configuration values from the database.
*/
public static function initDB()
{
// Get config table from the database
$_DATA = Database::fetch('config', true);
// Create variable to temporarily store values in
$_DBCN = [];
// Properly sort the values
foreach ($_DATA as $_CONF) {
$_DBCN[$_CONF['config_name']] = $_CONF['config_value'];
}
// Assign the temporary array to the static one
self::$database = $_DBCN;
}
/** /**
* Get a value from the local configuration file. * Get a value from the local configuration file.
* *
@ -89,7 +67,6 @@ class Config
*/ */
public static function local($key, $subkey = null) public static function local($key, $subkey = null)
{ {
// Check if the key that we're looking for exists // Check if the key that we're looking for exists
if (array_key_exists($key, self::$local)) { if (array_key_exists($key, self::$local)) {
if ($subkey) { if ($subkey) {
@ -119,11 +96,16 @@ class Config
*/ */
public static function get($key, $returnNull = false) public static function get($key, $returnNull = false)
{ {
// Check if the key that we're looking for exists // Check if the key that we're looking for exists
if (array_key_exists($key, self::$database)) { if (array_key_exists($key, self::$database)) {
// Then return the value // Then return the value
return self::$database[$key]; return self::$database[$key];
} else {
$value = Database::fetch('config', false, ['config_name' => [$key, '=']]);
if ($value) {
self::$database[$key] = $value['config_value'];
return self::$database[$key];
}
} }
// Then return the value // Then return the value

View file

@ -15,7 +15,7 @@ use Sakura\Template;
* @package Sakura * @package Sakura
* @author Julian van de Groep <me@flash.moe> * @author Julian van de Groep <me@flash.moe>
*/ */
class Auth class Auth extends Controller
{ {
public function login() public function login()
{ {

View file

@ -0,0 +1,18 @@
<?php
/**
* Holds the base controller.
*
* @package Sakura
*/
namespace Sakura\Controllers;
/**
* Base controller (which other controllers should extend on).
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Controller
{
}

View file

@ -0,0 +1,154 @@
<?php
/**
* Holds the file controller.
*
* @package Sakura
*/
namespace Sakura\Controllers;
use Sakura\Config;
use Sakura\User;
use Sakura\File;
use Sakura\Perms\Site;
/**
* File controller, handles user uploads like avatars.
*
* @package Sakura
* @author Julian van de Groep <me@flash.moe>
*/
class Files extends Controller
{
private function serveImage($data, $mime, $name)
{
// Add original filename
header('Content-Disposition: inline; filename="' . $name . '"');
// Set content type
header('Content-Type: ' . $mime);
// Return image data
return $data;
}
public function avatar($id = 0)
{
global $templateName;
$noAvatar = ROOT . str_replace(
'{{ TPL }}',
$templateName,
Config::get('no_avatar_img')
);
$none = [
'name' => basename($noAvatar),
'data' => file_get_contents($noAvatar),
'mime' => getimagesizefromstring($noAvatar)['mime'],
];
$deactivePath = ROOT . str_replace(
'{{ TPL }}',
$templateName,
Config::get('deactivated_avatar_img')
);
$deactive = [
'name' => basename($deactivePath),
'data' => file_get_contents($deactivePath),
'mime' => getimagesizefromstring($deactivePath)['mime'],
];
$bannedPath = ROOT . str_replace(
'{{ TPL }}',
$templateName,
Config::get('banned_avatar_img')
);
$banned = [
'name' => basename($bannedPath),
'data' => file_get_contents($bannedPath),
'mime' => getimagesizefromstring($bannedPath)['mime'],
];
$user = User::construct($id);
if ($user->permission(Site::DEACTIVATED)) {
return $this->serveImage($deactive['data'], $deactive['mime'], $deactive['name']);
}
if ($user->checkBan() || $user->permission(Site::RESTRICTED)) {
return $this->serveImage($banned['data'], $banned['mime'], $banned['name']);
}
if (!$user->avatar) {
return $this->serveImage($none['data'], $none['mime'], $none['name']);
}
$serve = new File($user->avatar);
if (!$serve->id) {
return $this->serveImage($none['data'], $none['mime'], $none['name']);
}
return $this->serveImage($serve->data, $serve->mime, $serve->name);
}
public function background($id = 0)
{
global $templateName;
$noBg = ROOT . Config::get('no_background_img');
$none = [
'name' => basename($noBg),
'data' => file_get_contents($noBg),
'mime' => getimagesizefromstring($noBg)['mime'],
];
if (!$id) {
return $this->serveImage($none['data'], $none['mime'], $none['name']);
}
$user = User::construct($id);
if ($user->permission(Site::DEACTIVATED) || $user->checkBan() || $user->permission(Site::RESTRICTED) || !$user->background) {
return $this->serveImage($none['data'], $none['mime'], $none['name']);
}
$serve = new File($user->background);
if (!$serve->id) {
return $this->serveImage($none['data'], $none['mime'], $none['name']);
}
return $this->serveImage($serve->data, $serve->mime, $serve->name);
}
public function header($id = 0)
{
global $templateName;
$noHeader = ROOT . Config::get('no_header_img');
$none = [
'name' => basename($noHeader),
'data' => file_get_contents($noHeader),
'mime' => getimagesizefromstring($noHeader)['mime'],
];
if (!$id) {
return $this->serveImage($none['data'], $none['mime'], $none['name']);
}
$user = User::construct($id);
if ($user->permission(Site::DEACTIVATED) || $user->checkBan() || $user->permission(Site::RESTRICTED) || !$user->header) {
return $this->serveImage($none['data'], $none['mime'], $none['name']);
}
$serve = new File($user->header);
if (!$serve->id) {
return $this->serveImage($none['data'], $none['mime'], $none['name']);
}
return $this->serveImage($serve->data, $serve->mime, $serve->name);
}
}

View file

@ -22,7 +22,7 @@ use Sakura\Utils;
* @package Sakura * @package Sakura
* @author Julian van de Groep <me@flash.moe> * @author Julian van de Groep <me@flash.moe>
*/ */
class Forums class Forums extends Controller
{ {
/** /**
* Serves the forum index. * Serves the forum index.

View file

@ -16,12 +16,12 @@ use Sakura\Users;
use Sakura\Utils; use Sakura\Utils;
/** /**
* Meta page controllers (sections that aren't big enough to warrant a dedicated controller class). * Meta page controllers (sections that aren't big enough to warrant a dedicated controller).
* *
* @package Sakura * @package Sakura
* @author Julian van de Groep <me@flash.moe> * @author Julian van de Groep <me@flash.moe>
*/ */
class Meta class Meta extends Controller
{ {
/** /**
* Serves the site index. * Serves the site index.

View file

@ -23,7 +23,7 @@ use Sakura\Perms\Site;
* @package Sakura * @package Sakura
* @author Julian van de Groep <me@flash.moe> * @author Julian van de Groep <me@flash.moe>
*/ */
class Premium class Premium extends Controller
{ {
public function index() public function index()
{ {
@ -96,8 +96,7 @@ class Premium
// Attempt to complete the transaction // Attempt to complete the transaction
try { try {
$finalise = Payments::completeTransaction($_GET['paymentId'], $_GET['PayerID']); $finalise = Payments::completeTransaction($_GET['paymentId'], $_GET['PayerID']);
} } catch (Exception $e) {
catch (Exception $e) {
return trigger_error('Something went horribly wrong.', E_USER_ERROR); return trigger_error('Something went horribly wrong.', E_USER_ERROR);
} }

View file

@ -20,7 +20,7 @@ use Sakura\Utils;
* @package Sakura * @package Sakura
* @author Julian van de Groep <me@flash.moe> * @author Julian van de Groep <me@flash.moe>
*/ */
class User class User extends Controller
{ {
/** /**
* Display the profile of a user. * Display the profile of a user.

View file

@ -143,10 +143,8 @@ class Router
// Handle the request // Handle the request
try { try {
try { return self::$dispatcher->dispatch($method, $url);
return self::$dispatcher->dispatch($method, $url); } catch (HttpMethodNotAllowedException $e) {
} catch (HttpMethodNotAllowedException $e) {
}
} catch (HttpRouteNotFoundException $e) { } catch (HttpRouteNotFoundException $e) {
} }

View file

@ -1,191 +0,0 @@
<?php
/*
* Sakura user image serving
*/
// Declare Namespace
namespace Sakura;
// Define that this page won't require templating
define('SAKURA_NO_TPL', true);
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Check if the m(ode) GET request is set
if (isset($_GET['m'])) {
switch ($_GET['m']) {
case 'avatar':
// Set paths
$noAvatar = ROOT . str_replace(
'{{ TPL }}',
$templateName,
Config::get('no_avatar_img')
);
$deactiveAvatar = ROOT . str_replace(
'{{ TPL }}',
$templateName,
Config::get('deactivated_avatar_img')
);
$bannedAvatar = ROOT . str_replace(
'{{ TPL }}',
$templateName,
Config::get('banned_avatar_img')
);
// If ?u= isn't set or if it isn't numeric
if (!isset($_GET['u']) || !is_numeric($_GET['u'])) {
$serveImage = $noAvatar;
break;
}
// Get user data
$user = User::construct($_GET['u']);
// If user is deactivated use deactive avatar
if ($user->permission(Perms\Site::DEACTIVATED)) {
$serveImage = $deactiveAvatar;
break;
}
// Check if user is banned
if ($user->checkBan() || $user->permission(Perms\Site::RESTRICTED)) {
$serveImage = $bannedAvatar;
break;
}
// Check if user has an avatar set
if (!$user->avatar) {
$serveImage = $noAvatar;
break;
}
// Attempt to get the file
$serve = new File($user->avatar);
// Check if the file exists
if (!$serve->id) {
$serveImage = $noAvatar;
break;
}
// Check if the avatar exist and assign it to a value
$serveImage = $serve->data;
$serveMime = $serve->mime;
$serveName = $serve->name;
break;
case 'background':
// Set paths
$noBackground = ROOT . Config::get('no_background_img');
// If ?u= isn't set or if it isn't numeric
if (!isset($_GET['u']) || !is_numeric($_GET['u'])) {
$serveImage = $noBackground;
break;
}
// Get user data
$user = User::construct($_GET['u']);
// If user is deactivated use deactive avatar
if ($user->permission(Perms\Site::DEACTIVATED)) {
$serveImage = $noBackground;
break;
}
// Check if user is banned
if (Bans::checkBan($_GET['u']) || $user->permission(Perms\Site::RESTRICTED)) {
$serveImage = $noBackground;
break;
}
// Check if user has a background set
if (!$user->background) {
$serveImage = $noBackground;
break;
}
// Attempt to get the file
$serve = new File($user->background);
// Check if the file exists
if (!$serve->id) {
$serveImage = $noBackground;
break;
}
// Check if the avatar exist and assign it to a value
$serveImage = $serve->data;
$serveMime = $serve->mime;
$serveName = $serve->name;
break;
case 'header':
// Set paths
$noHeader = ROOT . Config::get('no_header_img');
// If ?u= isn't set or if it isn't numeric
if (!isset($_GET['u']) || !is_numeric($_GET['u'])) {
$serveImage = $noHeader;
break;
}
// Get user data
$user = User::construct($_GET['u']);
// If user is deactivated use deactive avatar
if ($user->permission(Perms\Site::DEACTIVATED)) {
$serveImage = $noHeader;
break;
}
// Check if user is banned
if (Bans::checkBan($_GET['u']) || $user->permission(Perms\Site::RESTRICTED)) {
$serveImage = $noHeader;
break;
}
// Check if user has a header set
if (!$user->header) {
$serveImage = $noHeader;
break;
}
// Attempt to get the file
$serve = new File($user->header);
// Check if the file exists
if (!$serve->id) {
$serveImage = $noHeader;
break;
}
// Check if the avatar exist and assign it to a value
$serveImage = $serve->data;
$serveMime = $serve->mime;
$serveName = $serve->name;
break;
default:
$serveImage = ROOT . Config::get('pixel_img');
}
} else {
$serveImage = ROOT . Config::get('pixel_img');
}
// Do some more checks
if (!isset($serveName) || !isset($serveMime)) {
$serveName = basename($serveImage);
$serveImage = file_get_contents($serveImage);
$serveMime = getimagesizefromstring($serveImage)['mime'];
}
// Add original filename
header('Content-Disposition: inline; filename="' . $serveName . '"');
// Set content type
header('Content-Type: ' . $serveMime);
echo $serveImage;

View file

@ -1,313 +0,0 @@
<?php
/*
* Sakura Management
*/
// Declare Namespace
namespace Sakura;
use Sakura\Perms\Site;
use Sakura\Perms\Manage;
// Define that we are in Management mode
define('SAKURA_MANAGE', true);
// Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Make sure user has the permissions to view this
if (!$currentUser->permission(Manage::USE_MANAGE, Perms::MANAGE)) {
// Set parse variables
Template::vars($renderData);
// Print page contents
echo Template::render('global/restricted');
exit;
}
// Modes
$pages = [
'general' => [
'title' => 'General',
'modes' => [
'dashboard' => [
'title' => 'Dashboard',
'description' => [
'Welcome to the Broomcloset! Here\'s a quick overview of the site.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'info' => [
'title' => 'Info pages',
'description' => [
'Manage and edit the info pages.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
],
],
'config' => [
'title' => 'Configuration',
'modes' => [
'general' => [
'title' => 'General',
'description' => [
'Manages the appearance of the site and most other options that don\'t need their own category.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'uploads' => [
'title' => 'Uploads',
'description' => [
'Settings regarding uploads like avatars and backgrounds.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'premium' => [
'title' => 'Premium',
'description' => [
'Alters the way the premium system works.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'user' => [
'title' => 'User',
'description' => [
'Settings regarding users such as registration.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'mail' => [
'title' => 'Mail',
'description' => [
'How will Sakura send e-mails.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
],
],
'forums' => [
'title' => 'Forums',
'modes' => [
'manage' => [
'title' => 'Manage',
'description' => [
'Change the forums.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'settings' => [
'title' => 'Settings',
'description' => [
'Alter settings specific to the forum.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
],
],
'comments' => [
'title' => 'Comments',
'modes' => [
'manage' => [
'title' => 'Manage',
'description' => [
'View all the comment categories.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
],
],
'users' => [
'title' => 'Users',
'modes' => [
'manage-users' => [
'title' => 'Manage users',
'description' => [
'View and change users.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'manage-ranks' => [
'title' => 'Manage ranks',
'description' => [
'View and change ranks.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'profile-fields' => [
'title' => 'Profile fields',
'description' => [
'Manage the custom profile fields.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'option-fields' => [
'title' => 'Option fields',
'description' => [
'Manage the custom option fields.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'bans' => [
'title' => 'Bans',
'description' => [
'Banning users.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'warnings' => [
'title' => 'Warnings',
'description' => [
'Warn users.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
],
],
'permissions' => [
'title' => 'Permissions',
'modes' => [
'site' => [
'title' => 'Manage site',
'description' => [
'Alter the global site perms.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'management' => [
'title' => 'Manage management',
'description' => [
'Alter the management/moderation perms.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'forum' => [
'title' => 'Manage forums',
'description' => [
'Alter the perms of the forums.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
],
],
'logs' => [
'title' => 'Logs',
'modes' => [
'actions' => [
'title' => 'Actions',
'description' => [
'Viewing the global action logs.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'management' => [
'title' => 'Management',
'description' => [
'Viewing the management actions taken by staff.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
'errors' => [
'title' => 'Errors',
'description' => [
'Viewing the PHP error logs Sakura was able to log.',
],
'access' => !$currentUser->permission(Site::DEACTIVATED),
'menu' => true,
],
],
],
];
// Current settings page
$category = isset($_GET['cat']) ? (
array_key_exists($_GET['cat'], $pages) ? $_GET['cat'] : false
) : array_keys($pages)[0];
$mode = false;
// Only continue setting mode if $category is true
if ($category) {
$mode = isset($_GET['mode']) && $category ? (
array_key_exists($_GET['mode'], $pages[$category]['modes']) ? $_GET['mode'] : false
) : array_keys($pages[$category]['modes'])[0];
}
// Not found
if (!$category
|| empty($category)
|| !$mode
|| empty($mode)
|| !$pages[$category]['modes'][$mode]['access']) {
header('HTTP/1.0 404 Not Found');
// Set parse variables
Template::vars($renderData);
// Print page contents
echo Template::render('global/notfound');
exit;
}
// Set templates directory
$renderData['templates'] = 'manage';
// Render data
$renderData['current'] = $category . '.' . $mode;
// Settings pages
$renderData['pages'] = $pages;
// Page data
$renderData['page'] = [
'category' => $pages[$category]['title'],
'mode' => $pages[$category]['modes'][$mode]['title'],
'description' => $pages[$category]['modes'][$mode]['description'],
];
// Add special variables
switch ($category . '.' . $mode) {
case 'general.dashboard':
$renderData = array_merge($renderData, [
'stats' => [
'postcount' => Database::count('posts')[0],
'threadcount' => Database::count('topics')[0],
'commentcount' => Database::count('comments')[0],
'userscount' => Database::count('users')[0],
'bancount' => Database::count('bans')[0],
'uploadcount' => count(glob(ROOT . Config::get('user_uploads') . '/*')) - 1,
],
]);
break;
case 'logs.errors':
$errorLog = Database::fetch('error_log', true, null, ['error_id', true]);
$renderData = array_merge($renderData, ['errors' => $errorLog]);
break;
}
// Set parse variables
Template::vars($renderData);
// Print page contents
echo Template::render('main/settings');

View file

@ -25,16 +25,53 @@ Router::get('/forum', 'Forums@index', 'forums.index');
Router::get('/forum/{id}', 'Forums@forum', 'forums.forum'); Router::get('/forum/{id}', 'Forums@forum', 'forums.forum');
// Members // Members
Router::get('/members', 'User@members', 'members.all'); Router::get('/members', 'User@members', 'members.index');
Router::get('/members/{rank}', 'User@members', 'members.rank'); Router::get('/members/{rank}', 'User@members', 'members.rank');
// User // User
Router::get('/u/{id}', 'User@profile', 'user.profile'); Router::get('/u/{id}', 'User@profile', 'user.profile');
Router::get('/u/{id}/header', 'Files@header', 'user.header');
// Files
Router::get('/a/{id}', 'Files@avatar', 'file.avatar');
Router::get('/bg/{id}', 'Files@background', 'file.background');
// Premium // Premium
Router::get('/support', 'Premium@index', 'premium.index'); Router::get('/support', 'Premium@index', 'premium.index');
Router::get('/support/tracker', 'Premium@tracker', 'premium.tracker'); Router::get('/support/tracker', 'Premium@tracker', 'premium.tracker');
// Management
/*
* General
* - Dashboard
* - Info pages (possibly deprecate with wiki)
* Configuration
* - General
* - Files
* - User
* - Mail
* Forums
* - Manage
* - Settings
* Comments
* - Manage
* Users
* - Manage users
* - Manage ranks
* - Profile fields
* - Option fields
* - Bans and restrictions
* - Warnings
* Permissions
* - Site
* - Management
* - Forum
* Logs
* - Actions
* - Management
* - Errors
*/
// Redirections // Redirections
Router::any('/index.php', function () { Router::any('/index.php', function () {
// Info pages // Info pages
@ -130,6 +167,25 @@ Router::any('/support.php', function () {
header('Location: /support'); header('Location: /support');
}); });
Router::any('/imageserve.php', function () {
// Category + post
if (isset($_REQUEST['u']) && isset($_REQUEST['m'])) {
switch ($_REQUEST['m']) {
case 'avatar':
header('Location: /a/' . $_REQUEST['u']);
return;
case 'background':
header('Location: /bg/' . $_REQUEST['u']);
return;
case 'header':
header('Location: /u/' . $_REQUEST['u'] . '/header');
return;
}
}
header('Location: /bg/0');
});
Router::any('/faq.php', function () { Router::any('/faq.php', function () {
header('Location: /faq'); header('Location: /faq');
}); });

View file

@ -8,7 +8,7 @@
namespace Sakura; namespace Sakura;
// Define Sakura version // Define Sakura version
define('SAKURA_VERSION', '20160214'); define('SAKURA_VERSION', '20160215');
define('SAKURA_VLABEL', 'Amethyst'); define('SAKURA_VLABEL', 'Amethyst');
define('SAKURA_COLOUR', '#9966CC'); define('SAKURA_COLOUR', '#9966CC');
@ -25,7 +25,7 @@ set_time_limit(0);
// Set internal encoding method // Set internal encoding method
mb_internal_encoding('utf-8'); mb_internal_encoding('utf-8');
// Stop the execution if the PHP Version is older than 5.4.0 // Stop the execution if the PHP Version is older than 5.5.0
if (version_compare(phpversion(), '5.5.0', '<')) { if (version_compare(phpversion(), '5.5.0', '<')) {
die('Sakura requires at least PHP 5.5.0, please upgrade to a newer PHP version.'); die('Sakura requires at least PHP 5.5.0, please upgrade to a newer PHP version.');
} }
@ -64,9 +64,6 @@ error_reporting(Config::local('dev', 'show_errors') ? -1 : 0);
// Make the database connection // Make the database connection
Database::init(Config::local('database', 'driver')); Database::init(Config::local('database', 'driver'));
// Load the configuration stored in the database
Config::initDB();
// Check if we're using console // Check if we're using console
if (php_sapi_name() === 'cli' && !defined('SAKURA_CRON')) { if (php_sapi_name() === 'cli' && !defined('SAKURA_CRON')) {
$console = new Console\Application; $console = new Console\Application;