Example #1
0
 public function up($id = 0, $used, $check_whole = 1)
 {
     global $user_time;
     global $_SESSION;
     $_SESSION['error_inv'] = '';
     if ($id > 0) {
         $this->init_item($id);
     }
     if ($used == 0) {
         switch ($this->fact['type']) {
             case 1:
                 $used = 1;
                 break;
             case 2:
                 $used = 2;
                 if (isset($_GET['slot']) and $_GET['slot'] == 2 and $this->char['clevel'] >= 3) {
                     $used = 19;
                 }
                 if (isset($_GET['slot']) and $_GET['slot'] == 3 and $this->char['clevel'] >= 7) {
                     $used = 20;
                 }
                 break;
             case 3:
                 $used = 3;
                 break;
             case 4:
                 $used = 4;
                 break;
             case 5:
                 $used = 5;
                 break;
             case 6:
                 $used = 6;
                 break;
             case 7:
                 $used = 7;
                 break;
             case 8:
                 $used = 8;
                 break;
             case 9:
                 $used = 9;
                 break;
             case 10:
                 $used = 10;
                 break;
             case 11:
                 $used = 11;
                 break;
             case 12:
                 $used = 12;
                 if (isset($_GET['slot']) and $_GET['slot'] == 2) {
                     $used = 13;
                 }
                 if (isset($_GET['slot']) and $_GET['slot'] == 3) {
                     $used = 14;
                 }
                 break;
             case 13:
                 $used = 12;
                 if (isset($_GET['slot']) and $_GET['slot'] == 2) {
                     $used = 13;
                 }
                 if (isset($_GET['slot']) and $_GET['slot'] == 3) {
                     $used = 14;
                 }
                 break;
             case 14:
                 $used = 17;
                 break;
             case 15:
                 $used = 18;
                 break;
             case 16:
                 $used = 15;
                 if (isset($_GET['slot']) and $_GET['slot'] == 2) {
                     $used = 16;
                 }
                 break;
             case 18:
                 $used = 4;
                 break;
             case 18:
                 $used = 4;
                 break;
             case 23:
                 $used = 22;
                 break;
             case 24:
                 $used = 21;
                 break;
         }
     }
     if ($check_whole == 0) {
         $this->item_up($used);
     } elseif ($this->fact['can_up'] == 1 and $this->item['priznak'] == 0 and $this->item['user_id'] == $this->char['user_id'] and $this->item['used'] == 0 and $used > 0 and (!$this->counted_item() or $this->fact['type'] == 12 or $this->fact['type'] == 13)) {
         if (getFunc($this->item['user_id']) == 2 and $this->fact['type'] == 24 and mysql_num_rows(myquery("SELECT * FROM game_items WHERE user_id=" . $this->item['user_id'] . " and priznak=0 and used=21 and item_id=" . $this->item['item_id'] . "")) == 0) {
             return;
         } else {
             if ($this->item['ref_id'] != 0) {
                 $_SESSION['error_inv'] = 'error_ident';
                 setLocation("act.php?func=inv&error_ident");
                 return;
             }
             if ($this->item['item_uselife'] == 0 and $this->fact['type'] != 12 and $this->fact['type'] != 13) {
                 $_SESSION['error_inv'] = 'error_broken';
                 setLocation("act.php?func=inv&error_broken&reason=delay");
                 return;
             }
             $check = $this->check_up();
             if ($check != 1) {
                 $_SESSION['error_inv'] = 'error_stat';
                 $_SESSION['error_stat'] = $check;
                 setLocation("act.php?func=inv&error_stat");
                 return;
             }
             $check_used = $this->check_used($used);
             if ($check_used != 1) {
                 $_SESSION['error_inv'] = 'error_broken';
                 setLocation("act.php?func=inv&error_broken&reason=delay");
                 return;
             }
             $check = myquery("SELECT id FROM game_items WHERE user_id=" . $this->char['user_id'] . " AND priznak=0 AND used={$used}");
             if (mysql_num_rows($check)) {
                 list($used_item) = mysql_fetch_array($check);
                 $ItemUsed = new Item($used_item);
                 $kol = $ItemUsed->item_down();
                 if ($kol == 1 and $used_item == $this->item['item_id']) {
                     $this->item['count_item'] = $this->item['count_item'] + 1;
                 }
             }
             $this->item_up($used);
         }
     }
 }