Item decoding PHP.

Results 1 to 3 of 3
  1. #1
    Grand Master Just_Rytis is offline
    Grand MasterRank
    Oct 2006 Join Date
    PUSH main.00754EDCLocation
    561Posts

    Item decoding PHP.

    Hello,

    I'm trying to find 4 slots items in my server. I have a script based on CabalToolz v4 item decode functions, but it shows me only a few items, and always get "Maximum execution time of 120 seconds exceeded" - I set it to 120 already, tried more, but same.

    Here's the codes:

    4slot.php
    Code:
    <?php
    
    include 'config.php';
    include 'cabal/dbconnect.php';
    include 'cabal/item.info.php';
    
    $item_names = items_names();
    
    $get_inventory = $db->Execute("SELECT * FROM GAMEDB.dbo.cabal_Inventory_table");
    $inventory = $get_inventory->NumRows();
    
    set_time_limit(120);
    
    echo "<h1>Inventory</h1><br/ ><br />";
    for ($i=0; $inventory > $i; $i++) {
    
        $inv_row = $get_inventory->FetchRow();
    
        foreach (item_view($inv_row['Data']) as $item => $i) {
                if ($i['slot'] == 4) {
                $get_name = $db->Execute("SELECT Name FROM GAMEDB.dbo.cabal_character_table WHERE CharacterIdx = ?",array($inv_row['CharacterIdx']));
                $name = $get_name->FetchRow();
                echo '<li>'. $name['Name'] .', '. $i['name'] .' </li>';
                }
        }
    
    }
    
    $get_equip = $db->Execute("SELECT * FROM GAMEDB.dbo.cabal_equipment_table");
    $equip = $get_equip->NumRows();
    
    echo "<h1>Equipment</h1><br/ ><br />";
    for ($i=0; $equip > $i; $i++) {
    
        $eq_row = $get_equip->FetchRow();
    
        foreach (item_view($eq_row['Data']) as $item => $i) {
                if ($i['slot'] == 4) {
                $get_name = $db->Execute("SELECT Name FROM GAMEDB.dbo.cabal_character_table WHERE CharacterIdx = ?",array($eq_row['CharacterIdx']));
                $name = $get_name->FetchRow();
                echo '<li>'. $name['Name'] .', '. $i['name'] .' </li>';
                }
        }
    
    }
    
    $get_ware = $db->Execute("SELECT * FROM GAMEDB.dbo.cabal_warehouse_table");
    $ware = $get_ware->NumRows();
    
    echo "<h1>Warehouse</h1><br/ ><br />";
    for ($i=0; $ware > $i; $i++) {
    
        $eq_row = $get_ware->FetchRow();
    
        foreach (item_view($wa_row['Data']) as $item => $i) {
                if ($i['slot'] == 4) {
                $get_name = $db->Execute("SELECT Name FROM GAMEDB.dbo.cabal_character_table WHERE CharacterIdx = ?",array($wa_row['CharacterIdx']));
                $name = $get_name->FetchRow();
                echo '<li>'. $name['Name'] .', '. $i['name'] .' </li>';
                }
        }
    
    }
    
    ?>
    item_info.php
    Code:
    <?PHP
    
    function item_view($item) {
        $items = item_cut(strtoupper(bin2hex($item)),0,32);
        $items = preg_split('/ /', $items, -1,PREG_SPLIT_OFFSET_CAPTURE);
        
        foreach ($items as $res => $value ) {
            $num = $value[0];        
            $itemz[] = item_decode($num);
        }    
        return $itemz; 
    }
    function items_names() {
    global $_config;
        require_once('includes/parsecsv.lib.php');
        $csv = new parseCSV();
        $csv->auto('includes/items.csv');
        $c =0;
        foreach ($csv->data as $data => $d) {
    
            $item[(++$c)]['Item'] = $d['Item'];
            
        }
        return $item;
    }
    
    
    function item_cut($string, $begin, $shortlength, $number=1) {   
           $length = strlen($string);
           if($length > ($shortlength * $number))     {
                   $end = $begin + $shortlength;
                   $flag = 0;
                   for($x=$begin; $x < $end; $x++)    {   if(@ord($string[$x]) <= 120) { $flag++;  } }
                   if($flag%2==1) {     $end++;    }
                   $first_part = substr($string, 0, $end);
                   $last_part = substr($string, $end);
                   $newstring = $first_part. " " .$last_part;
                   $number++;        
               return item_cut($newstring, $end+1, $shortlength, $number);    
           } else return $string;
    }
    
    function item_decode($_item, $item_names = NULL) {
        if ($item_names == NULL) global $item_names;
        if (!is_array($item_names)) $item_names = items_names();
        if (substr($_item,0,2)=='0x') $_item = substr($_item,2);
    
        if ((strlen($_item)!=32) || (!ereg("(^[a-zA-Z0-9])",$_item)) || ($_item == 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
            return false;
        // Get the hex contents
        $_id     = hexdec(substr($_item,3,1).substr($_item,0,2));     // Item ID
        //$_loop  = hexdec(); 
        //if ($_loop != 0) $_id = $_loop .$_id;
        $_level =  floor(hexdec(substr($_item,2,1)) / 2) ;     
        $_bind = (hexdec(substr($_item,2,1)) % 2) > 0 ? 1 : 0;
        $_slot = hexdec(substr($_item,18,2)) / 16;
        
    
        //getname
        $info['data'] = $_item;
        $info['id'] = $_id;
        $info['cname'] = $item_names[$_id]['Item'] ;
        $info['bind'] = $_bind;
        $info['level'] = $_level;
        $info['slot'] = $_slot;
        $info['name'] = $_id.' <b>'.$item_names[$_id]['Item'].'</b> '. ($_level > 0 ? $_level : '') . ' ' . ($_bind > 0 ? '+ Binding' : '')
                . ' ' . ($_slot > 0 ? 'slots:'. $_slot : '');
        return $info;
    
    }
    
    
    ?>
    Can someone help me? Thanks.


  2. #2
    Sorcerer Supreme Alphakilo23 is offline
    Member +Rank
    Jun 2010 Join Date
    Ze German ländLocation
    428Posts

    Re: Item decoding PHP.

    Next time you encounter such an error, search the source code for the number (i.e. 120).
    Check 4slot.php line 12. Increasing the line will make the script run longer before it aborts.

    I have no clue how this file is implemented, but I think the query on line 29 has something to do with your error. Retrieving the whole equipment_table at every request seems kinda... Messy.

  3. #3
    Sorcerer Supreme Acnathon is offline
    Member +Rank
    Apr 2007 Join Date
    RaGEZONELocation
    463Posts

    Re: Item decoding PHP.

    I suggest you to write a new one from scratch.



Advertisement