Advertisement
Guest User

credits

a guest
Dec 8th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.60 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.  
  20. $date = gmdate('Y-m-d h:i:s');
  21.  
  22. if (strip_tags($_POST['sellcreditssubmit']) && strip_tags($_POST['sellcreditsamount']) && strip_tags($_POST['sellcreditsprice'])){
  23.  
  24. $sellcreditsamount = strip_tags($_POST['sellcreditsamount']);
  25.  
  26. $sellcreditsprice = strip_tags($_POST['sellcreditsprice']);
  27.  
  28. if($info->points < $sellcreditsamount){
  29. 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 credits!</td></tr></table><br>";
  30. }elseif($sellcreditsamount < "1"){
  31. 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 credit!</td></tr></table><br>";
  32. }elseif($sellcreditsprice < "1"){
  33. 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 credits for less than £1!</td></tr></table><br>";
  34.  
  35. }elseif($info->points >= $sellcreditsamount){
  36. $newcredits=$info->points - $sellcreditsamount;
  37.  
  38. mysql_query("UPDATE users SET points='$newcredits' WHERE username='$username'");
  39.  
  40. mysql_query("INSERT INTO `blackmarket` ( `id` , `username` , `amount` , `cost` , `type` , `date` )
  41.  
  42. VALUES ('', '$username', '$sellcreditsamount', '$sellcreditsprice', 'credits', '$date')");
  43.  
  44. echo "<table border=0 bordercolor=black align=center cellpadding=2 cellspacing=0><tr><td class=notice align=center><center><font color=green>Credits have been added!</td></tr></table><br>";
  45.  
  46. }}
  47.  
  48. //////////////////////////////////////////////////
  49.  
  50. $buysellcredits=strip_tags($_GET['option']);
  51. $buy=strip_tags($_GET['buy']);
  52. $remove=strip_tags($_GET['remove']);
  53.  
  54. if ($buy){
  55. $buycredits=mysql_fetch_object(mysql_query("SELECT * FROM blackmarket WHERE id= '$buy'"));
  56.  
  57.  
  58. if($buycredits->username == $username){
  59.  
  60. 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 credits!</td></tr></table><br>"; }
  61.  
  62. elseif($buycredits->cost-1 >= $fetch2->money){
  63.  
  64. 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!</td></tr></table><br>";
  65.  
  66. }elseif($buycredits->username != $username && $buycredits->cost <= $fetch2->money){
  67.  
  68. $buyercreditsamount=$buycredits->amount;
  69. $buyernewcredits=$fetch2->points + $buyercreditsamount;
  70. mysql_query("UPDATE users SET points='$buyernewcredits' WHERE username='$username'");
  71.  
  72. $buyercreditscost=$buycredits->cost;
  73. $buyernewmoney=$fetch2->money - $buyercreditscost;
  74. mysql_query("UPDATE users SET money='$buyernewmoney' WHERE username='$username'");
  75.  
  76.  
  77. $creditsseller=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$buycredits->username'"));
  78.  
  79. $sellercreditscost=$buycredits->cost;
  80. $sellernewmoney=$creditsseller->money+$buycredits->cost;
  81.  
  82. mysql_query("UPDATE users SET money='$sellernewmoney' WHERE username='$buycredits->username'");
  83.  
  84. mysql_query("DELETE FROM blackmarket WHERE id='$buy'");
  85.  
  86. mysql_query("INSERT INTO `blackmarket_logs` ( `id` , `seller` , `buyer` , `amount` , `type` , `price` , `date` )
  87.  
  88. VALUES ('', '$buycredits->username', '$username', '$buycredits->amount', 'Credits', '$buycredits->cost', '$date')");
  89.  
  90. 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 credits!</td></tr></table><br>";
  91.  
  92. }}
  93.  
  94.  
  95. if($remove){
  96. $removecredits=mysql_fetch_object(mysql_query("SELECT * FROM blackmarket WHERE id= '$remove'"));
  97. $fetchcreditsowner=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username= '$removecredits->username'"));
  98.  
  99. if($removecredits->username == $username){
  100.  
  101. mysql_query("DELETE FROM blackmarket WHERE id='$remove' AND username='$removecredits->username'");
  102. $pluscredits=$removecredits->amount;
  103. $newcredits=$fetch2->points+$pluscredits;
  104. mysql_query("UPDATE users SET points='$newcredits' WHERE username='$removecredits->username'");
  105. 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 credits!</td></tr></table><br>";
  106.  
  107. }elseif($info->userlevel == "3"){
  108.  
  109. mysql_query("DELETE FROM blackmarket WHERE id='$remove' AND username='$removecredits->username'");
  110. $pluscredits=$removecredits->amount;
  111. $newcredits=$fetchcreditsowner->points+$pluscredits;
  112. mysql_query("UPDATE users SET points='$newcredits' WHERE username='$removecredits->username'");
  113.  
  114. mysql_query("INSERT INTO `inbox` (`id`, `subject`, `to`, `from`, `message`, `date`, `read`) VALUES ('', 'Blackmarket', '$removecredits->username', 'MH Staff', 'Your credits 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());
  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 removed those credits! The owner has been notified.</td></tr></table><br>";
  117.  
  118. }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>"; }}
  119.  
  120. //////////////////////////////////////////////////
  121.  
  122.  
  123. if($removecredits->username == $username){ $buyremoveimage = "<a href=?remove=$coolshow->id><img src='http://icons.iconarchive.com/icons/fatcow/farm-fresh/24/cross-icon.png'></a>"; }else{ $buyremoveimage ="<a href=?buy=$coolshow->id><img src='http://icons.iconarchive.com/icons/fatcow/farm-fresh/24/cart-icon.png'></a>"; }
  124.  
  125. ?>
  126.  
  127. <?
  128. if ($site->gupdate == "1"){
  129. echo "<link href='style.css' rel='stylesheet' type='text/css'><center><div class='update'>$site->gupdatetext</div></center>
  130.  
  131. <br>";
  132. }
  133. ?>
  134.  
  135. <html>
  136.  
  137. <head>
  138.  
  139. <link href="style.css" rel="stylesheet" type="text/css">
  140. <script type="text/javascript" src="js/jquery.js"></script>
  141. <script type="text/javascript" src="js/jquery.tooltip.js"></script>
  142. <script type="text/javascript">
  143. $(document).ready(function(){
  144. tooltip('hover', 'class');
  145. });
  146. function checkAll(theElement) {
  147. var theForm = theElement.form, z = 0;
  148. for(z=0; z<theForm.length;z++){
  149. if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
  150. theForm[z].checked = theElement.checked;
  151. }
  152. }
  153. }
  154.  
  155. </script>
  156.  
  157. <script type="text/javascript">
  158. $(document).ready(function(){
  159. if("bullet" == "bullet"){
  160. $("#bullet_type1").attr("title", "<b>You have:</b> 60,000");
  161. $("#bullet_type2").attr("title", "<b>You have:</b> 7,627");
  162. tooltip("bullet_type1", "id");
  163. tooltip("bullet_type2", "id");
  164. }
  165. });
  166.  
  167. $(function() {
  168. $('.item_popup').nyroModal({
  169. callbacks :{afterShowCont: function (){
  170. tooltip("hover", "class");
  171. }}
  172. });
  173. tooltip('item_popup', 'class');
  174. });
  175.  
  176. $(document).ready(function(){
  177. $('.user_link').nyroModal({
  178. callbacks :{afterShowCont: function (){
  179. tooltip("hover", "class");
  180. }}
  181. });
  182. tooltip('user_link', 'class');
  183. });
  184. $(document).ready(function(){
  185. setTimer("timer1", 122635, {
  186. 0: function()
  187. {
  188. window.location.href=window.location.href;
  189. }});
  190. });
  191. $(document).ready(function(){
  192. setTimer("timer2", 130708, {
  193. 0: function()
  194. {
  195. window.location.href=window.location.href;
  196. }});
  197. });
  198. $(document).ready(function(){
  199. setTimer("timer3", 130770, {
  200. 0: function()
  201. {
  202. window.location.href=window.location.href;
  203. }});
  204. });
  205. $(document).ready(function(){
  206. setTimer("timer4", 144538, {
  207. 0: function()
  208. {
  209. window.location.href=window.location.href;
  210. }});
  211. });
  212. $(document).ready(function(){
  213. setTimer("timer5", 147722, {
  214. 0: function()
  215. {
  216. window.location.href=window.location.href;
  217. }});
  218. });
  219. $(document).ready(function(){
  220. setTimer("timer6", 172168, {
  221. 0: function()
  222. {
  223. window.location.href=window.location.href;
  224. }});
  225. });
  226. $(document).ready(function(){
  227. setTimer("timer7", 172619, {
  228. 0: function()
  229. {
  230. window.location.href=window.location.href;
  231. }});
  232. });
  233. $(document).ready(function(){
  234. setTimer("timer8", 172800, {
  235. 0: function()
  236. {
  237. window.location.href=window.location.href;
  238. }});
  239. });
  240. </script>
  241.  
  242. <style type="text/css">
  243. #tooltip {
  244. position: absolute;
  245. z-index: 3000;
  246. border: 1px solid #333333;
  247. background-color: #222222;
  248. color: #FFFFFF;
  249. font: 11px Verdana, Arial, Helvetica, sans-serif;
  250. padding: 5px;
  251. opacity: 0.85;
  252. max-width: 310px;
  253. }
  254. #tooltip h3, #tooltip div { margin: 0; }
  255. #tooltip h3 {
  256. color: #FFFFFF;
  257. font-size: 12px;
  258. font-weight: normal;
  259. }
  260.  
  261. .pagenumbers {
  262. background-color: #222222;
  263. padding: 4px 0;
  264. }
  265.  
  266. .bar_cont {
  267. display: inline-block;
  268. vertical-align:middle;
  269. }
  270. .bar {
  271. position: relative;
  272. width: 150px;
  273. line-height: 11px;
  274. border: 1px solid #000;
  275. color: #000000;
  276. background: url('images/crimebg/red.jpg');
  277. background-repeat: repeat-x;
  278. }
  279. .rg {
  280. position: relative;
  281. height: 11px;
  282. background-image: url('images/crimebg/green.jpg');
  283. background-repeat: repeat-x;
  284. z-index: 2;
  285. }
  286.  
  287. .textinput{
  288. background-color: #222222;
  289. color: #999999;
  290. font: 11px Verdana, Arial, Helvetica, sans-serif;
  291. height: 22px;
  292. width: 150px;
  293. border: 1px solid #333333;
  294. }
  295.  
  296. .menubox {
  297. text-align: left;
  298. margin-left: 5px;
  299. margin-right: 5px;
  300. margin-bottom: 5px;
  301. border: 1px solid #333333;
  302. background-color: #111111;
  303. padding: 5px 5px 5px 5px;
  304. }
  305.  
  306. .menubox a {
  307. color: #CCCCCC;
  308. text-decoration: none;
  309. display: block;
  310. width: 50px;
  311. }
  312. .menubox .unselected_link {
  313. border: 1px solid #505050;
  314. cursor: pointer;
  315. margin: 6px;
  316. padding: 5px 0px 5px 0px;
  317. vertical-align: middle;
  318. color: #cccccc;
  319. background: url(images/subhead.png) repeat-x;
  320. font: 11px Tahoma, Verdana, Arial, Helvetica, sans-serif;
  321. }
  322. .menubox .selected_link {
  323. border: 1px solid #505050;
  324. cursor: pointer;
  325. margin: 6px;
  326. padding: 5px 0px 5px 0px;
  327. vertical-align: middle;
  328. color: #cccccc;
  329. background: url(images/selected_box.png) repeat-x;
  330. font: 11px Tahoma, Verdana, Arial, Helvetica, sans-serif;
  331. }
  332.  
  333. .img {
  334. border: 1px solid #000000; }
  335.  
  336. </style>
  337.  
  338.  
  339. </head>
  340.  
  341. <body>
  342. <center><table class='menubox' align='center' style='border-radius: 20px; border: 0px;'>
  343. <tr>
  344. <td align='center'>
  345. <div style='float:left;'><a href='blackmarket.php' class='selected_link' style='width: 120px;'><u>Credits</u></a></div>
  346. <div style='float:left;'><a href='blackmarket_bullets.php' class='unselected_link' style='width: 120px;'><u>Bullets</u></a></div>
  347. </td>
  348. </tr>
  349. </table></center><br><br>
  350. <div id=overDiv style="position:absolute; visibility:hidden; z-index:1000;"></div>
  351. <form name="form" method="post" action="">
  352. <table border="0" width="650" align="center" cellpadding="0" cellspacing="0" class="table">
  353. <tr class="header">
  354. <td colspan="5" align="center">Black Market</td>
  355. </tr>
  356. <tr>
  357. <td width="150" class='subhead' align="center">Username</td>
  358. <td width="150" class='subhead' align="center">Offer</td>
  359. <td width="150" class='subhead' align="center">Cost</td>
  360. <td width="50" class='subhead' align="center">&nbsp;</td>
  361. <td width="50" class='subhead' align="center">&nbsp;</td>
  362. </tr>
  363.  
  364. <?
  365.  
  366. $whatpage=$_GET['page'];
  367.  
  368. $getTopics = mysql_query("SELECT * FROM `blackmarket`");
  369.  
  370. $totalTopics = mysql_num_rows($getTopics);
  371.  
  372.  
  373.  
  374. $topics_per_page = 15;
  375.  
  376. $offset = (int)$_GET['page'] * $topics_per_page;
  377.  
  378. $pages = ceil($totalTopics / $topics_per_page);
  379.  
  380. for ($i=0;$i<$pages;$i++)
  381.  
  382. {
  383.  
  384. $n = $i+1;
  385.  
  386. if ($_GET['page'] == $i)
  387.  
  388. {
  389.  
  390. $page .= "<b style='padding:4px; background-color: #173478; border-radius:20px; border-radius:20px;'>$n</b> ";
  391.  
  392. }
  393.  
  394. else
  395.  
  396. {
  397.  
  398. $page .= "<a href='blackmarket.php?page=$i' style='padding:4px; background-color: #111111; border-radius:20px; text-decoration: none;'>$n</a> ";
  399.  
  400. }}
  401.  
  402.  
  403.  
  404.  
  405.  
  406. $queryshow=mysql_query("SELECT * FROM blackmarket ORDER BY id DESC LIMIT $offset, $topics_per_page");
  407.  
  408. $num=mysql_num_rows($queryshow);
  409.  
  410. while($coolshow = mysql_fetch_object($queryshow)){
  411.  
  412.  
  413.  
  414. echo "
  415.  
  416. <tr><td align=center height='40'><a href=profile.php?viewuser=$coolshow->username><b>$coolshow->username</b></a></td>
  417.  
  418. <td align=center height='40'><b>".makecomma($coolshow->amount)." Credits</b></td>
  419.  
  420. <td align=center height='40'><b>&pound;".makecomma($coolshow->cost)."</b></td>
  421.  
  422. <td align=center height='40'><a href=?buy=$coolshow->id><img src='images/acc.png'></a></td>
  423.  
  424. <td align=center height='40'><a href=?remove=$coolshow->id><img src='images/del.png'></a></td>
  425.  
  426. </td>
  427.  
  428. </tr>";
  429.  
  430.  
  431. }
  432.  
  433. if ($num == "0"){
  434.  
  435. echo"<tr><td height='40' colspan=10 align=center>There are no current offers on the black market!</td></tr>";
  436.  
  437. }
  438.  
  439. ?>
  440. <tr><td colspan='6' align='center' class='pagenumbers'>
  441. <? echo "$page"; ?>
  442. </td></tr>
  443. </table>
  444. </form>
  445.  
  446. <br />
  447. <form method="post" action="">
  448.  
  449. <div align=center><table width="250" align="center" cellpadding="0" cellspacing="0" bordercolor="" class="table" border='0'>
  450.  
  451. <tr>
  452. <td class='header' colspan='4'><div align='center'>Add Offer</td>
  453. </tr>
  454.  
  455. <tr><td>&nbsp;</td></tr>
  456.  
  457. <tr>
  458.  
  459. <td align=right>&nbsp;&nbsp;&nbsp;&nbsp;Credits:&nbsp;&nbsp;</td>
  460.  
  461. <td><input name='sellcreditsamount' type='text' class=textinput size='30' style='height:20' onkeyup="this.value=this.value.replace(/[^0-9]/g, '');" autocomplete="off"></td>
  462.  
  463. </tr>
  464.  
  465. <tr><td>&nbsp;</td></tr>
  466.  
  467. <tr>
  468.  
  469. <td align=right>&nbsp;&nbsp;&nbsp;&nbsp;Amount:&nbsp;&nbsp;</td>
  470.  
  471. <td><input name='sellcreditsprice' type='text' class=textinput size='30' style='height:20' onkeyup="this.value=this.value.replace(/[^0-9]/g, '');" autocomplete="off"></td>
  472.  
  473. </tr>
  474.  
  475. <tr><td>&nbsp;</td></tr>
  476.  
  477. <tr>
  478.  
  479. <td align=center colspan=3><input type="submit" name="sellcreditssubmit" value="Add" class="button"></td>
  480.  
  481. </tr></table>
  482.  
  483. </form>
  484.  
  485. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement