ホームページ >php教程 >php手册 >PHP と ACCESS を使用してチャット ルームを作成する (3)

PHP と ACCESS を使用してチャット ルームを作成する (3)

WBOY
WBOYオリジナル
2016-06-21 09:02:55908ブラウズ
cinput.php3
以下:


输入


<スクリプト言語="JavaScript">





function suiji($max){
srand((double)microtime()*1000000);
$x=rand();
$y=getrandmax();
$r=$x/$y*($max-1);
$r=round($r++);
$r を返します。
}

関数 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++;
}
}
$iCount を返す;
}

関数 StrDupl($sStr, $iCnt){
$ret="";
for($i=1;$i<=$iCnt;$i++)
$ret.=$sStr;
$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," 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,"< /HEAD")) $bNeed="True";
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(">",">",str_replace("<","<",$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), "")) );
$right を返します。
}

$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 @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.", 'administrator', '".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 F ROMユーザーWHERE ユーザーID=".($id));
if (@odbc_fetch_into($result,0,&$rArr)){
if ($rArr[2]==$ps){
if ($rArr[3]>=(時間) ()-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 ユーザー ID=".$id);
$bCht="True";
$bToMe="False";
if (substr($sSend,0,3)=="/t "){
$sChtCont="%m想".substr($sS終わり、 3)."";
$sSecret="False";
$bCht="False";

elseif (substr($sSend,0,3)=="/: "){
$sCht Cont="%m".substr($sSend,3 )."";
$sSecret="False";
$bCht="False";

elseif (strto lower(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ルーム WHERE RoomID=".$rArr[0]);
if (@odbc_fetch_into($result,0,&$rArr))
$sChtCont="< ;font color=gray>【系统消息】".trim(substr($sSend,3))."現在房中にあります".$rArr[0]."。
";
else
$sChtCont="【系统消息】系统了,".trim(substr($sSend,3))."目前在的房间不可识别!";

else
$s ChtCont="【システムメッセージ】".trim(substr($sSend,3))."現在はアップラインがありません。" ;
$sSecret="True";
$bCht="False";

else{
$sChtCont="<フォントカラー=gray>【システムメッセージ】「.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='".tリム(サブスト( $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($Conn ID,"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($rA) rr[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) 値(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, bシークレット、ルーム ID) 値 (".$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";
?>


刷新:



  



声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。