<?php
class Item{
    public $BaseArray;
    function GetItemInfo($SelectedItem){
        $BaseArray = $this->BaseArray;
        if (substr($SelectedItem,0,2) == '0x') {
            $SelectedItem = substr($SelectedItem,2);
        }
        $SelectedItem = strtoupper($SelectedItem);
        $StrLenSelectedItem = strlen($SelectedItem);
        if ((strlen($SelectedItem) != 32) || (!preg_match('(^[a-zA-Z0-9])', $SelectedItem)) || ($SelectedItem == 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) {

            return false;
        }

        $ItemID = hexdec(substr($SelectedItem,0,2));
        $ItemSkill = hexdec(substr($SelectedItem,2,2));
        $ItemDur = hexdec(substr($SelectedItem,4,2));
        $Serial	= substr($SelectedItem,6,8);
        $ItemOption = hexdec(substr($SelectedItem,14,2));
        $Ancient = hexdec(substr($SelectedItem,16,2));
        $HarmOption = hexdec(substr($SelectedItem,20,1));
        $HarmValue = hexdec(substr($SelectedItem,21,1));
        $ItemType = hexdec(substr($SelectedItem,18,2));
        $Sockets = substr($SelectedItem,-10);
        $ItemType = $ItemType / 16;
        $ItemID = hexdec(substr($SelectedItem,0,3));
        if ($ItemType == 12) {
            if ( $ItemID == 103) {
                $ItemID = 262;
            } else if ($ItemID == 167) {
                $ItemID += 100;
            } else if($ItemID == 183){
                if (substr($SelectedItem,13,1) == "C") {
                    $ItemID = 267;
                } else {
                    $ItemID = 266;
                }
            } else {
                $ItemID = hexdec(substr($SelectedItem,0,2));
            }
        } else {
            $ItemID = hexdec(substr($SelectedItem,0,2));
        }
 
        //	ITEM BASE
        $ItemBase = $BaseArray[$ItemType.";".$ItemID.";".floor($ItemSkill / 8)];

        if(!$ItemBase) {
            $ItemBase = $BaseArray[$ItemType.";".$ItemID];
            $NoLevel = 0;
        }
        else {
            $NoLevel = 1;
        }
        // Скилл
        if ($ItemSkill < 128) {
            $Skill = '';
        }
        else {
            $Skill = '<font color=white><b>This weapon has a special skill</b></font><br>';
            $ItemSkill = $ItemSkill - 128;
        }

        // Уровень
        $ItemLevel = floor($ItemSkill / 8);
        $ItemSkill = $ItemSkill - $ItemLevel * 8;

        // Лак
        if($ItemSkill < 4) {
            $Luck_ = '';
        }
        else {
            $Luck = 'Luck (success rate of jewel of soul +25%)<br>Luck (critical damage rate +5%)';
            $Luck_ = '+Luck';
            $ItemSkill = $ItemSkill - 4;
        }

        // Ексе
        if($ItemOption	>= 64) {
            $ItemSkill += 4;
            $ItemOption += -64;
        }

        if($ItemOption	< 32) {
            $ItemSkillx6 = 0;
        }
        else {
            $ItemSkillx6 = 1;
            $ItemOption += -32;
        }

        if($ItemOption	< 16) {
            $ItemSkillx5 = 0;
        }
        else {
            $ItemSkillx5 = 1;
            $ItemOption += -16;
        }

        if($ItemOption	< 8) {
            $ItemSkillx4 = 0;
        }
        else {
            $ItemSkillx4 = 1;
            $ItemOption += -8;
        }

        if($ItemOption	< 4) {
            $ItemSkillx3 = 0;
        }
        else {
            $ItemSkillx3 = 1;
            $ItemOption += -4;
        }

        if($ItemOption	< 2) {
            $ItemSkillx2 = 0;
        }
        else {
            $ItemSkillx2 = 1;
            $ItemOption += -2;
        }

        if($ItemOption	< 1) {
            $ItemSkillx1 = 0;
        }
        else {
            $ItemSkillx1 = 1;
            $ItemOption += -1;
        }

        // ПвП

        if (!$ItemBase) {
            $NewType = (int)($ItemType - 0.5);

            $ItemBase = $BaseArray[$NewType.';'.$ItemID];

            if ($ItemBase) {
                $Refinery = array('Additional Damage +200','','Additional Damage +200','','Additional Damage +200','Additional Damage +200','Additional Damage +200','SD recovery rate increase +20%','SD auto recovery','Defensive skill +200','Max. HP increase +200','Max. SD increase +700');
                $RefineryOpt = '<br><b><font color=pink>'.$Refinery[$NewType];

                if ($NewType < 7) {
                    $RefineryOpt2 = 'Attack success rate increase +10';
                }
                else {
                    $RefineryOpt2 = 'Defense success rate increase +10';
                }

                $RefineryOpt .= '<br>'.$RefineryOpt2.'</font></b><br>';
            }
        }

        // Доп. инфо.
        $StickLevel = $ItemBase[8];
        $ItemExcType = $ItemBase[6];
        $ItemName = $ItemBase[5];
        if (!$ItemBase) {
            return false;
        }
        // Хармони
        if ($ItemBase[1] < 5) {
            $HarmOpt = array(
                '1'	 => 'Increases Minimum Damage',
                '2'	 => 'Increases Maximum Damage',
                '3'	 => 'Reduces Required Strength',
                '4'	 => 'Reduces Required Agility',
                '5'	 => 'Increases Min / Max Damage',
                '6'	 => 'Increases Critical Damage',
                '7'	 => 'Increases Skill Damage',
                '8'	 => 'Increases Attack Success Rate (PvP)',
                '9'	 => 'Increases SD Reduction',
                '10' => 'Increases SD Ignore Rate'
            );

            $HarmVal = array(
                '1'  =>	array(' +2',' +3',' +4',' +5',' +6',' +7',' +9',' +11',' +12',' +14',' +15',' +16',' +17',' +20'),
                '2'  =>	array(' +3',' +4',' +5',' +6',' +7',' +8',' +10',' +12',' +14',' +17',' +20',' +23',' +26',' +29'),
                '3'  =>	array(' -6',' -8',' -10',' -12',' -14',' -16',' -20',' -23',' -26',' -29',' -32',' -35',' -37',' -40'),
                '4'  =>	array(' -6',' -8',' -10',' -12',' -14',' -16',' -20',' -23',' -26',' -29',' -32',' -35',' -37',' -40'),
                '5'  =>	array('','','','','','',' +7',' +8',' +9',' +11',' +12',' +14',' +16',' +19'),
                '6'  =>	array('','','','','','',' +12',' +14',' +16',' +18',' +20',' +22',' +24',' +30'),
                '7'  =>	array('','','','','','','','','',' +12',' +14',' +16',' +18',' +22'),
                '8'  =>	array('','','','','','','','','',' +5',' +7',' +9',' +11',' +14'),
                '9'  =>	array('','','','','','','','','',' +3',' +5',' +7',' +9',' +10'),
                '10' =>	array('','','','','','','','','','','','','',' +10'),
            );

            $Harmony = $HarmOpt[$HarmOption].$HarmVal[$HarmOption][$HarmValue];
        }

        if ($ItemBase[1] == 5) {
            $HarmOpt = array(
                '1' => 'Increases Wizardry',
                '2' => 'Reduces Required Strength',
                '3' => 'Reduces Required Agility',
                '4' => 'Increases Skill Damage',
                '5' => 'Increases Critical Damage',
                '6' => 'Increases SD Reduction',
                '7' => 'Increases Attack Success Rate (PvP)',
                '8' => 'Increases SD Ignore Rate',
            );

            $HarmVal = array(
                '1' =>	array(' +6',' +8',' +10',' +12',' +14',' +16',' +17',' +18',' +19',' +21',' +23',' +25',' +27',' +31'),
                '2' =>	array(' -6',' -8',' -10',' -12',' -14',' -16',' -20',' -23',' -26',' -29',' -32',' -35',' -37',' -40'),
                '3' =>	array(' -6',' -8',' -10',' -12',' -14',' -16',' -20',' -23',' -26',' -29',' -32',' -35',' -37',' -40'),
                '4' =>	array('','','','','','',' +7',' +10',' +13',' +16',' +19',' +22',' +25',' +30'),
                '5' =>	array('','','','','','',' +10',' +12',' +14',' +16',' +18',' +20',' +22',' +28'),
                '6' =>	array('','','','','','','','','',' +4',' +6',' +8',' +10',' +13'),
                '7' =>	array('','','','','','','','','',' +5',' +7',' +9',' +11',' +14'),
                '8' =>	array('','','','','','','','','','','','','',' +15'),
            );

            $Harmony = $HarmOpt[$HarmOption].$HarmVal[$HarmOption][$HarmValue];
        }

        if ($ItemBase[1] > 5) {
            $HarmOpt = array(
                '1' => 'Increases Defense',
                '2' => 'Increases Max AG',
                '3' => 'Increases Max Health',
                '4' => 'Increases Health Regeneration Rate',
                '5' => 'Increases Mana Regeneration Rate',
                '6' => 'Increases Defense Success Rate (PvP)',
                '7' => 'Increases Damage Reduction',
                '8' => 'Increases SD Ratio Rate',
            );

            $HarmVal = array(
                '1' =>	array(' +3',' +4',' +5',' +6',' +7',' +8',' +10',' +12',' +14',' +16',' +18',' +20',' +22',' +25'),
                '2' =>	array('','','',' +4',' +6',' +8',' +10',' +12',' +14',' +16',' +18',' +20',' +22',' +25'),
                '3' =>	array('','','',' +7',' +9',' +11',' +13',' +15',' +17',' +19',' +21',' +23',' +25',' +30'),
                '4' =>	array('','','','','','',' +1',' +2',' +3',' +4',' +5',' +6',' +7',' +8'),
                '5' =>	array('','','','','','','','','',' +1',' +2',' +3',' +4',' +5'),
                '6' =>	array('','','','','','','','','',' +3',' +4',' +5',' +6',' +8'),
                '7' =>	array('','','','','','','','','',' +3',' +4',' +5',' +6',' +7'),
                '8' =>	array('','','','','','','','','','','','','',' +5'),
            );

            $Harmony = $HarmOpt[$HarmOption].$HarmVal[$HarmOption][$HarmValue];
        }

        // Типы ексе шмоток
        switch ($ItemExcType) {
            case 0:
                $Option1 = 'Increase acquisition rate of Mana after hunting monsters +Mana/8';
                $Option2 = 'Increase acquisition rate of Life after hunting monsters +life/8';
                $Option3 = 'Increase Attacking(Wizardry)speed +7';
                $Option4 = 'Increase Damage +2%';
                $Option5 = 'Increase Damage +level/20';
                $Option6 = 'Excellent Damage Rate +10%';
                $Inform = 'Additional Dmg';
                break;

            case 1:
                $Option1 = 'Increases acquisition rate of Zen after hunting monsters +30%';
                $Option2 = 'Defense success rate +10%';
                $Option3 = 'Reflect Damage +5%';
                $Option4 = 'Damage Decrease +4%';
                $Option5 = 'Increase Max Mana +4%';
                $Option6 = 'Increase Max HP +4%';
                $Inform = 'Additional defense';
                break;

            case 2:
                $Option1 = 'HP +50 increased';
                $Option2 = 'Mana +50 increased';
                $Option3 = 'Ignor opponents defensive power by 3%';
                $Option4 = 'Max AG +50 increased';
                $Option5 = 'Increase Attacking(Wizardry)speed +5';
                $Option6 = NULL;
                $Inform = 'Additional Dmg';
                $Skill = '';
                $NoColor = true;
                break;

            case 4:
                $Option1 = 'Ingor opponents defensive power by 5%';
                $Option2 = 'Returns the enemys attack power in 5%';
                $Option3 = 'Complete recovery of life in 5% rate';
                $Option4 = 'Complete recover of Mana in 5% rate';
                $Option5 = NULL;
                $Option6 = NULL;
                $Inform = 'Additional Dmg';
                $Skill = '';
                $NoColor = true;
                break;
        }

        $Excelent = '';

        if ($ItemBase[6] < 2) {
            if ($ItemSkillx6 == 1) $Excelent.='<br>'.$Option6;
            if ($ItemSkillx5 == 1) $Excelent.='<br>'.$Option5;
            if ($ItemSkillx4 == 1) $Excelent.='<br>'.$Option4;
            if ($ItemSkillx3 == 1) $Excelent.='<br>'.$Option3;
            if ($ItemSkillx2 == 1) $Excelent.='<br>'.$Option2;
            if ($ItemSkillx1 == 1) $Excelent.='<br>'.$Option1;
        }
        else {
            if ($ItemSkillx1 == 1) $Excelent.='<br>'.$Option1;
            if ($ItemSkillx2 == 1) $Excelent.='<br>'.$Option2;
            if ($ItemSkillx3 == 1) $Excelent.='<br>'.$Option3;
            if ($ItemSkillx4 == 1) $Excelent.='<br>'.$Option4;
            if ($ItemSkillx5 == 1) $Excelent.='<br>'.$Option5;
            if ($ItemSkillx6 == 1) $Excelent.='<br>'.$Option6;
        }

        if ($ItemBase[1] <= 5) {
            $ItemOption	= $ItemSkill*4;
        }
        elseif ($ItemBase[1] == 6) {
            $ItemOption	= $ItemSkill*5;
            $Inform = 'Additional defense rate ';
        }
        elseif ($ItemBase[1] <= 11) {
            $ItemOption	= $ItemSkill*4;
        }
        else {
            $ItemOption	= ($ItemSkill).'%';
            $Inform = 'Automatic HP recovery ';
        }

        // Цвет
        $Color = '#9AADD5;background-color:#000000';

        if ($Excelent != '') {
            $Color = '#2FF387;background-color:#000000';
        }

        if ($ItemLevel > 6) {
            $Color = '#F4CB3F;background-color:#000000';
        }

        if ($ItemOption == 0) {
            $ItemOption = '';
        }
        else {
            $ItemOption = '+'.$ItemOption;
            $ItemOption_ = $Inform.' '.$ItemOption;
        }

        if ($NoColor) {
            $Color = '#F4CB3F;background-color:#000000';
        }

        if (($ItemBase[1] == 13) && ($ItemBase[2] == 37)) {
            $Skill = '<br>Plasma storm skill (Mana:50)';
            $Color = '#9aadd5;background-color:#000000';
            $InfoDur = '<br>Life: '.$ItemDur.'<br>';
            $InfoLvl = 'Minimum Level Requirement: 300';

            if ($ItemSkillx1 == 1) {
                $ItemName .= ' + Destroy';
                $ItemOption_ = 'Increase final damage 10%<br>Increase speed<br>';
            }
            elseif ($ItemSkillx2 == 1) {
                $ItemName .= ' + Protect';
                $ItemOption_ = 'Absorb final damage 10%<br>Increase speed<br>';
            }
            $ItemOption_ .= '<br><font color=gold>Can summon the Fenrir when equipped</font>';
        }
        else {
            if ((!$NoColor) && ($Excelent != '') && ($ItemName)) {
                $Color = 'mediumspringgreen;background-color:#000000';
                $ExcName = 'Excellent ';
            }
        }
        // Dark Raven
        if ($ItemBase[1] == 13 && $ItemBase[2] == 5) {
            $Infoh = '<br>Dmg(rate): 180~200 (1000)<br>Attack speed: 20<br>Life: '.$ItemDur.'<br>Available command: 185';
        }

        // Transformation Ring
        if ($ItemBase[1] == 13 && $ItemBase[2] == 10) {
            $Color = 'white;background-color:#000000';
            $ItemOption_ = '<font color=red>Unable to Equip with a Different Transformation Ring</font>';
        }

        // Wizards Ring
        if ($ItemBase[1] == 13 && $ItemBase[2] == 20) {
            $Color = 'gold;background-color:#000000';
            $ItemOption_ = '<font color=red>Cannot Repair</font><br><font color=white>Durability: '.$ItemDur.'</font><br><br>Increase Wizardry Dmg +10%<br>Increase damage +10<br>Increase Attacking(Wizardry)speed +10';
        }

        // Moonstone Pendant
        if ($ItemBase[1] == 13 && $ItemBase[2] == 38) {
            $Color = 'gold;background-color:#000000';
            $ItemOption_ = '<font color=white>I.D of Kantur Chief Scientist. Tou can anter the Refinery Tower.</font>';
        }

        // Skeleton Warrior Ring
        if ($ItemBase[1] == 13 && $ItemBase[2] == 39) {
            $Color = 'white;background-color:#000000';
            $ItemOption_ = '<font color=white>Durability: '.$ItemDur.'</font><br><br>Increase defensive skill +10%<br>Increase vitality +200<br><br><font color=red>Unable to Equip with a Different Transformation Ring</font>';
        }

        // Jack O'Lantern Ring
        if ($ItemBase[1] == 13 && $ItemBase[2] == 40) {
            $Color = 'white;background-color:#000000';
            $ItemOption_ = '<font color=white>Durability: '.$ItemDur.'</font><br><br><font color=red>Unable to Equip with a Different Transformation Ring</font>';
        }

        // Santa Girl Ring
        if ($ItemBase[1] == 13 && $ItemBase[2] == 41) {
            $Color = 'white;background-color:#000000';
            $ItemOption_ = '<font color=white>Durability: '.$ItemDur.'</font><br><br>Increase Dmg +20<br>Increase Wizardry Dmg +20<br><br><font color=red>Unable to Equip with a Different Transformation Ring</font>';
        }

        // GameMaster Ring
        if ($ItemBase[1] == 13 && $ItemBase[2] == 42) {
            $Color = 'white;background-color:#000000';
            $ItemOption_ = '<font color=white>Durability: '.$ItemDur.'</font><br><br><font color=red>Unable to Equip with a Different Transformation Ring</font>';
        }

        // Snowman Transformation Ring
        if ($ItemBase[1] == 13 && $ItemBase[2] == 68) {
            $Color = 'white;background-color:#000000';
            $ItemOption_ = '<font color=white>Durability: '.$ItemDur.'</font><br><br><font color=red>Unable to Equip with a Different Transformation Ring</font>';
        }

        // Panda Ring
        if ($ItemBase[1] == 13 && $ItemBase[2] == 76) {
            $Color = 'white;background-color:#000000';
            $ItemOption_ = '<font color=white>Durability: '.$ItemDur.'</font><br><br><font color=red>Unable to Equip with a Different Transformation Ring</font>';
        }

        // Анциент
        if ($Ancient == 4) {
            $Ancient = 5;
        }

        if ($Ancient == 9) {
            $Ancient = 10;
        }

        if ($Ancient > 0) {
            if($Ancient == 5 && $ItemBase[28] != '-') {
                $AncientSet = $ItemBase[28];
            }

            if(($Ancient == 6 || $Ancient == 10) && $ItemBase[29] != '-') {
                $AncientSet = $ItemBase[29];
            }

            if ($AncientSet == 'Warrior') {
                $AncientInfo = 'Increase strength +10<br>Increase skill attacking rate +10<br>Increase max. AG +20<br>Increase AG increase rate +5<br>Increase defensive skill +20<br>Increase agility +10<br>Increase critical damage rate 5%<br>Increase excellent damage rate 5%<br>Increase strength +25';
            }
            elseif ($AncientSet == 'Anonymous') {
                $AncientInfo = 'Increase max. life +50<br>Increase agility +50<br>Increase defensive skill when using shield weapons 25%<br>Increase damage +30';
            }
            elseif ($AncientSet == 'Hyperion') {
                $AncientInfo = 'Increase energy +15<br>Increase agility +15<br>Increase skill attacking rate +20<br>Increase max. mana +30';
            }
            elseif ($AncientSet == 'Mist') {
                $AncientInfo = 'Increase stamina +20<br>Increase skill attacking rate +30<br>Double damage rate 10%<br>Increase agility +20';
            }
            elseif ($AncientSet == 'Eplete') {
                $AncientInfo = 'Increase skill attacking rate +15<br>Increase damage success rate +50<br>Increase Wizadry Dmg +5%<br>Increase max. life +50<br>Increase max. AG +30<br>Increase critical damage rate 10%<br>Increase excellent damage rate 10%';
            }
            elseif ($AncientSet == 'Berserker') {
                $AncientInfo = 'Increase max. damage +10<br>Increase max. damage +20<br>Increase max. damage +30<br>Increase max. damage +40<br>Increase skill arracking rate +40<br>Increase strength +40';
            }
            elseif ($AncientSet == 'Garuda') {
                $AncientInfo = 'Increase max. AG +30<br>Double damage rate 5%<br>Increase energy +15<br>Increase max. life +50<br>Increase skill attacking rate +25<br>Increase Wizardry Dmg +15%';
            }
            elseif ($AncientSet == 'Cloud') {
                $AncientInfo = 'Increase critical damage rate 20%<br>Increase critical damage +50';
            }
            elseif ($AncientSet == 'Kantata') {
                $AncientInfo = 'Increase energy +15<br>Increase stamina +30<br>Increase Wizardry Dmg +10%<br>Increase strength +15<br>Increase skill attacking rate +25<br>Increase excellent damage rate 10%<br>Increase excellent damage +20';
            }
            elseif ($AncientSet == 'Rave') {
                $AncientInfo = 'Increase skill attacking rate +20<br>Double damage rate 10%<br>Increase damage when using two handed weapons +30%<br>Ignore enemies defensive skill 5%';
            }
            elseif ($AncientSet == 'Hyon') {
                $AncientInfo = 'Increase defensive skill +25<br>Double damage rate 10%<br>Increase skill attacking rate +20<br>Increase critical damage rate 15%<br>Increase excellent damage rate 15%<br>Increase critical damage +20<br>Increase excellent damage +20';
            }
            elseif ($AncientSet == 'Vicious') {
                $AncientInfo = 'Increase skill attacking rate +15<br>Increase damage +15<br>Double damage rate 10%<br>Increase min. damage +20<br>Increase max. damage +30<br>Ignore enemies defensive skill 5%';
            }
            elseif ($AncientSet == 'Apollo') {
                $AncientInfo = 'Increase energy +10<br>Increase Wizardry Dmg +5%<br>Increase skill attacking rate +10<br>Increase max. mana +30<br>Increase max. life +30<br>Increase max. AG +20<br>Increase critical damage rate 10%<br>Increase excellent damage rate 10%<br>Increase energy +30';
            }
            elseif ($AncientSet == 'Barnake') {
                $AncientInfo = 'Increase Wizardry Dmg +10%<br>Increase energy +20<br>Increase skill attacking rate +30<br>Increase max. mana +100';
            }
            elseif ($AncientSet == 'Evis') {
                $AncientInfo = 'Increase skill attacking rate +15<br>Increase stamina +20<br>Increase Wizardry Dmg 10%<br>Double damage rate 5%<br>Increase damage succes rate +50<br>Increase AG increase rate +5';
            }
            elseif ($AncientSet == 'Sylion') {
                $AncientInfo = 'Double damage rate 5%<br>Increase critical damage rate 5%<br>Increase defensive skill +20<br>Increase strength +50<br>Increase agility +50<br>Increase stamina +50<br>Increase energy +50';
            }
            elseif ($AncientSet == 'Heras') {
                $AncientInfo = 'Increase strength +15<br>Increase Wizardry Dmg +10%<br>Increase defensive skill when using shield weapons 5%<br>Increase energy +15<br>Increase damage success rate +50<br>Increase critical damage rate 10%<br>Increase excellent damage rate 10%<br>Icrease max. life +50<br>Increase max. mana +50';
            }
            elseif ($AncientSet == 'Minet') {
                $AncientInfo = 'Increase energy +30<br>Increase defensive skill +30<br>Increase max. mana +100<br>Increase skill attacking rate +15';
            }
            elseif ($AncientSet == 'Anubis') {
                $AncientInfo = 'Double damage rate 10%<br>Increase max. mana +50<br>Increase Wizardry Dmg +10%<br>Increase critical damage rate 15%<br>Increase excellent damage rate 15%<br>Increase critical damage +20<br>Increase excellent damage +20';
            }
            elseif ($AncientSet == 'Enis') {
                $AncientInfo = 'Increase skill attacking rate +10<br>Double damage rate 10%<br>Increase energy +30<br>Increase Wizardry Dmg +10%<br>Ignore enemies defensive skill 5%';
            }
            elseif ($AncientSet == 'Ceto') {
                $AncientInfo = 'Increase agility +10<br>Increase max. life +50<br>Increase defensive skill +20<br>Increase defensive skill when using shield weapons 5%<br>Increase energy +10<br>Increase max. life +50<br>Increase strength +20';
            }
            elseif ($AncientSet == 'Drake') {
                $AncientInfo = 'Increase agility +20<br>Increase damage +25<br>Double damage rate 20%<br>Increase defensive skill +40<br>Increase critical damage rate 10%';
            }
            elseif ($AncientSet == 'Gaia') {
                $AncientInfo = 'Increase skill attacking rate +10<br>Increase max. mana +25<br>Increase strength +10<br>Double damage rate 5%<br>Increase agility +30<br>Increase excellent damage rate 10%<br>Increase excellent damage +10';
            }
            elseif ($AncientSet == 'Fase') {
                $AncientInfo = 'Increase max. life +100<br>Increase max. mana +100<br>Increase defensive skill +100';
            }
            elseif ($AncientSet == 'Odin') {
                $AncientInfo = 'Increase energy +15<br>Increase max. life +50<br>Increase damage success rate +50<br>Increase agility +30<br>Increase max. mana +50<br>Ignore enemies defensive skill 5%<br>Increase max. AG +50';
            }
            elseif ($AncientSet == 'Elvian') {
                $AncientInfo = 'Increase agility +30<br>Ignore enemies defensive skill 5%';
            }
            elseif ($AncientSet == 'Argo') {
                $AncientInfo = 'Increase max. damage +20<br>Increase skill attacking rate +25<br>Increase max. AG +50<br>Double damage rate 5%';
            }
            elseif ($AncientSet == 'Karis') {
                $AncientInfo = 'Increase skill attacking rate +15<br>Double damage rate 10%<br>Increase critical damage rate 10%<br>Increase agility +40';
            }
            elseif ($AncientSet == 'Gywen') {
                $AncientInfo = 'Increase agility +30<br>Increase min. damage +20<br>Increase defensive skill +20<br>Increase max. damage +20<br>Increase critical damage rate 15%<br>Increase excellent damage rate 15%<br>Increase critical damage +20<br>Increase excellent damage +20';
            }
            elseif ($AncientSet == 'Aruan') {
                $AncientInfo = 'Increase damage +10<br>Double damage rate 10%<br>Increase skill attacking rate +20<br>Increase critical damage rate 15%<br>Increase excellent damage rate 15%<br>Ignore enemies defensive skill 5%';
            }
            elseif ($AncientSet == 'Gaion') {
                $AncientInfo = 'Ignore enemies defensive skill 5%<br>Double damage rate 15%<br>Increase skill attacking rate +15<br>Increase excellent damage rate 15%<br>Increase excellent damage +30<br>Increase Wizardry Dmg +10%<br>Increase strength +30';
            }
            elseif ($AncientSet == 'Muren') {
                $AncientInfo = 'Increase skill attacking rate +10<br>Increase Wizardry Dmg +10%<br>Double damage rate 10%<br>Increase critical damage rate 15%<br>Increase excellent damage rate 15%<br>Increase defensive skill +25<br>Increase damage when using two handed weaspons +20%';
            }
            elseif ($AncientSet == 'Agnis') {
                $AncientInfo = 'Double damage rate 10%<br>Increase defensive skill +40<br>Increase skill attacking rate +20<br>Increase critical damage rate 15%<br>Increase excellent damage rate 15%<br>Increase critical damage +20<br>Increase excellent damage +20';
            }
            elseif ($AncientSet == 'Broy') {
                $AncientInfo = 'Increase damage +20<br>Increase skill attacking rate +20<br>Increase energy +30<br>Increase critical damage rate 15%<br>Increase excellent damage rate 15%<br>Ignore enemies defensive skill 5%<br>Increase command +30';
            }
            elseif ($AncientSet == 'Chrono') {
                $AncientInfo = 'Double damage rate 20%<br>Increase defensive skill +60<br>Increase skill attacking rate +30<br>Increase critical damage rate 15%<br>Increase excellent damage rate 15%<br>Increase critical damage +20<br>Increase excellent damage +20';
            }
            elseif ($AncientSet == 'Semeden') {
                $AncientInfo = 'Increase Wizardry Dmg +15%<br>Increase skill attacking rate +25<br>Increase energy +30<br>Increase critical damage rate 15%<br>Increase excellent damage rate 15%<br>Ignore enemies defensive skill 5%';
            }
            elseif ($AncientSet == 'Vega') {
                $AncientInfo = 'Increase damage success rate +50<br>Increase stamina +50<br>Increase max damage +30<br>Increase excellent damage rate 15%<br>Double damage rate 5%<br>Ignore enemies defensive skill 5%';
            }
            elseif ($AncientSet == 'Chameren') {
                $AncientInfo = 'Increase defensive skill +50<br>Double damage rate 5%<br>Increase damage +30<br>Increase critical damage +30<br>Increase excellent damage rate 15%<br>Increase skill attacking rate +30<br>Increase excellent damage +20';
            }
            else {
                $AncientInfo = 'Извините, но мы не имеем информации о <br> этом предмете';
            }

            //
            $AncientSet .= '\ ';
            $Color = 'springgreen;background-color:blue;';
            $ItemAncientInfo = '<br>Increase Stamina +'.$Ancient.'<br>';
            $AncInfo = '<br><br><font color=gold>Set item option info</font><br><br><font color=#666666>'.$AncientInfo.'</font>';
        }

        // Сокеты
        $Socket = array();
        if($Sockets != 'FFFFFFFFFF' && $Sockets != '0000000000') {
            $SocketInfo = array(
                'FE' => '<font color=#666666>No item application</font>',
                '00' => 'Fire((Level type)Attack/Wizardry increase +19)',
                '01' => 'Fire(Attack speed increase +7)',
                '02' => 'Fire(Maximum attack/Wizardry increase +30)',
                '03' => 'Fire(Minimum attack/Wizardry increase +20)',
                '04' => 'Fire(Attack/Wizardry increase +20)',
                '05' => 'Fire(AG cost decrease +40%)',
                '0A' => 'Water(Block rating increase +10%)',
                '0B' => 'Water(Defense increase +30)',
                '0C' => 'Water(Shield protection increase +7%)',
                '0D' => 'Water(Damage reduction +4%)',
                '0E' => 'Water(Damage reflection +5%)',
                '10' => 'Ice(Monster destruction for the Life increase +56)',
                '11' => 'Ice(Monster destruction for the Mana increase +56)',
                '12' => 'Ice(Skill attack increase +37)',
                '13' => 'Ice(Attack rating increase +25)',
                '14' => 'Ice(Item durability increase +30%)',
                '15' => 'Wind(Automatic Life recovery increase +8)',
                '16' => 'Wind(Maximum Life increase +4%)',
                '17' => 'Wind(Maximum Mana increase +4%)',
                '18' => 'Wind(Automatic Mana recovery increase +7)',
                '19' => 'Wind(Maximum AG increase +25)',
                '1A' => 'Wind(AG value increase +3)',
                '1D' => 'Lightning(Excellent damage increase +15)',
                '1E' => 'Lighting(Excellent damage rate increase +10%)',
                '1F' => 'Lighting(Critical damage increase +30)',
                '20' => 'Lighting(Critical damage rate increase +8%)',
                '24' => 'Ground(Health increase +30)',
                '32' => 'Fire((Level type)Attack/Wizardry increase +20)',
                '33' => 'Fire(Attack speed increase +8)',
                '34' => 'Fire(Maximum attack/Wizardry increase +32)',
                '35' => 'Fire(Minimum attack/Wizardry increase +22)',
                '36' => 'Fire(Attack/Wizardry increase +22)',
                '37' => 'Fire(AG cost decrease +41%)',
                '3C' => 'Water(Block rating increase +11%)',
                '3D' => 'Water(Defense increase +33)',
                '3E' => 'Water(Shield protection increase +10%)',
                '3F' => 'Water(Damage reduction +5%)',
                '40' => 'Water(Damage reflection +6%)',
                '42' => 'Ice(Monster destruction for the Life increase +64)',
                '43' => 'Ice(Monster destruction for the Mana increase +64)',
                '44' => 'Ice(Skill attack increase +40)',
                '45' => 'Ice(Attack rating increase +27)',
                '46' => 'Ice(Item durability increase +32%)',
                '47' => 'Wind(Automatic Life recovery increase +10)',
                '48' => 'Wind(Maximum Life increase +5%)',
                '49' => 'Wind(Maximum Mana increase +5%)',
                '4A' => 'Wind(Automatic Mana recovery increase +14)',
                '4B' => 'Wind(Maximum AG increase +30)',
                '4C' => 'Wind(AG value increase +5)',
                '4F' => 'Lightning(Excellent damage increase +20)',
                '50' => 'Lighting(Excellent damage rate increase +11%)',
                '51' => 'Lighting(Critical damage increase +32)',
                '52' => 'Lighting(Critical damage rate increase +9%)',
                '59' => 'Ground(Health increase +32)',
                '64' => 'Fire((Level type)Attack/Wizardry increase +21)',
                '65' => 'Fire(Attack speed increase +9)',
                '66' => 'Fire(Maximum attack/Wizardry increase +35)',
                '67' => 'Fire(Minimum attack/Wizardry increase +25)',
                '68' => 'Fire(Attack/Wizardry increase +25)',
                '69' => 'Fire(AG cost decrease +42%)',
                '6E' => 'Water(Block rating increase +12%)',
                '6F' => 'Water(Defense increase +36)',
                '70' => 'Water(Shield protection increase +15%)',
                '71' => 'Water(Damage reduction +6%)',
                '72' => 'Water(Damage reflection +7%)',
                '74' => 'Ice(Monster destruction for the Life increase +74)',
                '75' => 'Ice(Monster destruction for the Mana increase +74)',
                '76' => 'Ice(Skill attack increase +45)',
                '77' => 'Ice(Attack rating increase +30)',
                '78' => 'Ice(Item durability increase +34%)',
                '79' => 'Wind(Automatic Life recovery increase +13)',
                '7A' => 'Wind(Maximum Life increase +6%)',
                '7B' => 'Wind(Maximum Mana increase +6%)',
                '7C' => 'Wind(Automatic Mana recovery increase +21)',
                '7D' => 'Wind(Maximum AG increase +35)',
                '7E' => 'Wind(AG value increase +7)',
                '81' => 'Lightning(Excellent damage increase +25)',
                '82' => 'Lighting(Excellent damage rate increase +12%)',
                '83' => 'Lighting(Critical damage increase +35)',
                '84' => 'Lighting(Critical damage rate increase +10%)',
                '88' => 'Ground(Health increase +34)',
                '96' => 'Fire((Level type)Attack/Wizardry increase +22)',
                '97' => 'Fire(Attack speed increase +10)',
                '98' => 'Fire(Maximum attack/Wizardry increase +40)',
                '99' => 'Fire(Minimum attack/Wizardry increase +30)',
                '9A' => 'Fire(Attack/Wizardry increase +30)',
                '9B' => 'Fire(AG cost decrease +43%)',
                'A0' => 'Water(Block rating increase +13%)',
                'A1' => 'Water(Defense increase +39)',
                'A2' => 'Water(Shield protection increase +20%)',
                'A3' => 'Water(Damage reduction +7%)',
                'A4' => 'Water(Damage reflection +8%)',
                'A6' => 'Ice(Monster destruction for the Life increase +89)',
                'A7' => 'Ice(Monster destruction for the Mana increase +89)',
                'A8' => 'Ice(Skill attack increase +50)',
                'A9' => 'Ice(Attack rating increase +35)',
                'AA' => 'Ice(Item durability increase +36%)',
                'AB' => 'Wind(Automatic Life recovery increase +16)',
                'AC' => 'Wind(Maximum Life increase +7%)',
                'AD' => 'Wind(Maximum Mana increase +7%)',
                'AE' => 'Wind(Automatic Mana recovery increase +28)',
                'AF' => 'Wind(Maximum AG increase +40)',
                'B0' => 'Wind(AG value increase +10)',
                'B3' => 'Lightning(Excellent damage increase +30)',
                'B4' => 'Lighting(Excellent damage rate increase +13%)',
                'B5' => 'Lighting(Critical damage increase +40)',
                'B6' => 'Lighting(Critical damage rate increase +11%)',
                'BA' => 'Ground(Health increase +36)',
                'C8' => 'Fire((Level type)Attack/Wizardry increase +27)',
                'C9' => 'Fire(Attack speed increase +11)',
                'CA' => 'Fire(Maximum attack/Wizardry increase +50)',
                'CB' => 'Fire(Minimum attack/Wizardry increase +35)',
                'CC' => 'Fire(Attack/Wizardry increase +35)',
                'CD' => 'Fire(AG cost decrease +44%)',
                'D2' => 'Water(Block rating increase +14%)',
                'D3' => 'Water(Defense increase +42)',
                'D4' => 'Water(Shield protection increase +30%)',
                'D5' => 'Water(Damage reduction +8%)',
                'D6' => 'Water(Damage reflection +9%)',
                'D8' => 'Ice(Monster destruction for the Life increase +112)',
                'D9' => 'Ice(Monster destruction for the Mana increase +112)',
                'DA' => 'Ice(Skill attack increase +60)',
                'DB' => 'Ice(Attack rating increase +40)',
                'DC' => 'Ice(Item durability increase +38%)',
                'DD' => 'Wind(Automatic Life recovery increase +20)',
                'DE' => 'Wind(Maximum Life increase +8%)',
                'DF' => 'Wind(Maximum Mana increase +8%)',
                'E0' => 'Wind(Automatic Mana recovery increase +35)',
                'E1' => 'Wind(Maximum AG increase +50)',
                'E2' => 'Wind(AG value increase +15)',
                'E5' => 'Lightning(Excellent damage increase +40)',
                'E6' => 'Lighting(Excellent damage rate increase +14%)',
                'E7' => 'Lighting(Critical damage increase +50)',
                'E8' => 'Lighting(Critical damage rate increase +12%)',
                'EC' => 'Ground(Health increase +38)'
            );

            $Count = 1;

            for($i = 0; $i < 10; $i = $i + 2) {
                $Socket[] = (isset($SocketInfo[substr($Sockets,$i,2)])?'Socket '.$Count.': '.$SocketInfo[substr($Sockets,$i,2)]:'');
                $Count++;
            }
        }

        $Sockets_ = '';

        if($Socket) {
            $Color = '#b166fe;background-color:#000000';
            $Sockets_ = '<br><br><font color=#FF19FF>Socket item option info</font><br>';

            foreach($Socket as $Option) {
                if($Option) {
                    $Sockets_ .= '<br><font color=#60A0FF>'.$Option.'</font>';
                }
            }
        }

        // Проверка уровня
        if ($NoLevel == 1) {
            $ItemLvl = 0;
        }
        else {
            $ItemLvl = $ItemLevel;
        }

        // Считаем
        $NewDef	= $ItemBase[12] + ($ItemLvl * 3);
        $NewMinDmg = $ItemBase[9] + ($ItemLvl * 3);
        $NewMaxDmg = $ItemBase[10] + ($ItemLvl * 3);

        if ($ItemLvl <= 4) {
            $NewDur	= $ItemBase[14] + ($ItemLvl * 1);
        }

        if ($ItemLvl > 4) {
            $NewDur = $ItemBase[14] + (($ItemLvl-2) * 2);
        }

        if ($ItemLvl > 9) {
            $NewDef += $ItemLvl - 9;
            $NewDur	= $ItemBase[14] + (($ItemLvl*2)-3);
            $NewMinDmg += 1;
            $NewMaxDmg += 1;
        }

        if ($ItemLvl > 10) {
            $NewDef += $ItemLvl - 10;
            $NewDur	= $ItemBase[14] + (($ItemLvl*2)-1);
            $NewMinDmg += 2;
            $NewMaxDmg += 2;
        }

        if ($ItemLvl > 11) {
            $NewDef += $ItemLvl - 11;
            $NewDur	= $ItemBase[14] + (($ItemLvl+1)*2);
            $NewMinDmg += 3;
            $NewMaxDmg += 3;
        }

        if ($ItemLvl > 12) {
            $NewDef += $ItemLvl - 12;
            $NewDur	= $ItemBase[14] + (($ItemLvl+3)*2);
            $NewMinDmg += 4;
            $NewMaxDmg += 4;
        }

        if ($ItemLvl > 13) {
            $NewDef += $ItemLvl - 13;
            $NewDur	= $ItemBase[14] + $ItemLvl*2 + 11;
            $NewMinDmg += 5;
            $NewMaxDmg += 5;
        }

        if ($ItemLvl > 14) {
            $NewDef += $ItemLvl - 14;
            $NewDur	= $ItemBase[14] + $ItemLvl*2 + 17;
            $NewMinDmg += 6;
            $NewMaxDmg += 6;
        }

        if ($Excelent != NULL) {
            $NewDef += 16;
            $NewDur += 15;
            $NewMinDmg += 30;
            $NewMaxDmg += 30;
            $exlcols = '<font color=#9aadd5>';
            $exlcole = '</font>';
        }

        if ($Ancient > 0) {
            $NewDef += 20;
            $NewDur += 20;
            $NewMinDmg += 36;
            $NewMaxDmg += 36;
        }

        if($ItemLvl) {
            $ItemLvl = ' +'.$ItemLvl;
        }
        else {
            $ItemLvl = NULL;
        }

        if(!$ItemLvl) {
            if($ItemOption_) {
                $ItemLvl = '';
            }
        }

        if ($Harmony) {
            $Harmony = '<br><font color=yellow><b>'.$Harmony.'</b></font><br>';
        }

        if ($ItemOption_) {
            $ItemOption_ = '<br><font color=#9aadd5>'.$ItemOption_.'</font>';
        }

        if ($Luck) {
            $Luck = '<br><font color=#9aadd5>'.$Luck.'</font>';
        }

        if ($Skill) {
            $Skill = '<br><font color=#9aadd5>'.$Skill.'</font>';
        }

        if($Excelent) {
            $Excelent = '<font color=#9aadd5>'.$Excelent.'</font>';
        }

        if ($ItemType <= 5.5) {
            if ($ItemBase[3] == 1)	{
                $ItemHands = 'One-Handed';
            }
            else {
                $ItemHands = 'Two-Handed';
            }

            $Infoa = '<br>'.$exlcols.$ItemHands.' Damage: '.$NewMinDmg.' ~ '.$NewMaxDmg.$exlcole;
            $Infob = '<br>Attack Speed: '.$ItemBase[11];
        }
        elseif ($ItemType == 6) {
            $Infoa = '<br>Defense: '.$ItemBase[12];
            $Infob = '<br>'.$exlcols.'Defense Rate: '.$ItemBase[13].$exlcole;
        }
        elseif ($ItemType <= 11) {
            $Infoa = '<br>'.$exlcols.'Defense: '.$NewDef.$exlcole;
            $Infob = '';
        }
        else {
            $Infoa = '';
            $Infob = '';
        }

        if ($ItemBase[15] > 0) {
            $InfoLvl = '<br>Minimum Level Requirement: '.$ItemBase[15];
        }
        if ($ItemBase[16] > 0) {
            $InfoStr = '<br>Strength Requirement: '.$ItemBase[16];
        }
        if ($ItemBase[17] > 0)	{
            $InfoAgi = '<br>Agility Requirement: '.$ItemBase[17];
        }
        if ($ItemBase[18] > 0) {
            $InfoEne = '<br>Energy Requirement: '.$ItemBase[18];
        }
        if ($ItemBase[19] > 0) {
            $InfoVit = '<br>Vitality Requirement: '.$ItemBase[19];
        }
        if ($ItemBase[20] > 0) {
            $InfoCom = '<br>Command Requirement: '.$ItemBase[20];
        }
        if ($ItemBase[6] != '-1') {
            $InfoDur = '<br>Durability: '.$ItemDur.'/'.$NewDur;
        }

        if ($ItemBase[1] == 10 && $ItemLvl > 4) {
            $iteminca = '<br><b>Swimming speed increase</b><br>';
        }
        if ($ItemBase[1] == 11 && $ItemLvl > 4) {
            $itemincb = '<br><b>Increases moving speed</b><br>';
        }

        if (($ItemBase[21] == 1 || $ItemBase[21] == 2) && ($ItemBase[22] == 1 || $ItemBase[22] == 2) && ($ItemBase[23] == 1 || $ItemBase[23] == 2) && ($ItemBase[24] == 1 || $ItemBase[24] == 3) && ($ItemBase[25] == 1 || $ItemBase[25] == 3) && ($ItemBase[26] == 1 || $ItemBase[26] == 2)) {
            // пустоо
        }
        else {
            if ($ItemBase[21] == 0 && $ItemBase[22] == 0 && $ItemBase[23] == 0 && $ItemBase[24] == 0 && $ItemBase[25] == 0 && $ItemBase[26] == 0 && $ItemBase[27] == 0) {
                // пустоо
            }
            else {
                $ItemBR = '<br></br>';
            }

            if ($ItemBase[21] == 1) {
                $ItemDW	= '<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Dark Wizard</div>';
            }
            if ($ItemBase[21] == 2) {
                $ItemDW	= '<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Soul Master</div>';
            }
            if ($ItemBase[21] == 3) {
                $ItemDW	= '<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Grand Master</div>';
            }
            if ($ItemBase[22] == 1) {
                $ItemDK	= '<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Dark Knight</div>';
            }
            if ($ItemBase[22] == 2) {
                $ItemDK	= '<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Blade Knight</div>';
            }
            if ($ItemBase[23] == 1) {
                $ItemELF = '<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Fairy Elf</div>';
            }
            if ($ItemBase[23] == 2) {
                $ItemELF = '<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Muse Elf</div>';
            }
            if ($ItemBase[24] == 1) {
                $ItemMG	= '<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Magic Gladiator</div>';
            }
            if ($ItemBase[24] == 3) {
                $ItemMG	= '<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Duel Master</div>';
            }
            if ($ItemBase[25] == 1) {
                $ItemDL	= '<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Dark Lord</div>';
            }
            if ($ItemBase[25] == 3) {
                $ItemDL	= '<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Lord Emperror</div>';
            }
            if ($ItemBase[26] == 1) {
                $ItemSU	= "<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Summoner</div>";
            }
            if ($ItemBase[26] == 2) {
                $ItemSU	= "<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Bloody Summoner</div>";
            }
            if ($ItemBase[26] == 3) {
                $ItemSU	= "<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Dimension Master</div>";
            }
            if ($ItemBase[27] == 1) {
                $ItemRF	= "<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Rage Fighter</div>";
            }
            if ($ItemBase[27] == 3) {
                $ItemRF	= "<div style=color:#ffffff;background-color:#a00000;>Can be equipped by Fist Master</div>";
            }
        }


        // Вывод
        $Output['type']	= $ItemBase[1];
        $Output['id'] = $ItemID;
        $Output['name']	= stripslashes($ExcName.$AncientSet.$ItemName);
        $Output['X'] = $ItemBase[3];
        $Output['Y'] = $ItemBase[4];
        $Output['level'] = $ItemLvl;
        $Output['color'] = $Color;
        $Output['sn'] = $Serial;
        $Output['thumb'] = $this->GetItemImage($ItemBase[1],$ItemBase[2],$ItemLevel);
        $Output['info']	= "<div style=color:".$Color."><b>".$ExcName.$AncientSet.$ItemName.$ItemLvl."</b></div><font color=white>".$Infoa.$Infob.$InfoDur.$InfoLvl.$InfoStr.$InfoAgi.$InfoEne.$InfoVit.$InfoCom.$ItemBR.$Unique.$ItemDW.$ItemDK.$ItemELF.$ItemMG.$ItemDL.$ItemSU.$ItemRF.$iteminca.$itemincb.$RefineryOpt.$Harmony.$ItemAncientInfo.$Skill.$Luck.$ItemOption_.$Excelent.$AncInfo.$Sockets_."</font>";
        //$Output['info_img'] = "<div style=color:".$Color."><b>".$ExcName.$AncientSet.$ItemName.$ItemLvl."</b></div><br><img src=".$Output['thumb']."><br><font color=white>".$Infoa.$Infob.$InfoDur.$InfoStr.$InfoAgi.$InfoEne.$InfoVit.$InfoCom.$InfoLvl."</font>".$ItemBR.$Unique.$ItemDW.$ItemDK.$ItemELF.$ItemMG.$ItemDL.$ItemSU.$ItemRF.$RefineryOpt.$Harmony.$ItemAncientInfo.$Skill.$Luck.$ItemOption_.$Excelent.$AncInfo.$Sockets_;
        return $Output;
    }
    function GetItemImage($Type,$ID,$Level=0) {
        if($Level > 0) {
            $ItemLvl = '-'.$Level;
        }
        else {
            $ItemLvl = '';
        }

        if (file_exists('web/templates/default/images/items/'.$Type.'-'.$ID.$ItemLvl.'.gif'))	{
            $Output = '/web/templates/default/images/items/'.$Type.'-'.$ID.$ItemLvl.'.gif';
        }
        elseif (file_exists('web/templates/default/images/items/'.$Type.'-'.$ID.'.gif')) {
            $Output = '/web/templates/default/images/items/'.$Type.'-'.$ID.'.gif';
        }

        else {
            $Output = '/web/templates/default/images/items/item_noimg.png';
        }
        return $Output;
    }
    function GetBgImageCharItem($class,$hide = 0){
        if($hide){
            switch ($class) {

                case '0':		return '/web/templates/default/images/inventory/inv_dw_hide.png'; break;
                case '1':		return '/web/templates/default/images/inventory/inv_dw_hide.png'; break;
                case '2':		return '/web/templates/default/images/inventory/inv_dw_hide.png'; break;
                case '3':		return '/web/templates/default/images/inventory/inv_dw_hide.png'; break;
                case '16':		return '/web/templates/default/images/inventory/inv_dk_hide.png'; break;
                case '17':		return '/web/templates/default/images/inventory/inv_dk_hide.png'; break;
                case '18':		return '/web/templates/default/images/inventory/inv_dk_hide.png'; break;
                case '19':		return '/web/templates/default/images/inventory/inv_dk_hide.png'; break;
                case '32':		return '/web/templates/default/images/inventory/inv_fe_hide.png'; break;
                case '33':		return '/web/templates/default/images/inventory/inv_fe_hide.png'; break;
                case '34':		return '/web/templates/default/images/inventory/inv_fe_hide.png'; break;
                case '35':		return '/web/templates/default/images/inventory/inv_fe_hide.png'; break;
                case '48':		return '/web/templates/default/images/inventory/inv_mg_hide.png'; break;
                case '49':		return '/web/templates/default/images/inventory/inv_mg_hide.png'; break;
                case '50':		return '/web/templates/default/images/inventory/inv_mg_hide.png'; break;
                case '64':		return '/web/templates/default/images/inventory/inv_dl_hide.png'; break;
                case '65':		return '/web/templates/default/images/inventory/inv_dl_hide.png'; break;
                case '66':		return '/web/templates/default/images/inventory/inv_dl_hide.png'; break;
                case '80':		return '/web/templates/default/images/inventory/inv_sum_hide.png'; break;
                case '81':		return '/web/templates/default/images/inventory/inv_sum_hide.png'; break;
                case '82':		return '/web/templates/default/images/inventory/inv_sum_hide.png';	 break;
                case '83':		return '/web/templates/default/images/inventory/inv_sum_hide.png';	 break;
                case '96':		return '/web/templates/default/images/inventory/inv_rf_hide.png'; break;
                case '97':		return '/web/templates/default/images/inventory/inv_rf_hide.png';	 break;
                case '98':		return '/web/templates/default/images/inventory/inv_rf_hide.png';	 break;
            }
        }
        else{
            switch ($class) {

                case '0':		return '/web/templates/default/images/inventory/inv_dw.png'; break;
                case '1':		return '/web/templates/default/images/inventory/inv_dw.png'; break;
                case '2':		return '/web/templates/default/images/inventory/inv_dw.png'; break;
                case '3':		return '/web/templates/default/images/inventory/inv_dw.png'; break;
                case '16':		return '/web/templates/default/images/inventory/inv_dk.png'; break;
                case '17':		return '/web/templates/default/images/inventory/inv_dk.png'; break;
                case '18':		return '/web/templates/default/images/inventory/inv_dk.png'; break;
                case '19':		return '/web/templates/default/images/inventory/inv_dk.png'; break;
                case '32':		return '/web/templates/default/images/inventory/inv_fe.png'; break;
                case '33':		return '/web/templates/default/images/inventory/inv_fe.png'; break;
                case '34':		return '/web/templates/default/images/inventory/inv_fe.png'; break;
                case '35':		return '/web/templates/default/images/inventory/inv_fe.png'; break;
                case '48':		return '/web/templates/default/images/inventory/inv_mg.png'; break;
                case '49':		return '/web/templates/default/images/inventory/inv_mg.png'; break;
                case '50':		return '/web/templates/default/images/inventory/inv_mg.png'; break;
                case '64':		return '/web/templates/default/images/inventory/inv_dl.png'; break;
                case '65':		return '/web/templates/default/images/inventory/inv_dl.png'; break;
                case '66':		return '/web/templates/default/images/inventory/inv_dl.png'; break;
                case '80':		return '/web/templates/default/images/inventory/inv_sum.png'; break;
                case '81':		return '/web/templates/default/images/inventory/inv_sum.png'; break;
                case '82':		return '/web/templates/default/images/inventory/inv_sum.png';	 break;
                case '83':		return '/web/templates/default/images/inventory/inv_sum.png';	 break;
                case '96':		return '/web/templates/default/images/inventory/inv_rf.png'; break;
                case '97':		return '/web/templates/default/images/inventory/inv_rf.png';	 break;
                case '98':		return '/web/templates/default/images/inventory/inv_rf.png';	 break;
            }
        }
    }
    function GetCharInv($name, $class, $hide, $Db){
        if ($hide == 0) {
            $result = mssql_fetch_array(mssql_query("SELECT [Inventory] FROM [Character] WHERE [Name]='".$name."'", App::$DBs[$Db]->conn_id));
            $result = $result[0];
            $result = bin2hex($result);
            $result = strtoupper($result);
            /*echo "DECLARE @items VARBINARY(1728); SET @items = (SELECT [Inventory] FROM [Character] WHERE [Name]='$name'); PRINT @items;" . "br";
            $result = mssql_query("DECLARE @items VARBINARY(1728); SET @items = (SELECT [Inventory] FROM [Character] WHERE [Name]='$name'); PRINT @items;");
            $result = mssql_get_last_message($result);
            */
            //$result = substr($result, 2);
            for ($i=0; $i < 12; $i++) {
                $db_item_code[$i] = substr($result,(32*$i), 32);
                if($db_item_code[$i] != 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF') {
                    $db_item_info[$i] = $this->GetItemInfo(substr($result,(32*$i), 32));
                    if($db_item_info[$i] != NULL) {
                        $title_content[$i] = $db_item_info[$i]['info'];
                    }
                }
            }

        }
        $Inventory = '<div style="position:relative; height:407px; background:url('. $this->GetBgImageCharItem($class, $hide) .') no-repeat left top;">';
        if ($hide == 0) {
            // Оружко
            if($db_item_info[0]['thumb']) {
                $Inventory .= "<div style='position:absolute; left:6px; top:242px; width:69px; height:129px; background: url(".$db_item_info[0][thumb].") no-repeat center center;' onmouseover=\"Tip('".$title_content[0]."');\" onmouseout=\"UnTip();\">&nbsp;</div>";

            }
            // Щит
            if($db_item_info[1]['thumb']) {
                $Inventory .= "<div style='position:absolute; left:330px; top:242px; width:69px; height:129px; background: url(".$db_item_info[1][thumb].") no-repeat center center;' onmouseover=\"Tip('".$title_content[1]."');\" onmouseout=\"UnTip();\">&nbsp;</div>";
                //$Inventory .= $title_content[1];
            }
            // Шлем
            if($db_item_info[2]['thumb']) {
                $Inventory .= "<div style='position:absolute; left:73px; top:58px; width:56px; height:66px; background: url(".$db_item_info[2][thumb].") no-repeat center center;' onmouseover=\"Tip('".$title_content[2]."');\" onmouseout=\"UnTip();\">&nbsp;</div>";
                //$Inventory .= $title_content[2];
            }
            // Броня
            if($db_item_info[3]['thumb']) {
                $Inventory .= "<div style='position:absolute; left:40px; top:138px; width:82px; height:98px; background: url(".$db_item_info[3][thumb].") no-repeat center center;' onmouseover=\"Tip('".$title_content[3]."');\" onmouseout=\"UnTip();\">&nbsp;</div>";
                //$Inventory .= $title_content[3];
            }
            // Штаны
            if($db_item_info[4]['thumb']) {
                $Inventory .= "<div style='position:absolute; left:89px;	top:297px;	width:58px; height:74px; background: url(".$db_item_info[4][thumb].") no-repeat center center;' onmouseover=\"Tip('".$title_content[4]."');\" onmouseout=\"UnTip();\">&nbsp;</div>";
                //$Inventory .= $title_content[4];
            }
            // Перчатки
            if($db_item_info[5]['thumb']) {
                $Inventory .= "<div style='position:absolute; left:271px;	top:178px;	width:85px;	height:55px; background: url(".$db_item_info[5][thumb].") no-repeat center center;' onmouseover=\"Tip('".$title_content[5]."');\" onmouseout=\"UnTip();\">&nbsp;</div>";
                //$Inventory .= $title_content[5];
            }
            // Ботинки
            if($db_item_info[6]['thumb']) {
                $Inventory .= "<div style='position:absolute; left:258px;	top:297px; 	width:58px; height:74px; background: url(".$db_item_info[6][thumb].") no-repeat center center;' onmouseover=\"Tip('".$title_content[6]."');\" onmouseout=\"UnTip();\">&nbsp;</div>";
                //$Inventory .= $title_content[6];
            }
            // Крылья
            if($db_item_info[7]['thumb']) {
                $Inventory .= "<div style='position:absolute; left:272px;	top:59px; 	width:127px; height:110px; background: url(".$db_item_info[7][thumb].") no-repeat center center;' onmouseover=\"Tip('".$title_content[7]."');\" onmouseout=\"UnTip();\">&nbsp;</div>";
                //$Inventory .= $title_content[7];
            }
            // Ожерелье
            if($db_item_info[9]['thumb']) {
                $Inventory .= "<div style='position:absolute; left:233px;	top:80px; 	width:29px; height:29px; background: url(".$db_item_info[9][thumb].") no-repeat center center;' onmouseover=\"Tip('".$title_content[9]."');\" onmouseout=\"UnTip();\">&nbsp;</div>";
                //$Inventory .= $title_content[9];
            }
            // Кольцо 1
            if($db_item_info[10]['thumb']) {
                $Inventory .= "<div style='position:absolute; left:102px;	top:252px; 	width:29px; height:29px; background: url(".$db_item_info[10][thumb].") no-repeat center center;' onmouseover=\"Tip('".$title_content[10]."');\" onmouseout=\"UnTip();\">&nbsp;</div>";
                //$Inventory .= $title_content[10];
            }
            // Кольцо 2
            if($db_item_info[11]['thumb']) {
                $Inventory .= "<div style='position:absolute; left:272px;	top:252px; 	width:29px; height:29px; background: url(".$db_item_info[11][thumb].") no-repeat center center;' onmouseover=\"Tip('".$title_content[11]."');\" onmouseout=\"UnTip();\">&nbsp;</div>";
                //$Inventory .= $title_content[11];
            }
        }
        $Inventory .= '</div>';
        return $Inventory;
    }
    function LoadItemBase() {
        $this->BaseArray = NULL;
        $ItemBaseLoad = file('web/resource/db/items.db');
        $this->BaseArray = array();

        foreach($ItemBaseLoad as $ItemBaseLine) {
            if(!preg_match('/#/i',$ItemBaseLine)) {
                $ItemBase = explode("|",$ItemBaseLine);
                $ItemType = $ItemBase[1];
                $ItemID = $ItemBase[2];
                $this->BaseArray[$ItemType.";".$ItemID] = $ItemBase;
            }
        }
        return;
    }

    function Warehouse(){
        
        mssql_query("declare @it varbinary(1920); set @it=(select [Items] from [warehouse] where [AccountID]='".$_SESSION['login']."'); print @it", App::$DBs[$_SESSION['user_db']]->conn_id);
        $inv_items = mssql_get_last_message();


        if (substr($inv_items,0,2)=="0x") $inv_items = substr($inv_items,2);
        else $inv_items=strtoupper($inv_items);

        $col_i = strlen($inv_items)/32;


        $str =0;
        echo "<table style='width: 256px; border: 7px solid #2D2D2F; border-radius: 8px;' border='0' style='border-spacing: 0px;empty-cells: hide;' cellPadding='0' cellSpacing='0'><tbody>";
        if (round($col_i) == 0) {
            $inv_items = "";
            for ($i=0; $i < 120; $i++) {
                $inv_items .= "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
            }
            $col_i = strlen($inv_items)/32;
        }
        for ($i=0;$i<$col_i;$i++)
        {
            if (!$itemarr[$i] || strlen($itemarr[$i]==32))$itemarr[$i] = substr($inv_items,$i*32, 32); //вещь
            if ($itemarr[$i]!="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" && strlen($itemarr[$i])==32) //если не пуста¤ ¤чейка
            {
                $itemo = $this->GetItemInfo($itemarr[$i]);
                $x = $itemo['X'];
                $y = $itemo['Y'];
                if (!$x || !$y){$x=1;$y=1;}//если нет в базе вещи

                $img = "<div onmouseover=\"Tip('".$itemo['info']."');\" onmouseout=\"UnTip();\"><img src='".$itemo['thumb']."' id='tooltiper' align='center' style='width:".($x*32)."px; height:".($y*32)."px;'></div>";


                $j=$x*$y;
                $str=$i;
                $x1=0;
            }
            while($j>0)
            {
                if($x1<=$x)
                {
                    if ($str==$i)$itemarr[$str]="<td align='center' colspan='".$x."' rowspan='".$y."' style='color:white;background:url(/web/templates/default/images/warehouse/2.png);width:32px;height:32px;'><a href='#'>".$img."</a></td>";
                    else $itemarr[$str]="none";
                    $str++;
                    $x1++;
                    if($x1==$x)
                    {
                        $str +=(8-$x);
                        $x1=0;
                    }
                }
                else $itemarr[$str]="<td style='color:white;background:url(/web/templates/default/images/warehouse/1.png) no-repeat;width:32px;height:32px;' width='32' height='32' align='center'>&nbsp;</td>";
                $j--;
            }
            if($itemarr[$i]=="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") $itemarr[$i]="<td style='color:white;background:url(/web/templates/default/images/warehouse/1.png) no-repeat;' width='32' height='32' align='center'>&nbsp;</td>";
            if($i==0) echo "<tr>";
            if($itemarr[$i]!="none" )echo $itemarr[$i];
            if ($i%8==7 && $i+1!=$col_i)echo "</tr><tr>";
            if($i+1==$col_i) echo"</tr>";
        }
        echo "</table>";
    }
 
    function CreateItem($Type, $Index, $Lvl, $Skill, $Luck, $Opt, $Exc, $soc1="00", $soc2="00", $soc3="00", $soc4="00", $soc5="00", $pvp="0", $anc="00", $harmony="00"){
        $Type = trim(sprintf("%2X", $Type ,0));
        $Index = sprintf("%02X", $Index ,00);
        $Option = $Lvl * 8;
        if($Skill == 1) $Option += 128;
        if($Luck == 1) $Option += 4;
        if($Opt > 0 && $Opt < 4) $Option += 3;
        $Option = sprintf("%02X", $Option,00);
        $Excl = sprintf("%02X", $Exc,00);
        $Serial = mssql_fetch_row(App::$DBs[$_SESSION['user_db']]->simple_query("exec WZ_GetItemSerial"));
        $Serial = sprintf("%08X",$Serial[0],00);
        $Sockets = $soc1.$soc2.$soc3.$soc4.$soc5;


        $result = $Index.$Option."FF".$Serial.$Excl.$anc.$Type.$pvp.$harmony.$Sockets;
        return $result;
    }

    function SmartSearch($Inv,$x,$y){


        if (round($Inv) == 0) {
            return 0;
        }
        if (substr($Inv,0,2)=='0x') $Inv=substr($Inv,2);
        //else $Inv=strtoupper(urlencode(bin2hex($Inv)));

        $col_i = strlen($Inv)/32;
        for ($i=0;$i<$col_i;$i++)
        {
            if (!$itemarr[$i] || strlen($itemarr[$i]==32))$itemarr[$i] = substr($Inv,$i*32, 32);
            if ($itemarr[$i]!="FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" && strlen($itemarr[$i])==32)
            {
                $itemo = $this->GetItemInfo($itemarr[$i]);

                $xin = $itemo['X'];
                $yin = $itemo['Y'];
                if (!$xin || !$yin) {

                    $xin = 1;
                    $yin = 1;
                }
                $j=$xin*$yin;
                $str=$i;
                $x1=0;
                while($j>0)
                {
                    if($x1<=$xin)
                    {
                        $itemarr[$str]="not_empty";
                        $str++;
                        $x1++;
                        if($x1==$xin)
                        {
                            $str +=(8-$xin);
                            $x1=0;
                        }
                    }
                    $j--;
                }
            }
        }
        $c=0;
        for ($i=0;$i<$col_i;$i++)
        {
            $j = $x * $y;
            $str = $i;
            $x1=0;
            $found=0;
            $ind = ((floor($i/8)+1)*8)-1; // правый конец строки
            $raz = $i+($x-1);
            while($j>0)
            {
                if($x1<=$x)
                {
                    if (strlen($itemarr[$str])==32 && $str<$col_i && $raz<=$ind) $found++; else {$j=0;$found=0;}
                    $str++;
                    $x1++;

                    if($x1==$x)
                    {
                        $str +=(8-$x);
                        $ind+=8;
                        $x1=0;
                    }
                }
                $j--;
            }
            if ($found == $x*$y){unset($itemarr); return $i;}
        }
        unset($itemarr);
        return -1;
    }
    
    public function GetAllItems()
    {
        $ItemBaseLoad = file('web/resource/db/items.db');
        $ItemBase = array();
        foreach($ItemBaseLoad as $ItemBaseLine) {
            if(!preg_match('/#/i',$ItemBaseLine)) {
                $ItemBase[] = explode("|",$ItemBaseLine);
            }
        }
        return $ItemBase;
    }
    public function UpdateItem()
    {
        
    }
    public function DeleteItem()
    {
        
    }
    public function AddItem()
    {
        
    }
}