用PHP和ACCESS写聊天室(十)
程序员文章站
2022-07-11 08:08:25
func.php3 代码如下:
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
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;
}
?>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
上一篇: 淘小铺开店具体流程
下一篇: 原型和原型链--构造函数