<?php
include_once("files/zag.php");
include_once("files/ini.php");
$polz=mysql_query("SELECT * FROM `users` WHERE `udata0`='$log' AND `udata1`='$pas' LIMIT 1");
if(mysql_num_rows($polz)==0){
header ("Location: index.php?error");
echo'<div class="p">Ошибка! Пользователь с таким логином и паролем не зарегистрирован, или пароль/логин неверен! <a href="index.php">На главную</a><br>';exit;
}else{
include_once"files/up.php";
$vesh = htmlspecialchars(stripslashes($vesh));
$tip = htmlspecialchars(stripslashes($tip));
if($vesh!=="ScrollWeapon"){
echo "<form action=\"pokupka.php?&vesh=$vesh&tip=$tip\" method=\"post\">Сколько?<br/>";
echo "<input name=\"kol\" maxlength=\"10\" title=\"*N\" emptyok=\"true\"/><br/>";
echo '<input type="submit" value="Купить"></form>';
}elseif($vesh=="ScrollWeapon"){
if($den<"400000"){echo"<small>У вас не хватает денег!</small>"; include_once"files/down.php"; exit;}
$text = @file("data/vesh/$vesh.dat");
$data = explode(":||:",$text[0]);
$text="$data[0]:||:$data[1]:||:$data[2]:||:1:||:$data[4]:||:";
mysql_query("INSERT INTO `item` VALUES ('', '".$data[0]."', '".$data[1]."', '".$data[2]."' , '".$data[3]."' , '".$data[4]."' , '".$data[5]."' , '".$data[6]."' , '".$log."' )") or die(mysql_error());
$fp=fopen("data/item/$log.dat","a+");
flock ($fp,LOCK_EX);
fputs($fp,"$text\r\n");
flock ($fp,LOCK_UN);
fclose($fp);
$text = @file("data/reg/$log.dat");
$udat = explode(":||:",$text[0]);
$aden=$udat[8]-400000;
$text=$udat[0].':||:'.$udat[1].':||:'.$udat[2].':||:'.$udat[3].':||:'.$udat[4].':||:'.$udat[5].':||:'.$udat[6].':||:'.$udat[7].':||:'.$aden.':||:'.$udat[9].':||:'.$udat[10].':||:'.$udat[11].':||:'.$udat[12].':||:'.$udat[13].':||:'.$udat[14].':||:'.$udat[15].':||:'.$udat[16].':||:'.$udat[17].':||:'.$udat[18].':||:'.$udat[19].':||:'.$udat[20].':||:'.$udat[21].':||:'.$udat[22].':||:'.$udat[23].':||:'.$udat[24].':||:'.$udat[25].':||:'.$udat[26].':||:'.$udat[27].':||:'.$udat[28].':||:'.$udat[29].':||:'.$udat[30].':||:'.$udat[31].':||:'.$udat[32].':||:'.$udat[33].':||:'.$udat[34].':||:'.$udat[35].':||:'.$udat[36].':||:'.$udat[37].':||:'.$udat[38].':||:'.$udat[39].':||:'.$udat[40].':||:'.$udata[41].':||:'.$udata[42].':||:'.$udata[43].':||:'.$udata[44].':||:'.$udata[45].':||:'.$udata[46].':||:'.$udata[47].':||:'.$udata[48].':||:'.$udata[49].':||:'.$udata[50].':||:'.$udata[51].':||:'.$udata[52].':||:'.$udata[53].':||:'.$udata[54].':||:'.$udata[55].':||:'.$udata[56].':||:'.$udata[57].':||:'.$udata[58].':||:'.$udata[59].':||:'.$udata[60].':||:'.$udata[61].':||:'.$udata[62].':||:'.$udata[63].':||:'.$udata[64].':||:'.$udata[65].':||:'.$udata[66].':||:'.$udata[67].':||:'.$udata[68].':||:'.$udata[69].':||:'.$udata[70].':||:'.$udata[71].':||:'.$udata[72].':||:'.$udata[73].':||:'.$udata[74].':||:'.$udata[75].':||:'.$udata[76].':||:'.$udata[77].':||:'.$udata[78].':||:'.$udata[79].':||:'.$udata[80].':||:'.$udata[81].':||:'.$udata[82].':||:'.$udata[83].':||:'.$udata[84].':||:'.$udata[85].':||:'.$udata[86].':||:'.$udata[87].':||:'.$udata[88].':||:'.$udata[89].':||:'.$udata[90].':||:'.$udata[91].':||:'.$udata[92].':||:'.$udata[93].':||:'.$udata[94].':||:'.$udata[95].':||:'.$udata[96].':||:'.$udata[97].':||:'.$udata[98].':||:'.$udata[99].':||:'.$udata[100].':||:';
$fp=fopen("data/reg/$log.dat","a+");
flock($fp,LOCK_EX);
ftruncate($fp,0);
fputs($fp,"$text\r\n");
fflush($fp);
flock($fp,LOCK_UN);
fclose($fp);
echo"<small><a href=\"shop.php?\">Куплено</a></small>";
}
}
include_once"files/down.php";
?>