Click to See Complete Forum and Search --> : Help with code


Jick
04-19-2003, 07:47 PM
Can all you guys take a look at this page and its source and let me know if you find any flaws or improvments. I need to know if its working right so please help! Thank you. :)

http://kd7pyo.infinitypages.com/chatter/chatterbox.html

Thank you. Leave messages if you want to. :D

Jona
04-19-2003, 07:50 PM
Hey, Mike. I don't get any errors, but then again, I dunno if that page works in Netscape. *Glares at Khaki, as if expecting her to go to the page and tell us if she gets any errors* :D

Jick
04-20-2003, 12:16 AM
I changed some stuff and now there is a problem! I added the function to logout by clicking 'Exit' and what its sapposed to do is when you click it, it will automaticly insert a message into the chatroom that says "The user "theirusername" has logged out" and it gets the "theirusername" part from grabbing it from the textbox that says username. It also is sapposed to close that whole window then which will altimatly clear the cookies because its session based cookies. I have the username and font stuff being saved to a session cookie so as long as your in the same browser that info will be saved. But the whole thing isn't working so could someone take a look and see if they find any errors in my script and just ask if you would like me to post the php files that go with it! Thanks for your help! Here is the link:

http://kd7pyo.infinitypages.com/chatter/chatterbox.html

Thanks for the help. :)

Nevermore
04-20-2003, 05:46 AM
Works in Mozilla 5.0, and Netscape Navigator 7, although in NN there seems to be some strange alignement happening, both in the text area, where the text spaces strangely to reach the end of the line, and the text on the buttons and the textboxes goes off the bottom. It doesn't work in Opera 7.03 - the main text area just doesn't show up.
To keep it in line with the HTML 4.01 standards you really should add some META tags and use CSS not FONT tags. I suppose really you shouldn't use a table for positioning, but that is only a guideline.
Having said all of that, I do like the system - it just needs some people to talk to now! :D
I hope it all goes really well.

Nevermore
04-20-2003, 05:50 AM
It seems that the strange alignement is from the way the Gecko rendering engine displays the text. It is moe standards compiant than IE, which renders it properly, so if you stick more closely to the standards, it might repair itself. But then, my page doesn't work properly in IE because I used the stanadards correctly, and IE doesn't.

Nevermore
04-20-2003, 05:54 AM
I'm posting a lot of replies to this post...

Anyhow, I think that you should focus on the input textarea after a post. And where did you get all of those smilies? or did you draw them...

Jick
04-20-2003, 11:42 AM
I fixed it so now it works but if you look when you hit the exit button it succesfully closes the window and then when you go back a view it, it shows ( - has looged out ) like I want exept for the dash part. I want it so it says ( 'username' has logged out ) but I don't know whats wrong here is the logout.php file that tells the chat what to to when they click logout:


<?PHP
$filename="chatter.html";
$fp=file($filename);
$x=0;
$data="";
while($fp[$x]){ $data .= $fp[$x]; $x++; }
if ($data) {
$dataSplit = split("<!--chatter-->",$data);
$msgSplit = split('<hr>',$dataSplit[1]);
if (count($msgSplit) > 20) { $msgSplit = array_pop($msgSplit); }
}
$username = $_POST['hiddenNm'];
$message = "<font face=\"verdana\" color=\"FF0000\" size=\"1\"><i><b>$username HAS LOGGED OUT.</b></i></font>";

if(is_array($msgSplit)){
array_unshift($msgSplit,"\n<b>".$username."</b> - ".$date."<br>".$message."\n");
$dataSplit[1] = join("<hr>",$msgSplit);
}else{
$dataSplit[1] = "<b>".$username."</b> - ".$date."<br>".$message."\n";
}
if (is_writable($filename)) {
if (!$fp = fopen($filename,"w")) { echo "Cannot open file ($filename)"; exit; }
fwrite($fp,$dataSplit[0]."<!--chatter-->");
fwrite($fp,$dataSplit[1]."<!--chatter-->");
fwrite($fp,$dataSplit[2]);
fclose($fp);
} else { echo "The $filename is not writable"; exit; }
exit;
?>


Please help. Thanks. :D

havik
04-20-2003, 12:29 PM
it works good in NS6, but I don't see any " - has logged out" or anything like that so I'm not sure if you took that out or it just won't show up at all in NS6.

Havik

Jick
04-20-2003, 12:49 PM
You have to click the exit button and then it will close the browser and then you have to open a new browser to be able to see the message I'm talking about. :)

Jona
04-20-2003, 01:23 PM
Okay, it says someone has logged out and works. Except for it doesn't show the user's name... Hmmm.... I'll work a little on that JS part there... (Odd that it didn't work.)

Jona
04-20-2003, 01:36 PM
Works... :D

Nevermore
04-20-2003, 01:45 PM
I'm just curious, but how is the information being processed? I can't see any forms that actually submit to anywhere except the excit one. So what is updating the main frame?

Jona
04-20-2003, 01:54 PM
I used JavaScript to do the form process. Most of it is all client side (only 2 PHP scripts, and both are quite short). What the PHP (postform) does:

Checks to see how many messages exist. If 20 or more, clear the file ($filename) chatterbox.html. If not, split data at the comment tag: <!--chatter--> Then it declares variables from the form. Then, it uses str_replace (in Javascript, it'd just be strObj.replace()) to replace all smiley texts (e.g., :-/) into image tags of HTML. (I used Javascript to prevent anyone from actually using HTML in their post.) Then the script writes to the file saying: username - date - [horizontal line tag] - message (before it writes to the file, though, it checks to see if the file exists and/or is writable). Then is adds the header: refresh (so that all machines refresh the page--I think). Then the PHP script is done.

The second PHP script I wrote (taken partially from the first) does the same thing, except for the fact that it doesn't post a message. Rather it displays a message saying that "username has logged out." This form is submitted by Javascript before the window is closed by the button "Exit."

All of the rest is Javascript (that includes the session cookies).

Nevermore
04-20-2003, 01:58 PM
I think there is a slight security problem with the forum. Go have a look. I have manage to use purple text and create a hyperlink. I could put a JavaScript there. I might, but not a nasty one. Just to show you what I could do. HAHAHAHAHA!!! (By the way, I want to help fix it, not damage the system.)

Jona
04-20-2003, 02:10 PM
Can you please tell me how you did it so I can bump up security on it?