[Help] Webshop

Wikko0

Well-Known Member
Joined
Oct 17, 2012
Messages
659
Reaction score
261
Здравейте! Ще пробвам да обясня проблема си. Смятам, че има проблем някъде във функцията ItemInfo, а не намирам къде точно.
Та проблема е следния - предметите се добавят, но кредитите, които трябва да се образуват от функцията ItemInfo не се вземат от потребителя. Проблема е при всички предмети с изключение на Armor-ите и Sword-oвете. Когато направя var_dump на предмет различен от армор и слорд и дава false, а с армор и слорд си работи перфектно и връща всичките данни на предмета.Ето ги и кодовете

ItemAdder.php

Code:
<?
session_start();
ob_start();   
//if(!$login) { echo "<img src='img/l.gif' OnLoad=\"location.reload();\">"; }
include('javascript.php');
$mycreds = mssql_fetch_array(mssql_query("SELECT * FROM MEMB_CREDITS WHERE memb___id='".$_SESSION['dt_username']."'"));



if(!isset($_GET['i']) AND !$_GET['a'] AND !$_GET['ai'] AND !$_GET['ia'])
{
    
echo "
<div id='CategoryWrap'>
<ul id='CateSnu'>
<li><a OnClick=\"ajax('itemadd&t=6','Item Adder / Helmets')\">Helmets</a></li>
<li><a OnClick=\"ajax('itemadd&t=7','Item Adder / Armors')\">Armors</a></li>
<li><a OnClick=\"ajax('itemadd&t=9','Item Adder / Pants')\">Pants</a></li>
<li><a OnClick=\"ajax('itemadd&t=8','Item Adder / Gloves')\">Gloves</a></li>
<li><a OnClick=\"ajax('itemadd&t=10','Item Adder / Boots')\">Boots</a></li>
</ul>
<ul id='CateSnu'>
<li><a OnClick=\"ajax('itemadd&t=0','Item Adder / Swords')\">Swords</a></li>
<li><a OnClick=\"ajax('itemadd&t=1','Item Adder / Axes')\">Axes</a></li>
<li><a OnClick=\"ajax('itemadd&t=2','Item Adder / Maces')\">Maces</a></li>
<li><a OnClick=\"ajax('itemadd&t=3','Item Adder / Spears')\">Spears</a></li>
<li><a OnClick=\"ajax('itemadd&t=5','Item Adder / Staffs')\">Staffs</a></li>
</ul>
<ul id='CateSnu'>
<li><a OnClick=\"ajax('itemadd&t=4','Item Adder / Bows & Crossbows')\">Bows & Crossbows</a></li>
<li><a OnClick=\"ajax('itemadd&t=11','Item Adder / Shields')\">Shields</a></li>
<li><a OnClick=\"ajax('itemadd&t=14','Item Adder / Wings,Capes')\">Wings</a></li>

</div>";
}


if(isset($_GET['ai']))
{
    echo 'getai';
$item = mssql_fetch_array(mssql_query("SELECT * FROM WebShop WHERE credits>0 AND ex_type=3 AND uid=".(int) secure($_GET['ai'])));
$itemimg = ws_image($item['id'],$item['type'],0,$item['stickLevel']);
if(file_exists($itemimg)) { $img = "<img src='$itemimg' border=0>"; }
$AA    = sprintf("%02X", $item['id'],00);
$itemtype = $item['type'];
switch ($itemtype) {
    case 14:
        $itemtype=12;
    break;
    case 12:
        $itemtype=13;
    break;
    case 13:
        $itemtype=14;
    break;
}
$itemtype = $itemtype*16;
$FF    = sprintf("%02X",$itemtype,00);
$itemhex = ItemInfo($AA."6F93A2967A007F09".$FF."000000000000");
echo "<div id='itemadder'><br /><br />$img<br /><br />$itemhex[overlib]<br />
<input type='submit' name='submit' id='submit' OnClick = \"ajax('itemadd&ia=$item[uid]','Adding item...')\" class='button' value='Add this item in your warehouse' /><br />Total <span id='total' name='total'>".($item['credits']*$shopy['credits']['multiplier'])."</span> credits</div>";
}

