Просмотр файла gchat/inc/server.class.php

Размер файла: 1.44Kb
<?php

class gserver
{
var $url;
var $page;
function __construct ()
	{
	global $chat, $cms, $cache;
	$this->url = "http://globalscripts.ru/gchat/?site=$_SERVER[SERVER_NAME]".(defined ('USER_ID') && defined ('USER_NICK')?'&user_id='.USER_ID.'&user_nick='.USER_NICK.'&user_sex='.USER_SEX:null).(defined ('USER_ADMIN')?'&user_admin=1':null).(!empty ($chat->room)?'&room='.$chat->room.'&page='.$chat->page:null).'&cms='.$cms.($cache->cacheExists ()?null:'&get_content=1');
	}
	
function getContent ($params = null)
	{
	$url = $this->url;
	if ($params)
		$url .= '&'.$params; 
	$curl = curl_init ($url);
	curl_setopt  ($curl, CURLOPT_HEADER, false);
	curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt ($curl, CURLOPT_TIMEOUT, 1);
	if (isset ($_POST['send']) && !empty ($_POST['msg']) && defined ('USER_ID'))
		{
		if (!empty ($_POST['answer'])) /* Вставляем ответ */
			$_POST['msg'] = '[b]'.$_POST['answer'].'[/b], '.$_POST['msg'];
		curl_setopt ($curl, CURLOPT_POST, true);
		curl_setopt ($curl, CURLOPT_POSTFIELDS, "msg=$_POST[msg]");
		}
	$result = curl_exec ($curl);
	curl_close ($curl);
	return $result;
	}
	
function readContent ($content = null)
	{
	if (empty ($content))
		return null;
	if (is_array ($content))
		{
		foreach ($content AS $section)
			{
			echo "<div class='".DIV_NAVIGATION."'>$section</div>";
			}
		}
		else
		{
		echo "<div class='".DIV_NAVIGATION."'>$content</div>";
		}
	}
}