window.location.href("index.php");';
exit;break;
}
}
//////////////////////////////////////////show chat room infomation/////////////////////////////////////
function chat_getChatterListFromFreeServer($free_server_path, $roomname) {
if ($roomname == '')
$roomname = $_SERVER ['HTTP_HOST'];
$userListStr = "";
return $userListStr;
}
function chat_getChattersFromFreeServer($free_server_path, $roomname) {
$room = array ();
if ($roomname == '')
$roomname = $_SERVER ['HTTP_HOST'];
$room ['logon_users'] = "";
return $room;
}
function chat_getChattersFromLocalServer($chat_data_path) {
$room = array ();
$room ['connections'] = 0;
$room ['logon_users'] = 0;
$room ['room_numbers'] = 0;
$online_file = $chat_data_path . "online.txt";
if (! file_exists ( $online_file )) {
return $room;
}
if (! $row = file ( $online_file )) {
return $room;
}
$room_data = explode ( "|", $row [0] );
if (count ( $room_data ) == 3) {
$room ['connections'] = intval ( $room_data [0] );
$room ['logon_users'] = intval ( $room_data [1] );
$room ['room_numbers'] = intval ( $room_data [2] );
}
return $room;
}
function chat_getChattersFromExtendServer($primary_server_host) {
$room = array ();
$primary_server_host = chat_checkHTTP($primary_server_host);
$room ['connections'] = "";
$room ['logon_users'] = "";
$room ['room_numbers'] = "";
return $room;
}
function chat_getChatterListFromLocalServer($chat_data_path) {
if(!@dir($chat_data_path))return "chat data path error";
$userListStr = "";
$d = dir ( $chat_data_path );
while ( false !== ($entry = $d->read ()) ) {
$rest = substr ( $entry, 0, 5 );
if ($rest == "room_") {
if (file_exists ( $chat_data_path . $entry )) {
$f_users = file ( $chat_data_path . $entry );
for($i = 0; $i < count ( $f_users ); $i ++) {
$f_line = trim ( $f_users [$i] );
if ($f_line != "") {
$userListStr = ($userListStr == "") ? $f_line : $userListStr . ", " . $f_line;
}
}
}
}
}
$d->close ();
$userListStr = ($userListStr == "") ? "None" : $userListStr;
return $userListStr;
}
function chat_getChatterListFromExtendServer($primary_server_host) {
$primary_server_host = chat_checkHTTP($primary_server_host);
$userListStr = "";
$userListStr = (empty ( $userListStr )) ? "None" : $userListStr;
return $userListStr;
}
//////////////////////////////////////show chat room///////////
function chat_free($room_name)
{
if(empty($room_name))
$room_name = $_SERVER['HTTP_HOST'];
echo pageheader();
echo '
';
echo pagefooter();
}
function show_chat($running_mode,$host_address,$width,$height,$show_mode)
{
// global $swfname,$init_host,$init_port,$init_group;
$client_location = chat_checkSlash($host_address);
if($show_mode == 1){
$swfname = '123flashchat.swf';
}else if($show_mode == 2){
$swfname = 'lite.swf';
}
if($running_mode == 2)
{
$urlinfo = getHostParameters($client_location);
parse_str($urlinfo['query']);
$swfurl = $client_location.$swfname;
if(!empty($init_host)){
$swfurl .= (strpos($swfurl,"?"))?"&init_host=".$init_host:"?init_host=".$init_host;
}
if(!empty($init_port)){
$swfurl .= (strpos($swfurl,"?"))?"&init_port=".$init_port:"?init_port=".$init_port;
}
if(!empty($init_group)){
$swfurl .= (strpos($swfurl,"?"))?"&init_group=".$init_group:"?init_host=".$init_group;
}
}else if($running_mode == 1){
$swfname .= '?init_host='.$_SERVER['HTTP_HOST'];
$swfurl = $client_location.$swfname;
}
echo pageheader();
echo '
';
echo pagefooter();
}
function getHostParameters($client_location)
{
$content = @file_get_contents($client_location);
if(!empty($content))
{
$pattern = '|var urlValue="(.*)"|U';
preg_match($pattern, $content, $matches);
if(!empty($matches[1]))
{
$url = $matches[1];
$urlinfo = parse_url($url);
return $urlinfo;
}
else
{
$pattern = '|PARAM NAME=movie VALUE="(.*)"|U';
preg_match($pattern, $content, $matches);
if(!empty($matches[1]))
{
$url = $matches[1];
$urlinfo = parse_url($url);
return $urlinfo;
}
}
return false;
}
}
function pageheader()
{
global $running_mode;
echo '';
echo '';
echo '
Chat Room - Powered by 123FlashChat';
echo '';
if($running_mode=='free')
echo '
';
echo '';
}
function pagefooter()
{
echo '';
echo '';
}
function chat_checkHTTP($url)
{
if(false === strpos($url,'http://')){
$url = 'http://'.$url;
}
$url = chat_checkSlash($url);
return $url;
}
function chat_checkSlash($path)
{
if(substr($path,-1,1) != "/" && !empty($path)){
$path = $path."/";
}
return $path;
}
?>