用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简单的伪原创程序,配合商城采集用的
Oct 12 PHP
PHP--用万网的接口实现域名查询功能
Dec 13 PHP
PHP file_get_contents设置超时处理方法
Sep 30 PHP
PHP获取客户端真实IP地址的5种情况分析和实现代码
Jul 08 PHP
php利用事务处理转账问题
Apr 22 PHP
最准确的php截取字符串长度函数
Oct 29 PHP
Thinkphp框架开发移动端接口(2)
Aug 18 PHP
利用PHP如何写APP接口详解
Aug 23 PHP
Laravel重写用户登录简单示例
Oct 08 PHP
PHP 信号管理知识整理汇总
Feb 19 PHP
PHP获取当前日期及本周一是几月几号的方法
Mar 28 PHP
Laravel框架中缓存的使用方法分析
Sep 06 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内置过滤器FILTER使用实例
2014/06/25 PHP
PHP递归获取目录内所有文件的实现方法
2016/11/01 PHP
Windows平台实现PHP连接SQL Server2008的方法
2017/07/26 PHP
详解阿里云视频直播PHP-SDK接入教程
2020/07/09 PHP
一步一步制作jquery插件Tabs实现过程
2010/07/06 Javascript
img onload事件绑定各浏览器均可执行
2012/12/19 Javascript
jquery实现图片滚动效果的简单实例
2013/11/23 Javascript
jquery防止重复执行动画避免页面混乱
2014/04/22 Javascript
javascript实现根据汉字获取简拼
2016/09/25 Javascript
从零学习node.js之模块规范(一)
2017/02/21 Javascript
ES6中箭头函数的定义与调用方式详解
2017/06/02 Javascript
Echarts基本用法_动力节点Java学院整理
2017/08/11 Javascript
详解在vue-cli中使用路由
2017/09/25 Javascript
解决Vue.js由于延时显示了{{message}}引用界面的问题
2018/08/25 Javascript
Vue使用Ref跨层级获取组件的步骤
2021/01/25 Vue.js
[07:47]DOTA2国际邀请赛采访专栏:探访Valve总部
2013/08/08 DOTA
[00:27]DOTA2次级职业联赛 - Lilith战队宣传片
2014/12/01 DOTA
[51:36]EG vs VP 2018国际邀请赛淘汰赛BO3 第一场 8.24
2018/08/25 DOTA
Python socket编程实例详解
2015/05/27 Python
Python内置模块turtle绘图详解
2017/12/09 Python
Python输出各行命令详解
2018/02/01 Python
python3使用pandas获取股票数据的方法
2018/12/22 Python
利用Python正则表达式过滤敏感词的方法
2019/01/21 Python
python调用动态链接库的基本过程详解
2019/06/19 Python
Django缓存系统实现过程解析
2019/08/02 Python
numpy 声明空数组详解
2019/12/05 Python
python Plotly绘图工具的简单使用
2020/03/03 Python
python实现简易版学生成绩管理系统
2020/06/22 Python
如何在Cookie里面保存Unicode和国际化字符
2013/05/25 面试题
工程预算与管理应届生求职信
2013/10/06 职场文书
商务日语毕业生自荐信范文
2013/11/14 职场文书
土木建筑学生自我评价
2014/01/14 职场文书
长安大学毕业生自我鉴定
2014/01/17 职场文书
酒店中秋节活动方案
2014/01/31 职场文书
单位接收函范文
2015/01/30 职场文书
python 爬取吉首大学网站成绩单
2021/06/02 Python