View file stihi.php

File size: 10.42Kb
<?
header('Cache-Control: no-store, no-cache, must-revalidate');
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); 
 

$cm = mysql_query ("select count(id) as num from stihi WHERE 1;");
$cmc = mysql_fetch_array($cm);
$stihi = $cmc["num"]; 


require("version.php");

mysql_query ("Select * from bannlist WHERE (ip = '".$REMOTE_ADDR."')and(soft = '".$HTTP_USER_AGENT."')");
if ((mysql_affected_rows()!=0)&&($rm!=9)&&($row["level"]<7)) {
$re = mysql_query("SELECT name FROM rooms where rm = '9'"); 
$inam = mysql_fetch_array ($re); 
$nam = $inam["name"];
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=\"ban\" title=\"Стоп!\" ontimer=\"index.php?ver=$ver&amp;ref=$ref\"><timer value=\"300\"/>\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\">";
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>";
echo "<div align=\"left\">\n";
echo "<title>Стоп!</title>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"30; URL=index.php?ver=$ver&amp;ref=$ref\">";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/></head><body>";
echo "<div align=\"center\">";
}
echo $fsize1;
if ($ver=="xhtml"){echo"<div class='d2'>";}
echo "Вы забанены по связке ip+soft!!!<br/>\n";
echo "И доступ вам разрешен только в  <a href=\"chat.php?$ses&amp;rm=9&amp;ref=$ref\">".$nam."</a>\n";
if ($ver=="xhtml"){echo"</div>";}
echo $fsize2;
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close($link);
exit;
}   



if ($ver=="wml"){
echo $xml;
echo $dtd;
echo "<wml>\n";
echo "<card 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\">";
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>";
echo "<div align=\"left\">\n";
}

