Advertisement
Guest User

sore

a guest
Dec 8th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.75 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. session_start();
  4. include_once "includes/db_connect.php";
  5. include_once "includes/functions.php";
  6. logincheck();
  7. $username=$_SESSION['username'];
  8.  
  9.  
  10. $fetch= mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));
  11. $bf = mysql_fetch_object(mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"));
  12. $fetch_owner=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$bf->owner'"));
  13.  
  14. ?>
  15.  
  16. <?
  17. if ($site->gupdate == "1"){
  18. echo "<link href='style.css' rel='stylesheet' type='text/css'><center><div class='update'>$site->gupdatetext</div></center>
  19.  
  20. <br>";
  21. }
  22. ?>
  23.  
  24. <link href='style.css' rel='stylesheet' type='text/css'>
  25. <script type="text/javascript" src="/js/select.js"></script>
  26. <style type="text/css">
  27. .select, .selected {
  28. width: 110px;
  29. padding: 10px;
  30. }
  31. </style>
  32. <?php
  33.  
  34. if($_GET['buyfactory']){
  35.  
  36. $bf = mysql_fetch_object(mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"));
  37.  
  38. if($bf->owner == "0"){
  39.  
  40. if($info->money < 25000000){
  41. echo "<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You dont have &pound;25,000,000 to purchase this factory!</td></tr></table>";
  42.  
  43. }else{
  44.  
  45. mysql_query("UPDATE users SET money=money-25000000 WHERE username='$username'");
  46.  
  47. mysql_query("UPDATE bf SET owner='$username' WHERE location='$fetch->location'");
  48. mysql_query("UPDATE bf SET jspprice='4500' WHERE location='$fetch->location'");
  49. mysql_query("UPDATE bf SET fmjprice='4500' WHERE location='$fetch->location'");
  50. mysql_query("UPDATE bf SET profit='0' WHERE location='$fetch->location'");
  51.  
  52. echo" <table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=green>Your now the owner of $fetch->location bullet factory!</td></tr></table>";
  53.  
  54. }}}
  55.  
  56.  
  57. ?>
  58. <?php
  59.  
  60. if($_GET['drop']){
  61.  
  62. $bf = mysql_fetch_object(mysql_query("SELECT * FROM bf WHERE location='$fetch->location' AND owner='$username' LIMIT 1"));
  63.  
  64. if ($bf->owner == $username) {
  65.  
  66. mysql_query("UPDATE bf SET owner='0' WHERE location='$fetch->location'");
  67. mysql_query("UPDATE bf SET jspprice='4500' WHERE location='$fetch->location'");
  68. mysql_query("UPDATE bf SET fmjprice='4500' WHERE location='$fetch->location'");
  69. mysql_query("UPDATE bf SET profit='0' WHERE location='$fetch->location'");
  70.  
  71. echo"<br><div class=success>You have dropped the bullet factory in $fetch->location!<br><br>";
  72.  
  73. }}
  74.  
  75. /////////////////////////////////////////////////////
  76.  
  77.  
  78. if(strip_tags($_POST['submit'])){
  79. $type=$_POST['type'];
  80. $amount=strip_tags($_GET['amount']);
  81.  
  82.  
  83. if($type == "1"){
  84.  
  85. $bf = mysql_fetch_object(mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"));
  86.  
  87. if ($bf->owner == $username) {
  88.  
  89. echo" <table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You cant buy from your own factory!</td></tr></table><br>"; }
  90.  
  91. elseif ($bf->owner != $username) {
  92.  
  93. $amount=intval(strip_tags($_POST['amount']));
  94.  
  95. if ($amount == 0 || !$amount || ereg('[^0-9]',$amount)){
  96.  
  97. print " <table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You cant buy that amount!</td></tr></table><br>";
  98.  
  99. }elseif ($amount != 0 || $amount || !ereg('[^0-9]',$amount)){
  100.  
  101. $costs = $bf->jhpprice * $amount;
  102.  
  103.  
  104. if ($costs > $fetch->money){
  105.  
  106. echo " <table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You do not have enough money!</td></tr></table><br>";
  107.  
  108. }elseif ($costs <= $fetch->money){
  109.  
  110. if ($bf->jhpstock < $amount){
  111.  
  112. echo " <table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>There isn't enough JHP in stock for you to buy that amount!</td></tr></table><br>";
  113.  
  114. }elseif ($amount <= $bf->jhpstock){
  115.  
  116. mysql_query("UPDATE users SET money=money-$costs WHERE username='$username'");
  117.  
  118. mysql_query("UPDATE users SET JHP=JHP+$amount WHERE username='$username'");
  119.  
  120. mysql_query("UPDATE bf SET jhpstock=jhpstock-$amount WHERE location='$fetch->location'");
  121.  
  122. mysql_query("UPDATE bf SET profit=profit+$cost WHERE location='$fetch->location'");
  123.  
  124. mysql_query("UPDATE users SET money=money+$costs WHERE username='$bf->owner'");
  125.  
  126. echo" <table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0>
  127.  
  128. <tr><td class=notice align=center><center><font color=green>You've bought ".makecomma($amount)." JHP for &pound;".makecomma($costs)."!</td></tr></table><br>";
  129.  
  130. }}}}}}
  131.  
  132. /////////////////////////////////////////////////
  133.  
  134. if($type == "2"){
  135.  
  136. $bf = mysql_fetch_object(mysql_query("SELECT * FROM bf WHERE location='$fetch->location'"));
  137.  
  138. if ($bf->owner == $username) {
  139.  
  140. echo" <table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You cant buy from your own factory!</td></tr></table><br>"; }
  141.  
  142. elseif ($bf->owner != $username) {
  143.  
  144. $amount=intval(strip_tags($_POST['amount']));
  145.  
  146. if ($amount == 0 || !$amount || ereg('[^0-9]',$amount)){
  147.  
  148. print " <table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You cant buy that amount!</td></tr></table><br>";
  149.  
  150. }elseif ($amount != 0 || $amount || !ereg('[^0-9]',$amount)){
  151.  
  152. $costs = $bf->fmjprice * $amount;
  153.  
  154. if ($costs > $fetch->money){
  155.  
  156. echo " <table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You do not have enough money!</td></tr></table><br>";
  157.  
  158. }elseif ($costs <= $fetch->money){
  159.  
  160.  
  161. if ($bf->fmjstock < $amount){
  162.  
  163. echo " <table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>There isn't enough FMJ in stock for you to buy that amount!</td></tr></table><br>";
  164.  
  165. }elseif ($amount <= $bf->fmjstock){
  166.  
  167. mysql_query("UPDATE users SET money=money-$costs WHERE username='$username'");
  168.  
  169. mysql_query("UPDATE users SET FMJ=FMJ+$amount WHERE username='$username'");
  170.  
  171. mysql_query("UPDATE bf SET fmjstock=fmjstock-$amount WHERE location='$fetch->location'");
  172.  
  173. mysql_query("UPDATE bf SET profit=profit+$cost WHERE location='$fetch->location'");
  174.  
  175. mysql_query("UPDATE users SET money=money+$costs WHERE username='$bf->owner'");
  176.  
  177. echo" <table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0>
  178.  
  179. <tr><td class=notice align=center><center><font color=green>You've bought ".makecomma($amount)." FMJ for &pound;".makecomma($costs)."!</td></tr></table><br>";
  180.  
  181. }}}}}
  182.  
  183. ?>
  184.  
  185. <?php if($bf->owner == "0"){ echo "<link href='style.css' rel='stylesheet' type='text/css'><table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center>This bullet factory has no owner.<br>
  186. The price to buy this factory is &pound;25,000,000.<br>
  187. <a href=?buyfactory=yes>Buy Bullet Factory</a></td></tr></table><br>";exit; } ?>
  188.  
  189.  
  190. <br>
  191.  
  192. <form action='' method='post'>
  193. <input type="hidden" name="type" id="select" value="0">
  194.  
  195. <table width="400" align="center" cellspacing="0" class="table">
  196. <tr class="header"><td colspan="2">Bullet Factory - Owner: <?php if($bf->owner == "0"){ echo "No Owner"; }else{ echo "Owned by <a href='profile.php?viewuser=$bf->owner'>$bf->owner</a>"; } ?></td></tr>
  197.  
  198. <?php if($bf->producing == "yes"){ ?>
  199. <tr class="subhead"><td colspan="2" align="center">The stock will update in: <?php echo"".maketime($finds_status->bfstocktime).""; ?></td></tr>
  200. <? }else{ ?>
  201. <tr class="subhead"><td colspan="2" align="center">This bullet factory is currently not producing.</td></tr>
  202. <? } ?>
  203.  
  204. <tr><td height="10">&nbsp;</td></tr>
  205.  
  206. <tr><td width='50%' align='center'><div id='1' value='1' class='action select' onclick='SelectOption(this.id, this.className);'><img src='images/items/jhp.png'><br>Jacketed Hollow Point<br>Stock: <?php echo "".number_format($bf->jhpstock).""; ?><br>Cost: <?php echo "&pound;".number_format($bf->jhpprice).""; ?> / per bullet</div></td>
  207.  
  208. <td width='50%' align='center'><div id='2' value='2' class='action select' onclick='SelectOption(this.id, this.className);'><img src='images/items/fmj.png'><br>Full Metal Jacketed<br>Stock: <?php echo "".number_format($bf->fmjstock).""; ?><br>Cost: <?php echo "&pound;".number_format($bf->fmjprice).""; ?> / per bullet</div></td></tr>
  209.  
  210. <tr><td height="10">&nbsp;</td></tr>
  211.  
  212. <?php if($username == $bf->owner){ ?>
  213.  
  214. <tr><td class=notice colspan='5' align=center><center><font color=red>You cannot buy from your own Bullet Factory!</td></tr>
  215.  
  216. <? }else{ ?>
  217.  
  218. <tr><td align='center' colspan='2'>Bullets: <input type="text" name="amount" class="textbox" id="bullets" autocomplete="off" class="input"></td></tr>
  219. <tr><td align='center' colspan='2'><input type='submit' name='submit' class='button' value='Purchase'></td></tr>
  220. </table>
  221.  
  222. <? } ?>
  223. </form>
  224.  
  225. <table align="center">
  226. <tr>
  227. <td>
  228. <table align="center" cellspacing="0" class="table">
  229. <tr>
  230. <td width="25" align="right"><img src='/images/items/jhp.png' width="25"></td>
  231.  
  232. <td>You have <?php echo "".number_format($fetch->JHP).""; ?> JHP!</td>
  233. </tr>
  234. </table>
  235. </td>
  236.  
  237. <td>
  238. <table align="center" cellspacing="0" class="table">
  239. <tr>
  240. <td width="25" align="right"><img src='/images/items/fmj.png' width="25"></td>
  241.  
  242. <td>You have <?php echo "".number_format($fetch->FMJ).""; ?> FMJ!</td>
  243. </tr>
  244. </table>
  245. </td>
  246.  
  247. <td>
  248. <table align="center" cellspacing="0" class="table">
  249. <tr>
  250. <td width="25" align="right"><img src='/images/items/gbullet.png' width="25"></td>
  251.  
  252. <td>You have <?php echo "".number_format($fetch->GoldenBullet).""; ?> Golden Bullets!</td>
  253. </tr>
  254. </table>
  255. </td>
  256.  
  257. </tr>
  258. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement