<?php
/*
* @package LabCMS
* @copyright (c) 2006 Alexander Levin aka Loki (loki_angel@mail.ru)
* @support http://labcms.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
include dirname(__FILE__).'/class.lc_chat.php';

$chat=new lc_chat();

if (LabCMS::i()->isAjax())
{
	$json_response=array('error'=>'Метод '.$_POST['action'].' не найден');
	$chat->setTpl('');
	if (method_exists($chat, $method='lc_'.$_POST['action']))
	{
		$json_response['error']=0;
		if ($response=call_user_func(array($chat, $method)))
					$json_response=$response;
		if (!LabCMS::i()->no_errors) $json_response=array('error'=>LabCMS::i()->errors[0]);
	}
	
	echo real_json_encode($json_response);
	exit;
}
elseif (!method_exists($chat, $method='lc_'.$_POST['action'])) $method='lc_main';
call_user_func(array($chat, $method));

