Файл: Arhmobi_esdcms/status/index.php
Строк: 45
<?php
include_once '../sys/inc/start.php';
$doc = new document();
$doc->title = __('Cтатусы');
$ank = (empty($_GET ['id'])) ? $user : new user((int) $_GET ['id']);
if (!$ank->group)
$doc->access_denied(__('Нет данных'));
//Установка статуса
if (isset($_GET['reset']) && is_numeric($_GET['reset'])) {
$id_status = (int) $_GET['reset'];
$q = $db->prepare("SELECT * FROM `status` WHERE `id` = ? AND `id_user` = ? LIMIT 1");
$q->execute(Array($id_status, $user->id));
if (!$q->fetch()) {
header('Refresh: 1; url=./');
$doc->err(__('Статуса не существует'));
exit;
}
$q = $db->prepare("UPDATE `status` SET `pokaz` = ? WHERE `id_user` = ?");
$q->execute(Array(0, $user->id));
$q = $db->prepare("UPDATE `status` SET `pokaz` = ? WHERE `id` = ? LIMIT 1");
$q->execute(Array(1, $id_status));
$doc->msg(__('Статус упешно включен'));
}
if (isset($_GET['delete']) && is_numeric($_GET['delete'])) {
$id_status = (int) $_GET['delete'];
$q = $db->prepare("SELECT * FROM `status` WHERE `id` = ? AND `id_user` = ? LIMIT 1");
$q->execute(Array($id_status, $user->id));
if (!$q->fetch()) {
header('Refresh: 1; url=./');
$doc->err(__('Статуса не существует'));
exit;
}
$q = $db->prepare("DELETE FROM `status` WHERE `id` = ? LIMIT 1");
$q->execute(Array($id_status));
$q = $db->prepare("DELETE FROM `status_komm` WHERE `id_status` = ?");
$q->execute(Array($id_status));
$q = $db->prepare("DELETE FROM `status_like` WHERE `id_status` = ?");
$q->execute(Array($id_status));
$doc->msg(__('Статус упешно удален'));
}
$doc->title .= __(': "%s"', $ank->login);
$pages = new pages($db->query("SELECT COUNT(*) FROM `status` WHERE `id_user` = '" . $user->id . "'")->fetchColumn());
$pages->this_page();
//начало листинга
$listing = new listing();
//получение статусов
$q = $db->query("SELECT * FROM `status` WHERE `id_user` = '" . $ank->id . "' ORDER BY `id` DESC LIMIT " . $pages->limit);
if ($arr = $q->fetchAll()) {
foreach ($arr AS $status) {
$post = $listing->post();
$post->post = '<div class="DCMS_st"></div><div class="DCMS_st2">' . text::toOutput($status['msg']) . '</div>';
$res = $db->prepare("SELECT COUNT(*) FROM `status_komm` WHERE `id_status` = ?");
$res->execute(Array($status['id']));
$col = $res->fetchColumn();
if ($col)
$post->bottom = '<a href="/status/status_komm.php?id=' . $status['id'] . '">' . __('<br />%s Коментари' . misc::number($col, 'й', 'я', 'ев'), $col) . '</a>';
if ($status['pokaz'] == 0) {
if (($user->id == $ank->id) || $user->group >= 2) {
$post->action('show', '?id=' . $ank->id . '&reset=' . $status['id']);
$post->action('delete', '?id=' . $ank->id . '&delete=' . $status['id']);
} elseif ($user->group >= $ank->group) {
$post->action('complaint', "/complaint.php?id=$ank->id&return=" . URL . "&link=" . urlencode("/users/status/status_komm.php?id=$status[id]"));
}
} else {
$post->hightlight = true;
$post->title = '<font color="green">Установлен</font>';
}
}}
$listing->display(__('Статусов нет'));
$pages->display('?id=' . $ank->id . '&'); // вывод страниц
$doc->ret(__('Вернуться в анкету'), '/profile.view.php?id=' . $ank->id);