您现在的位置: 军旅同心 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 文章正文
用PHP和ACCESS写聊天室(十)
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 14:36:22
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),"&brvbar;",$sStr);
        $s=str_replace(chr(39),"&acute;",$s);
        $s=str_replace(chr(34),"&quot;",$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(">","&gt;",str_replace("<","&lt;",$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>

[1] [2] 下一页


 
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 版权申明 | 网站公告 | 管理登录 |