jeffman Posted May 16, 2008 Share Posted May 16, 2008 EDIT: I removed the links.Put these in a folder with write permission. Remove the .txt extensions. Load chat.html into a bunch of different browsers and have a party. Let me know if something breaks.As before, you'll need to adapt it to your own purposes.And let me know when you've downloaded them so I can remove the links. Link to comment Share on other sites More sharing options...
TehBlizzy Posted May 17, 2008 Author Share Posted May 17, 2008 Niiiiiiiiiiice! Thanks a crap load :)It'll take me a while to adapt it but it will be worth it Link to comment Share on other sites More sharing options...
TehBlizzy Posted May 17, 2008 Author Share Posted May 17, 2008 I've uploaded it and modified what I needed, but the username box will be hidden and it's value will be the session name and I got that to appear, but the alert error "Sorry: 302" keeps appearing. Wth? >> Link to comment Share on other sites More sharing options...
TehBlizzy Posted May 17, 2008 Author Share Posted May 17, 2008 ... Fixed it. I forgot I renamed the chat.php to chat_red.php in the file. Its all fixed now Link to comment Share on other sites More sharing options...
TehBlizzy Posted May 17, 2008 Author Share Posted May 17, 2008 I was chatting with one of my friends when I realized the messages would glitch up in different ways. It's best you see yourself.http://randomchatroom.zxq.net/index.phpUsername: testPassword: testRoom: Red Room Link to comment Share on other sites More sharing options...
TehBlizzy Posted May 17, 2008 Author Share Posted May 17, 2008 Thanks to and because of Synook, for being the lil devil he is, I added the strip_tags cmd to the posting script. I just gotta fix the est of the bugs Link to comment Share on other sites More sharing options...
Synook Posted May 17, 2008 Share Posted May 17, 2008 Don't forget htmlspecialchars() as well! Link to comment Share on other sites More sharing options...
TehBlizzy Posted May 17, 2008 Author Share Posted May 17, 2008 lol I didn't feel like editing my last one, I changed it to htmlentities() Link to comment Share on other sites More sharing options...
jeffman Posted May 17, 2008 Share Posted May 17, 2008 I see it's up, that's great. You'll want a faster server in the future, but it'll keep.Before you open it up to the public, you'll want to take other security meaures into mind. The big one is upload size. Someone could easily download the html page, change it around, and upload 100K every time they hit enter. In a minute, you'd hit your file quota. So you'll want to reject anything over a certain size. Link to comment Share on other sites More sharing options...
TehBlizzy Posted May 21, 2008 Author Share Posted May 21, 2008 I completely jumped ahead by modifying my whole chatroom code twice, and I got lost... so I deleted everything.This is basically my new chatroom code and it comes up with no error, but the page refreshes. Why? >> <?phpsession_start();?><html><head><title>Random Chatroom - Room One </title><link href='http://randomchatroom.zxq.net/css/red.css' rel='stylesheet' type='text/css'></head><script type="text/javascript"> var hObj; //must be global function hPostData() { var myData = document.getElementById("message").value; hObj = null; var myURL = "scripts/post_message.php"; if (hObj = getHObject()){ hObj.onreadystatechange = hStateChanged; hObj.open ('POST', myURL, true); hObj.setRequestHeader("Content-Type", "text/plain;charset=UTF-8"); hObj.send (myData); }else {alert ("Cannot get an HTTP object");} } function hStateChanged() { if (hObj.readyState == 4) { if (hObj.status == 200) { printResponse(hObj.responseText); }else{ alert ('Sorry: ' + hObj.status); } } } function getHObject() { var hObj = null; try {hObj = new XMLHttpRequest();} catch (e) { try {hObj = new ActiveXObject('Msxml2.XMLHTTP');} catch (e) {hObj = new ActiveXObject('Microsoft.XMLHTTP');} } return hObj; } function printResponse(myText) { var messages = document.getElementById('messages'); messages.innerHTML = myText; }</script><body><center><table border="1" width="800" height="600"><tr><td colspan="2" height="100"><center><h1>Random Chatroom - Room One</h1></td></tr><tr><td height="400" width="600"><div id="messages">messages go here</div></td><td><div id="current_users">user list goes here</div></td></tr><tr><td><div align="center"><form method="POST"><input type="text" value="<?php echo($_SESSION[myusername]); ?>" id="username"><input type="text" size="32" id="message">Â Â Â <input type="submit" onClick="hPostData()" value="Send!"></td></tr></table></body></html> This is my post_message.php: <?phpsession_start();$username = $_SESSION['myusername'];$message = $_POST['message'];$fp = fopen('messages/room_one.txt, 'a');fwrite($fp, '$username : $message');fclose($fp)?> I kinda deleted everything without saving the important code(s).. :S Link to comment Share on other sites More sharing options...
jeffman Posted May 21, 2008 Share Posted May 21, 2008 You need an onsubmit handler in your form tag, not your submit button, and it should return false after it calls its function. Thus: onsubmit="doSomething(); return false"; The reason you're refreshing is that you don't have an action specified in your form tag, and refreshing the page is the default action. Not widely known, but true. Link to comment Share on other sites More sharing options...
TehBlizzy Posted May 22, 2008 Author Share Posted May 22, 2008 Lmao. >_>I guesss I did delete too much. -Edit...Nevermind, they are back up Link to comment Share on other sites More sharing options...
TehBlizzy Posted June 1, 2008 Author Share Posted June 1, 2008 I've started messing with it again.. changed a bit of it... and its not doing anything...? I even added alert("TESTING!"); to very first line of the sendMessage() function and it didn't do anything??? What did I do wrong? <?phpsession_start();?><html><head><title>Random Chatroom - Room One </title><link href='http://randomchatroom.zxq.net/css/red.css' rel='stylesheet' type='text/css'></head><script type="text/javascript">function sendMessage() {var xmlHttp;try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); }catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { alert("Your browser does not support AJAX!"); return false; } } } var message = document.getElementById("message").value; xmlHttp.open('POST', scripts/post_message.php, true); xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlHttp.setRequestHeader("Content-length", parameters.length); xmlHttp.setRequestHeader("Connection", "close"); xmlHttp.send(message);}</script><body><center><table border="1" width="800" height="600"><tr><td colspan="2" height="100"><center><h1>Random Chatroom - Room One</h1></td></tr><tr><td height="400" width="600"><div id="messages">messages go here</div></td><td><div id="current_users">user list goes here</div></td></tr><tr><td><div align="center"><form method="POST" onSubmit="postMessage();return false;" action=""><input type="text" value="<?php echo($_SESSION[myusername]); ?>" id="username"><input type="text" size="32" id="message">Â Â Â <input type="submit" value="Send!"></td></tr></table></body></html> Link to comment Share on other sites More sharing options...
TehBlizzy Posted June 2, 2008 Author Share Posted June 2, 2008 Respond.. :)If anyone reads this, please go to http://randomchatroom.zxq.net/ and login as test//test and tell me if it logs you in and shows your username at the bottom of rooms.php . I think my school has blocked sessions and such from my site. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 3, 2008 Share Posted June 3, 2008 The login doesn't work for me. For Javascript errors, make sure you have Firebug installed to help with debugging. Link to comment Share on other sites More sharing options...
TehBlizzy Posted June 7, 2008 Author Share Posted June 7, 2008 Once I get the sessions to work, I'll check that out. I added an if to check if the session is being set, and it is, but it comes up with an error: Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php5) in Unknown on line 0 I guess that means the server or w/e can't save the session or something? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 17, 2008 Share Posted June 17, 2008 Warning: Unknown: write failed: No space left on device (28) in Unknown on line 0 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.