用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学习散记_编码(json_encode 中文不显示)
Nov 10 PHP
慎用preg_replace危险的/e修饰符(一句话后门常用)
Jun 19 PHP
php利用curl抓取新浪微博内容示例
Apr 27 PHP
php定时计划任务与fsockopen持续进程实例
May 23 PHP
Codeigniter(CI)框架分页函数及相关知识
Nov 03 PHP
php实现的树形结构数据存取类实例
Nov 29 PHP
yii中widget的用法
Dec 03 PHP
避免Smarty与CSS语法冲突的方法
Mar 02 PHP
Zend Framework教程之Zend_Layout布局助手详解
Mar 04 PHP
smarty的section嵌套循环用法示例
May 28 PHP
PHP更安全的密码加密机制Bcrypt详解
Jun 18 PHP
thinkphp ajaxfileupload实现异步上传图片的示例
Aug 28 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 ckeditor上传图片文件名乱码解决方法
2013/11/15 PHP
php实现过滤UBB代码的类
2015/03/12 PHP
关于PHP文件的自动运行方法分析
2016/05/13 PHP
php5.5使用PHPMailer-5.2发送邮件的完整步骤
2018/10/14 PHP
JavaScript Event学习补遗 addEventSimple
2010/02/11 Javascript
jQuery EasyUI API 中文文档 - Dialog对话框
2011/11/15 Javascript
2012年开发人员的16款新鲜的jquery插件体验分享
2012/12/28 Javascript
新增加的内容是如何将div的scrollbar自动移动最下面
2014/01/02 Javascript
将查询条件的input、select清空
2014/01/14 Javascript
JavaScript的作用域和块级作用域概念理解
2014/09/21 Javascript
javascript下拉框选项单击事件的例子分享
2015/03/04 Javascript
javascript随机抽取0-100之间不重复的10个数
2016/02/25 Javascript
javascirpt实现2个iframe之间传值的方法
2016/06/30 Javascript
全面了解函数声明与函数表达式、变量提升
2016/08/09 Javascript
JS实现的相册图片左右滚动完整实例
2016/11/23 Javascript
JS中图片压缩的方法小结
2017/11/14 Javascript
nuxt.js 缓存实践
2018/06/25 Javascript
Vue 中axios配置实例详解
2018/07/27 Javascript
Layui给数据表格动态添加一行并跳转到添加行所在页的方法
2018/08/20 Javascript
koa+mongoose实现简单增删改查接口的示例代码
2019/05/13 Javascript
微信小程序实现折线图的示例代码
2019/06/07 Javascript
[02:28]DOTA2亚洲邀请赛附加赛 RECAP赛事回顾
2015/01/29 DOTA
linux环境下安装pyramid和新建项目的步骤
2013/11/27 Python
Python通过RabbitMQ服务器实现交换机功能的实例教程
2016/06/29 Python
如何实现删除numpy.array中的行或列
2018/05/08 Python
python 代码实现k-means聚类分析的思路(不使用现成聚类库)
2020/06/01 Python
Python 创建守护进程的示例
2020/09/29 Python
实例讲解CSS3中Transform的perspective属性的用法
2016/04/22 HTML / CSS
巴西Mr. Cat在线商店:购买包包和鞋子
2019/09/08 全球购物
迪卡侬(Decathlon)加拿大官网:源自法国的运动专业超市
2020/11/22 全球购物
加拿大品牌鞋包连锁店:Little Burgundy
2021/02/28 全球购物
西北政法大学自主招生自荐信
2014/01/29 职场文书
2015年度党员自我评价范文
2015/03/03 职场文书
幼儿园重阳节活动总结
2015/05/05 职场文书
七夕情人节问候语
2015/11/11 职场文书
html css3不拉伸图片显示效果
2021/06/07 HTML / CSS