[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 ')
{