Файл: forum/topslist.php
Строк: 202
<?
session_start();
include ("header.php");
$data=date("YmdHi");
$data4=date("Ymd");
$ref=rand(10000,10000000);
if (!$autorize) {
echo $div["header"];
echo "[<a href="login.php?".session_name()."=".session_id()."">Вход</a>][<a href="reg.php?".session_name()."=".session_id()."">Регистрация</a>]<br/>";
echo $div["end"];
echo $div["div"];
if ($_SESSION['wap']!="xml") {echo "-<br/>";}
echo $div["end"];
}
//Проверка
$qp = mysql_query("select forums,podforums from forum where id='$p';");
if (mysql_affected_rows()==0)
{
echo $div["div"];
echo "Ошибка!<br/>";
if ($_SESSION['wap']!="xml") {echo "-<br/>";}
echo $div["end"];
include ("footer.php");
exit();
}
//берем все это дело :)
$fie=mysql_fetch_array($qp);
$forums=$fie['forums'];
$podforums=$fie['podforums'];
$qpf = mysql_query("select id from forum where ((forums='$forums')and(f='1'));");
$qpp = mysql_query("select id from forum where ((podforums='$podforums')and(b='1'));");
$forumsidDB=mysql_fetch_array($qpf);
$podforumsidDB=mysql_fetch_array($qpp);
$forumsid=$forumsidDB['id'];
$podforumsid=$podforumsidDB['id'];
//настройки навигации
$page=@$_GET['page'];
if (!isset($page) || $page=='' || $page<1 ) {
$page=1;}
if ($autorize) {$max_lines_on_page=$autorize['topmsg'];} else {$max_lines_on_page=10;}
$maxpages=5;
$t=2;
$limit=($page-1)* $max_lines_on_page;
//поехали :)
echo $div["header"];
echo "<a href="index.php?b=$forumsid&".session_name()."=".session_id()."">$forums</a> » ";
if ($mod!="add") {echo "$podforums<br/>";} else { echo "<a href="topslist.php?p=$podforumsid&".session_name()."=".session_id()."">$podforums</a><br/>";}
echo $div["end"];
echo $div["div"];
if ($_SESSION['wap']!="xml") {echo "-<br/>";}
echo $div["end"];
if ($autorize&&$mod=="add")
{
if (empty($go))
{
if ($_SESSION['wap']=="xml")
{
echo "<form action="topslist.php?p=$p&mod=add&".session_name()."=".session_id()."&go=post" method="post">";
echo "<div>";
echo "Тема: <br/>";
echo "<input name="theme" maxlength="100" title="Text"/><br/>";
echo "<select name="translitT" multiple="multiple">
<option value="1">Транслит</option></select><br/>";
echo "Сообщение: <br/>";
echo "<input name="message" maxlength="250" title="Text"/><br/>";
echo "<select name="translitM" multiple="multiple">
<option value="1">Транслит</option></select><br/>";
echo "<input class="ibutton" type="submit" value="Создать"/>";
echo "</div>";
echo "</form>";
}
else
{
echo "Тема: <br/>";
echo "</small><input name="theme".$ref."" maxlength="100" title="Text"/><br/><small>";
echo "</small><select multiple="true" name="translitT">
<option value="1">Транслит</option></select><small><br/>";
echo "Сообщение: <br/>";
echo "</small><input name="message".$ref."" maxlength="250" title="Text"/><br/><small>";
echo "</small><select multiple="true" name="translitM">
<option value="1">Транслит</option></select><small><br/>";
echo "<anchor title="send">Создать<go href="topslist.php?p=$p&mod=add&".session_name()."=".session_id()."&go=post" method="post">";
echo "<postfield name="theme" value="$(theme".$ref.")"/>";
echo "<postfield name="message" value="$(message".$ref.")"/>";
echo "<postfield name="translitM" value="$(translitM)"/>";
echo "<postfield name="translitT" value="$(translitT)"/>";
echo "</go></anchor><br/>";
}
}
else
{
echo $div["div"];
//проверка символов
$theme=htmlspecialchars(stripslashes(trim($theme)));
$message=htmlspecialchars(stripslashes(trim($message)));
$theme=str_replace("$","$$",$theme);
$message=str_replace("$","$$",$message);
if($translitM==1) $message=latrus($message);
if($translitT==1) $theme=latrus($theme);
if(empty($error)) $error='';
if(empty($theme)) $error='Название темы не может быть пустым!<br/>';
if(empty($message)) $error=$error.'Вам необходимо оставить сообщение!';
$row = @mysql_query("select * from messages where (themes='".$theme."');");
$w = @mysql_fetch_array($row);
$db_logins = $w['themes'];
//Проверка на схожесть и т.д
if(empty($error))
{
if(strtolower($theme) == strtolower($db_logins))
{
echo "Тема с таким названием уже существует!<br/>";
echo "<anchor>Назад<prev/></anchor><br/>";
}
else
{
$who=$autorize['login'];
@mysql_query("insert into messages values(0,'$forums','$podforums','$theme','$who','$message','0','$data');")or die ("FUCK");
$id_msg=mysql_insert_id();
@mysql_query("insert into forum values(0,'$forums','$podforums','$theme','','','1','$who','$data','','','$id_msg');")or die ("FUCK");
@mysql_query("UPDATE users SET `posts`=`posts`+'1' WHERE login='$who'");
echo "Тема успешно создана!<br/>";
}
}
else
{
echo "$error<br/>";
}
echo $div["end"];
}
echo $div["div"];
if ($_SESSION['wap']!="xml") {echo "-<br/>";}
echo $div["end"];
include ("footer.php");
exit();
}
echo $div["div"];
if (($autorize['adminka']==1)&&$admin=="del")
{
@mysql_query("delete from forum where `themes`='$delid'");
@mysql_query("delete from messages where `themes`='$delid'");
}
$q= mysql_query("select * from forum where ((t='1')and(podforums='$podforums')and(forums='$forums'));");
$all=mysql_num_rows($q);
$qy = mysql_query("select * from forum where ((`mod`='1')and(t='1')and(podforums='$podforums')and(forums='$forums')) order by id_msg desc LIMIT $limit, $max_lines_on_page;");
if (empty($page)||$page==1)
{
echo $div["end"];
echo $div["ten"];
while ($field=mysql_fetch_array($qy))
{
$id=$field['id'];
$themes=$field['themes'];
$who=$field['who'];
$db_data=$field['data'];
$db_data=substr($db_data,0,8);
$qi = mysql_query("select * from messages where ((forums='$forums')and(podforums='$podforums')and(themes='$themes'));");
$row=mysql_fetch_array($qi);
$post=$row['id'];
$i=mysql_num_rows($qi);
//if ($db_data==$data4) {echo "<b>!</b>";} else {echo "<b>!</b>";}
echo "<b>!</b><a href="postslist.php?p=$id&".session_name()."=".session_id()."">$themes</a><b>!</b>[$i] $who ";
if ($autorize['adminka']==1) { echo "<a href="topslist.php?p=$p&admin=del&delid=$themes&".session_name()."=".session_id()."">X</a><br/>";
} else { echo "<br/>"; }
}
}
if ($page>1) {echo $div["end"]; echo $div["ten"];}
$query = mysql_query("select * from forum where ((`mod`='0')and(t='1')and(podforums='$podforums')and(`forums`='$forums')) order by id_msg desc LIMIT $limit, $max_lines_on_page;");
if (mysql_affected_rows()==0)
{
echo "К сожалению пока нет тем :(<br/>";
if ($autorize) {echo "-<br/>[<a href="topslist.php?p=$p&mod=add&".session_name()."=".session_id()."">Новая тема</a>]<br/>";}
if ($_SESSION['wap']!="xml") {echo "-<br/>";}
echo $div["end"];
include ("footer.php");
exit();
}
else
{
while ($field=mysql_fetch_array($query))
{
$id=$field['id'];
$themes=$field['themes'];
$who=$field['who'];
$db_data=$field['data'];
$db_data=substr($db_data,0,8);
$qi = mysql_query("select * from messages where ((forums='$forums')and(podforums='$podforums')and(themes='$themes'));");
$row=mysql_fetch_array($qi);
$post=$row['id'];
$i=mysql_num_rows($qi);
//if ($db_data==$data4) {echo "<b>»</b>";} else {echo "»";}
echo "»"; echo "<a href="postslist.php?p=$id&".session_name()."=".session_id()."">$themes</a>[$i] $who ";
if ($autorize['adminka']==1) { echo "<a href="topslist.php?p=$p&admin=del&delid=$themes&".session_name()."=".session_id()."">X</a><br/>";
} else { echo "<br/>"; }
}
echo $div["end"];
echo $div["div"];
}
//функция навигации
function PRINT_NUM_PAGE(){
global $page,$all, $max_lines_on_page, $max_pages_on_page, $maxpages, $t, $p,$div;
$maxpage=ceil($all/$max_lines_on_page);
if ($maxpage!=1){
if ($_SESSION['wap']!="xml") {echo "-<br/>";}
if ($page>1) echo "<a href="topslist.php?p=$p&page=".($page-1)."&".session_name()."=".session_id()."">«-</a>";
else echo "«-";
if ($_SESSION['wap']=="xml")
{
echo $div["end"];
echo "<form action="topslist.php" method="get">";
echo "<div>";
echo "<input name="page" maxlength="3" value="1" size="3"/>";
echo "<input type="hidden" name="p" value="$p"/>";
echo "<input type="hidden" name="".session_name()."" value="".session_id().""/>";
echo "<input class="ibutton" type="submit" value="»"/>";
echo "</div>";
echo "</form>";
echo $div["div"];
}
else
{
echo " | </small><input name="page" maxlength="3" value="1" size="3"/><small>";
echo "<a href="topslist.php?p=$p&page=$(page)&".session_name()."=".session_id()."">»</a> | ";
}
if ($page<$maxpage) echo " <a href="topslist.php?p=$p&page=".($page+1)."&".session_name()."=".session_id()."">-»</a> <br/>";
else echo " -» <br/>";
if ($page==4) {echo "<a href="topslist.php?p=$p&page=1&".session_name()."=".session_id()."">1</a>";}
if ($page>4) {echo "<a href="topslist.php?p=$p&page=1&".session_name()."=".session_id()."">1</a> ... "; }
if ($t=='2'){
$l=$page - floor($maxpages/2);
$r=$page + floor($maxpages/2);
if ($l<1){$l='1'; $r=$maxpages;}
if ($r>$maxpage){$r=$r+$r/2;}
if (($page-1)>$maxpages-3/2){ $ll=$l+1; echo "<a href="topslist.php?p=$p&page=$ll&".session_name()."=".session_id()."">«</a> ";
}
}else{
$l = ceil($page/$maxpages)*$maxpages+1- $maxpages;
$r = ceil($page/$maxpages)*$maxpages;
}
$l=$l;
for ($l; $l<=$r; $l++){
if ($l>$maxpage)break;
if ($l == $page){
print " <b>$page</b> ";
}else{
echo " <a href="topslist.php?p=$p&page=$l&".session_name()."=".session_id()."">$l</a> ";}
}
if ($maxpage>$r) { $ll=$r+1;
echo "<a href="topslist.php?p=$p&page=$ll&".session_name()."=".session_id()."">»</a> ";}
if ($page<$maxpage-2&&$maxpage>5) {echo "... <a href="topslist.php?p=$p&page=$maxpage&".session_name()."=".session_id()."">$maxpage</a> ";}
echo "<br/>";
}
}
PRINT_NUM_PAGE();
if ($autorize) {echo "-<br/>"; echo "[<a href="topslist.php?p=$p&mod=add&".session_name()."=".session_id()."">Новая тема</a>]<br/>";}
$qpmf = mysql_query("select * from moders where ((forum='$forumsid')or(forum='all')) order by id;");
if (mysql_affected_rows()!=0)
{
echo "-<br/>";
echo "Модераторы: ";
while ($modery=mysql_fetch_array($qpmf))
{
$q=mysql_query("select max(id) from moders where ((forum='$forumsid')or(forum='all'));");
$row=mysql_fetch_array($q);
$last_id=$row['0'];
$id=$modery['id'];
echo "<b>".$modery['who']."</b>";
if ($id!=$last_id) {echo ", ";} else {echo "<br/>";}
}
}
if ($_SESSION['wap']!="xml") {echo "-<br/>";}
echo $div["end"];
include ("footer.php");
?>