[Share] how to deal with the source code of an online random chat website in Magic Mirror Online

Source: Internet
Author: User
[Share] Magic Mirror Online: An online random chat website source code program uses PHP + MySQL, jQuery to implement Ajax, DIV + CSS for page layout, and a client program written in VB. Original Demo address: http://ask.n9sky.com/MagicMirror/ (now can not access [share] "Magic Mirror Online" an online random chat site source code
The program uses PHP + MySQL, jQuery to implement Ajax, DIV + CSS for page layout, and a client program written in VB.

Original Demo address: http://ask.n9sky.com/MagicMirror/ (not accessible now)

Now some code is pasted:

The main operations of server. php are handled in this file.
PHP code
 
$ Do = @ $ _ GET ['do '];
If (''= $ do)
{
Exit ('missing action ');
}
Require 'config. php ';
Require 'dll. php ';
Session_start ();
// Check the session
If (''= $ _ SESSION ['Sid ']) exit ('logon timeout. Please close and try again! ');
Switch ($ do)
{
Case 'init ':
// Check user & update
Dll: import ('mysql ');
$ Db = new mysql ();
$ Db-> connect ($ dbs ['server'], $ dbs ['user'], $ dbs ['password']);
$ Db-> database ($ dbs ['database']);
// Update
$ Rs = $ db-> update (DBPrefix. 'user', 'Sid = "'. $ _ SESSION ['Sid'].'" ');
$ Rs-> set ('Client _ ','');
$ Rs-> set ('role', RoleOnline );
$ Rs-> set ('last _ access_time ', time ());
$ Rs-> setfunc ('login _ count', 'login _ count + 1 ');
$ Rs-> set ('last _ login_time ', time ());
$ Ip = $ _ SERVER ['remote _ ADDR '];
$ Ipx = explode ('.', $ ip );
$ Iplong =
$ Ipx [0] * 16777216 +
$ Ipx [1] * 65536 +
$ Ipx [2] * 256 +
$ Ipx [3];
$ Rs-> set ('last _ login_ip ', $ iplong );
If (! $ Rs-> update ())
{
// Add new
$ Rs = $ db-> insert (DBPrefix. 'user ');
$ Rs-> set ('Sid ', $ _ SESSION ['Sid']);
$ Rs-> set ('Client _ ','');
$ Rs-> set ('role', RoleOnline );
$ Rs-> set ('last _ access_time ', time ());
$ Rs-> set ('login _ count', 1 );
$ Rs-> set ('last _ login_time ', time ());
$ Rs-> set ('last _ login_ip ', $ iplong );
$ Rs-> insert ();
}
$ Db-> close ();
// Display init page
Display('init.html ');
Break;
Case 'status ':
Dll: import ('mysql ');
// Access $ dbs
Global $ dbs;
$ Db = new mysql ();
$ Db-> connect ($ dbs ['server'], $ dbs ['user'], $ dbs ['password']);
$ Db-> database ($ dbs ['database']);
// Update access
Update_access ($ db );
// Import mysql. class
Display('server.status.html ');
$ Db-> close ();
Break;
Case 'work ':
$ Mode = $ _ GET ['mode'];
// Update work mode
Dll: import ('mysql ');
$ Db = new mysql ();
$ Db-> connect ($ dbs ['server'], $ dbs ['user'], $ dbs ['password']);
$ Db-> database ($ dbs ['database']);
// Update
$ Rs = $ db-> update (DBPrefix. 'user', 'Sid = "'. $ _ SESSION ['Sid'].'" ');
Switch ($ mode)
{
Case 'ancer ':
$ Rs-> set ('role', RoleAnswer );
Break;
Case 'asker ':
$ Rs-> set ('role', RoleAsker );
Break;
Case 'chater ':
$ Rs-> set ('role', RoleChater );
Break;
Case 'offline ':
$ Rs-> set ('role', RoleOffline );
$ Rs-> set ('Client _ ','');
// Delete input status cache
@ Unlink (dirname ('.'). '/cache/'. $ _ SESSION ['Sid '].'. input. status ');
// Clear session
Unset ($ _ SESSION );
Break;
}
$ Rs-> set ('last _ access_time ', time ());
$ Rs-> update ();
$ Db-> close ();
// Display mode page
If ($ mode! = 'Offline ')
{

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.