diff --git a/config/config.example.ini b/config/config.example.ini
index fac49ed..0532ba2 100644
--- a/config/config.example.ini
+++ b/config/config.example.ini
@@ -44,3 +44,9 @@ whoisservers = config/whois.json
; JSON file containing ISO 3166 country codes
iso3166 = config/iso3166.json
+
+
+; Development mode settings
+[dev]
+; Enable development mode
+enable = true
diff --git a/libraries/Comments.php b/libraries/Comments.php
index 835e5f9..668de49 100644
--- a/libraries/Comments.php
+++ b/libraries/Comments.php
@@ -117,12 +117,12 @@ class Comments
{
// Check if the comment is long enough
- if (strlen($content) < Config::getConfig('comment_min_length')) {
+ if (strlen($content) < Config::get('comment_min_length')) {
return [0, 'TOO_SHORT'];
}
// Check if the comment isn't too long
- if (strlen($content) > Config::getConfig('comment_max_length')) {
+ if (strlen($content) > Config::get('comment_max_length')) {
return [0, 'TOO_LONG'];
}
diff --git a/libraries/Config.php b/libraries/Config.php
index e935db1..c4c6ccc 100644
--- a/libraries/Config.php
+++ b/libraries/Config.php
@@ -64,7 +64,7 @@ class Config
}
// Get values from the configuration on the file system
- public static function getLocalConfig($key, $subkey = null)
+ public static function local($key, $subkey = null)
{
// Check if the key that we're looking for exists
@@ -83,38 +83,17 @@ class Config
'Unable to get local configuration value "' . $key . '"',
E_USER_ERROR
);
- }
-
- // Dynamically set local configuration values, does not update the configuration file
- public static function setLocalConfig($key, $subkey, $value)
- {
-
- // Check if we also do a subkey
- if ($subkey) {
- // If we do we make sure that the parent key is an array
- if (!isset(self::$local[$key])) {
- self::$local[$key] = [];
- }
-
- // And then assign the value
- self::$local[$key][$subkey] = $value;
- }
-
- // Otherwise we just straight up assign it
- self::$local[$key] = $value;
+ return null;
}
// Get values from the configuration in the database
- public static function getConfig($key, $returnNull = false)
+ public static function get($key, $returnNull = false)
{
// Check if the key that we're looking for exists
if (array_key_exists($key, self::$database)) {
// Then return the value
return self::$database[$key];
- } elseif ($returnNull) {
- // Avoid the error trigger if requested
- return null;
}
// Then return the value
@@ -122,5 +101,6 @@ class Config
'Unable to get configuration value "' . $key . '"',
E_USER_ERROR
);
+ return null;
}
}
diff --git a/libraries/DBWrapper/mysql.php b/libraries/DBWrapper/mysql.php
index 43c25b7..6563160 100644
--- a/libraries/DBWrapper/mysql.php
+++ b/libraries/DBWrapper/mysql.php
@@ -31,23 +31,23 @@ class mysql
// Initialise connection
$this->initConnect(
(
- Config::getLocalConfig('database', 'unixsocket') ?
+ Config::local('database', 'unixsocket') ?
$this->prepareSock(
- Config::getLocalConfig('database', 'host'),
- Config::getLocalConfig('database', 'database')
+ Config::local('database', 'host'),
+ Config::local('database', 'database')
) :
$this->prepareHost(
- Config::getLocalConfig('database', 'host'),
- Config::getLocalConfig('database', 'database'),
+ Config::local('database', 'host'),
+ Config::local('database', 'database'),
(
- Config::getLocalConfig('database', 'port') !== null ?
- Config::getLocalConfig('database', 'port') :
+ Config::local('database', 'port') !== null ?
+ Config::local('database', 'port') :
3306
)
)
),
- Config::getLocalConfig('database', 'username'),
- Config::getLocalConfig('database', 'password')
+ Config::local('database', 'username'),
+ Config::local('database', 'password')
);
}
@@ -88,7 +88,7 @@ class mysql
{
// Begin preparation of the statement
- $prepare = 'SELECT ' . ($distinct ? 'DISTINCT ' : '') . ($column == '*' ? '' : '`') . $column . ($column == '*' ? '' : '`') . ' FROM `' . ($prefix ? $prefix : Config::getLocalConfig('database', 'prefix')) . $table . '`';
+ $prepare = 'SELECT ' . ($distinct ? 'DISTINCT ' : '') . ($column == '*' ? '' : '`') . $column . ($column == '*' ? '' : '`') . ' FROM `' . ($prefix ? $prefix : Config::local('database', 'prefix')) . $table . '`';
// If $data is set and is an array continue
if (is_array($data)) {
@@ -200,7 +200,7 @@ class mysql
{
// Begin preparation of the statement
- $prepare = 'INSERT INTO `' . ($prefix ? $prefix : Config::getLocalConfig('database', 'prefix')) . $table . '` ';
+ $prepare = 'INSERT INTO `' . ($prefix ? $prefix : Config::local('database', 'prefix')) . $table . '` ';
// Run the foreach statement twice for (`stuff`) VALUES (:stuff)
for ($i = 0; $i < 2; $i++) {
@@ -241,7 +241,7 @@ class mysql
{
// Begin preparation of the statement
- $prepare = 'UPDATE `' . ($prefix ? $prefix : Config::getLocalConfig('database', 'prefix')) . $table . '`';
+ $prepare = 'UPDATE `' . ($prefix ? $prefix : Config::local('database', 'prefix')) . $table . '`';
// Run a foreach on $data and complete the statement
foreach ($data as $key => $values) {
@@ -294,7 +294,7 @@ class mysql
{
// Begin preparation of the statement
- $prepare = 'DELETE FROM `' . ($prefix ? $prefix : Config::getLocalConfig('database', 'prefix')) . $table . '`';
+ $prepare = 'DELETE FROM `' . ($prefix ? $prefix : Config::local('database', 'prefix')) . $table . '`';
// If $data is set and is an array continue
if (is_array($data)) {
@@ -333,7 +333,7 @@ class mysql
{
// Begin preparation of the statement
- $prepare = 'SELECT COUNT(*) FROM `' . ($prefix ? $prefix : Config::getLocalConfig('database', 'prefix')) . $table . '`';
+ $prepare = 'SELECT COUNT(*) FROM `' . ($prefix ? $prefix : Config::local('database', 'prefix')) . $table . '`';
// If $data is set and is an array continue
if (is_array($data)) {
diff --git a/libraries/Main.php b/libraries/Main.php
index ede297e..520d51d 100644
--- a/libraries/Main.php
+++ b/libraries/Main.php
@@ -21,7 +21,7 @@ class Main
Config::init($config);
// Database
- Database::init(Config::getLocalConfig('database', 'driver'));
+ Database::init(Config::local('database', 'driver'));
// "Dynamic" Configuration
Config::initDB();
@@ -70,7 +70,7 @@ class Main
// Attempt to get the response
$resp = @file_get_contents(
'https://www.google.com/recaptcha/api/siteverify?secret='
- . Config::getConfig('recaptcha_private')
+ . Config::get('recaptcha_private')
. '&response='
. $response
);
@@ -160,6 +160,9 @@ class Main
die('An error occurred while executing the script.|1|javascript:alert("' . (isset($errid) ? 'Error Log ID: '. $errid : 'Failed to log.') . '");');
}
+ // Check for dev mode
+ $detailed = Config::local('dev', 'enable');
+
// Build page
$errorPage = '
@@ -193,7 +196,7 @@ class Main
if (isset($errid)) {
$errorPage .= '
The error and surrounding data has been logged.
- ' . (SAKURA_STABLE ? 'Report the following text to a staff member' : 'Logged as') . '
+ ' . ($detailed ? 'Report the following text to a staff member' : 'Logged as') . '
' . $errid . '
';
} else {
$errorPage .= 'Sakura was not able to log this error which could mean that there was an error
@@ -202,7 +205,7 @@ class Main
know about this error if it occurs again.
';
}
- if (!SAKURA_STABLE) {
+ if (!$detailed) {
$errorPage .= ' Summary
' . $error . '
Backtraces
';
@@ -249,28 +252,28 @@ class Main
$mail->isSMTP();
// Set the SMTP server host
- $mail->Host = Config::getConfig('smtp_server');
+ $mail->Host = Config::get('smtp_server');
// Do we require authentication?
- $mail->SMTPAuth = Config::getConfig('smtp_auth');
+ $mail->SMTPAuth = Config::get('smtp_auth');
// Do we encrypt as well?
- $mail->SMTPSecure = Config::getConfig('smtp_secure');
+ $mail->SMTPSecure = Config::get('smtp_secure');
// Set the port to the SMTP server
- $mail->Port = Config::getConfig('smtp_port');
+ $mail->Port = Config::get('smtp_port');
// If authentication is required log in as well
- if (Config::getConfig('smtp_auth')) {
- $mail->Username = Config::getConfig('smtp_username');
- $mail->Password = base64_decode(Config::getConfig('smtp_password'));
+ if (Config::get('smtp_auth')) {
+ $mail->Username = Config::get('smtp_username');
+ $mail->Password = base64_decode(Config::get('smtp_password'));
}
// Add a reply-to header
- $mail->addReplyTo(Config::getConfig('smtp_replyto_mail'), Config::getConfig('smtp_replyto_name'));
+ $mail->addReplyTo(Config::get('smtp_replyto_mail'), Config::get('smtp_replyto_name'));
// Set a from address as well
- $mail->setFrom(Config::getConfig('smtp_from_email'), Config::getConfig('smtp_from_name'));
+ $mail->setFrom(Config::get('smtp_from_email'), Config::get('smtp_from_name'));
// Set the addressee
foreach ($to as $email => $name) {
@@ -287,8 +290,8 @@ class Main
$htmlMail = file_get_contents(ROOT . 'templates/htmlEmail.tpl');
// Replace template tags
- $htmlMail = str_replace('{{ sitename }}', Config::getConfig('sitename'), $htmlMail);
- $htmlMail = str_replace('{{ siteurl }}', '//' . Config::getConfig('url_main'), $htmlMail);
+ $htmlMail = str_replace('{{ sitename }}', Config::get('sitename'), $htmlMail);
+ $htmlMail = str_replace('{{ siteurl }}', '//' . Config::get('url_main'), $htmlMail);
$htmlMail = str_replace('{{ contents }}', self::mdParse($body), $htmlMail);
// Set HTML body
@@ -317,7 +320,7 @@ class Main
{
// Run common sanitisation function over string
- $string = htmlentities($string, ENT_NOQUOTES | ENT_HTML401, Config::getConfig('charset'));
+ $string = htmlentities($string, ENT_NOQUOTES | ENT_HTML401, Config::get('charset'));
$string = stripslashes($string);
$string = strip_tags($string);
@@ -454,7 +457,7 @@ class Main
// Get CloudFlare Subnet list
$cfhosts = file_get_contents(
- ROOT . Config::getLocalConfig('data', 'cfipv' . (self::ipVersion($ip)))
+ ROOT . Config::local('data', 'cfipv' . (self::ipVersion($ip)))
);
// Replace \r\n with \n
@@ -597,7 +600,7 @@ class Main
$iso3166 = json_decode(
utf8_encode(
file_get_contents(
- ROOT . Config::getLocalConfig('data', 'iso3166')
+ ROOT . Config::local('data', 'iso3166')
)
),
true
diff --git a/libraries/Payments.php b/libraries/Payments.php
index 6dffa41..6a4235b 100644
--- a/libraries/Payments.php
+++ b/libraries/Payments.php
@@ -32,8 +32,8 @@ class Payments
try {
self::$paypal = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
- Config::getConfig('paypal_client_id'),
- Config::getConfig('paypal_secret')
+ Config::get('paypal_client_id'),
+ Config::get('paypal_secret')
)
);
} catch (\Exception $e) {
diff --git a/libraries/Session.php b/libraries/Session.php
index a29ad9f..8a40f71 100644
--- a/libraries/Session.php
+++ b/libraries/Session.php
@@ -99,7 +99,7 @@ class Session
}
// IP Check
- $ipCheck = Config::getConfig('session_check');
+ $ipCheck = Config::get('session_check');
// Origin checking
if ($ipCheck) {
diff --git a/libraries/Template.php b/libraries/Template.php
index e502d8e..0c521c4 100644
--- a/libraries/Template.php
+++ b/libraries/Template.php
@@ -25,7 +25,7 @@ class Template
public function __construct()
{
// Set template to default
- $this->setTemplate(Config::getConfig('site_style'));
+ $this->setTemplate(Config::get('site_style'));
}
// Set a template name
@@ -59,7 +59,7 @@ class Template
$twigEnv = [];
// Enable caching
- if (Config::getConfig('enable_tpl_cache')) {
+ if (Config::get('enable_tpl_cache')) {
$twigEnv['cache'] = ROOT . 'cache/twig';
}
diff --git a/libraries/Urls.php b/libraries/Urls.php
index 07be2c1..c7efe90 100644
--- a/libraries/Urls.php
+++ b/libraries/Urls.php
@@ -264,7 +264,7 @@ class Urls
}
// Check if mod_rewrite is enabled
- $rewrite = ($rewrite === null ? Config::getConfig('url_rewrite') : $rewrite) ? 1 : 0;
+ $rewrite = ($rewrite === null ? Config::get('url_rewrite') : $rewrite) ? 1 : 0;
// Format urls
$formatted = vsprintf($this->urls[$lid][$rewrite], $args);
diff --git a/libraries/User.php b/libraries/User.php
index 5038b78..8ddc2b5 100644
--- a/libraries/User.php
+++ b/libraries/User.php
@@ -179,7 +179,7 @@ class User
}
// Otherwise use the standard method
- return $this->data['user_last_online'] > (time() - Config::getConfig('max_online_time'));
+ return $this->data['user_last_online'] > (time() - Config::get('max_online_time'));
}
// Compatibility
@@ -686,19 +686,19 @@ class User
$username_clean = Main::cleanString($username, true);
// Check if the username is too short
- if (strlen($username_clean) < Config::getConfig('username_min_length')) {
+ if (strlen($username_clean) < Config::get('username_min_length')) {
return [0, 'TOO_SHORT'];
}
// Check if the username is too long
- if (strlen($username_clean) > Config::getConfig('username_max_length')) {
+ if (strlen($username_clean) > Config::get('username_max_length')) {
return [0, 'TOO_LONG'];
}
// Check if this username hasn't been used in the last amount of days set in the config
$getOld = Database::fetch('username_history', false, [
'username_old_clean' => [$username_clean, '='],
- 'change_time' => [(Config::getConfig('old_username_reserve') * 24 * 60 * 60), '>'],
+ 'change_time' => [(Config::get('old_username_reserve') * 24 * 60 * 60), '>'],
], ['change_id', true]);
// Check if anything was returned
@@ -796,7 +796,7 @@ class User
}
// Check password entropy
- if (Main::pwdEntropy($new) < Config::getConfig('min_entropy')) {
+ if (Main::pwdEntropy($new) < Config::get('min_entropy')) {
return [0, 'PASS_TOO_SHIT'];
}
diff --git a/libraries/Users.php b/libraries/Users.php
index 292a81b..82ed318 100644
--- a/libraries/Users.php
+++ b/libraries/Users.php
@@ -15,11 +15,11 @@ class Users
public static function checkLogin($uid = null, $sid = null)
{
// Assign $uid and $sid
- $uid = $uid ? $uid : (isset($_COOKIE[Config::getConfig('cookie_prefix') . 'id'])
- ? $_COOKIE[Config::getConfig('cookie_prefix') . 'id']
+ $uid = $uid ? $uid : (isset($_COOKIE[Config::get('cookie_prefix') . 'id'])
+ ? $_COOKIE[Config::get('cookie_prefix') . 'id']
: 0);
- $sid = $sid ? $sid : (isset($_COOKIE[Config::getConfig('cookie_prefix') . 'session'])
- ? $_COOKIE[Config::getConfig('cookie_prefix') . 'session']
+ $sid = $sid ? $sid : (isset($_COOKIE[Config::get('cookie_prefix') . 'session'])
+ ? $_COOKIE[Config::get('cookie_prefix') . 'session']
: 0);
// Get session
@@ -32,20 +32,20 @@ class Users
if ($sessionValid == 0 || Permissions::check('SITE', 'DEACTIVATED', $uid, 1)) {
// Unset User ID
setcookie(
- Config::getConfig('cookie_prefix') . 'id',
+ Config::get('cookie_prefix') . 'id',
0,
time() - 60,
- Config::getConfig('cookie_path'),
- Config::getConfig('cookie_domain')
+ Config::get('cookie_path'),
+ Config::get('cookie_domain')
);
// Unset Session ID
setcookie(
- Config::getConfig('cookie_prefix') . 'session',
+ Config::get('cookie_prefix') . 'session',
'',
time() - 60,
- Config::getConfig('cookie_path'),
- Config::getConfig('cookie_domain')
+ Config::get('cookie_path'),
+ Config::get('cookie_domain')
);
return false;
@@ -55,20 +55,20 @@ class Users
if ($sessionValid == 2) {
// User ID cookie
setcookie(
- Config::getConfig('cookie_prefix') . 'id',
+ Config::get('cookie_prefix') . 'id',
$uid,
time() + 604800,
- Config::getConfig('cookie_path'),
- Config::getConfig('cookie_domain')
+ Config::get('cookie_path'),
+ Config::get('cookie_domain')
);
// Session ID cookie
setcookie(
- Config::getConfig('cookie_prefix') . 'session',
+ Config::get('cookie_prefix') . 'session',
$sid,
time() + 604800,
- Config::getConfig('cookie_path'),
- Config::getConfig('cookie_domain')
+ Config::get('cookie_path'),
+ Config::get('cookie_domain')
);
}
@@ -93,7 +93,7 @@ class Users
public static function login($username, $password, $remember = false, $cookies = true)
{
// Check if authentication is disallowed
- if (Config::getConfig('lock_authentication')) {
+ if (Config::get('lock_authentication')) {
return [0, 'AUTH_LOCKED'];
}
@@ -150,20 +150,20 @@ class Users
if ($cookies) {
// User ID cookie
setcookie(
- Config::getConfig('cookie_prefix') . 'id',
+ Config::get('cookie_prefix') . 'id',
$user->id(),
time() + 604800,
- Config::getConfig('cookie_path'),
- Config::getConfig('cookie_domain')
+ Config::get('cookie_path'),
+ Config::get('cookie_domain')
);
// Session ID cookie
setcookie(
- Config::getConfig('cookie_prefix') . 'session',
+ Config::get('cookie_prefix') . 'session',
$sessionKey,
time() + 604800,
- Config::getConfig('cookie_path'),
- Config::getConfig('cookie_domain')
+ Config::get('cookie_path'),
+ Config::get('cookie_domain')
);
}
@@ -184,20 +184,20 @@ class Users
// Unset User ID
setcookie(
- Config::getConfig('cookie_prefix') . 'id',
+ Config::get('cookie_prefix') . 'id',
0,
time() - 60,
- Config::getConfig('cookie_path'),
- Config::getConfig('cookie_domain')
+ Config::get('cookie_path'),
+ Config::get('cookie_domain')
);
// Unset Session ID
setcookie(
- Config::getConfig('cookie_prefix') . 'session',
+ Config::get('cookie_prefix') . 'session',
'',
time() - 60,
- Config::getConfig('cookie_path'),
- Config::getConfig('cookie_domain')
+ Config::get('cookie_path'),
+ Config::get('cookie_domain')
);
// Return true indicating a successful logout
@@ -208,17 +208,17 @@ class Users
public static function register($username, $password, $confirmpass, $email, $tos, $captcha = null, $regkey = null)
{
// Check if authentication is disallowed
- if (Config::getConfig('lock_authentication')) {
+ if (Config::get('lock_authentication')) {
return [0, 'AUTH_LOCKED'];
}
// Check if registration is even enabled
- if (Config::getConfig('disable_registration')) {
+ if (Config::get('disable_registration')) {
return [0, 'DISABLED'];
}
// Check if registration codes are required
- if (Config::getConfig('require_registration_code')) {
+ if (Config::get('require_registration_code')) {
// Check if the code is valid
if (!self::checkRegistrationCode($regkey)) {
return [0, 'INVALID_REG_KEY'];
@@ -231,7 +231,7 @@ class Users
}
// Verify the captcha if it's enabled
- if (Config::getConfig('recaptcha')) {
+ if (Config::get('recaptcha')) {
if (!Main::verifyCaptcha($captcha)['success']) {
return [0, 'CAPTCHA_FAIL'];
}
@@ -243,12 +243,12 @@ class Users
}
// Username too short
- if (strlen($username) < Config::getConfig('username_min_length')) {
+ if (strlen($username) < Config::get('username_min_length')) {
return [0, 'NAME_TOO_SHORT'];
}
// Username too long
- if (strlen($username) > Config::getConfig('username_max_length')) {
+ if (strlen($username) > Config::get('username_max_length')) {
return [0, 'NAME_TOO_LONG'];
}
@@ -263,7 +263,7 @@ class Users
}
// Check password entropy
- if (Main::pwdEntropy($password) < Config::getConfig('min_entropy')) {
+ if (Main::pwdEntropy($password) < Config::get('min_entropy')) {
return [0, 'PASS_TOO_SHIT'];
}
@@ -276,7 +276,7 @@ class Users
$usernameClean = Main::cleanString($username, true);
$emailClean = Main::cleanString($email, true);
$password = Hashing::createHash($password);
- $requireActive = Config::getConfig('require_activation');
+ $requireActive = Config::get('require_activation');
$userRank = $requireActive ? [1] : [2];
$userRankJson = json_encode($userRank);
@@ -309,7 +309,7 @@ class Users
}
// Check if registration codes are required
- if (Config::getConfig('require_registration_code')) {
+ if (Config::get('require_registration_code')) {
// If we do mark the registration code that was used as used
self::markRegistrationCodeUsed($regkey, $uid);
}
@@ -322,7 +322,7 @@ class Users
public static function sendPasswordForgot($username, $email)
{
// Check if authentication is disallowed
- if (Config::getConfig('lock_authentication')) {
+ if (Config::get('lock_authentication')) {
return [0, 'AUTH_LOCKED'];
}
@@ -358,17 +358,17 @@ class Users
// Build the e-mail
$message = "Hello " . $user['username'] . ",\r\n\r\n";
- $message .= "You are receiving this notification because you have (or someone pretending to be you has) requested a password reset link to be sent for your account on \"" . Config::getConfig('sitename') . "\". If you did not request this notification then please ignore it, if you keep receiving it please contact the site administrator.\r\n\r\n";
+ $message .= "You are receiving this notification because you have (or someone pretending to be you has) requested a password reset link to be sent for your account on \"" . Config::get('sitename') . "\". If you did not request this notification then please ignore it, if you keep receiving it please contact the site administrator.\r\n\r\n";
$message .= "To use this password reset key you need to go to a special page. To do this click the link provided below.\r\n\r\n";
- $message .= "http://" . Config::getConfig('url_main') . $urls->format('SITE_FORGOT_PASSWORD') . "?pw=true&uid=" . $user['user_id'] . "&key=" . $verk . "\r\n\r\n";
+ $message .= "http://" . Config::get('url_main') . $urls->format('SITE_FORGOT_PASSWORD') . "?pw=true&uid=" . $user['user_id'] . "&key=" . $verk . "\r\n\r\n";
$message .= "If successful you should be able to change your password here.\r\n\r\n";
- $message .= "Alternatively if the above method fails for some reason you can go to http://" . Config::getConfig('url_main') . $urls->format('SITE_FORGOT_PASSWORD') . "?pw=true&uid=" . $user['user_id'] . " and use the key listed below:\r\n\r\n";
+ $message .= "Alternatively if the above method fails for some reason you can go to http://" . Config::get('url_main') . $urls->format('SITE_FORGOT_PASSWORD') . "?pw=true&uid=" . $user['user_id'] . " and use the key listed below:\r\n\r\n";
$message .= "Verification key: " . $verk . "\r\n\r\n";
$message .= "You can of course change this password yourself via the profile page. If you have any difficulties please contact the site administrator.\r\n\r\n";
- $message .= "--\r\n\r\nThanks\r\n\r\n" . Config::getConfig('mail_signature');
+ $message .= "--\r\n\r\nThanks\r\n\r\n" . Config::get('mail_signature');
// Send the message
- Main::sendMail([$user['email'] => $user['username']], Config::getConfig('sitename') . ' password restoration', $message);
+ Main::sendMail([$user['email'] => $user['username']], Config::get('sitename') . ' password restoration', $message);
// Return success
return [1, 'SUCCESS'];
@@ -378,12 +378,12 @@ class Users
public static function resetPassword($verk, $uid, $newpass, $verpass)
{
// Check if authentication is disallowed
- if (Config::getConfig('lock_authentication')) {
+ if (Config::get('lock_authentication')) {
return [0, 'AUTH_LOCKED'];
}
// Check password entropy
- if (Main::pwdEntropy($newpass) < Config::getConfig('min_entropy')) {
+ if (Main::pwdEntropy($newpass) < Config::get('min_entropy')) {
return [0, 'PASS_TOO_SHIT'];
}
@@ -426,7 +426,7 @@ class Users
public static function resendActivationMail($username, $email)
{
// Check if authentication is disallowed
- if (Config::getConfig('lock_authentication')) {
+ if (Config::get('lock_authentication')) {
return [0, 'AUTH_LOCKED'];
}
@@ -481,25 +481,25 @@ class Users
$urls = new Urls();
// Build the e-mail
- $message = "Welcome to " . Config::getConfig('sitename') . "!\r\n\r\n";
+ $message = "Welcome to " . Config::get('sitename') . "!\r\n\r\n";
$message .= "Please keep this e-mail for your records. Your account intormation is as follows:\r\n\r\n";
$message .= "----------------------------\r\n\r\n";
$message .= "Username: " . $user['username'] . "\r\n\r\n";
- $message .= "Your profile: http://" . Config::getConfig('url_main') . $urls->format('USER_PROFILE', [$user['user_id']]) . "\r\n\r\n";
+ $message .= "Your profile: http://" . Config::get('url_main') . $urls->format('USER_PROFILE', [$user['user_id']]) . "\r\n\r\n";
$message .= "----------------------------\r\n\r\n";
$message .= "Please visit the following link in order to activate your account:\r\n\r\n";
- $message .= "http://" . Config::getConfig('url_main') . $urls->format('SITE_ACTIVATE') . "?mode=activate&u=" . $user['user_id'] . "&k=" . $activate . "\r\n\r\n";
+ $message .= "http://" . Config::get('url_main') . $urls->format('SITE_ACTIVATE') . "?mode=activate&u=" . $user['user_id'] . "&k=" . $activate . "\r\n\r\n";
$message .= "Your password has been securely stored in our database and cannot be retrieved. ";
$message .= "In the event that it is forgotten, you will be able to reset it using the email address associated with your account.\r\n\r\n";
$message .= "Thank you for registering.\r\n\r\n";
- $message .= "--\r\n\r\nThanks\r\n\r\n" . Config::getConfig('mail_signature');
+ $message .= "--\r\n\r\nThanks\r\n\r\n" . Config::get('mail_signature');
// Send the message
Main::sendMail(
[
$user['email'] => $user['username'],
],
- Config::getConfig('sitename') . ' Activation Mail',
+ Config::get('sitename') . ' Activation Mail',
$message
);
@@ -605,7 +605,7 @@ class Users
'regcodes',
true,
['uid' => [$userId, '=']]
- )[0] >= Config::getConfig('max_reg_keys')) {
+ )[0] >= Config::get('max_reg_keys')) {
return false;
}
@@ -693,7 +693,7 @@ class Users
public static function checkAllOnline()
{
// Assign time - 500 to a variable
- $time = time() - Config::getConfig('max_online_time');
+ $time = time() - Config::get('max_online_time');
$return = [];
@@ -746,7 +746,7 @@ class Users
public static function updatePremiumMeta($id)
{
// Get the ID for the premium user rank from the database
- $premiumRank = Config::getConfig('premium_rank_id');
+ $premiumRank = Config::get('premium_rank_id');
// Create user object
$user = new User($id);
diff --git a/public/.htaccess b/public/.htaccess
index d76b89f..eb3ec8e 100644
--- a/public/.htaccess
+++ b/public/.htaccess
@@ -38,7 +38,6 @@ RewriteRule ^members/?$ members.php [L,QSA]
RewriteRule ^members/([a-z]+)/?$ members.php?sort=$1 [L,QSA]
RewriteRule ^members/([0-9]+)/?$ members.php?rank=$1 [L,QSA]
RewriteRule ^members/([a-z]+)/([0-9]+)/?$ members.php?sort=$1&rank=$2 [L,QSA]
-RewriteRule ^members/([0-9]+)/p([0-9]+)/?$ members.php?rank=$1&page=$2 [L,QSA]
# Profiles
RewriteRule ^u/?$ profile.php [L,QSA]
diff --git a/public/authenticate.php b/public/authenticate.php
index 4e19493..2f10e95 100644
--- a/public/authenticate.php
+++ b/public/authenticate.php
@@ -220,12 +220,12 @@ if (isset($_REQUEST['mode'])) {
$_REQUEST['email'],
isset($_REQUEST['tos']),
(
- Config::getConfig('recaptcha') ?
+ Config::get('recaptcha') ?
$_REQUEST['g-recaptcha-response'] :
null
),
(
- Config::getConfig('require_registration_code') ?
+ Config::get('require_registration_code') ?
$_REQUEST['registercode'] :
null
)
@@ -247,7 +247,7 @@ if (isset($_REQUEST['mode'])) {
'INVALID_EMAIL' => 'Your e-mail address is formatted incorrectly.',
'INVALID_MX' => 'No valid MX-Record found on the e-mail address you supplied.',
'EMAILSENT' => 'Your registration went through! An activation e-mail has been sent.',
- 'SUCCESS' => 'Your registration went through! Welcome to ' . Config::getConfig('sitename') . '!',
+ 'SUCCESS' => 'Your registration went through! Welcome to ' . Config::get('sitename') . '!',
];
diff --git a/public/imageserve.php b/public/imageserve.php
index 476ec75..fa4a4ea 100644
--- a/public/imageserve.php
+++ b/public/imageserve.php
@@ -13,7 +13,7 @@ define('SAKURA_NO_TPL', true);
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Path to user uploads
-$userDirPath = ROOT . Config::getConfig('user_uploads') . '/';
+$userDirPath = ROOT . Config::get('user_uploads') . '/';
// Check if the m(ode) GET request is set
if (isset($_GET['m'])) {
@@ -23,17 +23,17 @@ if (isset($_GET['m'])) {
$noAvatar = ROOT . str_replace(
'{{ TPL }}',
$templateName,
- Config::getConfig('no_avatar_img')
+ Config::get('no_avatar_img')
);
$deactiveAvatar = ROOT . str_replace(
'{{ TPL }}',
$templateName,
- Config::getConfig('deactivated_avatar_img')
+ Config::get('deactivated_avatar_img')
);
$bannedAvatar = ROOT . str_replace(
'{{ TPL }}',
$templateName,
- Config::getConfig('banned_avatar_img')
+ Config::get('banned_avatar_img')
);
// If ?u= isn't set or if it isn't numeric
@@ -69,7 +69,7 @@ if (isset($_GET['m'])) {
case 'background':
// Set paths
- $noBackground = ROOT . Config::getConfig('no_background_img');
+ $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'])) {
@@ -105,7 +105,7 @@ if (isset($_GET['m'])) {
case 'header':
// Set paths
- $noHeader = ROOT . Config::getConfig('no_header_img');
+ $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'])) {
@@ -140,11 +140,11 @@ if (isset($_GET['m'])) {
break;
default:
- $serveImage = ROOT . Config::getConfig('pixel_img');
+ $serveImage = ROOT . Config::get('pixel_img');
}
} else {
- $serveImage = ROOT . Config::getConfig('pixel_img');
+ $serveImage = ROOT . Config::get('pixel_img');
}
// Add original filename
diff --git a/public/index.php b/public/index.php
index 79b94c4..83f5348 100644
--- a/public/index.php
+++ b/public/index.php
@@ -46,9 +46,9 @@ if (isset($_GET['p'])) {
// Are we in forum mode?
$forumMode = isset($_GET['forum']) ? ($_GET['forum'] == true) : false;
-$renderData['news'] = ($forumMode ? null : (new News(Config::getConfig('site_news_category'))));
+$renderData['news'] = ($forumMode ? null : (new News(Config::get('site_news_category'))));
-$renderData['newsCount'] = Config::getConfig('front_page_news_posts');
+$renderData['newsCount'] = Config::get('front_page_news_posts');
$renderData['forum'] = ($forumMode ? (new Forum\Forum()) : null);
diff --git a/public/members.php b/public/members.php
index 5f3bebd..792926e 100644
--- a/public/members.php
+++ b/public/members.php
@@ -39,7 +39,7 @@ if (Users::checkLogin()) {
$renderData['users'] = ($_MEMBERLIST_ACTIVE && !$_MEMBERLIST_NFOUND ? Users::getUsersInRank($_MEMBERLIST_ACTIVE) : Users::getAllUsers());
- $renderData['membersPerPage'] = Config::getConfig('members_per_page');
+ $renderData['membersPerPage'] = Config::get('members_per_page');
// Set parse variables
$template->setVariables($renderData);
diff --git a/public/news.php b/public/news.php
index 457441e..7c38c3b 100644
--- a/public/news.php
+++ b/public/news.php
@@ -13,7 +13,7 @@ use DOMDocument;
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) . 'sakura.php';
// Create a new News object
-$news = new News(isset($_GET['cat']) ? $_GET['cat'] : Config::getConfig('site_news_category'));
+$news = new News(isset($_GET['cat']) ? $_GET['cat'] : Config::get('site_news_category'));
// News XML feed
if (isset($_GET['xml'])) {
@@ -22,11 +22,11 @@ if (isset($_GET['xml'])) {
// Meta data attributes
$metaData = [
- 'title' => ($_FEED_TITLE = Config::getConfig('sitename')) . ' News',
- 'link' => ($_FEED_URL = 'http://' . Config::getConfig('url_main')),
+ 'title' => ($_FEED_TITLE = Config::get('sitename')) . ' News',
+ 'link' => ($_FEED_URL = 'http://' . Config::get('url_main')),
'description' => 'News about ' . $_FEED_TITLE,
'language' => 'en-gb',
- 'webMaster' => Config::getConfig('admin_email') . ' (' . $_FEED_TITLE . ' Webmaster)',
+ 'webMaster' => Config::get('admin_email') . ' (' . $_FEED_TITLE . ' Webmaster)',
'pubDate' => ($_FEED_DATE = date('r', $posts[array_keys($posts)[0]]['news_timestamp'])),
'lastBuildDate' => $_FEED_DATE,
];
@@ -120,7 +120,7 @@ if (isset($_GET['xml'])) {
$renderData = array_merge($renderData, [
'news' => $news,
- 'postsPerPage' => Config::getConfig('news_posts_per_page'),
+ 'postsPerPage' => Config::get('news_posts_per_page'),
'viewPost' => isset($_GET['id']),
'postExists' => $news->postExists(isset($_GET['id']) ? $_GET['id'] : 0),
]);
diff --git a/public/settings.php b/public/settings.php
index ff656d1..bb8d632 100644
--- a/public/settings.php
+++ b/public/settings.php
@@ -388,8 +388,8 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
sprintf($notifStrings[$action[1]][0], $user->username()),
$notifStrings[$action[1]][1],
60000,
- '//' . Config::getConfig('url_main') . '/a/' . $user->id(),
- '//' . Config::getConfig('url_main') . '/u/' . $user->id(),
+ '//' . Config::get('url_main') . '/a/' . $user->id(),
+ '//' . Config::get('url_main') . '/u/' . $user->id(),
'1'
);
}
@@ -487,7 +487,7 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
}
// Set path variables
- $filepath = ROOT . Config::getConfig('user_uploads') . '/';
+ $filepath = ROOT . Config::get('user_uploads') . '/';
$filename = $filepath . $mode . '_' . $currentUser->id();
$currfile = isset($currentUser->userData()[$userDataKey])
&& !empty($currentUser->userData()[$userDataKey]) ? $currentUser->userData()[$userDataKey] : null;
@@ -576,8 +576,8 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
}
// Check if the image is too large
- if (($metadata[0] > Config::getConfig($mode . '_max_width')
- || $metadata[1] > Config::getConfig($mode . '_max_height'))) {
+ if (($metadata[0] > Config::get($mode . '_max_width')
+ || $metadata[1] > Config::get($mode . '_max_height'))) {
// Set render data
$renderData['page'] = [
@@ -591,8 +591,8 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
}
// Check if the image is too small
- if (($metadata[0] < Config::getConfig($mode . '_min_width')
- || $metadata[1] < Config::getConfig($mode . '_min_height'))) {
+ if (($metadata[0] < Config::get($mode . '_min_width')
+ || $metadata[1] < Config::get($mode . '_min_height'))) {
// Set render data
$renderData['page'] = [
@@ -606,7 +606,7 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
}
// Check if the file is too large
- if ((filesize($_FILES[$mode]['tmp_name']) > Config::getConfig($mode . '_max_fsize'))) {
+ if ((filesize($_FILES[$mode]['tmp_name']) > Config::get($mode . '_max_fsize'))) {
// Set render data
$renderData['page'] = [
@@ -1505,12 +1505,12 @@ if (Users::checkLogin()) {
case 'appearance.avatar':
case 'appearance.background':
$renderData[$mode] = [
- 'max_width' => Config::getConfig($mode . '_max_width'),
- 'max_height' => Config::getConfig($mode . '_max_height'),
- 'min_width' => Config::getConfig($mode . '_min_width'),
- 'min_height' => Config::getConfig($mode . '_min_height'),
- 'max_size' => Config::getConfig($mode . '_max_fsize'),
- 'max_size_view' => Main::getByteSymbol(Config::getConfig($mode . '_max_fsize')),
+ 'max_width' => Config::get($mode . '_max_width'),
+ 'max_height' => Config::get($mode . '_max_height'),
+ 'min_width' => Config::get($mode . '_min_width'),
+ 'min_height' => Config::get($mode . '_min_height'),
+ 'max_size' => Config::get($mode . '_max_fsize'),
+ 'max_size_view' => Main::getByteSymbol(Config::get($mode . '_max_fsize')),
];
break;
diff --git a/public/support.php b/public/support.php
index c9cd9c6..6a3693e 100644
--- a/public/support.php
+++ b/public/support.php
@@ -44,15 +44,15 @@ if (isset($_REQUEST['mode'])
if (!isset($_POST['months'])
|| !is_numeric($_POST['months'])
|| (int) $_POST['months'] < 1
- || (int) $_POST['months'] > Config::getConfig('premium_amount_max')) {
+ || (int) $_POST['months'] > Config::get('premium_amount_max')) {
header('Location: ' . $urls->format('SITE_PREMIUM') . '?fail=true');
} else {
// Calculate the total
- $total = (float) Config::getConfig('premium_price_per_month') * (int) $_POST['months'];
+ $total = (float) Config::get('premium_price_per_month') * (int) $_POST['months'];
$total = number_format($total, 2, '.', '');
// Generate item name
- $itemName = Config::getConfig('sitename')
+ $itemName = Config::get('sitename')
. ' Premium - '
. (string) $_POST['months']
. ' month'
@@ -62,8 +62,8 @@ if (isset($_REQUEST['mode'])
if ($transaction = Payments::createTransaction(
$total,
$itemName,
- Config::getConfig('sitename') . ' Premium Purchase',
- 'http://' . Config::getConfig('url_main') . $urls->format('SITE_PREMIUM')
+ Config::get('sitename') . ' Premium Purchase',
+ 'http://' . Config::get('url_main') . $urls->format('SITE_PREMIUM')
)) {
// Store the amount of months in the global session array
$_SESSION['premiumMonths'] = (int) $_POST['months'];
@@ -98,7 +98,7 @@ if (isset($_REQUEST['mode'])
Users::updatePremiumMeta($currentUser->id());
Main::updatePremiumTracker(
$currentUser->id(),
- ((float) Config::getConfig('premium_price_per_month') * $_SESSION['premiumMonths']),
+ ((float) Config::get('premium_price_per_month') * $_SESSION['premiumMonths']),
$currentUser->username()
. ' bought premium for '
. $_SESSION['premiumMonths']
@@ -156,9 +156,9 @@ if (isset($_GET['tracker'])) {
$renderData['page'] = [
'fail' => isset($_GET['fail']),
- 'price' => Config::getConfig('premium_price_per_month'),
+ 'price' => Config::get('premium_price_per_month'),
'current' => $currentUser->isPremium(),
- 'amount_max' => Config::getConfig('premium_amount_max'),
+ 'amount_max' => Config::get('premium_amount_max'),
];
diff --git a/sakura.php b/sakura.php
index ae255f6..da6c4a0 100644
--- a/sakura.php
+++ b/sakura.php
@@ -8,16 +8,15 @@
namespace Sakura;
// Define Sakura version
-define('SAKURA_VERSION', '20151203');
+define('SAKURA_VERSION', '20151204');
define('SAKURA_VLABEL', 'Eminence');
define('SAKURA_COLOUR', '#6C3082');
-define('SAKURA_STABLE', false);
// Define Sakura Path
define('ROOT', __DIR__ . '/');
-// Error Reporting: 0 for production and -1 for testing
-error_reporting(SAKURA_STABLE ? 0 : -1);
+// Turn error reporting on for the initial startup sequence
+error_reporting(-1);
// Set internal encoding method
mb_internal_encoding('utf-8');
@@ -69,13 +68,16 @@ set_error_handler(['Sakura\Main', 'errorHandler']);
// Initialise Main Class
Main::init(ROOT . 'config/config.ini');
+// Change error reporting according to the dev configuration
+error_reporting(Config::local('dev', 'enable') ? -1 : 0);
+
// Assign servers file to whois class
-Whois::setServers(ROOT . Config::getLocalConfig('data', 'whoisservers'));
+Whois::setServers(ROOT . Config::local('data', 'whoisservers'));
// Check if we the system has a cron service
-if (Config::getConfig('no_cron_service')) {
+if (Config::get('no_cron_service')) {
// If not do an "asynchronous" call to the cron.php script
- if (Config::getConfig('no_cron_last') < (time() - Config::getConfig('no_cron_interval'))) {
+ if (Config::get('no_cron_last') < (time() - Config::get('no_cron_interval'))) {
// Check OS
if (substr(strtolower(PHP_OS), 0, 3) == 'win') {
pclose(popen('start /B ' . PHP_BINDIR . '\php.exe ' . addslashes(ROOT . 'cron.php'), 'r'));
@@ -96,7 +98,7 @@ if (Config::getConfig('no_cron_service')) {
}
// Start output buffering
-ob_start(Config::getConfig('use_gzip') ? 'ob_gzhandler' : null);
+ob_start(Config::get('use_gzip') ? 'ob_gzhandler' : null);
// Auth check
$authCheck = Users::checkLogin();
@@ -110,11 +112,11 @@ $urls = new Urls();
// Prepare the name of the template to load (outside of SAKURA_NO_TPL because it's used in imageserve.php)
$templateName =
defined('SAKURA_MANAGE') ?
-Config::getConfig('manage_style') :
+Config::get('manage_style') :
(
isset($currentUser->optionFields()['useMisaki']) && $currentUser->optionFields()['useMisaki'] ?
'misaki' :
- Config::getConfig('site_style')
+ Config::get('site_style')
);
if (!defined('SAKURA_NO_TPL')) {
@@ -125,41 +127,44 @@ if (!defined('SAKURA_NO_TPL')) {
'version' => SAKURA_VERSION,
'label' => SAKURA_VLABEL,
'colour' => SAKURA_COLOUR,
- 'stable' => SAKURA_STABLE,
+ ],
+
+ 'dev' => [
+ 'enable' => Config::local('dev', 'enable'),
],
'cookie' => [
- 'prefix' => Config::getConfig('cookie_prefix'),
- 'domain' => Config::getConfig('cookie_domain'),
- 'path' => Config::getConfig('cookie_path'),
+ 'prefix' => Config::get('cookie_prefix'),
+ 'domain' => Config::get('cookie_domain'),
+ 'path' => Config::get('cookie_path'),
],
- 'urlMain' => Config::getConfig('url_main'),
- 'urlApi' => Config::getConfig('url_api'),
+ 'urlMain' => Config::get('url_main'),
+ 'urlApi' => Config::get('url_api'),
- 'contentPath' => Config::getConfig('content_path'),
- 'resources' => Config::getConfig('content_path') . '/data/' . $templateName,
+ 'contentPath' => Config::get('content_path'),
+ 'resources' => Config::get('content_path') . '/data/' . $templateName,
- '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'),
+ 'charset' => Config::get('charset'),
+ 'siteName' => Config::get('sitename'),
+ 'siteLogo' => Config::get('sitelogo'),
+ 'siteDesc' => Config::get('sitedesc'),
+ 'siteTags' => implode(", ", json_decode(Config::get('sitetags'), true)),
+ 'dateFormat' => Config::get('date_format'),
'currentPage' => '//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
'referrer' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null),
- 'onlineTimeout' => Config::getConfig('max_online_time'),
+ 'onlineTimeout' => Config::get('max_online_time'),
- 'recaptchaPublic' => Config::getConfig('recaptcha_public'),
- 'recaptchaEnabled' => Config::getConfig('recaptcha'),
+ 'recaptchaPublic' => Config::get('recaptcha_public'),
+ 'recaptchaEnabled' => Config::get('recaptcha'),
- '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'),
+ 'disableRegistration' => Config::get('disable_registration'),
+ 'lockAuth' => Config::get('lock_authentication'),
+ 'requireRegCodes' => Config::get('require_registration_code'),
+ 'requireActivation' => Config::get('require_activation'),
+ 'minPwdEntropy' => Config::get('min_entropy'),
+ 'minUsernameLength' => Config::get('username_min_length'),
+ 'maxUsernameLength' => Config::get('username_max_length'),
],
'php' => [
'sessionid' => \session_id(),
@@ -181,11 +186,11 @@ if (!defined('SAKURA_NO_TPL')) {
];
// Site closing
- if (Config::getConfig('site_closed')) {
+ if (Config::get('site_closed')) {
// Additional render data
$renderData = array_merge($renderData, [
'page' => [
- 'message' => Config::getConfig('site_closed_reason'),
+ 'message' => Config::get('site_closed_reason'),
],
]);
diff --git a/templates/yuuno/global/master.tpl b/templates/yuuno/global/master.tpl
index 0dc9e02..ad7e82a 100644
--- a/templates/yuuno/global/master.tpl
+++ b/templates/yuuno/global/master.tpl
@@ -239,7 +239,7 @@
- {% if not sakura.versionInfo.stable and php.self == '/index.php' and stats %}
+ {% if sakura.dev.enable and php.self == '/index.php' and stats %}