diff --git a/.htaccess b/.htaccess
index 13e5791d..274c5988 100644
--- a/.htaccess
+++ b/.htaccess
@@ -11,6 +11,9 @@ RewriteRule ^images/items/([0-9]+)\.gif$ tools/item.php?id=$1
RewriteRule ^characters/([A-Za-z0-9-_+']+)$ index.php?subtopic=characters&name=$1
RewriteRule ^guilds/([A-Za-z0-9-_+']+)$ index.php?subtopic=guilds&action=show&guild=$1
RewriteRule ^forum/board/([0-9]+)$ index.php?subtopic=forum&action=show_board&id=$1
+RewriteRule ^forum/board/([0-9]+)/([0-9]+)$ index.php?subtopic=forum&action=show_board&id=$1&page=$2
+RewriteRule ^forum/thread/([0-9]+)$ index.php?subtopic=forum&action=show_thread&id=$1
+RewriteRule ^forum/board/([0-9]+)/([0-9]+)$ index.php?subtopic=forum&action=show_thread&id=$1&page=$2
RewriteRule ^account/manage$ index.php?subtopic=accountmanagement
RewriteRule ^account/create$ index.php?subtopic=createaccount
RewriteRule ^account/lost$ index.php?subtopic=lostaccount
diff --git a/config.php b/config.php
index abd4d9c0..11ddcc4f 100644
--- a/config.php
+++ b/config.php
@@ -48,7 +48,7 @@ $config = array(
'site_closed_title' => 'Closed',
'site_closed_message' => 'Server is under maintance, please visit later.
',
- 'debug_level' => 0, // 0 - disabled, 1 - show load time, 2 - show db query counter, 3 - both
+ 'debug_level' => 0, // 0 - disabled, 1 - show load time, 2 - show db query counter, 3 - both, 4 - memory usage, 5 - load time & load time, 6 - queries & memory usage, 7 - all
'language' => 'en', // default language (currently only 'en' available)
'language_allow_change' => false,
diff --git a/index.php b/index.php
index 306a1e0e..0f432839 100644
--- a/index.php
+++ b/index.php
@@ -1 +1 @@
-
* @copyright 2017 MyAAC
* @version 0.0.1
* @link http://my-aac.org
*/
require_once('common.php');
require_once(BASE . 'config.local.php');
if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['installed']))
{
header('Location: ' . BASE_DIR . '/install/');
die('Setup detected that install/ directory exists. Please visit this url to start MyAAC Installation.
Delete install/ directory if you already installed MyAAC.
Remember to REFRESH this page when you\'re done!');
}
// define page visited, so it can be used within events system
$page = isset($_REQUEST['subtopic']) ? $_REQUEST['subtopic'] : (isset($_GET['p']) ? $_GET['p'] : '');
if(empty($page) || preg_match('/[^A-z0-9_\-]/', $page))
$page = 'news';
$page = strtolower($page);
define('PAGE', $page);
$template_place_holders = array();
// event system
require_once(SYSTEM . 'events.php');
$events = new Events();
$events->trigger('STARTUP');
require_once(SYSTEM . 'functions.php');
require_once(SYSTEM . 'init.php');
require_once(SYSTEM . 'login.php');
require_once(SYSTEM . 'status.php');
require_once(SYSTEM . 'template.php');
if($config['views_counter'])
require_once(SYSTEM . 'counter.php');
if($config['visitors_counter'])
{
require_once(SYSTEM . 'libs/visitors.php');
$visitors = new Visitors($config['visitors_counter_ttl']);
}
// page content loading
if(!isset($content[0]))
$content = '';
$load_it = true;
// check if site has been closed
if($config['site_closed'])
{
if(!admin())
{
$title = $config['site_closed_title'];
$content .= $config['site_closed_message'];
$load_it = false;
}
if(!$logged)
{
ob_start();
require(SYSTEM . 'pages/accountmanagement.php');
$content .= ob_get_contents();
ob_end_clean();
$load_it = false;
}
}
if($load_it)
{
if($config['site_closed'] && admin())
$content .= '
Site is under maintenance (closed mode). Only privileged users can see it.
'; if($config['backward_support']) require(SYSTEM . 'compat_pages.php'); $ignore = false; $file = SYSTEM . 'pages/' . $page . '.php'; if(!@file_exists($file)) { $logged_access = 0; if($logged && $account_logged && $account_logged->isLoaded()) { $logged_access = $account_logged->getAccess(); } $query = $db->query( 'SELECT `title`, `body`, `php`' . ' FROM `' . TABLE_PREFIX . 'pages`' . ' WHERE `name` LIKE ' . $db->quote($page) . ' AND `hidden` != 1 AND `access` <= ' . $db->quote($logged_access)); if($query->rowCount() > 0) // found page { $ignore = true; $query = $query->fetch(); $title = $query['title']; if($query['php'] == '1') // execute it as php code { $tmp = substr($query['body'], 0, 10); if(($pos = strpos($tmp, ' $errno, 'errstr' => $errstr); } set_error_handler('error_handler'); ob_start(); eval($tmp); $content .= ob_get_contents(); ob_end_clean(); restore_error_handler(); if(isset($php_errors[0]) && superAdmin()) { var_dump($php_errors); } } else $content .= $query['body']; // plain html } else { $page = '404'; $file = SYSTEM . 'pages/404.php'; } } ob_start(); if($events->trigger('BEFORE_PAGE')) { if(!$ignore) require($file); } $content .= ob_get_contents(); ob_end_clean(); $events->trigger('AFTER_PAGE'); } $title_full = (isset($title) ? $title . $config['title_separator'] : '') . $config['lua']['serverName']; if(file_exists($template_path . '/index.php')) require($template_path . '/index.php'); else if(file_exists($template_path . '/template.php')) // deprecated require($template_path . '/template.php'); else if($config['backward_support'] && file_exists($template_path . '/layout.php')) { // backward support for gesior $SQL = $db; $layout_header = template_header(); $layout_name = $template_path; $main_content = $content; $config['access_admin_panel'] = 2; $group_id_of_acc_logged = 0; if($logged && $account_logged) $group_id_of_acc_logged = $account_logged->getCustomField('group_id'); $config['gifts_system'] = ($config['site']['shop_system'] == 1); //$config['site']['shop_system'] = $config['gifts_system'] ? '1' : '0'; $config['serverinfo_page'] = 1; $config['download_page'] = 1; if($config['forum'] != '') $config['forum_link'] = (strtolower($config['forum']) == 'site' ? internalLayoutLink('forum') : $config['forum']); $config['site'] = &$config; require($template_path . '/layout.php'); } else { // TODO: save more info to log file die('ERROR: Cannot load template.'); } echo '' . "\n"; if(($config['debug_level'] & 1) == 1) echo ''; if(($config['debug_level'] & 2) == 2) echo "\n" . ''; if(($config['debug_level'] & 4) == 4 && function_exists('memory_get_peak_usage')) echo "\n" . ''; $events->trigger('FINISH'); ?> \ No newline at end of file + * @copyright 2017 MyAAC * @version 0.0.1 * @link http://my-aac.org */ require_once('common.php'); require_once(BASE . 'config.local.php'); if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['installed'])) { header('Location: ' . BASE_DIR . '/install/'); die('Setup detected that install/ directory exists. Please visit this url to start MyAAC Installation.Site is under maintenance (closed mode). Only privileged users can see it.
'; if($config['backward_support']) require(SYSTEM . 'compat_pages.php'); $ignore = false; $file = SYSTEM . 'pages/' . $page . '.php'; if(!@file_exists($file)) { $logged_access = 0; if($logged && $account_logged && $account_logged->isLoaded()) { $logged_access = $account_logged->getAccess(); } $query = $db->query( 'SELECT `title`, `body`, `php`' . ' FROM `' . TABLE_PREFIX . 'pages`' . ' WHERE `name` LIKE ' . $db->quote($page) . ' AND `hidden` != 1 AND `access` <= ' . $db->quote($logged_access)); if($query->rowCount() > 0) // found page { $ignore = true; $query = $query->fetch(); $title = $query['title']; if($query['php'] == '1') // execute it as php code { $tmp = substr($query['body'], 0, 10); if(($pos = strpos($tmp, ' $errno, 'errstr' => $errstr); } set_error_handler('error_handler'); ob_start(); eval($tmp); $content .= ob_get_contents(); ob_end_clean(); restore_error_handler(); if(isset($php_errors[0]) && superAdmin()) { var_dump($php_errors); } } else $content .= $query['body']; // plain html } else { $page = '404'; $file = SYSTEM . 'pages/404.php'; } } ob_start(); if($events->trigger('BEFORE_PAGE')) { if(!$ignore) require($file); } if($config['backward_support'] && isset($main_content)) $content .= $main_content; $content .= ob_get_contents(); ob_end_clean(); $events->trigger('AFTER_PAGE'); } $title_full = (isset($title) ? $title . $config['title_separator'] : '') . $config['lua']['serverName']; if(file_exists($template_path . '/index.php')) require($template_path . '/index.php'); else if(file_exists($template_path . '/template.php')) // deprecated require($template_path . '/template.php'); else if($config['backward_support'] && file_exists($template_path . '/layout.php')) { require($template_path . '/layout.php'); } else { // TODO: save more info to log file die('ERROR: Cannot load template.'); } echo '' . "\n"; if(($config['debug_level'] & 1) == 1) echo ''; if(($config['debug_level'] & 2) == 2) echo "\n" . ''; if(($config['debug_level'] & 4) == 4 && function_exists('memory_get_peak_usage')) echo "\n" . ''; $events->trigger('FINISH'); ?> \ No newline at end of file diff --git a/system/functions.php b/system/functions.php index 11753cce..02b93e88 100644 --- a/system/functions.php +++ b/system/functions.php @@ -45,6 +45,32 @@ function getPageLink($page, $action = null) } function internalLayoutLink($page, $action = null) {return getPageLink($page, $action);} +function getForumThreadLink($thread_id, $page = NULL) +{ + global $config; + + $url = ''; + if($config['friendly_urls']) + $url = BASE_URL . 'forum/thread/' . (int)$thread_id . (isset($page) ? '/' . $page : ''); + else + $url = BASE_URL . '?subtopic=forum&action=show_thread&id=' . (int)$thread_id . (isset($page) ? '&page=' . $page : ''); + + return $url; +} + +function getForumBoardLink($board_id, $page = NULL) +{ + global $config; + + $url = ''; + if($config['friendly_urls']) + $url = BASE_URL . 'forum/board/' . (int)$board_id . (isset($page) ? '/' . $page : ''); + else + $url = BASE_URL . '?subtopic=forum&action=show_board&id=' . (int)$board_id . (isset($page) ? '&page=' . $page : ''); + + return $url; +} + function getPlayerLink($name, $generate = true) { global $ots, $config; @@ -455,7 +481,7 @@ function check_account_name($name, &$error = '') } //is it valid nick for new char? -function check_name_new_char($name) +function check_name_new_char($name, &$error = '') { global $db, $config; @@ -464,92 +490,127 @@ function check_name_new_char($name) $first_words_blocked = array('admin ', 'administrator ', 'gm ', 'cm ', 'god ','tutor ', "'", '-'); foreach($first_words_blocked as $word) { - if($word == substr($name_lower, 0, strlen($word))) + if($word == substr($name_lower, 0, strlen($word))) { + $error = 'Your name contains blocked words.'; return false; + } } - if(substr($name_lower, -1) == "'" || substr($name_lower, -1) == "-") + if(substr($name_lower, -1) == "'" || substr($name_lower, -1) == "-") { + $error = 'Your name contains illegal characters.'; return false; + } - if(substr($name_lower, 1, 1) == ' ') + if(substr($name_lower, 1, 1) == ' ') { + $error = 'Your name contains illegal space.'; return false; + } - if(substr($name_lower, -2, 1) == " ") + if(substr($name_lower, -2, 1) == " ") { + $error = 'Your name contains illegal space.'; return false; + } - if(strtolower($config['lua']['serverName']) == $name_lower) + if(strtolower($config['lua']['serverName']) == $name_lower) { + $error = 'Your name cannot be same as server name.'; return false; + } $names_blocked = array('admin', 'administrator', 'gm', 'cm', 'god', 'tutor'); foreach($names_blocked as $word) { - if($word == $name_lower) - return false; - } - - $name_length = strlen($name_lower); - for($i = 0; $i < $name_length; $i++) - { - if(isset($name_lower[$i - 1]) && $name_lower[$i - 1] == ' ' && isset($name_lower[$i + 1]) && $name_lower[$i + 1] == ' ') + if($word == $name_lower) { + $error = 'Your name contains blocked words.'; return false; + } } $words_blocked = array('admin', 'administrator', 'gamemaster', 'game master', 'game-master', "game'master", '--', "''","' ", " '", '- ', ' -', "-'", "'-", 'fuck', 'sux', 'suck', 'noob', 'tutor'); foreach($words_blocked as $word) { - if(!(strpos($name_lower, $word) === false)) + if(!(strpos($name_lower, $word) === false)) { + $error = 'Your name contains illegal words.'; return false; + } + } + + $name_length = strlen($name_lower); + for($i = 0; $i < $name_length; $i++) + { + if(isset($name_lower[$i]) && isset($name_lower[$i + 1]) && $name_lower[$i] == $name_lower[$i + 1] && isset($name_lower[$i + 2]) && $name_lower[$i] == $name_lower[$i + 2]) { + $error = 'Your name is invalid.'; + return false; + } } for($i = 0; $i < $name_length; $i++) { - if(isset($name_lower[$i]) && isset($name_lower[$i + 1]) && $name_lower[$i] == $name_lower[$i + 1] && isset($name_lower[$i + 2]) && $name_lower[$i] == $name_lower[$i + 2]) - return false; - } - - for($i = 0; $i < $name_length; $i++) - { - if(isset($name_lower[$i - 1]) && $name_lower[$i - 1] == ' ' && isset($name_lower[$i + 1]) && $name_lower[$i + 1] == ' ') + if(isset($name_lower[$i - 1]) && $name_lower[$i - 1] == ' ' && isset($name_lower[$i + 1]) && $name_lower[$i + 1] == ' ') { + $error = 'Your name contains too many spaces.'; return false; + } } if(isset($config['monsters'])) { - if(in_array($name_lower, $config['monsters'])) + if(in_array($name_lower, $config['monsters'])) { + $error = 'Your name cannot contains monster name.'; return false; + } } $monsters = $db->query( 'SELECT ' . $db->fieldName('name') . ' FROM ' . $db->tableName(TABLE_PREFIX . 'monsters') . ' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($name_lower)); - if($monsters->rowCount() > 0) + if($monsters->rowCount() > 0) { + $error = 'Your name cannot contains monster name.'; return false; + } $spells_name = $db->query( 'SELECT ' . $db->fieldName('name') . ' FROM ' . $db->tableName(TABLE_PREFIX . 'spells') . ' WHERE ' . $db->fieldName('name') . ' LIKE ' . $db->quote($name_lower)); - if($spells_name->rowCount() > 0) + if($spells_name->rowCount() > 0) { + $error = 'Your name cannot contains spell name.'; return false; + } $spells_words = $db->query( 'SELECT ' . $db->fieldName('words') . ' FROM ' . $db->tableName(TABLE_PREFIX . 'spells') . ' WHERE ' . $db->fieldName('words') . ' = ' . $db->quote($name_lower)); - if($spells_words->rowCount() > 0) + if($spells_words->rowCount() > 0) { + $error = 'Your name cannot contains spell name.'; return false; - - if(isset($config['npc'])) - { - if(in_array($name_lower, $config['npc'])) - return false; } - if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- '") != $name_length) - return false; + if(isset($config['npc'])) + { + if(in_array($name_lower, $config['npc'])) { + $error = 'Your name cannot contains NPC name.'; + return false; + } + } - return preg_match("/[A-z ']{3,28}/", $name); + if(strspn($name, "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM- '") != $name_length) { + $error = 'This name contains invalid letters, words or format. Please use only a-Z, - , \' and space.'; + return false; + } + + if($name_length < 3 || $name_length > 28) { + $error = 'Your name cannot be shorter than 3 characters and longer than 28 characters.'; + return false; + } + + + if(!preg_match("/[A-z ']{3,28}/", $name)) { + $error = 'Your name containst illegal characters.'; + return false; + } + + return true; } function check_rank_name($name) @@ -778,7 +839,7 @@ function template_form() else { $templates = get_templates(); - $cache->set('templates', serialize($templates), 120); + $cache->set('templates', serialize($templates), 30); } } else @@ -815,7 +876,7 @@ function getCreatureName($killer, $showStatus = false, $extendedInfo = false) if(!$showStatus) return $str.''.$player->getName().''; - $str .= ''.$player->getName().''; + $str .= '' . $player->getName() . ''; if($extendedInfo) { $str .= '
| '.htmlspecialchars($thread_name['post_topic']).' by ' . getPlayerLink($thread_name['name']) . ' | |
| Author | |