basic functions: Can log in, chat, record the number of online IP events, can control the font color of chat, automatically convert the URL of the chat as a link address, can customize the chat room title, advertising information and so on. Use text as a storage medium, and interest can refer to the code and expand it.
In fact, PHP as a fast-developing scripting language is great!
= = = Code = =
The following is the referenced content:
/**
* Night passers-by simple chat room
* Author: Heiyeluren
* Created: 2005-8-10 22:42
* Modified: 2005-8-11 23:25
*/
Error_reporting (7);
Session_Start ();
Header ("contenttype:text/html;charset=gb2312");
Define ("SCRIPT", $_server[' Script_name ']);
Define ("Chat_note", "./chat.txt");
Define ("Online_list", "./online.txt");
Define ("Ref_time", 5);
Define ("Chat_name", "Night Passerby chat room");
Define ("Ad_msg", "Today is Chinese Valentine's Day, wish everyone Happy Valentine's Day!!");
Get value
if (Isset ($_get[' action ')) &&!empty ($_get[' action ')) {
$action = $_get[' action '];
}
If you have already logged in, jump directly to the chat screen.
if (!isset ($_get[' action ')) && isset ($_session[' username ']) {
Header ("Location:".) SCRIPT. "? Action=chat ");
}
Login Tips
if (!isset ($_get[' action '))
{
if (!session_is_registered (' username '))
{
echo "
[ ". Chat_name. "] ©2005
";
Exit
}
}
Check Login
if ($action = = ' Login ')
{
if (Isset ($_post[' Login_user ')) &&!empty ($_post[' Login_user ']) {
$username = $_post[' Login_user ');
} else {
$username = "Tourist";
}
Session_register (' username ');
Save_online ($username, Get_client_ip ());
Header ("Location:".) SCRIPT. "? Action=chat ");
}
Start Chatting www.knowsky.com
if ($action = = "Chat")
{
$online _sum = Get_online_sum ();
echo "[ ". Chat_name. "]
". Ad_msg. "
[Current online: $online _sum]
<iframe src="&quot;.SCRIPT.&quot;?action=say" name="say_win" width="800<br"></iframe>height=60 Scrolling=no frameborder=0>
";
}
Speaking interface
if ($action = = "Say")
{
echo "[ ". Chat_name. "]
Onsubmit= ' return check () ' >
[". $_session[' username ']."] Said: maxlength=500 name=chatmsg style= ' background-color: #99CC99;
width:550px; height:22px; border:1px Solid: #000000 ' >
Default color Black Silence Red Passion Blue and cheerful Peach Romance Green Youth Cyan Refreshing Purple formality Night Excitement Blue Blues Khaki Uniform Gold-filled years Lake Wave Ripples Shiny Blue Violet The hint of love Http://www.bkjia.com/PHPjc/814352.htmlWww.bkjia.comTrueHttp://www.bkjia.com/PHPjc/814352.htmlTecharticleBasic functions: Can log in, chat, record the number of online IP events, can control the font color of chat, automatically convert the URL of the chat as a link address, can customize the chat room title, advertising letter ...