[Help] Трябва ми някой който чатка hex

KR373N

Well-Known Member
Joined
May 18, 2008
Messages
1,943
Reaction score
446
искам да направа този код от 32 битов на 20 битов за версия 99б

PHP:
<?
include	("usernameaccess.php");
function	fibonaci($value,	$first)	{
	if	($value	==	'0')
	{
		$i_current	=	0;
	}
	elseif	($value	==	'1')
	{
		$i_current	=	$first;
	}
	else
	{
		$i_last		=	$first;
		$i_current	=	$first;
		$i			=	0;
		$k			=	2;
		do
		{
			$i			=	$i_current	+	$i_last;
			$i_last		=	$i_current;
			$i_current	=	$i;
			$k++;
		}
		while	($k	<=	$value);
	}
	return	$i_current;
}
if	(isset($_POST['step']))
{
	$select_cat	=	mssql_query("select * from EW_CATEGORY order by id_cat");
	if	(mssql_num_rows($select_cat)	<=	0)
	{
		echo "<script type=\"text/javascript\">getitem('step=1','buycontet');</script>";
		exit();
	}
	$myrow_cat	=	mssql_fetch_array($select_cat);
	?>
	<form action="" method="post" id="form1">
	<table align="center" style="margin:0px auto;" cellspacing="3">
			<tr>
				<td align="right"><? echo	select_item_type;?>:</td>
				<td>
					<select onChange="getitem('step1=1&id_cat=' + this.form.id_cat.options[this.form.id_cat.selectedIndex].value,'step1');" name="id_cat" id="id_cat">
					<option value="no">< < < NONE > > ></option>
						<?
						do
						{
							printf("<option value='%s'>%s</option>",	$myrow_cat['id_cat'],	UTF8RawUrlDecode(htmlspecialchars($myrow_cat['name'])));
						}
						while	($myrow_cat	=	mssql_fetch_array($select_cat));
						?>
					</select>
				</td>
			</tr>
	</table>
	<div id="step1"></div>
	</form>
	<?
	exit();
}
elseif	(isset($_POST['step1']))
{
	if	($WebShop['show_zero']	==	0)	$show_zero	=	'and credits>0';
	else	$show_zero	=	'';
	$id_cat			=	$_POST['id_cat'];
	if ($id_cat	==	'no')	exit();
	$select_item	=	mssql_query("select * from EW_ITEMS where id_cat=$id_cat  $show_zero order by id_item");
	if	(mssql_num_rows($select_item)	<=	0)
	{
		echo "<script type=\"text/javascript\">getitem('step=1','buycontet');</script>";
		exit();
	}
	$myrow_item		=	mssql_fetch_array($select_item);
	?>
	<table align="center" style="margin:0px auto;" cellspacing="3">
			<tr>
				<td align="right"><? echo	select_item_name;?>:</td>
				<td>
					<select id="item_id" onChange="getitem('step2=1&item_id=' + document.getElementById('item_id').value,'step2');" name="item_id">
					<option value="no">< < < NONE > > ></option>
						<?
						do
						{
							printf("<option value='%s'>%s | %s credits</option>",	$myrow_item['id'],	UTF8RawUrlDecode(htmlspecialchars($myrow_item['name'])),	$myrow_item['credits']);
						}
						while	($myrow_item	=	mssql_fetch_array($select_item));
						?>
					</select>
				</td>
			</tr>
	 </table>
		<div id="step2"></div>
	<?
	exit();
}
elseif	(isset($_POST['step2']))
{
	$item_id		=	$_POST['item_id'];
	if ($item_id	==	'no')	exit();
	$select_item	=	mssql_query("select * from EW_ITEMS where id='$item_id'");
	if	(mssql_num_rows($select_item)	<=	0)
	{
		echo "<script type=\"text/javascript\">getitem('step=1','buycontet');</script>";
		exit();
	}
	$myrow_item	=	mssql_fetch_array($select_item);
			if	($myrow_item['exe_type']	!=	5)
			{
	?><table align="center" style="margin:0px auto;" cellspacing="3">
				<tr>
					<td>Select Item Options:</td>
					<td>
						<?
						if	($myrow_item['skill']	==	'1')
						{
							?>
							<input onclick="viewitem(document.getElementById('item_id').value);" id='item_skill' name="item_skill" value="1" type="checkbox"><label for="item_skill"> Skill |
							<?
							$krr	=	$myrow_item['credits']*$WebShop['item_skill'];
							echo	$krr." credits</label >";
						}
						if	($myrow_item['luck']	==	'1')
						{
							?>
							<input onclick="viewitem(document.getElementById('item_id').value);" id="item_luck" name="item_luck" value="1" type="checkbox"><label for="item_luck"> Luck |
							<?
							$krr	=	$myrow_item['credits']*$WebShop['item_luck'];
							echo	$krr." credits</label >";
						}
						?>
					</td>
				</tr>
				<tr>
					<td align="right">Additional Option:</td>
					<td>
						<select id="item_option" onchange="viewitem(document.getElementById('item_id').value);" name="item_option">
							<?					
							if	($myrow_item['id_cat']	!=	6)
							{
								$i	=	0;
								$ap	=	0;
								do
								{
									$krr	=	fibonaci($i,	$WebShop['kr_per_option'])*$myrow_item['credits'];
									printf	("<option value='%s'>%s | %s credits</option>",	$i,	$ap,	$krr);
									$i++;
									$ap		=	$ap + 4;
								}
								while	($i	<=	$myrow_item['max_option']);
							}
							else
							{
								$i	=	0;
								$ap	=	0;
								do
								{
									$krr	=	fibonaci($i,	$WebShop['kr_per_option'])*$myrow_item['credits'];
									printf	("<option value='%s'>%s | %s credits</option>",$i,	$ap,	$krr);
									$i++;
									$ap		=	$ap + 5;
								}
								while	($i	<=	$myrow_item['max_option']);
							}
							?>					
						</select>
					</td>
				</tr>
				<tr>
					<td align="right">Level:</td>
					<td>
						<select onChange="getitem('steph=1&hoption=' + this.form.harmony.options[this.form.harmony.selectedIndex].value + '&itemtype=' + this.form.id_cat.options[this.form.id_cat.selectedIndex].value + '&itemlevel=' + this.form.item_level.options[this.form.item_level.selectedIndex].value,'hvalue');" name="item_level" id="item_level">
							<?
							$i	=	0;
							do
							{
								$krr	=	fibonaci($i,	$WebShop['kr_per_level'])*$myrow_item['credits'];
								printf	("<option value='%s'>%s | %s credits</option>",$i,$i,$krr);
								$i++;
							}
							while	($i	<=	$myrow_item['max_level']);
							?>
						</select>
					</td>
				</tr>
				<? if ($myrow_item['refinery']	==	'1')	{?>
					<tr>
						<td align="right"><label for="refinery">Refinery Lvl 380 Option:</label></td>
						<td>
							<input onclick="viewitem(document.getElementById('item_id').value);" id='refinery' name="refinery" value="1" type="checkbox"> <? echo	$WebShop['refinery_price']." credits";?>
						</td>
					</tr>
				<? }?>
				<? if ($myrow_item['harmony']	==	'1')	{?>
					<tr>
						<td align="right">Harmony Option:</td>
						<td>
							<select onChange="getitem('steph=1&hoption=' + this.form.harmony.options[this.form.harmony.selectedIndex].value + '&itemtype=' + this.form.id_cat.options[this.form.id_cat.selectedIndex].value + '&itemlevel=' + this.form.item_level.options[this.form.item_level.selectedIndex].value,'hvalue');" name="harmony" id="harmony">
							<?
								echo "<option value='0'>< < < NONE > > > | 0 credits</option>";
							if ($myrow_item['id_cat']	<	5)
							{
								echo "<option value='1'>Min. attack increase</option>";
								echo "<option value='2'>Max. attack increase</option>";
								echo "<option value='3'>Required strength decrease</option>";
								echo "<option value='4'>Required agility decrease</option>";
								echo "<option value='5'>Attack (Max, Min)</option>";
								echo "<option value='6'>Critical Damage increase</option>";
								echo "<option value='7'>Skill Damage increase</option>";
								echo "<option value='8'>Attack Success Rate (PvP) increase</option>";
								echo "<option value='9'>SD Reduction</option>";
								echo "<option value='10'>SD Ignore Rate</option>";
							}
							elseif ($myrow_item['id_cat']	==	5)
							{
								echo "<option value='1'>Wizardly attack increase</option>";
								echo "<option value='2'>Required strength decrease</option>";
								echo "<option value='3'>Required agility decrease</option>";
								echo "<option value='4'>Skill Damage increase</option>";
								echo "<option value='5'>Critical Damage increase</option>";
								echo "<option value='6'>SD Reduction</option>";
								echo "<option value='7'>Attack Success Rate (PvP) increase</option>";
								echo "<option value='8'>SD Ignore Rate</option>";
							}
							else
							{
								echo "<option value='1'>Defense increase</option>";
								echo "<option value='2'>Max. AG Increase</option>";
								echo "<option value='3'>Max. HP increase</option>";
								echo "<option value='4'>Life auto increment increase</option>";
								echo "<option value='5'>Mana auto increment increase</option>";
								echo "<option value='6'>Defense success rate increase(PVP)</option>";
								echo "<option value='7'>Damage decrement increase</option>";
								echo "<option value='8'>SD Ratio Rate increase</option>";
							}
							?>
							</select> | <? echo	$WebShop['harmony_price']." credits";?>
						</td>
					</tr>
				</table><div id="hvalue"></div><table align="center" style="margin:0px auto;" cellspacing="3">
				<? }?>
				<?
				if ($myrow_item['socket_item']	>	0)	{?>
					<tr>
						<td></td><td>
							<?	$krr	=	$WebShop['socket_option']*$myrow_item['credits'];
								echo	"First socket option price: $krr credits.<br>Next socket option price: $krr * (".$WebShop['socket_option_inc']." * count of exe option) credits.";	?>
						</td>
					</tr>
				<?
					for ($i=1;$i<=$myrow_item['socket_item'];$i++)
					{?>
						<tr>
							<td align="right">Socket <? echo $i;?>:</td>
							<td>
								<select onchange="viewitem(document.getElementById('item_id').value);" name="socket<? echo $i;?>" id="socket<? echo $i;?>">
								<?
									echo "<option value='255'>NONE | 0 credits</option>";
									echo "<option value='254'>Socket $i: No item application | $WebShop[socket_slot] credits</option>";
									echo "<option value='0'>Socket $i: Fire((Level type)Attack/Wizardly increase +24)</option>";
									echo "<option value='1'>Socket $i: Fire(Attack speed increase +7)</option>";
									echo "<option value='2'>Socket $i: Fire(Maximum attack/Wizardly increase +30)</option>";
									echo "<option value='3'>Socket $i: Fire(Minimum attack/Wizardly increase +20)</option>";
									echo "<option value='4'>Socket $i: Fire(Attack/Wizardly increase +20)</option>";
									echo "<option value='5'>Socket $i: Fire(Slight AG reduction +40%)</option>";
									echo "<option value='10'>Socket $i: Ice(Attack defensibility increase +10)</option>";
									echo "<option value='11'>Socket $i: Water(Defensibility increase +30)</option>";
									echo "<option value='12'>Socket $i: Water(Shield protection increase +7%)</option>";
									echo "<option value='13'>Socket $i: Water(Damage reflection +5%)</option>";
									echo "<option value='14'>Socket $i: Water(Damage reduction +4%)</option>";
									echo "<option value='16'>Socket $i: Ice(Monster destruction for the Life increase +8)</option>";
									echo "<option value='17'>Socket $i: Ice(Monster destruction for the Mana increase +8)</option>";
									echo "<option value='18'>Socket $i: Ice(Skill attack increase +37)</option>";
									echo "<option value='19'>Socket $i: Ice(Attack accuracy increase +25)</option>";
									echo "<option value='20'>Socket $i: Ice(Item strengthener +30%)</option>";
									echo "<option value='21'>Socket $i: Ice(Automatic Life recovery increase +8)</option>";
									echo "<option value='22'>Socket $i: Wind(Maximum Life increase +4%)</option>";
									echo "<option value='23'>Socket $i: Wind(Maximum Mana increase +4%)</option>";
									echo "<option value='24'>Socket $i: Wind(Automatic Mana recovery increase +8)</option>";
									echo "<option value='25'>Socket $i: Wind(Maximum AG increase +25)</option>";
									echo "<option value='26'>Socket $i: Wind(AG value increase +3)</option>";
									echo "<option value='29'>Socket $i: Lighting(Excellent damage increase +30)</option>";
									echo "<option value='30'>Socket $i: Lighting(Excellent damage rate increase +10%)</option>";
									echo "<option value='31'>Socket $i: Lighting(Critical damage increase +30)</option>";
									echo "<option value='32'>Socket $i: Lighting(Critical damage rate increase +8%)</option>";
									echo "<option value='36'>Socket $i: Ground(Stamina increase +30)</option>";
								?>
								</select>
							</td>
						</tr>
					<? }
				}?>
				<tr>
					<td align="right">Item Type:</td>
					<td>
						<input onClick="document.getElementById('step3').innerHTML='';viewitem(document.getElementById('item_id').value);" id='normal' name="item_type" type="radio" value="normal" checked><label for="normal">Normal</label>
						<?
						if	($myrow_item['ancient']	==	'1')
						{
							?>
							<input onClick="getitem('stepanc=1&id=<? echo $item_id;?>','step3');" id='ancient' name="item_type" type="radio" value="ancient"><label for="ancient">Ancient</label>
							<?
						}
						if	($myrow_item['exe_type']	!=	'4'	and	$myrow_item['max_exe_level']	>	0)
						{
							?>
							<input onClick="getitem('stepexe=1&id=<? echo $item_id;?>','step3');" id='excelence' name="item_type" type="radio" value="excelence"><label for="excelence">Excelence</label>
							<?
						}
						?>
					</td>
				</tr>
	 </table>
			<?
			}
			?>
			<div id="step3"></div>
			<center><input onclick="viewitem(document.getElementById('item_id').value + ',yes');" id="get_item" name="get_item" type="button" value="<? echo	get_item; ?>"></center>
<?
	exit();
}
elseif (isset($_POST['steph']))
{
	$hoption	=	$_POST['hoption'];
	$itemtype	=	$_POST['itemtype'];
	$itemlevel	=	$_POST['itemlevel'];
	echo harmonyselect($itemtype,$itemlevel,$hoption);
	exit();
}
elseif	(isset($_POST['stepexe']))
{
	$id				=	$_POST['id'];
	$select_item	=	mssql_query("select * from EW_ITEMS where id='$id' order by id");
	if	(mssql_num_rows($select_item)	<=	0)
	{
		echo "<script type=\"text/javascript\">getitem('step=1','buycontet');</script>";
		exit();
	}
	$myrow_item		=	mssql_fetch_array($select_item);
	?>
	<table align="center" style="margin:0px auto;" cellspacing="3">
		<tr>
			<td colspan="2">
				<?	$krr	=	$WebShop['exe_option']*$myrow_item['credits'];
					echo	"First exe option price: $krr credits.<br>Next exe option price: $krr * (".$WebShop['exe_option_inc']." * count of exe option) credits.";	?>
			</td>
		</tr>
			<tr>
				<td align="right" valign="top">Select Exe Options (max <?	echo	$myrow_item['max_exe_level'];	?>):</td>
				<td>
					<? 
					if	($myrow_item['exe_type']	!=	6)
					{
						$select_exetype	=	mssql_query("select * from EW_EXETYPE where exe_type='$myrow_item[exe_type]' order by exe_opt");
						$myrow_exetype	=	mssql_fetch_array($select_exetype);					
						$i				=	0;
						do
						{
							$i++;
							printf	("<input onclick=\"viewitem(document.getElementById('item_id').value);\" name='ex%s' id='ex%s' value='%s' type='checkbox'><label  for=\"ex%s\">%s</label><br>",	$i,	$i,	$i,	$i,	UTF8RawUrlDecode(htmlspecialchars($myrow_exetype['exe_value'])));
						}
						while	($myrow_exetype	=	mssql_fetch_array($select_exetype));
					}
					else
					{
						?>
					   	<input onclick="viewitem(document.getElementById('item_id').value);" id='fenrir1' name="fenrir" type="radio" value="1" checked><label for="fenrir1">Fenrir Destroy</label>
						<input onclick="viewitem(document.getElementById('item_id').value);" id='fenrir2' name="fenrir" type="radio" value="2"><label for="fenrir2">Fenrir Protect</label>
						<input onclick="viewitem(document.getElementById('item_id').value);" id='fenrir4' name="fenrir" type="radio" value="4"><label for="fenrir4">Golden Fenrir</label>
   						<?
					}
					?>
				</td>
			</tr>
	</table>
	<?
	exit();
}
elseif	(isset($_POST['stepanc']))
{
	$id				=	$_POST['id'];
	$select_item	=	mssql_query("select * from EW_ITEMS where id='$id'");
	if	(mssql_num_rows($select_item)	<=	0)
	{
		echo "<script type=\"text/javascript\">getitem('step=1','buycontet');</script>";
		exit();
	}
	$myrow_item	=	mssql_fetch_array($select_item);
	?>
	<table align="center" style="margin:0px auto;" cellspacing="3">
			<tr>
				<td align="right" valign="top">Select Ancient Option:</td>
				<td>
					<input onclick="viewitem(document.getElementById('item_id').value);" id='ancient1' name="ancient" type="radio" value="1" checked><label for="ancient1">+5 Stamina |
						<?
						$krr	=	$myrow_item['credits']*$WebShop['ancient1'];
						echo	$krr." credits";
						?>
						</label><br>
					<input onclick="viewitem(document.getElementById('item_id').value);" id='ancient2' name="ancient" type="radio" value="2"><label for="ancient2">+10 Stamina |
						<?
						$krr	=	$myrow_item['credits']*$WebShop['ancient2'];
						echo	$krr." credits";
						?>
						</label>
				</td>
			</tr>
	</table>
<?
	exit();
}
elseif	(isset($_POST['step3']))
{
	$total_kr		=	0;
	$id				=	$_POST['item_id'];
	if ($id	==	'no')	exit();
	$select_item	=	mssql_query("select * from EW_ITEMS where id='$id'");
	if	(mssql_num_rows($select_item)	==	0)
	{
		echo "<script type=\"text/javascript\">getitem('step=1','buycontet');</script>";
		exit();
	}
	$myrow_item		=	mssql_fetch_array($select_item);
	eval(exe_type ($myrow_item['exe_type']));
	$log0		=	$myrow_item['name'];
	$total_kr	+=	$myrow_item['credits'];
	if (!$_POST['pre_buy'])
	{
		$query		=	mssql_query("exec WZ_GetItemSerial");
		$serial		=	mssql_fetch_row($query);
		if			($_SERVER['itemlenght']	==	20)	$serial			=	"000".sprintf("%05X", $serial[0],00000);
		elseif		($_SERVER['itemlenght']	==	32)	$serial			=	sprintf("%08X", $serial[0],00000000);
		
	}
	else
	{
		$serial		=	'00000';
	}
	$value1		=	sprintf("%02X", $myrow_item['id_item'],00);
	$value2		=	0;
	$value6		=	0;
	if	($myrow_item['id_cat']	!=	5)	$value3	=	sprintf("%02X",	$myrow_item['durability'],	00);
	else	$value3	=	sprintf("%02X",	$myrow_item['magicdur'],	00);
	$value4		=	$serial;
	$itemtype	=	$myrow_item['id_cat'];
	$itemtype	=	$itemtype*16;
	if	(isset($_POST['refinery']))
	{
		$itemtype		+=	8;
		$total_kr		+=	$WebShop['refinery_price'];
	}
	$value7		=	sprintf("%02X", $itemtype,00);
	$value5		=	0;
	if	($myrow_item['exe_type']	!=	5)
	{
		$value2		+=	$_POST['item_level']*8;
		$nde		=	fibonaci($_POST['item_level'],	$WebShop['kr_per_level']);
		$total_kr	+=	$nde*$myrow_item['credits'];
		$log1		=	" + ".$_POST['item_level'];
		$exe_opts	=	0;
		if	($_POST['item_option']	>=	4) 
		{
			$value2		+=	$_POST['item_option']-4;
			$log2		=	" + ".($_POST['item_option']*4).$op7;
			$nde		=	fibonaci($_POST['item_option'],	$WebShop['kr_per_option']);
			$total_kr	+=	$nde*$myrow_item['credits'];
			$value5		+=	64;
		} 
		else	
		{
			$value2		+=	$_POST['item_option'];
			$log2		=	" + ".($_POST['item_option']*4).$op7;
			$nde		=	fibonaci($_POST['item_option'],	$WebShop['kr_per_option']);
			$total_kr	+=	$nde*$myrow_item['credits'];
		}
		if	($_POST['item_skill']	==	1) 
		{
			$value2		+=	128;
			$log3		=	" + skill";
			$total_kr	+=	$WebShop['item_skill']*$myrow_item['credits'];
		}
		if	($_POST['item_luck']	==	1) 
		{
			$value2		+=	4;
			$log4		=	" + luck";
			$total_kr	+=	$WebShop['item_luck']*$myrow_item['credits'];
		}
		if	($value2	<	0)	$value2	=	0;
		if	($_POST['ancient']	>	0)
		{
			$log5	=	" + ancient";
			switch	($_POST['ancient'])	{
				case	1:
					$value6		=	5;
					$total_kr	+=	$WebShop['ancient1']*$myrow_item['credits'];
					break;
				case	2:
					$value6		=	9;
					$total_kr	+=	$WebShop['ancient2']*$myrow_item['credits'];
					break;
			}
		}
		if	($_POST['fenrir'])
		{
			switch	($_POST['fenrir'])	{
				case	1:
					$value5		=	1;
					$log6		=	" (Fenrir Destroy)";
					$total_kr	+=	$WebShop['fenrir_destroy'];
					break;
				case	2:
					$value5		=	2;
					$log6		=	" (Fenrir Protect)";
					$total_kr	+=	$WebShop['fenrir_protect'];
					break;
				case	4:
					$value5		=	4;
					$log6		=	" (Golden Fenrir)";
					$total_kr	+=	$WebShop['golden_fenrir'];
					break;
			}
		}
		else
		{
			function	exeinc($value,$inc)
			{
				$return		=	1;
				if	($value	>	1)
				{
					for	($i	=	1;	$i	<	$value;	$i++)
					{
						$return	=	$return*$inc;
					}
				}
				return	$return;
			}
			if	($_POST['ex1'])	{
				$value5		+=	1;
				$log7		=	" + ".$op1;
				$exe_opts	++;
				$total_kr	+=	$WebShop['exe_option'] * exeinc($exe_opts,	$WebShop['exe_option_inc']) * $myrow_item['credits'];
			}
			if	($_POST['ex2'])	{
				$value5		+=	2;
				$log8		=	" + ".$op2;
				$exe_opts	++;
				$total_kr	+=	$WebShop['exe_option'] * exeinc($exe_opts,	$WebShop['exe_option_inc']) * $myrow_item['credits'];
			}
			if	($_POST['ex3'])	{
				$value5		+=	4;
				$log9		=	" + ".$op3;
				$exe_opts	++;
				$total_kr	+=	$WebShop['exe_option'] * exeinc($exe_opts,	$WebShop['exe_option_inc']) * $myrow_item['credits'];
			}
			if	($_POST['ex4'])	{
				$value5		+=	8;
				$log10		=	" + ".$op4;
				$exe_opts	++;
				$total_kr	+=	$WebShop['exe_option'] * exeinc($exe_opts,	$WebShop['exe_option_inc']) * $myrow_item['credits'];
			}
			if	($_POST['ex5'])	{
				$value5		+=	16;
				$log11		=	" + ".$op5;
				$exe_opts	++;
				$total_kr	+=	$WebShop['exe_option'] * exeinc($exe_opts,	$WebShop['exe_option_inc']) * $myrow_item['credits'];
			}
			if	($_POST['ex6']){
				$value5		+=	32;
				$log12		=	" + ".$op6;
				$exe_opts	++;
				$total_kr	+=	$WebShop['exe_option'] * exeinc($exe_opts,	$WebShop['exe_option_inc']) * $myrow_item['credits'];
			}
		}
	}
	else
	{
		$value2	+=	$myrow_item['max_level']*8;
		$log1	=	" + ".$myrow_item['max_level'];
		if	($myrow_item['max_option']	>=	4) 
		{
			$value2	+=	$myrow_item['max_option']-4;
			$log2	=	" + ".$myrow_item['max_option']*4;
			$value5	+=	64;
		} 
		else	
		{
			$value2	+=	$myrow_item['max_option'];
			$log2	=	" + ".$myrow_item['max_option']*4;
		}
		if	($myrow_item['skill']	==	1) 
		{
			$value2	+=	128;
			$log3	=	" + skill";
		}
		if	($myrow_item['luck']	==	1) 
		{
			$value2	+=	4;
			$log4	=	" + luck";
		}
		if	($value2	<	0)	$value2	=	0;
	
		if	($myrow_item['ancient']	>	0)
		{
			$log5	=	" + ancient";
			switch	($myrow_item['ancient'])	{
				case	1:
					$value6	=	5;
					break;
				case	2:
					$value6	=	9;
					break;
			}
		}
	}
	$value2		=	sprintf("%02X", $value2,00);
	$value5		=	sprintf("%02X", $value5,00);
	$value6		=	sprintf("%02X", $value6,00);
	$value8		=	sprintf("%01X", $_POST['harmony'],0).sprintf("%01X", $_POST['harmonyvalue'],0);
	if (isset($_POST['harmonyvalue']))
	{
		$total_kr	+=	$WebShop['harmony_price'];
	}
	$socketcount	=	0;
	for ($i=1;$i<=5;$i++)
	{
		if (isset($_POST['socket'.$i]))
		{
			$value9		.=	sprintf("%02X", $_POST['socket'.$i],00);
			if ($_POST['socket'.$i]	<	254)
			{
				$socketcount++;
				$total_kr	+=	$WebShop['socket_option'] * exeinc($socketcount,	$WebShop['socket_option_inc']) * $myrow_item['credits'];
			}
			elseif ($_POST['socket'.$i]	==	254)
			{
				$socketcount++;
				$total_kr	+=	$WebShop['socket_slot'];
			}
		}
		else
		{
			$value9		.=	"FF";
		}
	}
	$newitem	=	$value1.$value2.$value3.$value4.$value5.$value6.$value7.$value8.$value9;
		if	(isset($_POST['pre_buy']))
		{
			$total_kr		=	$total_kr * $WebShop['reduce'];
			$total_kr		=	round($total_kr,	2);
			$item			=	ItemInfo($newitem);
			?>
			<table align="center" style="margin:0px auto;" cellspacing="3">
				<tr>
					<td colspan="2" style="text-align:center; padding:3px; font-size:10px; background-image:url(<? echo "http://".$_SERVER['SERVER_NAME'].$_SERVER['ROOT_FOLDER']."/";?>images/back_item.png);">
							<?	echo	$item['echo_item'];	?>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<font size="+1">
								<?	echo	"<br>".total_price;	?>: <?	echo	$total_kr;	?> <?	echo	creditss;	?>
							</font>
					</td>
				</tr>
			</table>
			<?
		}
		else	
		{
	$query		=	mssql_query("declare @it varbinary(1920); set @it=(select Items from warehouse where accountid='$username'); print @it");
	$mycuritems	=	mssql_get_last_message();
	$test		=	0;
	$slot 		=	vaultexplore($mycuritems,	$myrow_item['x'],	$myrow_item['y']);
	$test		=	$slot*$_SERVER['itemlenght'];
	if	($exe_opts	>	$myrow_item['max_exe_level'])
	{
		echo	"<ul><li>".select_more_then_max.$myrow_item['max_exe_level']."</ul>";
	}
	elseif	($slot	==	1337)
	{
		echo	"<ul><li>".not_enouth_place."</ul>";
	}
	else
	{
			$total_kr	=	$total_kr*$WebShop['reduce'];
			$total_kr	=	round($total_kr,	2);
			$result		=	mssql_query("select credits from EW_CREDITS where memb___id='$username'");
			if	(mssql_num_rows($result)	<=	0)
			{
				echo	"<input type=\"hidden\" id=\"refreshpage\" value=\"Buy-Items\">";
				exit();
			}
			$myrow		=	mssql_fetch_array($result);
			if	($myrow['credits']	>=	$total_kr)
			{
				$new_kr		=	$myrow['credits'] - $total_kr;
				$log_all	=	"Buy item: ".$log0.$log1.$log2.$log3.$log4.$log5.$log6.$log7.$log8.$log9.$log10.$log11.$log12." Serial:".$serial;
				$mynewitems	=	substr_replace($mycuritems,	$newitem,	($test+2),	$_SERVER['itemlenght']);
				$query		=	"update warehouse set Items=$mynewitems where accountid='$username';";
				if	(!mssql_query($query))
				{
					echo	"<ul><li>".eror_while_adding."</li></ul>";
				}
				else
				{
					$query2		=	mssql_query("Update EW_CREDITS set credits='$new_kr' where memb___id='$username'");
					$insert_log	=	mssql_query("insert into EW_LOG (account,[index],credits,datetime) values ('$username','$log_all','$total_kr','$date')");
					echo	"<ul><li>".succes_create."</li></ul>";
				}
			}
			else
			{
				echo	"<ul><li>".eror_not_kr."</li></ul>";
			}
		}
	}
	exit();
}
echo "<script type=\"text/javascript\">document.getElementById(\"h4\").innerHTML = \"".item_buy."\"</script>
		<input type='hidden' id='module_contet' value='".item_buy."'>";
	echo "<div id='buycontet'>";
	echo	warning_value_place;
	echo	"<br><br><img alt='' src='".$template."img/item_place.gif'>";
	?>
