| 1 |
<?php |
| 2 |
/** |
| 3 |
* Funkcje pliku: |
| 4 |
* Bank - deposit gold and give item to another player |
| 5 |
* |
| 6 |
* @name : bank.php |
| 7 |
* @copyright : (C) 2004,2005,2006,2007 Vallheru Team based on Gamers-Fusion ver 2.5 |
| 8 |
* @author : thindil <thindil@users.sourceforge.net> |
| 9 |
* @author : yeskov <yeskov@users.sourceforge.net> |
| 10 |
* @author : eyescream <tduda@users.sourceforge.net> |
| 11 |
* @version : 1.4 |
| 12 |
* @since : 08.10.2007 |
| 13 |
* |
| 14 |
*/ |
| 15 |
|
| 16 |
// |
| 17 |
// |
| 18 |
// This program is free software; you can redistribute it and/or modify |
| 19 |
// it under the terms of the GNU General Public License as published by |
| 20 |
// the Free Software Foundation; either version 2 of the License, or |
| 21 |
// (at your option) any later version. |
| 22 |
// |
| 23 |
// This program is distributed in the hope that it will be useful, |
| 24 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 |
// GNU General Public License for more details. |
| 27 |
// |
| 28 |
// You should have received a copy of the GNU General Public License |
| 29 |
// along with this program; if not, write to the Free Software |
| 30 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 31 |
// |
| 32 |
// $Id$ |
| 33 |
|
| 34 |
$title = 'Skarbiec'; |
| 35 |
require_once('includes/head.php'); |
| 36 |
|
| 37 |
/** |
| 38 |
* Get the localization for game |
| 39 |
*/ |
| 40 |
|
| 41 |
require_once("languages/".$player -> lang."/bank.php"); |
| 42 |
|
| 43 |
if ($player -> location != 'Altara' && $player -> location != 'Ardulith') |
| 44 |
{ |
| 45 |
error (ERROR); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Withdraw gold from bank |
| 50 |
*/ |
| 51 |
if (isset ($_GET['action']) && $_GET['action'] == 'withdraw') |
| 52 |
{ |
| 53 |
if (!isset($_POST['with'])) |
| 54 |
{ |
| 55 |
error(EMPTY_FIELD); |
| 56 |
} |
| 57 |
integercheck($_POST['with']); |
| 58 |
if (!ereg("^[1-9][0-9]*$", $_POST['with'])) |
| 59 |
{ |
| 60 |
error (ERROR); |
| 61 |
} |
| 62 |
if ($_POST['with'] > $player -> bank) |
| 63 |
{ |
| 64 |
error (NO_MONEY); |
| 65 |
} |
| 66 |
$db -> Execute("UPDATE `players` SET `credits`=`credits`+".$_POST['with'].", `bank`=`bank`-".$_POST['with']." WHERE `id`=".$player -> id); |
| 67 |
error ("<br />".WITHDRAW." ".$_POST['with']." ".GOLD_COINS); |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Deposit gold to bank |
| 72 |
*/ |
| 73 |
if (isset ($_GET['action']) && $_GET['action'] == 'deposit') |
| 74 |
{ |
| 75 |
if (!isset($_POST['dep'])) |
| 76 |
{ |
| 77 |
error (EMPTY_FIELD); |
| 78 |
} |
| 79 |
integercheck($_POST['dep']); |
| 80 |
if (!ereg("^[1-9][0-9]*$", $_POST['dep'])) |
| 81 |
{ |
| 82 |
error (ERROR); |
| 83 |
} |
| 84 |
if ($_POST['dep'] > $player -> credits || $_POST['dep'] <= 0) |
| 85 |
{ |
| 86 |
error (NO_MONEY); |
| 87 |
} |
| 88 |
$db -> Execute("UPDATE players SET credits=credits-".$_POST['dep'].", bank=bank+".$_POST['dep']." WHERE id=".$player -> id); |
| 89 |
error ("<br />".DEPOSIT." ".$_POST['dep']." ".GOLD_COINS); |
| 90 |
} |
| 91 |
|
| 92 |
/** |
| 93 |
* Donations of gold for another player |
| 94 |
*/ |
| 95 |
if (isset ($_GET['action']) && $_GET['action'] == 'donation') |
| 96 |
{ |
| 97 |
if (!ereg("^[1-9][0-9]*$", $_POST['pid']) || !ereg("^[1-9][0-9]*$", $_POST['with'])) |
| 98 |
{ |
| 99 |
error(ERROR); |
| 100 |
} |
| 101 |
integercheck($_POST['with']); |
| 102 |
$objGold = $db -> Execute("SELECT `bank` FROM `players` WHERE `id`=".$player -> id); |
| 103 |
if ($objGold -> fields['bank'] < $_POST['with']) |
| 104 |
{ |
| 105 |
error(NO_GOLD); |
| 106 |
} |
| 107 |
$objGold -> Close(); |
| 108 |
if ($player -> credits < 0) |
| 109 |
{ |
| 110 |
error(MINUS_GOLD); |
| 111 |
} |
| 112 |
if ($_POST['pid'] == $player -> id) |
| 113 |
{ |
| 114 |
error (BAD_PLAYER); |
| 115 |
} |
| 116 |
$objDonated = $db -> Execute("SELECT `id`, `user` FROM `players` WHERE `id`=".$_POST['pid']); |
| 117 |
if (!$objDonated -> fields['id']) |
| 118 |
{ |
| 119 |
error (NO_PLAYER); |
| 120 |
} |
| 121 |
$strPlayerName = $objDonated -> fields['user']; |
| 122 |
$objDonated -> Close(); |
| 123 |
$db -> Execute("UPDATE `players` SET `bank`=`bank`+".$_POST['with']." WHERE `id`=".$_POST['pid']); |
| 124 |
$db -> Execute("UPDATE `players` SET `bank`=`bank`-".$_POST['with']." WHERE `id`=".$player -> id); |
| 125 |
$strDate = $db -> DBDate($newdate); |
| 126 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$_POST['pid'].",'".T_PLAYER." <b><a href=view.php?view=".$player -> id.">".$player -> user."</a></b>".T_ID."<b>".$player -> id."</b>, ".T_GIVE." ".$_POST['with']." ".GOLD_COINS."', ".$strDate.")"); |
| 127 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$player -> id.",'".YOU_SEND." <b><a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b>, ID<b> ".$_POST['pid']."</b> ".G_AMOUNT." ".$_POST['with']." ".GOLD_COINS."', ".$strDate.")"); |
| 128 |
$db -> Execute("INSERT INTO `logs` (`owner`, `log`, `czas`) VALUES(".$player -> id.",'".YOU_SEND." <b><a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b>, ID<b> ".$_POST['pid']."</b> ".G_AMOUNT." ".$_POST['with']." ".GOLD_COINS."', ".$strDate.")"); |
| 129 |
error("<br />".YOU_SEND." <b><a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b>, ID<b> ".$_POST['pid']."</b> ".G_AMOUNT." ".$_POST['with']." ".GOLD_COINS); |
| 130 |
} |
| 131 |
|
| 132 |
/** |
| 133 |
* Mithril donations to another player |
| 134 |
*/ |
| 135 |
if (isset ($_GET['action']) && $_GET['action'] == 'mithril') |
| 136 |
{ |
| 137 |
integercheck($_POST['mithril']); |
| 138 |
if (!ereg("^[1-9][0-9]*$", $_POST['pid']) || !ereg("^[1-9][0-9]*$", $_POST['mithril'])) |
| 139 |
{ |
| 140 |
error (ERROR); |
| 141 |
} |
| 142 |
if ($_POST['pid'] == $player -> id) |
| 143 |
{ |
| 144 |
error (BAD_PLAYER); |
| 145 |
} |
| 146 |
$objMithril = $db -> Execute("SELECT `platinum` FROM `players` WHERE `id`=".$player -> id); |
| 147 |
if ($objMithril -> fields['platinum'] < $_POST['mithril']) |
| 148 |
{ |
| 149 |
error(NO_MITHRIL); |
| 150 |
} |
| 151 |
$objMithril -> Close(); |
| 152 |
$objDonated = $db -> Execute("SELECT `id`, `user` FROM `players` WHERE `id`=".$_POST['pid']); |
| 153 |
if (!$objDonated -> fields['id']) |
| 154 |
{ |
| 155 |
error (NO_PLAYER); |
| 156 |
} |
| 157 |
$strPlayerName = $objDonated -> fields['user']; |
| 158 |
$objDonated -> Close(); |
| 159 |
$db -> Execute("UPDATE `players` SET `platinum`=`platinum`+".$_POST['mithril']." WHERE `id`=".$_POST['pid']); |
| 160 |
$db -> Execute("UPDATE `players` SET `platinum`=`platinum`-".$_POST['mithril']." WHERE `id`=".$player -> id); |
| 161 |
$strDate = $db -> DBDate($newdate); |
| 162 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$_POST['pid'].",'".T_PLAYER." <b><a href=view.php?view=".$player -> id.">".$player ->user."</a></b> ".T_ID."<b>".$player -> id."</b>, ".T_GIVE." ".$_POST['mithril']." ".M_AMOUNT."', ".$strDate.")"); |
| 163 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$player -> id.",'".YOU_SEND." <b><a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b> ID<b> ".$_POST['pid']."</b>, ".$_POST['mithril']." ".M_AMOUNT."', ".$strDate.")"); |
| 164 |
$db -> Execute("INSERT INTO `logs` (`owner`, `log`, `czas`) VALUES(".$player -> id.",'".YOU_SEND." <b><a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b> ID<b> ".$_POST['pid']."</b>, ".$_POST['mithril']." ".M_AMOUNT."', ".$strDate.")"); |
| 165 |
error ("<br />".YOU_SEND." <b><a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b> ID<b> ".$_POST['pid']."</b>, ".$_POST['mithril']." ".M_AMOUNT.""); |
| 166 |
} |
| 167 |
|
| 168 |
/** |
| 169 |
* Give minerals to another player |
| 170 |
*/ |
| 171 |
if (isset ($_GET['action']) && $_GET['action'] == 'minerals') |
| 172 |
{ |
| 173 |
integercheck($_POST['amount']); |
| 174 |
if (!ereg("^[1-9][0-9]*$", $_POST['pid']) || !ereg("^[1-9][0-9]*$", $_POST['amount'])) |
| 175 |
{ |
| 176 |
error(ERROR); |
| 177 |
} |
| 178 |
$arrSqlname = array('copperore', 'zincore', 'tinore', 'ironore', 'copper', 'bronze', 'brass', 'iron', 'steel', 'coal', 'adamantium', 'meteor', 'crystal', 'pine', 'hazel', 'yew', 'elm'); |
| 179 |
if (!in_array($_POST['item'], $arrSqlname)) |
| 180 |
{ |
| 181 |
error(ERROR); |
| 182 |
} |
| 183 |
$intKey = array_search($_POST['item'], $arrSqlname); |
| 184 |
$objMinerals = $db -> Execute("SELECT ".$_POST['item']." FROM `minerals` WHERE `owner`=".$player -> id); |
| 185 |
if (!$objMinerals -> fields[$_POST['item']]) |
| 186 |
{ |
| 187 |
error(NO_MINERALS); |
| 188 |
} |
| 189 |
$arrName = array(COPPERORE, ZINCORE, TINORE, IRONORE, COPPER, BRONZE, BRASS, IRON, STEEL, COAL, ADAMANTIUM, METEOR, CRYSTAL, PINE, HAZEL, YEW, ELM); |
| 190 |
$strMineralname = $arrName[$intKey]; |
| 191 |
if ($objMinerals -> fields[$_POST['item']] < $_POST['amount']) |
| 192 |
{ |
| 193 |
error(NO_MINERAL." ".$strMineralname); |
| 194 |
} |
| 195 |
$objMinerals -> Close(); |
| 196 |
if ($_POST['pid'] == $player -> id) |
| 197 |
{ |
| 198 |
error(BAD_PLAYER); |
| 199 |
} |
| 200 |
$objDonated = $db -> Execute("SELECT `id`, `user` FROM `players` WHERE `id`=".$_POST['pid']); |
| 201 |
if (empty($objDonated -> fields['id'])) |
| 202 |
{ |
| 203 |
error(NO_PLAYER); |
| 204 |
} |
| 205 |
$strPlayerName = $objDonated -> fields['user']; |
| 206 |
$objDonated -> Close(); |
| 207 |
$objHave = $db -> Execute("SELECT `owner` FROM `minerals` WHERE `owner`=".$_POST['pid']); |
| 208 |
if (empty($objHave -> fields['owner'])) |
| 209 |
{ |
| 210 |
$db -> Execute("INSERT INTO `minerals` (`owner`, `".$_POST['item']."`) VALUES(".$_POST['pid'].",".$_POST['amount'].")") or error (E_DB); |
| 211 |
} |
| 212 |
else |
| 213 |
{ |
| 214 |
$db -> Execute("UPDATE `minerals` SET `".$_POST['item']."`=`".$_POST['item']."`+".$_POST['amount']." WHERE `owner`=".$_POST['pid']) or error (E_DB2); |
| 215 |
} |
| 216 |
$objHave -> Close(); |
| 217 |
$db -> Execute("UPDATE `minerals` SET `".$_POST['item']."`=`".$_POST['item']."`-".$_POST['amount']." WHERE `owner`=".$player -> id); |
| 218 |
$strDate = $db -> DBDate($newdate); |
| 219 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$_POST['pid'].",'".T_PLAYER."<b> <a href=view.php?view=".$player -> id.">".$player ->user."</a></b> ".T_ID."<b>".$player -> id."</b>, ".T_GIVE." <b>".$_POST['amount']." ".T_AMOUNT." ".$strMineralname."</b>.', ".$strDate.")"); |
| 220 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$player -> id.", '".YOU_SEND." <b> <a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b> ID<b> ".$_POST['pid'].", ".$_POST['amount']." ".T_AMOUNT." ".$strMineralname."</b>.', ".$strDate.")"); |
| 221 |
$db -> Execute("INSERT INTO `logs` (`owner`, `log`, `czas`) VALUES(".$player -> id.", '".YOU_SEND." <b> <a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b> ID<b> ".$_POST['pid'].", ".$_POST['amount']." ".T_AMOUNT." ".$strMineralname."</b>.', ".$strDate.")"); |
| 222 |
error ("<br />".YOU_SEND." <b><a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b> ID<b> ".$_POST['pid']."</b>, <b>".$_POST['amount']."</b> ".T_AMOUNT." <b>".$strMineralname."</b>."); |
| 223 |
} |
| 224 |
|
| 225 |
/** |
| 226 |
* Give herbs to another player |
| 227 |
*/ |
| 228 |
if (isset ($_GET['action']) && $_GET['action'] == 'herbs') |
| 229 |
{ |
| 230 |
integercheck($_POST['amount']); |
| 231 |
if (!ereg("^[1-9][0-9]*$", $_POST['pid']) || !ereg("^[1-9][0-9]*$", $_POST['amount'])) |
| 232 |
{ |
| 233 |
error (ERROR); |
| 234 |
} |
| 235 |
$arrHerbs = array('illani', 'illanias', 'nutari', 'dynallca', 'illani_seeds', 'illanias_seeds', 'nutari_seeds', 'dynallca_seeds'); |
| 236 |
if (!in_array($_POST['item'], $arrHerbs)) |
| 237 |
{ |
| 238 |
error (ERROR); |
| 239 |
} |
| 240 |
$herbs = $db -> Execute("SELECT `id`, `".$_POST['item']."` FROM `herbs` WHERE `gracz`=".$player -> id); |
| 241 |
if (empty ($herbs -> fields['id'])) |
| 242 |
{ |
| 243 |
error (NO_HERBS); |
| 244 |
} |
| 245 |
$herb = "$_POST[item]"; |
| 246 |
$arrName = array(HERB1, HERB2, HERB3, HERB4, HERB5, HERB6, HERB7, HERB8); |
| 247 |
$intKey = array_search($_POST['item'], $arrHerbs); |
| 248 |
if ($herbs -> fields[$herb] < $_POST['amount']) |
| 249 |
{ |
| 250 |
error (NO_MINERAL." ".$arrName[$intKey]); |
| 251 |
} |
| 252 |
$herbs -> Close(); |
| 253 |
if ($_POST['pid'] == $player -> id) |
| 254 |
{ |
| 255 |
error (BAD_PLAYER); |
| 256 |
} |
| 257 |
$objDonated = $db -> Execute("SELECT `id`, `user` FROM `players` WHERE `id`=".$_POST['pid']); |
| 258 |
if (empty ($objDonated -> fields['id'])) |
| 259 |
{ |
| 260 |
error (NO_PLAYER); |
| 261 |
} |
| 262 |
$strPlayerName = $objDonated -> fields['user']; |
| 263 |
$objDonated -> Close(); |
| 264 |
$have = $db -> Execute("SELECT `id` FROM `herbs` WHERE `gracz`=".$_POST['pid']); |
| 265 |
if (empty ($have -> fields['id'])) |
| 266 |
{ |
| 267 |
$db -> Execute("INSERT INTO `herbs` (`gracz`, `".$_POST['item']."`) VALUES(".$_POST['pid'].",".$_POST['amount'].")"); |
| 268 |
} |
| 269 |
else |
| 270 |
{ |
| 271 |
$db -> Execute("UPDATE `herbs` SET `".$_POST['item']."`=`".$_POST['item']."`+".$_POST['amount']." WHERE `gracz`=".$_POST['pid']); |
| 272 |
} |
| 273 |
$have -> Close(); |
| 274 |
$db -> Execute("UPDATE `herbs` SET `".$_POST['item']."`=`".$_POST['item']."`-".$_POST['amount']." WHERE `gracz`=".$player -> id); |
| 275 |
$strDate = $db -> DBDate($newdate); |
| 276 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$_POST['pid'].",'".T_PLAYER."<b><a href=view.php?view=".$player -> id.">".$player ->user."</a></b> ".T_ID."<b>".$player -> id."</b>, ".T_GIVE." ".$_POST['amount']." ".$arrName[$intKey].".', ".$strDate.")"); |
| 277 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$player -> id.",'".YOU_SEND." <b><a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b> ID<b> ".$_POST['pid'].", ".$_POST['amount']." ".$arrName[$intKey].".', ".$strDate.")"); |
| 278 |
error ("<br />".YOU_SEND." <b><a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b> ID<b> ".$_POST['pid']."</b>, <b>".$_POST['amount']."</b> ".$arrName[$intKey]); |
| 279 |
} |
| 280 |
|
| 281 |
/** |
| 282 |
* Give potions to another player |
| 283 |
*/ |
| 284 |
if (isset ($_GET['action']) && $_GET['action'] == 'potions') |
| 285 |
{ |
| 286 |
integercheck($_POST['amount']); |
| 287 |
if (!ereg("^[1-9][0-9]*$", $_POST['pid']) || !ereg("^[1-9][0-9]*$", $_POST['amount']) || !ereg("^[1-9][0-9]*$", $_POST['item'])) |
| 288 |
{ |
| 289 |
error (ERROR); |
| 290 |
} |
| 291 |
$item = $db -> Execute("SELECT * FROM `potions` WHERE `id`=".$_POST['item']); |
| 292 |
if ($player -> id != $item -> fields['owner']) |
| 293 |
{ |
| 294 |
error (NOT_YOUR); |
| 295 |
} |
| 296 |
if (empty ($item -> fields['id'])) |
| 297 |
{ |
| 298 |
error (NO_ITEM); |
| 299 |
} |
| 300 |
if ($_POST['pid'] == $player -> id) |
| 301 |
{ |
| 302 |
error (BAD_PLAYER); |
| 303 |
} |
| 304 |
$objDonated = $db -> Execute("SELECT `id`, `user` FROM `players` WHERE `id`=".$_POST['pid']); |
| 305 |
if (empty ($objDonated -> fields['id'])) |
| 306 |
{ |
| 307 |
error (NO_PLAYER); |
| 308 |
} |
| 309 |
$strPlayerName = $objDonated -> fields['user']; |
| 310 |
$objDonated -> Close(); |
| 311 |
if ($item -> fields['amount'] < $_POST['amount']) |
| 312 |
{ |
| 313 |
error (NO_MINERAL." ".$item -> fields['name']); |
| 314 |
} |
| 315 |
$test = $db -> Execute("SELECT `id` FROM `potions` WHERE `name`='".$item -> fields['name']."' AND `owner`=".$_POST['pid']." AND `status`='K' AND `power`=".$item -> fields['power']); |
| 316 |
if (empty ($test -> fields['id'])) |
| 317 |
{ |
| 318 |
$db -> Execute("INSERT INTO potions (`owner`, `name`, `efect`, `power`, `amount`, `status`, `type`) VALUES(".$_POST['pid'].",'".$item -> fields['name']."','".$item -> fields['efect']."',".$item -> fields['power'].",".$_POST['amount'].",'K','".$item ->fields['type']."')") or error(E_DB4); |
| 319 |
} |
| 320 |
else |
| 321 |
{ |
| 322 |
$db -> Execute("UPDATE `potions` SET `amount`=`amount`+".$_POST['amount']." WHERE `id`=".$test ->fields['id']); |
| 323 |
} |
| 324 |
$test -> Close(); |
| 325 |
if ($_POST['amount'] < $item -> fields['amount']) |
| 326 |
{ |
| 327 |
$db -> Execute("UPDATE `potions` SET `amount`=`amount`-".$_POST['amount']." WHERE `id`=".$item -> fields['id']); |
| 328 |
} |
| 329 |
else |
| 330 |
{ |
| 331 |
$db -> Execute("DELETE FROM `potions` WHERE `id`=".$item -> fields['id']); |
| 332 |
} |
| 333 |
$strDate = $db -> DBDate($newdate); |
| 334 |
$db -> Execute("INSERT INTO log (`owner`, `log`, `czas`) VALUES(".$_POST['pid'].",'".T_PLAYER."<b><a href=view.php?view=".$player -> id.">".$player ->user."</a></b> ".T_ID."<b>".$player -> id."</b>, ".T_GIVE." ".$_POST['amount']." ".$item -> fields['name']."</b> (+".$item -> fields['power'].").', ".$strDate.")") or error (E_DB3); |
| 335 |
$db -> Execute("INSERT INTO log (`owner`, `log`, `czas`) VALUES(".$player -> id.",'".YOU_SEND." <b><a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b> ID<b> ".$_POST['pid'].", ".$_POST['amount']." ".T_AMOUNT." ".$item -> fields['name']." (+".$item -> fields['power'].").', ".$strDate.")"); |
| 336 |
error ("<br />".YOU_SEND." <b><a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b>, ID<b> ".$_POST['pid']."</b>, <b>".$_POST['amount']."</b> ".T_AMOUNT." <b>".$item -> fields['name']."</b> (+".$item -> fields['power'].")."); |
| 337 |
$item -> Close(); |
| 338 |
} |
| 339 |
|
| 340 |
/** |
| 341 |
* Donations of item to another player |
| 342 |
*/ |
| 343 |
if (isset ($_GET['action']) && $_GET['action'] == 'items') |
| 344 |
{ |
| 345 |
integercheck($_POST['amount']); |
| 346 |
if (!ereg("^[1-9][0-9]*$", $_POST['pid']) || !ereg("^[1-9][0-9]*$", $_POST['amount']) || !ereg("^[1-9][0-9]*$", $_POST['item'])) |
| 347 |
{ |
| 348 |
error (ERROR); |
| 349 |
} |
| 350 |
$item = $db -> Execute("SELECT * FROM `equipment` WHERE `id`=".$_POST['item']); |
| 351 |
if ($player -> id != $item -> fields['owner']) |
| 352 |
{ |
| 353 |
error (NOT_YOUR); |
| 354 |
} |
| 355 |
if (empty ($item -> fields['id'])) |
| 356 |
{ |
| 357 |
error (NO_ITEM); |
| 358 |
} |
| 359 |
if ($_POST['pid'] == $player -> id) |
| 360 |
{ |
| 361 |
error (BAD_PLAYER); |
| 362 |
} |
| 363 |
$objDonated = $db -> Execute("SELECT `id`, `user` FROM `players` WHERE `id`=".$_POST['pid']); |
| 364 |
if (empty ($objDonated -> fields['id'])) |
| 365 |
{ |
| 366 |
error (NO_PLAYER); |
| 367 |
} |
| 368 |
$strPlayerName = $objDonated -> fields['user']; |
| 369 |
$objDonated -> Close(); |
| 370 |
if ($item -> fields['amount'] < $_POST['amount']) |
| 371 |
{ |
| 372 |
error (NO_MINERAL." ".$item -> fields['name']); |
| 373 |
} |
| 374 |
$test = $db -> Execute("SELECT `id` FROM `equipment` WHERE `name`='".$item -> fields['name']."' AND `wt`=".$item -> fields['wt']." AND `type`='".$item -> fields['type']."' AND `status`='U' AND `owner`=".$_POST['pid']." AND `power`=".$item -> fields['power']." AND `zr`=".$item -> fields['zr']." AND `szyb`=".$item -> fields['szyb']." AND `maxwt`=".$item -> fields['maxwt']." AND `poison`=".$item -> fields['poison']." AND `cost`=".$item -> fields['cost']); |
| 375 |
if (empty ($test -> fields['id'])) |
| 376 |
{ |
| 377 |
$db -> Execute("INSERT INTO `equipment` (`owner`, `name`, `power`, `type`, `cost`, `zr`, `wt`, `minlev`, `maxwt`, `amount`, `magic`, `poison`, `szyb`, `twohand`, `repair`) VALUES(".$_POST['pid'].",'".$item -> fields['name']."',".$item -> fields['power'].",'".$item -> fields['type']."',".$item -> fields['cost'].",".$item -> fields['zr'].",".$item -> fields['wt'].",".$item -> fields['minlev'].",".$item -> fields['maxwt'].",".$_POST['amount'].",'".$item -> fields['magic']."',".$item -> fields['poison'].",".$item -> fields['szyb'].",'".$item -> fields['twohand']."', ".$item -> fields['repair'].")") or error(E_DB4); |
| 378 |
} |
| 379 |
else |
| 380 |
{ |
| 381 |
if ($item -> fields['type'] != 'R') |
| 382 |
{ |
| 383 |
$db -> Execute("UPDATE `equipment` SET `amount`=`amount`+".$_POST['amount']." WHERE `id`=".$test -> fields['id']); |
| 384 |
} |
| 385 |
else |
| 386 |
{ |
| 387 |
$db -> Execute("UPDATE `equipment` SET `wt`=`wt`+".$item -> fields['wt']." WHERE `id`=".$test -> fields['id']); |
| 388 |
} |
| 389 |
} |
| 390 |
$test -> Close(); |
| 391 |
if ($_POST['amount'] < $item -> fields['amount']) |
| 392 |
{ |
| 393 |
$db -> Execute("UPDATE `equipment` SET `amount`=`amount`-".$_POST['amount']." WHERE `id`=".$item -> fields['id']); |
| 394 |
} |
| 395 |
else |
| 396 |
{ |
| 397 |
$db -> Execute("DELETE FROM `equipment` WHERE `id`=".$item -> fields['id']); |
| 398 |
} |
| 399 |
|
| 400 |
// Display detailed information about bonuses of each item. |
| 401 |
$strAttributes = '('; |
| 402 |
switch($item -> fields['type']) |
| 403 |
{ |
| 404 |
case 'A': // Pieces of armor: defense, agility and durability. |
| 405 |
$intAgi = $item -> fields['zr'] * -1; |
| 406 |
$strAttributes.= I_DEF.' +'.$item -> fields['power'].', '.I_AGI.' '.$intAgi.'%, '.I_DUR.' '.$item -> fields['wt'].'/'.$item -> fields['maxwt']; |
| 407 |
break; |
| 408 |
case 'B': // Bows: speed and durability. |
| 409 |
$strAttributes.= I_SPE.' +'.$item -> fields['szyb'].', '.I_DUR.' '.$item -> fields['wt'].'/'.$item -> fields['maxwt']; |
| 410 |
break; |
| 411 |
case 'H': // Helmets, |
| 412 |
case 'P': // plate legs, |
| 413 |
case 'S': // and shiels: defense and durability. |
| 414 |
$strAttributes.= I_DEF.' +'.$item -> fields['power'].', '.I_DUR.' '.$item -> fields['wt'].'/'.$item -> fields['maxwt']; |
| 415 |
break; |
| 416 |
case 'R': // Arrows: attack. |
| 417 |
$strAttributes.= I_ATT.' +'.$item -> fields['power']; |
| 418 |
break; |
| 419 |
case 'W': // Melee weapons: attack and durability. |
| 420 |
$strAttributes.= I_ATT.' +'.$item -> fields['power'].', '.I_DUR.' '.$item -> fields['wt'].'/'.$item -> fields['maxwt']; |
| 421 |
break; |
| 422 |
|
| 423 |
case 'C': // Mage robe: percent bonus to mana. |
| 424 |
$strAttributes.= I_MANA.' +'.$item -> fields['power'].'%'; |
| 425 |
break; |
| 426 |
case 'T': // Mage wand: percent bonus to spell strength. |
| 427 |
$strAttributes.= I_ATT.' +'.$item -> fields['power'].'%'; |
| 428 |
break; |
| 429 |
|
| 430 |
case 'I': // Rings: bonus type is in ring's description, so here we only display value. |
| 431 |
default: // same for items that may be added in future, only 'power' field in database with no description. |
| 432 |
$strAttributes.= '+'.$item -> fields['power']; |
| 433 |
} |
| 434 |
$strAttributes.= ').'; |
| 435 |
|
| 436 |
$strDate = $db -> DBDate($newdate); |
| 437 |
$db -> Execute("INSERT INTO log (`owner`, `log`, `czas`) VALUES(".$_POST['pid'].",'".T_PLAYER." <b><a href=view.php?view=".$player -> id.">".$player ->user."</a></b>".T_ID."<b>".$player -> id."</b>, ".T_GIVE." ".$_POST['amount']." ".I_AMOUNT." ".$item -> fields['name']."</b> ".$strAttributes."', ".$strDate.")"); |
| 438 |
|
| 439 |
$db -> Execute("INSERT INTO log (`owner`, `log`, `czas`) VALUES(".$player -> id.",'".YOU_SEND." <b><a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b> ID<b> ".$_POST['pid'].'</b>, '.$_POST['amount']." ".T_AMOUNT." ".$item -> fields['name']."</b> ".$strAttributes."', ".$strDate.")"); |
| 440 |
|
| 441 |
error ("<br />".YOU_SEND." <b><a href=view.php?view=".$_POST['pid'].">".$strPlayerName."</a></b>, ID<b> ".$_POST['pid'].'</b> '.$_POST['amount']." ".T_AMOUNT." ".$item -> fields['name']."</b> ".$strAttributes); |
| 442 |
} |
| 443 |
|
| 444 |
|
| 445 |
/** |
| 446 |
* Bank robbery |
| 447 |
*/ |
| 448 |
if ((isset ($_GET['action']) && $_GET['action'] == 'steal') && $player -> clas == 'Złodziej') |
| 449 |
{ |
| 450 |
if ($player -> hp <= 0) |
| 451 |
{ |
| 452 |
error (YOU_DEAD); |
| 453 |
} |
| 454 |
require_once("includes/checkexp.php"); |
| 455 |
if ($player -> crime <= 0) |
| 456 |
{ |
| 457 |
error (NO_CRIME); |
| 458 |
} |
| 459 |
$roll = rand (1, ($player -> level * 100)); |
| 460 |
/** |
| 461 |
* Add bonus from bless |
| 462 |
*/ |
| 463 |
$strBless = FALSE; |
| 464 |
$objBless = $db -> Execute("SELECT bless, blessval FROM players WHERE id=".$player -> id); |
| 465 |
if ($objBless -> fields['bless'] == 'inteli') |
| 466 |
{ |
| 467 |
$player -> inteli = $player -> inteli + $objBless -> fields['blessval']; |
| 468 |
$strBless = 'inteli'; |
| 469 |
} |
| 470 |
if ($objBless -> fields['bless'] == 'agility') |
| 471 |
{ |
| 472 |
$player -> agility = $player -> agility + $objBless -> fields['blessval']; |
| 473 |
$strBless = 'agility'; |
| 474 |
} |
| 475 |
$objBless -> Close(); |
| 476 |
if ($strBless) |
| 477 |
{ |
| 478 |
$db -> Execute("UPDATE players SET bless='', blessval=0 WHERE id=".$player -> id); |
| 479 |
} |
| 480 |
$chance = ($player -> agility + $player -> inteli) - $roll; |
| 481 |
if ($chance < 1) |
| 482 |
{ |
| 483 |
$cost = 1000 * $player -> level; |
| 484 |
$expgain = ceil($player -> level / 10); |
| 485 |
checkexp($player -> exp,$expgain,$player -> level,$player -> race,$player -> user,$player -> id,0,0,$player -> id,'',0); |
| 486 |
$db -> Execute("UPDATE players SET miejsce='Lochy', crime=crime-1 WHERE id=".$player -> id); |
| 487 |
$strDate = $db -> DBDate($newdate); |
| 488 |
$db -> Execute("INSERT INTO `jail` (`prisoner`, `verdict`, `duration`, `cost`, `data`) VALUES(".$player -> id.", '".VERDICT."', 7, ".$cost.", ".$strDate.")") or error (E_DB4); |
| 489 |
$db -> Execute("INSERT INTO log (owner, log, czas) VALUES(".$player -> id.",'".L_REASON.": ".$cost.".','".$newdate."')"); |
| 490 |
error (C_CACHED); |
| 491 |
} |
| 492 |
if ($chance > 0) |
| 493 |
{ |
| 494 |
$gain = $player -> level * 1000; |
| 495 |
$expgain = ($player -> level * 10); |
| 496 |
$db -> Execute("UPDATE players SET crime=crime-1, credits=credits+".$gain." WHERE id=".$player -> id); |
| 497 |
checkexp($player -> exp,$expgain,$player -> level,$player -> race,$player -> user,$player -> id,0,0,$player -> id,'',0); |
| 498 |
error (C_SUCCES.$gain.C_SUCCES2); |
| 499 |
} |
| 500 |
} |
| 501 |
|
| 502 |
/** |
| 503 |
* Buy safe box for astral components |
| 504 |
*/ |
| 505 |
if (isset($_GET['action']) && $_GET['action'] == 'safe') |
| 506 |
{ |
| 507 |
$objSafebox = $db -> Execute("SELECT `level` FROM `astral_bank` WHERE `owner`=".$player -> id." AND `location`='V'"); |
| 508 |
if ($objSafebox -> fields['level'] != 3) |
| 509 |
{ |
| 510 |
if (!$objSafebox -> fields['level']) |
| 511 |
{ |
| 512 |
$objSafebox -> fields['level'] = 0; |
| 513 |
} |
| 514 |
$arrSafeneed = array(array(20000, 150, 0, 0), |
| 515 |
array(40000, 300, 50, 0), |
| 516 |
array(100000, 450, 100, 50)); |
| 517 |
$intKey = $objSafebox -> fields['level']; |
| 518 |
if ($player -> credits < $arrSafeneed[$intKey][0]) |
| 519 |
{ |
| 520 |
error(NO_MONEY); |
| 521 |
} |
| 522 |
if ($player -> platinum < $arrSafeneed[$intKey][1]) |
| 523 |
{ |
| 524 |
error(NO_MITHRIL); |
| 525 |
} |
| 526 |
$objMinerals = $db -> Execute("SELECT `crystal`, `adamantium` FROM `minerals` WHERE `owner`=".$player -> id); |
| 527 |
if ($objMinerals -> fields['adamantium'] < $arrSafeneed[$intKey][2]) |
| 528 |
{ |
| 529 |
error(NO_MINERAL." ".ADAMANTIUM."!"); |
| 530 |
} |
| 531 |
if ($objMinerals -> fields['crystal'] < $arrSafeneed[$intKey][3]) |
| 532 |
{ |
| 533 |
error(NO_MINERAL." ".CRYSTAL."!"); |
| 534 |
} |
| 535 |
if (!$objSafebox -> fields['level']) |
| 536 |
{ |
| 537 |
$db -> Execute("INSERT INTO `astral_bank` (`owner`, `level`, `location`) VALUES(".$player -> id.", 1, 'V')"); |
| 538 |
} |
| 539 |
else |
| 540 |
{ |
| 541 |
$db -> Execute("UPDATE `astral_bank` SET `level`=`level`+1 WHERE `owner`=".$player -> id." AND `location`='V'"); |
| 542 |
} |
| 543 |
$db -> Execute("UPDATE `players` SET `credits`=`credits`-".$arrSafeneed[$intKey][0].", `platinum`=`platinum`-".$arrSafeneed[$intKey][1]." WHERE `id`=".$player -> id); |
| 544 |
$db -> Execute("UPDATE `minerals` SET `adamantium`=`adamantium`-".$arrSafeneed[$intKey][2].", `crystal`=`crystal`-".$arrSafeneed[$intKey][3]." WHERE `owner`=".$player -> id); |
| 545 |
error(YOU_UPGRADE); |
| 546 |
} |
| 547 |
else |
| 548 |
{ |
| 549 |
error(SAFE_ENOUGH); |
| 550 |
} |
| 551 |
$objSafebox -> Close(); |
| 552 |
} |
| 553 |
|
| 554 |
/** |
| 555 |
* Assign variables to template |
| 556 |
*/ |
| 557 |
$smarty -> assign(array("Potions" => '', |
| 558 |
"Minerals" => '', |
| 559 |
"Items" => '', |
| 560 |
"Crime" => '', |
| 561 |
"Herbs" => '', |
| 562 |
"Safebox" => '', |
| 563 |
"Bankinfo" => BANK_INFO, |
| 564 |
"Iwant" => I_WANT, |
| 565 |
"Awithdraw" => A_WITHDRAW, |
| 566 |
"Adeposit" => A_DEPOSIT, |
| 567 |
"Agive" => A_GIVE, |
| 568 |
"Dplayer" => D_PLAYER, |
| 569 |
"Goldcoins" => GOLD_COINS, |
| 570 |
"Mithril" => $player -> platinum, |
| 571 |
"Mamount" => M_AMOUNT, |
| 572 |
"Iamount" => I_AMOUNT, |
| 573 |
"Iamount2" => I_AMOUNT2, |
| 574 |
"Aastral" => A_ASTRAL, |
| 575 |
"Aastral2" => A_ASTRAL2, |
| 576 |
"Hamount" => H_AMOUNT)); |
| 577 |
|
| 578 |
/** |
| 579 |
* Main menu |
| 580 |
*/ |
| 581 |
if (!isset($_GET['action']) || (isset($_GET['action']) && $_GET['action'] != 'astral')) |
| 582 |
{ |
| 583 |
/** |
| 584 |
* List of items |
| 585 |
*/ |
| 586 |
$item = $db -> Execute("SELECT `id`, `name`, `amount`, `power`, `zr`, `szyb` FROM `equipment` WHERE `owner`=".$player -> id." AND `status`='U'"); |
| 587 |
if ($item -> fields['id']) |
| 588 |
{ |
| 589 |
$arrid = array(); |
| 590 |
$arrname = array(); |
| 591 |
$arramount = array(); |
| 592 |
$arrPower = array(); |
| 593 |
$arrAgi = array(); |
| 594 |
$arrSpeed = array(); |
| 595 |
$i = 0; |
| 596 |
while (!$item -> EOF) |
| 597 |
{ |
| 598 |
$arrid[$i] = $item -> fields['id']; |
| 599 |
$arrname[$i] = $item -> fields['name']; |
| 600 |
$arramount[$i] = $item -> fields['amount']; |
| 601 |
$arrPower[$i] = $item -> fields['power']; |
| 602 |
$arrAgi[$i] = $item -> fields['zr'] * -1; |
| 603 |
$arrSpeed[$i] = $item -> fields['szyb']; |
| 604 |
$i = $i + 1; |
| 605 |
$item -> MoveNext(); |
| 606 |
} |
| 607 |
$smarty -> assign (array("Itemid" => $arrid, |
| 608 |
"Itemname" => $arrname, |
| 609 |
"Itemamount" => $arramount, |
| 610 |
"Itempower" => $arrPower, |
| 611 |
"Itemagi" => $arrAgi, |
| 612 |
"Itemspeed" => $arrSpeed, |
| 613 |
"Iagi" => I_AGI, |
| 614 |
"Ispe" => I_SPE, |
| 615 |
"Items" => 1)); |
| 616 |
} |
| 617 |
$item -> Close(); |
| 618 |
|
| 619 |
/** |
| 620 |
* List of potions |
| 621 |
*/ |
| 622 |
$miks = $db -> Execute("SELECT `id`, `name`, `amount`, `power` FROM `potions` WHERE `owner`=".$player -> id." AND `status`='K'"); |
| 623 |
if ($miks -> fields['id']) |
| 624 |
{ |
| 625 |
$arrid = array(); |
| 626 |
$arrname = array(); |
| 627 |
$arramount = array(); |
| 628 |
$arrPower = array(); |
| 629 |
$i = 0; |
| 630 |
while (!$miks -> EOF) |
| 631 |
{ |
| 632 |
$arrid[$i] = $miks -> fields['id']; |
| 633 |
$arrname[$i] = $miks -> fields['name']; |
| 634 |
$arramount[$i] = $miks -> fields['amount']; |
| 635 |
$arrPower[$i] = $miks -> fields['power']; |
| 636 |
$i = $i + 1; |
| 637 |
$miks -> MoveNext(); |
| 638 |
} |
| 639 |
$smarty -> assign (array("Potionid" => $arrid, |
| 640 |
"Potionname" => $arrname, |
| 641 |
"Potionamount" => $arramount, |
| 642 |
"Potionpower" => $arrPower, |
| 643 |
"Potions" => 1)); |
| 644 |
} |
| 645 |
$miks -> Close(); |
| 646 |
|
| 647 |
/** |
| 648 |
* List of herbs |
| 649 |
*/ |
| 650 |
$test = $db -> Execute("SELECT illani, illanias, nutari, dynallca, illani_seeds, illanias_seeds, nutari_seeds, dynallca_seeds FROM herbs WHERE gracz=".$player -> id); |
| 651 |
if (!empty ($test -> fields['illani']) || !empty ($test -> fields['illanias']) || !empty ($test -> fields['nutari']) || !empty ($test -> fields['dynallca']) || !empty($test -> fields['illani_seeds']) || !empty($test -> fields['illanias_seeds']) || !empty($test -> fields['nutari_seeds']) || !empty($test -> fields['dynallca_seeds'])) |
| 652 |
{ |
| 653 |
$arrname = array ('illani','illanias','nutari','dynallca', 'illani_seeds', 'illanias_seeds', 'nutari_seeds', 'dynallca_seeds'); |
| 654 |
$arrName = array(HERB1, HERB2, HERB3, HERB4, HERB5, HERB6, HERB7, HERB8); |
| 655 |
$arritem = array(); |
| 656 |
$arrName2 = array(); |
| 657 |
$j = 0; |
| 658 |
for ($i = 0; $i < 8; $i++) |
| 659 |
{ |
| 660 |
$name = $arrname[$i]; |
| 661 |
if ($test -> fields[$name] > 0) |
| 662 |
{ |
| 663 |
$arritem[$j] = $name; |
| 664 |
$arrName2[$j] = $arrName[$i]; |
| 665 |
$j++; |
| 666 |
} |
| 667 |
} |
| 668 |
$smarty -> assign (array("Herbs" => 1, |
| 669 |
"Herbname" => $arritem, |
| 670 |
"Herbname2" => $arrName2)); |
| 671 |
} |
| 672 |
$test -> Close(); |
| 673 |
|
| 674 |
/** |
| 675 |
* List of minerals |
| 676 |
*/ |
| 677 |
$objMinerals = $db -> Execute("SELECT `copperore`, `zincore`, `tinore`, `ironore`, `coal`, `copper`, `bronze`, `brass`, `iron`, `steel`, `pine`, `hazel`, `yew`, `elm`, `crystal`, `adamantium`, `meteor` FROM `minerals` WHERE `owner`=".$player -> id); |
| 678 |
$arrAmount = array($objMinerals -> fields['copperore'], $objMinerals -> fields['zincore'], $objMinerals -> fields['tinore'], $objMinerals -> fields['ironore'], $objMinerals -> fields['copper'], $objMinerals -> fields['bronze'], $objMinerals -> fields['brass'], $objMinerals -> fields['iron'], $objMinerals -> fields['steel'], $objMinerals -> fields['coal'], $objMinerals -> fields['adamantium'], $objMinerals -> fields['meteor'], $objMinerals -> fields['crystal'], $objMinerals -> fields['pine'], $objMinerals -> fields['hazel'], $objMinerals -> fields['yew'], $objMinerals -> fields['elm']); |
| 679 |
$strAvailable = 'N'; |
| 680 |
$arrSqlname = array('copperore', 'zincore', 'tinore', 'ironore', 'copper', 'bronze', 'brass', 'iron', 'steel', 'coal', 'adamantium', 'meteor', 'crystal', 'pine', 'hazel', 'yew', 'elm'); |
| 681 |
$arrMinerals = array(MIN1, MIN2, MIN3, MIN4, MIN5, MIN6, MIN7, MIN8, MIN9, MIN10, MIN11, MIN12, MIN13, MIN14, MIN15, MIN16, MIN17); |
| 682 |
$arrOptions = array(); |
| 683 |
$arrMineralsname = array(); |
| 684 |
$j = 0; |
| 685 |
for ($i = 0; $i < 17; $i++) |
| 686 |
{ |
| 687 |
if ($arrAmount[$i]) |
| 688 |
{ |
| 689 |
$strAvailable = 'Y'; |
| 690 |
$arrOptions[$j] = $arrSqlname[$i]; |
| 691 |
$arrMineralsname[$j] = $arrMinerals[$i]; |
| 692 |
$j++; |
| 693 |
} |
| 694 |
} |
| 695 |
if ($strAvailable == 'Y') |
| 696 |
{ |
| 697 |
$smarty -> assign (array("Minerals" => 1, |
| 698 |
"Minoption" => $arrOptions, |
| 699 |
"Minname" => $arrMineralsname)); |
| 700 |
} |
| 701 |
$objMinerals -> Close(); |
| 702 |
|
| 703 |
/** |
| 704 |
* Buy safe box |
| 705 |
*/ |
| 706 |
$objSafebox = $db -> Execute("SELECT `level` FROM `astral_bank` WHERE `owner`=".$player -> id." AND `location`='V'"); |
| 707 |
if ($objSafebox -> fields['level'] != 3) |
| 708 |
{ |
| 709 |
if (!$objSafebox -> fields['level']) |
| 710 |
{ |
| 711 |
$objSafebox -> fields['level'] = 0; |
| 712 |
} |
| 713 |
$arrSafeneed = array(array(20000, 150, 0, 0), |
| 714 |
array(40000, 300, 50, 0), |
| 715 |
array(100000, 450, 100, 50)); |
| 716 |
$intKey = $objSafebox -> fields['level']; |
| 717 |
$intUpgrade = $intKey + 1; |
| 718 |
$strSafebox = BUY_SAFE.$intUpgrade.BUY_SAFE2.$arrSafeneed[$intKey][0].ASTRAL_GOLD.", ".$arrSafeneed[$intKey][1].ASTRAL_MITH.", ".$arrSafeneed[$intKey][2]." ".ADAMANTIUM.", ".$arrSafeneed[$intKey][3]." ".CRYSTAL."."; |
| 719 |
$smarty -> assign("Safebox", "<li><a href=\"bank.php?action=safe\">".$strSafebox."</a></li>"); |
| 720 |
} |
| 721 |
$objSafebox -> Close(); |
| 722 |
|
| 723 |
/** |
| 724 |
* Steal action (only for thief) |
| 725 |
*/ |
| 726 |
if ($player -> clas == 'Złodziej' && $player -> crime > 0) |
| 727 |
{ |
| 728 |
$smarty -> assign ("Crime", "<p><a href=\"bank.php?action=steal\">".A_CRIME."</a></p>"); |
| 729 |
} |
| 730 |
} |
| 731 |
|
| 732 |
/** |
| 733 |
* Astral vault |
| 734 |
*/ |
| 735 |
if (isset($_GET['action']) && $_GET['action'] == 'astral') |
| 736 |
{ |
| 737 |
if (!isset($_GET['type'])) |
| 738 |
{ |
| 739 |
error(ERROR); |
| 740 |
} |
| 741 |
|
| 742 |
$smarty -> assign("Type", $_GET['type']); |
| 743 |
|
| 744 |
/** |
| 745 |
* List of maps, plans, recipes |
| 746 |
*/ |
| 747 |
if ($_GET['type'] == 'p') |
| 748 |
{ |
| 749 |
$arrMaps = array(MAP1, MAP2, MAP3, MAP4, MAP5, MAP6, MAP7); |
| 750 |
$arrMaps2 = array(MAP1, MAP2, MAP3, MAP4, MAP5, MAP6, MAP7); |
| 751 |
$arrPlans = array(PLAN1, PLAN2, PLAN3, PLAN4, PLAN5); |
| 752 |
$arrPlans2 = array(PLAN1, PLAN2, PLAN3, PLAN4, PLAN5); |
| 753 |
$arrRecipes = array(RECIPE1, RECIPE2, RECIPE3, RECIPE4, RECIPE5); |
| 754 |
$arrRecipes2 = array(RECIPE1, RECIPE2, RECIPE3, RECIPE4, RECIPE5); |
| 755 |
$arrFormulas = array(FORMULA1, FORMULA2, FORMULA3, FORMULA4, FORMULA5); |
| 756 |
$arrFormulas2 = array(FORMULA1, FORMULA2, FORMULA3, FORMULA4, FORMULA5); |
| 757 |
$arrNames = array_merge($arrMaps, $arrPlans, $arrRecipes, $arrFormulas); |
| 758 |
|
| 759 |
require_once('includes/astralvault.php'); |
| 760 |
|
| 761 |
showastral('V', 'bank.php?action=astral&type=p', $player -> id); |
| 762 |
|
| 763 |
$smarty -> assign(array("Tname" => T_NAME, |
| 764 |
"Tmaps" => T_MAPS, |
| 765 |
"Tplans" => T_PLANS, |
| 766 |
"Trecipes" => T_RECIPES, |
| 767 |
"Tformulas" => T_FORMULAS, |
| 768 |
"Tmaps2" => T_MAPS2, |
| 769 |
"Tplans2" => T_PLANS2, |
| 770 |
"Trecipes2" => T_RECIPES2, |
| 771 |
"Tformulas2" => T_FORMULAS2, |
| 772 |
"Mapsname" => $arrMaps, |
| 773 |
"Plansname" => $arrPlans, |
| 774 |
"Recipesname" => $arrRecipes, |
| 775 |
"Formulasname" => $arrFormulas, |
| 776 |
"Mapsname2" => $arrMaps2, |
| 777 |
"Plansname2" => $arrPlans2, |
| 778 |
"Recipesname2" => $arrRecipes2, |
| 779 |
"Formulasname2" => $arrFormulas2, |
| 780 |
"Mapsamount" => $arrMapsamount, |
| 781 |
"Plansamount" => $arrPlansamount, |
| 782 |
"Recipesamount" => $arrRecipesamount, |
| 783 |
"Formulasamount" => $arrFormulasamount, |
| 784 |
"Mapsamount2" => $arrCmapsamount, |
| 785 |
"Plansamount2" => $arrCplansamount, |
| 786 |
"Recipesamount2" => $arrCrecipesamount, |
| 787 |
"Formulasamount2" => $arrCformulasamount, |
| 788 |
"Tcomponents" => $arrNames, |
| 789 |
"Tsend" => T_SEND, |
| 790 |
"Tpiece" => T_PIECE, |
| 791 |
"Tnumber" => T_NUMBER, |
| 792 |
"Tamount" => T_AMOUNT2, |
| 793 |
"Agive" => A_GIVE2, |
| 794 |
"Message" => '')); |
| 795 |
} |
| 796 |
/** |
| 797 |
* List of components |
| 798 |
*/ |
| 799 |
if ($_GET['type'] == 'c') |
| 800 |
{ |
| 801 |
$arrCompnames = array(array(COMP1, COMP2, COMP3, COMP4, COMP5, COMP6, COMP7), |
| 802 |
array(CONST1, CONST2, CONST3, CONST4, CONST5), |
| 803 |
array(POTION1, POTION2, POTION3, POTION4, POTION5), |
| 804 |
array(JEWELLERY1, JEWELLERY2, JEWELLERY3, JEWELLERY4, JEWELLERY5)); |
| 805 |
$arrCompnames2 = array(MAGICCOMP, MAGICCONST, MAGICPOTIONS, MAGICJEWELLERY); |
| 806 |
$arrNames2 = array_merge($arrCompnames[0], $arrCompnames[1], $arrCompnames[2], $arrCompnames[3]); |
| 807 |
|
| 808 |
require_once('includes/astralvault.php'); |
| 809 |
|
| 810 |
$arrComponents = showcomponents('V', $player -> id); |
| 811 |
|
| 812 |
$smarty -> assign(array("Tname" => T_NAME, |
| 813 |
"Tmagic" => $arrCompnames2, |
| 814 |
"Tcomp" => $arrCompnames, |
| 815 |
"Components" => $arrComponents, |
| 816 |
"Tcomponents2" => $arrNames2, |
| 817 |
"Tsend" => T_SEND, |
| 818 |
"Tnumber" => T_NUMBER, |
| 819 |
"Tamount" => T_AMOUNT2, |
| 820 |
"Agive" => A_GIVE2, |
| 821 |
"Tcomponent3" => T_COMPONENT, |
| 822 |
"Message" => '')); |
| 823 |
} |
| 824 |
|
| 825 |
/** |
| 826 |
* Merge plans, maps, recipes |
| 827 |
*/ |
| 828 |
if (isset($_GET['step']) && ($_GET['step'] != 'piece' && $_GET['step'] != 'component')) |
| 829 |
{ |
| 830 |
mergeplans('V', $player -> id); |
| 831 |
$smarty -> assign("Message", YOU_MERGE); |
| 832 |
} |
| 833 |
|
| 834 |
/** |
| 835 |
* Give item to player |
| 836 |
*/ |
| 837 |
if (isset($_GET['step']) && ($_GET['step'] == 'piece' || $_GET['step'] == 'component')) |
| 838 |
{ |
| 839 |
integercheck($_POST['amount']); |
| 840 |
if (!ereg("^[1-9][0-9]*$", $_POST['amount']) || !ereg("^[0-9]*$", $_POST['name']) || !ereg("^[0-9]*$", $_POST['pid']) || !ereg("^[1-9][0-9]*$", $_POST['number'])) |
| 841 |
{ |
| 842 |
error(ERROR); |
| 843 |
} |
| 844 |
$objDonated = $db -> Execute("SELECT `id` FROM `players` WHERE `id`=".$_POST['pid']); |
| 845 |
if (empty($objDonated -> fields['id'])) |
| 846 |
{ |
| 847 |
error(NO_PLAYER); |
| 848 |
} |
| 849 |
$objDonated -> Close(); |
| 850 |
if ($_POST['pid'] == $player -> id) |
| 851 |
{ |
| 852 |
error(BAD_PLAYER); |
| 853 |
} |
| 854 |
$intCompname = $_POST['name']; |
| 855 |
if ($_GET['step'] == 'piece') |
| 856 |
{ |
| 857 |
if ($_POST['name'] < 7) |
| 858 |
{ |
| 859 |
$strName = 'M'; |
| 860 |
} |
| 861 |
if ($_POST['name'] > 6 && $_POST['name'] < 12) |
| 862 |
{ |
| 863 |
$strName = 'P'; |
| 864 |
} |
| 865 |
if ($_POST['name'] > 11 && $POST['name']< 17) |
| 866 |
{ |
| 867 |
$strName = 'R'; |
| 868 |
} |
| 869 |
if ($_POST['name'] > 16) |
| 870 |
{ |
| 871 |
$strName = 'Y'; |
| 872 |
} |
| 873 |
|
| 874 |
$strType = PIECE; |
| 875 |
$strCompname = $arrNames[$intCompname]; |
| 876 |
} |
| 877 |
else |
| 878 |
{ |
| 879 |
if ($_POST['name'] < 7) |
| 880 |
{ |
| 881 |
$strName = 'C'; |
| 882 |
} |
| 883 |
if ($_POST['name'] > 6 && $_POST['name'] < 12) |
| 884 |
{ |
| 885 |
$strName = 'O'; |
| 886 |
} |
| 887 |
if ($_POST['name'] > 11 && $_POST['name'] < 17) |
| 888 |
{ |
| 889 |
$strName = 'T'; |
| 890 |
} |
| 891 |
if ($_POST['name'] > 16) |
| 892 |
{ |
| 893 |
$strName = 'J'; |
| 894 |
} |
| 895 |
$strType = COMPONENT; |
| 896 |
$strCompname = $arrNames2[$intCompname]; |
| 897 |
} |
| 898 |
$arrNumber = array(0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4); |
| 899 |
$strPiecename = $strName.$arrNumber[$_POST['name']]; |
| 900 |
$intNumber = $_POST['number'] - 1; |
| 901 |
$objAmount = $db -> Execute("SELECT `amount` FROM `astral` WHERE `owner`=".$player -> id." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='V'") or die($db -> ErrorMsg()); |
| 902 |
if (!$objAmount -> fields['amount']) |
| 903 |
{ |
| 904 |
error(NO_AMOUNT); |
| 905 |
} |
| 906 |
if ($objAmount -> fields['amount'] < $_POST['amount']) |
| 907 |
{ |
| 908 |
error(NO_AMOUNT); |
| 909 |
} |
| 910 |
$objTest = $db -> Execute("SELECT `amount` FROM `astral` WHERE `owner`=".$_POST['pid']." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='V'"); |
| 911 |
if (!$objTest -> fields['amount']) |
| 912 |
{ |
| 913 |
$db -> Execute("INSERT INTO `astral` (`owner`, `type`, `number`, `amount`, `location`) VALUES(".$_POST['pid'].", '".$strPiecename."', ".$intNumber.", ".$_POST['amount'].", 'V')"); |
| 914 |
} |
| 915 |
else |
| 916 |
{ |
| 917 |
$db -> Execute("UPDATE `astral` SET `amount`=`amount`+".$_POST['amount']." WHERE `owner`=".$_POST['pid']." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='V'"); |
| 918 |
} |
| 919 |
$objTest -> Close(); |
| 920 |
if ($objAmount -> fields['amount'] == $_POST['amount']) |
| 921 |
{ |
| 922 |
$db -> Execute("DELETE FROM `astral` WHERE `owner`=".$player -> id." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='V'"); |
| 923 |
} |
| 924 |
else |
| 925 |
{ |
| 926 |
$db -> Execute("UPDATE `astral` SET `amount`=`amount`-".$_POST['amount']." WHERE `owner`=".$player -> id." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='V'"); |
| 927 |
} |
| 928 |
$objAmount -> Close(); |
| 929 |
$strMessage = YOU_GIVE.$strType.$strCompname.M_AMOUNT2.$_POST['amount']." ".D_PLAYER.": ".$_POST['pid']."."; |
| 930 |
$strMessage2 = YOU_GET.$strType.$strCompname.M_AMOUNT2.$_POST['amount'].D_PLAYER2.$player -> id."."; |
| 931 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$_POST['pid'].", '".$strMessage2."','".$newdate."')"); |
| 932 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$player -> id.", '".$strMessage."','".$newdate."')"); |
| 933 |
$smarty -> assign("Message", $strMessage); |
| 934 |
} |
| 935 |
} |
| 936 |
|
| 937 |
/** |
| 938 |
* Initialization of variable |
| 939 |
*/ |
| 940 |
if (!isset($_GET['action'])) |
| 941 |
{ |
| 942 |
$_GET['action'] = ''; |
| 943 |
} |
| 944 |
|
| 945 |
/** |
| 946 |
* Display site |
| 947 |
*/ |
| 948 |
$smarty -> assign (array("Bank" => $player -> bank, |
| 949 |
"Gold" => $player -> credits, |
| 950 |
"Action" => $_GET['action'])); |
| 951 |
$smarty -> display ('bank.tpl'); |
| 952 |
|
| 953 |
require_once("includes/foot.php"); |
| 954 |
|
| 955 |
?> |