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/sakura.php

148 lines
5.6 KiB
PHP
Raw Normal View History

2015-04-01 15:35:27 +00:00
<?php
/*
2015-05-24 22:06:53 +00:00
* Sakura Community Management System
2015-05-29 19:27:45 +00:00
* (c) 2013-2015 Flashwave <http://flash.moe> & Circlestorm <http://circlestorm.net>
2015-04-01 15:35:27 +00:00
*/
// Declare namespace
namespace Sakura;
// Define Sakura version
2015-08-18 13:13:40 +00:00
define('SAKURA_VERSION', '20150813');
2015-05-09 00:56:55 +00:00
define('SAKURA_VLABEL', 'Eminence');
define('SAKURA_COLOUR', '#6C3082');
2015-07-31 21:18:14 +00:00
define('SAKURA_STABLE', false);
2015-04-01 15:35:27 +00:00
// Define Sakura Path
2015-04-06 16:15:20 +00:00
define('ROOT', str_replace(basename(__DIR__), '', dirname(__FILE__)));
2015-04-01 15:35:27 +00:00
// Error Reporting: 0 for production and -1 for testing
2015-06-29 00:36:37 +00:00
error_reporting(SAKURA_STABLE ? 0 : -1);
2015-04-01 15:35:27 +00:00
2015-07-05 00:03:15 +00:00
// Set internal encoding method
mb_internal_encoding('utf-8');
2015-04-01 15:35:27 +00:00
// Include libraries
require_once ROOT .'_sakura/vendor/autoload.php';
require_once ROOT .'_sakura/components/Main.php';
require_once ROOT .'_sakura/components/Hashing.php';
require_once ROOT .'_sakura/components/Configuration.php';
2015-05-29 19:27:45 +00:00
require_once ROOT .'_sakura/components/Database.php';
2015-04-01 15:35:27 +00:00
require_once ROOT .'_sakura/components/Templates.php';
2015-05-29 19:27:45 +00:00
require_once ROOT .'_sakura/components/Permissions.php';
2015-04-01 15:35:27 +00:00
require_once ROOT .'_sakura/components/Sessions.php';
require_once ROOT .'_sakura/components/Users.php';
2015-05-03 16:25:57 +00:00
require_once ROOT .'_sakura/components/Forum.php';
2015-04-30 23:01:01 +00:00
require_once ROOT .'_sakura/components/Manage.php';
2015-07-30 01:12:53 +00:00
require_once ROOT .'_sakura/components/Bans.php';
2015-04-18 18:26:52 +00:00
require_once ROOT .'_sakura/components/Whois.php';
2015-06-29 12:40:00 +00:00
require_once ROOT .'_sakura/components/Payments.php';
2015-04-28 15:53:53 +00:00
require_once ROOT .'_sakura/components/SockChat.php';
2015-04-01 15:35:27 +00:00
2015-05-29 19:27:45 +00:00
// Include database extensions
2015-07-30 01:12:53 +00:00
foreach(glob(ROOT .'_sakura/components/database/*.php') as $driver) {
require_once $driver;
}
2015-04-01 15:35:27 +00:00
// Set Error handler
2015-04-30 23:01:01 +00:00
set_error_handler(array('Sakura\Main', 'errorHandler'));
2015-04-01 15:35:27 +00:00
2015-07-30 01:12:53 +00:00
// Initialise Main Class
2015-05-29 19:27:45 +00:00
Main::init(ROOT .'_sakura/config/config.ini');
// Start output buffering
ob_start(Configuration::getConfig('use_gzip') ? 'ob_gzhandler' : null);
2015-04-01 15:35:27 +00:00
2015-07-30 01:12:53 +00:00
if(!defined('SAKURA_NO_TPL')) {
// Set base page rendering data
$renderData = [
'sakura' => [
'version' => SAKURA_VERSION,
'vlabel' => SAKURA_VLABEL,
'vcolour' => SAKURA_COLOUR,
'stable' => SAKURA_STABLE,
'url_main' => Configuration::getConfig('url_main'),
'url_api' => Configuration::getConfig('url_api'),
'content_path' => Configuration::getConfig('content_path'),
'resources' => Configuration::getConfig('content_path') .'/data/'. strtolower(Templates::$_TPL),
2015-07-30 01:12:53 +00:00
'charset' => Configuration::getConfig('charset'),
'currentpage' => '//'. $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'],
'recaptcha_public' => Configuration::getConfig('recaptcha_public'),
'recaptcha_enable' => Configuration::getConfig('recaptcha'),
'disableregister' => Configuration::getConfig('disable_registration'),
'locksite' => Configuration::getConfig('lock_site'),
'locksitereason' => Configuration::getConfig('lock_site_reason'),
'lockauth' => Configuration::getConfig('lock_authentication'),
'requireregcodes' => Configuration::getConfig('require_registration_code'),
'requireactiveate' => Configuration::getConfig('require_activation'),
'sitename' => Configuration::getConfig('sitename'),
'sitedesc' => Configuration::getConfig('sitedesc'),
'sitetags' => implode(", ", json_decode(Configuration::getConfig('sitetags'), true)),
'cookieprefix' => Configuration::getConfig('cookie_prefix'),
'cookiedomain' => Configuration::getConfig('cookie_domain'),
'cookiepath' => Configuration::getConfig('cookie_path'),
'minpwdentropy' => Configuration::getConfig('min_entropy'),
'minusernamelength' => Configuration::getConfig('username_min_length'),
'maxusernamelength' => Configuration::getConfig('username_max_length'),
'disqus_shortname' => Configuration::getConfig('disqus_shortname'),
'disqus_api_key' => Configuration::getConfig('disqus_api_key'),
'date_format' => Configuration::getConfig('date_format')
2015-07-30 01:12:53 +00:00
],
'perms' => [
'canGetPremium' => Permissions::check('SITE', 'OBTAIN_PREMIUM', Session::$userId, 1),
'canUseForums' => Permissions::check('FORUM', 'USE_FORUM', Session::$userId, 1)
],
'php' => [
'sessionid' => \session_id(),
'time' => \time(),
'self' => $_SERVER['PHP_SELF']
],
'user' => [
'checklogin' => Users::checkLogin(),
'session' => Session::$sessionId,
'data' => ($_init_udata = Users::getUser(Session::$userId)),
'rank' => ($_init_rdata = Users::getRank($_init_udata['rank_main'])),
'colour' => ($_init_udata['name_colour'] == null ? $_init_rdata['colour'] : $_init_udata['name_colour'])
]
];
// Ban checking
if(Users::checkLogin() && $ban = Bans::checkBan(Session::$userId)) {
// Additional render data
$renderData = array_merge($renderData, [
'ban' => [
'reason' => $ban['reason'],
'issued' => $ban['issued'],
'expires' => $ban['expires'],
'issuer' => Users::getUser($ban['issuer'])
],
'page' => [
'title' => 'You are banned!'
]
]);
2015-07-30 17:07:23 +00:00
Users::logout();
2015-07-30 01:12:53 +00:00
print Templates::render('errors/banned.tpl', $renderData);
exit;
}
}