用PHP和ACCESS写聊天室(十)


Posted in PHP onOctober 09, 2006

func.php3
代码如下:
<?php
function suiji($max)
{
        srand((double)microtime()*1000000);
        $x=rand();
        $y=getrandmax();
        $r=$x/$y*($max-1);
        $r=round($r++);
        return $r;
}

function StrOccurs($sStr, $sFind){
        $sTemp=$sStr;
        $iLen=strlen($sFind);
        $iCount=0;
        while (true){
                if (strstr($sTemp, $sFind))
                        break;
                else
                        $sTemp = instr($sTemp,strpos($sTemp,$sFind)+$iLen);
                        $iCount++;
                }
        }
        return $iCount;
}

function StrDupl($sStr, $iCnt){
        $ret="";
        for($i=1;$i<=$iCnt;$i++)
                $ret.=$sStr;
        return $ret;
}

function DelQuot($sStr){
        $s=str_replace(chr(124),"¦",$sStr);
        $s=str_replace(chr(39),"´",$s);
        $s=str_replace(chr(34),""",$s);
        return s;
}

function DelTag($sStr){
        $bNeed="False";
        $sOther=strtoupper($sStr);
        if ($bNeed!="True" || !strstr($sOther,"<TABLE")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</TABLE")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<SCRIPT")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</SCRIPT")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<BODY")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</BODY")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<HTML")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</HTML")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<HEAD")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</HEAD")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<FORM")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</FORM")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<INPUT")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</INPUT")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<OPTION")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</OPTION")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<SELECT")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</SELECT")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<APPLET")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</APPLET")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<OBJECT")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</OBJECT")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<MENU")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</MENU")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<FRAMESET")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</FRAMESET")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<FRAME")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</FRAME")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<IFRAME")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</IFRAME")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<STYLE")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"</STYLE")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"<BASE")) $bNeed="True";
        if ($bNeed!="True" || !strstr($sOther,"FONT-SIZE:")) $bNeed="True";
        if ($bNeed=="True")
                return str_replace(">",">",str_replace("<","<",$sStr));
        else
                return $sStr;
}

function AddLost($sStr){
        $ret=$sStr;
        $ret.=StrDupl(">", (StrOccurs(strtoupper($ret), "<") - StrOccurs(strtoupper($ret), ">")));
        $ret.=StrDupl("</FONT>", (StrOccurs(strtoupper($ret), "<FONT") - StrOccurs(strtoupper($ret), "</FONT>")));
        $ret.=StrDupl("</B>", (StrOccurs(strtoupper($ret), "<B") - StrOccurs(strtoupper($ret), "</B>")));
        $ret.=StrDupl("</I>", (StrOccurs(strtoupper($ret), "<I") - StrOccurs(strtoupper($ret), "</I>")));
        $ret.=StrDupl("</U>", (StrOccurs(strtoupper($ret), "<U") - StrOccurs(strtoupper($ret), "</U>")));
        $ret.=StrDupl("</S>", (StrOccurs(strtoupper($ret), "<S") - StrOccurs(strtoupper($ret), "</S>")));
        $ret.=StrDupl("</STRIKE>", (StrOccurs(strtoupper($ret), "<STRIKE") - StrOccurs(strtoupper($ret), "</STRIKE>")));
        $ret.=StrDupl("</STRONG>", (StrOccurs(strtoupper($ret), "<STRONG") - StrOccurs(strtoupper($ret), "</STRONG>")));
        $ret.=StrDupl("</SMALL>", (StrOccurs(strtoupper($ret), "<SMALL") - StrOccurs(strtoupper($ret), "</SMALL>")));
        $ret.=StrDupl("</CITE>", (StrOccurs(strtoupper($ret), "<CITE") - StrOccurs(strtoupper($ret), "</CITE>")));
        $ret.=StrDupl("</EM>", (StrOccurs(strtoupper($ret), "<EM") - StrOccurs(strtoupper($ret), "</EM>")));
        $ret.=StrDupl("</CODE>", (StrOccurs(strtoupper($ret), "<CODE") - StrOccurs(strtoupper($ret), "</CODE>")));
        $ret.=StrDupl("</SAMP>", (StrOccurs(strtoupper($ret), "<SAMP") - StrOccurs(strtoupper($ret), "</SAMP>")));
        $ret.=StrDupl("</KBD>", (StrOccurs(strtoupper($ret), "<KBD") - StrOccurs(strtoupper($ret), "</KBD>")));
        $ret.=StrDupl("</VAR>", (StrOccurs(strtoupper($ret), "<VAR") - StrOccurs(strtoupper($ret), "</VAR>")));
        $ret.=StrDupl("</DFN>", (StrOccurs(strtoupper($ret), "<DFN") - StrOccurs(strtoupper($ret), "</DFN>")));
        $ret.=StrDupl("</BIG>", (StrOccurs(strtoupper($ret), "<BIG") - StrOccurs(strtoupper($ret), "</BIG>")));
        $ret.=StrDupl("</SUP>", (StrOccurs(strtoupper($ret), "<SUP") - StrOccurs(strtoupper($ret), "</SUP>")));
        $ret.=StrDupl("</SUB>", (StrOccurs(strtoupper($ret), "<SUB") - StrOccurs(strtoupper($ret), "</SUB>")));
        $ret.=StrDupl("</H1>", (StrOccurs(strtoupper($ret), "<H1") - StrOccurs(strtoupper($ret), "</H1>")));
        $ret.=StrDupl("</H2>", (StrOccurs(strtoupper($ret), "<H2") - StrOccurs(strtoupper($ret), "</H2>")));
        $ret.=StrDupl("</H3>", (StrOccurs(strtoupper($ret), "<H3") - StrOccurs(strtoupper($ret), "</H3>")));
        $ret.=StrDupl("</H4>", (StrOccurs(strtoupper($ret), "<H4") - StrOccurs(strtoupper($ret), "</H4>")));
        $ret.=StrDupl("</H5>", (StrOccurs(strtoupper($ret), "<H5") - StrOccurs(strtoupper($ret), "</H5>")));
        $ret.=StrDupl("</H6>", (StrOccurs(strtoupper($ret), "<H6") - StrOccurs(strtoupper($ret), "</H6>")));
        $ret.=StrDupl("</H7>", (StrOccurs(strtoupper($ret), "<H7") - StrOccurs(strtoupper($ret), "</H7>")));
        return $ret;
}
?>

【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】    

PHP 相关文章推荐
PHP 抓取新浪读书频道的小说并生成txt电子书的代码
Dec 18 PHP
SWFUpload与CI不能正确上传识别文件MIME类型解决方法分享
Apr 18 PHP
php class中self,parent,this的区别以及实例介绍
Apr 24 PHP
ThinkPHP分页类使用详解
Mar 05 PHP
实用的PHP带公钥加密类分享(每次加密结果都不一样哦)
Aug 20 PHP
PHPUnit安装及使用示例
Oct 29 PHP
PHP抽奖算法程序代码分享
Oct 08 PHP
CI框架实现优化文件上传及多文件上传的方法
Jan 04 PHP
解决php-fpm.service not found问题的办法
Jun 06 PHP
PHP以json或xml格式返回请求数据的方法
May 31 PHP
使用tp框架和SQL语句查询数据表中的某字段包含某值
Oct 18 PHP
yii2.0框架实现上传excel文件后导入到数据库的方法示例
Apr 13 PHP
php生成EXCEL的东东
Oct 09 #PHP
一个取得文件扩展名的函数
Oct 09 #PHP
PHP 如何向 MySQL 发送数据
Oct 09 #PHP
PHP安装攻略:常见问题解答(一)
Oct 09 #PHP
利用PHP实现与ASP Banner组件相似的类
Oct 09 #PHP
PHP聊天室技术
Oct 09 #PHP
在windows iis5下安装php4.0+mysql之我见
Oct 09 #PHP
You might like
利用php+mysql来做一个功能强大的在线计算器
2010/10/12 PHP
php不用正则验证真假身份证
2013/11/06 PHP
Laravel框架数据库CURD操作、连贯操作总结
2014/09/03 PHP
php使用ob_flush不能每隔一秒输出原理分析
2015/06/02 PHP
PHP基于PDO调用sqlserver存储过程通用方法【基于Yii框架】
2017/10/07 PHP
Thinkphp极验滑动验证码实现步骤解析
2020/11/24 PHP
ExtJS 2.2.1的grid控件在ie6中的显示问题
2009/05/04 Javascript
Javascript获取HTML静态页面参数传递值示例
2013/08/18 Javascript
深入理解javascript动态插入技术
2013/11/12 Javascript
jQuery中:disabled选择器用法实例
2015/01/04 Javascript
javascript中clipboardData对象用法详解
2015/05/13 Javascript
轻松学习jQuery插件EasyUI EasyUI实现拖动基本操作
2015/11/30 Javascript
Node.js程序中的本地文件操作用法小结
2016/03/06 Javascript
Vue.js bootstrap前端实现分页和排序
2017/03/10 Javascript
JS/jquery实现一个网页内同时调用多个倒计时的方法
2017/04/27 jQuery
bootstrap轮播图示例代码分享
2017/05/17 Javascript
Angular.JS中的this指向详解
2017/05/17 Javascript
详解nodejs中express搭建权限管理系统
2017/09/15 NodeJs
jQuery length 和 size()区别总结
2018/04/26 jQuery
vue本地打开build后生成的dist文件夹index.html问题
2019/09/04 Javascript
基于VSCode调试网页JavaScript代码过程详解
2020/07/20 Javascript
[01:03:59]2018DOTA2亚洲邀请赛3月30日 小组赛B组VGJ.T VS Secret
2018/03/31 DOTA
Python通过PIL获取图片主要颜色并和颜色库进行对比的方法
2015/03/19 Python
简单解决Python文件中文编码问题
2015/11/22 Python
浅谈pyqt5在QMainWindow中布局的问题
2019/06/21 Python
Python 获取windows桌面路径的5种方法小结
2019/07/15 Python
wxpython布局的实现方法
2019/11/01 Python
Python 模拟生成动态产生验证码图片的方法
2020/02/01 Python
Pycharm远程连接服务器并实现代码同步上传更新功能
2020/02/25 Python
前端canvas水印快速制作(附完整代码)
2019/09/19 HTML / CSS
eBay瑞士购物网站:eBay.ch
2018/12/24 全球购物
设计师大码女装:11 Honoré
2020/05/03 全球购物
自荐信的禁忌和要点
2013/10/15 职场文书
千与千寻观后感
2015/06/04 职场文书
处罚决定书范文
2015/06/24 职场文书
奖学金申请书(范文)
2019/08/14 职场文书