mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-27 01:39:22 +02:00
* some optimizations & fixes according to awesome PHPStorm Php Inspections plugin!
This commit is contained in:
parent
c48452b37d
commit
eab416c0b4
11
common.php
11
common.php
@ -30,7 +30,7 @@ define('MYAAC_VERSION', '0.8.0-dev');
|
|||||||
define('DATABASE_VERSION', 23);
|
define('DATABASE_VERSION', 23);
|
||||||
define('TABLE_PREFIX', 'myaac_');
|
define('TABLE_PREFIX', 'myaac_');
|
||||||
define('START_TIME', microtime(true));
|
define('START_TIME', microtime(true));
|
||||||
define('MYAAC_OS', (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? 'WINDOWS' : (strtoupper(PHP_OS) == 'DARWIN' ? 'MAC' : 'LINUX'));
|
define('MYAAC_OS', stripos(PHP_OS, 'WIN') === 0 ? 'WINDOWS' : (strtoupper(PHP_OS) === 'DARWIN' ? 'MAC' : 'LINUX'));
|
||||||
|
|
||||||
// account flags
|
// account flags
|
||||||
define('FLAG_ADMIN', 1);
|
define('FLAG_ADMIN', 1);
|
||||||
@ -54,7 +54,7 @@ define('TICKER', 2);
|
|||||||
define('ARTICLE', 3);
|
define('ARTICLE', 3);
|
||||||
|
|
||||||
// directories
|
// directories
|
||||||
define('BASE', dirname(__FILE__) . '/');
|
define('BASE', __DIR__ . '/');
|
||||||
define('ADMIN', BASE . 'admin/');
|
define('ADMIN', BASE . 'admin/');
|
||||||
define('SYSTEM', BASE . 'system/');
|
define('SYSTEM', BASE . 'system/');
|
||||||
define('CACHE', SYSTEM . 'cache/');
|
define('CACHE', SYSTEM . 'cache/');
|
||||||
@ -87,16 +87,15 @@ define('TFS_LAST', TFS_03);
|
|||||||
// basedir
|
// basedir
|
||||||
$basedir = '';
|
$basedir = '';
|
||||||
$tmp = explode('/', $_SERVER['SCRIPT_NAME']);
|
$tmp = explode('/', $_SERVER['SCRIPT_NAME']);
|
||||||
$size = sizeof($tmp) - 1;
|
$size = count($tmp) - 1;
|
||||||
for($i = 1; $i < $size; $i++)
|
for($i = 1; $i < $size; $i++)
|
||||||
$basedir .= '/' . $tmp[$i];
|
$basedir .= '/' . $tmp[$i];
|
||||||
|
|
||||||
$basedir = str_replace('/admin', '', $basedir);
|
$basedir = str_replace(array('/admin', '/install'), '', $basedir);
|
||||||
$basedir = str_replace('/install', '', $basedir);
|
|
||||||
define('BASE_DIR', $basedir);
|
define('BASE_DIR', $basedir);
|
||||||
|
|
||||||
if(isset($_SERVER['HTTP_HOST'])) {
|
if(isset($_SERVER['HTTP_HOST'])) {
|
||||||
if (isset($_SERVER['HTTPS'][0]) && $_SERVER['HTTPS'] == 'on')
|
if (isset($_SERVER['HTTPS'][0]) && $_SERVER['HTTPS'] === 'on')
|
||||||
define('SERVER_URL', 'https://' . $_SERVER['HTTP_HOST']);
|
define('SERVER_URL', 'https://' . $_SERVER['HTTP_HOST']);
|
||||||
else
|
else
|
||||||
define('SERVER_URL', 'http://' . $_SERVER['HTTP_HOST']);
|
define('SERVER_URL', 'http://' . $_SERVER['HTTP_HOST']);
|
||||||
|
33
index.php
33
index.php
@ -29,8 +29,8 @@
|
|||||||
// ini_set('display_startup_errors', 1);
|
// ini_set('display_startup_errors', 1);
|
||||||
// error_reporting(E_ALL);
|
// error_reporting(E_ALL);
|
||||||
|
|
||||||
require_once('common.php');
|
require_once 'common.php';
|
||||||
require_once(SYSTEM . 'functions.php');
|
require_once SYSTEM . 'functions.php';
|
||||||
|
|
||||||
$uri = $_SERVER['REQUEST_URI'];
|
$uri = $_SERVER['REQUEST_URI'];
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ if(preg_match("/^[A-Za-z0-9-_%\'+]+\.png$/i", $uri)) {
|
|||||||
$_REQUEST['name'] = urldecode($tmp[0]);
|
$_REQUEST['name'] = urldecode($tmp[0]);
|
||||||
|
|
||||||
chdir(TOOLS . 'signature');
|
chdir(TOOLS . 'signature');
|
||||||
include(TOOLS . 'signature/index.php');
|
include TOOLS . 'signature/index.php';
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
else if(preg_match("/^(.*)\.(gif|jpg|png|jpeg|tiff|bmp|css|js|less|map|html|php|zip|rar|gz|ttf|woff|ico)$/i", $_SERVER['REQUEST_URI'])) {
|
else if(preg_match("/^(.*)\.(gif|jpg|png|jpeg|tiff|bmp|css|js|less|map|html|php|zip|rar|gz|ttf|woff|ico)$/i", $_SERVER['REQUEST_URI'])) {
|
||||||
@ -57,7 +57,7 @@ else if(preg_match("/^(.*)\.(gif|jpg|png|jpeg|tiff|bmp|css|js|less|map|html|php|
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(file_exists(BASE . 'config.local.php'))
|
if(file_exists(BASE . 'config.local.php'))
|
||||||
require_once(BASE . 'config.local.php');
|
require_once BASE . 'config.local.php';
|
||||||
|
|
||||||
if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['installed']))
|
if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['installed']))
|
||||||
{
|
{
|
||||||
@ -120,8 +120,7 @@ else {
|
|||||||
'/^news\/archive\/?$/' => array('subtopic' => 'newsarchive'),
|
'/^news\/archive\/?$/' => array('subtopic' => 'newsarchive'),
|
||||||
'/^news\/archive\/[0-9]+\/?$/' => array('subtopic' => 'newsarchive', 'id' => '$2'),
|
'/^news\/archive\/[0-9]+\/?$/' => array('subtopic' => 'newsarchive', 'id' => '$2'),
|
||||||
'/^polls\/[0-9]+\/?$/' => array('subtopic' => 'polls', 'id' => '$1'),
|
'/^polls\/[0-9]+\/?$/' => array('subtopic' => 'polls', 'id' => '$1'),
|
||||||
'/^spells\/[A-Za-z0-9-_%]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'spells', 'vocation' => '$1', 'order' => '$2'),
|
'/^spells\/[A-Za-z0-9-_%]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'spells', 'vocation' => '$1', 'order' => '$2')
|
||||||
'/^gifts\/history\/?$/' => array('subtopic' => 'gifts', 'action' => 'show_history'),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($rules as $rule => $redirect) {
|
foreach($rules as $rule => $redirect) {
|
||||||
@ -164,15 +163,15 @@ define('PAGE', $page);
|
|||||||
|
|
||||||
$template_place_holders = array();
|
$template_place_holders = array();
|
||||||
|
|
||||||
require_once(SYSTEM . 'init.php');
|
require_once SYSTEM . 'init.php';
|
||||||
|
|
||||||
// event system
|
// event system
|
||||||
require_once(SYSTEM . 'hooks.php');
|
require_once SYSTEM . 'hooks.php';
|
||||||
$hooks = new Hooks();
|
$hooks = new Hooks();
|
||||||
$hooks->load();
|
$hooks->load();
|
||||||
require_once(SYSTEM . 'template.php');
|
require_once SYSTEM . 'template.php';
|
||||||
require_once(SYSTEM . 'login.php');
|
require_once SYSTEM . 'login.php';
|
||||||
require_once(SYSTEM . 'status.php');
|
require_once SYSTEM . 'status.php';
|
||||||
|
|
||||||
$twig->addGlobal('config', $config);
|
$twig->addGlobal('config', $config);
|
||||||
$twig->addGlobal('status', $status);
|
$twig->addGlobal('status', $status);
|
||||||
@ -236,11 +235,11 @@ if(isset($config['anonymous_usage_statistics']) && $config['anonymous_usage_stat
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($config['views_counter'])
|
if($config['views_counter'])
|
||||||
require_once(SYSTEM . 'counter.php');
|
require_once SYSTEM . 'counter.php';
|
||||||
|
|
||||||
if($config['visitors_counter'])
|
if($config['visitors_counter'])
|
||||||
{
|
{
|
||||||
require_once(SYSTEM . 'libs/visitors.php');
|
require_once SYSTEM . 'libs/visitors.php';
|
||||||
$visitors = new Visitors($config['visitors_counter_ttl']);
|
$visitors = new Visitors($config['visitors_counter_ttl']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +263,7 @@ if(fetchDatabaseConfig('site_closed', $site_closed)) {
|
|||||||
if(!$logged)
|
if(!$logged)
|
||||||
{
|
{
|
||||||
ob_start();
|
ob_start();
|
||||||
require(SYSTEM . 'pages/accountmanagement.php');
|
require SYSTEM . 'pages/accountmanagement.php';
|
||||||
$content .= ob_get_contents();
|
$content .= ob_get_contents();
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
$load_it = false;
|
$load_it = false;
|
||||||
@ -305,7 +304,7 @@ if($config['backward_support']) {
|
|||||||
$config['site']['screenshot_page'] = true;
|
$config['site']['screenshot_page'] = true;
|
||||||
|
|
||||||
if($config['forum'] != '')
|
if($config['forum'] != '')
|
||||||
$config['forum_link'] = (strtolower($config['forum']) == 'site' ? getLink('forum') : $config['forum']);
|
$config['forum_link'] = (strtolower($config['forum']) === 'site' ? getLink('forum') : $config['forum']);
|
||||||
|
|
||||||
foreach($status as $key => $value)
|
foreach($status as $key => $value)
|
||||||
$config['status']['serverStatus_' . $key] = $value;
|
$config['status']['serverStatus_' . $key] = $value;
|
||||||
@ -317,7 +316,7 @@ if($load_it)
|
|||||||
$content .= '<p class="note">Site is under maintenance (closed mode). Only privileged users can see it.</p>';
|
$content .= '<p class="note">Site is under maintenance (closed mode). Only privileged users can see it.</p>';
|
||||||
|
|
||||||
if($config['backward_support'])
|
if($config['backward_support'])
|
||||||
require(SYSTEM . 'compat_pages.php');
|
require SYSTEM . 'compat_pages.php';
|
||||||
|
|
||||||
$ignore = false;
|
$ignore = false;
|
||||||
|
|
||||||
@ -388,7 +387,7 @@ if($load_it)
|
|||||||
ob_start();
|
ob_start();
|
||||||
if($hooks->trigger(HOOK_BEFORE_PAGE)) {
|
if($hooks->trigger(HOOK_BEFORE_PAGE)) {
|
||||||
if(!$ignore)
|
if(!$ignore)
|
||||||
require($file);
|
require $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($config['backward_support'] && isset($main_content[0]))
|
if($config['backward_support'] && isset($main_content[0]))
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
defined('MYAAC') or die('Direct access not allowed!');
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
|
|
||||||
if(!isset($config['database_type'][0]) || !isset($config['database_user'][0]) || !isset($config['database_password'][0]) || !isset($config['database_name'][0]))
|
if(!isset($config['database_type'][0], $config['database_user'][0], $config['database_password'][0], $config['database_name'][0]))
|
||||||
{
|
{
|
||||||
if(isset($config['lua']['sqlType'])) {// tfs 0.3
|
if(isset($config['lua']['sqlType'])) {// tfs 0.3
|
||||||
if(isset($config['lua']['mysqlHost'])) {// tfs 0.2
|
if(isset($config['lua']['mysqlHost'])) {// tfs 0.2
|
||||||
|
@ -70,7 +70,7 @@ function getPlayerLink($name, $generate = true)
|
|||||||
if(is_numeric($name))
|
if(is_numeric($name))
|
||||||
{
|
{
|
||||||
$player = new OTS_Player();
|
$player = new OTS_Player();
|
||||||
$player->load(intval($name));
|
$player->load((int)$name);
|
||||||
if($player->isLoaded())
|
if($player->isLoaded())
|
||||||
$name = $player->getName();
|
$name = $player->getName();
|
||||||
}
|
}
|
||||||
@ -88,9 +88,7 @@ function getHouseLink($name, $generate = true)
|
|||||||
if(is_numeric($name))
|
if(is_numeric($name))
|
||||||
{
|
{
|
||||||
$house = $db->query(
|
$house = $db->query(
|
||||||
'SELECT ' . $db->fieldName('name') .
|
'SELECT `name` FROM `houses` WHERE `id` = ' . (int)$name);
|
||||||
' FROM ' . $db->tableName('houses') .
|
|
||||||
' WHERE ' . $db->fieldName('id') . ' = ' . (int)$name);
|
|
||||||
if($house->rowCount() > 0)
|
if($house->rowCount() > 0)
|
||||||
$name = $house->fetchColumn();
|
$name = $house->fetchColumn();
|
||||||
}
|
}
|
||||||
@ -122,7 +120,7 @@ function getGuildLink($name, $generate = true)
|
|||||||
function getItemNameById($id) {
|
function getItemNameById($id) {
|
||||||
global $db;
|
global $db;
|
||||||
$query = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'items` WHERE `id` = ' . $db->quote($id) . ' LIMIT 1;');
|
$query = $db->query('SELECT `name` FROM `' . TABLE_PREFIX . 'items` WHERE `id` = ' . $db->quote($id) . ' LIMIT 1;');
|
||||||
if($query->rowCount() == 1) {
|
if($query->rowCount() === 1) {
|
||||||
$item = $query->fetch();
|
$item = $query->fetch();
|
||||||
return $item['name'];
|
return $item['name'];
|
||||||
}
|
}
|
||||||
@ -154,7 +152,7 @@ function getFlagImage($country)
|
|||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
if(!isset($config['countries']))
|
if(!isset($config['countries']))
|
||||||
require(SYSTEM . 'countries.conf.php');
|
require SYSTEM . 'countries.conf.php';
|
||||||
|
|
||||||
if(!isset($config['countries'][$country])) {
|
if(!isset($config['countries'][$country])) {
|
||||||
return '';
|
return '';
|
||||||
@ -176,16 +174,18 @@ function getBoolean($v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(is_numeric($v))
|
if(is_numeric($v))
|
||||||
return intval($v) > 0;
|
return (int)$v > 0;
|
||||||
|
|
||||||
$v = strtolower($v);
|
$v = strtolower($v);
|
||||||
return $v == 'yes' || $v == 'true';
|
return $v === 'yes' || $v === 'true';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates random string.
|
* Generates random string.
|
||||||
*
|
*
|
||||||
* @param int $length Length of the generated string.
|
* @param int $length Length of the generated string.
|
||||||
|
* @param bool $lowCase Should lower case characters be used?
|
||||||
|
* @param bool $upCase Should upper case characters be used?
|
||||||
* @param bool $numeric Should numbers by used too?
|
* @param bool $numeric Should numbers by used too?
|
||||||
* @param bool $special Should special characters by used?
|
* @param bool $special Should special characters by used?
|
||||||
* @return string Generated string.
|
* @return string Generated string.
|
||||||
@ -242,7 +242,7 @@ function fetchDatabaseConfig($name, &$value)
|
|||||||
{
|
{
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
$query = $db->query('SELECT ' . $db->fieldName('value') . ' FROM ' . $db->tableName(TABLE_PREFIX . 'config') . ' WHERE ' . $db->fieldName('name') . ' = ' . $db->quote($name));
|
$query = $db->query('SELECT `value` FROM `' . TABLE_PREFIX . 'config` WHERE `name` = ' . $db->quote($name));
|
||||||
if($query->rowCount() <= 0)
|
if($query->rowCount() <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -297,9 +297,9 @@ function encrypt($str)
|
|||||||
$str .= $config['database_salt'];
|
$str .= $config['database_salt'];
|
||||||
|
|
||||||
$encryptionType = $config['database_encryption'];
|
$encryptionType = $config['database_encryption'];
|
||||||
if(isset($encryptionType) && strtolower($encryptionType) != 'plain')
|
if(isset($encryptionType) && strtolower($encryptionType) !== 'plain')
|
||||||
{
|
{
|
||||||
if($encryptionType == 'vahash')
|
if($encryptionType === 'vahash')
|
||||||
return base64_encode(hash('sha256', $str));
|
return base64_encode(hash('sha256', $str));
|
||||||
|
|
||||||
return hash($encryptionType, $str);
|
return hash($encryptionType, $str);
|
||||||
@ -350,6 +350,8 @@ function delete_player($name)
|
|||||||
$player->delete();
|
$player->delete();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//delete guild with id
|
//delete guild with id
|
||||||
@ -407,7 +409,7 @@ function tickers()
|
|||||||
{
|
{
|
||||||
global $tickers_content, $featured_article;
|
global $tickers_content, $featured_article;
|
||||||
|
|
||||||
if(PAGE == 'news') {
|
if(PAGE === 'news') {
|
||||||
if(isset($tickers_content))
|
if(isset($tickers_content))
|
||||||
return $tickers_content . $featured_article;
|
return $tickers_content . $featured_article;
|
||||||
}
|
}
|
||||||
@ -429,9 +431,9 @@ function template_place_holder($type)
|
|||||||
if(array_key_exists($type, $template_place_holders) && is_array($template_place_holders[$type]))
|
if(array_key_exists($type, $template_place_holders) && is_array($template_place_holders[$type]))
|
||||||
$ret = implode($template_place_holders[$type]);
|
$ret = implode($template_place_holders[$type]);
|
||||||
|
|
||||||
if($type == 'head_start')
|
if($type === 'head_start')
|
||||||
$ret .= template_header();
|
$ret .= template_header();
|
||||||
elseif($type == 'body_end')
|
elseif($type === 'body_end')
|
||||||
$ret .= template_ga_code();
|
$ret .= template_ga_code();
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
@ -574,7 +576,7 @@ function getCreatureName($killer, $showStatus = false, $extendedInfo = false)
|
|||||||
$players_rows .= "item or field";
|
$players_rows .= "item or field";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(in_array(substr(strtolower($killer), 0, 1), $vowels))
|
if(in_array(strtolower($killer[0]), $vowels))
|
||||||
$players_rows .= "an ";
|
$players_rows .= "an ";
|
||||||
else
|
else
|
||||||
$players_rows .= "a ";
|
$players_rows .= "a ";
|
||||||
@ -746,7 +748,7 @@ function get_templates()
|
|||||||
$path = TEMPLATES;
|
$path = TEMPLATES;
|
||||||
foreach(scandir($path) as $file)
|
foreach(scandir($path) as $file)
|
||||||
{
|
{
|
||||||
if($file[0] != '.' && $file != '..' && is_dir($path . $file))
|
if($file[0] !== '.' && $file !== '..' && is_dir($path . $file))
|
||||||
$ret[] = $file;
|
$ret[] = $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -765,7 +767,7 @@ function get_plugins()
|
|||||||
foreach(scandir($path) as $file) {
|
foreach(scandir($path) as $file) {
|
||||||
$file_ext = pathinfo($file, PATHINFO_EXTENSION);
|
$file_ext = pathinfo($file, PATHINFO_EXTENSION);
|
||||||
$file_name = pathinfo($file, PATHINFO_FILENAME);
|
$file_name = pathinfo($file, PATHINFO_FILENAME);
|
||||||
if ($file == '.' || $file == '..' || $file == 'disabled' || $file == 'example.json' || is_dir($path . $file) || $file_ext != 'json')
|
if ($file === '.' || $file === '..' || $file === 'disabled' || $file === 'example.json' || $file_ext !== 'json' || is_dir($path . $file))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$ret[] = str_replace('.json', '', $file_name);
|
$ret[] = str_replace('.json', '', $file_name);
|
||||||
@ -797,7 +799,7 @@ function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true)
|
|||||||
global $mailer, $config;
|
global $mailer, $config;
|
||||||
if(!$mailer)
|
if(!$mailer)
|
||||||
{
|
{
|
||||||
require(SYSTEM . 'libs/phpmailer/PHPMailerAutoload.php');
|
require SYSTEM . 'libs/phpmailer/PHPMailerAutoload.php';
|
||||||
$mailer = new PHPMailer();
|
$mailer = new PHPMailer();
|
||||||
$mailer->setLanguage('en', LIBS . 'phpmailer/language/');
|
$mailer->setLanguage('en', LIBS . 'phpmailer/language/');
|
||||||
}
|
}
|
||||||
@ -871,9 +873,7 @@ function load_config_lua($filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
$config_string = file_get_contents($filename);
|
$config_string = str_replace(array("\r\n", "\r"), "\n", file_get_contents($filename));
|
||||||
$config_string = str_replace("\r\n", "\n", $config_string);
|
|
||||||
$config_string = str_replace("\r", "\n", $config_string);
|
|
||||||
$lines = explode("\n", $config_string);
|
$lines = explode("\n", $config_string);
|
||||||
if(count($lines) > 0)
|
if(count($lines) > 0)
|
||||||
foreach($lines as $ln => $line)
|
foreach($lines as $ln => $line)
|
||||||
@ -984,12 +984,14 @@ function getTopPlayers($limit = 5) {
|
|||||||
$query = $db->query('SELECT `player_id` FROM `players_online` WHERE `player_id` = ' . $player['id']);
|
$query = $db->query('SELECT `player_id` FROM `players_online` WHERE `player_id` = ' . $player['id']);
|
||||||
$player['online'] = ($query->rowCount() > 0 ? 1 : 0);
|
$player['online'] = ($query->rowCount() > 0 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
unset($player);
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach($players as &$player) {
|
foreach($players as &$player) {
|
||||||
$player['rank'] = ++$i;
|
$player['rank'] = ++$i;
|
||||||
}
|
}
|
||||||
|
unset($player);
|
||||||
|
|
||||||
if($cache->enabled())
|
if($cache->enabled())
|
||||||
$cache->set('top_' . $limit . '_level', serialize($players), 120);
|
$cache->set('top_' . $limit . '_level', serialize($players), 120);
|
||||||
@ -1008,7 +1010,7 @@ function deleteDirectory($dir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach(scandir($dir) as $item) {
|
foreach(scandir($dir) as $item) {
|
||||||
if($item == '.' || $item == '..') {
|
if($item === '.' || $item === '..') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1021,6 +1023,6 @@ function deleteDirectory($dir) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validator functions
|
// validator functions
|
||||||
require_once(LIBS . 'validator.php');
|
require_once LIBS . 'validator.php';
|
||||||
require_once(SYSTEM . 'compat.php');
|
require_once SYSTEM . 'compat.php';
|
||||||
?>
|
?>
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
defined('MYAAC') or die('Direct access not allowed!');
|
defined('MYAAC') or die('Direct access not allowed!');
|
||||||
|
|
||||||
// load configuration
|
// load configuration
|
||||||
require_once(BASE . 'config.php');
|
require_once BASE . 'config.php';
|
||||||
if(file_exists(BASE . 'config.local.php')) // user customizations
|
if(file_exists(BASE . 'config.local.php')) // user customizations
|
||||||
require(BASE . 'config.local.php');
|
require BASE . 'config.local.php';
|
||||||
|
|
||||||
if(!isset($config['installed']) || !$config['installed']) {
|
if(!isset($config['installed']) || !$config['installed']) {
|
||||||
die('MyAAC has not been installed yet or there was error during installation. Please install again.');
|
die('MyAAC has not been installed yet or there was error during installation. Please install again.');
|
||||||
@ -20,7 +20,7 @@ if(!isset($config['installed']) || !$config['installed']) {
|
|||||||
|
|
||||||
date_default_timezone_set($config['date_timezone']);
|
date_default_timezone_set($config['date_timezone']);
|
||||||
// take care of trailing slash at the end
|
// take care of trailing slash at the end
|
||||||
if($config['server_path'][strlen($config['server_path']) - 1] != '/')
|
if($config['server_path'][strlen($config['server_path']) - 1] !== '/')
|
||||||
$config['server_path'] .= '/';
|
$config['server_path'] .= '/';
|
||||||
|
|
||||||
// enable gzip compression if supported by the browser
|
// enable gzip compression if supported by the browser
|
||||||
@ -28,11 +28,11 @@ if($config['gzip_output'] && isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($
|
|||||||
ob_start('ob_gzhandler');
|
ob_start('ob_gzhandler');
|
||||||
|
|
||||||
// cache
|
// cache
|
||||||
require_once(SYSTEM . 'libs/cache.php');
|
require_once SYSTEM . 'libs/cache.php';
|
||||||
$cache = Cache::getInstance($config['cache_engine'], $config['cache_prefix']);
|
$cache = Cache::getInstance($config['cache_engine'], $config['cache_prefix']);
|
||||||
|
|
||||||
// twig
|
// twig
|
||||||
require_once(LIBS . 'Twig/Autoloader.php');
|
require_once LIBS . 'Twig/Autoloader.php';
|
||||||
Twig_Autoloader::register();
|
Twig_Autoloader::register();
|
||||||
|
|
||||||
$twig_loader = new Twig_Loader_Filesystem(SYSTEM . 'templates');
|
$twig_loader = new Twig_Loader_Filesystem(SYSTEM . 'templates');
|
||||||
@ -117,35 +117,35 @@ if(isset($config['lua']['servername']))
|
|||||||
if(isset($config['lua']['houserentperiod']))
|
if(isset($config['lua']['houserentperiod']))
|
||||||
$config['lua']['houseRentPeriod'] = $config['lua']['houserentperiod'];
|
$config['lua']['houseRentPeriod'] = $config['lua']['houserentperiod'];
|
||||||
|
|
||||||
if($config['item_images_url'][strlen($config['item_images_url']) - 1] != '/')
|
if($config['item_images_url'][strlen($config['item_images_url']) - 1] !== '/')
|
||||||
$config['item_images_url'] .= '/';
|
$config['item_images_url'] .= '/';
|
||||||
|
|
||||||
// localize data/ directory
|
// localize data/ directory
|
||||||
if(isset($config['lua']['dataDirectory'][0]))
|
if(isset($config['lua']['dataDirectory'][0]))
|
||||||
{
|
{
|
||||||
$tmp = $config['lua']['dataDirectory'];
|
$tmp = $config['lua']['dataDirectory'];
|
||||||
if($tmp[0] != '/')
|
if($tmp[0] !== '/')
|
||||||
$tmp = $config['server_path'] . $tmp;
|
$tmp = $config['server_path'] . $tmp;
|
||||||
|
|
||||||
if($tmp[strlen($tmp) - 1] != '/') // do not forget about trailing slash
|
if($tmp[strlen($tmp) - 1] !== '/') // do not forget about trailing slash
|
||||||
$tmp .= '/';
|
$tmp .= '/';
|
||||||
}
|
}
|
||||||
else if(isset($config['lua']['data_directory'][0]))
|
else if(isset($config['lua']['data_directory'][0]))
|
||||||
{
|
{
|
||||||
$tmp = $config['lua']['data_directory'];
|
$tmp = $config['lua']['data_directory'];
|
||||||
if($tmp[0] != '/')
|
if($tmp[0] !== '/')
|
||||||
$tmp = $config['server_path'] . $tmp;
|
$tmp = $config['server_path'] . $tmp;
|
||||||
|
|
||||||
if($tmp[strlen($tmp) - 1] != '/') // do not forget about trailing slash
|
if($tmp[strlen($tmp) - 1] !== '/') // do not forget about trailing slash
|
||||||
$tmp .= '/';
|
$tmp .= '/';
|
||||||
}
|
}
|
||||||
else if(isset($config['lua']['datadir'][0]))
|
else if(isset($config['lua']['datadir'][0]))
|
||||||
{
|
{
|
||||||
$tmp = $config['lua']['datadir'];
|
$tmp = $config['lua']['datadir'];
|
||||||
if($tmp[0] != '/')
|
if($tmp[0] !== '/')
|
||||||
$tmp = $config['server_path'] . $tmp;
|
$tmp = $config['server_path'] . $tmp;
|
||||||
|
|
||||||
if($tmp[strlen($tmp) - 1] != '/') // do not forget about trailing slash
|
if($tmp[strlen($tmp) - 1] !== '/') // do not forget about trailing slash
|
||||||
$tmp .= '/';
|
$tmp .= '/';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -260,7 +260,7 @@ class POT
|
|||||||
$this->path = str_replace('\\', '/', $path);
|
$this->path = str_replace('\\', '/', $path);
|
||||||
|
|
||||||
// appends ending slash to directory path
|
// appends ending slash to directory path
|
||||||
if( substr($this->path, -1) != '/')
|
if( substr($this->path, -1) !== '/')
|
||||||
{
|
{
|
||||||
$this->path .= '/';
|
$this->path .= '/';
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ class POT
|
|||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
// default POT directory
|
// default POT directory
|
||||||
$this->path = dirname(__FILE__) . '/';
|
$this->path = __DIR__ . '/';
|
||||||
// registers POT autoload mechanism
|
// registers POT autoload mechanism
|
||||||
spl_autoload_register( array($this, 'loadClass') );
|
spl_autoload_register( array($this, 'loadClass') );
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ if($current_session !== false)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ACTION == 'logout' && !isset($_REQUEST['account_login'])) {
|
if(ACTION === 'logout' && !isset($_REQUEST['account_login'])) {
|
||||||
if(isset($account_logged) && $account_logged->isLoaded()) {
|
if(isset($account_logged) && $account_logged->isLoaded()) {
|
||||||
if($hooks->trigger(HOOK_LOGOUT, array('account' => $account_logged, 'password' => getSession('password')))) {
|
if($hooks->trigger(HOOK_LOGOUT, array('account' => $account_logged, 'password' => getSession('password')))) {
|
||||||
unsetSession('account');
|
unsetSession('account');
|
||||||
@ -52,7 +52,7 @@ if(ACTION == 'logout' && !isset($_REQUEST['account_login'])) {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// new login with data from form
|
// new login with data from form
|
||||||
if(!$logged && isset($_POST['account_login']) && isset($_POST['password_login']))
|
if(!$logged && isset($_POST['account_login'], $_POST['password_login']))
|
||||||
{
|
{
|
||||||
$login_account = $_POST['account_login'];
|
$login_account = $_POST['account_login'];
|
||||||
$login_password = $_POST['password_login'];
|
$login_password = $_POST['password_login'];
|
||||||
|
@ -56,7 +56,7 @@ if($cache->enabled())
|
|||||||
if($fetch_from_db)
|
if($fetch_from_db)
|
||||||
{
|
{
|
||||||
// get info from db
|
// get info from db
|
||||||
$status_query = $db->query('SELECT ' . $db->fieldName('name') . ', ' . $db->fieldName('value') . ' FROM ' . $db->tableName(TABLE_PREFIX . 'config') . ' WHERE ' . $db->fieldName('name') . ' LIKE "%status%"');
|
$status_query = $db->query('SELECT `name`, `value` FROM `' . TABLE_PREFIX . 'config` WHERE ' . $db->fieldName('name') . ' LIKE "%status%"');
|
||||||
if($status_query->rowCount() <= 0) // empty, just insert it
|
if($status_query->rowCount() <= 0) // empty, just insert it
|
||||||
{
|
{
|
||||||
foreach($status as $key => $value)
|
foreach($status as $key => $value)
|
||||||
|
@ -66,7 +66,7 @@ if($exists || ($config['backward_support'] && file_exists(BASE . $template_path
|
|||||||
$config[$key] = $value;
|
$config[$key] = $value;
|
||||||
}
|
}
|
||||||
else if(file_exists(BASE . $template_path . '/config.php'))
|
else if(file_exists(BASE . $template_path . '/config.php'))
|
||||||
require(BASE . $template_path . '/config.php');
|
require BASE . $template_path . '/config.php';
|
||||||
|
|
||||||
$template = array();
|
$template = array();
|
||||||
$template['link_account_manage'] = getLink('account/manage');
|
$template['link_account_manage'] = getLink('account/manage');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user