diff --git a/.cache/templates/.htaccess b/.cache/templates/.htaccess
new file mode 100644
index 0000000..e67301e
--- /dev/null
+++ b/.cache/templates/.htaccess
@@ -0,0 +1,4 @@
+
+Order Allow,Deny
+Deny from All
+
diff --git a/.cache/templates/wowhead/.htaccess b/.cache/templates/wowhead/.htaccess
new file mode 100644
index 0000000..e67301e
--- /dev/null
+++ b/.cache/templates/wowhead/.htaccess
@@ -0,0 +1,4 @@
+
+Order Allow,Deny
+Deny from All
+
diff --git a/.cache/world/.htaccess b/.cache/world/.htaccess
new file mode 100644
index 0000000..e67301e
--- /dev/null
+++ b/.cache/world/.htaccess
@@ -0,0 +1,4 @@
+
+Order Allow,Deny
+Deny from All
+
diff --git a/.gitignore b/.gitignore
index 447728f..3eabc70 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,9 @@
# List of files and directories not to include in the repository.
+
+# Application configuration
+configs/config.php
+
+# Cache
+.cache/world/*.aww
+.cache/templates/wowhead/%%*.php
+/.cache/
\ No newline at end of file
diff --git a/LICENSE.mdown b/LICENSE.mdown
new file mode 100644
index 0000000..399c9d7
--- /dev/null
+++ b/LICENSE.mdown
@@ -0,0 +1,31 @@
+LEGAL NOTICE
+------------
+
+**mangos-zero-database** is released under the GPL v3.
+
+The terms and conditions of this license are described below:
+
+ Copyright (C) 2011 mangos foundation
+
+ mangos-zero-database is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+
+This file (`LICENSE.mdown`) **must** be apart of any redistributable packages
+made from this software. No licenses should be removed from this software if
+you are making redistributable copies.
+
+
+CONTENT COPYRIGHT
+-----------------
+Game content is Copyright © 2004-2011 Blizzard Entertainment. Other works in
+this repository is of authorship © 2005-2011 *mangos foundation*.
diff --git a/account.php b/account.php
new file mode 100644
index 0000000..1e66e2d
--- /dev/null
+++ b/account.php
@@ -0,0 +1,108 @@
+config_load($conf_file, 'account');
+
+// Создание аккаунта
+if (($_REQUEST['account'] == 'signup') and (isset($_POST['username'])) and (isset($_POST['password'])) and (isset($_POST['c_password'])) and ($UDWBaseconf['register'] == true)) {
+ // Совпадают ли введенные пароли?
+ if ($_POST['password'] != $_POST['c_password']) {
+ $smarty->assign('signup_error', $smarty->get_config_vars('Different_passwords'));
+ } else {
+ // Существует ли уже такой пользователь?
+ if ($rDB->selectCell('SELECT Count(id) FROM ?_account WHERE username=? LIMIT 1', $_POST['username']) == 1) {
+ $smarty->assign('signup_error', $smarty->get_config_vars('Such_user_exists'));
+ } else {
+ // Вроде все нормально, создаем аккаунт
+ $success = $rDB->selectCell('INSERT INTO ?_account(`username`, `sha_pass_hash`, `email`, `joindate`, `expansion`, `last_ip`)
+ VALUES (?, ?, ?, NOW(), ?, ?)', $_POST['username'], create_usersend_pass($_POST['username'], $_POST['password']), (isset($_POST['email'])) ? $_POST['email'] : '', $UDWBaseconf['expansion'], (isset($_SERVER["REMOTE_ADDR"])) ? $_SERVER["REMOTE_ADDR"] : ''
+ );
+ if ($success > 0) {
+ // Все отлично, авторизуем
+ $_REQUEST['account'] = 'signin';
+ } else {
+ // Неизвестная ошибка
+ $smarty->assign('signup_error', $smarty->get_config_vars('Unknow_error_on_account_create'));
+ }
+ }
+ }
+}
+
+if (($_REQUEST['account'] == 'signin') and (isset($_POST['username'])) and (isset($_POST['password']))) {
+ //$usersend_pass = create_usersend_pass($_POST['username'], $_POST['password']);
+ $shapass = $_POST['password'];
+ $user = CheckPwd($_POST['username'], $shapass);
+ if ($user == -1) {
+ del_user_cookie();
+ if (isset($_SESSION['username']))
+ UnSet($_SESSION['username']);
+ $smarty->assign('signin_error', $smarty->get_config_vars('Such_user_doesnt_exists'));
+ } elseif ($user == 0) {
+ del_user_cookie();
+ if (isset($_SESSION['username']))
+ UnSet($_SESSION['username']);
+ $smarty->assign('signin_error', $smarty->get_config_vars('Wrong_password'));
+ } else {
+ // Имя пользователя и пароль совпадают
+ $_SESSION['username'] = $user['name'];
+ $_SESSION['shapass'] = $shapass;
+ $_REQUEST['account'] = 'signin_true';
+ $_POST['remember_me'] = (IsSet($_POST['remember_me'])) ? $_POST['remember_me'] : 'no';
+ if ($_POST['remember_me'] == 'yes') {
+ // Запоминаем пользователя
+ $remember_time = time() + 3000000;
+ SetCookie('remember_me', $_POST['username'] . $shapass, $remember_time);
+ } else {
+ del_user_cookie();
+ }
+ }
+}
+
+
+switch ($_REQUEST['account']):
+ case '':
+ // TODO: Настройки аккаунта (Account Settings)
+ break;
+ case 'signin_false':
+ case 'signin':
+ // Вход в систему
+ $smarty->assign('register', $UDWBaseconf['register']);
+ $smarty->display('signin.tpl');
+ break;
+ case 'signup_false':
+ case 'signup':
+ // You can change to your realm page
+ //header( 'Location: http://your_realm_regpage' );
+ $smarty->display('signup.tpl');
+ break;
+ break;
+ case 'signout':
+ // Выход из пользователя
+ UnSet($user);
+ session_unset();
+ session_destroy();
+ $_SESSION = array();
+ del_user_cookie();
+ case 'signin_true':
+ default:
+ // На предыдущую страницу
+ // Срабатывает при:
+ // 1. $_REQUEST['account'] = 'signout' (выход)
+ // 2. $_REQUEST['account'] = 'signok' (успешная авторизация)
+ // 3. Неизвестное значение $_REQUEST['account']
+ $_REQUEST['next'] = (IsSet($_REQUEST['next'])) ? $_REQUEST['next'] : '';
+ if (($_REQUEST['next'] == '?account=signin') or ($_REQUEST['next'] == '?account=signup'))
+ $_REQUEST['next'] = '';
+ header('Location: ?' . $_REQUEST['next']);
+ break;
+endswitch;
\ No newline at end of file
diff --git a/ajax.php b/ajax.php
new file mode 100644
index 0000000..83cf365
--- /dev/null
+++ b/ajax.php
@@ -0,0 +1,94 @@
+ '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '' => '<\/'));
+}
+
+// Параметры передаваемые скрипту
+@list($what, $id) = explode("=", $_SERVER['QUERY_STRING']);
+$id = intval($id);
+
+$x = '';
+
+switch ($what) {
+ case 'item':
+ if (!$item = load_cache(6, $id)) {
+ require_once('includes/allitems.php');
+ $item = allitemsinfo($id, 1);
+ save_cache(6, $id, $item);
+ }
+ $x .= '$WowheadPower.registerItem(' . $id . ', 0, {';
+ if ($item['name'])
+ $x .= 'name: \'' . str_normalize($item['name']) . '\',';
+ if ($item['quality'])
+ $x .= 'quality: ' . $item['quality'] . ',';
+ if ($item['icon'])
+ $x .= 'icon: \'' . str_normalize($item['icon']) . '\',';
+ if ($item['info'])
+ $x .= 'tooltip: \'' . str_normalize($item['info']) . '\'';
+ $x .= '});';
+ break;
+ case 'spell':
+ if (!$spell = load_cache(14, $id)) {
+ require_once('includes/allspells.php');
+ $spell = allspellsinfo($id, 1);
+ save_cache(14, $id, $spell);
+ }
+ $x .= '$WowheadPower.registerSpell(' . $id . ', 0,{';
+ if ($spell['name'])
+ $x .= 'name: \'' . str_normalize($spell['name']) . '\',';
+ if ($spell['icon'])
+ $x .= 'icon: \'' . str_normalize($spell['icon']) . '\',';
+ if ($spell['info'])
+ $x .= 'tooltip: \'' . str_normalize($spell['info']) . '\'';
+ $x .= '});';
+ break;
+ case 'quest':
+ if (!$quest = load_cache(11, $id)) {
+ require_once('includes/allquests.php');
+ $quest = GetDBQuestInfo($id, QUEST_DATAFLAG_AJAXTOOLTIP);
+ $quest['tooltip'] = GetQuestTooltip($quest);
+ save_cache(11, $id, $quest);
+ }
+ $x .= '$WowheadPower.registerQuest(' . $id . ', 0,{';
+ if ($quest['name'])
+ $x .= 'name: \'' . str_normalize($quest['name']) . '\',';
+ if ($quest['tooltip'])
+ $x .= 'tooltip: \'' . str_normalize($quest['tooltip']) . '\'';
+ $x .= '});';
+ break;
+ default:
+ break;
+}
+
+echo $x;
\ No newline at end of file
diff --git a/comment.php b/comment.php
new file mode 100644
index 0000000..bff9b0b
--- /dev/null
+++ b/comment.php
@@ -0,0 +1,73 @@
+query('INSERT
+ INTO ?_aowow_comments(`type`, `typeid`, `userid`, `commentbody`, `post_date`{, ?#})
+ VALUES (?d, ?d, ?d, ?, NOW(){, ?d})', (empty($_POST['replyto']) ? DBSIMPLE_SKIP : 'replyto'), $_GET["type"], $_GET["typeid"], (empty($_SESSION['userid']) ? 0 : $_SESSION['userid']), stripslashes($_POST['commentbody']), (empty($_POST['replyto']) ? DBSIMPLE_SKIP : $_POST['replyto'])
+ );
+ if (empty($_POST['replyto']))
+ $DB->query('UPDATE ?_aowow_comments SET `replyto`=?d WHERE `id`=?d LIMIT 1', $newid, $newid);
+ echo '';
+ echo '';
+ break;
+ case 'delete':
+ // Удаление комментарий (Ajax)
+ // Номер комментария: $_GET['id']
+ // Имя пользователя, удаляющего комментарий: $_GET['username']
+ $DB->query('DELETE FROM ?_aowow_comments WHERE `id`=?d {AND `userid`=?d} LIMIT 1', $_GET['id'], ($_SESSION['roles'] > 1) ? DBSIMPLE_SKIP : $_SESSION['userid']
+ );
+ break;
+ case 'edit':
+ // Редактирование комментария
+ // Номер комментария: $_GET['id']
+ // Новое содержание комментария: $_POST['body']
+ // Номер пользователя: $_SESSION['userid']
+ if (IsSet($_POST['body']))
+ $DB->query('UPDATE ?_aowow_comments SET `commentbody`=?, `edit_userid`=?, `edit_date`=NOW() WHERE `id`=?d {AND `userid`=?d} LIMIT 1', stripslashes($_POST['body']), $_SESSION['userid'], $_GET['id'], ($_SESSION['roles'] > 1) ? DBSIMPLE_SKIP : $_SESSION['userid']
+ );
+ echo $_POST['body'];
+ break;
+ case 'rate':
+ /*
+ * Установка собственоого рейтинга (модераторы и т.п.)
+ * Номер комментария: $_GET['id']
+ * Новое значение рейтинга: $_GET['rating']
+ * Номер пользователя: $_SESSION['userid']
+ */
+ // Проверка на хоть какое то значение рейтинга, и на то, что пользователь за этот коммент не голосовал
+ if (IsSet($_GET['rating']) and !($DB->selectCell('SELECT `commentid` FROM ?_aowow_comments_rates WHERE `userid`=?d AND `commentid`=?d LIMIT 1', $_SESSION['userid'], $_GET['id'])))
+ $DB->query('INSERT INTO ?_aowow_comments_rates(`commentid`, `userid`, `rate`) VALUES (?d, ?d, ?d)', $_GET['id'], $_SESSION['userid'], $_GET['rating']);
+ break;
+ case 'undelete':
+ // Восстановление комментария
+ // Номер комментария: $_GET['id']
+ // Имя пользователя, удаляющего комментарий: $_GET['username']
+ default:
+ break;
+endswitch;
\ No newline at end of file
diff --git a/configs/.htaccess b/configs/.htaccess
new file mode 100644
index 0000000..e67301e
--- /dev/null
+++ b/configs/.htaccess
@@ -0,0 +1,4 @@
+
+Order Allow,Deny
+Deny from All
+
diff --git a/configs/config.php.in b/configs/config.php.in
new file mode 100644
index 0000000..bd1da0b
--- /dev/null
+++ b/configs/config.php.in
@@ -0,0 +1,34 @@
+config_load($conf_file, 'faction');
+
+// Номер фракции
+$id = $podrazdel;
+
+if (!$faction = load_cache(18, intval($id))) {
+ unset($faction);
+
+ // Подключаемся к ДБ:
+ global $DB;
+
+ $row = $DB->selectRow('
+ SELECT factionID, name_loc' . $_SESSION['locale'] . ', description1_loc' . $_SESSION['locale'] . ', description2_loc' . $_SESSION['locale'] . ', team, side
+ FROM ?_aowow_factions
+ WHERE factionID=?d
+ LIMIT 1
+ ', $id
+ );
+ if ($row) {
+ $faction = array();
+ // Номер фракции
+ $faction['entry'] = $row['factionID'];
+ // Название фракции
+ $faction['name'] = $row['name_loc' . $_SESSION['locale']];
+ // Описание фракции, из клиента:
+ $faction['description1'] = $row['description1_loc' . $_SESSION['locale']];
+ // Описание фракции, c wowwiki.com, находится в таблице factions.sql:
+ $faction['description2'] = $row['description2_loc' . $_SESSION['locale']];
+ // Команда/Группа фракции
+ if ($row['team'] != 0)
+ $faction['group'] = $DB->selectCell('SELECT name_loc' . $_SESSION['locale'] . ' FROM ?_aowow_factions WHERE factionID=?d LIMIT 1', $row['team']);
+ // Альянс(1)/Орда(2)
+ if ($row['side'] != 0)
+ $faction['side'] = $row['side'];
+
+ // Итемы с requiredreputationfaction
+ $item_rows = $DB->select('
+ SELECT ?#, entry
+ FROM ?_item_template i, ?_aowow_icons a
+ WHERE
+ i.RequiredReputationFaction=?d
+ AND a.id=i.displayid
+ ', $item_cols[2], $id
+ );
+ if ($item_rows) {
+ $faction['items'] = array();
+ foreach ($item_rows as $i => $row)
+ $faction['items'][] = iteminfo2($row, 0);
+ unset($faction['items']);
+ }
+
+ // Персонажи, состоящие во фракции
+ $creature_rows = $DB->select('
+ SELECT ?#, entry
+ FROM ?_creature_template, ?_aowow_factiontemplate
+ WHERE
+ faction_A IN (SELECT factiontemplateID FROM ?_aowow_factiontemplate WHERE factionID=?d)
+ AND factiontemplateID=faction_A
+ ', $npc_cols[0], $id
+ );
+ if ($creature_rows) {
+ $faction['creatures'] = array();
+ foreach ($creature_rows as $i => $row)
+ $faction['creatures'][] = creatureinfo2($row);
+ unset($creature_rows);
+ }
+
+ // Квесты для этой фракции
+ $quests_rows = $DB->select('
+ SELECT ?#
+ FROM ?_quest_template
+ WHERE
+ RewRepFaction1=?d
+ OR RewRepFaction2=?d
+ OR RewRepFaction3=?d
+ OR RewRepFaction4=?d
+ ', $quest_cols[2], $id, $id, $id, $id
+ );
+ if ($quests_rows) {
+ $faction['quests'] = array();
+ foreach ($quests_rows as $i => $row)
+ $faction['quests'][] = GetQuestInfo($row, 0xFFFFFF);
+ unset($quests_rows);
+ }
+
+ // Faction cache
+ save_cache(18, $faction['entry'], $faction);
+ }
+}
+
+$page = array(
+ 'Mapper' => false,
+ 'Book' => false,
+ 'Title' => $faction['name'] . ' - ' . $smarty->get_config_vars('Factions'),
+ 'tab' => 0,
+ 'type' => 8,
+ 'typeid' => $faction['entry'],
+ 'path' => '[0, 7, 0]'
+);
+$smarty->assign('page', $page);
+
+// Комментарии
+$smarty->assign('comments', getcomments($page['type'], $page['typeid']));
+
+// Данные о квесте
+$smarty->assign('faction', $faction);
+// Если хоть одна информация о вещи найдена - передаём массив с информацией о вещях шаблонизатору
+if (isset($allitems))
+ $smarty->assign('allitems', $allitems);
+/*
+ if (isset($npcs))
+ $smarty->assign('npcs',$npcs);
+ if (isset($quests))
+ $smarty->assign('quests',$quests);
+ if (isset($items))
+ $smarty->assign('items',$items);
+ */
+// Количество MySQL запросов
+$smarty->assign('mysql', $DB->getStatistics());
+// Загружаем страницу
+$smarty->display('faction.tpl');
\ No newline at end of file
diff --git a/factions.php b/factions.php
new file mode 100644
index 0000000..067b679
--- /dev/null
+++ b/factions.php
@@ -0,0 +1,56 @@
+config_load($conf_file, 'factions');
+
+global $DB;
+
+$rows = $DB->select('
+ SELECT factionID, team, name_loc' . $_SESSION['locale'] . ' as name, side
+ FROM ?_aowow_factions
+ WHERE
+ reputationListID!=-1
+ '
+);
+if (!$factions = load_cache(19, 'x')) {
+ unset($factions);
+
+ $factions = array();
+ foreach ($rows as $numRow => $row) {
+ $factions[$numRow] = array();
+ $factions[$numRow]['entry'] = $row['factionID'];
+ if ($row['team'] != 0)
+ $factions[$numRow]['group'] = $DB->selectCell('SELECT name_loc' . $_SESSION['locale'] . ' FROM ?_aowow_factions WHERE factionID=? LIMIT 1', $row['team']);
+ if ($row['side'])
+ $factions[$numRow]['side'] = $row['side'];
+ $factions[$numRow]['name'] = $row['name'];
+ }
+ save_cache(19, 'x', $factions);
+}
+
+global $page;
+$page = array(
+ 'Mapper' => false,
+ 'Book' => false,
+ 'Title' => $smarty->get_config_vars('Factions'),
+ 'tab' => 0,
+ 'type' => 0,
+ 'typeid' => 0,
+ 'path' => '[0, 7]'
+);
+$smarty->assign('page', $page);
+
+// Статистика выполнения mysql запросов
+$smarty->assign('mysql', $DB->getStatistics());
+$smarty->assign('factions', $factions);
+// Загружаем страницу
+$smarty->display('factions.tpl');
\ No newline at end of file
diff --git a/forum.php b/forum.php
new file mode 100644
index 0000000..621039a
--- /dev/null
+++ b/forum.php
@@ -0,0 +1,41 @@
+..