Location: PHPKode > projects > Aerial chat > frame.php
<?php
require "./connect.inc.php";


header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

$timeout=180;

$LOGIN=$_POST['LOGIN'];
$PASSWORD=$_POST['PASSWORD'];
$ip=$_SERVER['REMOTE_ADDR'];
$ip=$ip."#".$_SERVER['HTTP_X_FORWARDED_FOR'];
$browser=$_SERVER['HTTP_USER_AGENT'];

$sql_101="SELECT ip from ae_ban";
$sql_h_101 = mysql_query($sql_101) or die ("Could not execute request ! err code : $sql_101");
while(list($t_ip) = mysql_fetch_row($sql_h_101)) {
if ($t_ip==$_SERVER['REMOTE_ADDR']) {die ("You are not welcome anymore !");}
}

if (!$LOGIN) {
	die ("You must have a login");
	}


$PASSWORD=crypt($_POST['PASSWORD'],$LOGIN);

$sql_7="SELECT id,password,color,refresh_time,login_name from ae_users where login_name='$LOGIN'";
        $sql_h_7 = mysql_query($sql_7) or die ("Could not execute request ! err code : $sql_7");
        while(list($t_id,$t_password,$t_color,$t_refresh_time,$t_login_name) = mysql_fetch_row($sql_h_7)) {
                $id=$t_id;
                $password=$t_password;
                $color=$t_color;
                $refresh_time=$t_refresh_time;
                $login_name=$t_login_name;
                }


if (!$id) {$link=mysql_close($link) or die("Could not disconnect");die ("Unknown user !!!");}


if ($PASSWORD == $password) {




//########## Contrôle sur les connections actives de tout le monde ##########
$sql_10="SELECT id,last_refresh,login_name,UNIX_TIMESTAMP() from ae_users where (connected='1' or connected='2') group by login_name;";
        $sql_h_10 = mysql_query($sql_10) or die ("Could not execute request ! err code : $sql_10");
        while(list($t_id,$t_last_refresh,$t_login_name,$now) = mysql_fetch_row($sql_h_10)) {
        if (($now - $t_last_refresh) > $timeout) {
              $disconnected_user=$t_login_name;
              $sql_12="UPDATE `ae_users` SET `connected` = '0' WHERE `id` = '$t_id';";
              $sql_h_12 = mysql_query($sql_12) or die ("SQL[12] Could not execute request ! err code : $sql_12");

//########## On prévient les autres de la déconnexion de l'utilisateur déconnecté de force ##########
              msg_dw("<B>I kicked $disconnected_user [timeout]</B>");
              }
        }


//########## On n'authorise de passer la connection à 1 que par ici ... ################
//########## On met à jour la table users avec les infos de connection active ##########
$sql_7 = "UPDATE `ae_users` SET `last_msg_id` = 0,`last_refresh` = UNIX_TIMESTAMP(), `connected` = 1,`ip` = '$ip',`browser` = '$browser'  WHERE `id` = '$id';";
$sql_h_7 = mysql_query($sql_7) or die ("Could not execute request ! err code : $sql_7");


//########## On prévient les autres de notre arrivée sur le chat ##########
msg_dw("$login_name just came in");


$sql_798 = "UPDATE `ae_users` SET `newsound` = 'welcome'";
$sql_h_798 = mysql_query($sql_798) or die ("Could not execute request ! err code : $sql_798");










$color_name=$color_name[$color];


print <<<EOT
<HEAD>
<TITLE>Aerial Chat</TITLE>
</HEAD>


<frameset rows="*,30">
    <frame src="./top.php?id=$id&COLOR=$color&REFRESH=$refresh_time" name=xtop frameborder="0" >
    <frame src="./bottom.php?id=$id&COLOR=$color&REFRESH=$refresh_time"  frameborder="0" scrollbar=0>


    <noframes>
        <body bgcolor="#FF0000">
            Votre navigateur ne gère pas les frames ...
        </body>
    </noframes>


</frameset>




EOT;
}


else {
        print "Echec de l'authentification pour $LOGIN ...<br>";
        }


//########## Fermeture de la connection #########
$link=mysql_close($link) or die("Could not disconnect");

function msg_dw ($MSG_DW) {
$sql_1=<<<EOT
INSERT INTO `ae_la_plage` (`id`, `msg`, `msg_timestamp`, `msg_time`, `msg_color`,`msg_odd`,`userinfo`)
VALUES ('1', '<B>$MSG_DW</B>', UNIX_TIMESTAMP(), NOW(), 'FF0000','0','Admin');
EOT;
$sql_h_1 = mysql_query($sql_1) or die ("Could not execute request ! err code : $sql_1");
         }

?>
Return current item: Aerial chat