chavdave26

staff_items.php

Oct 17th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.83 KB | None | 0 0
  1. <?php
  2. include "sglobals.php";
  3. //This contains item stuffs
  4. switch($_GET['action'])
  5. {
  6. case 'newitem': new_item_form(); break;
  7. case 'newitemsub': new_item_submit(); break;
  8. case 'giveitem': give_item_form(); break;
  9. case 'giveitemsub': give_item_submit(); break;
  10. case 'killitem': kill_item_form(); break;
  11. case 'killitemsub': kill_item_submit(); break;
  12. case 'killitemtype': kill_itemtype_form(); break;
  13. case 'killitemtypesub': kill_itemtype_submit(); break;
  14. case 'edititem': edit_item_begin(); break;
  15. case 'edititemform': edit_item_form(); break;
  16. case 'edititemsub': edit_item_sub(); break;
  17. case 'newitemtype': newitemtype(); break;
  18. default: print "Error: This script requires an action."; break;
  19. }
  20. function new_item_form()
  21. {
  22. global $db,$ir,$c;
  23. if($ir['user_level'] > 2)
  24. {
  25. die("403");
  26. }
  27. print "
  28.  
  29.  
  30. <div class='generalinfo_txt'>
  31. <div><img src='images/info_left.jpg' alt='' /></div>
  32. <div class='info_mid'><h2 style='padding-top:10px;'> Add an Item to the Game</h2></div>
  33. <div><img src='images/info_right.jpg' alt='' /></div> </div>
  34. <div class='generalinfo_simple'><br> <br><br>
  35. <form action='staff_items.php?action=newitemsub' method='post'>
  36. Item Name: <input type='text' STYLE='color: black; background-color: white;' name='itmname' value='' /><br />
  37. Item Desc.: <input type='text' STYLE='color: black; background-color: white;' name='itmdesc' value='' /><br />
  38. Item Type: ".itemtype_dropdown($c,'itmtype')."<br />
  39. Item Buyable: <input type='checkbox' name='itmbuyable' checked='checked' /><br />
  40. Item Price: <input type='text' STYLE='color: black; background-color: white;' name='itmbuyprice' /><br />
  41. Item Sell Value: <input type='text' STYLE='color: black; background-color: white;' name='itmsellprice' /><br />
  42. Picture: <input type='text' name='picture' length='5' maxlength='20' /> <br />
  43. <hr />
  44. <b>Usage Form</b><hr />
  45. <b><u>Effect 1</u></b><br />
  46. On? <input type='radio' name='effect1on' value='1' /> Yes <input type='radio' name='effect1on' value='0' checked='checked' /> No<br />
  47. Stat: <select name='effect1stat' type='dropdown'>
  48. <option value='energy'>Energy</option>
  49. <option value='will'>Will</option>
  50. <option value='brave'>Brave</option>
  51. <option value='hp'>Health</option>
  52. <option value='strength'>Strength</option>
  53. <option value='agility'>Agility</option>
  54. <option value='guard'>Guard</option>
  55. <option value='labour'>Labour</option>
  56. <option value='IQ'>IQ</option>
  57. <option value='hospital'>Hospital Time</option>
  58. <option value='jail'>Jail Time</option>
  59. <option value='money'>Money</option>
  60. <option value='crystals'>Crystals</option>
  61. <option value='cdays'>Education Days Left</option>
  62. <option value='bankmoney'>Bank money</option>
  63. <option value='cybermoney'>Cyber money</option>
  64. <option value='crimexp'>Crime XP</option>
  65. </select> Direction: <select name='effect1dir' type='dropdown'>
  66. <option value='pos'>Increase</option>
  67. <option value='neg'>Decrease</option>
  68. </select><br />
  69. Amount: <input type='text' STYLE='color: black; background-color: white;' name='effect1amount' value='0' /> <select name='effect1type' type='dropdown'>
  70. <option value='figure'>Value</option>
  71. <option value='percent'>Percent</option>
  72. </select><hr />
  73. <b><u>Effect 2</u></b><br />
  74. On? <input type='radio' name='effect2on' value='1' /> Yes <input type='radio' name='effect2on' value='0' checked='checked' /> No<br />
  75. Stat: <select name='effect2stat' type='dropdown'>
  76. <option value='energy'>Energy</option>
  77. <option value='will'>Will</option>
  78. <option value='brave'>Brave</option>
  79. <option value='hp'>Health</option>
  80. <option value='strength'>Strength</option>
  81. <option value='agility'>Agility</option>
  82. <option value='guard'>Guard</option>
  83. <option value='labour'>Labour</option>
  84. <option value='IQ'>IQ</option>
  85. <option value='hospital'>Hospital Time</option>
  86. <option value='jail'>Jail Time</option>
  87. <option value='money'>Money</option>
  88. <option value='crystals'>Crystals</option>
  89. <option value='cdays'>Education Days Left</option>
  90. <option value='bankmoney'>Bank money</option>
  91. <option value='cybermoney'>Cyber money</option>
  92. <option value='crimexp'>Crime XP</option>
  93. </select> Direction: <select name='effect2dir' type='dropdown'>
  94. <option value='pos'>Increase</option>
  95. <option value='neg'>Decrease</option>
  96. </select><br />
  97. Amount: <input type='text' STYLE='color: black; background-color: white;' name='effect2amount' value='0' /> <select name='effect2type' type='dropdown'>
  98. <option value='figure'>Value</option>
  99. <option value='percent'>Percent</option>
  100. </select><hr />
  101. <b><u>Effect 3</u></b><br />
  102. On? <input type='radio' name='effect3on' value='1' /> Yes <input type='radio' name='effect3on' value='0' checked='checked' /> No<br />
  103. Stat: <select name='effect3stat' type='dropdown'>
  104. <option value='energy'>Energy</option>
  105. <option value='will'>Will</option>
  106. <option value='brave'>Brave</option>
  107. <option value='hp'>Health</option>
  108. <option value='strength'>Strength</option>
  109. <option value='agility'>Agility</option>
  110. <option value='guard'>Guard</option>
  111. <option value='labour'>Labour</option>
  112. <option value='IQ'>IQ</option>
  113. <option value='hospital'>Hospital Time</option>
  114. <option value='jail'>Jail Time</option>
  115. <option value='money'>Money</option>
  116. <option value='crystals'>Crystals</option>
  117. <option value='cdays'>Education Days Left</option>
  118. <option value='bankmoney'>Bank money</option>
  119. <option value='cybermoney'>Cyber money</option>
  120. <option value='crimexp'>Crime XP</option>
  121. </select> Direction: <select name='effect3dir' type='dropdown'>
  122. <option value='pos'>Increase</option>
  123. <option value='neg'>Decrease</option>
  124. </select><br />
  125. Amount: <input type='text' STYLE='color: black; background-color: white;' name='effect3amount' value='0' /> <select name='effect3type' type='dropdown'>
  126. <option value='figure'>Value</option>
  127. <option value='percent'>Percent</option>
  128. </select><hr />
  129. <b>Combat Usage</b><br />
  130. Weapon Power: <input type='text' STYLE='color: black; background-color: white;' name='weapon' value='0' /><br />
  131. Armor Defense: <input type='text' STYLE='color: black; background-color: white;' name='armor' value='0' /><hr />
  132. <input type='submit' STYLE='color: black; background-color: white;' value='Add Item To Game' /></form></div><div><img src='images/generalinfo_btm.jpg' alt='' /></div><br></div></div></div></div></div>";
  133. }
  134. function new_item_submit()
  135. {
  136. global $db,$ir,$c,$h;
  137. if($ir['user_level'] > 2)
  138. {
  139. die("403");
  140. }
  141. if(!isset($_POST['itmname']) || !isset($_POST['itmdesc']) || !isset($_POST['itmtype']) || !isset($_POST['itmbuyprice']) || !isset($_POST['itmsellprice']))|| !isset($_POST['picture']))
  142. {
  143. print "You missed one or more of the fields. Please go back and try again.<br />
  144. <a href='staff_items.php?action=newitem'>&gt; Back</a>";
  145. $h->endpage();
  146. exit;
  147. }
  148. $itmname=$db->escape($_POST['itmname']);
  149. $itmdesc=$db->escape($_POST['itmdesc']);
  150. $weapon=abs((int) $_POST['weapon']);
  151. $armor=abs((int) $_POST['armor']);
  152. if($_POST['itmbuyable'] == 'on') { $itmbuy=1; } else { $itmbuy=0; }
  153. $efx1=$db->escape(serialize(array("stat" => $_POST['effect1stat'], "dir" => $_POST['effect1dir'], "inc_type" => $_POST['effect1type'], "inc_amount" => abs((int) $_POST['effect1amount']))));
  154. $efx2=$db->escape(serialize(array("stat" => $_POST['effect2stat'], "dir" => $_POST['effect2dir'], "inc_type" => $_POST['effect2type'], "inc_amount" => abs((int) $_POST['effect2amount']))));
  155. $efx3=$db->escape(serialize(array("stat" => $_POST['effect3stat'], "dir" => $_POST['effect3dir'], "inc_type" => $_POST['effect3type'], "inc_amount" => abs((int) $_POST['effect3amount']))));
  156. $m=$db->query("INSERT INTO items VALUES('',{$_POST['itmtype']},'$itmname','$itmdesc',{$_POST['itmbuyprice']},{$_POST['itmsellprice']},$itmbuy, '{$_POST['effect1on']}', '$efx1', '{$_POST['effect2on']}', '$efx2', '{$_POST['effect3on']}', '$efx3', $weapon, $armor, '{$_POST['picture']}')");
  157. print "The {$_POST['itmname']} Item was added to the game.";
  158. stafflog_add("Created item {$_POST['itmname']}");
  159.  
  160. }
  161. function give_item_form()
  162. {
  163. global $db,$ir,$c;
  164. if($ir['user_level'] > 3)
  165. {
  166. die("403");
  167. }
  168. print "
  169.  
  170. <div class='generalinfo_txt'>
  171. <div><img src='images/info_left.jpg' alt='' /></div>
  172. <div class='info_mid'><h2 style='padding-top:10px;'> Giving Item To User</h2></div>
  173. <div><img src='images/info_right.jpg' alt='' /></div> </div>
  174. <div class='generalinfo_simple'><br> <br><br>
  175.  
  176. <form action='staff_items.php?action=giveitemsub' method='post'>
  177. User: ".user_dropdown($c,'user')."<br />
  178. Item: ".item_dropdown($c,'item')."<br />
  179. Quantity: <input type='text' STYLE='color: black; background-color: white;' name='qty' value='1' /><br />
  180. <input type='submit' STYLE='color: black; background-color: white;' value='Give Item' /></form></div><div><img src='images/generalinfo_btm.jpg' alt='' /></div><br></div></div></div></div></div>";
  181. }
  182. function give_item_submit()
  183. {
  184. global $db,$ir,$c;
  185. if($ir['user_level'] > 3)
  186. {
  187. die("403");
  188. }
  189. $db->query("INSERT INTO inventory VALUES('',{$_POST['item']},{$_POST['user']},{$_POST['qty']})",$c) or die(mysql_error());
  190. print "You gave {$_POST['qty']} of item ID {$_POST['item']} to user ID {$_POST['user']}";
  191. stafflog_add("Gave {$_POST['qty']} of item ID {$_POST['item']} to user ID {$_POST['user']}");
  192. }
  193. function kill_item_form()
  194. {
  195. global $db,$ir,$c,$h,$userid;
  196. if($ir['user_level'] > 2)
  197. {
  198. die("403");
  199. }
  200.  
  201.  
  202. print "
  203.  
  204.  
  205. <div class='generalinfo_txt'>
  206. <div><img src='images/info_left.jpg' alt='' /></div>
  207. <div class='info_mid'><h2 style='padding-top:10px;'> Deleting Item</h2></div>
  208. <div><img src='images/info_right.jpg' alt='' /></div> </div>
  209. <div class='generalinfo_simple'><br> <br><br>
  210.  
  211. The item will be permanently removed from the game.<br />
  212. <form action='staff_items.php?action=killitemsub' method='post'>
  213. Item: ".item_dropdown($c,'item')."<br />
  214. <input type='submit' STYLE='color: black; background-color: white;' value='Kill Item' /></form></div><div><img src='images/generalinfo_btm.jpg' alt='' /></div><br></div></div></div></div></div>";
  215. }
  216. function kill_item_submit()
  217. {
  218. global $db,$ir,$c,$h,$userid;
  219. if($ir['user_level'] > 2)
  220. {
  221. die("403");
  222. }
  223.  
  224. $d=$db->query("SELECT * FROM items WHERE itmid={$_POST['item']}");
  225. $itemi=$db->fetch_row($d);
  226. $db->query("DELETE FROM items WHERE itmid={$_POST['item']}");
  227. $db->query("DELETE FROM shopitems WHERE sitemITEMID={$_POST['item']}");
  228. $db->query("DELETE FROM inventory WHERE inv_itemid={$_POST['item']}");
  229. $db->query("DELETE FROM itemmarket WHERE imITEM={$_POST['item']}");
  230.  
  231. print "The {$itemi['itmname']} Item was removed from the game.";
  232. stafflog_add("Deleted item {$itemi['itmname']}");
  233. }
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240. function kill_itemtype_submit()
  241. {
  242. global $db,$ir,$c,$h,$userid;
  243. if($ir['user_level'] > 2)
  244. {
  245. die("403");
  246. }
  247.  
  248. $d=$db->query("SELECT * FROM itemtypes WHERE itmtypeid={$_POST['itmtype']}");
  249. $itemi=$db->fetch_row($d);
  250. $db->query("DELETE FROM itemtypes WHERE itmtypeid={$_POST['itmtype']}");
  251.  
  252.  
  253. print "The {$itemi['itmtypename']} Item Type was removed from the game.";
  254. stafflog_add("Deleted item type {$itemi['itmtypename']}");
  255. }
  256.  
  257.  
  258.  
  259. function kill_itemtype_form()
  260. {
  261. global $db,$ir,$c,$h,$userid;
  262. if($ir['user_level'] > 2)
  263. {
  264. die("403");
  265. }
  266.  
  267. print "
  268.  
  269.  
  270. <div class='generalinfo_txt'>
  271. <div><img src='images/info_left.jpg' alt='' /></div>
  272. <div class='info_mid'><h2 style='padding-top:10px;'> Deleting Item Type</h2></div>
  273. <div><img src='images/info_right.jpg' alt='' /></div> </div>
  274. <div class='generalinfo_simple'><br> <br><br>
  275.  
  276. The item type will be permanently removed from the game.<br />
  277. <form action='staff_items.php?action=killitemtypesub' method='post'>
  278. Item Type: ".itemtype_dropdown($c,'itmtype')."<br />
  279. <input type='submit' STYLE='color: black; background-color: white;' value='Kill Item' /></form></div><div><img src='images/generalinfo_btm.jpg' alt='' /></div><br></div></div></div></div></div>";
  280. }
  281.  
  282.  
  283.  
  284. function edit_item_begin()
  285. {
  286. global $db,$ir,$c,$h,$userid;
  287. if($ir['user_level'] > 2)
  288. {
  289. die("403");
  290. }
  291.  
  292.  
  293. print "
  294.  
  295.  
  296. <div class='generalinfo_txt'>
  297. <div><img src='images/info_left.jpg' alt='' /></div>
  298. <div class='info_mid'><h2 style='padding-top:10px;'> Editing Item</h2></div>
  299. <div><img src='images/info_right.jpg' alt='' /></div> </div>
  300. <div class='generalinfo_simple'><br> <br><br>
  301.  
  302.  
  303. You can edit any aspect of this item.<br />
  304. <form action='staff_items.php?action=edititemform' method='post'>
  305. Item: ".item_dropdown($c,'item')."<br />
  306. <input type='submit' STYLE='color: black; background-color: white;' value='Edit Item' /></form></div><div><img src='images/generalinfo_btm.jpg' alt='' /></div><br></div></div></div></div></div>";
  307. }
  308. function edit_item_form()
  309. {
  310. global $db,$ir,$c,$h;
  311. if($ir['user_level'] > 2)
  312. {
  313. die("403");
  314. }
  315. $d=$db->query("SELECT * FROM items WHERE itmid={$_POST['item']}");
  316. $itemi=$db->fetch_row($d);
  317. print "
  318.  
  319.  
  320. <div class='generalinfo_txt'>
  321. <div><img src='images/info_left.jpg' alt='' /></div>
  322. <div class='info_mid'><h2 style='padding-top:10px;'> Editing Item</h2></div>
  323. <div><img src='images/info_right.jpg' alt='' /></div> </div>
  324. <div class='generalinfo_simple'><br> <br><br>
  325.  
  326. <form action='staff_items.php?action=edititemsub' method='post'>
  327. <input type='hidden' name='itmid' value='{$_POST['item']}' />
  328. Item Name: <input type='text' STYLE='color: black; background-color: white;' name='itmname' value='{$itemi['itmname']}' /><br />
  329. Item Desc.: <input type='text' STYLE='color: black; background-color: white;' name='itmdesc' value='{$itemi['itmdesc']}' /><br />
  330. Item Type: ".itemtype_dropdown($c,'itmtype',$itemi['itmtype'])."<br />
  331. Item Buyable: <input type='checkbox' name='itmbuyable'";
  332. if ($itemi['itmbuyable']) { print " checked='checked'"; }
  333. print " /><br />Item Price: <input type='text' STYLE='color: black; background-color: white;' name='itmbuyprice' value='{$itemi['itmbuyprice']}' /><br />
  334. Item Sell Value: <input type='text' STYLE='color: black; background-color: white;' name='itmsellprice' value='{$itemi['itmsellprice']}' /><hr /><b>Usage Form</b><hr />";
  335. $stats=array(
  336. "energy" => "Energy",
  337. "will" => "Will",
  338. "brave" => "Brave",
  339. "hp" => "Health",
  340. "strength" => "Strength",
  341. "agility" => "Agility",
  342. "guard" => "Guard",
  343. "labour" => "Labour",
  344. "IQ" => "IQ",
  345. "hospital" => "Hospital Time",
  346. "jail" => "Jail Time",
  347. "money" => "Money",
  348. "crystals" => "Crystals",
  349. "cdays" => "Education Days Left",
  350. "bankmoney" => "Bank money",
  351. "cybermoney" => "Cyber money",
  352. "crimexp" => "Crime XP");
  353. for($i=1;$i<=3;$i++)
  354. {
  355. if($itemi["effect".$i])
  356. {
  357. $efx=unserialize($itemi["effect".$i]);
  358. }
  359. else
  360. {
  361. $efx=array("inc_amount" => 0);
  362. }
  363. $switch1=($itemi['effect'.$i.'_on'] > 0) ? " checked='checked'" : "";
  364. $switch2=($itemi['effect'.$i.'_on'] > 0) ? "" : " checked='checked'";
  365. print "<b><u>Effect {$i}</u></b><br />
  366. On? <input type='radio' name='effect{$i}on' value='1'$switch1 /> Yes <input type='radio' name='effect{$i}on' value='0'$switch2 /> No<br />
  367. Stat: <select name='effect{$i}stat' type='dropdown'>";
  368. foreach($stats as $k => $v)
  369. {
  370. if($k==$efx['stat'])
  371. {
  372. print "<option value='{$k}' selected='selected'>{$v}</option>\n";
  373. }
  374. else
  375. {
  376. print "<option value='$k'>{$v}</option>\n";
  377. }
  378. }
  379. if($efx['dir']=="neg")
  380. {
  381. $str="<option value='pos'>Increase</option><option value='neg' selected='selected'>Decrease</option>";
  382. }
  383. else
  384. {
  385. $str="<option value='pos' selected='selected'>Increase</option><option value='neg'>Decrease</option>";
  386. }
  387. if($efx['inc_type']=="percent")
  388. {
  389. $str2="<option value='figure'>Value</option><option value='percent' selected='selected'>Percent</option>";
  390. }
  391. else
  392. {
  393. $str2="<option value='figure' selected='selected'>Value</option><option value='percent'>Percent</option>";
  394. }
  395. print "</select> Direction: <select name='effect{$i}dir' type='dropdown'>{$str}
  396. </select><br />
  397. Amount: <input type='text' STYLE='color: black; background-color: white;' name='effect{$i}amount' value='{$efx['inc_amount']}' /> <select name='effect{$i}type' type='dropdown'>{$str2}</select><hr />";
  398. }
  399.  
  400. print "<b>Combat Usage</b><br />
  401. Weapon Power: <input type='text' STYLE='color: black; background-color: white;' name='weapon' value='{$itemi['weapon']}' /><br />
  402. Armor Defense: <input type='text' STYLE='color: black; background-color: white;' name='armor' value='{$itemi['armor']}' /><hr />
  403. <input type='submit' STYLE='color: black; background-color: white;' value='Edit Item' /></form> </div><div><img src='images/generalinfo_btm.jpg' alt='' /></div><br></div></div></div></div></div> ";
  404. }
  405. function edit_item_sub()
  406. {
  407. global $db,$ir,$c,$h,$userid;
  408. if($ir['user_level'] > 2)
  409. {
  410. die("403");
  411. }
  412.  
  413. if(!isset($_POST['itmname']) || !isset($_POST['itmdesc']) || !isset($_POST['itmtype']) || !isset($_POST['itmbuyprice']) || !isset($_POST['itmsellprice']))
  414. {
  415. print "You missed one or more of the fields. Please go back and try again.<br />
  416. <a href='staff_items.php?action=edititem'>&gt; Back</a>";
  417. $h->endpage();
  418. exit;
  419. }
  420. $itmname=$_POST['itmname'];
  421. $itmdesc=$_POST['itmdesc'];
  422. $weapon=abs((int) $_POST['weapon']);
  423. $armor=abs((int) $_POST['armor']);
  424. if($_POST['itmbuyable'] == 'on') { $itmbuy=1; } else { $itmbuy=0; }
  425. $db->query("DELETE FROM items WHERE itmid={$_POST['itmid']}",$c);
  426. $efx1=$db->escape(serialize(array("stat" => $_POST['effect1stat'], "dir" => $_POST['effect1dir'], "inc_type" => $_POST['effect1type'], "inc_amount" => abs((int) $_POST['effect1amount']))));
  427. $efx2=$db->escape(serialize(array("stat" => $_POST['effect2stat'], "dir" => $_POST['effect2dir'], "inc_type" => $_POST['effect2type'], "inc_amount" => abs((int) $_POST['effect2amount']))));
  428. $efx3=$db->escape(serialize(array("stat" => $_POST['effect3stat'], "dir" => $_POST['effect3dir'], "inc_type" => $_POST['effect3type'], "inc_amount" => abs((int) $_POST['effect3amount']))));
  429. $m=$db->query("INSERT INTO items VALUES('{$_POST['itmid']}',{$_POST['itmtype']},'$itmname','$itmdesc',{$_POST['itmbuyprice']},{$_POST['itmsellprice']},$itmbuy, '{$_POST['effect1on']}', '$efx1', '{$_POST['effect2on']}', '$efx2', '{$_POST['effect3on']}', '$efx3', $weapon, $armor)");
  430. print "The {$_POST['itmname']} Item was edited successfully.";
  431. stafflog_add("Edited item {$_POST['itmname']}");
  432. }
  433.  
  434. function newitemtype()
  435. {
  436. global $db,$ir,$c,$h,$userid;
  437. if($ir['user_level'] > 2)
  438. {
  439. die("403");
  440. }
  441. if($_POST['name'])
  442. {
  443. $db->query("INSERT INTO itemtypes VALUES(NULL, '{$_POST['name']}')");
  444. print "Item Type {$_POST['name']} added.";
  445. stafflog_add("Added item type {$_POST['name']}");
  446. }
  447. else
  448. {
  449. print "
  450.  
  451.  
  452. <div class='generalinfo_txt'>
  453. <div><img src='images/info_left.jpg' alt='' /></div>
  454. <div class='info_mid'><h2 style='padding-top:10px;'> Add Item Type</h2></div>
  455. <div><img src='images/info_right.jpg' alt='' /></div> </div>
  456. <div class='generalinfo_simple'><br> <br><br>
  457.  
  458.  
  459. <form action='staff_items.php?action=newitemtype' method='post'>
  460. Name: <input type='text' STYLE='color: black; background-color: white;' name='name' /><br />
  461. <input type='submit' STYLE='color: black; background-color: white;' value='Add Item Type' /></form></div><div><img src='images/generalinfo_btm.jpg' alt='' /></div><br></div></div></div></div></div>";
  462. }
  463. }
  464. $h->endpage();
  465. ?>
Advertisement
Add Comment
Please, Sign In to add comment