<br>
<center>
	<input onClick="getitem('step=1','buycontet');" type="button" value="<? echo	i_have_places;?>">
</center>
</div>
<div id="itemview"></div>
<script type="text/javascript">
function getitem(url,divid)	{
var xmlhttpbi = false;
	document.getElementById(divid).innerHTML = "<center><img alt='Loading' width='110px' border='0' src='<? echo "http://".$_SERVER['SERVER_NAME'].$_SERVER['ROOT_FOLDER']."/";?>images/bigrotation2.gif'></center>";
	if(window.XMLHttpRequest){
		xmlhttpbi=new XMLHttpRequest();
		if(xmlhttpbi.overrideMimeType){
			xmlhttpbi.overrideMimeType('text/xml');
		}
	} else if(window.ActiveXObject){
		try{
			xmlhttpbi=new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try{
				xmlhttpbi=new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e){
			}
		}
	}
	if(!xmlhttpbi) {
		alert('Your Browser don\'t support Ajax!');
		return false;
	}
	xmlhttpbi.onreadystatechange = function() {
		if (xmlhttpbi.readyState==4) {
			document.getElementById(divid).innerHTML = xmlhttpbi.responseText;
			if (document.getElementById("id_cat")) if (document.getElementById("id_cat").value	!=	'no')	viewitem(document.getElementById("item_id").value);
			else	document.getElementById("itemview").innerHTML	=	"";
			}
	}
	xmlhttpbi.open('POST',rootfolder+'getpage.php?cat=Buy-Items');
	xmlhttpbi.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
	xmlhttpbi.send(url);
}
function viewitem(id)
{
var xmlhttpbi2 = false;
	document.getElementById("itemview").innerHTML = "<center><img alt='Loading' width='110px' border='0' src='<? echo "http://".$_SERVER['SERVER_NAME'].$_SERVER['ROOT_FOLDER']."/";?>images/bigrotation2.gif'></center>";
	if(window.XMLHttpRequest){
		xmlhttpbi2=new XMLHttpRequest();
		if(xmlhttpbi2.overrideMimeType){
			xmlhttpbi2.overrideMimeType('text/xml');
		}
	} else if(window.ActiveXObject){
		try{
			xmlhttpbi2=new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try{
				xmlhttpbi2=new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e){
			}
		}
	}
	if(!xmlhttpbi2) {
		alert('Your Browser don\'t support Ajax!');
		return false;
	}
	xmlhttpbi2.onreadystatechange = function() {
		if (xmlhttpbi2.readyState==4) {
			document.getElementById("itemview").innerHTML = xmlhttpbi2.responseText;
			}
	}
	self.form = document.getElementById("form1");
	var senddata = formData2QueryString(self.form);
	var url0 = "";
	id = id.split(",");
	if (id[1]	!=	'yes')	url0	=	"step3=1&pre_buy=1&id=" + id[0];
	else	url0	=	"step3=1&id=" + id[0];
	xmlhttpbi2.open('POST',rootfolder+'getpage.php?cat=Buy-Items');
	xmlhttpbi2.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
	xmlhttpbi2.send(url0 + senddata);
}
</script>