View file index.php

File size: 2.66Kb
<? include("head.php");
if(!isset($_SESSION['user_id']))
echo '<div class="menu">Авторизация<br/>
<form action="auth.php" method="post">
Логин:<br/> <input name="auth_name" type="text" /><br/>
Пароль:<br/> <input name="auth_pass" type="password" /><br/> 
<input name="" type="submit" value="Вход" />
</form>
<a href="reg.php">Регистрация</a></div>';
else if($me['admin'] ==2)echo "<div class='cat'><a href='admin/index.php'>Админ-меню</a><br/></div>";
if(isset($me))echo "<div class='cat'><b>Личное:</b><br/>
<a href='my.php'>Анкета</a><br/>
<a href='mail.php'>Личная почта</a><br/>
<a href='exit.php'>Выход</a>
</div>";

$new_q=mysql_query("SELECT * FROM `sh_new` ORDER BY `time` DESC LIMIT 1");
while($new=mysql_fetch_array($new_q))
{echo "<div class='menu'><b>Последняя новость:</b><br/><a href='new.php?id=$new[id]'>$new[name]</a><br/><small>$new[description]</small></div>";
}


$cat_q=mysql_query("SELECT * FROM `sh_cat`");
echo "<div class='menu'><b>Форумы:</b><br/>";
while($cat=mysql_fetch_array($cat_q))
{$num_pod=mysql_num_rows(mysql_query("SELECT * FROM `sh_podcat` WHERE `refid`=$cat[id]")); echo "<a href='cat.php?id=$cat[id]'>$cat[name]</a> [$num_pod/$cat[tem]/$cat[post]]<br>";}echo "</div>";

$actual_q=mysql_query("SELECT * FROM `sh_tem` WHERE `close`=0 ORDER BY `time` DESC LIMIT 5");
echo "<div class='menu'><b>Актуальные темы:</b><br/>";
while($actual=mysql_fetch_array($actual_q)){
$posl_post=mysql_fetch_array(mysql_query("SELECT * FROM `sh_post` WHERE `tema`='$actual[id]' ORDER BY `date` DESC"));
$postov=mysql_num_rows(mysql_query("SELECT * FROM `sh_post` WHERE `tema`='$actual[id]' ORDER BY `date` DESC"));
$us_av=mysql_query("SELECT * FROM `sh_user` WHERE `id`='$posl_post[avtor]'");
$user_avtor=mysql_fetch_array($us_av);
$posl_post['date']=str_replace(date("Y.m.d"), "Сегодня", $posl_post['date']);
echo "<a href='tema.php?id=$actual[id]'>$actual[name]</a> ($postov) Последний: [$posl_post[date] ";
if(mysql_num_rows($us_av)==1)echo "От: $user_avtor[echologin]]<br/>";
else echo "От: DELETED#$posl_post[avtor]]<br/>";}

echo "</div><div class='menu'><b>Статистика:</b><br/>Пользователей: ".mysql_num_rows(mysql_query("SELECT * FROM `sh_user`"))."<br/>
Форумов: ".mysql_num_rows(mysql_query("SELECT * FROM `sh_cat`"))."<br/>
Категорий: ".mysql_num_rows(mysql_query("SELECT * FROM `sh_podcat`"))."<br/>
Тем: ".mysql_num_rows(mysql_query("SELECT * FROM `sh_tem`"))."<br/>
Сообщений: ".mysql_num_rows(mysql_query("SELECT * FROM `sh_post`"))."</div>";
include("foot.php");
?>