Файл: Arhmobi_esdcms/sys/widgets/chat_n/index.php
Строк: 33
<?php
defined('DCMS') or die;
$db = DB::me();
$res = $db->prepare("
SELECT * FROM (
SELECT COUNT( * ) cnt FROM `chat_mini` WHERE `time` > ?) q1, (
SELECT COUNT( * ) users FROM `users_online` WHERE `request` LIKE ?)q2
");
$res->execute(Array(NEW_TIME, '/chat_mini/%'));
$row = $res->fetch();
$new_posts = $row['cnt'];
$users = $row['users'];
$listing = new listing();
$post = $listing->post();
$post->highlight = true;
$post->icon('ch_mini');
$post->url = '/chat_mini/';
$post->title = __('Мини чат');
if ($new_posts)
$post->counter = '+' . $new_posts;
if ($users)
$post->bottom = __('%s ' . misc::number($users, 'человек', 'человека', 'человек'), $users);
$q = $db->query("SELECT * FROM `chat_mini` ORDER BY `id` DESC LIMIT 2");
if ($arr = $q->fetchAll()) {
foreach ($arr AS $message) {
$ank = new user($message['id_user']);
$post = $listing->post();
$post->id = 'chat_post_' . $message['id'];
$post->url = '/chat_mini/actions.php?id=' . $message['id'];
$post->time = misc::when($message['time']);
$post->title = $ank->nick();
$post->post = text::toOutput($message['message']);
if ($user->group >= 2)
$post->action('delete', "/chat_mini/message.delete.php?id=$message[id]&return=" . URL);
}
}
$listing->display();