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

Размер файла: 1.31Kb
<?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'))
		{
		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_SECTION_1."'>$section</div>";
			}
		}
		else
		{
		echo "<div class='".DIV_SECTION_1."'>$content</div>";
		}
	}
}