I used to find... online staff Library // add users
Function AddUser ($ username ){
Global $ db;
$ Ip = getenv ('remote _ ADDR ');
$ Ip1 = getenv ('http _ X_FORWARDED_FOR ');
If ($ Ip1! = "") & ($ Ip1! = "Unknown") $ Ip = $ Ip1;
$ Current_time = date ("Y-m-d H: I: s ");
$ SQL = "select user from class_online where user = '$ username '";
$ Res = mysql_query ($ SQL, $ db );
$ Row = @ mysql_num_rows ($ res );
If ($ row = 0 ){
$ SQL = "insert into class_online (user, ip, lasttime) values ('$ username',' $ IP', '$ current_time ')";
Mysql_query ($ SQL, $ db );
}
}
// Update the online user name list
Function UpdateMember (){
Global $ db;
$ SQL = "delete from class_online where UNIX_TIMESTAMP ()-UNIX_TIMESTAMP (lasttime)> 180"; // exit if you are not active for 3 minutes
// Echo $ SQL;
Mysql_query ($ SQL, $ db );
}
// Update the online status
Function UpdateOnline ($ username ){
Global $ db;
$ Current_time = date ("Y-m-d H: I: s ");;
$ SQL = "update class_online set lasttime = '$ current_time' where user = '$ username '";
$ Res = mysql_query ($ SQL, $ db );
}
// Delete a user
Function OutOneUser ($ user ){
Global $ db;
$ SQL = "delete from class_online where user = '$ user '";
Mysql_query ($ SQL, $ db );
Return true;
}
// Check whether it is online
Function CheckUser ($ user ){
Global $ db;
$ SQL = "select user from class_online where user = '$ user '";
$ Res = mysql_query ($ SQL, $ db );
$ Row = mysql_num_rows ($ res );
If ($ row> 0) return true;
Else return false;
}
// Obtain the online list
Function ReadOnlineName (){
Global $ db;
$ SQL = "select * from class_online ";
$ Res = mysql_query ($ SQL, $ db );
While ($ row = mysql_fetch_array ($ res )){
$ Result [] = $ row [user];
}
Return $ result;
}
*************** End
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.