<?
include 'mysql.php';
include_once("include/sesi.php");
Error_Reporting(E_ALL & ~E_NOTICE);
include_once("include/antixak.php");
$_title = 'Linewap2';
include 'include/ini.php';
include 'include/header.php';
$log = htmlspecialchars(stripslashes($log));
$pas = htmlspecialchars(stripslashes($pas));
/////////////////////////////////////////////////////
$text = @file("MySql/base123/reg/$log.dat");
if ($text!=""){
$udata = explode(":||:",$text[0]);
$login=trim($udata[0]);
$password=trim($udata[1]);}
////////////////////////////////////////////////////////
if (isset($user)) {
if(!@file("MySql/base123/sellruk/$log.dat")){echo"<small>Ошибка</small>"; include"include/down.php"; exit;}
$file=@file("MySql/base123/item/$log.dat");
$total=count($file);

$text = @file("MySql/base123/sellruk/$log.dat");
$data = explode("||",$text[0]);

for($i=0; $i<$total; $i++){
$item = explode(":||:",$file[$i]);

if($item[4]==$data[4]){

$fp=fopen("MySql/base123/item/$log.dat","w");
flock ($fp,LOCK_EX);
unset($file[$i]);
fputs($fp, implode("",$file));
flock ($fp,LOCK_UN);
fclose($fp);

$all=$data[3]+$item[3];

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

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

unlink ("MySql/base123/sellruk/$log.dat");
echo"<small>Продажа отменена.</small>";
include_once"include/down.php";

exit;

}else{

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

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

unlink ("MySql/base123/sellruk/$log.dat");

echo"<small>Продажа отменена.</small>";

include_once"include/down.php";

exit;

}}



}else{echo"<small>Пароль или логин неверен!</small>";}

include_once"include/down.php";
?>
