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>
代码如下:
<?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>