Guest User

Untitled

a guest
Jan 13th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. <?php
  2.  
  3. if (!isset($_SESSION)) {
  4. session_start();
  5. }
  6. if (file_exists('../../config/config.php')) {
  7. require_once ("../../config/config.php");
  8. } else {
  9. require_once ("../config/config.php");
  10. }
  11. protegeLogin();
  12. $vnum_post = limpar($_POST['id']);
  13. if(strtotime(date("H:i:s")) < @$_SESSION['time_compra']){
  14. $t = $_SESSION['time_compra'] - strtotime(date("H:i:s"));
  15. echo "Você deve aguardar ".$t." segundos para fazer outra compra.";
  16. exit();
  17. }
  18. if (!is_numeric($vnum_post) && empty($vnum_post)) {
  19. echo "Algo deu errado, tente novamente ou contacte um administrador.\n";
  20. exit();
  21. }
  22. $query = mysqli_query($con, "SELECT website.item_mall.nome_item,website.item_mall.item_vnum,website.item_mall.valor,website.item_mall.quantidade,website.item_mall.desconto,website.item_mall.item_tempo_tipo,website.item_mall.item_tempo,account.account.login,account.account.coins FROM website.item_mall,account.account WHERE account.account.id = '" . $_SESSION['id'] . "' AND website.item_mall.id = '" . $vnum_post . "'");
  23. $dados = mysqli_fetch_object($query);
  24. $nome_item_db = $dados->nome_item;
  25. $moedas = $dados->coins;
  26. $valor_item = $dados->valor - $dados->desconto;
  27. $quantidade = $dados->quantidade;
  28. $vnum_item = $dados->item_vnum;
  29. $tipo_tempo = $dados->item_tempo_tipo;
  30. $item_tempo = $dados->item_tempo;
  31. if ($moedas < $valor_item) {
  32. echo "Você não possui moedas suficientes para adquirir o item.\n";
  33. exit();
  34. }
  35. $socket_1_2 = "";
  36. $tempo_item = "";
  37. if($tipo_tempo != 0){
  38. if($tipo_tempo == 1){
  39. $socket_1_2 = ",socket2";
  40. $tempo_item = ",'".$item_tempo."'";
  41. }elseif($tipo_tempo == 2){
  42. $socket_1_2 = ",socket0";
  43. $item_tempo_fu = strtotime(date("Y-m-d H:i:s")) + $item_tempo * 60;
  44. $tempo_item = ",'".$item_tempo_fu."'";
  45. }
  46. }
  47. $resto_moedas = $moedas - $valor_item;
  48. $update = mysqli_query($con, "UPDATE account.account SET account.coins = '" . $resto_moedas . "' WHERE account.id = '" . $_SESSION['id'] . "'");
  49. $update2 = mysqli_query($con, "UPDATE website.item_mall SET website.item_mall.qt_compras = website.item_mall.qt_compras + 1 WHERE website.item_mall.id = '" . $vnum_post . "'");
  50. $insert = mysqli_query($con, "INSERT INTO player.item_award (login,vnum,count,given_time,why".$socket_1_2.",mall) VALUES('" . $_SESSION['login'] . "','" . $vnum_item . "','" . $quantidade . "','now()','Item Mall'".$tempo_item.",'1')") or die(mysqli_error($con));
  51. $_SESSION['coins'] = $resto_moedas;
  52. $data = date("Y-m-d H:i:s");
  53. $ip = $_SERVER["REMOTE_ADDR"];
  54. $log = mysqli_query($con, "INSERT INTO website.logs VALUES('','" . $_SESSION['id'] . "','13','Comprou o item - " . $nome_item_db . " - Por ".$valor_item." moedas','".$vnum_post."','".$nome_item_db."','','" . $data . "','" . $ip . "')")or die(mysqli_error($con));
  55. $time_compra = strtotime(date("H:i:s")) + $config['time_compra_itens'];
  56. $_SESSION['time_compra'] = $time_compra;
  57. echo "OK";
  58. ?>
Advertisement
Add Comment
Please, Sign In to add comment