php include data Plugins document php include codes pagination php err

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
include 'data/Plugins/document.php';
include 'codes/pagination.php';
error_reporting(E_ALL);
H ('Гостевая');
$db = DB::$dbs;
?>
<div class="menu2"><?=hi($us);?></div>
<?php
if (isset($_GET{'del'}))
{
$query = $db->query('SELECT `user` FROM `guest` WHERE `id` = "'.(int) $_GET['del'].'"');
if ($query->rowCount() > 0 OR $us['level'] >= 2)
{
$user = $query -> fetch();
$user = $user['user'];
if ($user == $us['id'] OR $us['level'] >= 2)
{
$db->query('DELETE FROM `guest` WHERE ((`id` = "'.(int) $_GET['del'].'"))');
echo '<div class="error">Удалено</div>';
}
}
}
if (isset($_POST{'btn'}))
{
$error = [];
if (empty($_POST['message']))
{
$error[] = 'Вы не ввели сообщение';
}
if (isset($_GET['send']))
{
if ($db -> query('SELECT `id` FROM `us` WHERE `id` = "'.(int) $_GET['send'].'"') -> rowCount() == 0)
{
$error[] = 'Вы хотите ответить не существующему юзеру';
}
if ($_GET['send'] == $us['id'])
{
$error[]='Вы не можете ответить самому себе';
}
}
if (empty($error))
{
$ips = (isset($us[ 'id' ]) == 0 ) ? $IP : '';
$send = isset($_GET['send']) ? (int) $_GET['send'] : '';
$prepareQuery = 'INSERT INTO `guest` SET
`id` = "NULL",
`user` = "'.$us{'id'}.'",
`message` = '.$db->quote($_POST{'message'}).',
`time` = "'.time().'",
`send` = "'.$send.'",
`ip` = "'.$ips.'"
';
if ($send != '')
{
$query = 'INSERT INTO `action` SET
`id` = "NULL",
`value` = "us{'.$us['id'].'} ответил вам в <a href=/guest.php>гостевой</a>",
`t` = "'.time().'",
`us` = "'.(int) $send.'",
`see` = "1",
`razd` = "other"
';
$db -> query($query);
}
if ($db -> query($prepareQuery))
{
header('location: /guest.php?success');
}
else
{
?><div class="error">Сообщение не добавленно, ошибка сервера</div><?php
}
}
else
{
foreach ($error as $err)
{
?><div class="error"><?=$err;?></div><?php
}
}
}
if (isset($_GET{'success'}))
{
?><div class="access">Сообщение добавленно</div><?php
}
$pg = new Pagination;
$pg -> init([
'page' => isset($_GET['page']) ? (int) $_GET['page'] : 1,
'num' => 10,
'posts' => $db->query('SELECT `id` FROM `guest`')->rowCount()
]);
$query = $db -> query('SELECT * FROM `guest` ORDER BY `id` DESC LIMIT '.$pg->start.', '.$pg->num);
if (isset($_GET['send']))
{
?><div class="block">Ответ: <?=Nick((int) $_GET['send']);?></div><?php
}
?>
<div style="padding: 10px; background-color: #ddd; border: 1px solid #ddd;">
<form method="POST">
<p><textarea name="message"></textarea></p>
<p><input type="submit" name="btn" value="Написать"></p>
</form>
</div>
<?php
if ($query -> rowCount() > 0)
{
$rows = $query -> fetchAll();
foreach ($rows as $row)
{
?>
<div class="block">
<?=Nick($row['user']);?> <?=($row['send'] != 0 ? 'ответил: '.Nick($row['send']) : '');?> <b>(<?=datef($row['time']);?>)</b> <?=($us['id'] != $row['user'] ? '<a href="?send='.$row['user'].'">[Отв]</a>' : '');?> <?=(($us{'id'} == $row{'user'} OR $us['level'] >= 2) ? '<a href="?del='.$row{'id'}.'"> [Удл]</a>' : '');?>
<p><?=tag(htmlspecialchars($row['message']));?>
<?=(($row[ 'ip' ] != 0 AND $row[ 'user' ] == 0 AND $us[ 'level' ] >= 2) ? '</p><div style="float:right;">IP: <a href="/adm/ips.php?ip=' . $row[ 'ip' ] . '">' . $row[ 'ip' ] . '</a></div><br/>' : '</p>'); ?>
</div>
<?php
}
echo $pg->display('?page=');
}
else
{
?>
<div class="error">Сообщений пока нет!</div>
<?php
}
require_once('includes/Footers.php');
?>