用PHP和ACCESS写聊天室(十)

5年以前  |  阅读数:230 次  |  编程语言:PHP 

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

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

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
获取IMEI
贪吃蛇
文件下载
双位运算符
发送邮件
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
提取后缀名
年的日历图
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例