Вход Регистрация
Файл: gamele.ru/inc/maps/store.php
Строк: 316
<script type="text/javascript" src="/globals/JS/windows_v03.js"></script>
<?     
if (VALIDATION): 

    if (isset(
$_REQUEST["action"]) && !empty($_REQUEST["action"]) && $_REQUEST["action"]=='buy' && !empty($_REQUEST["item"])):
        
$info explode ('_',$_REQUEST["item"]);
        
$v mysql_fetch_array(mysql_query("SELECT * FROM instrumentory WHERE ID=".$info[0]));
        if (
$v["ID"]):
            if (
$info[1]>$v["kolvo"]): $info[1] = $v["kolvo"]; endif;
            if (
$v["kolvo"]>=$info[1] && $player["money"]>=$info[1]*$v["price"]):
                
mysql_query ("UPDATE users SET money=money-".($info[1]*$v["price"])." WHERE uid=".$player["uid"]);
                
mysql_query("UPDATE capital SET money=money+".($info[1]*$v["price"])." WHERE organization='store'");
                
mysql_query ("UPDATE instrumentory SET kolvo=kolvo-".$info[1]." WHERE ID=".$info[0]);
                if (
$info[0]==1): sql("UPDATE users SET alchemy_d=alchemy_d+100 WHERE uid=".$player["uid"]);
                elseif (
$info[0]==2): sql("UPDATE users SET alchemy_m=alchemy_m+100 WHERE uid=".$player["uid"]);
                elseif (
$info[0]==3): sql("UPDATE users SET alchemy_b=alchemy_b+".intval($info[1])." WHERE uid=".$player["uid"]);
                elseif (
$info[0]==4): sql("UPDATE users SET healer_b=healer_b+".intval($info[1])." WHERE uid=".$player["uid"]);
                elseif (
$info[0]==9): sql("UPDATE users SET writer_list=writer_list+".intval($info[1])." WHERE uid=".$player["uid"]);
                else:
                    for (
$a=0,$b=intval($info[1]);$a<$b;$a++):
                        
insert_wp($v["id_in_w"],$player["uid"],-1,0);
                    endfor;
                endif;
            endif;
        endif;
    endif;
    
    if (isset(
$_REQUEST["store_act"]) && !empty($_REQUEST["store_act"]) && isset($_REQUEST["res_kolvo"]) && !empty($_REQUEST["res_kolvo"]) && isset($_REQUEST["what_res"])):
        if (
$_REQUEST["store_act"]=='sell'):
            
$kaz mysql_result(mysql_query("SELECT money FROM capital WHERE organization='store'"),0,'money');
            
$cur_now mysql_num_rows(mysql_query("SELECT name FROM `wp` WHERE id_in_w='".$_REQUEST["what_res"]."' and uidp=".$player["uid"].""));
            
$resources3 mysql_fetch_array(mysql_query("SELECT * FROM store_gos WHERE resource_id='".$_REQUEST["what_res"]."'"));
            if (
$_REQUEST["res_kolvo"]>$cur_now): $_REQUEST["res_kolvo"] = $cur_now; endif;
            if (
$_REQUEST["res_kolvo"]>($resources3['resource_max']-$resources3['resource_is'])): $_REQUEST["res_kolvo"] = ($resources3['resource_max']-$resources3['resource_is']); endif;
            
mysql_query ("UPDATE store_gos SET resource_is=resource_is+".$_REQUEST["res_kolvo"]." WHERE resource_id='".$_REQUEST["what_res"]."'");
            
$is mysql_result ($resources3$a'resource_is');
            
$max mysql_result ($resources3$a'resource_max');
            
$price_total1 $resources3["resource_price"]*$_REQUEST["res_kolvo"];
            if (
$price_total1>$kaz):
            
$_REQUEST["res_kolvo"] = floor ($kaz/$b_price);
            
$price_total1 $resources3["resource_price"]*$_REQUEST["res_kolvo"];
            endif;
            
mysql_query ("DELETE FROM wp WHERE id_in_w='".$_REQUEST["what_res"]."' and uidp=".$player["uid"]." LIMIT ".$_REQUEST["res_kolvo"]."");
            
mysql_query ("UPDATE users SET money=money+".$price_total1." WHERE uid=".$player["uid"]."");
            
mysql_query("UPDATE capital SET money=money-".$price_total1." WHERE organization='store'");
            
