[分享] 《魔镜在线》一个在线随机聊天网站源码,该如何处理
[分享] 《魔镜在线》一个在线随机聊天网站源码
程序使用PHP+MySQL,jQuery实现Ajax,页面布局用的DIV+CSS,并有一个VB写的客户端程序。
原演示地址:http://ask.n9sky.com/MagicMirror/ (现在不能访问了)
现在贴出部分代码:
server.php 主要的操作处理都在这个文件
- PHP code
<br> <?php <br /> $do = @$_GET['do']; <br> if ('' == $do) <br> { <br> exit('Missing Action'); <br> } <br> require 'config.php'; <br> require 'dll.php'; <br> session_start(); <br> // check session <br> if ('' == $_SESSION['sid']) exit('登录超时,请关闭重试!'); <br> switch ($do) <br> { <br> case 'init': <br> // check user && update <br> dll::import('mysql'); <br> $db = new mysql(); <br> $db->connect($dbs['server'], $dbs['user'], $dbs['password']); <br> $db->database($dbs['database']); <br> // update <br> $rs = $db->update(DBPrefix.'user', 'sid="'.$_SESSION['sid'].'"'); <br> $rs->set('client_to', ''); <br> $rs->set('role', RoleOnline); <br> $rs->set('last_access_time', time()); <br> $rs->setfunc('login_count', 'login_count+1'); <br> $rs->set('last_login_time', time()); <br> $ip = $_SERVER['REMOTE_ADDR']; <br> $ipx = explode('.', $ip); <br> $iplong = <br> $ipx[0] * 16777216 + <br> $ipx[1] * 65536 + <br> $ipx[2] * 256 + <br> $ipx[3]; <br> $rs->set('last_login_ip', $iplong); <br> if (!$rs->update()) <br> { <br> // add new <br> $rs = $db->insert(DBPrefix.'user'); <br> $rs->set('sid', $_SESSION['sid']); <br> $rs->set('client_to', ''); <br> $rs->set('role', RoleOnline); <br> $rs->set('last_access_time', time()); <br> $rs->set('login_count', 1); <br> $rs->set('last_login_time', time()); <br> $rs->set('last_login_ip', $iplong); <br> $rs->insert(); <br> } <br> $db->close(); <br> // display init page <br> display('init.html'); <br> break; <br> case 'status': <br> dll::import('mysql'); <br> // access $dbs <br> global $dbs; <br> $db = new mysql(); <br> $db->connect($dbs['server'], $dbs['user'], $dbs['password']); <br> $db->database($dbs['database']); <br> // update access <br> update_access($db); <br> // import mysql.class <br> display('server.status.html'); <br> $db->close(); <br> break; <br> case 'work': <br> $mode = $_GET['mode']; <br> // update work mode <br> dll::import('mysql'); <br> $db = new mysql(); <br> $db->connect($dbs['server'], $dbs['user'], $dbs['password']); <br> $db->database($dbs['database']); <br> // update <br> $rs = $db->update(DBPrefix.'user', 'sid="'.$_SESSION['sid'].'"'); <br> switch ($mode) <br> { <br> case 'answer': <br> $rs->set('role', RoleAnswer); <br> break; <br> case 'asker': <br> $rs->set('role', RoleAsker); <br> break; <br> case 'chater': <br> $rs->set('role', RoleChater); <br> break; <br> case 'offline': <br> $rs->set('role', RoleOffline); <br> $rs->set('client_to', ''); <br> // delete input status cache <br> @unlink(dirname('.').'/cache/'.$_SESSION['sid'].'.input.status'); <br> // clear session <br> unset($_SESSION); <br> break; <br> } <br> $rs->set('last_access_time', time()); <br> $rs->update(); <br> $db->close(); <br> // display mode page <br> if ($mode != 'offline') <br> {<div class="clear"> </div>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Many users will choose the Huawei brand when choosing smart watches. Among them, Huawei GT3pro and GT4 are very popular choices. Many users are curious about the difference between Huawei GT3pro and GT4. Let’s introduce the two to you. . What are the differences between Huawei GT3pro and GT4? 1. Appearance GT4: 46mm and 41mm, the material is glass mirror + stainless steel body + high-resolution fiber back shell. GT3pro: 46.6mm and 42.9mm, the material is sapphire glass + titanium body/ceramic body + ceramic back shell 2. Healthy GT4: Using the latest Huawei Truseen5.5+ algorithm, the results will be more accurate. GT3pro: Added ECG electrocardiogram and blood vessel and safety

Interpretation of MyBatis dynamic SQL tags: Detailed explanation of Set tag usage MyBatis is an excellent persistence layer framework. It provides a wealth of dynamic SQL tags and can flexibly construct database operation statements. Among them, the Set tag is used to generate the SET clause in the UPDATE statement, which is very commonly used in update operations. This article will explain in detail the usage of the Set tag in MyBatis and demonstrate its functionality through specific code examples. What is Set tag Set tag is used in MyBati

Session failure is usually caused by the session lifetime expiration or server shutdown. The solutions: 1. Extend the lifetime of the session; 2. Use persistent storage; 3. Use cookies; 4. Update the session asynchronously; 5. Use session management middleware.

Solution to the cross-domain problem of PHPSession In the development of front-end and back-end separation, cross-domain requests have become the norm. When dealing with cross-domain issues, we usually involve the use and management of sessions. However, due to browser origin policy restrictions, sessions cannot be shared by default across domains. In order to solve this problem, we need to use some techniques and methods to achieve cross-domain sharing of sessions. 1. The most common use of cookies to share sessions across domains

1. Implementing SMS login based on session 1.1 SMS login flow chart 1.2 Implementing sending SMS verification code Front-end request description: Description of request method POST request path /user/code request parameter phone (phone number) return value No back-end interface implementation: @Slf4j@ ServicepublicclassUserServiceImplextendsServiceImplimplementsIUserService{@OverridepublicResultsendCode(Stringphone,HttpSessionsession){//1. Verify mobile phone number if

After several pre-releases, the KDE Plasma development team unveiled version 6.0 of its desktop environment for Linux and BSD systems on 28 February, using the Qt6 framework for the first time. KDE Plasma 6.1 now comes with a number of new features t

Why Snipping Tool Not Working on Windows 11 Understanding the root cause of the problem can help find the right solution. Here are the top reasons why the Snipping Tool might not be working properly: Focus Assistant is On: This prevents the Snipping Tool from opening. Corrupted application: If the snipping tool crashes on launch, it might be corrupted. Outdated graphics drivers: Incompatible drivers may interfere with the snipping tool. Interference from other applications: Other running applications may conflict with the Snipping Tool. Certificate has expired: An error during the upgrade process may cause this issu simple solution. These are suitable for most users and do not require any special technical knowledge. 1. Update Windows and Microsoft Store apps

JavaScriptCookies Using JavaScript cookies is the most effective way to remember and track preferences, purchases, commissions and other information. Information needed for a better visitor experience or website statistics. PHPCookieCookies are text files that are stored on client computers and retained for tracking purposes. PHP transparently supports HTTP cookies. How do JavaScript cookies work? Your server sends some data to your visitor's browser in the form of a cookie. Browsers can accept cookies. If present, it will be stored on the visitor's hard drive as a plain text record. Now, when a visitor reaches another page on the site
