Просмотр файла darkworld/sellrukvesh.php

Размер файла: 4.22Kb
<?
Error_Reporting(E_ALL & ~E_NOTICE);
include_once("files/antixak.php");
header("Content-type:text/vnd.wap.wml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.2//EN\" \"http://www.wapforum.org/DTD/wml12.dtd\">";
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>";
echo "<card id=\"index\" title=\"&#x41F;&#x435;&#x440;&#x441;&#x43E;&#x43D;&#x430;&#x436;\">";
echo "<p align=\"left\">";

$log = htmlspecialchars(stripslashes($log));
$pas = htmlspecialchars(stripslashes($pas));
/////////////////////////////////////////////////////
$text = @file("data/reg/$log.dat"); 
if ($text!=""){
$udata = explode(":||:",$text[0]);
$login=trim($udata[0]);
$password=trim($udata[1]);}
////////////////////////////////////////////////////////
if (md5($pas)==$password && $log==$login && $log!=="" && md5($pas)!=="") {

switch($go) {

default:

echo "<small>Сколько?:</small><br/>";
echo "<input name=\"kol\" maxlength=\"10\" title=\"*N\" emptyok=\"true\"/><br/>";
echo "<small>Цена за 1 штуку:</small><br/>";
echo "<input name=\"cena\" maxlength=\"10\" title=\"*N\" emptyok=\"true\"/><br/>";
echo "<small><anchor title=\"go\">Продать!<go href=\"sellrukvesh.php?log=$log&amp;pas=$pas&amp;go=go&amp;name=$name&amp;id=$id\" method=\"post\">";
echo "<postfield name=\"kol\" value=\"$(kol)\"/>";
echo "<postfield name=\"cena\" value=\"$(cena)\"/>";
echo "</go></anchor></small><br/>";

break;

case 'go':

$kol = htmlspecialchars(stripslashes($kol));
$id = htmlspecialchars(stripslashes($id));
$cena = htmlspecialchars(stripslashes($cena));

if(eregi("[^0-9]",$kol)){echo"<small>&#x412;&#x432;&#x43E;&#x434;&#x438;&#x442;&#x435; &#x447;&#x438;&#x441;&#x43B;&#x43E;, &#x430; &#x43D;&#x435; &#x431;&#x443;&#x43A;&#x432;&#x44B;!</small>"; include_once"files/down.php"; exit;}
if(eregi("[^0-9]",$cena)){echo"<small>&#x412;&#x432;&#x43E;&#x434;&#x438;&#x442;&#x435; &#x447;&#x438;&#x441;&#x43B;&#x43E;, &#x430; &#x43D;&#x435; &#x431;&#x443;&#x43A;&#x432;&#x44B;!</small>"; include_once"files/down.php"; exit;}

if(empty($cena)){echo"<small>Вы не ввели цену товара.</small>"; include_once"files/down.php"; exit;}
if(empty($kol)){echo"<small>Вы не ввели колличество товара.</small>"; include_once"files/down.php"; exit;}


$file = @file("data/item/$log.dat");
$file = array_reverse($file);
$data = explode(":||:",$file[$id]);

if($data[4]=="Olimpiad Medal"){echo"<small>Продажа медалей ЗАПРЕЩЕНА!</small>"; include_once"files/down.php"; exit; }
if($kol>$data[3]){echo"<small>У вас нет столько вещей!</small>"; include_once"files/down.php"; exit; }



$text="$data[0]||$data[1]||$data[2]||$kol||$data[4]||$cena||$text||";

$fp=fopen("data/sellruk/$log.dat","w");  
flock($fp,LOCK_EX);                                                     
fputs($fp,"$text");
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp); 

$kol=$data[3]-$kol;

if($kol=="0"){



$file=file("data/item/$log.dat"); 
$file = array_reverse($file);
$fp=fopen("data/item/$log.dat","w");
flock ($fp,LOCK_EX);
for ($i=0;$i< sizeof($file);$i++) { if ($i==$id) {unset($file[$i]);} }
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);
}else{


$file=file("data/item/$log.dat"); 
$file = array_reverse($file);
$fp=fopen("data/item/$log.dat","w");
flock ($fp,LOCK_EX);
for ($i=0;$i< sizeof($file);$i++) { if ($i==$id) {unset($file[$i]);} }
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);

$text="$data[0]:||:$data[1]:||:$data[2]:||:$kol:||:$data[4]:||:";

$fp=fopen("data/item/$log.dat","a+");  
flock($fp,LOCK_EX);                                                     
fputs($fp,"$text\r\n");
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp); 

}

echo"<small>Вещи выставленны на продажу.<br/><a href=\"sellruktime.php?log=$log&amp;pas=$pas\">Продолжить</a></small>";

break;

}
}else{echo"<small>&#x41F;&#x430;&#x440;&#x43E;&#x43B;&#x44C; &#x438;&#x43B;&#x438; &#x43B;&#x43E;&#x433;&#x438;&#x43D; &#x43D;&#x435;&#x432;&#x435;&#x440;&#x435;&#x43D;!</small>";}

include_once"files/down.php";
?>