$message 'Сдано '.$_REQUEST["res_kolvo"].' ед. ресурса <strong>&laquo;'.$resources3["resource_name"].'&raquo;</strong>.<br>На Ваш счет зачислено <strong>'.$price_total1.' LM</strong>.';
        elseif (
$_REQUEST["store_act"]=='buy'):
            
$resources3 mysql_fetch_array(mysql_query("SELECT * FROM store_gos WHERE resource_id='".$_REQUEST["what_res"]."'"));
            if (
$_REQUEST["res_kolvo"]>$resources3["resource_is"]): $_REQUEST["res_kolvo"] = $resources3["resource_is"]; endif;
            
$price_total1 = ($resources3["resource_price"]+5)*$_REQUEST["res_kolvo"];
            if (
$price_total1>$player["money"]):
            
$_REQUEST["res_kolvo"] = round ($player["money"]/($resources3["resource_price"]+5))-1;
            
$price_total1 = ($resources3["resource_price"]+5)*$_REQUEST["res_kolvo"];
            endif;
            if (
$price_total1>&& $_REQUEST["res_kolvo"]>0):
                
mysql_query ("UPDATE store_gos SET resource_is=resource_is-".$_REQUEST["res_kolvo"]." WHERE resource_id='".$_REQUEST["what_res"]."'");
                
mysql_query ("UPDATE users SET money=money-".$price_total1." WHERE uid=".$player["uid"]."");
                
mysql_query("UPDATE capital SET money=money+".$price_total1." WHERE organization='store'");
                for (
$a=0,$b=$_REQUEST["res_kolvo"]; $a<$b$a++):
                    
sql("INSERT INTO `wp` (`uidp` , `weared` ,`id_in_w`, `price` , `dprice` , `image` , `index` , `type` , `stype` , `name` , `describe` , `weight` , `where_buy` , `max_durability` , `durability` ,`p_type`) VALUES ('".$player["uid"]."', '0','".$_REQUEST["what_res"]."','".$resources3["resource_price"]."', '0', '".$resources3["resource_image"]."', '".$resources3["resource_index"]."', '".$resources3["resource_type"]."', '".$resources3["resource_type"]."', '".$resources3["resource_name"]."', '', '1', '0', '1', '1','2');");
                endfor;
                
$message 'Куплено '.$_REQUEST["res_kolvo"].' ед. ресурса <strong>&laquo;'.$resources3["resource_name"].'&raquo;</strong>.<br>С Вашего счета списано <strong>'.$price_total1.' LM</strong>.';
            endif;
        elseif (
$_REQUEST["store_act"]=='set_sell'):
            
$resources3 mysql_fetch_array(mysql_query("SELECT * FROM store_gos WHERE resource_id='".$_REQUEST["what_res"]."'"));
            
$cur_now mysql_num_rows(mysql_query("SELECT name FROM `wp` WHERE id_in_w='".$_REQUEST["what_res"]."' and uidp=".$player["uid"].""));
            if (
$_REQUEST["res_kolvo"]>$cur_now):
                
$_REQUEST["res_kolvo"] = $cur_now;
            endif;
            if (
$_REQUEST["res_kolvo"]>0):
                
$minprice round($resources3["resource_price"] * 0.6);
                
$maxprice round($resources3["resource_price"] * 1.4);
                if (
$_REQUEST["res_price"]<$minprice): $_REQUEST["res_price"] = $minprice; endif;
                if (
$_REQUEST["res_price"]>$maxprice): $_REQUEST["res_price"] = $maxprice; endif;
                
mysql_query ("INSERT INTO store_res VALUES ('','".$player["uid"]."','".$resources3["resource_id"]."','".$resources3["resource_type"]."','".$resources3["resource_index"]."','".$resources3["resource_name"]."','".$resources3["resource_image"]."','".$_REQUEST["res_kolvo"]."','".$_REQUEST["res_price"]."')");
                
mysql_query ("DELETE FROM wp WHERE id_in_w='".$_REQUEST["what_res"]."' and uidp=".$player["uid"]." LIMIT ".$_REQUEST["res_kolvo"]."");
                
$message 'Успешно подана заявка на продажу '.$_REQUEST["res_kolvo"].' ед. ресурса <strong>&laquo;'.$resources3["resource_name"].'&raquo;</strong>.';
            endif;
        endif;
    endif;
    
    if (
$_REQUEST["store_act"]=='set_buy'):
            
$info mysql_fetch_array(mysql_query("SELECT * FROM store_res WHERE ID=".$_REQUEST["res_buy"]));
            
