View file chat/rooms.who.php

File size: 2.14Kb
<?php
#-*- coding: utf-8 -*-
#Name:     chatRooms v1.0 alpha
#Author:    Nugroho Adi Prayatso
#e-mail:     hongoaoi@gmail.com
#Web:        frendzzi.tk

include_once '../sys/inc/start.php';
$doc = new document(1);

$doc->title = 'Who is online?';

if (!isset($_GET['id']) || !is_numeric($_GET['id']))
{
header('Refresh: 1; url=./');
$doc->err('Error when selecting');
exit;
}
$id_room=(int)$_GET['id'];

$q=mysql_query("SELECT * FROM `chat_rooms` WHERE `id` = '$id_room'");

if (!mysql_num_rows($q))
{
header('Refresh: 1; url=./');
$doc->err('Not found');
exit;
}

$room=mysql_fetch_assoc($q);
$nama=mysql_fetch_array(mysql_query("select * from chat_rooms where id =".$id_room));

$doc->title = 'Who is online - '.$nama['name'].' ('.mysql_result(mysql_query("SELECT COUNT(*) FROM `chat_who` WHERE `room` = '$id_room'"),0).')';

$posts = array();


$whois = "".mysql_result(mysql_query("SELECT COUNT(*) FROM `users_online` WHERE `request` LIKE '/chat/rooms.%.php?id=$id_room'"),0)." people online now";

$posts[] = array('icon' => array('size' => 'small', 'src' => '/sys/images/icons/dpanel.smiles.png'), 'title' => $whois);

$pages = new pages;

$pages->posts = mysql_result(mysql_query("SELECT COUNT(*) FROM `users_online` WHERE `request` LIKE '/chat/rooms.%.php?id=$id_room'"),0);

$pages->this_page();

$q = mysql_query("SELECT * FROM `users_online` WHERE `time_last` > '".(TIME-120)."' AND  `request` LIKE '/chat/rooms.%.php?id=$id_room' ORDER BY `time_last` DESC LIMIT {$pages->my_start()}, {$pages->items_per_page}");


while ($siapa = mysql_fetch_assoc($q)) {
    $ol = new user($siapa['id_user']);
    $where = "Location: <a href='".$siapa[request]."'>$siapa[request]</a>";

    $posts[] = array('title' => $ol->show(), 'icon' => $ol->icon(), 'post' => $where);

}

if (!$posts)
    $posts[] = array('icon' => array('size' => 'small', 'src' => '/sys/images/icons/empty.png'), 'title' => 'No users online');


$show = new design();
$show->assign('post', $posts);
$show->display('design.listing.tpl');

$pages->listing('?&amp;');

$doc->ret('Back', 'rooms.post.php?id=' . $room['id']);
$doc->ret('Chat', '/chat/');
?>