[Share] "Magic mirror Online" an online random chat site source code, how to deal with

Source: Internet
Author: User
[Share] "Magic mirror Online" an online random chat site source
The program uses Php+mysql,jquery to implement AJAX, page layout with the Div+css, and has a VB written by the client program.

Original Demo Address: http://ask.n9sky.com/MagicMirror/(cannot be accessed now)

Now post some of the code:

server.php main operations are handled in this file
PHP Code
 
$do = @$_get[' do ');
if ("' = = $do)
{
Exit (' Missing Action ');
}
Require ' config.php ';
Require ' dll.php ';
Session_Start ();
Check session
if (' = = $_session[' sid ']) exit (' login timeout, please close retry! ');
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_to ', ');
$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_to ', ');
$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 ' answer ':
$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_to ', ');
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 ')
{
  • Related Article

    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.