View file chat/index.php

File size: 1.74Kb
<?php
include ("../conf.php");
include ("../lock.php");

if ($user == $myrow["user"] && $pass == $myrow["pass"])
{
echo "<link rel='stylesheet' type='text/css' href='../style.css'/>";
include ("../head.php");


$result = mysql_query("SELECT * FROM chat ORDER BY id DESC LIMIT 13",$db);
$myrow = mysql_fetch_array($result);



$at_page=10;
$count=mysql_result(mysql_query("SELECT COUNT(`id`) FROM `chat`"), 0);

$pages=ceil($count/$at_page);

$page=abs(intval(@$_REQUEST['page']));
if($page==0) $page=1;
define('PAGE', $page);
unset($page);

$from=(PAGE-1)*$at_page;
$result=mysql_query("SELECT * FROM chat ORDER BY `id` DESC LIMIT $from, $at_page");
$myrow = mysql_fetch_array($result);


echo "<div class='nav'>• <a href=add.php?page=add&user=$user&pass=$pass>Написать</a></div>";

do
{
echo "<div class='nav'> Ник: [<a href='../info.php?user=$user&pass=$pass&id=".$myrow['id_user']."'>".$myrow['user2']."</a>]<br />";
echo "<small>".$myrow['date']." </small><br />";
echo "".$myrow['text']."<br /></div>";
}
while ($myrow = mysql_fetch_array($result));

echo "<div class='nav'>";
if(PAGE>1) echo "<a href='index.php?page=".(PAGE-1)."&user=$user&pass=$pass'>Назад</a>";
if(PAGE<$pages) echo " <a href='index.php?page=".(PAGE+1)."&user=$user&pass=$pass'>Вперед</a>";
if($pages>1) echo "";
echo "</div>";

echo "<div class='nav'>• <a href=../menu.php?user=$user&pass=$pass>В меню</a></div>";
include ("../foot.php");
exit();
}
else
{
echo "<link rel='stylesheet' type='text/css' href='../style.css'/>";
include ("../head.php");
echo "<div class='nav'>";
echo "Ошибка! <br />Неверный <b>Ник</b> или<b>Пароль</b>!<br /></div>";
echo "<div class='nav'><a href='index.php'>На главную</a></div>";
include ("../foot.php");
}

?>