Ajax PHP Chat Room Instance Code (1/5) _php Tutorial

Source: Internet
Author: User
Tags ajax chat
/*
Ajax PHP Chat Room Instance Code
But it must be based on the following terms:
Signature You must clearly indicate the name of the author.
* Non-commercial use. You may not use the current work for commercial purposes.
* Stay consistent. If you change, transform, or construct a new work based on the current work, you should distribute the final work in exactly the same agreement as the current agreement
* For any two use or distribution, you must make it clear to others that the current work's license terms
* With the explicit permission of the author, certain terms here may be waived

This convention is a simple and easy-to-read summary of legal texts (complete agreements)
****************************************/
Parameter Setting ****************
Show online users

$disonline = true;
The number of recent items displayed in the new login (default is 30)
$leastnum = 30;
The default room name (the default is to change a file every day), if you remove D, it is a month to change a file
$room = Date ("y-m-d");
Room save path, must end with/
$roomdir = "rooms/";
Encoding method
$charset = "Utf-8";
Maximum number of content bars displayed by client (not too large recommended)
$maxdisplay = 300;


Language
$lang = Array (
Chat Room Description
"description" = "Welcome to the mini Ajax chat room." Latest Version 1.2. Download please go to www.bKjia.c0m ",
Chat room Title
"Title" = "Mini Ajax Chatroom by Longbill",
The first one to chat room welcome
"Firstone" = "Welcome to Longbill's Mini Ajax chatroom!",
Display when information has forbidden content
"Ban" = "I am a pig!",
Key words
"keywords" = "chat room, mini, small, ajax,chat,chatroom,longbill,bkjia.c0m,php, web Effects",
Speech tips
"Hereyourwords" = "Speak here!"
);

Error_reporting (e_all ^ e_notice ^ e_warning);
Header ("content-type:text/html; Charset=utf-8 ");

$get _past_sec = 3; If you find a missing message, you can adjust the value appropriately.
$touchs = 10; Check the time interval for online people

if (!function_exists ("file_get_contents"))
{
function file_get_contents ($path)
{
if (!file_exists ($path)) return false;
$fp = @fopen ($path, "R");
$all =fread ($fp, FileSize ($path));
Fclose ($FP);
return $all;
}
}

if (!function_exists ("file_put_contents"))
{
function file_put_contents ($path, $val)
{
$fp = @fopen ($path, "w");
Fputs ($fp, $val);
Fclose ($FP);
return true;
}
}

$title = $lang ["title"];
$earlier = 10;
$description = $lang ["description"];
$origroom = $room;
$least = ($_get["Dis"]) intval ($_get["Dis"): $leastnum;
$touchme = $_post[' Touchme ');
if (!is_dir ($roomdir)) @mkdir ($roomdir) or Die ("error when creating folder $roomdir");
$room = $_get[' "");
if (! $room) $room = $_post["Guest"];
$room = Checkfilename ($room);
if (! $room) $room = $origroom;
$filename = $roomdir. $room. ". Dat.php ";
$datafile = $roomdir. $room. ". PHP ";
if (!file_exists ($filename)) @file_put_contents ($filename, "." N ". Time ()." | ". $lang ["Firstone"]. " n ");
if (!file_exists ($datafile)) @file_put_contents ($datafile, "." n ");
$action = $_post["Action"];

function Checkfilename ($file)
{
if (! $file) return "";
$file = Trim ($file);
$a = substr ($file,-1);
$file = Eregi_replace ("^[.\/]*", "", $file);
$file = Eregi_replace ("[. \/]*$", "", $file);
$arr = Array (".. /","./","/","\",".. \",".\");
$file = Str_replace ($arr, "", $file);
return $file;
}

1 2 3) 4 5

http://www.bkjia.com/PHPjc/632034.html www.bkjia.com true http://www.bkjia.com/PHPjc/632034.html techarticle PHP Tutorial/* Ajax PHP Chat room instance code but must be based on the following terms: * attribution. You must clearly indicate the name of the author. * Non-commercial use. You may not use the current work for business ...

  • 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.