$info2 mysql_fetch_array(mysql_query("SELECT * FROM store_gos WHERE resource_id='".$info["resource_id"]."'"));
            if (
count($info)>1):
                for (
$a=0,$b=$info["resource_is"]; $a<$b$a++):
                    
sql("INSERT INTO `wp` (`uidp` , `weared` ,`id_in_w`, `price` , `dprice` , `image` , `index` , `type` , `stype` , `name` , `describe` , `weight` , `where_buy` , `max_durability` , `durability` ,`p_type`) VALUES ('".$player["uid"]."', '0','".$info["resource_id"]."','".$info2["resource_price"]."', '0', '".$info["resource_image"]."', '".$info["resource_index"]."', '".$info["resource_type"]."', '".$info["resource_type"]."', '".$info["resource_name"]."', '', '1', '0', '1', '1','2');");
                endfor;
                
mysql_query ("DELETE FROM store_res WHERE ID=".$_REQUEST["res_buy"]);
                
$total $info["resource_is"] * $info["resource_price"];
                if (
$player["money"]>=$total):
                    
mysql_query ("UPDATE users SET money = money - ".$total." WHERE uid=".$player["uid"]);
                    
$total2 round($total*0.9);
                    
mysql_query ("UPDATE users SET money = money + ".$total2." WHERE uid=".$info["owner"]);
                    
mysql_query ("UPDATE capital SET money=money+".($total-$total2)." WHERE organization='store'");
                    
$message 'Оплачено предложение на '.$info["resource_is"].' ед. ресурса <strong>&laquo;'.$info["resource_name"].'&raquo;</strong>.<br>С Вашего счета списано <strong>'.$total.' LM</strong>.';
say_to_chat('s',"Ваша заявка на ".$info["resource_is"]." ед. ресурса <strong>&laquo;".$info["resource_name"]."&raquo;</strong> оплачена. На Ваш счет зачислено <strong>".$total2." LM</strong>.",1,mysql_result(mysql_query("SELECT user FROM users WHERE uid=".$info["owner"].""),0,'user'),'*',0);
                endif;
            endif;
    endif;
endif; 
?>


<? if ($player["loc"]=='53'): ?>

<center><div style="width:525px; height:25px; background-image:url(/interface/clan_top2.gif); background-repeat:no-repeat; vertical-align:top; padding-top:5px;"><a href="/main.php?move=store_0&vcode=<?=VCODE?>"><strong>Подвал</strong></a> | <a href="/main.php?room=1"><strong>Скупка Ресурсов</strong></a> | <a href="/main.php?room=2"><strong>Рынок Ресурсов</strong></a> | <a href="/main.php?move=store_2&vcode=<?=VCODE?>"><strong>Второй Этаж</strong></a></div></center>
<? if ($_REQUEST["room"]==1): ?>
<center><div style="width:525px; vertical-align:top; margin-top:-7px;"><a href="/main.php?room=1&subroom=hunt"><strong>Охота</strong></a> | <a href="/main.php?room=1&subroom=fish"><strong>Рыбалка</strong></a> | <a href="/main.php?room=1&subroom=herbal"><strong>Собирательство</strong></a> | <a href="/main.php?room=1&subroom=resources"><strong>Шахтерство</strong></a> | <a href="#"><strong>Лесорубство</strong></a></div></center>
<?
if (isset($_REQUEST["subroom"]) && !empty($_REQUEST["subroom"])):
    
$resources mysql_query("SELECT * FROM store_gos WHERE resource_type='".$_REQUEST["subroom"]."' ORDER BY resource_name ASC");
    
$total '';
    while (
$v=mysql_fetch_array($resources)):
        if (
$total<>''): $total .= ','; endif;
        
$is mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM wp WHERE id_in_w='".$v["resource_id"]."' AND uidp=".$player["uid"]));
        
$total .= '["'.$v["resource_name"].'","'.$v["resource_image"].'",'.$v["resource_price"].','.$v["resource_is"].','.$v["resource_max"].',"'.$v["resource_id"].'",'.$is[0].','.$v["resource_number"].']';
    endwhile;
?>   
<script type="text/javascript" src="/globals/JS/m_guild_v04.js"></script>
<script type="text/javascript">
<? if (isset($message) && !empty($message)): ?>
message_window ('success','Результат','<?=$message?>','ok','') 
<? endif; ?>
resources = [<?=$total?>];
render_resources(resources,['<?=VCODE?>','<?=$_REQUEST["room"]?>','<?=$_REQUEST["subroom"]?>']);
</script>
<? 
endif;
elseif (
$_REQUEST["room"]==2): ?>
<center><div style="width:525px; vertical-align:top; margin-top:-7px;"><a href="/main.php?room=2&subroom=buy"><strong>Посмотреть предложения</strong></a> | <a href="/main.php?room=2&subroom=sell"><strong>Выставить на продажу</strong></a></div></center>
<?
if ($_REQUEST["subroom"]=='sell'):
    
