| 1 |
<?php |
| 2 |
/** |
| 3 |
* File functions: |
| 4 |
* City menu |
| 5 |
* |
| 6 |
* @name : city.php |
| 7 |
* @copyright : (C) Orodlin |
| 8 |
* @author : mzah <s.paweska@gmail.com> |
| 9 |
* @author : eyescream <tduda@users.sourceforge.net> |
| 10 |
* @author : Marek Stasiak <l3thal2@gmail.com> |
| 11 |
* @version : preAlfa |
| 12 |
* @since : 30.09.07 |
| 13 |
* |
| 14 |
*/ |
| 15 |
|
| 16 |
// Published under GNU GPL 2 or later. See /install/README file for details. |
| 17 |
// $Id$ |
| 18 |
|
| 19 |
$title = 'Altara'; |
| 20 |
require_once('includes/head.php'); |
| 21 |
|
| 22 |
/** |
| 23 |
* Get the localization for game |
| 24 |
*/ |
| 25 |
|
| 26 |
require_once('languages/'.$player -> lang.'/city.php'); |
| 27 |
|
| 28 |
if($player -> location != 'Altara' && $player -> location != 'Ardulith') |
| 29 |
{ |
| 30 |
error (NO_CITY, RET_LOC); |
| 31 |
} |
| 32 |
|
| 33 |
function city() |
| 34 |
{ |
| 35 |
global $db, $player, $smarty, $arrTitles, $arrNames; |
| 36 |
$objPoll = $db -> GetRow('SELECT `value` FROM `settings` WHERE `setting`=\'poll\''); |
| 37 |
if ($player -> location == 'Altara') |
| 38 |
{ |
| 39 |
if ($objPoll['value'] == 'Y' && $player -> poll == 'N') |
| 40 |
{ |
| 41 |
$arrNames[5][3] = '<b>N</b> '.$arrNames[5][3]; |
| 42 |
} |
| 43 |
$arrFiles = array(array('grid.php', 'news.php', 'chat.php', 'poorhouse.php', 'landfill.php'), |
| 44 |
array('house.php', 'tribes.php','newspaper.php', 'wieza.php', 'alchemik.php', 'temple.php'), |
| 45 |
array('battle.php', 'train.php', 'jail.php', 'warehouse.php'), |
| 46 |
array('monuments.php', 'memberlist.php', 'hof.php','tower.php', 'reputation.php'), |
| 47 |
array('weapons.php','armor.php', 'bows.php', 'msklep.php', 'jewellershop.php', 'market.php'), |
| 48 |
array('updates.php', 'library.php', 'court.php', 'polls.php', 'stafflist.php'), |
| 49 |
array('travel.php'), |
| 50 |
array('outposts.php', 'farm.php', 'core.php', 'lumbermill.php')); |
| 51 |
} |
| 52 |
elseif ($player -> location == 'Ardulith') |
| 53 |
{ |
| 54 |
$arrFiles = array(array('smelter.php', 'kowal.php', 'mines.php', 'maze.php', 'jeweller.php', 'landfill.php'), |
| 55 |
array('house.php', 'tribes.php', 'poorhouse.php', 'news.php', 'chat.php'), |
| 56 |
array('market.php', 'warehouse.php', 'armor.php', 'weapons.php', 'msklep.php', 'skarbiec.php', 'bows.php'), |
| 57 |
array('updates.php','temple.php', 'newspaper.php', 'library.php', 'court.php', 'monuments.php', 'memberlist.php', 'tower.php', 'polls.php', 'stafflist.php'), |
| 58 |
array('battle.php', 'jail.php', 'train.php', 'core.php'), |
| 59 |
array('outposts.php', 'farm.php', 'travel.php', 'city.php?step=gory')); |
| 60 |
} |
| 61 |
$arrNews = $db -> GetRow('SELECT `id`, `autor`, `tytul`, `tresc` FROM `ogloszenia` ORDER BY `id` DESC LIMIT 1'); |
| 62 |
$smarty -> assign_by_ref('News', $arrNews); |
| 63 |
|
| 64 |
$smarty -> assign(array('Titles' => $arrTitles, |
| 65 |
'Files' => $arrFiles, |
| 66 |
'Names' => $arrNames)); |
| 67 |
} |
| 68 |
|
| 69 |
function nubiaquest() |
| 70 |
{ |
| 71 |
global $db, $player, $smarty, $objItem; |
| 72 |
$intItem = 1; |
| 73 |
if (isset($_GET['step'])) |
| 74 |
{ |
| 75 |
if ($_GET['step'] == 'give') |
| 76 |
{ |
| 77 |
$smarty -> assign('Staffquest', STAFF_QUEST1); |
| 78 |
$db -> Execute('DELETE FROM `equipment` WHERE `id`='.$objItem -> fields['id']); |
| 79 |
$db -> Execute('UPDATE `players` SET `credits`=`credits`+100000 WHERE `id`='.$player -> id); |
| 80 |
require_once('includes/checkexp.php'); |
| 81 |
checkexp($player -> exp, 10000, $player -> level, $player -> race, $player -> user, $player -> id, 0, 0, $player -> id, '', 0); |
| 82 |
} |
| 83 |
elseif ($_GET['step'] == 'take') |
| 84 |
{ |
| 85 |
$smarty -> assign('Staffquest', STAFF_QUEST2); |
| 86 |
$db -> Execute('DELETE FROM `equipment` WHERE `id`='.$objItem -> fields['id']); |
| 87 |
$db -> Execute('UPDATE `players` SET `credits`=`credits`+10000 WHERE `id`='.$player -> id); |
| 88 |
} |
| 89 |
} |
| 90 |
return $intItem; |
| 91 |
} |
| 92 |
|
| 93 |
function ogloszenie() |
| 94 |
{ |
| 95 |
global $player, $smarty; |
| 96 |
$smarty -> assign('Price', $player->level*500); |
| 97 |
} |
| 98 |
|
| 99 |
function dodaj() |
| 100 |
{ |
| 101 |
global $player, $smarty, $db; |
| 102 |
$koszt=$player -> level * 500; |
| 103 |
if (empty($_POST['tytul']) || empty($_POST['tresc'])) |
| 104 |
{ |
| 105 |
error(ERR_FIELDS); |
| 106 |
} |
| 107 |
elseif($player -> credits < $koszt) |
| 108 |
{ |
| 109 |
error(ERR_GOLD); |
| 110 |
} |
| 111 |
$db -> Execute('UPDATE `players` SET `credits`=`credits`-'.(int)$koszt.' WHERE `id`='.$player -> id); |
| 112 |
$_POST['tresc'] = nl2br(htmlspecialchars($_POST['tresc'])); |
| 113 |
$_POST['tytul'] = htmlspecialchars($_POST['tytul']); |
| 114 |
$db -> Execute('INSERT INTO `ogloszenia` (`autor`, `tytul`, `tresc`) VALUES(\'('.$player->user.' ID:'.$player->id.')\',\''.$_POST['tytul'].'\',\''.$_POST['tresc'].'\')'); |
| 115 |
error (ERR_ADDED); |
| 116 |
} |
| 117 |
|
| 118 |
function last10() |
| 119 |
{ |
| 120 |
global $smarty, $db; |
| 121 |
$old = $db ->setFetchMode(ADODB_FETCH_NUM); |
| 122 |
$arrNews = $db -> GetAll('SELECT `id`, `autor`, `tytul`, `tresc` FROM `ogloszenia` ORDER BY `id` DESC LIMIT 10'); |
| 123 |
$smarty -> assign_by_ref('ArrNews', $arrNews); |
| 124 |
$db ->setFetchMode($old); |
| 125 |
} |
| 126 |
|
| 127 |
function del() |
| 128 |
{ |
| 129 |
global $smarty, $player, $db; |
| 130 |
if ($player -> rank != 'Admin' && $player -> rank != 'Staff') |
| 131 |
{ |
| 132 |
error(PERMISSION); |
| 133 |
} |
| 134 |
if (!isset($_GET['del'])) |
| 135 |
{ |
| 136 |
error(NO_ANN); |
| 137 |
} |
| 138 |
$remid = intval($_GET['del']); |
| 139 |
$db -> Execute('DELETE FROM `ogloszenia` WHERE `id`='.$remid.''); |
| 140 |
error(DELETED); |
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* Initialization of variable |
| 145 |
*/ |
| 146 |
if (!isset($_GET['step'])) |
| 147 |
{ |
| 148 |
$_GET['step'] = ''; |
| 149 |
} |
| 150 |
|
| 151 |
/** |
| 152 |
* City menu |
| 153 |
*/ |
| 154 |
$intItem = 0; |
| 155 |
if ($player -> location == 'Altara') |
| 156 |
{ |
| 157 |
$objItem = $db -> GetRow('SELECT `id` FROM `equipment` WHERE `name`=\''.ITEM.'\' AND `owner`='.$player -> id); |
| 158 |
if ($objItem == NULL && $_GET['step']!='ogloszenie' && $_GET['step']!='dodaj' && $_GET['step']!='list') |
| 159 |
{ |
| 160 |
city(); |
| 161 |
} elseif (isset($_GET['del'])) |
| 162 |
{ |
| 163 |
del(); |
| 164 |
} elseif ($_GET['step']=='list') |
| 165 |
{ |
| 166 |
city(); |
| 167 |
last10(); |
| 168 |
} elseif ($_GET['step']=='ogloszenie') { |
| 169 |
ogloszenie(); |
| 170 |
} elseif ($_GET['step']=='dodaj') { |
| 171 |
dodaj(); |
| 172 |
} else { |
| 173 |
nubiaquest(); |
| 174 |
} |
| 175 |
if ($objItem != NULL) $objItem -> Close(); |
| 176 |
} elseif ($player -> location == 'Ardulith') { |
| 177 |
if ($_GET['step']=='') { |
| 178 |
city(); |
| 179 |
} elseif (isset($_GET['del'])) |
| 180 |
{ |
| 181 |
del(); |
| 182 |
} elseif ($_GET['step']=='list') { |
| 183 |
city(); |
| 184 |
last10(); |
| 185 |
} elseif ($_GET['step']=='ogloszenie') { |
| 186 |
ogloszenie(); |
| 187 |
} elseif ($_GET['step']=='dodaj') { |
| 188 |
dodaj(); |
| 189 |
} else { |
| 190 |
$db -> Execute('UPDATE `players` SET `miejsce`=\'Góry\' WHERE `id`='.$player -> id); |
| 191 |
} |
| 192 |
} |
| 193 |
|
| 194 |
/** |
| 195 |
* Assign variables to template and display page |
| 196 |
*/ |
| 197 |
$smarty -> assign(array('Item' => $intItem, |
| 198 |
'Step' => $_GET['step'], |
| 199 |
'Location' => $player -> location, |
| 200 |
'Rank' => $player -> rank)); |
| 201 |
$smarty -> display ('city.tpl'); |
| 202 |
|
| 203 |
require_once('includes/foot.php'); |
| 204 |
?> |