function process_entry($t_entry, $link, $is_go)
{
    global $dbi;
    $drop_type = 1;
    //echo " #Getting information for npc: ".$t_entry." from wowhead : $link <br> ";
    $file = @fopen($link, "r");
    if ($file) {
        //echo "have file<br>";
        $go_name = "";
        $looted_entry = $t_entry;
        //for gameobjects this will be sound1
        while (!feof($file)) {
            $line = fgets($file);
            //echo $line;
            if ($is_go != 0 && strpos("#" . $line, "type: 2, typeId: {$t_entry}, name: '") != 0) {
                //var g_pageInfo = {type: 2, typeId: 202065, name: '"Damsel\'s" "Purse"'};
                $line_stripped = str_replace(array(")", ";", "\""), "", $line);
                //echo "$line_stripped<br>";
                $name_parts = explode(", name: '", $line_stripped);
                $name_parts = explode("'}", $name_parts[1]);
                $go_name = $name_parts[0];
                //fetch the sound1 ID for this GO name
                //				$sql="select sound1 from gameobject_names where name like ('".mysql_escape_string($go_name)."')";
                $sql = "select count( distinct sound1 ) from gameobject_names where name like ('{$go_name}') group by sound1";
                $get_res2 = mysql_query($sql, $dbi) or die(" Q200611231501 " . mysql_error($dbi));
                list($matches_count) = mysql_fetch_row($get_res2);
                if ($matches_count > 1) {
                    echo "!!warning, go with name {$go_name} has more then 1 sound IDs<br>";
                } else {
                    if ($matches_count == 0) {
                        echo "#missing GO with name {$go_name} <br> {$sql}<br>";
                        break;
                    }
                }
                $sql = "select sound1 from gameobject_names where name like ('{$go_name}') group by sound1";
                $get_res2 = mysql_query($sql, $dbi) or die(" Q200611231501 " . mysql_error($dbi));
                $looted_entry = "";
                while (list($tl_entry) = mysql_fetch_row($get_res2)) {
                    $looted_entry .= "{$tl_entry},";
                }
            }
            if (strpos("#" . $line, "template: 'item', id: 'contains',") == 0 && strpos("#" . $line, "template: 'item', id: 'drops',") == 0) {
                continue;
            }
            //template: 'item', id: 'contains', name: LANG.tab_contains, tabs: tabsRelated, parent: 'lkljbjkb574', extraCols: [Listview.extraCols.count, Listview.extraCols.percent], sort:['-percent', 'name'], _totalCount: 9087, computeDataFunc: Listview.funcBox.initLootTable, onAfterCreate: Listview.funcBox.addModeIndicator, data: [{"classs":0,"id":50288,"level":1,"name":"6Blood Elf's Belongings","reqlevel":1,"slot":0,"source":[2],"sourcemore":[{"n":"\"Damsel's\" \"Purse\"","t":2,"ti":202065,"z":490}],"subclass":0,modes:{"mode":4,"4":{"count":9087,"outof":9087}},count:9087,stack:[1,1]}]});
            //{"classs":0,"id":50288,"level":1,"name":"6Blood Elf's Belongings","reqlevel":1,"slot":0,"source":[2],"sourcemore":[{"n":"\"Damsel's\" \"Purse\"","t":2,"ti":202065,"z":490}],"subclass":0,modes:{"mode":4,"4":{"count":9087,"outof":9087}},count:9087,stack:[1,1]}]}
            $line = str_replace(array("}", ")", ";", "\""), "", $line);
            //echo $line."<br>";
            $pieces = explode(",id:", $line);
            //print_r( $pieces );
            //echo "<br>";
            $ind = 0;
            foreach ($pieces as $index => $val) {
                //echo $val."<br>";
                $pieces2 = explode(",", $val);
                $itemid = $pieces2[0];
                //echo "$itemid<br>";
                if ($itemid <= 0) {
                    continue;
                }
                $drops[$ind] = $itemid;
                //the challange of finding out all possible drop modes ...
                //modes:{"mode":4,"4":{"count":23871,"outof":24095}
                $loot_info_loot_modes_naked = $val;
                //echo "$loot_info_loot_modes_naked<br>";
                //unexisting values
                $drop_counts[$ind]["n"]["this"] = -66;
                $drop_counts[$ind]["n"]["total"] = -66;
                $drop_counts[$ind]["5h"]["this"] = -66;
                $drop_counts[$ind]["5h"]["total"] = -66;
                $drop_counts[$ind]["5n"]["this"] = -66;
                $drop_counts[$ind]["5n"]["total"] = -66;
                $drop_counts[$ind]["10n"]["this"] = -66;
                $drop_counts[$ind]["10n"]["total"] = -66;
                $drop_counts[$ind]["25n"]["this"] = -66;
                $drop_counts[$ind]["25n"]["total"] = -66;
                $drop_counts[$ind]["10h"]["this"] = -66;
                $drop_counts[$ind]["10h"]["total"] = -66;
                $drop_counts[$ind]["25h"]["this"] = -66;
                $drop_counts[$ind]["25h"]["total"] = -66;
                //non dungeon drop
                //{"classs":15,"id":62328,"level":1,"name":"7Shed Fur","slot":0,"source":[2],"subclass":0,modes:{"mode":4,"4":{"count":2314,"outof":5066}},count:2314,stack:[1,1]}
                //dungeon drop
                //{"classs":2,"displayid":77012,"dps":143.7,"id":55777,"level":308,"name":"4Torturer's Mercy","reqlevel":78,"slot":21,"slotbak":21,"source":[2],"sourcemore":[{"bd":1,"dd":-1,"n":"Rom'ogg Bonecrusher","t":1,"ti":39665,"z":4926}],"speed":2.30,"subclass":4,modes:{"mode":2,"4":{"count":8564,"outof":47589},"2":{"count":8561,"outof":30394}},count:8564,stack:[1,1]}
                if (strpos($loot_info_loot_modes_naked, "mode:4") != 0) {
                    //normal loot
                    $loot_info_loot_modes_counts = explode("4:{count:", $loot_info_loot_modes_naked);
                    //print_r($loot_info_loot_modes_counts);
                    $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                    //8484,outof:32289}
                    $drop_counts[$ind]["n"]["this"] = $numbers[0];
                    $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                    $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                    $drop_counts[$ind]["n"]["total"] = $numbers[0];
                } else {
                    //5n - based on mode mode
                    $loot_info_loot_modes_counts = explode("2:{count:", $loot_info_loot_modes_naked);
                    //print_r($loot_info_loot_modes_counts);
                    $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                    //8484,outof:32289}
                    $drop_counts[$ind]["5n"]["this"] = $numbers[0];
                    $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                    $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                    $drop_counts[$ind]["5n"]["total"] = $numbers[0];
                    //5h - based on mode mode
                    $loot_info_loot_modes_counts = explode("4:{count:", $loot_info_loot_modes_naked);
                    //print_r($loot_info_loot_modes_counts);
                    $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                    //8484,outof:32289}
                    $drop_counts[$ind]["5h"]["this"] = $numbers[0];
                    $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                    $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                    $drop_counts[$ind]["5h"]["total"] = $numbers[0];
                }
                //10 man normal counts
                //8:{count:8484,outof:32289}
                $loot_info_loot_modes_counts = explode("8:{count:", $loot_info_loot_modes_naked);
                $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                //8484,outof:32289}
                //echo "$val <BR>";
                //echo "$loot_info_loot_modes[1] <BR>";
                //echo "$loot_info_loot_modes_naked <BR>";
                //echo "$loot_info_loot_modes_counts[1] <BR>";
                //echo "$numbers[0] <BR>";
                $drop_counts[$ind]["10n"]["this"] = $numbers[0];
                $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                $drop_counts[$ind]["10n"]["total"] = $numbers[0];
                //25 man normal counts
                $loot_info_loot_modes_counts = explode("16:{count:", $loot_info_loot_modes_naked);
                $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                //8484,outof:32289}
                $drop_counts[$ind]["25n"]["this"] = $numbers[0];
                $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                $drop_counts[$ind]["25n"]["total"] = $numbers[0];
                //10 man heroic counts
                $loot_info_loot_modes_counts = explode("32:{count:", $loot_info_loot_modes_naked);
                $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                //8484,outof:32289}
                $drop_counts[$ind]["10h"]["this"] = $numbers[0];
                $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                $drop_counts[$ind]["10h"]["total"] = $numbers[0];
                //25 man heroic counts
                $loot_info_loot_modes_counts = explode("64:{count:", $loot_info_loot_modes_naked);
                $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                //8484,outof:32289}
                $drop_counts[$ind]["25h"]["this"] = $numbers[0];
                $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                $drop_counts[$ind]["25h"]["total"] = $numbers[0];
                $pieces4 = explode("stack:[", $val);
                $pieces2 = explode(",", $pieces4[1]);
                $stack_min[$ind] = $pieces2[0];
                $pieces5 = explode("]", $pieces2[1]);
                $stack_max[$ind] = $pieces5[0];
                //echo "found drop ".$drops[$ind]." with count ".$drop_counts[$ind]." stack min ".$stack_min[$ind]." stack max ".$stack_max[$ind]."<br>";
                $diff_str = "n";
                LootFound($looted_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind], $go_name != "");
                $diff_str = "5n";
                LootFound($looted_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind], $go_name != "");
                $diff_str = "5h";
                LootFound($looted_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind], $go_name != "");
                $diff_str = "10n";
                LootFound($looted_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind], $go_name != "");
                $diff_str = "10h";
                LootFound($looted_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind], $go_name != "");
                $diff_str = "25n";
                LootFound($looted_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind], $go_name != "");
                $diff_str = "25h";
                LootFound($looted_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind], $go_name != "");
                $ind++;
            }
        }
        fclose($file);
    }
}
function process_entry($t_entry)
{
    $drop_type = 1;
    //	$link = "http://www.wowhead.com/npc=".$t_entry."#sell";
    //	$link = "http://www.wowhead.com/items?filter=cr=129;crs=0;crv=$t_entry";
    $link = "C:/temp/wowhead NPC/npc=" . $t_entry . ".htm";
    //echo " #Getting information for npc: ".$t_entry." from wowhead : $link <br> ";
    $file = @fopen($link, "r");
    if ($file) {
        //echo "have file<br>";
        while (!feof($file)) {
            $line = fgets($file);
            //echo $line;
            if (strpos("#" . $line, "template: 'item', id: 'drops',") == 0) {
                continue;
            }
            //template: 'item', id: 'drops', name: LANG.tab_drops, tabs: tabsRelated, parent: 'lkljbjkb574', extraCols: [Listview.extraCols.count, Listview.extraCols.percent], sort:['-percent', 'name'], _totalCount: 24095, computeDataFunc: Listview.funcBox.initLootTable, onAfterCreate: Listview.funcBox.addModeIndicator, data: [{"classs":12,"id":58361,"level":1,"name":"6Blackrock Orc Weapon","reqlevel":1,"slot":0,"source":[2],"sourcemore":[{"n":"Blackrock Invader","t":1,"ti":42937,"z":12}],"subclass":0,modes:{"mode":4,"4":{"count":23871,"outof":24095}}
            //{"classs":12,"id":58361,"level":1,"name":"6Blackrock Orc Weapon","reqlevel":1,"slot":0,"source":[2],"sourcemore":[{"n":"Blackrock Invader","t":1,"ti":42937,"z":12}],"subclass":0,modes:{"mode":4,"4":{"count":23871,"outof":24095}}
            $line = str_replace(array("}", ")", ";", "\""), "", $line);
            //echo $line."<br>";
            $pieces = explode(",id:", $line);
            //print_r( $pieces );
            //echo "<br>";
            $ind = 0;
            foreach ($pieces as $index => $val) {
                //echo $val."<br>";
                $pieces2 = explode(",", $val);
                $itemid = $pieces2[0];
                //echo "$itemid<br>";
                if ($itemid <= 0) {
                    continue;
                }
                $drops[$ind] = $itemid;
                //the challange of finding out all possible drop modes ...
                //modes:{"mode":4,"4":{"count":23871,"outof":24095}
                $loot_info_loot_modes_naked = $val;
                //echo "$loot_info_loot_modes_naked<br>";
                //unexisting values
                $drop_counts[$ind]["n"]["this"] = -66;
                $drop_counts[$ind]["n"]["total"] = -66;
                $drop_counts[$ind]["5h"]["this"] = -66;
                $drop_counts[$ind]["5h"]["total"] = -66;
                $drop_counts[$ind]["5n"]["this"] = -66;
                $drop_counts[$ind]["5n"]["total"] = -66;
                $drop_counts[$ind]["10n"]["this"] = -66;
                $drop_counts[$ind]["10n"]["total"] = -66;
                $drop_counts[$ind]["25n"]["this"] = -66;
                $drop_counts[$ind]["25n"]["total"] = -66;
                $drop_counts[$ind]["10h"]["this"] = -66;
                $drop_counts[$ind]["10h"]["total"] = -66;
                $drop_counts[$ind]["25h"]["this"] = -66;
                $drop_counts[$ind]["25h"]["total"] = -66;
                //non dungeon drop
                //{"classs":15,"id":62328,"level":1,"name":"7Shed Fur","slot":0,"source":[2],"subclass":0,modes:{"mode":4,"4":{"count":2314,"outof":5066}},count:2314,stack:[1,1]}
                //dungeon drop
                //{"classs":2,"displayid":77012,"dps":143.7,"id":55777,"level":308,"name":"4Torturer's Mercy","reqlevel":78,"slot":21,"slotbak":21,"source":[2],"sourcemore":[{"bd":1,"dd":-1,"n":"Rom'ogg Bonecrusher","t":1,"ti":39665,"z":4926}],"speed":2.30,"subclass":4,modes:{"mode":2,"4":{"count":8564,"outof":47589},"2":{"count":8561,"outof":30394}},count:8564,stack:[1,1]}
                if (strpos($loot_info_loot_modes_naked, "mode:4") != 0) {
                    //normal loot
                    $loot_info_loot_modes_counts = explode("4:{count:", $loot_info_loot_modes_naked);
                    //print_r($loot_info_loot_modes_counts);
                    $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                    //8484,outof:32289}
                    $drop_counts[$ind]["n"]["this"] = $numbers[0];
                    $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                    $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                    $drop_counts[$ind]["n"]["total"] = $numbers[0];
                } else {
                    //5n - based on mode mode
                    $loot_info_loot_modes_counts = explode("2:{count:", $loot_info_loot_modes_naked);
                    //print_r($loot_info_loot_modes_counts);
                    $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                    //8484,outof:32289}
                    $drop_counts[$ind]["5n"]["this"] = $numbers[0];
                    $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                    $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                    $drop_counts[$ind]["5n"]["total"] = $numbers[0];
                    //5h - based on mode mode
                    $loot_info_loot_modes_counts = explode("4:{count:", $loot_info_loot_modes_naked);
                    //print_r($loot_info_loot_modes_counts);
                    $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                    //8484,outof:32289}
                    $drop_counts[$ind]["5h"]["this"] = $numbers[0];
                    $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                    $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                    $drop_counts[$ind]["5h"]["total"] = $numbers[0];
                }
                //10 man normal counts
                //8:{count:8484,outof:32289}
                $loot_info_loot_modes_counts = explode("8:{count:", $loot_info_loot_modes_naked);
                $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                //8484,outof:32289}
                //echo "$val <BR>";
                //echo "$loot_info_loot_modes[1] <BR>";
                //echo "$loot_info_loot_modes_naked <BR>";
                //echo "$loot_info_loot_modes_counts[1] <BR>";
                //echo "$numbers[0] <BR>";
                $drop_counts[$ind]["10n"]["this"] = $numbers[0];
                $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                $drop_counts[$ind]["10n"]["total"] = $numbers[0];
                //25 man normal counts
                $loot_info_loot_modes_counts = explode("16:{count:", $loot_info_loot_modes_naked);
                $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                //8484,outof:32289}
                $drop_counts[$ind]["25n"]["this"] = $numbers[0];
                $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                $drop_counts[$ind]["25n"]["total"] = $numbers[0];
                //10 man heroic counts
                $loot_info_loot_modes_counts = explode("32:{count:", $loot_info_loot_modes_naked);
                $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                //8484,outof:32289}
                $drop_counts[$ind]["10h"]["this"] = $numbers[0];
                $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                $drop_counts[$ind]["10h"]["total"] = $numbers[0];
                //25 man heroic counts
                $loot_info_loot_modes_counts = explode("64:{count:", $loot_info_loot_modes_naked);
                $numbers = explode(",", $loot_info_loot_modes_counts[1]);
                //8484,outof:32289}
                $drop_counts[$ind]["25h"]["this"] = $numbers[0];
                $loot_info_loot_modes_counts = explode("outof:", $loot_info_loot_modes_counts[1]);
                $numbers = explode("}", $loot_info_loot_modes_counts[1]);
                $drop_counts[$ind]["25h"]["total"] = $numbers[0];
                $pieces4 = explode("stack:[", $val);
                $pieces2 = explode(",", $pieces4[1]);
                $stack_min[$ind] = $pieces2[0];
                $pieces5 = explode("]", $pieces2[1]);
                $stack_max[$ind] = $pieces5[0];
                //echo "found drop ".$drops[$ind]." with count ".$drop_counts[$ind]." stack min ".$stack_min[$ind]." stack max ".$stack_max[$ind]."<br>";
                $diff_str = "n";
                LootFound($t_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind]);
                $diff_str = "5n";
                LootFound($t_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind]);
                $diff_str = "5h";
                LootFound($t_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind]);
                $diff_str = "10n";
                LootFound($t_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind]);
                $diff_str = "10h";
                LootFound($t_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind]);
                $diff_str = "25n";
                LootFound($t_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind]);
                $diff_str = "25h";
                LootFound($t_entry, $drop_type, $diff_str, $drop_counts[$ind][$diff_str]["total"], $drop_counts[$ind][$diff_str]["this"], $drops[$ind], $stack_min[$ind], $stack_max[$ind]);
                $ind++;
            }
        }
        fclose($file);
    }
}