$out '';
    
$res = array();
    
$all mysql_query ("SELECT DISTINCT id_in_w FROM wp WHERE (stype='herbal' or stype='resource' or stype='fish' or stype='hunt') and uidp=".$player["uid"]." ORDER BY stype ASC");
    while (
$a=mysql_fetch_array($all)):
        
$info2 mysql_fetch_array(mysql_query("SELECT * FROM store_gos WHERE resource_id='".$a["id_in_w"]."'"));
        if (
$info2["resource_id"]):
            if (
$out<>''): $out.=','; endif;
            
$info3 mysql_fetch_array(mysql_query("SELECT COUNT(id) FROM wp WHERE id_in_w='".$a["id_in_w"]."' and uidp=".$player["uid"]));
            
$out .= '["'.$info2["resource_name"].'","'.$info2["resource_id"].'","'.$info2["resource_image"].'",'.$info2["resource_price"].','.$info3[0].','.$info2["resource_number"].']';
        endif;
    endwhile; 
?>
<script type="text/javascript" src="/globals/JS/m_guild_v04.js"></script>
<script type="text/javascript">
<? if (isset($message) && !empty($message)): ?>
message_window ('success','Результат','<?=$message?>','ok','') 
<? endif; ?>
resources = [<?=$out?>];
render_store_sell(resources,['<?=VCODE?>','<?=$_REQUEST["room"]?>','<?=$_REQUEST["subroom"]?>']);
</script>
<? 
elseif ($_REQUEST["subroom"]=='buy'):
    
$out '';
    
$res = array();
    
$all mysql_query ("SELECT * FROM store_res ORDER BY resource_name ASC");
    while (
$a=mysql_fetch_array($all)):
        if (
$out<>''): $out.=','; endif;
        
$out .= '["'.$a["resource_name"].'","'.$a["resource_type"].'","'.$a["resource_image"].'",'.$a["resource_price"].','.$a["resource_is"].','.$a["ID"].']';
    endwhile;
?>
<script type="text/javascript" src="/globals/JS/m_guild_v04.js"></script>
<script type="text/javascript">
<? if (isset($message) && !empty($message)): ?>
message_window ('success','Результат','<?=$message?>','ok','') 
<? endif; ?>
resources = [<?=$out?>];
render_store_buy(resources,['<?=VCODE?>','<?=$_REQUEST["room"]?>','<?=$_REQUEST["subroom"]?>']);
</script>
<?
endif;
endif; 
?>

<center><div style="width:525px; height:25px; background-image:url(/interface/clan_top2.gif); background-repeat:no-repeat; vertical-align:top; padding-top:5px;"><a href="/main.php?move=store_1&vcode=<?=VCODE?>"><strong>Первый Этаж</strong></a> | <a href="/main.php?room=1"><strong>Гильдия Мастеров</strong></a> | <a href="#"><strong>Отдел Закупок</strong></a> | <a href="/main.php?room=quests"><strong>Квесты</strong></a></div></center>
<? if ($_REQUEST["room"]==1): ?>
<center><div style="width:525px; vertical-align:top; margin-top:-7px;"><a href="/main.php?room=1&subroom=1"><strong>Письменный стол</strong></a> | <a href="/main.php?room=1&subroom=2"><strong>Место Крафтера</strong></a></div></center>
<?
if ($_REQUEST["subroom"]==1):
    require (
'writer.php');
elseif (
$_REQUEST["subroom"]==2):
    require (
'crafter.php');
endif;
endif; 
?>
<?
if ($_REQUEST["room"]=='quests'):
require (
'QUEST.php'); ?>
<tr><td align=center>
<table border="0" width="100%" cellpadding="5">
        <tr><td width="150" align="center" valign="top"><img src="/images/playerons/unknown.gif" border="0"></td>
        <td valign="top">
        <?=check_quests($player,$_REQUEST,$quest_add_info)?>
        </td>
            </tr></table>
</td></tr>
<? endif; ?>

<? endif; ?>
<? 
if ($player["waiter"]>time()): ?>
<script type=text/javascript>
init_timer (<?=($player["waiter"]-time())?>);
</script>
<? endif; ?>
Онлайн: 1
Реклама