<?php
iseedeadpeople();
$success = false;
switch (1) {
default:
/********** Buy Resources *************/
$webshop['buyres'] = true; // Start Stop Module
$webshop['buyres_temp'] = array(
// ItemName HexMark Credits
array("Box of Kundun + 1" ,'CB40' ,200),
array("Box of Kundun + 2" ,'CB48' ,300),
array("Box of Kundun + 3" ,'CB50' ,400),
array("Box of Kundun + 4" ,'CB58' ,500),
array("Box of Kundun + 5" ,'CB60' ,600),
array("Jewel of Chaos" ,'8F00' ,600),
array("Jewel of Life" ,'D000' ,600),
array("Jewel of Bless" ,'CD00' ,600),
array("Jewel of Soul" ,'CE00' ,600),
);
require 'inc/function.iteminfo.php';
foreach($webshop['sell_resources'] as $key => $values){
$options .= "<form method='post'><option value='".$key."'>".$values[0]."</option>";
$prices .= "<tr><td>" .$values[0]. "</td><td> x" .$values[2]. " credits</td></tr>";
}
if(isset($_POST['type']) && isset($_POST['count'])){
$type = (int)$_POST['type'];
$count = (int)$_POST['count'];
if($type >=0 && $type < count($webshop['buyres_temp']) && $count > 0){
if(mssql_num_rows(mssql_query("Select * from Memb_Stat where ConnectStat=0 and memb___id='" . htmlspecialchars($_COOKIE['WebShopUsername']. "'"))) == 1){
if($mycreds >= bcmul($count,$webshop['buyres_temp'][$type][2])){
for($i=0;$i < $count; $i++){
$mycuritems = '0x' . strtoupper(bin2hex(mssql_fetch_row(mssql_query("SELECT [Items] FROM [warehouse] WHERE [AccountID]='" . $GLOBALS['mu_user'] . "'"))[0]));
$ser_ex = mssql_fetch_row(mssql_query("exec WZ_GetItemSerial"));
$newitem = $webshop['buyres_temp'][$type][1]."00".sprintf("%08X", $ser_ex[0],00000000)."800000";
$test = 0;
$slot = smartsearch($mycuritems,1,1);
$test = $slot*20;
if ($slot == 1337) {
print "<br>".phrase_no_slots;
}
else{
$mynewitems = substr_replace($mycuritems, $newitem, ($test+2), 20);
$update_ware = mssql_query("Update warehouse set items = ".$mynewitems." where AccountID='".htmlspecialchars($_COOKIE['WebShopUsername'])."'");
if($update_ware){
mssql_query("Update Memb_Credits set credits = credits-".bcmul($count,$webshop['buyres_temp'][$type][2])." where memb___id='".htmlspecialchars($_COOKIE['WebShopUsername'])."'");
$message = "You have successfully bought x".$count." " . $webshop['buyres_temp'][$type][0] ." for " . bcmul($count,$webshop['buyres_temp'][$type][2]) . " credits " ;
echo '<meta http-equiv="refresh" content="1">';
$success = true;
}
}
}
if($success){
echo $message;
}
}
else{
print phrase_lack_credits;
}
}
else{
echo phrase_leave_the_game;
}
}
else{
echo "Please select the resource properly";
}
}
print '<fieldset style="width: 350px;background-color: #DDDDDD;border: 1px solid #000000; font-family: arial; font-size: 12px;"><legend class="mu_style2" style="padding: 3px;font-weight:bold;background-color: #DDDDDD;border: 1px solid #000000;border-bottom:0px;">Sell Resources</legend>';
echo "
<form method='post'>
<table width=100% cellpadding='2' cellspacing='1' border='1'>
<tr style='background:#bbbbbb;font-weight:600'>
<td>Choose Resource</td>
<td>Amount</td>
</tr>
<tr>
<td><select name='type'>".$options."</select></td>
<td><input type='number' name='count'/></td>
<td align='center'>
<input class='button' type='submit' value='Buy Now' name='submit'/>
</td>
</tr>";
echo '</table></br>
<fieldset style="width: 300px">
<legend class="mu_style2" style="padding: 0px;font-weight:bold;">Price Table</legend>
<div align="justify">
<table width=100% cellpadding="2" cellspacing="1" border=1>
<tr style="background:#bbbbbb;font-weight:600"><td>Resource Name</td><td> Price Each</td></tr>
'.$prices.'
</table>
</div>
</fieldset>';
}
?>