| 1 |
<?php |
| 2 |
/** |
| 3 |
* File functions: |
| 4 |
* Tribe magazine - add potions to clan, give potions to clan members |
| 5 |
* |
| 6 |
* @name : tribeware.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 : 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: tribeware.php 918 2007-03-03 17:55:42Z thindil $ |
| 32 |
|
| 33 |
$title = "Magazyn klanu"; |
| 34 |
require_once("includes/head.php"); |
| 35 |
|
| 36 |
/** |
| 37 |
* Get the localization for game |
| 38 |
*/ |
| 39 |
require_once("languages/".$player -> lang."/tribeware.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 |
$perm = $db -> Execute("SELECT warehouse FROM tribe_perm WHERE tribe=".$player -> tribe." AND player=".$player -> id); |
| 66 |
$owner = $db -> Execute("SELECT owner FROM tribes WHERE id=".$player -> tribe); |
| 67 |
|
| 68 |
/** |
| 69 |
* Main menu |
| 70 |
*/ |
| 71 |
if (!isset($_GET['step']) && !isset($_GET['daj']) && !isset($_GET['step2']) && !isset($_GET['step3'])) |
| 72 |
{ |
| 73 |
$smarty -> assign(array("Wareinfo" => WARE_INFO, |
| 74 |
"Aadd" => A_ADD, |
| 75 |
"Ashow" => A_SHOW)); |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* Potions list in warehouse |
| 80 |
*/ |
| 81 |
if (isset ($_GET['step']) && $_GET['step'] == 'zobacz') |
| 82 |
{ |
| 83 |
$arrlist = array('id', 'name', 'efect'); |
| 84 |
if (isset($_GET['lista']) && !in_array($_GET['lista'], $arrlist)) |
| 85 |
{ |
| 86 |
error (ERROR); |
| 87 |
} |
| 88 |
$miks = $db -> Execute("SELECT * FROM tribe_mag WHERE owner=".$player -> tribe." ORDER BY ".$_GET['lista']." DESC"); |
| 89 |
if (!$miks -> fields['id']) |
| 90 |
{ |
| 91 |
error(NO_ITEMS); |
| 92 |
} |
| 93 |
$amount = $db -> Execute("SELECT amount FROM tribe_mag WHERE owner=".$player-> tribe); |
| 94 |
$przed = 0; |
| 95 |
while (!$amount -> EOF) |
| 96 |
{ |
| 97 |
$przed = $przed + $amount -> fields['amount']; |
| 98 |
$amount -> MoveNext(); |
| 99 |
} |
| 100 |
$amount -> Close(); |
| 101 |
$arrname = array(); |
| 102 |
$arrefect = array(); |
| 103 |
$arramount = array(); |
| 104 |
$arrlink = array(); |
| 105 |
$i = 0; |
| 106 |
while (!$miks -> EOF) |
| 107 |
{ |
| 108 |
$arrname[$i] = $miks -> fields['name']; |
| 109 |
if ($miks -> fields['type'] != 'A') |
| 110 |
{ |
| 111 |
$arrname[$i] = $arrname[$i]." (moc:".$miks -> fields['power'].")"; |
| 112 |
} |
| 113 |
$arrefect[$i] = $miks -> fields['efect']; |
| 114 |
$arramount[$i] = $miks -> fields['amount']; |
| 115 |
if ($player -> id == $owner -> fields['owner'] || $perm -> fields['warehouse']) |
| 116 |
{ |
| 117 |
$arrlink[$i] = "<td>- <a href=tribeware.php?daj=".$miks -> fields['id'].">".A_GIVE."</a></td>"; |
| 118 |
} |
| 119 |
else |
| 120 |
{ |
| 121 |
$arrlink[$i] = "<td></td>"; |
| 122 |
} |
| 123 |
$miks -> MoveNext(); |
| 124 |
$i = $i + 1; |
| 125 |
} |
| 126 |
$miks -> Close(); |
| 127 |
$smarty -> assign ( array("Amount1" => $przed, |
| 128 |
"Name" => $arrname, |
| 129 |
"Efect" => $arrefect, |
| 130 |
"Amount" => $arramount, |
| 131 |
"Link" => $arrlink, |
| 132 |
"Inware" => IN_WARE, |
| 133 |
"Potions" => POTIONS, |
| 134 |
"Tname" => T_NAME, |
| 135 |
"Tefect" => T_EFECT, |
| 136 |
"Tamount2" => T_AMOUNT2, |
| 137 |
"Toptions" => T_OPTIONS)); |
| 138 |
} |
| 139 |
|
| 140 |
/** |
| 141 |
* Give player potions from tribe warehouse |
| 142 |
*/ |
| 143 |
if (isset ($_GET['daj'])) |
| 144 |
{ |
| 145 |
if (!isset ($_GET['step3'])) |
| 146 |
{ |
| 147 |
$miks = $db -> Execute("SELECT * FROM tribe_mag WHERE id=".$_GET['daj']); |
| 148 |
$smarty -> assign ( array("Id" => $_GET['daj'], |
| 149 |
"Name" => $miks -> fields['name'], |
| 150 |
"Amount" => $miks -> fields['amount'], |
| 151 |
"Agive" => A_GIVE, |
| 152 |
"Playerid" => PLAYER_ID, |
| 153 |
"Tamount" => T_AMOUNT)); |
| 154 |
$miks -> Close(); |
| 155 |
} |
| 156 |
if (isset ($_GET['step3']) && $_GET['step3'] == 'add') |
| 157 |
{ |
| 158 |
integercheck($_POST['amount']); |
| 159 |
if (!ereg("^[1-9][0-9]*$", $_POST['did']) || !ereg("^[1-9][0-9]*$", $_POST['amount'])) |
| 160 |
{ |
| 161 |
error (ERROR); |
| 162 |
} |
| 163 |
$dtrib = $db -> Execute("SELECT tribe FROM players WHERE id=".$_POST['did']); |
| 164 |
if ($dtrib -> fields['tribe'] != $player -> tribe) |
| 165 |
{ |
| 166 |
error (NOT_IN_CLAN); |
| 167 |
} |
| 168 |
$dtrib -> Close(); |
| 169 |
$zbroj = $db -> Execute("SELECT * FROM tribe_mag WHERE id=".$_GET['daj']); |
| 170 |
if ($zbroj -> fields['amount'] < $_POST['amount']) |
| 171 |
{ |
| 172 |
error (NO_ITEMS); |
| 173 |
} |
| 174 |
$test = $db -> Execute("SELECT id FROM potions WHERE name='".$zbroj -> fields['name']."' AND owner=".$_POST['did']." AND status='K' AND power=".$zbroj -> fields['power']); |
| 175 |
if (!$test -> fields['id']) |
| 176 |
{ |
| 177 |
$db -> Execute("INSERT INTO potions (name, owner, efect, type, power, status, amount) VALUES('".$zbroj -> fields['name']."',".$_POST['did'].",'".$zbroj -> fields['efect']."','".$zbroj -> fields['type']."',".$zbroj -> fields['power'].",'K',".$_POST['amount'].")"); |
| 178 |
} |
| 179 |
else |
| 180 |
{ |
| 181 |
$db -> Execute("UPDATE potions SET amount=amount+".$_POST['amount']." WHERE id=".$test -> fields['id']); |
| 182 |
} |
| 183 |
$test -> Close(); |
| 184 |
if ($_POST['amount'] < $zbroj -> fields['amount']) |
| 185 |
{ |
| 186 |
$db -> Execute("UPDATE tribe_mag SET amount=amount-".$_POST['amount']." WHERE id=".$zbroj -> fields['id']); |
| 187 |
} |
| 188 |
else |
| 189 |
{ |
| 190 |
$db -> Execute("DELETE FROM tribe_mag WHERE id=".$zbroj -> fields['id']); |
| 191 |
} |
| 192 |
|
| 193 |
// Get name of the person that receives potions. |
| 194 |
$objGetName = $db -> Execute("SELECT `user` FROM `players` WHERE `id`=".$_POST['did'].';'); |
| 195 |
$strReceiversName = $objGetName -> fields['user']; |
| 196 |
$objGetName -> Close(); |
| 197 |
unset( $objGetName ); |
| 198 |
|
| 199 |
$smarty -> assign ("Message", YOU_GIVE1.'<b><a href="view.php?view='.$_POST['did'].'">'.$strReceiversName.'</a></b>'.YOU_GIVE2.'<b>'.$_POST['did']."</b> ".$_POST['amount'].T_AMOUNT.$zbroj -> fields['name']); |
| 200 |
$strDate = $db -> DBDate($newdate); |
| 201 |
$db -> Execute("INSERT INTO log (owner,log, czas) VALUES(".$_POST['did'].", '".YOU_GET.$_POST['amount'].T_AMOUNT.$zbroj -> fields['name'].".', ".$strDate.")"); |
| 202 |
$objPerm = $db -> Execute("SELECT player FROM tribe_perm WHERE tribe=".$player -> tribe." AND warehouse=1"); |
| 203 |
while (!$objPerm -> EOF) |
| 204 |
{ |
| 205 |
$db -> Execute("INSERT INTO log (owner,log, czas) VALUES(".$objPerm -> fields['player'].", '".YOU_GIVE1.'<b><a href="view.php?view='.$_POST['did'].'">'.$strReceiversName.'</a></b>'.YOU_GIVE2.'<b>'.$_POST['did']."</b> ".$_POST['amount'].T_AMOUNT.$zbroj -> fields['name'].".', ".$strDate.")"); |
| 206 |
$objPerm -> MoveNext(); |
| 207 |
} |
| 208 |
$objPerm -> Close(); |
| 209 |
$zbroj -> Close(); |
| 210 |
} |
| 211 |
} |
| 212 |
|
| 213 |
/** |
| 214 |
* Add potions to tribe warehouse |
| 215 |
*/ |
| 216 |
if (isset ($_GET['step']) && $_GET['step'] == 'daj') |
| 217 |
{ |
| 218 |
$miks = $db -> Execute("SELECT * FROM potions WHERE status='K' AND owner=".$player -> id); |
| 219 |
$arrid = array(); |
| 220 |
$arrname = array(); |
| 221 |
$arramount = array(); |
| 222 |
$i = 0; |
| 223 |
while (!$miks -> EOF) |
| 224 |
{ |
| 225 |
$arrid[$i] = $miks -> fields['id']; |
| 226 |
$arrname[$i] = $miks -> fields['name']; |
| 227 |
$arramount[$i] = $miks -> fields['amount']; |
| 228 |
$miks -> MoveNext(); |
| 229 |
$i = $i + 1; |
| 230 |
} |
| 231 |
$miks -> Close(); |
| 232 |
$smarty -> assign( array("Itemid" => $arrid, |
| 233 |
"Name" => $arrname, |
| 234 |
"Amount" => $arramount, |
| 235 |
"Additem" => ADD_ITEM, |
| 236 |
"Potion" => POTION, |
| 237 |
"Amount2" => AMOUNT2, |
| 238 |
"Aadd" => A_ADD, |
| 239 |
"Tamount2" => T_AMOUNT2)); |
| 240 |
if (isset ($_GET['step2']) && $_GET['step2'] == 'add') |
| 241 |
{ |
| 242 |
integercheck($_POST['amount']); |
| 243 |
if (!ereg("^[1-9][0-9]*$", $_POST['przedmiot']) || !ereg("^[1-9][0-9]*$", $_POST['amount'])) |
| 244 |
{ |
| 245 |
error (ERROR); |
| 246 |
} |
| 247 |
$przed = $db -> Execute("SELECT * FROM potions WHERE id=".$_POST['przedmiot']); |
| 248 |
if (!$przed -> fields['name']) |
| 249 |
{ |
| 250 |
error (ERROR); |
| 251 |
} |
| 252 |
if ($_POST['amount'] > $przed -> fields['amount']) |
| 253 |
{ |
| 254 |
error (NO_AMOUNT); |
| 255 |
} |
| 256 |
$test = $db -> Execute("SELECT id FROM tribe_mag WHERE name='".$przed -> fields['name']."' AND owner=".$player -> tribe." AND power=".$przed -> fields['power']); |
| 257 |
if (!$test -> fields['id']) |
| 258 |
{ |
| 259 |
$db -> Execute("INSERT INTO tribe_mag (name, owner, efect, type, power, amount) VALUES('".$przed -> fields['name']."',".$player -> tribe.",'".$przed -> fields['efect']."','".$przed -> fields['type']."',".$przed -> fields['power'].",".$_POST['amount'].")"); |
| 260 |
} |
| 261 |
else |
| 262 |
{ |
| 263 |
$db -> Execute("UPDATE tribe_mag SET amount=amount+".$_POST['amount']." WHERE id=".$test -> fields['id']); |
| 264 |
} |
| 265 |
if ($_POST['amount'] < $przed -> fields['amount']) |
| 266 |
{ |
| 267 |
$db -> Execute("UPDATE potions SET amount=amount-".$_POST['amount']." WHERE id=".$przed -> fields['id']); |
| 268 |
} |
| 269 |
else |
| 270 |
{ |
| 271 |
$db -> Execute("DELETE FROM potions WHERE id=".$przed -> fields['id']); |
| 272 |
} |
| 273 |
$smarty -> assign ("Message", YOU_ADD.$_POST['amount'].T_AMOUNT."<b>".$przed -> fields['name'].TO_WARE); |
| 274 |
$strDate = $db -> DBDate($newdate); |
| 275 |
$db -> Execute("INSERT INTO log (owner,log, czas) VALUES(".$owner -> fields['owner'].", '".L_PLAYER."<a href=view.php?view=".$player -> id.">".$player -> user.L_ID.$player -> id.ADD_TO.$_POST['amount'].T_AMOUNT.$przed -> fields['name'].".', ".$strDate.")"); |
| 276 |
$objPerm = $db -> Execute("SELECT player FROM tribe_perm WHERE tribe=".$player -> tribe." AND warehouse=1"); |
| 277 |
while (!$objPerm -> EOF) |
| 278 |
{ |
| 279 |
$db -> Execute("INSERT INTO log (owner,log, czas) VALUES(".$objPerm -> fields['player'].", '".L_PLAYER."<a href=view.php?view=".$player -> id.">".$player -> user.L_ID.$player -> id.ADD_TO.$_POST['amount'].T_AMOUNT.$przed -> fields['name'].".', ".$strDate.")"); |
| 280 |
$objPerm -> MoveNext(); |
| 281 |
} |
| 282 |
$objPerm -> Close(); |
| 283 |
$przed -> Close(); |
| 284 |
} |
| 285 |
} |
| 286 |
|
| 287 |
/** |
| 288 |
* Initialization of variables |
| 289 |
*/ |
| 290 |
if (!isset($_GET['step'])) |
| 291 |
{ |
| 292 |
$_GET['step'] = ''; |
| 293 |
} |
| 294 |
if (!isset($_GET['step2'])) |
| 295 |
{ |
| 296 |
$_GET['step2'] = ''; |
| 297 |
} |
| 298 |
if (!isset($_GET['step3'])) |
| 299 |
{ |
| 300 |
$_GET['step3'] = ''; |
| 301 |
} |
| 302 |
if (!isset($_GET['daj'])) |
| 303 |
{ |
| 304 |
$_GET['daj'] = ''; |
| 305 |
} |
| 306 |
|
| 307 |
/** |
| 308 |
* Assign variables to template and display page |
| 309 |
*/ |
| 310 |
$smarty -> assign(array("Step" =>$_GET['step'], |
| 311 |
"Step2" => $_GET['step2'], |
| 312 |
"Give" => $_GET['daj'], |
| 313 |
"Step3" => $_GET['step3'], |
| 314 |
"Amain" => A_MAIN, |
| 315 |
"Adonate" => A_DONATE, |
| 316 |
"Amembers" => A_MEMBERS, |
| 317 |
"Apotions" => A_POTIONS, |
| 318 |
"Aminerals" => A_MINERALS, |
| 319 |
"Aherbs" => A_HERBS, |
| 320 |
"Aleft" => A_LEFT, |
| 321 |
"Aleader" => A_LEADER, |
| 322 |
"Aforums" => A_FORUMS, |
| 323 |
"Aarmor" => A_ARMOR, |
| 324 |
"Aastral" => A_ASTRAL)); |
| 325 |
$smarty -> display('tribeware.tpl'); |
| 326 |
|
| 327 |
require_once("includes/foot.php"); |
| 328 |
?> |