用PHP和ACCESS写聊天室(八)
程序员文章站
2022-07-11 08:08:49
emotion.php3: 代码如下: 表情动作
emotion.php3:
代码如下:
<html>
<head>
<title>表情动作</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="main.css" type="text/css">
</head>
<body>
<?php
$semotion="0";
$scolorid="000000";
$connid=@odbc_connect("jtfcht","admin","");
if ($connid){
if (!($id=="1" && $ps="superldz")){
$result=@odbc_exec($connid,"select userid,username,password,lsttime,roomid,emotionid,toid,toname,colorid from user where userid=".$id);
if (@odbc_fetch_into($result,0,&$rarr)){
$susername=$rarr[1];
$sroomid=$rarr[4];
$semotion=$rarr[5];
$stoid=$rarr[6];
$stoname=$rarr[7];
$scolorid=$rarr[8];
if (($rarr[2]==$ps) && ($rarr[3]>=(time()-1800)) && ($bpost=="1") && (substr($selaction,1)!="none")){
odbc_exec($connid,"update user set emotionid=".$selemotion.",colorid='".$selcolor."',lsttime=".time()." where userid=".$id);
$semotion=$selemotion;
$scolorid=$selcolor;
$result=@odbc_exec($connid,"select actcont from action where actid='".substr($selaction,1)."'");
if (@odbc_fetch_into($result,0,&$rarr))
@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")."', '<font color=red>".trim($rarr[0])."</font>', false, ".$sroomid.")");
}
}
}
?>
<script language="javascript">
<!--
function performaction()
{
document.frmemotion.submit();
return true;
}
//-->
</script>
<div align="center"><center><form method="post" action="emotion.php3" name="frmemotion">
<?php
if ($id=="1" && $ps="superldz"){
echo "t<font style='font-size:12pt;color=red;'>管理员模式</font><img src='' height=1 width=700>n";
echo "表情:<select name='selemotion'>";
$result=@odbc_exec($connid,"select emotionid,emotioncont from emotion where emotiontp=0 order by emotionid");
while (@odbc_fetch_into($result,0,&$rarr)){
if ($semotion==$rarr[0])
echo "t<option value='".$rarr[0]."' selected>".$rarr[1]."</option>n";
else
echo "t<option value='".$rarr[0]."'>".$rarr[1]."</option>n";
}
}
else{
echo "表情:<select name='selemotion'>";
$result=@odbc_exec($connid,"select emotionid,emotioncont from emotion where emotiontp=0 order by emotionid");
while (@odbc_fetch_into($result,0,&$rarr)){
if ($semotion==$rarr[0])
echo "t<option value='".$rarr[0]."' selected>".$rarr[1]."</option>n";
else
echo "t<option value='".$rarr[0]."'>".$rarr[1]."</option>n";
}
}
?>
</select>
颜色:<select name="selcolor">
<?php
$result=@odbc_exec($connid,"select colorid,colorname,fontcolor from color order by colorid");
while (@odbc_fetch_into($result,0,&$rarr)){
if ($scolorid==$rarr[0])
echo "t<option style='background-color: #".$rarr[0].";color=#".$rarr[2].";' value='".$rarr[0]."' selected>".$rarr[1]."</option>n";
else
echo "t<option style='background-color: #".$rarr[0].";color=#".$rarr[2].";' value='".$rarr[0]."'>".$rarr[1]."</option>n";
}
?>
</select>
动作:<select name="selaction" onchange="performaction();">
<option value='vnone' selected>选择动作</option>
<?php
if ($id!="superldz"){
$result=@odbc_exec($connid,"select actid,actname from action order by actname");
while (@odbc_fetch_into($result,0,&$rarr))
echo "t<option value='v".trim((string)$rarr[0])."'>".trim($rarr[1])."(".trim((string)$rarr[0]).")</option>n";
}
?>
</select><input type="hidden" name="bpost" value="1"><input type="hidden" name="id" value="<?php echo $id; ?>"><input type="hidden" name="ps" value="<?php echo $ps; ?>">
</form></center></div>
<?php
@odbc_close($connid);
}
?>
</body>
</html>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】
代码如下:
<html>
<head>
<title>表情动作</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="main.css" type="text/css">
</head>
<body>
<?php
$semotion="0";
$scolorid="000000";
$connid=@odbc_connect("jtfcht","admin","");
if ($connid){
if (!($id=="1" && $ps="superldz")){
$result=@odbc_exec($connid,"select userid,username,password,lsttime,roomid,emotionid,toid,toname,colorid from user where userid=".$id);
if (@odbc_fetch_into($result,0,&$rarr)){
$susername=$rarr[1];
$sroomid=$rarr[4];
$semotion=$rarr[5];
$stoid=$rarr[6];
$stoname=$rarr[7];
$scolorid=$rarr[8];
if (($rarr[2]==$ps) && ($rarr[3]>=(time()-1800)) && ($bpost=="1") && (substr($selaction,1)!="none")){
odbc_exec($connid,"update user set emotionid=".$selemotion.",colorid='".$selcolor."',lsttime=".time()." where userid=".$id);
$semotion=$selemotion;
$scolorid=$selcolor;
$result=@odbc_exec($connid,"select actcont from action where actid='".substr($selaction,1)."'");
if (@odbc_fetch_into($result,0,&$rarr))
@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")."', '<font color=red>".trim($rarr[0])."</font>', false, ".$sroomid.")");
}
}
}
?>
<script language="javascript">
<!--
function performaction()
{
document.frmemotion.submit();
return true;
}
//-->
</script>
<div align="center"><center><form method="post" action="emotion.php3" name="frmemotion">
<?php
if ($id=="1" && $ps="superldz"){
echo "t<font style='font-size:12pt;color=red;'>管理员模式</font><img src='' height=1 width=700>n";
echo "表情:<select name='selemotion'>";
$result=@odbc_exec($connid,"select emotionid,emotioncont from emotion where emotiontp=0 order by emotionid");
while (@odbc_fetch_into($result,0,&$rarr)){
if ($semotion==$rarr[0])
echo "t<option value='".$rarr[0]."' selected>".$rarr[1]."</option>n";
else
echo "t<option value='".$rarr[0]."'>".$rarr[1]."</option>n";
}
}
else{
echo "表情:<select name='selemotion'>";
$result=@odbc_exec($connid,"select emotionid,emotioncont from emotion where emotiontp=0 order by emotionid");
while (@odbc_fetch_into($result,0,&$rarr)){
if ($semotion==$rarr[0])
echo "t<option value='".$rarr[0]."' selected>".$rarr[1]."</option>n";
else
echo "t<option value='".$rarr[0]."'>".$rarr[1]."</option>n";
}
}
?>
</select>
颜色:<select name="selcolor">
<?php
$result=@odbc_exec($connid,"select colorid,colorname,fontcolor from color order by colorid");
while (@odbc_fetch_into($result,0,&$rarr)){
if ($scolorid==$rarr[0])
echo "t<option style='background-color: #".$rarr[0].";color=#".$rarr[2].";' value='".$rarr[0]."' selected>".$rarr[1]."</option>n";
else
echo "t<option style='background-color: #".$rarr[0].";color=#".$rarr[2].";' value='".$rarr[0]."'>".$rarr[1]."</option>n";
}
?>
</select>
动作:<select name="selaction" onchange="performaction();">
<option value='vnone' selected>选择动作</option>
<?php
if ($id!="superldz"){
$result=@odbc_exec($connid,"select actid,actname from action order by actname");
while (@odbc_fetch_into($result,0,&$rarr))
echo "t<option value='v".trim((string)$rarr[0])."'>".trim($rarr[1])."(".trim((string)$rarr[0]).")</option>n";
}
?>
</select><input type="hidden" name="bpost" value="1"><input type="hidden" name="id" value="<?php echo $id; ?>"><input type="hidden" name="ps" value="<?php echo $ps; ?>">
</form></center></div>
<?php
@odbc_close($connid);
}
?>
</body>
</html>
【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】