if($_GET['ia'])
{
    print_r ($_SESSION['dt_username']);
    echo 'getia';
$i_info = mssql_fetch_array(mssql_query("SELECT * FROM WebShop WHERE uid='".(int) secure($_GET['ia'])."'"));
$credita = mssql_fetch_row(mssql_query("exec WZ_GetItemSerial"));
$DDEE = sprintf("%08X", $credita[0],00000000);
$query = mssql_query("declare @it varbinary(1200) set @it=(select [Items] from [warehouse] where [AccountID]='".secure($_SESSION['dt_username'])."'); print @it;");
$mycuritems = mssql_get_last_message();
$test = 0;
$slot = smartsearch($mycuritems,$i_info['X'],$i_info['Y']);
$test = $slot*20;

if($mycreds['credits'] < $i_info['credits']) { echo '<br />You do not have enough credits to do that.'; $error = true; }
elseif(($mycreds['credits']-$i_info['credits'])<0) { echo '<br />You do not have enough credits to do that.'; $error = true; }
elseif($i_info['credits']==0) { echo '<br />That item is not for sale'; $error = true; }
elseif($slot==1337) { echo "Your warehouse is full.Please make some space"; $error = true; }

    if(!$error)
    {
    $AA    = sprintf("%02X", $i_info['id'],00);
    $itemtype = $i_info['type'];
    switch ($itemtype) {
        case 14:
            $itemtype=12;
        break;
        case 12:
            $itemtype=13;
        break;
        case 13:
            $itemtype=14;
        break;
    }
    $itemtype = $itemtype*16;
    $FF    = sprintf("%02X",$itemtype,00);
    $newitem = $AA."6F93".$DDEE."7F09".$FF."000000000000";
    $item = ItemInfo($newitem);
    $mynewitems = substr_replace($mycuritems,$newitem,$test,20);
    mssql_query("Update [MEMB_CREDITS] set [credits]=[credits]-'".$item['credits']."' WHERE [memb___id]='" . secure($_SESSION['dt_username']) . "'

");
    mssql_query("UPDATE warehouse SET items = ".$mynewitems." WHERE AccountId = '".secure($_SESSION['dt_username'])."'");
    shoplog("Bought <a style=\"border-bottom: 1px dashed #339942\"$item[nfo]>".$i_info['name']."</a> for ".$i_info['credits']." credits");
    echo "<br /><div style=\"color:#fff\">Item was added in your warehouse</div><br /><div style='$item[style];width: ".($i_info['X']*32)."px;height: ".($i_info['Y']*32)."px;'$item[nfo]></div><img src='img/l.gif' Onload=\"logged()\">";
    }
}

//Normal Item Add
if(isset($_GET['t']) AND !isset($_GET['i']) AND $_GET['t'] < 16)
{
$cat = mssql_query("SELECT * FROM WebShop WHERE credits>0 AND ex_type != 3 AND category=".(int) secure($_GET['t'])." ORDER BY credits asc");
$i = 0;
echo "
<table width=100% cellpadding='2' cellspacing='0' border='0'>";
while($items = mssql_fetch_array($cat)) {
$itemimg = ws_image($items['id'],$items['type'],0,$items['stickLevel']);
if (file_exists($itemimg)) { $imgs = "<img src='$itemimg' border=0>"; }
echo "<td align='center' class='test'><a OnClick=\"ajax('itemadd&i=$items[uid]','Item Adder / $items[name]')\">$imgs<br />".$items['name']." (".($items['credits']*$shopy['credits']['multiplier'])." credits)</a></td>";
if($i%2) { echo "</tr><tr>"; }
$i++;
unset($imgs,$items);
}
echo "</table>";
}

if(isset($_GET['i']))
{
    
$item = mssql_fetch_array(mssql_query("SELECT * FROM WebShop WHERE credits>0 AND ex_type != 3 AND uid=".(int) secure($_GET['i'])));
$itemimg = ws_image($item['id'],$item['type'],0,$item['stickLevel']);
if (file_exists($itemimg)) { $img = "<img src='$itemimg' border=0>"; }
echo "<div id='itemadder'><br /><br />$img<br /><span id='iname'>$item[name]</span>&nbsp;";
//
if ($item['hasLevel']==1) {
echo ' <select style="padding: 0px; width:80px;" onKeyPress="setTimeout(\'IeIlIn();\',1);" onClick="IeIlIn();" id="item_level" name="item_level"><optgroup label="Item Level"><option value="0">0</option>';
$op=0;
while ($op<$shopy['limit']['item_level']) { $op++; echo '<option value="'.$op.'">+'.$op.'</option>'; }
echo '</select><br />'; }
else { echo '<select style="display:none" type="hidden" id="item_level" name="item_level"><option value="0"></option></select><br />'; }
//
if($item['skill']==1) { echo '<br /><label id="iskill" onKeyPress="setTimeout(\'itemSkill();\',1);" onClick="itemSkill();"><input type="checkbox" id="item_skill" name="item_skill" value="1"> <b>This weapon has a special skill</b></label>'; }
else { echo '<input type="checkbox" style="display:none" id="item_skill" name="item_skill" value="1">'; }
//
if($item['luck']==1) { echo '<br /><label id="iluck" onKeyPress="setTimeout(\'itemLuck();\',1);" onClick="itemLuck();"><input type="checkbox" id="item_luck" name="item_luck" value="1"> Luck (success rate of jewel of soul +25%)<br>Luck (critical damage rate +5%)</label><br />'; }
else { echo '<input type="checkbox" style="display:none" id="item_luck" name="item_luck" value="1">'; }
//
switch($item['ex_type'])
{
            case -1 :
            echo '<input type="checkbox" style="display:none" value=1 id=ex1 name=ex1><input type="checkbox" style="display:none" value=1 id=ex2 name=ex2><input type="checkbox" style="display:none" value=1 id=ex3 name=ex3><input type="checkbox" style="display:none" value=1 id=ex4 name=ex4><input type="checkbox" style="display:none" value=1 id=ex5 name=ex5><input type="checkbox" style="display:none" value=1 id=ex6 name=ex6>';
                break;
            case 0 :
            $op1    = 'Increase MP/kill +8 ';
            $op2    = 'Increase HP/kill +8';
            $op3    = 'Increase attacking(wizardly)speed+7';
            $op4    = 'Increase wizardly damage +2%';
            $op5    = 'Increase Damage +level/20';
            $op6    = 'Excellent Damage Rate +10% ';
            $inf    = 'Additional Damage';
            break;
            case 1 :
            $op1    = 'Increase Zen After Hunt +40%';
            $op2    = 'Defense success rate +10%';
            $op3    = 'Reflect damage +5%';
            $op4    = 'Damage Decrease +4%';
            $op5    = 'Increase MaxMana +4%';
            $op6    = 'Increase MaxHP +4%';
            $inf    = 'Additional Defense';
            $skill    = '';
            break;
            case 2 :
            $op1    = ' Increase HP';
            $op2    = ' Increase MP';
            $op3    = " Ignores 3% of your opponent\'s armor";
            $op4    = ' Increase Stamina +50';
            $op5    = ' Increase Attacking Speed +5';
            $op6    = ' <i>Do not select (Gives nothing)</i>';
            $skill    = '';
            break;
            case 3:
                echo '<input type="checkbox" style="display:none" value="0" id="ex1" name="ex1"><input type="checkbox" style="display:none" value="0" id="ex2" name="ex2"><input type="checkbox" style="display:none" value="0" id="ex3" name="ex3"><input type="checkbox" style="display:none" value="0" id="ex4" name="ex4"><input type="checkbox" style="display:none" value="0" id="ex5" name="ex5"><input type="checkbox" style="display:none" value="0" id="ex6" name="ex6">';
            break;
            case 4:
        $op1    = " Ignores 5% of your opponent\'s armor";
        $op2    = ' 10% chance to fully reflect incoming damage';
        $op3    = ' 5% rate / atack to recover Life completly';
        $op4    = ' 5% rate / atack to recover Mana completly';
        $op5    = ' Increase attacking(wizardly)speed+7';
        $op6    = ' <i>Do not select (Gives nothing)</i>';           
            break;
}       
if (($item['ex_type']!=-1) && ($item['ex_type']!=3))
{
echo '<br />
<label id=exc1><input onclick="IeIlIn();" onKeyPress="setTimeout(\'IeIlIn();\',1);" type=checkbox value=1 id=ex1 name=ex1> '.$op1.'</label><br />
<label id=exc2><input onclick="IeIlIn();" onKeyPress="setTimeout(\'IeIlIn();\',1);" type=checkbox value=1 id=ex2 name=ex2> '.$op2.'</label><br />
<label id=exc3><input onclick="IeIlIn();" onKeyPress="setTimeout(\'IeIlIn();\',1);" type=checkbox value=1 id=ex3 name=ex3> '.$op3.'</label><br />
<label id=exc4><input onclick="IeIlIn();" onKeyPress="setTimeout(\'IeIlIn();\',1);" type=checkbox value=1 id=ex4 name=ex4> '.$op4.'</label><br />
<label id=exc5><input onclick="IeIlIn();" onKeyPress="setTimeout(\'IeIlIn();\',1);" type=checkbox value=1 id=ex5 name=ex5> '.$op5.'</label><br />
<label id=exc6><input onclick="IeIlIn();" onKeyPress="setTimeout(\'IeIlIn();\',1);" type=checkbox value=1 id=ex6 name=ex6> '.$op6.'</label>';
}
//
if (($item['id']==37) && ($item['type']==12))
{
echo "<br />
<select id='fenrir' onKeyPress=\"setTimeout('fenrir()',1)\" onClick=\"fenrir()\">
<option value='0'>Normal</option>
<option value='1'>Fenrir + Destroy</option>
<option value='2'>Fenrir + Protect</option>
<option value='3'>Golden Fenrir</option>
</select>";
}
else { echo "<div id='fenrir'></div>"; }

if ($item['hasOption']==1)
{
switch ($item['optionType']) {
    case 1:
        $opmultiplier=1;
        $inf = ' Additional Damage ';
    break;
    case 2:
        $opmultiplier=5;
        $inf = ' Additional Defense rate ';
    break;
    default:
        $opmultiplier=4;
}
echo '<br /><span id="itemOpt">'.$inf.'&nbsp; <select style="padding: 0px; width:80px;" onKeyPress="setTimeout(\'itemOpt();\',1);" onClick="itemOpt();" id="item_option" name="item_option"><optgroup label="Item Option"><option value="0">0</option>';
$op=0;
while($op<$shopy['limit']['item_option']) { $op++; echo '<option value="'.$op.'">+'.($op*$opmultiplier).'</option>'; }
echo '</select></span>';
}
else { echo '<select style="display:none" type="hidden" id="item_option" name="item_option"><option value="0"></option></select>'; }
//
if($item['refinery']==1) {
$refop    = "".$refinery[$item['type']];
if($item['type']<7) { $refop2 ="Pow Success Rate +10"; }
else { $refop2 = "Def Success rate +10"; }
$refop .= '<br />'.$refop2.'';
echo '<br /><br /><label id="item_ref_c" onKeyPress="setTimeout(\'refOpt();\',1);" onClick="refOpt();"><input type="checkbox" id="item_ref" name="item_ref" value="1">'.$refop.'</label><br />'; }
else { echo "<div id='item_ref'></div>"; }
//
if($item['harmony']>=1 AND $item['harmony']<=3) {
echo '<br /><select style="padding: 0px; width:250px;" onKeyPress="setTimeout(\'harmony();\',1);" onClick="harmony();" id="item_harmony" name="item_harmony"><optgroup label="Harmony Option"><option value="0">None</option>';
$op = 1;
while (@$harmony_opt[$item['harmony']][$op]['name']) { echo '<option value="'.$op.'">'.$harmony_opt[$item['harmony']][$op]['name'].'</option>'; $op++; }
echo '</select><br />'; }
else { echo "<div id='item_harmony'></div>"; }
if($item['sockets'] == 1)
{
echo "<br />";
$s = 1;
while($s<6) {
echo "Socket $s: <select id='socket_$s' onKeyPress=\"setTimeout('sockets()',1)\" onClick=\"sockets()\">";
$socket = 0;
while($socket<38) { if(@$socket_type[$socket]) { echo "<option value='$socket'>".$socket_type[$socket]."</otpion>"; } $socket++;}
echo "</select><br />";
$s++;
}
}
else { echo "<div id='socket_1'></div><div id='socket_2'></div><div id='socket_3'></div><div id='socket_4'></div><div id='socket_5'></div>"; }

echo "<br /><br />
<input type='hidden' name='credits' id='credits' value='".($item['credits']*$shopy['credits']['multiplier'])."' />
<input type='hidden' name='id' id='id' value='".$item['name']."' />
<input type='hidden' name='itype' id='itype' value='".$item['ex_type']."' />
<input type='submit' name='submit' class='button' id='submit'
OnClick = \"ajax('itemadd&a=1&uid=$_GET[i]&'+doc('item_level')+'&'+doc('item_skill',1)+'&'+doc('item_luck',1)+'&'+doc('ex1',1)+'&'+doc('ex2',1)+'&'+doc('ex3',1)+'&'+doc('ex4',1)+'&'+doc('ex5',1)+'&'+doc('ex6',1)+'&'+doc('item_option')+'&'+doc('item_ref',1)+'&'+doc('item_harmony')+'&'+doc('fenrir')+'&'+doc('socket_1')+'&'+doc('socket_2')+'&'+doc('socket_3')+'&'+doc('socket_4')+'&'+doc('socket_5'),'Adding $item[name]...')\"
value='Add this item in your warehouse' /> <br />To select item option, please click in the text.
Total <span id='total' name='total'>".($item['credits']*$shopy['credits']['multiplier'])."</span> credits</div>";
}

if($_GET['a'])
{
    
$i_info = mssql_fetch_array(mssql_query("select * from [WebShop] where [uid]='".(int) secure($_GET['uid'])."'"));
$credita = mssql_fetch_row(mssql_query("exec WZ_GetItemSerial"));
$online = mssql_fetch_array(mssql_query("SELECT * FROM MEMB_STAT WHERE memb___id='".secure($_SESSION['dt_username'])."' AND ConnectStat = 1"));
$credita = sprintf("%08X", $credita[0],00000000);

$BB    = 0;
$ZZ    = 0;
$CC    = sprintf("%02X", $i_info['default_durability'],00);
$DDEE = $credita;
$itemtype = $i_info['type'];
switch ($itemtype) {
    case 14:
        $itemtype=12;
    break;
    case 12:
        $itemtype=13;
    break;
    case 13:
        $itemtype=14;
    break;
}
$itemtype = $itemtype*16;
$FF    = sprintf("%02X",$itemtype,00);
$HH    = 0;
$HI    = 0;
if(($i_info['hasLevel']==1) && ($_GET['item_level']>0) && ($_GET['item_level']<=$shopy['limit']['item_level'])) { $BB += $_GET['item_level']*8; }
else { $BB += $i_info['stickLevel']*8; }
if($_GET['item_level']>$shopy['limit']['item_level']) { echo '<br />The maximum level that item can be is <b>'.$_GET['limit']['item_level'].'</b>, do not exceed it!'; $error = true; }
if($_GET['item_option']>$shopy['limit']['item_option']) { echo '<br />The maximum option that item can have is at stage #<b>'.$shopy['limit']['item_option'].'</b>, do not exceed it!'; $error = true; }
$ops = 0;       
if(($i_info['hasOption']==1) && ($_GET['item_option']>0) && ($_GET['item_option']<=7)) {
if($_GET['item_option']>=4) { $BB += $_GET['item_option']-4; $HH+=64; }
else { $BB += $_GET['item_option']; }
}
if(($i_info['skill']==1) && ($_GET['item_skill']==1)) { $BB += 128; }
if(($i_info['luck']==1) && ($_GET['item_luck']==1)) { $BB += 4; }
if($BB<0) $BB=0;
if(($i_info['ex_type']!=-1) && ($i_info['ex_type']!=3))
{
if($_GET['ex1']) { $HH+=1; $ops++; }
if($_GET['ex2']) { $HH+=2; $ops++; }
if($_GET['ex3']) { $HH+=4; $ops++; }
if($_GET['ex4']) { $HH+=8; $ops++; }
if($_GET['ex5']) { $HH+=16; $ops++; }
if($_GET['ex6']) { $HH+=32; $ops++; }
}
if(($i_info['type']==12) && ($i_info['id']==37))
{
    switch($_GET['fenrir'])
    {
        case 1:
            $HH=1;
            $i_info['credits'] += $shopy['credits']['fenrir_destroy'];
        break;
        case 2:
            $HH=2;
            $i_info['credits'] += $shopy['credits']['fenrir_protect'];
        break;
        case 3:
            $HH=4;
            $i_info['credits'] += $shopy['credits']['fenrir_gold'];
        break;
    }
}
if($_GET['item_ref']==1) { $FF    = sprintf("%02X",$itemtype+8,00); }
if($_GET['item_harmony']>0) { $HI = $_GET['item_harmony'].sprintf("%01X",'13',00); } else { $HI = sprintf("%02X",'00',00); }
            $first = $i_info['type']*2;
            $second = $i_info['id'];
            if($first >= 16)  { $HH+=128; $first = $first - 16; }
            if($second > 15) { $first = $first + 1; $second = $second - 16; }
$names = ($i_info['type']*32)+$i_info['id'];
$AA = sprintf("%02X",$names,00);
if($names >=255) { $AA = substr($AA,1,2); } else { $AA = sprintf("%02X",$names,00); }
$BB = sprintf("%02X",$BB,00);
$HH = sprintf("%02X",$HH,00);
$ZZ = sprintf("%02X",$ZZ,00);

$newitem = $AA.$BB.$CC.$DDEE.$HH.$ZZ.$FF;

$item = ItemInfo($newitem);
if($ops>$shopy['limit']['item_excellent']) { echo '<br />The maximum excellent options an item can have are #<b>'.$webshop['limit']['item_excellent'].'</b>, do not exceed them!'; $error = true; }

if(@$online) { echo "<br />Your account is online.Must to be offline to buy items"; $error = true; }
elseif($mycreds['credits'] < $item['credits']) { echo '<br />You do not have enough credits to do that.'; $error = true; }
elseif(($mycreds['credits']-$item['credits'])<0) { echo '<br />You do not have enough credits to do that.'; $error = true; }
elseif($i_info['credits']==0) { echo '<br />That item is not for sale'; $error = true; }
//Searcher
$mycuritems = substr(mssql_get_last_message(mssql_query("declare @it varbinary(1920) set @it=(select [Items] from [warehouse] where [AccountID]='".$_SESSION['dt_username']."'); print @it;")),2);       
$test        = 0;
$slot = smartsearch($mycuritems,$i_info['X'],$i_info['Y']);
$test = $slot * 20;

if($slot==1337) { echo "Your warehouse is fulls.Please make some space"; $error = true; }
if(!$error) {
$mynewitems = substr_replace($mycuritems,$newitem,$test,20);
mssql_query("Update [warehouse] set [Items]=0x" . $mynewitems . " WHERE [AccountId]='" . secure($_SESSION['dt_username']) . "'");
mssql_query("Update [MEMB_CREDITS] set [credits]=[credits]-'".$item['credits']."' WHERE [memb___id]='" . secure($_SESSION['dt_username']) . "'
");
var_dump ($item); // tuk wrushta dannite za predmeta

echo "<br /><div style=\"color:#fff\">Item was added in your warehouse</div><br /><div style='$item[style];width: ".($item['X']*32)."px;height: ".($item['Y']*32)."px;'$item[nfo]></div><img src='img/l.gif' Onload=\"logged()\">";
}
}





?>
 

Wikko0

Well-Known Member
Joined
Oct 17, 2012
Messages
659
Reaction score
261
ItemInfo функцията
Code:
<?
$cat = array(0=>1,1=>1,2=>1,3=>1,4=>1,5=>2,6=>3,7=>3,8=>3,9=>3,10=>3,11=>3);
function ItemInfo($_item,$type=false)
{
global $shopy,$harmony_opt,$socket_type,$cat;
if (substr($_item,0,2)=='0x') $_item = substr($_item,2);
if ((strlen($_item)!=20) || (!ereg("(^[a-zA-Z0-9])",$_item)) || ($_item == 'FFFFFFFFFFFFFFFFFFFF')) return false;

    // Get the hex contents
    $sy     = hexdec(substr($_item,0,2));         // Item ID
    $iop     = hexdec(substr($_item,2,2));         // Item Level/Skill/Option Data
    $itemdur= hexdec(substr($_item,4,2));         // Item Durability
    $serial    = substr($_item,6,8);                // Item SKey
    $ioo     = hexdec(substr($_item,14,2));         // Item Excellent Info/ Option
    $ac    = hexdec(substr($_item,16,2));             // Ancient data
    $itt     = hexdec(substr($_item,18,2));         // Item Type

    
    $credits = 0;
    $itemtype = $itt/16;
    // The ancient types with no set options
    if ($ac==4)
        $ac=5;
    if ($ac==9)
        $ac=10;
    // Debug
    switch ($itemtype) {
        case 12:
            $itemtype=14;
            break;
        case 13:
            $itemtype=12;
            break;
        case 14:
            $itemtype=13;
            break;
    }
    // Skill Check
    if ($iop<128)
        $skill    = '';
    else {
        $skill    = '<b>This weapon has a special skill</b>';
        $iop    = $iop-128;
        $credits += $shopy['credits']['itemskill'];
    }
    // Item Level Check
    $itemlevel    = floor($iop/8);
    $iop        = $iop-$itemlevel*8;
    // Luck Check
    if($iop<4)
        $luck    = '';
    else {
        $luck    = "Luck (success rate of jewel of soul +25%)<br>Luck (critical damage rate +5%)";
        $iop    = $iop-4;
        $credits += $shopy['credits']['itemsluck'];
    }
    // Excellent option check
    $exc = false;   
    if($ioo>=64)    { $iop+=4; $ioo+=-64; $exc = true; }
    if($ioo<32)    { $iopx6=0; } else { $iopx6=1; $ioo+=-32; $exc = true; }
    if($ioo<16)    { $iopx5=0; } else { $iopx5=1; $ioo+=-16; $exc = true; }
    if($ioo<8)    { $iopx4=0; } else { $iopx4=1; $ioo+=-8; $exc = true; }
    if($ioo<4)    { $iopx3=0; } else { $iopx3=1; $ioo+=-4; $exc = true; }
    if($ioo<2)    { $iopx2=0; } else { $iopx2=1; $ioo+=-2; $exc = true; }
    if($ioo<1)    { $iopx1=0; } else { $iopx1=1; $ioo+=-1; $exc = true; }
    
    $fquery        = mssql_query("select * from [WebShop] where [id]=".$sy." and [type]=".$itemtype." and [stickLevel]=".$itemlevel);
    if (mssql_num_rows($fquery)<1)
    {
        $fquery    = mssql_query("select * from [WebShop] where [id]=".$sy." and [type]=".$itemtype);
        $nolevel= 0;
    } else
        $nolevel=1;
    if (mssql_num_rows($fquery)<1) {
        $newtype=(int) ($itemtype-0.5);
        $fquery    = mssql_query("select * from [WebShop] where [id]=".$sy." and [type]=".$newtype);
        $nolevel= 0;
        if (mssql_num_rows($fquery)>0){
            $refop    = "<font color=#F6358A>".$refinery[$newtype];
            if ($newtype<7)
                $refop2 ="Pow Success Rate +10";
            else
                $refop2 = "Def Success rate +10";
            $refop .= '<br>'.$refop2.'</font></b>';
            $credits += $shopy['credits']['itemsref'];
        }
        
    }

    $fresult    = mssql_fetch_array($fquery);   
    $iopxltype    = $fresult['ex_type'];
    $itemname    = $fresult['name'];
    // Case that item is not found -> stop the proccess
    if (!$fresult)
        return false;

    $itemexl = "";
    switch ($iopxltype) {
    case 0 :
        $op1    = 'Increase Mana per kill +8';
        $op2    = 'Increase hit points per kill +8';
        $op3    = 'Increase attacking(wizardly)speed+7';
        $op4    = 'Increase wizardly damage +2%';
        $op5    = 'Increase Damage +level/20';
        $op6    = 'Excellent Damage Rate +10%';
        $inf    = 'Additional Damage';
        break;
    case 1:
        $op1    = 'Increase Zen After Hunt +40%';
        $op2    = 'Defense success rate +10%';
        $op3    = 'Reflect damage +5%';
        $op4    = 'Damage Decrease +4%';
        $op5    = 'Increase MaxMana +4%';
        $op6    = 'Increase MaxHP +4%';
        $inf    = 'Additional Defense';
        $skill    = '';
        break;
    case 2:
        $op1    = ' Increased Health +'.(50+(5*$itemlevel));
        $op2    = ' Increased Mana +'.(50+(5*$itemlevel));
        $op3    = " Ignores 3% of your opponent\'s armor";
        $op4    = ' Increase Stamina +50';
        $op5    = ' Increase Attacking Speed +5';
        $op6    = '';
        $inf    = 'Additional Damage';
        $skill    = '';
        $nocolor= true;
        $wings = true;
        break;
    case 4: // v0.9
        $op1    = " Ignores 5% of your opponent\'s armor";
        $op2    = ' 10% chance to fully reflect incoming damage';
        $op3    = ' 5% rate / atack to recover Life completly';
        $op4    = ' 5% rate / atack to recover Mana completly';
        $op5    = '';
        $op6    = '';
        $inf    = 'Additional Damage';
        $skill    = '';
        $nocolor= true;
        $wings2 = true;
        break;
    }
    
    if ($iopx1==1) { $itemexl.='^^'.$op1; $credits += $shopy['credits']['itemexl']; }
    if ($iopx2==1) { $itemexl.='^^'.$op2; $credits += $shopy['credits']['itemexl']; }
    if ($iopx3==1) { $itemexl.='^^'.$op3; $credits += $shopy['credits']['itemexl']; }
    if ($iopx4==1) { $itemexl.='^^'.$op4; $credits += $shopy['credits']['itemexl']; }
    if ($iopx5==1) { $itemexl.='^^'.$op5; $credits += $shopy['credits']['itemexl']; }
    if ($iopx6==1) { $itemexl.='^^'.$op6; $credits += $shopy['credits']['itemexl']; }

    if ($fresult['optionType']==1) {
        $itemoption= ($iop).'%';
        $inf    = ' Automatic HP Recovery rate ';
    } elseif ($fresult['optionType']==2) {
        $itemoption= $iop*5;
        $inf    = ' Additional Defense rate ';
    }
    elseif($wings && !$iopx6 && ($fresult['id'] == 4 OR $fresult['id'] == 5))
    {
        $itemoption= ($iop).'%';
        $inf    = ' Automatic HP Recovery rate ';
        $hp = true;
    }   
    elseif($wings2 && !$iopx6 && !$iopx5)
    {
        $itemoption= ($iop).'%';
        $inf    = ' Automatic HP Recovery rate ';
        $hp = true;
    }   
    else
        $itemoption    = $iop*4;

    $credits += $iop*$shopy['credits']['itemopt'];
    $c        = '#FFFFFF'; // White -> Normal Item
    if (($iop>1) || ($luck!='')) $c = '#8CB0EA';
    if ($itemlevel>6) $c = '#F4CB3F';
    $tipche        = 0;
    if ($itemexl!='') {         // Green -> Excellent Item
        $c    = '#2FF387';
        $tipche    = 1;
    }
    if ($itemoption==0)
        $itemoption    = '';
    else
        $itemoption     = $inf." +".$itemoption;

    if ($itemexl!='')
        $incrall=20;

    if ($fresult['cmd'])
        $fresult['cmd']+=$incrall;

    if ($fresult['str'])
        $fresult['str']+=($itemlevel*7)+($itemoption*5)+$incrall;

    if ($fresult['agi'])
        $fresult['agi']+=($itemlevel*4)+$incrall;

    // In case the item is ancient
    if ($ac>0) {
        $c    = '#2347F3';// Blue -> Ancient Item
        if ($itemoption)
            $itemoption .= "<br>";
        $itemoption.='Ancient: +'.$ac.' stamina';
        $tipche=2;
        $itemname = 'Ancient '.$itemname;
        $ancient = "<br /><br /><font color=#F4CB3F>Set Item Option Info</font><br /><br /><font color=gray>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</font>";
    }
    if (@$nocolor)     $c='#F4CB3F';
    if(@$hp AND $itemoption) { $c = '#ff00ff'; $hp7 = '+'.($iop).'% HP'; }

    // Fenrir (from v0.4);
    if (($fresult['type']==12) && ($fresult['id']==37))
    {
        $skill    = "Plasma storm skill (Mana:50)";
        $c    = "#8CB0EA";
        if ($iopx1==1) {
            $itemname.=" +Destroy";
            $itemoption="Increase final damage 10%<br>Increase speed";
        }
        elseif ($iopx2==1) {
            $itemname.=" +Protect";
            $itemoption="Absorb final damage 10%<br>Increase speed";
        }
        elseif ($iopx3==1) { // v0.9
            $itemname="<font color=#F4CB3F>Golden Fenrir</font>";
            $itemoption="Increase speed";
        }
    }
    else
        if ((@!$nocolor) &&($itemexl!='') && ($itemname)) $itemname = 'Excellent '.$itemname;
        /*
        if((@!$nocolor) && (hexdec(substr($_item,14,2))>0) && ($itemname) && ($ac>0)) { $itemname = 'Excellent Ancient '.$itemname; $ancient = "<br /><br /><font color=#F4CB3F>Set Item Option Info</font><br /><br /><font color=gray>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</font>"; }
        elseif((@!$nocolor) && (hexdec(substr($_item,14,2))==0) && ($itemname) && ($ac>0)) { $itemname = 'Ancient '.$itemname; }
        elseif((@!$nocolor) && ($itemexl!='') && ($itemname) && ($ac==0)) { $itemname = 'Excellent '.$itemname; }
        */
    if ($nolevel==1)
        $ilvl=0;
    else
        $ilvl=$itemlevel;
    
$credits += $itemlevel*$shopy['credits']['itemlvl'];
if($harmony_opt[$cat[$fresult['category']]][$harmony_t]['name']) { $credits += $shopy['credits']['itemshar']; }

$s = 1;
while($socket[$s])
{
    if($socket[$s] != '255')
    {
    $socket_i .= "Socket $s: ".$socket_type[$socket[$s]]."^^";
    $socket_items = true;
    }
    $s++;
}
if($socket_items) { $socket_item = "^^^^Socket Item Option Info^^^^$socket_i"; }
    
$output['bcredits'] = $fresult['credits'];
$output['credits'] = ($fresult['credits']*$shopy['credits']['multiplier'])+$credits;
$output['category'] = $fresult['category'];
$output['name'] = $itemname;
$output['hp'] = $hp7;
$output['level']= $ilvl;
$output['opt']    = $itemoption;
$output['exl']    = $itemexl;
$output['luck']    = $luck;
$output['skill'] = $skill;
$output['ref']    = $refop;
$output['harmony'] = $harmony_opt[$cat[$fresult['category']]][$harmony_t]['name'];
$output['harmony_lvl'] = $harmony_opt[$cat[$fresult['category']]][$harmony_t]['opt'][$harmony_lvl];
$output['sockets'] = $socket_item;
$output['dur']    = $itemdur;
$output['X']    = $fresult['X'];
$output['Y']    = $fresult['Y'];
$output['refund'] = $fresult['cansellitem'];
$output['thumb'] = ws_image($fresult['id'], $fresult['type'], $tipche, $itemlevel);
$output['color'] = $c;
$output['sn']    = $serial;

$itemformat ='<div align=center style=\'padding-left: 6px; padding-right:6px;font-family:arial;font-size: 10px;\'>[IMG]<span style=\'font-weight:bold;font-size: 11px;\'>[Name]</span> Durability [Skill] [Refinery] [Harmony] [Luck] [Excellent] [Socket] [Ancient] [note]</span></div>';
if($output['level']) $plusche = '+'.$output['level'];
$overlib = @str_replace('[Name]','<span style=color:'.$output['color'].'>'.$output['name'].' '.$plusche.' '.$hp7.'</span>', addslashes($itemformat));
if((!@$output['luck']) && (!@$output['exl']) && (!@$output['skill']) && (!@$output['option'])) $addx='<br />';
$overlib = str_replace('Durability','<br /><br />'.$output['dur'].' durability', $overlib);
if(@$output['opt'])  $option='<br /><font color=#9aadd5>'.$output['opt'].'</font>';
if(@$output['luck']) $luck='<br /><font color=#9aadd5>'.$output['luck'].'';
$overlib = @str_replace('[Luck]', $luck.$option.'</font>', $overlib);
if(@$output['ref']) @$refine = $output['ref'].'<br />';
$overlib = @str_replace('[Refinery]', $refine, $overlib);
if(@$output['harmony']) @$harmony='<br /><font color=#F4CB33>'.$output['harmony'].$output['harmony_lvl'].'</font><br />';
$overlib = @str_replace('[Harmony]', $harmony, $overlib);                           
if(@$output['skill']) $skill='<br /><font color=#9aadd5>'.$output['skill'].'</font><br />';
$overlib = @str_replace('[Skill]', $skill, $overlib);
if(@$output['exl']) $exl='<font color=#8CB0EA>'.str_replace('^^','<br />', $output['exl']).'</font>';
$overlib = @str_replace('[Excellent]', $exl,$overlib);
if(@$output['sockets']) $sockets = str_replace('^^','<br />', $output['sockets']);
$overlib = @str_replace('[Socket]',$sockets,$overlib);
$overlib = @str_replace('[Ancient]',$ancient,$overlib);
$overlib = @str_replace('[note]', $_rnote,$overlib);
if(@$output['thumb'] AND @$type) $img = "<img src=\'$output[thumb]\'><br />";
$overlib = @str_replace('[IMG]',$img,$overlib);
$output['style'] = "background: url($output[thumb]) center center no-repeat;";
$output['nfo'] = "onmouseover=\"return overlib('".$overlib."');\" onmouseout=\"return nd();\"";
$output['overlib'] = $overlib;
return $output;

unset($output,$itemformat,$credits);
}

function ws_image($theid,$type,$ExclAnci,$lvl=0) {
@include('shopy.config.php');
    switch ($type) {
        case 14:
            $type=12;
            break;
        case 12:
            $type=13;
            break;
        case 13:
            $type=14;
            break;
    }
    switch ($ExclAnci) {
        case 1:    // Excellent item
        $tnpl    = '10';
        break;
        case 2:    // Ancient item
        $tnpl    = '01';
        break;
        default:// Normal Item
        $tnpl    = '00';

    }
    $itype    = $type*16;
    if ($theid>31) {
        $nxt    ="F9";
        $theid    +=-32;
    }
    else
        $nxt    = "00";
    if ($itype<128)  {
        $tipaj = "00";
        $theid += $itype;
    } else {
        $tipaj = "80";
        $itype += -128;
        $theid += $itype;
    }
    $itype    += $theid;
    $itype    = sprintf("%02X",$itype,00);
    $iid     = sprintf("%02X",$theid,00);

    if (file_exists($shopy['image']['path'].'/'.$tnpl.$itype.$tipaj.$nxt.'.gif'))
        $output = $shopy['image']['path'].'/'.$tnpl.$itype.$tipaj.$nxt.'.gif';
    else
        $output = $shopy['image']['path'].'/00'.$itype.$tipaj.$nxt.'.gif';

    $i    = $lvl+1;   
    while ($i>0) {
        $i+=-1;
        $il=sprintf("%02X", $i, 00);
        if (file_exists($shopy['image']['path'].'/'.$tnpl.$itype.$tipaj.$nxt.$il.'.gif')){
            $output=$shopy['image']['path'].'/'.$tnpl.$itype.$tipaj.$nxt.$il.'.gif';
            $i=0;
        }
            
    }
    return $output;
}
function all_items($account,$lenght =1200,$table = "warehouse",$user_col="AccountId",$item_col="items") {
            if(phpversion() >= "5.3"){
                $itemsa = mssql_fetch_array(mssql_query("SELECT [".$item_col."] FROM [".$table."] WHERE [".$user_col."]='".$account."'"));
                  return strtoupper(bin2hex($itemsa[$item_col]));
            }
            else{
                  return substr(mssql_get_last_message(mssql_query("declare @it varbinary(1200) set @it=(select [Items] from [warehouse] where [AccountID]='".$account."'); print @it;")),2);               
            }
        }
function smartsearch($whbin, $itemX, $itemY) {
        if (substr($whbin, 0, 2) == '0x') {
            $whbin = substr($whbin, 2);
        }

        $items = str_repeat('0', 120);
        $itemsm = str_repeat('1', 120);
        $i = 0;
        while ($i < 120) {
            $_item = substr($whbin, (20 * $i), 20);

            $lvl = hexdec(substr($_item, 2, 2)); //Level,Option,Skill,Luck
            if ($lvl >= 128) {
                $lvl = $lvl - 128;
            }
            $itemlevel = floor($lvl / 8);

            $level = substr($_item, 0, 1);
            $level2 = substr($_item, 1, 1);
            $level3 = substr($_item, 14, 2);
            $level1 = hexdec(substr($level, 0, 1));
            if (($level1 % 2) <> 0) {
                $level2 = "1" . $level2;
                $level1--;
            }
            if (hexdec($level3) >= 128) {
                $level1 += 16;
            }
            $level1 /= 2;
            $id = hexdec($level2);

            $result = mssql_query("select [x],[y] from [DTweb_JewelDeposit_Items] where [id]={$id} and [type]={$level1}");
            $res = mssql_fetch_row($result);


            $y = 0;
            while ($y < $res[1]) {
                $y++;
                $x = 0;
                while ($x < $res[0]) {
                    $items = substr_replace($items, '1', ($i + $x) + (($y - 1) * 8), 1);
                    $x++;
                }
            }
            $i++;
        }
        $y = 0;
        while ($y < $itemY) {
            $y++;
            $x = 0;
            while ($x < $itemX) {
                $x++;
                $spacerq[$x + (8 * ($y - 1))] = true;
            }
        }
        $walked = 0;
        $i = 0;
        while ($i < 120) {
            if (isset($spacerq[$i])) {
                $itemsm = substr_replace($itemsm, '0', $i - 1, 1);
                $last = $i;
                $walked++;
            }
            if ($walked == count($spacerq)) {
                $i = 119;
            }
            $i++;
        }
        $useforlength = substr($itemsm, 0, $last);
        $findslotlikethis = '^' . str_replace('++', '+', str_replace('1', '+[0-1]+', $useforlength));
        $i = 0;
        $nx = 0;
        $ny = 0;
        while ($i < 120) {
            if ($nx == 8) {
                $ny++;
                $nx = 0;
            }
            if ((eregi($findslotlikethis, substr($items, $i, strlen($useforlength)))) && ($itemX + $nx < 9) && ($itemY + $ny < 16)) {
                return $i;
            }
            $i++;
            $nx++;
        }
        return 1337;
    }
?>
 

r00tme

Member
Joined
Feb 4, 2021
Messages
73
Reaction score
63
Интересно! Уж, функцията е за сезон 1 пък гледам сокети и хармонии викаш горе някакви глобали. Дарка е прав, няма друг начин освен да дебъгваш. Първо виж дали тази функция чете опциите правилно, след това кредитите дали добавя правилно (не в акаунта, а в самата функция), убеди се че не се презаписват (или изтриват) някъде стойностите след добавките и т.н. Като за начало махни всичко, което няма общо с хекс дължина 20, най-малкото ще си почистиш кода за да се ориентираш по-добре.
 
  • Like
Reactions: Wikko0

Wikko0

Well-Known Member
Joined
Oct 17, 2012
Messages
659
Reaction score
261
Така и не можах да намеря грешката, затова го пренаписах на ново и вече уж работи както трябва :D
Явно трябвало по трудния начин да се направи..
 

mistar_ti

Active Member
Joined
Dec 5, 2010
Messages
163
Reaction score
104
Сравни си кода и освен това спри да пишеш на notepad++ много е добър за бърз едит обаче за повечко код не може да откриваш грешките си още снощи шях да ти пиша от безплатните visual studio code + няколко добавки (Auto close tag, PHP DockBlocker, PHP Inteliphens и Rainbow brackets) и (Dark+ Tailwind) тема ще улеснят много работата ти.
 
  • Like
Reactions: Dea7h

Wikko0

Well-Known Member
Joined
Oct 17, 2012
Messages
659
Reaction score
261
Пиша на Phpstorm, а това не беше моят компютър 😁
 

r00tme

Member
Joined
Feb 4, 2021
Messages
73
Reaction score
63
PHP на notepad++ само, той не заслуважа повече внимание тоя език :D
 
  • Haha
Reactions: Wikko0

RaFa

Team Member
Joined
Jan 24, 2009
Messages
783
Reaction score
472
Гледам си се оправил, но все пак да ти кажа какво видях почти веднага :D

В ItemInfo, ако HEX-a е с дължина повече от 20 символа, връщаш false.
Във всички if-ове освен, там където ти връща правилната информация за предмета, HEX-a e над 20 символа:
PHP:
if (isset($_GET['ai'])) {
    // ....
    $itemhex  = ItemInfo($AA . "6F93A2967A007F09" . $FF . "000000000000");
    // ....
}

if ($_GET['ia']) {
    // ....
    $newitem    = $AA . "6F93" . $DDEE . "7F09" . $FF . "000000000000";
    // ....
}

А защо ти се добавя предметът, пък не ти се махат кредитите... най-вероятно си влизал в някой if, който не трябва и си презаписвал променливи *тук гадая*