Location: PHPKode > projects > Aerial chat > xframe.php
<?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");

require "./connect.inc.php";
require "./content.".$language.".php";

$timeout=180;
$display_at_start=18;

if (isset($_POST['LOGIN'])) {$LOGIN=$_POST['LOGIN'];} else {$LOGIN="";}
if (isset($_POST['PASSWORD'])){$PASSWORD=crypt($_POST['PASSWORD'],$LOGIN);} else {$PASSWORD="";}
if (isset($_GET['LOGIN'])){$LOGIN=$_GET['LOGIN'];}
if (isset($_GET['from'])) {$from=$_GET['from'];} else {$from="";}
if (isset($_SERVER['REMOTE_ADDR'])) {$IPMASQUERADE=$_SERVER['REMOTE_ADDR'];} else {$IPMASQUERADE="";}
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {$IPLOCAL=$_SERVER['HTTP_X_FORWARDED_FOR'];} else {$IPLOCAL="";}
if (isset($_SERVER['HTTP_USER_AGENT'])) {$browser=$_SERVER['HTTP_USER_AGENT'];} else {$browser="";}

$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 ("$LOGIN / $from $t_45");}

if ($from=="mateur") {
$sql_1 = <<<EOT
INSERT INTO `ae_users`
(`id`, `login_name`, `connected`, `last_refresh`, `color`,`refresh_time`,`password`, `email`,`private_msg`)
VALUES ('', '$LOGIN', '1', UNIX_TIMESTAMP(),'000000','10','BADABOUILLE','mateur','Bienvenue sur Aerial chat !');
EOT;
$sql_h_1 = mysql_query($sql_1) or die ("$t_46");
$PASSWORD="BADABOUILLE";
}


$sql_7="SELECT id,password,color,refresh_time,login_name,channel 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,$t_channel) = 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;
                $channel=$t_channel;
                }

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

if ($PASSWORD == $password) {

        $sql_10="SELECT id,last_refresh,login_name,UNIX_TIMESTAMP() from ae_users where ((connected='1' or connected='2') or (login_name like 'MATEUR%')) 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");

                if (strstr($t_login_name,"MATEUR")) {
                        $sql_404="delete from ae_users where `login_name`='$t_login_name';";
                        $sql_h_404 = mysql_query($sql_404) or die ("Could not execute request ! err code : $sql_404");
                        }

                 }

     }


        $sql_10="OPTIMIZE TABLE `ae_users`";
        $sql_h_10 = mysql_query($sql_10) or die ("Could not execute request ! err code : $sql_10");

        $sql_10="OPTIMIZE TABLE $channel;";
        $sql_h_10 = mysql_query($sql_10) or die ("Could not execute request ! err code : $sql_10");


        $sql_10="SELECT max(msg_id) from $channel;";
        $sql_h_10 = mysql_query($sql_10) or die ("Could not execute request ! err code : $sql_10");
        while(list($t_msg_id) = mysql_fetch_row($sql_h_10)) {$max_msg_id=$t_msg_id-$display_at_start;}


$sql_7 = "UPDATE `ae_users` SET `news_id`=1, `last_msg_id` = $max_msg_id, `last_refresh` = UNIX_TIMESTAMP(), `connected` = 1,`ip` = '$IPMASQUERADE#$IPLOCAL',`browser` = 'X|$browser'  WHERE `id` = '$id';";
$sql_h_7 = mysql_query($sql_7) or die ("Could not execute request ! err code : $sql_7");

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

$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];
if ($from=="mateur") {
print <<<EOT
<HEAD>
<TITLE>Aerial Chat</TITLE>
</HEAD>

<frameset rows="*">
    <frame src="./xtopmateur.php?id=$id&REFRESH=$refresh_time"  name= "haut" frameborder="0" >
    <noframes>
        <body bgcolor="#FF0000">
            Your browser needs frames
        </body>
    </noframes>

</frameset>


EOT;
}




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

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

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

</frameset>


EOT;
}

else {
        print "$t_48 $LOGIN<br>";
        }

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

function msg_dw ($MSG_DW,$channel) {
$sql_1=<<<EOT
INSERT INTO `$channel` (`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