switch($go) {

case 'read':
$q=@mysql_query("select title,content,autor,login from stihi where id='$mid';");
$arrr=@mysql_fetch_array($q);
$cont = $arrr['content'];
$autor = $arrr['autor'];
$cont = str_replace("...","<br/>",$cont);
$cont = str_replace(".","<br/>",$cont);
		echo $fsize1;
		if ($ver=="xhtml"){echo"<div class='d3'>";}
		echo "".$arrr['title'];
		if ($ver=="wml"){echo "<br/>";}
		if ($ver=="wml"){echo $divide;}
		if ($ver=="xhtml"){echo"</div>";}
		if ($ver=="xhtml"){echo"<div class='d1'>";}
		echo "$cont";
		if ($ver=="wml"){echo "<br/>";}
		if ($ver=="wml"){echo $divide;}
		echo "<br/><u>Автор:</u> ".$arrr['autor'];
		if ($ver=="wml"){echo "<br/>";}
		if ($ver=="wml"){echo $divide;}
		if ($ver=="xhtml"){echo"</div>";}
	    if ($ver=="xhtml"){echo"<div class='d2'>";}
		$user=$arrr["login"];
		if($row["sex"] = "М"){
		echo "Разместил <b>$user</b>\n";}
		else if($row["sex"] = "Ж"){
        echo "Разместила <b>$user</b>\n";}
		echo "<br/>";
        if ($ver=="xhtml"){echo"</div>";}
        echo $fsize2;
break;

case 'add':

$title=trim(htmlspecialchars(stripslashes($title)));
$content=trim(htmlspecialchars(stripslashes($content)));
$login=trim(htmlspecialchars(stripslashes($login)));
$autor=trim(htmlspecialchars(stripslashes($autor)));
$login = $row["user"];

if(empty($title)) $error=$error."<u>Название не введено!</u><br/>";
if(empty($autor)) $error=$error."<u>забыли автора!</u><br/>";
if(empty($content)) $error=$error."<u>Пустое содержание!</u><br/>";
if(empty($action)) {
if ($ver=="wml"){
echo"Внимание после точки начинается новая строка";
echo $fsize1;
echo "Название:<br/>";
echo $fsize2;
echo "<input name=\"title\" maxlength=\"50\" title=\"title\"/><br/>\n";
echo $fsize1;
echo "Содержание:<br/>";
echo $fsize2;
echo "<input name=\"content\" maxlength=\"9999\" title=\"content\"/><br/>\n";
echo $fsize1;
echo "Автор:<br/>";
echo $fsize2;
echo "<input name=\"autor\" maxlength=\"50\" title=\"autor\"/><br/>\n";
echo $fsize1;
echo $fsize1;
echo "<anchor>Добавить<go href=\"stihi.php?$ses&amp;go=add&amp;ref=$ref\" method=\"post\">";
echo "<postfield name=\"action\" value=\"add\"/>";
echo "<postfield name=\"title\" value=\"$(title)\"/>";
echo "<postfield name=\"content\" value=\"$(content)\"/>";
echo "<postfield name=\"autor\" value=\"$(autor)\"/>";
echo "</go></anchor>";
echo $fsize2;
echo "<br/>";
}else{
echo "<form method=\"POST\" action=\"stihi.php?$ses&amp;go=add&amp;ref=$ref\" name=\"auth\">\n";
echo "<input type=\"hidden\" name=\"action\" value=\"add\"/>\n";
if ($ver=="xhtml"){echo"<div class='d3'>";}
echo"Внимание после точки начинается новая строка";
if ($ver=="xhtml"){echo"</div>";}
if ($ver=="xhtml"){echo"<div class='d2'>";}
echo $fsize1;
echo "Название:<br/>";
echo $fsize2;
echo "<input type=\"text\" name=\"title\" maxlength=\"50\" title=\"title\"/><br/>\n";
echo $fsize1;
echo "Содержание:<br/>";
echo $fsize2;
echo "<input type=\"text\" name=\"content\" maxlength=\"9999\" title=\"content\"/><br/>\n";
echo $fsize1;
echo "Автор:<br/>";
echo $fsize2;
echo "<input type=\"text\" name=\"autor\" maxlength=\"50\" title=\"autor\"/><br/>\n";
echo "<input type=\"submit\" value=\"Добавить\" name=\"enter\"><br/>\n";
if ($ver=="xhtml"){echo"</div>";}
}
} else { 
if(empty($error)) {
if($title!=$last_stihi['title'])
if($content!=$last_stihi['content']){
if(mysql_query("insert into stihi values(0,'".$login."','".$title."','".$content."','".$autor."');")) { 
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;
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;

case 'del':
$q = mysql_query("select id,title from stihi order by id desc;");
if (mysql_affected_rows() == 0) {
echo $fsize1;
if ($ver=="xhtml"){echo"<div class='d2'>";}
echo "Стихов нет!!!<br/>\n";
if ($ver=="xhtml"){echo"</div>";}
echo $fsize2;
} else {
if(empty($action)) {
while($arrr=mysql_fetch_array($q)) {
echo $fsize1;
if ($ver=="xhtml"){echo"<div class='d1'>";}
echo "<a href=\"stihi.php?action=del&amp;$ses&amp;go=del&amp;mid=".$arrr['id']."\">".$arrr['title']."</a><br/>";
if ($ver=="xhtml"){echo"</div>";}
echo $fsize2;
}
} else {
if(mysql_query("delete from stihi where id='".$mid."' limit 1;")){ 
echo $fsize1;
if ($ver=="xhtml"){echo"<div class='d2'>";}
echo "<b>Запись успешно удалена!</b><br/>";
if ($ver=="xhtml"){echo"</div>";}
echo $fsize2;
}
}
}
break;


default:
$new = mysql_query ("select count(id) as num from stihi;");
$stihi = mysql_fetch_array($new);
$num = $stihi["num"]; 
if(!isset($s))$s=0;
$mx=round(($num/10)+0.45);
if($s>$mx)$s=$mx;
if($s==0)$s=1;
$ot=(($s-1)*10)+1;
$do=$s*10;
if($do>$num)$do=$num;
$o=$ot-1;
$n=$ot;
if($do==0)$n=$o;
echo $fsize1;
if ($ver=="xhtml"){echo"<div class='d3'>";}
echo "<img src='smile/iyou2.gif' alt='=)'/><br/>";
if ($ver=="xhtml"){echo"</div>";}
echo "<div class='d2'>Показывает $n-$do из $num<br/></div>\n";

if($ver=="xhtml"){ echo "<div class='d2'>";}
$r = mysql_query ("select id,title from `stihi` order by id desc limit $o,$do");
for ($i=$ot;$i<=$do;$i++){
$arrr = mysql_fetch_array($r);
$date=date("j.m.Y");


if (mysql_affected_rows() == 0) {
if ($ver=="xhtml"){echo"<div class='d1'>";}
echo "здесь пока пусто(<br/>";
if ($ver=="xhtml"){echo"</div>";}
}
if ($ver=="xhtml"){echo"<div class='d1'>";}
echo "<a href=\"stihi.php?$ses&amp;mid=".$arrr['id']."&amp;go=read&amp;ref=$ref\">".$arrr['title']."</a><br/>";
if ($ver=="xhtml"){echo"</div>";}
}
$next=$s+1;
$prev=$s-1;
if ($num>$do) {
$ot=(($next-1)*10)+1;
$do=$next*10;
if($do>$num)$do=$num;


echo "<a href=\"stihi.php?mod=m&amp;$ses&amp;s=$next&amp;ref=$ref\">&gt;&gt;$ot-$do&gt;&gt;</a><br/>\n";

}
if($s>1) {
$ot=(($prev-1)*10)+1;
$do=$prev*10;

echo "<a href=\"stihi.php?mod=m&amp;$ses&amp;s=$prev&amp;ref=$ref\">&lt;&lt;$ot-$do&lt;&lt;</a><br/>\n";
}
break;

}

if($go) {
if ($ver=="xhtml"){echo"<div class='d3'>";}
echo "<a href=\"stihi.php?$ses&amp;ref=$ref\">стихи</a><br/>";

if ($ver=="xhtml"){echo"</div>";}
}

if ($ver=="xhtml"){echo"<div class='d3'>";}
echo "<a href=\"stihi.php?$ses&amp;go=add&amp;ref=$ref\"><font color='red'>добавить стих</font></a><br/>";
if($row["level"] > 5) {
echo $fsize1;
if ($ver=="xhtml"){echo"<div class='d3'>";}
echo "<a href=\"stihi.php?$ses&amp;go=del&amp;ref=$ref\"><font color='red'>удалить стих</font></a><br/>";
if ($ver=="xhtml"){echo"</div>";}
echo $fsize2;
}
echo "<a href=\"enter.php?$ses&amp;ref=$ref\">Прихожая</a><br/>";
if ($ver=="xhtml"){echo"</div>";}
echo $fsize2;
include_once"foot.php";
if ($ver=="wml")echo "</p></card></wml>";
else echo "</div></body></html>";
mysql_close($link);
?>