首页 > php教程 > php手册 > 正文

ajax php 聊天室实例代码(1/5)

php中文网
发布: 2016-06-13 09:57:52
原创
1172人浏览过

Browse AI
Browse AI

AI驱动的网页内容抓取和数据采集工具

Browse AI 105
查看详情 Browse AI

php教程
/*
ajax php 聊天室实例代码
但是必须基于以下条款:
  * 署名。你必须明确标明作者的名字。.
  * 非商业用途。 你不可将当前作品用于商业目的。
  * 保持一致。 如果你基于当前作品更改、变换或构造新作品,你应当按照与当前协议完全相同的协议分发最终作品
  * 对于任何二次使用或分发,你必须让其他人明确当前作品的授权条款
  * 在得到作者的明确允许下,这里的某些条款可以放弃

此约定是法律文本 (完整的协议)的简单易读概要
****************************************/
//****************参数设置****************
//显示在线用户

$disonline = true; //新登陆时显示最近内容的条数(默认为30条) $leastnum = 30; //默认的房间名(默认是每天换一个文件),如果去掉d,则是每月换一个文件 $room = date("y-m-d"); //房间保存路径,必须以/结尾 $roomdir = "rooms/"; //编码方式 $charset = "utf-8"; //客户端最大显示内容条数(建议不要太大) $maxdisplay = 300; //语言 $lang = array( //聊天室描述 "description"=>"欢迎来到迷你ajax聊天室。最新版本 1.2。下载请到www.bKjia.c0m", //聊天室标题 "title"=>"mini ajax chatroom by longbill", //第一个到聊天室的欢迎 "firstone"=>"welcome to longbill's mini ajax chatroom!", //当信息有禁止内容时显示 "ban"=>"i am a pig!", //关键字 "keywords"=>"聊天室,迷你,小型,ajax,chat,chatroom,longbill,bKjia.c0m,php,网页特效", //发言提示 "hereyourwords" => "在这里发言!" ); error_reporting(e_all ^ e_notice ^ e_warning); header("content-type:text/html; charset=utf-8"); $get_past_sec = 3; //如果发现丢话,可以适当调大这个值 $touchs = 10; //检查在线人数的时间间隔   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['room']; if (!$room) $room = $_post["room"]; $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

相关标签:
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号