Chat-Box

<?php


function getChatterList($running_mode, $room_name, $primary_server_host,$chat_data_path) {

    if ($running_mode == 1) {       
        return chat_getChatterListFromLocalServer ( chat_checkSlash($chat_data_path) );
    } else if ($running_mode == 2) {
        return chat_getChatterListFromExtendServer ( $primary_server_host );
    } else if ($running_mode == 0) {
        return chat_getChatterListFromFreeServer ( 'http://free.123flashchat.com/', $room_name );
    }

}

function getChatters($running_mode, $room_name, $primary_server_host,$chat_data_path) {


    if ($running_mode == 1) {
       
        return chat_getChattersFromLocalServer ( chat_checkSlash($chat_data_path) );
    } else if ($running_mode == 2) {
        return chat_getChattersFromExtendServer ( $primary_server_host );
    } else if ($running_mode == 0) {
        return chat_getChattersFromFreeServer ( 'http://free.123flashchat.com/', $room_name );
    }

}

function show_flash_chat($running_mode, $room_name, $primary_server_host,$chat_data_path,$width,$height,$show_mode) {

       
    switch($running_mode)
    {
        case '0':
            chat_free($room_name,$show_mode);
            break;
        case '1':
        case '2':
            show_chat($running_mode, $primary_server_host,$width,$height,$show_mode);
            break;

        default:
             echo '<script>window.location.href("index.php");</script>';
             exit;break;
    }


}




//////////////////////////////////////////show chat room infomation/////////////////////////////////////

function chat_getChatterListFromFreeServer($free_server_path, $roomname) {
    if ($roomname == '')
        $roomname = $_SERVER ['HTTP_HOST'];
    $userListStr = "<script lanauge=javascript src='" . $free_server_path . "freeroomuser.php?roomname=" . rawurlencode ( $roomname ) . "'></script>";
    return $userListStr;
}

function chat_getChattersFromFreeServer($free_server_path, $roomname) {
    $room = array ();
    if ($roomname == '')
        $roomname = $_SERVER ['HTTP_HOST'];
    $room ['logon_users'] = "<script lanauge=javascript src='" . $free_server_path . "freeroomnum.php?roomname=" . rawurlencode ( $roomname ) . "'></script>";
    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'] = "<script lanauge=javascript src='" . $primary_server_host . "connections.php'></script>";
    $room ['logon_users'] = "<script lanauge=javascript src='" . $primary_server_host . "logon_users.php'></script>";
    $room ['room_numbers'] = "<script lanauge=javascript src='" . $primary_server_host . "room_numbers.php'></script>";
   
    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 = "<script lanauge=javascript src='" . $primary_server_host . "user_list.php'></script>";
    $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 '<!-- FROM 123FLASHCHAT CODE BEGIN -->
    <div style="width:728px;height:500px; margin:0 auto;">
    <iframe name="chatloader" id="chatloader" scrolling="no" src="http://free.123flashchat.com/freechat.php?room='.rawurlencode($room_name).'&width=728&height=550" width="728" height="550" border="0" marginWidth=0 marginHeight=0 frameborder="no" framespacing="0"></iframe>
    </div>
    <!-- 123FLASHCHAT CHAT ROOM CODE END -->';
    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 '<!-- FROM 123FLASHCHAT CODE BEGIN --><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'.$width.'" height="'.$height.'">';
        echo '<param name=movie value="'.$swfurl.'">';
        echo '<param name=quality value=high>' ;
        echo '<param name=menu value=false>';
        echo '<param name=scale value=noscale>';
        echo '<param name="allowScriptAccess" value="always" />';
        echo '<embed src="'.$swfurl.'" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'.$width.'" height="'.$height.'" menu="false" scale="noscale" allowScriptAccess="always">';
        echo '</embed>';
        echo '</object><!-- 123FLASHCHAT CHAT ROOM CODE END -->';
        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 '<html>';
        echo '<head>';
        echo '<title>Chat Room - Powered by 123FlashChat</title>';
        echo '</head>';
        if($running_mode=='free')
        echo '<link rel="stylesheet" type="text/css" media="screen" href="http://www.123flashchat.com/stylesheet22.css" />';
        echo '<body topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no">';
}

function pagefooter()
{
        echo '</body>';
        echo '</html>';
}


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;
}
?>

Créer un site internet gratuit avec E-monsite.com - Signaler un contenu illicite - Voir d'autres sites dans la catégorie Communauté Virtuelle
Créer un forum - Videos Droles - Clips musique - Cours création de site web