Просмотр файла globalchat/chat.php

Размер файла: 2.47Kb
<?php
require 'controller/prestart.php';
/* Проверяем переданные параметры */
if (!empty ($_GET['room_id']) && is_numeric ($_GET['room_id']))
$room_id = (int) $_GET['room_id'];
else
{
header ("Location: index.php");
exit ();
}

if ($gc_browser_type == 'web')
{
header ("Location: ajax_chat.php?room_id=$room_id");
exit ();
}

$currentPage = $gcNavigation->getPageNumber ();
/* Заказываем и получаем результат */
$gcProcess->addRequest ('currentPage', $currentPage);

if (!empty ($_POST['msg']) && (empty ($_SESSION['gc_msg_last']) || $_SESSION['gc_msg_last'] !== $_POST['msg']))
{
$_SESSION['gc_msg_last'] = $_POST['msg'];
	if (!empty ($_POST['write_to_user']))
	$_POST['msg'] = '@'.$_POST['write_to_user'].', '.$_POST['msg'];
$gcProcess->addRequest ('msg', $_POST['msg']);
}
elseif (!empty ($_GET['write_to_user']))
$gcProcess->addRequest ('getUserInfo', $_GET['write_to_user']);

$gcProcess->addRequest ('roomId', $room_id);
$gcProcess->requestTo ('chat.php');

require 'controller/start.php';

$gcChat = new gcChat;
$gcSmarty->assign ('roomId', $room_id);

if (!empty ($result['module']))
{
$gcSmarty->assign ('module', $result['module']);
$gcSmarty->display ('module_'.$result['module']['name'].'.tpl');
}

if (empty ($_GET['autoupdate']))
{
	if (!empty ($_GET['write_to_user']))
	{
	$gcSmarty->assign ('userId', (int) $_GET['write_to_user']);
	$gcSmarty->display ('write_user.tpl');
	}
$gcSmarty->assign ('autoupdate', !empty ($_GET['autoupdate']));
$gcSmarty->assign ('time', TIME);
$gcSmarty->display ('msg_form.tpl');
}
else
{
	if (!empty ($_POST['autoupdate_interval']))
	$gcChat->changeAutoRefreshInterval ($_POST['autoupdate_interval']);
	
$autoupdate_interval = $gcChat->getAutoRefreshInterval ();
$gcSmarty->assign ('autoupdateInterval', $autoupdate_interval);
$gcSmarty->assign ('time', TIME);
$gcSmarty->display ('autoupdate_interval_form.tpl');
header ("Refresh: $autoupdate_interval; url=?room_id=$room_id&autoupdate=1&".TIME);
}

$gcSmarty->assign ('usersList', $result['usersInTheRoom']);
$gcSmarty->assign ('div', 1);
$gcSmarty->display ('users_in_the_room.tpl');

$gcSmarty->assign ('chatMsgs', $result['chatMsgs']);
$gcSmarty->assign ('myId', $result['myId']);
$gcSmarty->display ('msgs_list.tpl');

echo $gcChat->pagination ("?room_id=$room_id&amp;", $result['numberOfMsgsInTheRoom'], $currentPage);

$gcSmarty->display ('room_foot.tpl');

require "cms/$gc_cms/foot.php";