您的位置:首页网页设计PHP实例 → 用PHP和ACCESS写聊天室三

用PHP和ACCESS写聊天室三

时间:2004/11/7 3:23:00来源:本站整理作者:蓝点我要评论(0)

cinput.php3

如下:





输入














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 = substr($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,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    if ($bNeed!="True" || !strstr($sOther,"

    if ($bNeed!="True" || !strstr($sOther,"
    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("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    $ret.=StrDupl("", (StrOccurs(strtoupper($ret), "")));

    return $ret;

}



$sSecret="False";

$sRefRate=5;

$ConnID=@odbc_connect("jtfcht","admin","");

if ($ConnID){

    if ($id=="1" && $ps="superldz"){

        $result=@odbc_exec($ConnID,"SELECT RefRate FROM User WHERE UserID=".$id);

        if (@odbc_fetch_into($result,0,&$rArr)){

            $sRefRate=$rArr[0];

            if ($cmdSend=="送出"){

                $sRefRate=(int)($txtRefRate);

                if ($sRefRate<2) $sRefRate=2;

                @odbc_exec($ConnID,"UPDATE User SET RefRate=".$sRefRate.",LstTime=".time()." WHERE UserID=".($id));

                @odbc_exec($ConnID,"INSERT INTO ChtCont (sIDFrom, sNameFrom, sIPFrom, sIDTo, sNameTo, sTime, sCont, bSecret, RoomID) VALUES (".$id.", '管理员', '".getenv("REMOTE_ADDR")."', 0, '大家', '".date("H:i:s")."', '【系统消息】".trim(DelQuot(htmlspecialchars($txtSend)))."', False, 0)");

            }

        }

    }

    else{

        $result=@odbc_exec($ConnID,"SELECT UserID,UserName,PassWord,LstTime,Secret,RefRate,ToID,ToName,RoomID FROM User WHERE UserID=".($id));

        if (@odbc_fetch_into($result,0,&$rArr)){

            if ($rArr[2]==$ps){

                if ($rArr[3]>=(time()-1800)){

                    if ($rArr[4]) $sSecret="True";

                    $sRefRate=$rArr[5];

                    if ($cmdSend=="送出"){

                        $sUserName=$rArr[1];

                        $sToID=$rArr[6];

                        $sToName=$rArr[7];

                        $sRoomID=$rArr[8];

                        //$sSend=AddLost(DelTag(DelQuot($txtSend)));

                        $sSend=DelQuot(htmlspecialchars($txtSend));

                        if ($chkSecret=="Yes"){

                            $sSecret="True";

                            $sTalk="悄悄说:";

                        }

                        else{

                            $sSecret="False";

                            $sTalk="说:";

                        }

                        $sRefRate=(int)($txtRefRate);

                        if ($sRefRate<2) $sRefRate=2;

                        @odbc_exec($ConnID,"UPDATE User SET EmotionID=".$sEmotion.",ColorID='".$sColor."',Secret=".$sSecret.",RefRate=".$sRefRate.",LstTime=".time()." WHERE UserID=".$id);

                        $bCht="True";

                        $bToMe="False";

                        if (substr($sSend,0,3)=="/t "){

                            $sChtCont="%m想".substr($sSend,3)."";

                            $sSecret="False";

                            $bCht="False";

                        }

                        elseif (substr($sSend,0,3)=="/: "){

                            $sChtCont="%m".substr($sSend,3)."";

                            $sSecret="False";

                            $bCht="False";

                        }

                        elseif (strtolower(substr($sSend,0,3))=="/w "){

                            $result=@odbc_exec($ConnID,"SELECT RoomID FROM User WHERE UserName='".trim(substr($sSend,3))."'");

                            if (@odbc_fetch_into($result,0,&$rArr)){

                                if ($rArr[0]>0){

                                    $result=@odbc_exec($ConnID,"SELECT RoomName FROM Room WHERE RoomID=".$rArr[0]);

                                    if (@odbc_fetch_into($result,0,&$rArr))

                                        $sChtCont="【系统消息】".trim(substr($sSend,3))."目前在房间".$rArr[0]."。";

                                    else

                                        $sChtCont="【系统消息】系统混乱了,".trim(substr($sSend,3))."目前在的房间不可识别!";

                                }

                                else

                                    $sChtCont="【系统消息】".trim(substr($sSend,3))."目前没有上线。";

                                $sSecret="True";

                                $bCht="False";

                            }

                            else{

                                $sChtCont="【系统消息】没有".trim(substr($sSend,3))."这个人。";

                                $sSecret="True";

                                $bCht="False";

                            }

                            $bToMe="True";

                        }

                        elseif (substr($sSend,0,3)=="// "){

                            $result=@odbc_exec($ConnID,"SELECT ActCont FROM Action WHERE ActID='".trim(substr($sSend,3))."'");

                            if (@odbc_fetch_into($result,0,&$rArr)){

                                $sChtCont="".trim($rArr[0])."";

                                $sSecret="False";

                                $bCht="False";

                            }

                            else $bCht="True";

                        }

                        if ($bCht=="True"){

                            $result=@odbc_exec($ConnID,"SELECT COUNT(EmotionTp) AS CNT_TP FROM Emotion WHERE EmotionTp=".$sEmotion);

                            @odbc_fetch_into($result,0,&$rArr);

                            if ($rArr[0]>0){

                                $iEmCnt=suiji($rArr[0]);

                                $result=@odbc_exec($ConnID,"SELECT EmotionCont FROM Emotion WHERE EmotionTp=".$sEmotion." AND EmotionID=".$iEmCnt);

                                if (@odbc_fetch_into($result,0,&$rArr))

                                    $sChtCont="%m".trim($rArr[0])."对%g".$sTalk.$sSend;

                                else

                                    $sChtCont="%m对%g".$sTalk.$sSend;

                            }

                            else $sChtCont="%m对%g".$sTalk.$sSend;

                            if ($sSecret=="True")

                                $sChtCont="".$sChtCont."";

                            else

                                $sChtCont="".$sChtCont."";

                        }

                        if ($bToMe=="True")

                            @odbc_exec($ConnID,"INSERT INTO ChtCont (sIDFrom, sNameFrom, sIPFrom, sIDTo, sNameTo, sTime, sCont, bSecret, RoomID) VALUES (0, '大家', '".getenv("REMOTE_ADDR")."', ".$id.", '".$sUserName."', '".date("H:i:s")."', '".$sChtCont."', ".$sSecret.", ".$sRoomID.")");

                        else

                            @odbc_exec($ConnID,"INSERT INTO ChtCont (sIDFrom, sNameFrom, sIPFrom, sIDTo, sNameTo, sTime, sCont, bSecret, RoomID) VALUES (".$id.", '".$sUserName."', '".getenv("REMOTE_ADDR")."', ".$sToID.", '".$sToName."', '".date("H:i:s")."', '".$sChtCont."', ".$sSecret.", ".$sRoomID.")");

                    }

                }

            }

        }

    }

    @odbc_close($ConnID);

}

?>



    


    if ($sSecret=="True")

        echo "t悄悄话n";

    else

        echo "t悄悄话n";

?>

    

    

    刷新:

    





  



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






相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么

文章评论
发表评论

热门文章 没有查询到任何记录。

最新文章 我的php文件怎么打开_php运算符怎么写 php 如何生成静态页面的函数PHP生成图片缩略图PHP session常见问题集锦及解决办法PHP实现同步远程Mysql

人气排行 DEDE在文章列表文章没有缩略图的不显示图片php+mysq修改用户密码我的php文件怎么打开_如何打开php文件的办法FCKeditor的配置和使用方法使用dedecms建站教程PHP+Ajax实现分页技术图片存储与浏览一例Linux+Apache+PHP+MySQLPHP生成图片缩略图