when you login to a room with this chat script I made it always gives a blank page!
also in javascrip how can i refrech the iframe used in the chat to desplay the room
all error fixes are welcome…
and needed even if minor
and i thank all the people that help me in advance
working script: [url]http://www.inixos.net/chat.php
[code=php]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<?php
function file_open($file, $type, $value = “”){
if(!file_exists($file) && $type == “a”)
{$type = “w”;}
$fh = @fopen($file, $type);
if($value != “”){
@fwrite($fh, $value);
}
if($type != ‘w’ && $type != ‘a’){
return @fread($fh, @filesize($file));
}
@fclose ($fh);
}
$act=$_POST[‘act’];
$room=$_POST[‘room’];
$name=$_POST[‘name’];
$msg=$_POST[‘text’];
$rroom=$_GET[‘room’];
$ract=$_GET[‘act’];
?>
<html>
<head>
<title>Untitled</title>
<style type=”text/css”>
<!–
.button {
background:green;
color:lime;
border:1px solid lime;
}
.text {
border:1px solid lime;
background:white;
}
.sbtn {
background:green;
color:lime;
border:0;
}
.stxt {
border:0;
}
<? if($act!=”room”) { ?>
BODY {
background:darkcyan;
color:white;
}
<? } ?>
–>
</style>
</head>
<body>
<code>
<center>
<?
if($name==”” && $ract!=”room”) {
$act=”name”;
}
if($act==””) {
$act=”name”;
}
if($act==”logout”) {
logout();
}
if($act==”name”) {
name();
}
if($act==”joinc”) {
joinc();
}
if($act==”send”) {
send();
}
if($act==”chat”) {
chat();
}
function logout() {
file_open(“all_chat.txt”,”w”,$name.” Left the “.$room.” Room<BR>n”.file_open($room.”_chat.txt”, ‘r’));
file_open($room.”_chat.txt”,”w”,$name.” Left the Room<BR>n”.file_open($room.”_chat.txt”, ‘r’));
file_open(“act_chat.txt”,”w”,”The Room “.$room.” Was Activated (by “.$name.” Leaving The Chat)<BR>n”.file_open(“act_chat.txt”, ‘r’));
$act=”name”;
}
function name() {
?>
<form action=”<? echo($PHP_SELF); ?>” method=”post”>
<input type=”hidden” name=”act” value=”joinc”>
Nick Name:<input type=”text” name=”name” class=”text”><BR>
Room Name:<input type=”text” name=”room” class=”text”><BR>
<input type=”submit” value=”Join Room” class=”button”><input type=”reset” value=”Clear” class=”button”>
</form>
<?
}
function joinc() {
file_open(“all_chat.txt”,”w”,$name.” Joined the “.$room.” Room<BR>n”.file_open($room.”_chat.txt”, ‘r’));
file_open($room.”_chat.txt”,”w”,$name.” Joined the Room<BR>n”.file_open($room.”_chat.txt”, ‘r’));
file_open(“act_chat.txt”,”w”,”The Room “.$room.” Was Activated (by “.$name.” Joining The Chat)<BR>n”.file_open(“act_chat.txt”, ‘r’));
$act=”chat”;
}
function send() {
if($msg!=””) {
file_open($room.”_chat.txt”,”w”,$name.” says: “.$msg.”<BR>n”.file_open($room.”_chat.txt”, ‘r’));
file_open(“all_chat.txt”,”w”,$name.” says in “.$room.”: “.$msg.”<BR>n”.file_open(“all_chat.txt”, ‘r’));
file_open(“act_chat.txt”,”w”,”The Room “.$room.” Was Activated (By “.$name.” Saying “.$msg.”)<BR>n”.file_open(“act_chat.txt”, ‘r’));
$msg=”;
}
$act=”chat”;
}
function del() {
file_open(“act_chat.txt”,”w”,”The Room “.$room.” Was Activated (By “.$name.” Clearing The Room)<BR>n”.file_open(“act_chat.txt”, ‘r’));
file_open($room.”_chat.txt”,”w”,””);
}
function chat() {
file_open(“act_chat.txt”,”w”,”The Room “.$room.” Was Activated (by “.$name.” Viewing The Chat)<BR>n”.file_open(“act_chat.txt”, ‘r’));
?>
<span style=”text”><iframe src=”<? echo($room); ?>_chat.txt” width=”100%” height=”90%” marginwidth=”0″ marginheight=”0″ frameborder=”0″ vspace=”0″ hspace=”0″></iframe></span><BR>
<form name=”chat” action=”<? echo($PHP_SELF); ?>” method=”post”>
<input type=”hidden” value=”send” name=”act”>
<input type=”hidden” value=”<? echo($name); ?>” name=”name”>
<input type=”hidden” value=”<? echo($room); ?>” name=”room”>
<? if($room!=”all” && $room!=”act”) { ?>
<span class=”text”><input name=”text” type=”text” size=”74″ value=”<? echo($msg); ?>” class=”stxt”>
<input type=”submit” value=”SEND !” class=”sbtn”></span><span class=”text”><button onclick=”this.form.act.value=’logout’;this.form.submit();” class=”sbtn”>Logout</button></span>
<input type=”hidden” value=”chat” name=”act”>
<input type=”hidden” value=”<? echo($room); ?>” name=”room”>
<input type=”hidden” value=”<? echo($name); ?>” name=”name”>
<? } else {?>
<button onclick=”this.form.act.value=’del’;this.form.submit()” class=”button”>Delete The Contents Of This Room</button>
<button onclick=”this.form.act.value=’logout’;this.form.submit();” class=”button”>Logout</button>
<? } ?>
</form>
<?
}
?>
</center>
</body>
</html>