2015-04-01 15:35:27 +00:00
|
|
|
<?php
|
|
|
|
/*
|
2015-05-24 22:06:53 +00:00
|
|
|
* Sakura Community Management System
|
2015-10-10 21:17:50 +00:00
|
|
|
* (c) 2013-2015 Flashwave <http://flash.moe>
|
2015-04-01 15:35:27 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
// Declare namespace
|
|
|
|
namespace Sakura;
|
|
|
|
|
|
|
|
// Define Sakura version
|
2015-11-10 23:34:48 +00:00
|
|
|
define('SAKURA_VERSION', '20151110');
|
2015-09-14 20:51:23 +00:00
|
|
|
define('SAKURA_VLABEL', 'Eminence');
|
|
|
|
define('SAKURA_COLOUR', '#6C3082');
|
|
|
|
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-08-23 22:08:36 +00:00
|
|
|
// Stop the execution if the PHP Version is older than 5.4.0
|
2015-09-14 20:51:23 +00:00
|
|
|
if (version_compare(phpversion(), '5.4.0', '<')) {
|
2015-08-29 13:25:57 +00:00
|
|
|
die('<h3>Sakura requires at least PHP 5.4.0, please upgrade to a newer PHP version.</h3>');
|
2015-08-23 22:08:36 +00:00
|
|
|
}
|
|
|
|
|
2015-04-01 15:35:27 +00:00
|
|
|
// Include libraries
|
2015-09-14 20:51:23 +00:00
|
|
|
require_once ROOT . '_sakura/vendor/autoload.php';
|
|
|
|
require_once ROOT . '_sakura/components/Main.php';
|
|
|
|
require_once ROOT . '_sakura/components/Hashing.php';
|
2015-11-06 22:30:37 +00:00
|
|
|
require_once ROOT . '_sakura/components/Config.php';
|
2015-09-14 20:51:23 +00:00
|
|
|
require_once ROOT . '_sakura/components/Database.php';
|
|
|
|
require_once ROOT . '_sakura/components/Urls.php';
|
2015-10-31 18:14:54 +00:00
|
|
|
require_once ROOT . '_sakura/components/Template.php';
|
2015-09-14 20:51:23 +00:00
|
|
|
require_once ROOT . '_sakura/components/Permissions.php';
|
2015-10-18 01:50:50 +00:00
|
|
|
require_once ROOT . '_sakura/components/Session.php';
|
2015-09-14 20:51:23 +00:00
|
|
|
require_once ROOT . '_sakura/components/User.php';
|
2015-10-10 21:17:50 +00:00
|
|
|
require_once ROOT . '_sakura/components/Rank.php';
|
2015-11-06 22:30:37 +00:00
|
|
|
require_once ROOT . '_sakura/components/Users.php'; //<
|
|
|
|
require_once ROOT . '_sakura/components/Forums.php'; //<
|
2015-09-14 20:51:23 +00:00
|
|
|
require_once ROOT . '_sakura/components/News.php';
|
|
|
|
require_once ROOT . '_sakura/components/Comments.php';
|
|
|
|
require_once ROOT . '_sakura/components/Manage.php';
|
|
|
|
require_once ROOT . '_sakura/components/Bans.php';
|
|
|
|
require_once ROOT . '_sakura/components/Whois.php';
|
|
|
|
require_once ROOT . '_sakura/components/Payments.php';
|
2015-10-24 08:55:45 +00:00
|
|
|
require_once ROOT . '_sakura/components/Trick.php';
|
2015-04-01 15:35:27 +00:00
|
|
|
|
2015-05-29 19:27:45 +00:00
|
|
|
// Include database extensions
|
2015-09-14 20:51:23 +00:00
|
|
|
foreach (glob(ROOT . '_sakura/components/database/*.php') as $driver) {
|
2015-07-30 01:12:53 +00:00
|
|
|
require_once $driver;
|
|
|
|
}
|
2015-04-01 15:35:27 +00:00
|
|
|
|
|
|
|
// Set Error handler
|
2015-10-18 19:06:30 +00:00
|
|
|
set_error_handler(['Sakura\Main', 'errorHandler']);
|
2015-04-01 15:35:27 +00:00
|
|
|
|
2015-07-30 01:12:53 +00:00
|
|
|
// Initialise Main Class
|
2015-09-14 20:51:23 +00:00
|
|
|
Main::init(ROOT . '_sakura/config/config.ini');
|
2015-05-29 19:27:45 +00:00
|
|
|
|
2015-08-23 22:08:36 +00:00
|
|
|
// Assign servers file to whois class
|
2015-11-06 22:30:37 +00:00
|
|
|
Whois::setServers(ROOT . '_sakura/' . Config::getLocalConfig('data', 'whoisservers'));
|
2015-08-23 22:08:36 +00:00
|
|
|
|
2015-09-12 19:57:44 +00:00
|
|
|
// Check if we the system has a cron service
|
2015-11-06 22:30:37 +00:00
|
|
|
if (Config::getConfig('no_cron_service')) {
|
2015-09-12 19:57:44 +00:00
|
|
|
// If not do an "asynchronous" call to the cron.php script
|
2015-11-06 22:30:37 +00:00
|
|
|
if (Config::getConfig('no_cron_last') < (time() - Config::getConfig('no_cron_interval'))) {
|
2015-09-12 19:57:44 +00:00
|
|
|
// Check OS
|
2015-09-14 20:51:23 +00:00
|
|
|
if (substr(strtolower(PHP_OS), 0, 3) == 'win') {
|
|
|
|
pclose(popen('start /B ' . PHP_BINDIR . '\php.exe ' . addslashes(ROOT . '_sakura\cron.php'), 'r'));
|
2015-09-12 19:57:44 +00:00
|
|
|
} else {
|
2015-09-14 20:51:23 +00:00
|
|
|
pclose(popen(PHP_BINDIR . '/php ' . ROOT . '_sakura/cron.php > /dev/null 2>/dev/null &', 'r'));
|
2015-09-12 19:57:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Update last execution time
|
|
|
|
Database::update('config', [
|
|
|
|
[
|
2015-09-14 20:51:23 +00:00
|
|
|
'config_value' => time(),
|
2015-09-12 19:57:44 +00:00
|
|
|
],
|
|
|
|
[
|
2015-09-14 20:51:23 +00:00
|
|
|
'config_name' => ['no_cron_last', '='],
|
|
|
|
],
|
2015-09-12 19:57:44 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-29 19:27:45 +00:00
|
|
|
// Start output buffering
|
2015-11-06 22:30:37 +00:00
|
|
|
ob_start(Config::getConfig('use_gzip') ? 'ob_gzhandler' : null);
|
2015-04-01 15:35:27 +00:00
|
|
|
|
2015-10-18 01:50:50 +00:00
|
|
|
// Auth check
|
|
|
|
$authCheck = Users::checkLogin();
|
|
|
|
|
2015-08-21 22:07:45 +00:00
|
|
|
// Create a user object for the current logged in user
|
2015-10-18 01:50:50 +00:00
|
|
|
$currentUser = new User($authCheck[0]);
|
2015-08-21 22:07:45 +00:00
|
|
|
|
2015-09-04 23:49:53 +00:00
|
|
|
// Create the Urls object
|
|
|
|
$urls = new Urls();
|
|
|
|
|
2015-08-29 13:25:57 +00:00
|
|
|
// Prepare the name of the template to load (outside of SAKURA_NO_TPL because it's used in imageserve.php)
|
2015-09-14 20:51:23 +00:00
|
|
|
$templateName =
|
|
|
|
defined('SAKURA_MANAGE') ?
|
2015-11-06 22:30:37 +00:00
|
|
|
Config::getConfig('manage_style') :
|
2015-10-11 23:37:54 +00:00
|
|
|
(
|
2015-11-10 14:23:20 +00:00
|
|
|
isset($currentUser->optionFields()['useMisaki']) && $currentUser->optionFields()['useMisaki'] ?
|
2015-10-12 17:28:34 +00:00
|
|
|
'misaki' :
|
2015-11-06 22:30:37 +00:00
|
|
|
Config::getConfig('site_style')
|
2015-10-12 17:28:34 +00:00
|
|
|
);
|
2015-07-30 01:12:53 +00:00
|
|
|
|
2015-09-14 20:51:23 +00:00
|
|
|
if (!defined('SAKURA_NO_TPL')) {
|
2015-07-30 01:12:53 +00:00
|
|
|
// Set base page rendering data
|
|
|
|
$renderData = [
|
|
|
|
'sakura' => [
|
2015-08-20 23:17:27 +00:00
|
|
|
'versionInfo' => [
|
2015-09-14 20:51:23 +00:00
|
|
|
'version' => SAKURA_VERSION,
|
|
|
|
'label' => SAKURA_VLABEL,
|
|
|
|
'colour' => SAKURA_COLOUR,
|
|
|
|
'stable' => SAKURA_STABLE,
|
2015-08-20 23:17:27 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
'cookie' => [
|
2015-11-06 22:30:37 +00:00
|
|
|
'prefix' => Config::getConfig('cookie_prefix'),
|
|
|
|
'domain' => Config::getConfig('cookie_domain'),
|
|
|
|
'path' => Config::getConfig('cookie_path'),
|
2015-08-20 23:17:27 +00:00
|
|
|
],
|
|
|
|
|
2015-11-06 22:30:37 +00:00
|
|
|
'urlMain' => Config::getConfig('url_main'),
|
|
|
|
'urlApi' => Config::getConfig('url_api'),
|
2015-08-20 23:17:27 +00:00
|
|
|
|
2015-11-06 22:30:37 +00:00
|
|
|
'contentPath' => Config::getConfig('content_path'),
|
|
|
|
'resources' => Config::getConfig('content_path') . '/data/' . $templateName,
|
2015-08-20 23:17:27 +00:00
|
|
|
|
2015-11-06 22:30:37 +00:00
|
|
|
'charset' => Config::getConfig('charset'),
|
|
|
|
'siteName' => Config::getConfig('sitename'),
|
|
|
|
'siteLogo' => Config::getConfig('sitelogo'),
|
|
|
|
'siteDesc' => Config::getConfig('sitedesc'),
|
|
|
|
'siteTags' => implode(", ", json_decode(Config::getConfig('sitetags'), true)),
|
|
|
|
'dateFormat' => Config::getConfig('date_format'),
|
2015-10-16 15:37:10 +00:00
|
|
|
'currentPage' => '//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
|
2015-10-22 14:24:18 +00:00
|
|
|
'referrer' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null),
|
2015-08-20 23:17:27 +00:00
|
|
|
|
2015-11-06 22:30:37 +00:00
|
|
|
'recaptchaPublic' => Config::getConfig('recaptcha_public'),
|
|
|
|
'recaptchaEnabled' => Config::getConfig('recaptcha'),
|
2015-07-30 01:12:53 +00:00
|
|
|
|
2015-11-06 22:30:37 +00:00
|
|
|
'disableRegistration' => Config::getConfig('disable_registration'),
|
|
|
|
'lockAuth' => Config::getConfig('lock_authentication'),
|
|
|
|
'requireRegCodes' => Config::getConfig('require_registration_code'),
|
|
|
|
'requireActivation' => Config::getConfig('require_activation'),
|
|
|
|
'minPwdEntropy' => Config::getConfig('min_entropy'),
|
|
|
|
'minUsernameLength' => Config::getConfig('username_min_length'),
|
|
|
|
'maxUsernameLength' => Config::getConfig('username_max_length'),
|
2015-07-30 01:12:53 +00:00
|
|
|
],
|
|
|
|
'php' => [
|
|
|
|
'sessionid' => \session_id(),
|
2015-09-14 20:51:23 +00:00
|
|
|
'time' => \time(),
|
|
|
|
'self' => $_SERVER['PHP_SELF'],
|
2015-07-30 01:12:53 +00:00
|
|
|
],
|
|
|
|
|
2015-08-19 19:44:01 +00:00
|
|
|
'session' => [
|
2015-10-18 01:50:50 +00:00
|
|
|
'checkLogin' => $authCheck,
|
|
|
|
'sessionId' => $authCheck[1],
|
|
|
|
'userId' => $authCheck[0],
|
2015-08-19 19:44:01 +00:00
|
|
|
],
|
|
|
|
|
2015-09-04 23:49:53 +00:00
|
|
|
'user' => $currentUser,
|
2015-09-14 20:51:23 +00:00
|
|
|
'urls' => $urls,
|
2015-07-30 01:12:53 +00:00
|
|
|
];
|
|
|
|
|
2015-09-16 20:34:36 +00:00
|
|
|
// Site closing
|
2015-11-06 22:30:37 +00:00
|
|
|
if (Config::getConfig('site_closed')) {
|
2015-09-16 20:34:36 +00:00
|
|
|
// Additional render data
|
|
|
|
$renderData = array_merge($renderData, [
|
|
|
|
|
|
|
|
'page' => [
|
2015-11-06 22:30:37 +00:00
|
|
|
'message' => Config::getConfig('site_closed_reason'),
|
2015-09-16 20:34:36 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
2015-11-06 22:30:37 +00:00
|
|
|
// Initialise templating engine
|
|
|
|
$template = new Template();
|
|
|
|
|
|
|
|
// Change templating engine
|
|
|
|
$template->setTemplate($templateName);
|
|
|
|
|
|
|
|
// Set parse variables
|
|
|
|
$template->setVariables($renderData);
|
|
|
|
|
|
|
|
// Print page contents
|
|
|
|
echo $template->render('global/information.tpl');
|
2015-09-16 20:34:36 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2015-07-30 01:12:53 +00:00
|
|
|
// Ban checking
|
2015-11-07 22:58:02 +00:00
|
|
|
if ($authCheck && $ban = Bans::checkBan($currentUser->id())) {
|
2015-07-30 01:12:53 +00:00
|
|
|
// Additional render data
|
|
|
|
$renderData = array_merge($renderData, [
|
2015-09-07 20:53:47 +00:00
|
|
|
|
2015-07-30 01:12:53 +00:00
|
|
|
'ban' => [
|
2015-09-14 20:51:23 +00:00
|
|
|
'reason' => $ban['reason'],
|
|
|
|
'issued' => $ban['issued'],
|
|
|
|
'expires' => $ban['expires'],
|
2015-11-10 14:23:20 +00:00
|
|
|
'issuer' => (new User($ban['issuer'])),
|
2015-09-14 20:51:23 +00:00
|
|
|
],
|
2015-09-07 20:53:47 +00:00
|
|
|
|
2015-07-30 01:12:53 +00:00
|
|
|
]);
|
|
|
|
|
2015-07-30 17:07:23 +00:00
|
|
|
Users::logout();
|
2015-11-06 22:30:37 +00:00
|
|
|
|
|
|
|
// Initialise templating engine
|
|
|
|
$template = new Template();
|
|
|
|
|
|
|
|
// Change templating engine
|
|
|
|
$template->setTemplate($templateName);
|
|
|
|
|
|
|
|
// Set parse variables
|
|
|
|
$template->setVariables($renderData);
|
|
|
|
|
|
|
|
// Print page contents
|
|
|
|
echo $template->render('main/banned.tpl');
|
2015-07-30 01:12:53 +00:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|