View file mag.php

File size: 12.11Kb
<?
header("Cache-Control: no-cache");
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");

if ($ver=="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>";
echo "<head><meta http-equiv=\"Cache-Control\" content=\"no-cache\" forua=\"true\"/></head>";
echo "<card id=\"chatrules\" title=\"Магазин\">";
echo "<p><small>";
}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\">";
if($row["skin"]=="0"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css.css\"/>";}
if($row["skin"]=="1"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css1.css\"/>";}
if($row["skin"]=="2"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css2.css\"/>";}
if($row["skin"]=="3"){
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"css/css3.css\"/>";}
echo "<title>Магазин Чата</title>";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body><div class=\"header\">";

}

$re =mysql_fetch_array(mysql_query("Select money,posts,status,user from users where id='$id' LIMIT 1;"));
$row =mysql_fetch_array(mysql_query("Select nik,status,objav,topic,obiav from kurs where id='1' LIMIT 1;"));
$nik= $row["nik"];
$status= $row["status"];
$objav= $row["objav"];
$topic= $row["topic"];
$obiav= $row["obiav"];
$monets = $re["money"];
$post= $re["posts"];
switch($mode) {
default:
if ($ver=="xhtml"){echo"<div class='d3'>";}
echo "<b>Магазин Чата</b><br/>";
if ($ver=="xhtml"){echo"</div>";}

if ($ver=="wml"){echo $divide;}
if ($ver=="xhtml"){echo"<div class='d1'>";}
echo"У вас : <font color='green'><b>$monets рублей</b></font><br/>";
if ($ver=="xhtml"){echo"</div>";}
if ($ver=="xhtml"){echo"<div class='d2'>";}
echo "<a href=\"mag.php?$ses&amp;ref=$ref&amp;mode=topic\">сменить Топик в комнате($topic рублей)</a><br/>\n";
echo "<a href=\"mag.php?$ses&amp;ref=$ref&amp;mode=status\">купить Особый Статус($status рублей)</a><br/>\n";
echo "<a href=\"mag.php?$ses&amp;ref=$ref&amp;mode=obiav\">Объявление в прихожей($obiav рублей)</a><br/>\n";
echo "<a href=\"mag.php?$ses&amp;ref=$ref&amp;mode=nik\">Сменить ник($nik рублей)</a><br/>\n";
if ($ver=="xhtml"){echo"</div>";}
break;

case'topic':
if ($ver=="xhtml"){echo"<div class='d3'>";}
echo"<b>Выбирите Комнату,в которой вы хотите изменить топик</b>:<br/>";
if ($ver=="xhtml"){echo"</div>";}
$re =mysql_fetch_array(mysql_query("Select money,posts from users where id='$id' LIMIT 1;"));
$monets = $re["money"];
echo $fsize1;
if ($ver=="xhtml"){echo"<div class='d2'>";}
echo"У вас: <font color='green'><b>$monets рублей</b></font><br/>";
if ($ver=="xhtml"){echo"</div>";}
if ($monets<25){if ($ver=="xhtml"){echo"<div class='d2'>";}echo"Для изменения топика необходимо иметь <font color='green'><b>25рублей</b></font><br/>";
echo" пожалуйста зайдите позже(когда наберете необходимую сумму)!<br/>";if ($ver=="xhtml"){echo"</div>";}
}
else
{
$q = mysql_query("select rm,name from rooms");
while($arr=mysql_fetch_array($q)) {
echo $fsize1;
if ($ver=="xhtml"){echo"<div class='d1'>";}
echo "<a href=\"top.php?$ses&amp;ref=$ref&amp;rm=".$arr['rm']."\">".$arr['rm'].". ".$arr['name']."</a><br/>";
if ($ver=="xhtml"){echo"</div>";}
echo $fsize2;
}
}
break;
case'status':
if ($ver=="xhtml"){echo"<div class='d3'>";}
echo"Особый статус ;)<br/>";
if ($ver=="xhtml"){echo"</div>";}
$stat= $re["status"];
$stat=htmlspecialchars(stripslashes(trim($stat)));
$stat = check($stat);
if ($monets<50){if ($ver=="xhtml"){echo"<div class='d2'>";}echo"Чтобы купить себе статус вам нужно иметь <font color='green'><b>50рублей</b></font><br/>";
echo" сейчас ваш статус: <font color='blue'>$stat</font><br/>";if ($ver=="xhtml"){echo"</div>";}
} 
else
{
$stat= $re["status"];
if ($ver=="xhtml"){echo"<div class='d1'>";}
echo "<form method=\"post\" action=\"mag.php?$ses&amp;ref=$ref&amp;mode=status_set\">\n";
echo "Статус:<br/><input name=\"stat\" class=\"form\" value=\"$stat\" type=\"text\" />\n";
echo "<input value=\"Изменить\" class=\"form\" type=\"submit\" />\n";
echo "</form>\n";
if ($ver=="xhtml"){echo"</div>";}
}
break;
case'status_set':
$monets = $re["money"];
$monets=htmlspecialchars(stripslashes(trim($monets)));
$monets = check($monets);
if($stat==''){
if ($ver=="xhtml"){echo"<div class='d2'>";}
echo"ERROR<br/>";
if ($ver=="xhtml"){echo"</div>";}
if ($ver=="xhtml"){echo"<div class='d3'>";}
echo "<a href=\"mag.php?$ses&amp;ref=$ref&amp;mode=status\">Особый Статус</a><br/>\n";
if ($ver=="xhtml"){echo"</div>";}
}
else if ($monets<50){
if ($ver=="xhtml"){echo"<div class='d2'>";}
echo"Недостаточно средств!<br/>";
if ($ver=="xhtml"){echo"</div>";}
if ($ver=="xhtml"){echo"<div class='d3'>";}
echo "<a href=\"mag.php?$ses&amp;ref=$ref&amp;mode=status\">Особый Статус</a><br/>\n";
if ($ver=="xhtml"){echo"</div>";}
}
else
{
 if(@mysql_query("update `users` set status='$stat'  WHERE `id` = '".$id."';"))
 {
 $bablo=$monets-50;
 mysql_query("update `users` set money='$bablo'  WHERE `id` = '".$id."';");
 if ($ver=="xhtml"){echo"<div class='d2'>";}
 echo"Статус успешно изменён!<br/>";
 if ($ver=="xhtml"){echo"</div>";}
 if ($ver=="xhtml"){echo"<div class='d3'>";}
 echo "<a href=\"mag.php?$ses&amp;ref=$ref&amp;mode=status\">Особый Статус</a><br/>\n";
 if ($ver=="xhtml"){echo"</div>";}
 }

}

break;

case'nik':
if ($ver=="xhtml"){echo"<div class='d3'>";}
echo"Смена ника ;)<br/>";
if ($ver=="xhtml"){echo"</div>";}
$stat= $re["user"];
$stat=htmlspecialchars(stripslashes(trim($stat)));
$stat = check($stat);
if ($monets<1000){if ($ver=="xhtml"){echo"<div class='d2'>";}echo"Чтобы купить себе новый ник вам нужно иметь <font color='green'><b>1000рублей</b></font><br/>";
} 
else
{
$stat= $re["user"];
$stat=htmlspecialchars(stripslashes(trim($stat)));
$stat = check($stat);
if ($ver=="xhtml"){echo"<div class='d2'>";}
echo" сейчас ваш ник: <font color='blue'>$stat</font><br/>";
if ($ver=="xhtml"){echo"</div>";}
if ($ver=="xhtml"){echo"<div class='d1'>";}
echo "<form method=\"post\" action=\"mag.php?$ses&amp;ref=$ref&amp;mode=nik_set\">\n";
echo "Новый ник:<br/><input name=\"stat\" class=\"form\" value=\"$stat\" type=\"text\" />\n";
echo "<input value=\"Изменить\" class=\"form\" type=\"submit\" />\n";
echo "</form>\n";
if ($ver=="xhtml"){echo"</div>";}
}
break;
case'nik_set':
$monets = $re["money"];
$monets=htmlspecialchars(stripslashes(trim($monets)));
$monets = check($monets);
if($stat==''){
if ($ver=="xhtml"){echo"<div class='d2'>";}
echo"ERROR<br/>";
if ($ver=="xhtml"){echo"</div>";}
if ($ver=="xhtml"){echo"<div class='d3'>";}
echo "<a href=\"mag.php?$ses&amp;ref=$ref&amp;mode=nik\">Смена ника</a><br/>\n";
if ($ver=="xhtml"){echo"</div>";}
}
else if ($monets<1000){
if ($ver=="xhtml"){echo"<div class='d2'>";}
echo"Недостаточно средств!<br/>";
if ($ver=="xhtml"){echo"</div>";}
if ($ver=="xhtml"){echo"<div class='d3'>";}
echo "<a href=\"mag.php?$ses&amp;ref=$ref&amp;mode=nik\">Смена ника</a><br/>\n";
if ($ver=="xhtml"){echo"</div>";}
}
else
{
 if(@mysql_query("update `users` set user='$stat'  WHERE `id` = '".$id."';"))
 {
 $bablo=$monets-1000;
 mysql_query("update `users` set money='$bablo'  WHERE `id` = '".$id."';");
 if ($ver=="xhtml"){echo"<div class='d2'>";}
 echo"Ник успешно изменён!<br/>";
 if ($ver=="xhtml"){echo"</div>";}
 if ($ver=="xhtml"){echo"<div class='d3'>";}
 echo "<a href=\"mag.php?$ses&amp;ref=$ref&amp;mode=nik\">Смена ника</a><br/>\n";
 if ($ver=="xhtml"){echo"</div>";}
 }

}

break;


case 'obiav':
if ($monets<100){echo"Для добавления обьявления необходимо иметь <font color='green'><b>100рублей</b></font><br/>";
echo" пожалуйста зайдите позже(когда наберете необходимую сумму)!<br/>";
}
else{
$login=$row["user"]; 
$title=trim(htmlspecialchars(stripslashes($title)));
$content=trim(htmlspecialchars(stripslashes($content)));
$login=trim(htmlspecialchars(stripslashes($login)));
$title = check($title);
$content = check($content);
$login = check($login);

if(empty($title)) $error=$error."<div class='d2'><u>Название не введено!</u></div><br/>";
if(empty($content)) $error=$error."<div class='d2'><u>Пустое содержание объявления!</u></div><br/>";
if(empty($action)) {
if ($ver=="wml"){
echo $fsize1;
echo "<font color='red'>Внимание!  Любое объявление содержащее мат(в любом контексте) рекламу сторонних ресурсов будет незамедлительно удалено,а автор уйдет в баню и на долго!(создавая обьявление не забывайте о правилах чата)</font><br/>";
echo "Название:<br/>";
echo $fsize2;
echo "<input name=\"title\"/><br/>";
echo $fsize1;
echo "Содержание:<br/>";
echo $fsize2;
echo "<input name=\"content\"/><br/>";
echo $fsize1;
echo "<anchor>Добавить<go href=\"mag.php?$ses&amp;mode=obiav$takep\" method=\"post\">";
echo "<postfield name=\"action\" value=\"add\"/>";
echo "<postfield name=\"title\" value=\"$(title)\"/>";
echo "<postfield name=\"content\" value=\"$(content)\"/>";
echo "</go></anchor>";
echo $fsize2;
echo "<br/>";
}else{
if ($ver=="xhtml"){echo"<div class='d1'>";}
echo "<form method=\"POST\" action=\"mag.php?$ses&amp;mode=obiav$takep\" name=\"auth\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"add\"/>\n";
echo $fsize1;
echo "<font color='red'>Внимание!  Любое объявление содержащее мат(в любом контексте) рекламу сторонних ресурсов будет незамедлительно удалено,а автор уйдет в баню и на долго!(создавая обьявление не забывайте о правилах чата)</font><br/>";
echo "Название:<br/>";
echo $fsize2;
echo "<input type=\"text\" name=\"title\"/><br/>\n";
echo $fsize1;
echo "Содержание:<br/>";
echo $fsize2;
echo "<input type=\"text\" name=\"content\"/><br/>\n";
echo "<input type=\"submit\" value=\"Добавить\" name=\"enter\"><br/>\n";
if ($ver=="xhtml"){echo"</div>";}
}
} else { 

if(empty($error)) {
if($title!=$last_obiav['title']) {
if(mysql_query("insert into obiav values(0,'".$login."','".$title."','".$content."');")) 
 { 

echo $fsize1;
if ($ver=="xhtml"){echo"<div class='d2'>";}
$bablo2=$monets-100;
mysql_query("update `users` set money='$bablo2'  WHERE `id` = '".$id."';");
echo "<b>Ваше объявление успешно добавлено!</b><br/>"; 
if ($ver=="xhtml"){echo"</div>";}
echo $fsize2;
} else { 
echo $fsize1;
if ($ver=="xhtml"){echo"<div class='d2'>";}
echo "<b>Проблемы с базой данных!</b><br/>"; 
if ($ver=="xhtml"){echo"</div>";}
echo $fsize2;
} 
} else { 
echo $fsize1;
{
if ($ver=="xhtml"){echo"<div class='d2'>";}
echo "<b>Такое объявление уже добавлено</b><br/>";
if ($ver=="xhtml"){echo"</div>";}
echo $fsize2;}
}
} else { 
echo $fsize1;
echo $error; 
echo $fsize2;
} 
}
}
break;

}
if($ver=="xhtml"){ echo "</div><div class='d3'>";}
echo "<a href=\"mag.php?$ses&amp;ref=$ref\">Магазин</a><br/>\n";
echo "<a href=\"cabinet.php?$ses&amp;ref=$ref\">Личный кабинет</a><br/>\n";
echo "<a href=\"enter.php?$ses&amp;ref=$ref\">Прихожая</a><br/>";

echo "</small>";
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
?>