diff --git a/.htaccess.dist b/.htaccess.dist
index faeae507..c932ecdc 100644
--- a/.htaccess.dist
+++ b/.htaccess.dist
@@ -1,33 +1,7 @@
Options -Indexes -MultiViews
RewriteEngine On
-#RewriteBase /
-# Page parser
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
-RewriteRule ^([A-Za-z0-9-_+']+)\.png/?$ tools/signature/index.php?name=$1 [L]
-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/thread/([0-9]+)/([0-9]+)$ index.php?subtopic=forum&action=show_thread&id=$1&page=$2
-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
-RewriteRule ^account/logout$ index.php?subtopic=accountmanagement&action=logout
-RewriteRule ^news/archive/([0-9]+)$ index.php?subtopic=newsarchive&id=$1
-RewriteRule ^news/archive$ index.php?subtopic=newsarchive
-RewriteRule ^highscores/([A-Za-z0-9-_]+)/([A-Za-z0-9-_]+)?$ index.php?subtopic=highscores&list=$1&vocation=$2
-RewriteRule ^highscores/([A-Za-z0-9-_']+)$ index.php?subtopic=highscores&list=$1
-RewriteRule ^polls/([0-9]+)$ index.php?subtopic=polls&id=$1
-RewriteRule ^admin/$ admin/index.php
-RewriteRule ^install/$ install/index.php
-
-# temp solution >.>
-RewriteCond %{REQUEST_FILENAME} !-f
-RewriteCond %{REQUEST_FILENAME} !-d
-RewriteRule ^([A-Za-z0-9-_]+)/?$ index.php?p=$1 [L]
-RewriteRule ^([A-Za-z0-9-_]+)/([A-Za-z0-9-_]+)?$ index.php?p=$1&action=$2 [L]
\ No newline at end of file
+RewriteRule ^.*$ index.php [L]
\ No newline at end of file
diff --git a/index.php b/index.php
index 8e70e347..7aab0826 100644
--- a/index.php
+++ b/index.php
@@ -39,8 +39,81 @@ if(file_exists(BASE . 'install') && (!isset($config['installed']) || !$config['i
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!');
}
+$uri = str_replace(BASE_DIR . '/', '', $_SERVER['REQUEST_URI']);
+$uri = str_replace('index.php/', '', $uri);
+$uri = str_replace('?', '', $uri);
+
+if(empty($uri)) {
+ $_REQUEST['p'] = 'news';
+}
+else if(file_exists(SYSTEM . 'pages/' . $uri . '.php')) {
+ $_REQUEST['p'] = $uri;
+}
+else {
+ $rules = array(
+ '/^account\/manage\/?$/' => array('subtopic' => 'accountmanagement'),
+ '/^account\/create\/?$/' => array('subtopic' => 'createaccount'),
+ '/^account\/lost\/?$/' => array('subtopic' => 'lostaccount'),
+ '/^account\/logout\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'logout'),
+ '/^account\/password\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changepassword'),
+ '/^account\/register\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'registeraccount'),
+ '/^account\/register\/new\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'registernew'),
+ '/^account\/email\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changeemail'),
+ '/^account\/info\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changeinfo'),
+ '/^account\/character\/create\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'createcharacter'),
+ '/^account\/character\/name\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changename'),
+ '/^account\/character\/sex\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changesex'),
+ '/^account\/character\/delete\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'deletecharacter'),
+ '/^account\/character\/comment\/[A-Za-z]+\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changecomment', 'name' => '$3'),
+ '/^account\/character\/comment\/?$/' => array('subtopic' => 'accountmanagement', 'action' => 'changecomment'),
+ '/^characters\/[A-Za-z0-9-_%+\']+$/' => array('subtopic' => 'characters', 'name' => '$1'),
+ '/^news\/archive\/?$/' => array('subtopic' => 'newsarchive'),
+ '/^news\/archive\/[0-9]+\/?$/' => array('subtopic' => 'newsarchive', 'id' => '$2'),
+ '/^guilds\/[A-Za-z0-9-_%+\']+$/' => array('subtopic' => 'guilds', 'action' => 'show', 'guild' => '$1'),
+ '/^forum\/board\/[0-9]+\/?$/' => array('subtopic' => 'forum', 'action' => 'show_board', 'id' => '$2'),
+ '/^forum\/board\/[0-9]+\/[0-9]+\/?$/' => array('subtopic' => 'forum', 'action' => 'show_board', 'id' => '$2', 'page' => '$3'),
+ '/^forum\/thread\/[0-9]+\/?$/' => array('subtopic' => 'forum', 'action' => 'show_thread', 'id' => '$2'),
+ '/^forum\/thread\/[0-9]+\/[0-9]+\/?$/' => array('subtopic' => 'forum', 'action' => 'show_thread', 'id' => '$2', 'page' => '$3'),
+ '/^gifts\/history\/?$/' => array('subtopic' => 'gifts', 'action' => 'show_history'),
+ '/^highscores\/[A-Za-z0-9-_]+\/[A-Za-z0-9-_]+\/?$/' => array('subtopic' => 'highscores', 'list' => '$1', 'vocation' => '$2'),
+ '/^highscores\/[A-Za-z0-9-_\']+\/?$/' => array('subtopic' => 'highscores', 'list' => '$1'),
+ '/^polls\/[0-9]+\/?$/' => array('subtopic' => 'polls', 'id' => '$1')
+ );
+
+ if (preg_match("/^[A-Za-z0-9-_%\'+]+\.png$/i", $uri)) {
+ $tmp = explode('.', $uri);
+ $_REQUEST['name'] = urldecode($tmp[0]);
+
+ chdir(TOOLS . 'signature');
+ include('index.php');
+ exit();
+ }
+
+ $found = false;
+ foreach($rules as $rule => $redirect) {
+ if (preg_match($rule, $uri)) {
+ $tmp = explode('/', $uri);
+ foreach($redirect as $key => $value) {
+ if(strpos($value, '$') !== false) {
+ $value = str_replace('$' . $value[1], $tmp[$value[1]], $value);
+ }
+
+ $_REQUEST[$key] = $value;
+ $_GET[$key] = $value;
+ }
+
+ $found = true;
+ break;
+ }
+ }
+
+ if(!$found) {
+ $_REQUEST['p'] = '404';
+ }
+}
+
// define page visited, so it can be used within events system
-$page = isset($_REQUEST['subtopic']) ? $_REQUEST['subtopic'] : (isset($_GET['p']) ? $_GET['p'] : '');
+$page = isset($_REQUEST['subtopic']) ? $_REQUEST['subtopic'] : (isset($_REQUEST['p']) ? $_REQUEST['p'] : '');
if(empty($page) || preg_match('/[^A-z0-9_\-]/', $page))
$page = 'news';
@@ -156,7 +229,7 @@ if($config['backward_support']) {
$config['site']['screenshot_page'] = true;
if($config['forum'] != '')
- $config['forum_link'] = (strtolower($config['forum']) == 'site' ? internalLayoutLink('forum') : $config['forum']);
+ $config['forum_link'] = (strtolower($config['forum']) == 'site' ? getLink('forum') : $config['forum']);
foreach($status as $key => $value)
$config['status']['serverStatus_' . $key] = $value;
diff --git a/system/functions.php b/system/functions.php
index 915e55fd..3b3a920c 100644
--- a/system/functions.php
+++ b/system/functions.php
@@ -38,46 +38,27 @@ function generateLink($url, $name, $blank = false) {
return '' . $name . '';
}
-function getLink($page, $name, $blank = false) {
- return generateLink(getPageLink($page), $name, $blank);
+function getFullLink($page, $name, $blank = false) {
+ return generateLink(getLink($page), $name, $blank);
}
-function getPageLink($page, $action = null)
+function getLink($page, $action = null)
{
global $config;
-
- // TODO: tibiacom template is not working correctly with this
- if($config['friendly_urls'])
- return BASE_URL . $page . ($action ? '/' . $action : '');
-
- return BASE_URL . '?subtopic=' . $page . ($action ? '&action=' . $action : '');
+ return BASE_URL . ($config['friendly_urls'] ? '' : '?') . $page . ($action ? '/' . $action : '');
}
-function internalLayoutLink($page, $action = null) {return getPageLink($page, $action);}
+function internalLayoutLink($page, $action = null) {return getLink($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;
+ return BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'forum/thread/' . (int)$thread_id . (isset($page) ? '/' . $page : '');
}
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;
+ return BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'forum/board/' . (int)$board_id . (isset($page) ? '/' . $page : '');
}
function getPlayerLink($name, $generate = true)
@@ -91,12 +72,8 @@ function getPlayerLink($name, $generate = true)
if($player->isLoaded())
$name = $player->getName();
}
-
- $url = '';
- if($config['friendly_urls'])
- $url = BASE_URL . 'characters/' . urlencode($name);
- else
- $url = BASE_URL . '?subtopic=characters&name=' . urlencode($name);
+
+ $url = BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'characters/' . urlencode($name);
if(!$generate) return $url;
return generateLink($url, $name);
@@ -115,13 +92,9 @@ function getHouseLink($name, $generate = true)
if($house->rowCount() > 0)
$name = $house->fetchColumn();
}
-
- $url = '';
- if($config['friendly_urls'])
- $url = BASE_URL . 'houses/' . urlencode($name);
- else
- $url = BASE_URL . '?subtopic=houses&page=view&house=' . urlencode($name);
-
+
+ $url = BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'houses/' . urlencode($name);
+
if(!$generate) return $url;
return generateLink($url, $name);
}
@@ -138,11 +111,7 @@ function getGuildLink($name, $generate = true)
$name = $guild->fetchColumn();
}
- $url = '';
- if($config['friendly_urls'])
- $url = BASE_URL . 'guilds/' . urlencode($name);
- else
- $url = BASE_URL . '?subtopic=guilds&action=show&guild=' . urlencode($name);
+ $url = BASE_URL . ($config['friendly_urls'] ? '' : '?') . 'guilds/' . urlencode($name);
if(!$generate) return $url;
return generateLink($url, $name);
diff --git a/system/init.php b/system/init.php
index 8f15c91f..14db405f 100644
--- a/system/init.php
+++ b/system/init.php
@@ -42,6 +42,15 @@ $function = new Twig_SimpleFunction('getStyle', function ($i) {
});
$twig->addFunction($function);
+$function = new Twig_SimpleFunction('getLink', function ($s) {
+ global $config;
+ if($config['friendly_urls'])
+ return $s;
+
+ return '?' . $s;
+});
+$twig->addFunction($function);
+
// trim values we receive
if(isset($_POST))
{
diff --git a/system/login.php b/system/login.php
index b3d28540..d5375e6b 100644
--- a/system/login.php
+++ b/system/login.php
@@ -113,6 +113,9 @@ else
}
}
}
+ else {
+ $errors[] = 'Please enter your account ' . (USE_ACCOUNT_NAME ? 'name' : 'password') . ' and password.';
+ }
}
// stay-logged with sessions
diff --git a/system/pages/accountmanagement.php b/system/pages/accountmanagement.php
index a795b0d8..8511d4c4 100644
--- a/system/pages/accountmanagement.php
+++ b/system/pages/accountmanagement.php
@@ -17,7 +17,6 @@ if($config['account_country'])
$groups = new OTS_Groups_List();
-$errors = array();
$show_form = true;
$config_salt_enabled = fieldExist('salt', 'accounts');
if(!$logged)
@@ -29,7 +28,7 @@ if(!$logged)
{
if(!empty($errors))
echo $twig->render('error_box.html.twig', array('errors' => $errors));
-
+
echo $twig->render('account.login.html.twig', array(
'redirect' => isset($_REQUEST['redirect']) ? $_REQUEST['redirect'] : null,
'account' => USE_ACCOUNT_NAME ? 'Name' : 'Number',
@@ -39,6 +38,8 @@ if(!$logged)
}
}
+$errors = array();
+
if(isset($_REQUEST['redirect']))
{
$redirect = urldecode($_REQUEST['redirect']);
@@ -63,7 +64,7 @@ if(!$logged)
else
{
if($config['generate_new_reckey'] && $config['mail_enabled'])
- $account_registered = 'Yes ( Buy new Recovery Key )';
+ $account_registered = 'Yes ( Buy new Recovery Key )';
else
$account_registered = 'Yes';
}
@@ -477,7 +478,7 @@ if($action == "changeemail") {
}
//############## GENERATE NEW RECOVERY KEY ###########
- if($action == "newreckey")
+ if($action == "registernew")
{
if(isset($_POST['reg_password']))
$reg_password = encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $_POST['reg_password']);
@@ -542,45 +543,52 @@ if($action == "changeemail") {
//###### CHANGE CHARACTER COMMENT ######
if($action == "changecomment") {
- $player_name = stripslashes($_REQUEST['name']);
+ $player_name = isset($_REQUEST['name']) ? stripslashes($_REQUEST['name']) : null;
$new_comment = isset($_POST['comment']) ? htmlspecialchars(stripslashes(substr($_POST['comment'],0,2000))) : NULL;
$new_hideacc = isset($_POST['accountvisible']) ? (int)$_POST['accountvisible'] : NULL;
- if(check_name($player_name)) {
- $player = $ots->createObject('Player');
- $player->find($player_name);
- if($player->isLoaded()) {
- $player_account = $player->getAccount();
- if($account_logged->getId() == $player_account->getId()) {
- if(isset($_POST['changecommentsave']) && $_POST['changecommentsave'] == 1) {
- $player->setCustomField("hidden", $new_hideacc);
- $player->setCustomField("comment", $new_comment);
- $account_logged->logAction('Changed comment for character ' . $player->getName() . '.');
- echo $twig->render('success.html.twig', array(
- 'title' => 'Character Information Changed',
- 'description' => 'The character information has been changed.'
- ));
- }
- else
- {
- echo $twig->render('account.change_comment.html.twig', array(
- 'player' => $player,
- 'player_name' => $player_name
- ));
+
+ if($player_name != null) {
+ if (check_name($player_name)) {
+ $player = $ots->createObject('Player');
+ $player->find($player_name);
+ if ($player->isLoaded()) {
+ $player_account = $player->getAccount();
+ if ($account_logged->getId() == $player_account->getId()) {
+ if (isset($_POST['changecommentsave']) && $_POST['changecommentsave'] == 1) {
+ $player->setCustomField("hidden", $new_hideacc);
+ $player->setCustomField("comment", $new_comment);
+ $account_logged->logAction('Changed comment for character ' . $player->getName() . '.');
+ echo $twig->render('success.html.twig', array(
+ 'title' => 'Character Information Changed',
+ 'description' => 'The character information has been changed.'
+ ));
+ $show_form = false;
+ }
+ } else {
+ $errors[] = 'Error. Character ' . $player_name . ' is not on your account.';
}
+ } else {
+ $errors[] = "Error. Character with this name doesn't exist.";
}
- else
- {
- echo "Error. Character ".$player_name." is not on your account.";
- }
- }
- else
- {
- echo "Error. Character with this name doesn't exist.";
+ } else {
+ $errors[] = 'Error. Name contain illegal characters.';
}
}
- else
- {
- echo "Error. Name contain illegal characters.";
+ else {
+ $errors[] = 'Please enter character name.';
+ }
+
+ if($show_form) {
+ if(!empty($errors)) {
+ echo $twig->render('error_box.html.twig', array('errors' => $errors));
+ }
+
+ if(isset($player)) {
+ echo $twig->render('account.change_comment.html.twig', array(
+ 'player' => $player,
+ 'player_name' => $player_name
+ ));
+ }
}
}
diff --git a/system/pages/admin/pages.php b/system/pages/admin/pages.php
index 4d29408f..c41c62a6 100644
--- a/system/pages/admin/pages.php
+++ b/system/pages/admin/pages.php
@@ -181,7 +181,7 @@ if(!empty($action))
'.htmlspecialchars($thread_name['post_topic']).' by ' . getPlayerLink($thread_name['name']) . ' | |
Author | '.$guild->getName().' '.$description.''; if(admin()) echo ' Delete this guild (for ADMIN only!)'; - echo ' |