- Joined
- Oct 17, 2012
- Messages
- 660
- Reaction score
- 263
Здравейте! Ще пробвам да обясня проблема си. Смятам, че има проблем някъде във функцията ItemInfo, а не намирам къде точно.
Та проблема е следния - предметите се добавят, но кредитите, които трябва да се образуват от функцията ItemInfo не се вземат от потребителя. Проблема е при всички предмети с изключение на Armor-ите и Sword-oвете. Когато направя var_dump на предмет различен от армор и слорд и дава false, а с армор и слорд си работи перфектно и връща всичките данни на предмета.Ето ги и кодовете
ItemAdder.php
Та проблема е следния - предметите се добавят, но кредитите, които трябва да се образуват от функцията 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> ";
//
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.' <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()\">";
}
}
?>