View file prezent.php

File size: 6.61Kb
<?

header("Cache-Control: no-cache");
$ver = empty($ver) || ($ver!='wml' && !file_exists('css/'.$ver.'.css')) ? 'xhtml' : $ver;
if ($ver=="wml") header ("Content-type:text/vnd.wap.wml; charset=utf-8");
else header("Content-Type:text/html; charset=UTF-8");

require("inc.php");
$link = connect_db();
list($row, $id, $ps, $fsize1, $fsize2) = check_login($link);
require("version.php");

$user = $row["user"];
$posts = $row["posts"];

$adm = @mysql_query ("Select user from users where id='1' LIMIT 1;");
$z = @mysql_fetch_array ($adm);
$administration = $z["user"];

if(!isset($go)){
if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>";
echo "<card id=\"cabinet\" title=\"Подари посты другу\">";
echo "<p align=\"center\">\n";
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/$ver.css\"/>";
echo "<title>Подари посты другу</title>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
echo "<form method=\"POST\" action=\"prezent.php?go=view&amp;$ses&amp;ref=$ref\" name=\"auth\">\n"; 
}
echo $fsize1;
echo "Кому дарим посты?<br/>\n";
echo "Ник или ID:<br/>\n";
echo $fsize2;
echo "<input name=\"nick\" maxlength=\"13\" title=\"friend\"/><br/>\n";
echo $fsize1;
echo $divide;
echo "Транслитирация ника:<br/>\n";
echo $fsize2;
echo "<select name=\"trun\">\n";
echo "<option value=\"0\">Нет</option>\n";
echo "<option value=\"1\">Да</option>\n";
echo "</select><br/>\n";
echo $fsize1;
echo $divide;
echo "Сколько не жалко?<br/>\n";
echo "От 0 до ".$posts."<br/>\n";
echo $fsize2;
echo "<input name=\"post\" maxlength=\"13\" format=\"*N\"/><br/>\n";
if ($ver=="wml"){
echo $fsize1;
echo "<anchor title=\"go\">Подарить<go href=\"prezent.php?go=view&amp;$ses&amp;ref=$ref\" method=\"post\">\n";
echo "<postfield name=\"nick\" value=\"$(nick)\"/>\n";
echo "<postfield name=\"post\" value=\"$(post)\"/>\n";
echo "<postfield name=\"trun\" value=\"$(trun)\"/>\n";
echo "</go></anchor>\n";
echo $fsize2;
echo "<br/>";
}else{
echo "<input type=\"submit\" value=\"Подарить\" name=\"enter\"><br/>\n";
}
echo $fsize1;
echo $divide;
echo "<a href=\"cabinet.php?$ses&amp;ref=$ref\">Личный кабинет</a><br/>\n";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
exit;
}

if(@$go == "view"){       
if (!ctype_digit($nick)) {
if($trun==1)$nick=trun_to_rus($nick);
$nick=trim($nick);    
$post=trim($post);
if($nick=="")$nick=0;
$latuser=strtolower($nick);
$ruser = rus_to_k($nick);
if($ruser==$nick){
$select = mysql_query ("Select id,user,posts from users where latuser = '".$latuser."'"); 
} else {
$select = mysql_query ("select id,user,posts from users where ruser = '".$ruser."'");
}
} else {
$select = mysql_query ("select id,user,posts from users where id = '".$nick."'");
}
if (mysql_affected_rows() == 0){
if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>";
echo "<card id=\"error\" title=\"Ошибка\" ontimer=\"prezent.php?$ses&amp;ref=$ref\"><timer value=\"15\"/>";
echo "<p align=\"center\">";
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/$ver.css\"/>";
echo "<title>Ошибка</title>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=prezent.php?$ses&amp;ref=$ref\">";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
echo "Юзер не найден. Возможно ник удалён.<br/>";
echo $divide;
echo "<a href=\"prezent.php?$ses&amp;rm=$rm&amp;ref=$ref\">Назад</a><br/>\n";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
exit;	
}
$inf = mysql_fetch_array ($select); 
$usid=$inf["id"];
$nick = $inf["user"];

if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>\n";
echo "<card id=\"results\" title=\"Найдено\">\n";
echo "<p align=\"center\">\n";
}else{
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/$ver.css\"/>";
echo "<title>Найдено</title>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"2; URL=cabinet.php?$ses&amp;ref=$ref\">";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;

if($id==$usid){
print "И как это вы себе решили посты подарить? Такое не возможно!!!.<br/>";
}else{
if ($post>$posts){
echo "У Вас недостаточно постов для данного подарка.<br/>";
}else{
$data = date("d-M-Y [H:i]");
$kol = rand(0,99999999);
$time = time();
$topic = "Подарок!!!";
$message = "Приветствую <b>".$nick."</b>!!! На ваш баланс зачислено <b>".$post."</b> постов. Подарок от юзера ".$user.".";

if (!ctype_digit($id)) {header("Location: index.php"); die;}
if (!ctype_digit($usid)) {header("Location: index.php"); die;}
if (!ctype_digit($post)) {header("Location: index.php"); die;}
if (@mysql_query("Insert into zapiski set klu4='".$kol."', who ='".$administration."', idwho ='1', message = '".$message."', towhom = '".$nick."', idtowhom = '".$usid."', time = '".$time."', readd = '0', topic = '".$topic."', date='".$data."'")&&
@mysql_query ("Update users set posts=posts-'".$post."' where id ='".$id."';")&&
@mysql_query ("Update users set posts=posts+'".$post."' where id ='".$usid."';")){
print "Подарок для <b>".$nick."</b> успешно доставлен.<br/>";
} else {
print "Ошибка. Подарок не доставлен.<br/>";
}
}
}
print $divide;
echo "<a href=\"cabinet.php?$ses&amp;ref=$ref\">Личный кабинет</a><br/>\n";
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close ($link);
exit;
}
?>