Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.59 KB | None | 0 0
  1. <?php
  2. Include "config.php";
  3.  
  4. if (!empty($_GET['id'])){
  5.  
  6.     $_id = $_GET['id'];
  7.     $_index = $_GET['i'];
  8.            
  9.     $link = mysql_connect($mysql_host, $mysql_user, $mysql_password)
  10.     or die("Could not connect : " . mysql_error());
  11.     mysql_select_db($my_database) or die("Could not select database");
  12.    
  13.     $w_msg = "SELECT * FROM e_weapons where w_index = '$_index'";
  14.     $w_result = mysql_query($w_msg);
  15.     $w_line = mysql_fetch_array($w_result);
  16.        
  17.     $w_index = $w_line["w_index"];
  18.     $w_cost = $w_line["w_cost"];
  19.     $w_experience = $w_line["w_experience"];
  20.     $w_array_index = $w_line["w_array_index"];
  21.        
  22.     $u_msg = "SELECT * FROM e_users where vk_id = '$_id'";
  23.     $u_result = mysql_query($u_msg);
  24.     $u_line = mysql_fetch_array($u_result);
  25.        
  26.     $u_vk_id = $u_line["vk_id"];
  27.     $u_experience = $u_line["experience"];
  28.     $u_money = $u_line["money"];
  29.     list($u_weapon[0], $u_weapon[1], $u_weapon[2]) = explode( ',', $u_line["weapons"]);
  30.        
  31.     if (($u_vk_id == $_id) && ($w_index == $_index))
  32.     {
  33.         if ($u_experience >= $w_experience)
  34.         {
  35.             echo "[experience]"."1"."[/experience]";
  36.             if ($u_money >= $w_cost)
  37.             {
  38.                 echo "[money]"."1"."[/money]";
  39.                 $u_weapon[$w_array_index] = 1;
  40.                 $u_money = $u_money - $w_cost;
  41.                    
  42.                 $u_arr = array($u_weapon[0], $u_weapon[1], $u_weapon[2]);
  43.                 $u_weapons = implode(",",$u_arr);
  44.                    
  45.                 $u_msg = "UPDATE e_users SET weapons = '$u_weapons', money = '$u_money' WHERE vk_id = '$_id'";
  46.                 mysql_query($u_msg) or die("Query failed : " . mysql_error());
  47.                 mysql_close($link);
  48.             }else{echo "[money]"."0"."[/money]";}
  49.         }else{echo "[experience]"."0"."[/experience]";}
  50.     }
  51. }
  52. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement