| 1 |
<?php |
| 2 |
/** |
| 3 |
* File functions: |
| 4 |
* Tribe astral vault - plans, maps, recipes |
| 5 |
* |
| 6 |
* @name : tribeastral.php |
| 7 |
* @copyright : (C) 2006,2007 Vallheru Team based on Gamers-Fusion ver 2.5 |
| 8 |
* @author : thindil <thindil@users.sourceforge.net> |
| 9 |
* @author : eyescream <tduda@users.sourceforge.net> |
| 10 |
* @version : 1.3 |
| 11 |
* @since : 03.03.2007 |
| 12 |
* |
| 13 |
*/ |
| 14 |
|
| 15 |
// |
| 16 |
// |
| 17 |
// This program is free software; you can redistribute it and/or modify |
| 18 |
// it under the terms of the GNU General Public License as published by |
| 19 |
// the Free Software Foundation; either version 2 of the License, or |
| 20 |
// (at your option) any later version. |
| 21 |
// |
| 22 |
// This program is distributed in the hope that it will be useful, |
| 23 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 24 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 25 |
// GNU General Public License for more details. |
| 26 |
// |
| 27 |
// You should have received a copy of the GNU General Public License |
| 28 |
// along with this program; if not, write to the Free Software |
| 29 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 30 |
// |
| 31 |
// $Id$ |
| 32 |
|
| 33 |
$title = "Astralny skarbiec"; |
| 34 |
require_once("includes/head.php"); |
| 35 |
|
| 36 |
/** |
| 37 |
* Get the localization for game |
| 38 |
*/ |
| 39 |
require_once("languages/".$player -> lang."/tribeastral.php"); |
| 40 |
|
| 41 |
/** |
| 42 |
* Check if player is in clan |
| 43 |
*/ |
| 44 |
if (!$player -> tribe) |
| 45 |
{ |
| 46 |
error (NO_CLAN); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Check if player is in city |
| 51 |
*/ |
| 52 |
if ($player -> location != 'Altara' && $player -> location != 'Ardulith') |
| 53 |
{ |
| 54 |
error (ERROR); |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Assign variable to template |
| 59 |
*/ |
| 60 |
$smarty -> assign("Message",''); |
| 61 |
|
| 62 |
/** |
| 63 |
* Check who have permission to give potions |
| 64 |
*/ |
| 65 |
$objPerm = $db -> Execute("SELECT `astralvault` FROM `tribe_perm` WHERE `tribe`=".$player -> tribe." AND `player`=".$player -> id); |
| 66 |
$objOwner = $db -> Execute("SELECT `owner` FROM `tribes` WHERE id=".$player -> tribe); |
| 67 |
|
| 68 |
/** |
| 69 |
* Main menu |
| 70 |
*/ |
| 71 |
if (!isset($_GET['action'])) |
| 72 |
{ |
| 73 |
if ($player -> id == $objOwner -> fields['owner'] || $objPerm -> fields['astralvault']) |
| 74 |
{ |
| 75 |
$strAgive = A_GIVE; |
| 76 |
|
| 77 |
/** |
| 78 |
* Buy safe box |
| 79 |
*/ |
| 80 |
$objSafebox = $db -> Execute("SELECT `level` FROM `astral_bank` WHERE `owner`=".$player -> tribe." AND `location`='C'"); |
| 81 |
if ($objSafebox -> fields['level'] != 3) |
| 82 |
{ |
| 83 |
if (!$objSafebox -> fields['level']) |
| 84 |
{ |
| 85 |
$objSafebox -> fields['level'] = 0; |
| 86 |
} |
| 87 |
$arrSafeneed = array(array(200000, 200, 100, 0, 0), |
| 88 |
array(400000, 400, 200, 100, 0), |
| 89 |
array(800000, 800, 400, 200, 100)); |
| 90 |
$intKey = $objSafebox -> fields['level']; |
| 91 |
$intUpgrade = $intKey + 1; |
| 92 |
$strSafebox = "<a href=\"tribeastral.php?action=safe\">".BUY_SAFE.$intUpgrade.BUY_SAFE2.$arrSafeneed[$intKey][0].ASTRAL_GOLD.", ".$arrSafeneed[$intKey][1].ASTRAL_MITH.", ".$arrSafeneed[$intKey][2]." ".ADAMANTIUM.", ".$arrSafeneed[$intKey][3]." ".CRYSTAL.", ".$arrSafeneed[$intKey][4]." ".METEOR.".</a>"; |
| 93 |
} |
| 94 |
else |
| 95 |
{ |
| 96 |
$strSafebox = ''; |
| 97 |
} |
| 98 |
$objSafebox -> Close(); |
| 99 |
} |
| 100 |
else |
| 101 |
{ |
| 102 |
$strAgive = ''; |
| 103 |
$strSafebox = ''; |
| 104 |
} |
| 105 |
$smarty -> assign(array("Wareinfo" => WARE_INFO, |
| 106 |
"Aadd" => A_ADD, |
| 107 |
"Ashow" => A_SHOW, |
| 108 |
"Ashow2" => A_SHOW2, |
| 109 |
"Safebox" => $strSafebox, |
| 110 |
"Agive" => $strAgive)); |
| 111 |
|
| 112 |
$_GET['action'] = ''; |
| 113 |
} |
| 114 |
|
| 115 |
$arrMaps = array(MAP1, MAP2, MAP3, MAP4, MAP5, MAP6, MAP7); |
| 116 |
$arrMaps2 = array(MAP1, MAP2, MAP3, MAP4, MAP5, MAP6, MAP7); |
| 117 |
$arrPlans = array(PLAN1, PLAN2, PLAN3, PLAN4, PLAN5); |
| 118 |
$arrPlans2 = array(PLAN1, PLAN2, PLAN3, PLAN4, PLAN5); |
| 119 |
$arrRecipes = array(RECIPE1, RECIPE2, RECIPE3, RECIPE4, RECIPE5); |
| 120 |
$arrRecipes2 = array(RECIPE1, RECIPE2, RECIPE3, RECIPE4, RECIPE5); |
| 121 |
$arrFormulas = array(FORMULA1, FORMULA2, FORMULA3, FORMULA4, FORMULA5); |
| 122 |
$arrFormulas2 = array(FORMULA1, FORMULA2, FORMULA3, FORMULA4, FORMULA5); |
| 123 |
$arrCompnames = array(array(COMP1, COMP2, COMP3, COMP4, COMP5, COMP6, COMP7), |
| 124 |
array(CONST1, CONST2, CONST3, CONST4, CONST5), |
| 125 |
array(POTION1, POTION2, POTION3, POTION4, POTION5), |
| 126 |
array(JEWELLERY1, JEWELLERY2, JEWELLERY3, JEWELLERY4, JEWELLERY5)); |
| 127 |
|
| 128 |
/** |
| 129 |
* View astral components |
| 130 |
*/ |
| 131 |
if (isset($_GET['action']) && $_GET['action'] == 'view') |
| 132 |
{ |
| 133 |
if (!isset($_GET['type'])) |
| 134 |
{ |
| 135 |
error(ERROR); |
| 136 |
} |
| 137 |
|
| 138 |
$smarty -> assign("Type", $_GET['type']); |
| 139 |
|
| 140 |
/** |
| 141 |
* List of maps, plans, recipes |
| 142 |
*/ |
| 143 |
if (isset($_GET['type']) && $_GET['type'] == 'p') |
| 144 |
{ |
| 145 |
require_once('includes/astralvault.php'); |
| 146 |
|
| 147 |
$strMessage = ''; |
| 148 |
|
| 149 |
/** |
| 150 |
* Merge plans, maps, recipes |
| 151 |
*/ |
| 152 |
if (isset($_GET['step'])) |
| 153 |
{ |
| 154 |
if ($player -> id == $objOwner -> fields['owner'] || $objPerm -> fields['astralvault']) |
| 155 |
{ |
| 156 |
showastral('C', '', $player -> tribe); |
| 157 |
mergeplans('C', $player -> tribe); |
| 158 |
$strMessage = YOU_MERGE; |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
showastral('C', 'tribeastral.php?action=view&type=p', $player -> tribe); |
| 163 |
|
| 164 |
$smarty -> assign(array("Tname" => T_NAME, |
| 165 |
"Tmaps" => T_MAPS, |
| 166 |
"Tplans" => T_PLANS, |
| 167 |
"Trecipes" => T_RECIPES, |
| 168 |
"Tformulas" => T_FORMULAS, |
| 169 |
"Tmaps2" => T_MAPS2, |
| 170 |
"Tplans2" => T_PLANS2, |
| 171 |
"Trecipes2" => T_RECIPES2, |
| 172 |
"Tformulas2" => T_FORMULAS2, |
| 173 |
"Mapsname" => $arrMaps, |
| 174 |
"Plansname" => $arrPlans, |
| 175 |
"Recipesname" => $arrRecipes, |
| 176 |
"Formulasname" => $arrFormulas, |
| 177 |
"Mapsname2" => $arrMaps2, |
| 178 |
"Plansname2" => $arrPlans2, |
| 179 |
"Recipesname2" => $arrRecipes2, |
| 180 |
"Formulasname2" => $arrFormulas2, |
| 181 |
"Mapsamount" => $arrMapsamount, |
| 182 |
"Plansamount" => $arrPlansamount, |
| 183 |
"Recipesamount" => $arrRecipesamount, |
| 184 |
"Formulasamount" => $arrFormulasamount, |
| 185 |
"Mapsamount2" => $arrCmapsamount, |
| 186 |
"Plansamount2" => $arrCplansamount, |
| 187 |
"Recipesamount2" => $arrCrecipesamount, |
| 188 |
"Formulasamount2" => $arrCformulasamount, |
| 189 |
"Message" => $strMessage)); |
| 190 |
} |
| 191 |
|
| 192 |
/** |
| 193 |
* List of components, constructions, potions |
| 194 |
*/ |
| 195 |
if (isset($_GET['type']) && $_GET['type'] == 'c') |
| 196 |
{ |
| 197 |
$arrCompnames2 = array(MAGICCOMP, MAGICCONST, MAGICPOTIONS, MAGICJEWELLERY); |
| 198 |
|
| 199 |
require_once('includes/astralvault.php'); |
| 200 |
|
| 201 |
$arrComponents = showcomponents('C', $player -> tribe); |
| 202 |
|
| 203 |
$smarty -> assign(array("Tname" => T_NAME, |
| 204 |
"Tmagic" => $arrCompnames2, |
| 205 |
"Tcomp" => $arrCompnames, |
| 206 |
"Components" => $arrComponents)); |
| 207 |
} |
| 208 |
} |
| 209 |
|
| 210 |
/** |
| 211 |
* Give astral components to clan |
| 212 |
*/ |
| 213 |
if (isset($_GET['action']) && $_GET['action'] == 'add') |
| 214 |
{ |
| 215 |
$arrNames = array_merge($arrMaps, $arrPlans, $arrRecipes, $arrFormulas); |
| 216 |
$arrNames2 = array_merge($arrCompnames[0], $arrCompnames[1], $arrCompnames[2], $arrCompnames[3]); |
| 217 |
$smarty -> assign(array("Addto" => ADD_TO, |
| 218 |
"Piecenumber" => PIECE_NUMBER, |
| 219 |
"Astralamount" => ASTRAL_AMOUNT, |
| 220 |
"Aadd" => A_ADD, |
| 221 |
"Addto2" => ADD_TO2, |
| 222 |
"Inames" => $arrNames, |
| 223 |
"Inames2" => $arrNames2, |
| 224 |
"Message" => '')); |
| 225 |
/** |
| 226 |
* Add component to clan |
| 227 |
*/ |
| 228 |
if (isset($_GET['step']) && ($_GET['step'] == 'piece' || $_GET['step'] == 'component')) |
| 229 |
{ |
| 230 |
integercheck($_POST['amount']); |
| 231 |
if (!ereg("^[1-9][0-9]*$", $_POST['amount']) || !ereg("^[0-9]*$", $_POST['name']) || !ereg("^[1-9][0-9]*$", $_POST['number'])) |
| 232 |
{ |
| 233 |
error(ERROR); |
| 234 |
} |
| 235 |
$intCompname = $_POST['name']; |
| 236 |
if ($_GET['step'] == 'piece') |
| 237 |
{ |
| 238 |
if ($_POST['name'] < 7) |
| 239 |
{ |
| 240 |
$strName = 'M'; |
| 241 |
} |
| 242 |
if ($_POST['name'] > 6 && $_POST['name'] < 12) |
| 243 |
{ |
| 244 |
$strName = 'P'; |
| 245 |
} |
| 246 |
if ($_POST['name'] > 11 && $_POST['name'] < 17) |
| 247 |
{ |
| 248 |
$strName = 'R'; |
| 249 |
} |
| 250 |
if ($_POST['name'] > 16) |
| 251 |
{ |
| 252 |
$strName = 'Y'; |
| 253 |
} |
| 254 |
$strType = PIECE; |
| 255 |
$strCompname = $arrNames[$intCompname]; |
| 256 |
} |
| 257 |
else |
| 258 |
{ |
| 259 |
if ($_POST['name'] < 7) |
| 260 |
{ |
| 261 |
$strName = 'C'; |
| 262 |
} |
| 263 |
if ($_POST['name'] > 6 && $_POST['name'] < 12) |
| 264 |
{ |
| 265 |
$strName = 'O'; |
| 266 |
} |
| 267 |
if ($_POST['name'] > 11 && $_POST['name'] <17 ) |
| 268 |
{ |
| 269 |
$strName = 'T'; |
| 270 |
} |
| 271 |
if ($_POST['name'] > 16 ) |
| 272 |
{ |
| 273 |
$strName = 'J'; |
| 274 |
} |
| 275 |
$strType = COMPONENT; |
| 276 |
$strCompname = $arrNames2[$intCompname]; |
| 277 |
} |
| 278 |
$arrNumber = array(0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4); |
| 279 |
$strPiecename = $strName.$arrNumber[$_POST['name']]; |
| 280 |
$intNumber = $_POST['number'] - 1; |
| 281 |
$objAmount = $db -> Execute("SELECT `amount` FROM `astral` WHERE `owner`=".$player -> id." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='V'") or die($db -> ErrorMsg()); |
| 282 |
if (!$objAmount -> fields['amount']) |
| 283 |
{ |
| 284 |
error(NO_AMOUNT); |
| 285 |
} |
| 286 |
if ($objAmount -> fields['amount'] < $_POST['amount']) |
| 287 |
{ |
| 288 |
error(NO_AMOUNT); |
| 289 |
} |
| 290 |
$objTest = $db -> Execute("SELECT `amount` FROM `astral` WHERE `owner`=".$player -> tribe." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='C'"); |
| 291 |
if (!$objTest -> fields['amount']) |
| 292 |
{ |
| 293 |
$db -> Execute("INSERT INTO `astral` (`owner`, `type`, `number`, `amount`, `location`) VALUES(".$player -> tribe.", '".$strPiecename."', ".$intNumber.", ".$_POST['amount'].", 'C')"); |
| 294 |
} |
| 295 |
else |
| 296 |
{ |
| 297 |
$db -> Execute("UPDATE `astral` SET `amount`=`amount`+".$_POST['amount']." WHERE `owner`=".$player -> tribe." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='C'"); |
| 298 |
} |
| 299 |
$objTest -> Close(); |
| 300 |
if ($objAmount -> fields['amount'] == $_POST['amount']) |
| 301 |
{ |
| 302 |
$db -> Execute("DELETE FROM `astral` WHERE `owner`=".$player -> id." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='V'"); |
| 303 |
} |
| 304 |
else |
| 305 |
{ |
| 306 |
$db -> Execute("UPDATE `astral` SET `amount`=`amount`-".$_POST['amount']." WHERE `owner`=".$player -> id." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='V'"); |
| 307 |
} |
| 308 |
$objAmount -> Close(); |
| 309 |
|
| 310 |
$strMessage = HE_ADD.$strType.$strCompname.M_AMOUNT.$_POST['amount']."."; |
| 311 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$objOwner -> fields['owner'].", '".T_PLAYER1.'<b><a href="view.php?view="'.$player -> id.'>'.$player -> user.'</a></b>'.T_PLAYER2.'<b>'.$player -> id."</b> ".$strMessage."','".$newdate."')"); |
| 312 |
$objPerm = $db -> Execute("SELECT `player` FROM `tribe_perm` WHERE `tribe`=".$player -> tribe." AND `astralvault`=1"); |
| 313 |
while (!$objPerm -> EOF) |
| 314 |
{ |
| 315 |
$db -> Execute("INSERT INTO log (`owner`, `log`, `czas`) VALUES(".$objPerm -> fields['player'].", '".T_PLAYER1.'<a href="view.php?view="'.$player -> id.'>'.$player -> user.'</a>'.T_PLAYER2.'<b>'.$player -> id."</b> ".$strMessage."','".$newdate."')"); |
| 316 |
$objPerm -> MoveNext(); |
| 317 |
} |
| 318 |
$objPerm -> Close(); |
| 319 |
$strMessage2 = YOU_ADD.$strType.$strCompname.M_AMOUNT.$_POST['amount']."."; |
| 320 |
$smarty -> assign("Message", $strMessage2); |
| 321 |
require_once('includes/checkastral.php'); |
| 322 |
checkastral($player -> tribe); |
| 323 |
} |
| 324 |
} |
| 325 |
|
| 326 |
/** |
| 327 |
* Give astral components to player |
| 328 |
*/ |
| 329 |
if (isset($_GET['action']) && $_GET['action'] == 'give') |
| 330 |
{ |
| 331 |
if ($player -> id != $objOwner -> fields['owner'] && !$objPerm -> fields['astralvault']) |
| 332 |
{ |
| 333 |
error(NO_PERM); |
| 334 |
} |
| 335 |
$arrNames = array_merge($arrMaps, $arrPlans, $arrRecipes, $arrFormulas); |
| 336 |
$arrNames2 = array_merge($arrCompnames[0], $arrCompnames[1], $arrCompnames[2], $arrCompnames[3]); |
| 337 |
$smarty -> assign(array("Addto" => ADD_TO, |
| 338 |
"Piecenumber" => PIECE_NUMBER, |
| 339 |
"Astralamount" => ASTRAL_AMOUNT, |
| 340 |
"Agive" => A_GIVE, |
| 341 |
"Inames" => $arrNames, |
| 342 |
"Inames2" => $arrNames2, |
| 343 |
"Addto2" => ADD_TO2, |
| 344 |
"Addto3" => ADD_TO3, |
| 345 |
"Message" => '')); |
| 346 |
/** |
| 347 |
* Give piece of component to player |
| 348 |
*/ |
| 349 |
if (isset($_GET['step']) && ($_GET['step'] == 'piece' || $_GET['step'] == 'component')) |
| 350 |
{ |
| 351 |
integercheck($_POST['amount']); |
| 352 |
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'])) |
| 353 |
{ |
| 354 |
error(ERROR); |
| 355 |
} |
| 356 |
$objDonated = $db -> Execute("SELECT `id` FROM `players` WHERE `id`=".$_POST['pid']); |
| 357 |
if (empty ($objDonated -> fields['id'])) |
| 358 |
{ |
| 359 |
error(NO_PLAYER); |
| 360 |
} |
| 361 |
$objDonated -> Close(); |
| 362 |
$intCompname = $_POST['name']; |
| 363 |
if ($_GET['step'] == 'piece') |
| 364 |
{ |
| 365 |
if ($_POST['name'] < 7) |
| 366 |
{ |
| 367 |
$strName = 'M'; |
| 368 |
} |
| 369 |
if ($_POST['name'] > 6 && $_POST['name'] < 12) |
| 370 |
{ |
| 371 |
$strName = 'P'; |
| 372 |
} |
| 373 |
if ($_POST['name'] > 11 && $_POST['name'] <17) |
| 374 |
{ |
| 375 |
$strName = 'R'; |
| 376 |
} |
| 377 |
if ($_POST['name'] > 16 ) |
| 378 |
{ |
| 379 |
$strName = 'Y'; |
| 380 |
} |
| 381 |
$strType = PIECE; |
| 382 |
$strCompname = $arrNames[$intCompname]; |
| 383 |
} |
| 384 |
else |
| 385 |
{ |
| 386 |
if ($_POST['name'] < 7) |
| 387 |
{ |
| 388 |
$strName = 'C'; |
| 389 |
} |
| 390 |
if ($_POST['name'] > 6 && $_POST['name'] < 12) |
| 391 |
{ |
| 392 |
$strName = 'O'; |
| 393 |
} |
| 394 |
if ($_POST['name'] > 11 && $_POST['name'] <17) |
| 395 |
{ |
| 396 |
$strName = 'T'; |
| 397 |
} |
| 398 |
if ($_POST['name'] > 16 ) |
| 399 |
{ |
| 400 |
$strName = 'J'; |
| 401 |
} |
| 402 |
$strType = COMPONENT; |
| 403 |
$strCompname = $arrNames2[$intCompname]; |
| 404 |
} |
| 405 |
$arrNumber = array(0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4); |
| 406 |
$strPiecename = $strName.$arrNumber[$_POST['name']]; |
| 407 |
$intNumber = $_POST['number'] - 1; |
| 408 |
$objAmount = $db -> Execute("SELECT `amount` FROM `astral` WHERE `owner`=".$player -> tribe." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='C'") or die($db -> ErrorMsg()); |
| 409 |
if (!$objAmount -> fields['amount']) |
| 410 |
{ |
| 411 |
error(NO_AMOUNT); |
| 412 |
} |
| 413 |
if ($objAmount -> fields['amount'] < $_POST['amount']) |
| 414 |
{ |
| 415 |
error(NO_AMOUNT); |
| 416 |
} |
| 417 |
$objTest = $db -> Execute("SELECT `amount` FROM `astral` WHERE `owner`=".$_POST['pid']." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='V'"); |
| 418 |
if (!$objTest -> fields['amount']) |
| 419 |
{ |
| 420 |
$db -> Execute("INSERT INTO `astral` (`owner`, `type`, `number`, `amount`, `location`) VALUES(".$_POST['pid'].", '".$strPiecename."', ".$intNumber.", ".$_POST['amount'].", 'V')"); |
| 421 |
} |
| 422 |
else |
| 423 |
{ |
| 424 |
$db -> Execute("UPDATE `astral` SET `amount`=`amount`+".$_POST['amount']." WHERE `owner`=".$_POST['pid']." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='V'"); |
| 425 |
} |
| 426 |
$objTest -> Close(); |
| 427 |
if ($objAmount -> fields['amount'] == $_POST['amount']) |
| 428 |
{ |
| 429 |
$db -> Execute("DELETE FROM `astral` WHERE `owner`=".$player -> tribe." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='C'"); |
| 430 |
} |
| 431 |
else |
| 432 |
{ |
| 433 |
$db -> Execute("UPDATE `astral` SET `amount`=`amount`-".$_POST['amount']." WHERE `owner`=".$player -> tribe." AND `type`='".$strPiecename."' AND `number`=".$intNumber." AND `location`='C'"); |
| 434 |
} |
| 435 |
$objAmount -> Close(); |
| 436 |
// Get name of the person which receives astral component. |
| 437 |
$objGetName = $db -> Execute("SELECT `user` FROM `players` WHERE `id`=".$_POST['pid'].';'); |
| 438 |
$strReceiversName = $objGetName -> fields['user']; |
| 439 |
$objGetName -> Close(); |
| 440 |
unset( $objGetName ); |
| 441 |
// Get name of the person which receives astral component. |
| 442 |
|
| 443 |
$strMessage = YOU_GIVE.$strType.$strCompname.M_AMOUNT.$_POST['amount'].TO_PLAYER1.'<b><a href="view.php?view='.$_POST['pid'].'">'.$strReceiversName.'</a></b>'.TO_PLAYER2.'<b>'.$_POST['pid']."</b>."; |
| 444 |
$strMessage2 = YOU_GET.$strType.$strCompname.M_AMOUNT.$_POST['amount']."."; |
| 445 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$_POST['pid'].", '".$strMessage2."','".$newdate."')"); |
| 446 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$objOwner -> fields['owner'].", '".$strMessage."','".$newdate."')"); |
| 447 |
$objPerm = $db -> Execute("SELECT `player` FROM `tribe_perm` WHERE `tribe`=".$player -> tribe." AND `astralvault`=1"); |
| 448 |
while (!$objPerm -> EOF) |
| 449 |
{ |
| 450 |
$db -> Execute("INSERT INTO log (`owner`, `log`, `czas`) VALUES(".$objPerm -> fields['player'].", '".$strMessage."','".$newdate."')"); |
| 451 |
$objPerm -> MoveNext(); |
| 452 |
} |
| 453 |
$objPerm -> Close(); |
| 454 |
$smarty -> assign("Message", $strMessage); |
| 455 |
require_once('includes/checkastral.php'); |
| 456 |
checkastral($player -> tribe); |
| 457 |
} |
| 458 |
/** |
| 459 |
* Give component to player |
| 460 |
*/ |
| 461 |
if (isset($_GET['step']) && $_GET['step'] == 'all') |
| 462 |
{ |
| 463 |
integercheck($_POST['amount']); |
| 464 |
if (!ereg("^[1-9][0-9]*$", $_POST['amount']) || !ereg("^[0-9]*$", $_POST['name']) || !ereg("^[0-9]*$", $_POST['pid'])) |
| 465 |
{ |
| 466 |
error(ERROR); |
| 467 |
} |
| 468 |
$objDonated = $db -> Execute("SELECT `id` FROM `players` WHERE `id`=".$_POST['pid']); |
| 469 |
if (empty ($objDonated -> fields['id'])) |
| 470 |
{ |
| 471 |
error(NO_PLAYER); |
| 472 |
} |
| 473 |
$objDonated -> Close(); |
| 474 |
if ($_POST['name'] < 7) |
| 475 |
{ |
| 476 |
$strName = 'M'; |
| 477 |
} |
| 478 |
if ($_POST['name'] > 6 && $_POST['name'] < 12) |
| 479 |
{ |
| 480 |
$strName = 'P'; |
| 481 |
} |
| 482 |
if ($_POST['name'] > 11 && $_POST['name'] < 17) |
| 483 |
{ |
| 484 |
$strName = 'R'; |
| 485 |
} |
| 486 |
if ($_POST['name'] > 16) |
| 487 |
{ |
| 488 |
$strName = 'Y'; |
| 489 |
} |
| 490 |
$intCompname = $_POST['name']; |
| 491 |
$strType = COMPONENT; |
| 492 |
$strCompname = $arrNames[$intCompname]; |
| 493 |
$arrNumber = array(1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5); |
| 494 |
$strPiecename = $strName.$arrNumber[$_POST['name']]; |
| 495 |
$objAmount = $db -> Execute("SELECT `amount` FROM `astral_plans` WHERE `owner`=".$player -> tribe." AND `name`='".$strPiecename."' AND `location`='C'") or die($db -> ErrorMsg()); |
| 496 |
if (!$objAmount -> fields['amount']) |
| 497 |
{ |
| 498 |
error(NO_AMOUNT); |
| 499 |
} |
| 500 |
if ($objAmount -> fields['amount'] < $_POST['amount']) |
| 501 |
{ |
| 502 |
error(NO_AMOUNT); |
| 503 |
} |
| 504 |
$objTest = $db -> Execute("SELECT `amount` FROM `astral_plans` WHERE `owner`=".$_POST['pid']." AND `name`='".$strPiecename."' AND `location`='V'"); |
| 505 |
if (!$objTest -> fields['amount']) |
| 506 |
{ |
| 507 |
$db -> Execute("INSERT INTO `astral_plans` (`owner`, `name`, `amount`, `location`) VALUES(".$_POST['pid'].", '".$strPiecename."', ".$_POST['amount'].", 'V')"); |
| 508 |
} |
| 509 |
else |
| 510 |
{ |
| 511 |
$db -> Execute("UPDATE `astral_plans` SET `amount`=`amount`+".$_POST['amount']." WHERE `owner`=".$_POST['pid']." AND `name`='".$strPiecename."' AND `location`='V'"); |
| 512 |
} |
| 513 |
$objTest -> Close(); |
| 514 |
if ($objAmount -> fields['amount'] == $_POST['amount']) |
| 515 |
{ |
| 516 |
$db -> Execute("DELETE FROM `astral_plans` WHERE `owner`=".$player -> tribe." AND `name`='".$strPiecename."' AND `location`='C'"); |
| 517 |
} |
| 518 |
else |
| 519 |
{ |
| 520 |
$db -> Execute("UPDATE `astral_plans` SET `amount`=`amount`-".$_POST['amount']." WHERE `owner`=".$player -> tribe." AND `name`='".$strPiecename."' AND `location`='C'"); |
| 521 |
} |
| 522 |
$objAmount -> Close(); |
| 523 |
// Get name of the person which receives astral component. |
| 524 |
$objGetName = $db -> Execute("SELECT `user` FROM `players` WHERE `id`=".$_POST['pid'].';'); |
| 525 |
$strReceiversName = $objGetName -> fields['user']; |
| 526 |
$objGetName -> Close(); |
| 527 |
unset( $objGetName ); |
| 528 |
|
| 529 |
$strMessage = YOU_GIVE.$strType.$strCompname.M_AMOUNT.$_POST['amount'].TO_PLAYER1.'<b><a href="view.php?view='.$_POST['pid'].'">'.$strReceiversName.'</a></b>'.TO_PLAYER2.'<b>'.$_POST['pid']."</b>."; |
| 530 |
$strMessage2 = YOU_GET.$strType.$strCompname.M_AMOUNT.$_POST['amount']."."; |
| 531 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$_POST['pid'].", '".$strMessage2."','".$newdate."')"); |
| 532 |
$db -> Execute("INSERT INTO `log` (`owner`, `log`, `czas`) VALUES(".$objOwner -> fields['owner'].", '".$strMessage."','".$newdate."')"); |
| 533 |
$objPerm = $db -> Execute("SELECT `player` FROM `tribe_perm` WHERE `tribe`=".$player -> tribe." AND `astralvault`=1"); |
| 534 |
while (!$objPerm -> EOF) |
| 535 |
{ |
| 536 |
$db -> Execute("INSERT INTO log (`owner`, `log`, `czas`) VALUES(".$objPerm -> fields['player'].", '".$strMessage."','".$newdate."')"); |
| 537 |
$objPerm -> MoveNext(); |
| 538 |
} |
| 539 |
$objPerm -> Close(); |
| 540 |
$smarty -> assign("Message", $strMessage); |
| 541 |
} |
| 542 |
} |
| 543 |
|
| 544 |
/** |
| 545 |
* Buy safe box for astral components |
| 546 |
*/ |
| 547 |
if (isset($_GET['action']) && $_GET['action'] == 'safe') |
| 548 |
{ |
| 549 |
if ($player -> id != $objOwner -> fields['owner'] && !$objPerm -> fields['astralvault']) |
| 550 |
{ |
| 551 |
error(NO_PERM); |
| 552 |
} |
| 553 |
$objSafebox = $db -> Execute("SELECT `level` FROM `astral_bank` WHERE `owner`=".$player -> tribe." AND `location`='C'"); |
| 554 |
if ($objSafebox -> fields['level'] != 3) |
| 555 |
{ |
| 556 |
if (!$objSafebox -> fields['level']) |
| 557 |
{ |
| 558 |
$objSafebox -> fields['level'] = 0; |
| 559 |
} |
| 560 |
$arrSafeneed = array(array(200000, 200, 100, 0, 0), |
| 561 |
array(400000, 400, 200, 100, 0), |
| 562 |
array(800000, 800, 400, 200, 100)); |
| 563 |
$intKey = $objSafebox -> fields['level']; |
| 564 |
$objTribe = $db -> Execute("SELECT `credits`, `platinum` FROM `tribes` WHERE `id`=".$player -> tribe); |
| 565 |
if ($objTribe -> fields['credits'] < $arrSafeneed[$intKey][0]) |
| 566 |
{ |
| 567 |
error(NO_MONEY); |
| 568 |
} |
| 569 |
if ($objTribe -> fields['platinum'] < $arrSafeneed[$intKey][1]) |
| 570 |
{ |
| 571 |
error(NO_MITHRIL); |
| 572 |
} |
| 573 |
$objTribe -> Close(); |
| 574 |
$objMinerals = $db -> Execute("SELECT `crystal`, `adamantium`, `meteor` FROM `tribes` WHERE `id`=".$player -> tribe); |
| 575 |
if ($objMinerals -> fields['adamantium'] < $arrSafeneed[$intKey][2]) |
| 576 |
{ |
| 577 |
error(NO_MINERAL.ADAMANTIUM."!"); |
| 578 |
} |
| 579 |
if ($objMinerals -> fields['crystal'] < $arrSafeneed[$intKey][3]) |
| 580 |
{ |
| 581 |
error(NO_MINERAL.CRYSTAL."!"); |
| 582 |
} |
| 583 |
if ($objMinerals -> fields['meteor'] < $arrSafeneed[$intKey][4]) |
| 584 |
{ |
| 585 |
error(NO_MINERAL.METEOR."!"); |
| 586 |
} |
| 587 |
$objMinerals -> Close(); |
| 588 |
if (!$objSafebox -> fields['level']) |
| 589 |
{ |
| 590 |
$db -> Execute("INSERT INTO `astral_bank` (`owner`, `level`, `location`) VALUES(".$player -> tribe.", 1, 'C')"); |
| 591 |
} |
| 592 |
else |
| 593 |
{ |
| 594 |
$db -> Execute("UPDATE `astral_bank` SET `level`=`level`+1 WHERE `owner`=".$player -> tribe." AND `location`='C'"); |
| 595 |
} |
| 596 |
$db -> Execute("UPDATE `tribes` SET `credits`=`credits`-".$arrSafeneed[$intKey][0].", `platinum`=`platinum`-".$arrSafeneed[$intKey][1].", `adamantium`=`adamantium`-".$arrSafeneed[$intKey][2].", `crystal`=`crystal`-".$arrSafeneed[$intKey][3].", `meteor`=`meteor`-".$arrSafeneed[$intKey][4]." WHERE `id`=".$player -> tribe); |
| 597 |
error(YOU_UPGRADE); |
| 598 |
} |
| 599 |
else |
| 600 |
{ |
| 601 |
error(SAFE_ENOUGH); |
| 602 |
} |
| 603 |
$objSafebox -> Close(); |
| 604 |
} |
| 605 |
|
| 606 |
/** |
| 607 |
* Assign variables to template and display page |
| 608 |
*/ |
| 609 |
$smarty -> assign(array("Action" =>$_GET['action'], |
| 610 |
"Amain" => A_MAIN, |
| 611 |
"Adonate" => A_DONATE, |
| 612 |
"Amembers" => A_MEMBERS, |
| 613 |
"Apotions" => A_POTIONS, |
| 614 |
"Aminerals" => A_MINERALS, |
| 615 |
"Aherbs" => A_HERBS, |
| 616 |
"Aleft" => A_LEFT, |
| 617 |
"Aleader" => A_LEADER, |
| 618 |
"Aforums" => A_FORUMS, |
| 619 |
"Aarmor" => A_ARMOR, |
| 620 |
"Aastral" => A_ASTRAL)); |
| 621 |
$smarty -> display('tribeastral.tpl'); |
| 622 |
|
| 623 |
require_once("includes/foot.php"); |
| 624 |
?> |