Advertisement
Guest User

black bullets

a guest
Dec 8th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.77 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. include "includes/db_connect.php";
  6.  
  7. include "includes/functions.php";
  8.  
  9. logincheck();
  10.  
  11. $username=$_SESSION['username'];
  12.  
  13. $query=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
  14. $info = mysql_fetch_object($query);
  15. $query1=mysql_query("SELECT * FROM users WHERE username='$username' LIMIT 1");
  16. $fetch2 = mysql_fetch_object($query1);
  17.  
  18. $fetch=mysql_query("SECLET * FROM users WHERE username='$username'");
  19. $username=$_SESSION['username'];
  20.  
  21. $date = gmdate('Y-m-d h:i:s');
  22.  
  23.  
  24. if (strip_tags($_POST['sellbulletssubmit']) && strip_tags($_POST['sellbulletsamount']) && strip_tags($_POST['sellbulletsprice']) && strip_tags($_POST['sellbulletstype'])){
  25.  
  26. $sellbulletsamount = strip_tags($_POST['sellbulletsamount']);
  27.  
  28. $sellbulletstype = strip_tags($_POST['sellbulletstype']);
  29.  
  30. $sellbulletsprice = strip_tags($_POST['sellbulletsprice']);
  31.  
  32. $jhppriceselllow = $sellbulletsamount * 4000;
  33. $jhppricesellhigh = $sellbulletsamount * 4500;
  34. $fmjpriceselllow = $sellbulletsamount * 4500;
  35. $fmjpricesellhigh = $sellbulletsamount * 5000;
  36.  
  37. if($info->$sellbulletstype < $sellbulletsamount){
  38. echo "<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You havent got enough $sellbulletstype!</font></td></tr></table><br>";
  39.  
  40. }elseif($sellbulletsamount < "1"){
  41. echo "<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You cannot sell less than one $sellbulletstype!</font></td></tr></table><br>";
  42.  
  43. }elseif($sellbulletstype == "JHP" && $sellbulletsprice < $jhppriceselllow){
  44.  
  45. echo"<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>The minimum price for JHP is &pound;4,000!</font></td></tr></table><br>";
  46.  
  47. }elseif($sellbulletstype == "JHP" && $sellbulletsprice > $jhppricesellhigh){
  48.  
  49. echo"<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>The maximum price for JHP is &pound;4,500!</font></td></tr></table><br>";
  50.  
  51. }elseif($sellbulletstype == "FMJ" && $sellbulletsprice < $fmjpriceselllow){
  52.  
  53. echo"<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>The maximum price for FMJ is &pound;5,000!</font></td></tr></table><br>";
  54.  
  55. }elseif($sellbulletstype == "FMJ" && $sellbulletsprice > $fmjpricesellhigh){
  56.  
  57. echo"<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>The minimum price for FMJ is &pound;4,500!</font></td></tr></table><br>";
  58.  
  59. }else{
  60.  
  61. $newbullets=$info->$sellbulletstype - $sellbulletsamount;
  62.  
  63. mysql_query("UPDATE users SET $sellbulletstype='$newbullets' WHERE username='$username'");
  64.  
  65. mysql_query("INSERT INTO `blackmarket_bullets` ( `id` , `username` , `amount` , `cost` , `type` , `date` )
  66.  
  67. VALUES ('', '$username', '$sellbulletsamount', '$sellbulletsprice', '$sellbulletstype', '$date')");
  68.  
  69. echo "<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=green>Your $sellbulletstype has been added to the blackmarket!</td></tr></table><br>";
  70.  
  71. }}
  72.  
  73. //////////////////////////////////////////////////
  74.  
  75. $buysellbullets=strip_tags($_GET['option']);
  76. $buy=strip_tags($_GET['buy']);
  77. $remove=strip_tags($_GET['remove']);
  78.  
  79. if ($buy){
  80. $buybullets=mysql_fetch_object(mysql_query("SELECT * FROM blackmarket_bullets WHERE id= '$buy'"));
  81.  
  82. $Bulletstype=$buybullets->type;
  83.  
  84. if($buybullets->username == $username){
  85.  
  86. echo"<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You cannot buy your own $Bulletstype!</td></tr></table><br>"; }
  87.  
  88. elseif($buybullets->cost-1 >= $fetch2->money){
  89.  
  90. 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 enough money to buy those $Bulletstype!</td></tr></table><br>";
  91.  
  92. }elseif($buybullets->username != $username && $buybullets->cost <= $fetch2->money){
  93.  
  94. $buyerbulletsamount=$buybullets->amount;
  95. $buyernewbullets=$fetch2->$Bulletstype + $buyerbulletsamount;
  96. mysql_query("UPDATE users SET $Bulletstype='$buyernewbullets' WHERE username='$username'");
  97.  
  98. $buyerbulletscost=$buybullets->cost;
  99. $buyernewmoney=$fetch2->money - $buyerbulletscost;
  100. mysql_query("UPDATE users SET money='$buyernewmoney' WHERE username='$username'");
  101.  
  102.  
  103. $bulletsseller=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$buybullets->username'"));
  104.  
  105. $sellerbulletscost=$buybullets->cost;
  106. $sellernewmoney=$bulletsseller->money+$buybullets->cost;
  107.  
  108. mysql_query("UPDATE users SET money='$sellernewmoney' WHERE username='$buybullets->username'");
  109.  
  110. mysql_query("DELETE FROM blackmarket_bullets WHERE id='$buy'");
  111.  
  112. mysql_query("INSERT INTO `blackmarket_logs` ( `id` , `seller` , `buyer` , `amount` , `type` , `amount` , `date` )
  113.  
  114. VALUES ('', '$buybullets->username', '$username', '$buybullets->amount', '$Bulletstype', '$buybullets->cost', '$date')");
  115.  
  116. echo"<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=green>You successfully brought those $Bulletstype!</td></tr></table><br>";
  117.  
  118. }}
  119.  
  120.  
  121. if($remove){
  122. $removebullets=mysql_fetch_object(mysql_query("SELECT * FROM `blackmarket_bullets` WHERE id= '$remove'"));
  123. $fetchbulletsowner=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username= '$removebullets->username'"));
  124.  
  125. $BULLETStype=$removebullets->type;
  126.  
  127. if($removebullets->username == $username){
  128.  
  129. mysql_query("DELETE FROM blackmarket_bullets WHERE id='$remove' AND username='$username'");
  130.  
  131. $plusbullets=$removebullets->amount;
  132. $newbullets=$fetch2->$BULLETStype+$plusbullets;
  133. mysql_query("UPDATE users SET $BULLETStype='$newbullets' WHERE username='$username'");
  134. echo"<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=green>You successfully removed your $BULLETStype!</td></tr></table><br>";
  135.  
  136. }elseif($info->userlevel == "3"){
  137.  
  138. mysql_query("DELETE FROM blackmarket_bullets WHERE id='$remove' AND username='$removebullets->username'");
  139.  
  140. $plusbullets=$removebullets->amount;
  141. $newbullets=$fetchbulletsowner->$BULLETStype+$plusbullets;
  142. mysql_query("UPDATE users SET $BULLETStype='$newbullets' WHERE username='$removebullets->username'");
  143.  
  144. mysql_query("INSERT INTO `inbox` (`id`, `subject`, `to`, `from`, `message`, `date`, `read`) VALUES ('', 'Blackmarket', '$removecredits->username', 'MH Staff', 'Your bullets have been removed from the blackmarket by a member of staff. This may be because of several different reasons, usually it is because you have set the price as an un-reasonable amount.', '$date', '0');") or die (mysql_error());
  145.  
  146. echo"<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=green>You successfully removed those $BULLETStype! The owner has been notified.</td></tr></table><br>";
  147.  
  148. }else{ echo"<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=red>You cannot remove those!</td></tr></table><br>"; }}
  149.  
  150. //////////////////////////////////////////////////
  151. ?>
  152.  
  153. <html>
  154.  
  155. <head>
  156.  
  157. <link href="style.css" rel="stylesheet" type="text/css">
  158. <script type="text/javascript" src="js/jquery.js"></script>
  159. <script type="text/javascript" src="js/jquery.tooltip.js"></script>
  160. <script type="text/javascript">
  161. $(document).ready(function(){
  162. tooltip('hover', 'class');
  163. });
  164. function checkAll(theElement) {
  165. var theForm = theElement.form, z = 0;
  166. for(z=0; z<theForm.length;z++){
  167. if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
  168. theForm[z].checked = theElement.checked;
  169. }
  170. }
  171. }
  172.  
  173. </script>
  174. <style type="text/css">
  175. #tooltip {
  176. position: absolute;
  177. z-index: 3000;
  178. border: 1px solid #333333;
  179. background-color: #222222;
  180. color: #FFFFFF;
  181. font: 11px Verdana, Arial, Helvetica, sans-serif;
  182. padding: 5px;
  183. opacity: 0.85;
  184. max-width: 310px;
  185. }
  186. #tooltip h3, #tooltip div { margin: 0; }
  187. #tooltip h3 {
  188. color: #FFFFFF;
  189. font-size: 12px;
  190. font-weight: normal;
  191. }
  192.  
  193. .pagenumbers {
  194. background-color: #222222;
  195. padding: 4px 0;
  196. }
  197.  
  198. .bar_cont {
  199. display: inline-block;
  200. vertical-align:middle;
  201. }
  202. .bar {
  203. position: relative;
  204. width: 150px;
  205. line-height: 11px;
  206. border: 1px solid #000;
  207. color: #000000;
  208. background: url('images/crimebg/red.jpg');
  209. background-repeat: repeat-x;
  210. }
  211. .rg {
  212. position: relative;
  213. height: 11px;
  214. background-image: url('images/crimebg/green.jpg');
  215. background-repeat: repeat-x;
  216. z-index: 2;
  217. }
  218.  
  219. .textinput{
  220. background-color: #222222;
  221. color: #999999;
  222. font: 11px Verdana, Arial, Helvetica, sans-serif;
  223. height: 22px;
  224. width: 150px;
  225. border: 1px solid #333333;
  226. }
  227.  
  228. .menubox {
  229. text-align: left;
  230. margin-left: 5px;
  231. margin-right: 5px;
  232. margin-bottom: 5px;
  233. border: 1px solid #333333;
  234. background-color: #111111;
  235. padding: 5px 5px 5px 5px;
  236. }
  237.  
  238. .menubox a {
  239. color: #CCCCCC;
  240. text-decoration: none;
  241. display: block;
  242. width: 50px;
  243. }
  244. .menubox .unselected_link {
  245. border: 1px solid #505050;
  246. cursor: pointer;
  247. margin: 6px;
  248. padding: 5px 0px 5px 0px;
  249. vertical-align: middle;
  250. color: #cccccc;
  251. background: url(images/subhead.png) repeat-x;
  252. font: 11px Tahoma, Verdana, Arial, Helvetica, sans-serif;
  253. }
  254. .menubox .selected_link {
  255. border: 1px solid #505050;
  256. cursor: pointer;
  257. margin: 6px;
  258. padding: 5px 0px 5px 0px;
  259. vertical-align: middle;
  260. color: #cccccc;
  261. background: url(images/selected_box.png) repeat-x;
  262. font: 11px Tahoma, Verdana, Arial, Helvetica, sans-serif;
  263. }
  264.  
  265. .img {
  266. border: 1px solid #000000; }
  267.  
  268. </style>
  269.  
  270.  
  271. </head>
  272.  
  273. <body>
  274. <center><table class='menubox' align='center' style='border-radius: 20px; border: 0px;'>
  275. <tr>
  276. <td align='center'>
  277. <div style='float:left;'><a href='blackmarket.php' class='unselected_link' style='width: 120px;'><u>Credits</u></a></div>
  278. <div style='float:left;'><a href='blackmarket_bullets.php' class='selected_link' style='width: 120px;'><u>Bullets</u></a></div>
  279.  
  280. </td>
  281. </tr>
  282. </table></center><br><br>
  283. <div id=overDiv style="position:absolute; visibility:hidden; z-index:1000;"></div>
  284. <form name="form" method="post" action="">
  285. <table border="0" width="650" align="center" cellpadding="0" cellspacing="0" class="table">
  286. <tr class="header">
  287. <td colspan="7" align="center">Black Market</td>
  288. </tr>
  289. <tr>
  290. <td width="150" class='subhead' align="center">Username</td>
  291. <td width="150" class='subhead' align="center">Offer</td>
  292. <td width="150" class='subhead' align="center">Cost</td>
  293. <td width="50" class='subhead' align="center">&nbsp;</td>
  294. <td width="50" class='subhead' align="center">&nbsp;</td>
  295. </tr>
  296. <?
  297.  
  298. $whatpage=$_GET['page'];
  299.  
  300. $getTopics = mysql_query("SELECT * FROM `blackmarket_bullets`");
  301.  
  302. $totalTopics = mysql_num_rows($getTopics);
  303.  
  304.  
  305.  
  306. $topics_per_page = 10;
  307.  
  308. $offset = (int)$_GET['page'] * $topics_per_page;
  309.  
  310. $pages = ceil($totalTopics / $topics_per_page);
  311.  
  312. for ($i=0;$i<$pages;$i++)
  313.  
  314. {
  315.  
  316. $n = $i+1;
  317.  
  318. if ($_GET['page'] == $i)
  319.  
  320. {
  321.  
  322. $page .= "<b style='padding:4px; background-color: #173478; border-radius:20px;'>$n</b> ";
  323.  
  324. }
  325.  
  326. else
  327.  
  328. {
  329.  
  330. $page .= "<a href='blackmarket_bullets.php?page=$i' style='padding:4px; background-color: #111111; border-radius:20px; text-decoration: none;'>$n</a> ";
  331.  
  332. }}
  333.  
  334.  
  335.  
  336.  
  337.  
  338. $queryshow=mysql_query("SELECT * FROM blackmarket_bullets ORDER BY id DESC LIMIT $offset, $topics_per_page");
  339.  
  340. $num=mysql_num_rows($queryshow);
  341.  
  342. while($coolshow = mysql_fetch_object($queryshow)){
  343.  
  344.  
  345.  
  346. echo "
  347.  
  348. <tr><td align=center height='40'><a href=profile.php?viewuser=$coolshow->username><b>$coolshow->username</b></a></td>
  349.  
  350. <td align=center height='40'><b>".makecomma($coolshow->amount)." $coolshow->type</b></td>
  351.  
  352. <td align=center height='40'><b>&pound;".makecomma($coolshow->cost)."</b></td>
  353.  
  354. <td align=center height='40'><a href=?buy=$coolshow->id><img src='images/acc.png'></a></td>
  355.  
  356. <td align=center height='40'><a href=?remove=$coolshow->id><img src='images/del.png'></a></td>
  357.  
  358. </td>
  359.  
  360. </tr>";
  361.  
  362.  
  363. }
  364.  
  365. if ($num == "0"){
  366.  
  367. echo"<tr><td height='40' colspan=10 align=center>There are no current offers on the black market!</td></tr>";
  368.  
  369. }
  370.  
  371. ?>
  372. <tr><td colspan='6' align='center' class='pagenumbers'>
  373. <? echo "$page"; ?>
  374. </td></tr>
  375. </table>
  376. </form>
  377.  
  378. <br />
  379. <form method="post" action="">
  380.  
  381. <div align=center><table width="250" align="center" cellpadding="0" cellspacing="0" bordercolor="" class="table" border='0'>
  382.  
  383. <tr>
  384. <td class='header' colspan='5'><div align='center'>Add Offer</td>
  385. </tr>
  386.  
  387. <tr><td colspan='5'>&nbsp;</td></tr>
  388.  
  389. <tr>
  390.  
  391. <td align="right">Bullets:</td>
  392.  
  393. <td colspan='2' align="center"><input name='sellbulletsamount' type='text' class=textinput size='30' style='height:20' onkeyup="this.value=this.value.replace(/[^0-9]/g, '');" autocomplete="off"></td>
  394.  
  395. </tr>
  396.  
  397. <tr><td colspan='5'>&nbsp;</td></tr>
  398.  
  399. <tr>
  400.  
  401. <td align="right">Type:</td>
  402.  
  403. <td align="center"><input type="radio" name="sellbulletstype" id="select" value="JHP">JHP <input type="radio" name="sellbulletstype" id="select" value="FMJ">FMJ</td>
  404.  
  405. </tr>
  406.  
  407. <tr><td>&nbsp;</td></tr>
  408.  
  409. <tr>
  410.  
  411. <td align="right">Amount:</td>
  412.  
  413. <td align="center"><input name='sellbulletsprice' type='text' class=textinput size='30' style='height:20' onkeyup="this.value=this.value.replace(/[^0-9]/g, '');" autocomplete="off"></td>
  414.  
  415. </tr>
  416.  
  417. <tr><td>&nbsp;</td></tr>
  418.  
  419. <tr>
  420.  
  421. <td align=center colspan=3><input type="submit" name="sellbulletssubmit" value="Add" class="button"></td>
  422.  
  423. </tr></table>
  424.  
  425. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement