ahmad_511, on 10 Sep, 2009 - 11:34 AM, said:
sorry for late, but you know... life and work
@Glorfindal, try to use explode() function instead of split()
@axisofevil, the link you provided is broken, please check. you can use your web site file manager to give the necessary permissions
@AjusJudy, to add multiple chat rooms please follow these steps:
index.html
directly under the sign in form tag:
Add a select control (name="room",id="selRoom")
append room options(two for example) into the select and give them differnt values("fun","health")
<form onsubmit="signInOut();return false" id="signInForm">
<select id="selRoom" name="room">
<option value="fun">Fun</option>
<option value="health">Health</option>
</select>
<input id="userName" type="text">
<input id="signInButt" name="signIn" type="submit" value="Sign in">
<span id="signInName">User name</span>
</form>chatbox.js
hideShow() function / if(hs=="hide"){} block:
Add
signInForm.selRoom.style.display="block"
hideShow() function / if(hs=="show"){} block:
Add
signInForm.selRoom.style.display="none"
Modify
signInName.innerHTML=signInForm.selRoom.options[signInForm.selRoom.selectedIndex].innerHTML+" / " + signInForm.userName.value
signInOut() function / if (signInForm.signInButt.name=="signIn"){} block
Modify
var data="user=" + signInForm.userName.value +"&room="+signInForm.selRoom.value+"&oper=signin";
signInOut() function / if (signInForm.signInButt.name=="signOut"){} block
Modify
var data="user=" + signInForm.userName.value +"&room="+signInForm.selRoom.value+"&oper=signout";
checkSignOut() function / if(res=="signout"){} block
Add
lastReceived=0; chatBox.innerHTML=""; usersOnLine.innerHTML="";
updateInfo() function
Modify
Ajax_Send("POST","users.php","room="+signInForm.selRoom.value,showUsers)
Ajax_Send("POST","receive.php","lastreceived="+lastReceived+"&room="+signInForm.selRoom.value,showMessages)
sendMessage() function
Modify
var data="message="+messageForm.message.value+"&user="+signInForm.userName.value+"&room="+signInForm.selRoom.value;
users.php
saveUsers() function
Modify
$file_save=fopen("onlineusers_".$_POST['room'].".txt","w+");
First line after the end of the function
Modify
$onlineusers_file=file("onlineusers_".$_POST['room'].".txt",FILE_IGNORE_NEW_LINES);
send.php
Add
$room="room_".$_POST['room'].".txt";
Modify
$room_file=file($room,FILE_IGNORE_NEW_LINES);
$file_save=fopen($room,"w+");
receive.php
Add
$room="room_".$_POST['room'].".txt";
Modify
$room_file=file($room,FILE_IGNORE_NEW_LINES);
Finally:
Add the following files to your chatbox folder and give them write/read permissions
room_fun.txt, room_health.txt
onlineusers_fun.txt, onlineusers_health.txt
Note: you have to add a text file (room_VALUE.txt)for each option value in the room select control, (VALUE is the option's value)
you can download the updated files here
hope it helps
Quote
it worked great thanks for the script and sparing your little time.
another Qn, ....how can we use a database to store our users, make them login with a password, restrict them from using a room where they dont belong and finally give them a timeout; ie one can use a room for one hour then time out until next day, or how to put a room on and off at specific times. thanks alot.








MultiQuote





|