View file book/index.php

File size: 2.63Kb
<?php
include_once "../config.php";
include_once "../inc/inc.php";
include_once "../inc/func.php";
include_once "../inc/user.php";
include_once "../inc/gzip.php";
include_once "../inc/online.php";
include_once "../themes/$theme/index.php";

if ($kto == 'user') {
    echo 'Гостевая<br>';
    echo'<form action="add.php?act=add" method="post">';
    echo'Сообщение<br>';
    echo'<textarea cols="30" rows="5" name="msg" type="text" value=""></textarea><br><br>';
    echo'<input type="submit" value="Добавить">';
    echo'</form><hr>';
} else {
    echo 'Вы не можете добавлять сообщения<hr>';
} 

$vsego = mysql_num_rows(mysql_query("SELECT * FROM " . $pref . "book"));
$pagevsego = $vsego / $kolbook;
$pagevsego = (int)$pagevsego;
$bbb = $vsego - ($pagevsego * $kolbook);
if ($bbb > 0) {
    $pagevsego++;
} 
$page = (int)$page;
if ($page >= $pagevsego) {
    $page = $pagevsego;
} 
if ((!isset($page)) || ($page <= 0) || ($page == '')) {
    $page = 1;
    $start = 0;
} else {
    $start = ($page * $kolbook) - $kolbook;
} 
// if($page>=$pagevsego){$page=$pagevsego;}
// $vsego = mysql_num_rows(mysql_query("SELECT * FROM ".$pref."book"));
// $query = "SELECT * FROM ".$pref."book LIMIT $start, $kolbook ORDER BY id DESC";
$query = "SELECT * FROM " . $pref . "book ORDER BY id DESC LIMIT $start, $kolbook";
$result = mysql_query($query);
// echo $start;
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
    echo '<div class="b"><a href="/setting/anketa.php?id=' . $line['id_user'] . '">' . $line['login'] . '</a> [' . $line['data'] . '] [' . $line['vrem'] . ']</div>';
    $soob = smile($line[msg]);
    echo $soob . '<br>';
    echo '[' . $line['ip'] . ' - ' . $line['brow'] . ']<br>';
    if (strlen($line['otvet']) >= 2) {
        echo'<font color="red"><u>Ответ администрации:</u></font><br><font color="#aa0000">' . $line['otvet'] . '</font><br>';
    } 
} 
echo '<hr>Страницы:<br>';
if ($page == '1') {
    echo'&lt;-Назад';
} else {
    $ggg = $page-1;
    echo '<a href="index.php?page=' . $ggg . '">&lt;-Назад</a>';
} 
echo ' [' . $page . ' из ' . $pagevsego . '] ';
if (($page == $pagevsego) || ($pagevsego == 0)) {
    echo 'Вперёд-&gt;<br>';
} else {
    $ggg = $page + 1;
    echo '<a href="index.php?page=' . $ggg . '">Вперёд-&gt;</a><br>';
} 
echo '<form action="index.php" method="get">';
echo '<input name="page" type="text" value=""><input type="submit" value="&gt;&gt;">';
echo '</form>';
echo '<hr>Всего сообщений: ' . $vsego;

include_once "../themes/$theme/foot.php";

?>