Write chat rooms with PHP and access (iv)
Last Update:2017-02-28
Source: Internet
Author: User
The code is as follows:
<?php
$ConnID = @odbc_connect ("Jtfcht", "admin", "");
if ($ConnID) {
@odbc_exec ($ConnID, "DELETE * from Room WHERE (Roomid is (SELECT DISTINCT roomid from User)) and roomid<>1");
$result = @odbc_exec ($ConnID, "SELECT password,lsttime,roomid,refrate from User WHERE userid=". $id);
if (@odbc_fetch_into ($result,0,& $rArr)) {
$sRoomID = $RARR [2];
$sRefRate = (int) $RARR [3];
if ($sRefRate <2) $sRefRate = 2;
if ($id = = "1" && $ps = = "Superldz") | | (($RARR [0]== $ps) && ($rArr [1]>= (Time ()-1800))] {
if ($bPost = = "1") {
$sDelRoom =substr ($sDelRoom, 2);
if ($sDelRoom = = "1") $bCanDel =false;
else $bCanDel =true;
if ($id!= "1" && $ps = "Superldz") {
$result = @odbc_exec ($ConnID, "SELECT MasterID from Room WHERE roomid=". $sDelRoom);
if (@odbc_fetch_into ($result,0,& $rArr)) {
if ($RARR [0]!= $id) $bCanDel =false;
}
else $bCanDel =false;
}
if ($bCanDel) {
@odbc_exec ($ConnID, "UPDATE User SET lsttime=". Time (). " WHERE roomid= ". $sDelRoom." and userid= ". $id);
@odbc_exec ($ConnID, "UPDATE User SET roomid=1 WHERE roomid=". $sDelRoom);
@odbc_exec ($ConnID, "DELETE * from Room WHERE roomid=". $sDelRoom);
$sRoomID = "1";
}
}
?>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Room </title>
<link rel= "stylesheet" href= "Main.css" type= "Text/css" >
<meta http-equiv= "Refresh" content= "<?php Echo ((int) ($sRefRate) *8);? >;url=room.php3?id=<?php Echo $id >&ps=<?php echo $ps; >&at=<?php echo Time ();?> ">
<script language= "JavaScript" >
<!--
function Checkvalid () {
Document.frmInRoom.selRoom.value = Document.frmRoom.selRoom.value;
return true;
}
function Alertit () {
Document.frmDelRoom.sDelRoom.value = Document.frmRoom.selRoom.value;
return confirm ("You really want to demolish this house!") ");
}
-->
</script>
<body>
<table width= "100%" border= "0" align= "center" cellpadding= "0" cellspacing= "2" >
<tr>
<TD colspan= "3" > <font style= "FONT-SIZE:10.5PT;" > Existing Rooms:</font></td>
</tr>
<form method= "POST" action= "#" Name= "Frmroom" >
<tr>
<TD align= "Center" colspan= "3" ><?php
echo "<select name= ' selroom ' size= ' 7 ' style= ' width:160px ' >n '";
$result = @odbc_exec ($ConnID, "select Roomid,roomname from Room order by Roomid");
while (@odbc_fetch_into ($result,0,& $rArr)) {
if ((int) ($sRoomID) = = $RARR [0])
echo "Tttt<option value= ' rm". $RARR [0]. "' selected> '. $RARR [1]." </option>n ";
Else
echo "Tttt<option value= ' rm". $RARR [0]. "' > ". $RARR [1]." </option>n ";
}
echo "Tttt</select>n";
?>
</td>
</tr>
</form>
<tr>
<?php
if ($id = = "1" && $ps = "Superldz") {
?>
<TD width= "align=" "Center" ></td>
<TD width= "align=" center ></td>
<?php
}
else{
?>
<form method= "POST" action= "Newroom.php3" name= "Frmnewroom" target= "Member" >
<TD align= "center" ><input type= "Submit" Name= "Newroom" value= "new" ><input type= "hidden" name= "id" value = "<?php echo $id;?>" ><input type= "hidden" name= "PS" value= "<?php echo $ps;?>" ></td>
</form>
<form method= "POST" action= "Enterrm.php3" name= "Frminroom" >
<TD align= "center" ><input type= "Submit" Name= "Cmdenter" value= "Add" ><input type= "hidden" name= "selroom "Value=" 1 "><input type=" hidden "name=" Spass "value=" "><input type=" hidden "name=" id "value=" <?php Echo $id?> "><input type=" hidden "name=" PS "value=" <?php echo $ps;?> "></td>
</form>
<?php
}
?>
<form method= "POST" action= "Room.php3" name= "Frmdelroom" >
<TD align= "center" ><input type= "Submit" Name= "Delroom" value= "Demolition Room" ><input type= "hidden" name= "Sdelroom" "Value=" 1 "><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;?> "></td>
</form>
</tr>
</table>
</body>
<?php
}
else echo "}
else echo "@odbc_close ($ConnID);
}
else echo "?>