Просмотр файла katrinka.ru/admin/chat.php

Размер файла: 8Kb
<?php
  include '../wap/config.php';
  include '../wap/guestbook/mylib.php';
  include 'acl.php';
  $addr=$_SERVER['REMOTE_ADDR'];
  list ($aid, $pl) = priv_level();
#  if (($r==16)&&($aid!=1)&&($aid!=18172)) exit;
  if (($r==18)&&($pl<4)) exit;
  $ppp=100;
  if ($addr=='217.118.66.232') $ppp=20;
  if (($r==18)&&($pl!=4)) exit;
  if (!($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass"))) {
    echo ("пЫЙВЛБ РПДЛМАЮЕОЙС Л вд!\n");
	exit;
  }
  pg_query($conn,"SET CLIENT_ENCODING TO 'KOI8';");
  if (($_GET['r']==0)&&($action=='')) {
	$res=pg_query($conn,"select min(id) from chat_rooms;");
	$r=pg_result($res,0,0);
	$link=sprintf("Location: chat.php?r=%s", $r);
	header($link);
	pg_close($conn);
	exit;
  }

if ($action=='') {
  $res=pg_query($conn,"select name_eng,name_rus from chat_rooms where id='$r';");
  if (!pg_numrows($res)) { pg_close($conn); exit; }
  $room=pg_result($res,0,1); if ($room=='') $room=pg_result($res,0,0);
  print "<html><head>\n";
  print "<title>WAP CHAT: ".$room."</title>\n"; ?>
</head>
<frameset cols="*,150">
  <frameset rows="*,40">
<?php print "<frame name=\"main\" scrolling=\"auto\" noresize src=\"chat.php?action=main&amp;r=".$r."\">\n";
print "<frame name=\"commands\" scrolling=\"no\" noresize src=\"chat.php?action=add&amp;r=".$r."\">\n"; ?>
  </frameset>
  <frameset rows="240,*">
<?php print "<frame name=\"rooms\" scrolling=\"auto\" noresize src=\"chat.php?action=rooms&amp;r=".$r."\">\n";
print "<frame name=\"users\" scrolling=\"auto\" noresize src=\"chat.php?action=users&amp;r=".$r."\">\n"; ?>
  </frameset>
</frameset>
<?php }

if ($action=='main') {
  header("Cache-Control: no-cache"); ?>
<html>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="30">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" content="no-cache">
</head>
<body>
<?php
  $offset=$p*$ppp;
  $mstate[0]='РХВМЙЛХЕФУС';
  $mstate[1]='<font color=red>ое РХВМЙЛХЕФУС</font>';
  pg_query($conn,"SET CLIENT_ENCODING TO 'KOI8';");
  $timex=time()-3600;
  if (($r==13)||($r==18)) $timex=time()-86400;
  if ($r!=18) {
  	$res=pg_query($conn,"select chat.id,chat.fr_u,chat.to_u,chat.message,chat.time,users.id,users.login,users.moder,chat.agent,chat.host,users.access,chat.flag from chat,users where chat.fr_u=users.id and chat.room='$r' and chat.time>'$timex' order by chat.id desc limit $ppp offset $offset;");
  } else {
  	$res=pg_query($conn,"select chat_tet.id,chat_tet.fr_u,chat_tet.to_u,chat_tet.message,chat_tet.time,users.id,users.login,users.moder,chat_tet.agent,chat_tet.host,users.access from chat_tet,users where chat_tet.fr_u=users.id and chat_tet.time>'$timex' order by chat_tet.id desc limit $ppp offset $offset;");
  }
  $mp=floor(($numrec-1)/$ppp);
#  print "<center>уФТБОЙГЩ: ";
#  for ($i=0;$i<=$mp;$i++) if ($i==$p) print $i." "; else print "<a href=\"book.php?p=".$i."\">".$i."</a>\n";
#  print "<font size=1 face=arial>(чЩЧПД РП ".$ppp." РПУФПЧ ОБ УФТБОЙГХ)</font></center>\n";

  for ($i=0;$i<pg_numrows($res);$i++) {

    $message=pg_result($res,$i,3);
	$message=smileys($message);
	$id=pg_result($res,$i,0);
	$uid=pg_result($res,$i,5);
	$access=pg_result($res,$i,10);
	if ($r!=18) $pflag=pg_result($res,$i,11);
	$name=pg_result($res,$i,6);
	$to=pg_result($res,$i,2);
	if ($to) {
		$res_to=pg_query($conn,"select login from users where id='$to';");
		$name_to=pg_result($res_to,0,0);
	}
	if ($access==4) $name = sprintf("<b><i>%s</i></b>", pg_result($res,$i,6));
	if (($access==2)||($access==3)) $name = sprintf("<b>%s</b>", pg_result($res,$i,6));
	if ($access==1) $name = sprintf("<i>%s</i>", pg_result($res,$i,6));
	$mtime=strftime("%H:%M", pg_result($res,$i,4));
	$ban=pg_result($res,$i,7);
	$agent=pg_result($res,$i,8);
#	$host=sprintf("%s [%s]", gethostbyaddr(pg_result($res,$i,9)), pg_result($res,$i,9));
	list ($opname, $chatok) = check_op(pg_result($res,$i,9));
	$host=sprintf("[%s] - %s", pg_result($res,$i,9), $opname);
	if ($ban) { 
		$status=sprintf("<font color=red size=1>[B]</font>");
		$cstatus=sprintf("<font color=red>B</font>");
	} else {
		$status=sprintf("<font size=1>[<a href=user_ban.php?id=%d&l=2&r=%d target=_top title=\"ъБВБОЙФШ\">B</a>] [<a href=user_kick.php?id=%d&l=2&r=%d target=_top title=\"лЙЛ\">K</a>]</font>", $uid, $r, $uid, $r);
		$cstatus=sprintf("<a href=user_banclear.php?id=%d>C</a>", $uid);
	}
	if ($to)
		print "<font size=1>[<a href=\"chat_del.php?id=".$id."&amp;r=".$r."\" title=\"хДБМЙФШ РПУФ\">x</a>]</font> ".$status." <a href=\"user_edit.php?id=".$uid."&amp;l=2&amp;r=".$r."\" target=_top title=\"".$agent." ".$host."\">".$name." -&gt;".$name_to." ".$mtime." &gt;</a> ".$message."<br>\n";
	else
		if ($pflag==1) {
			print "<font size=1>[<a href=\"chat_del.php?id=".$id."&amp;r=".$r."\" title=\"хДБМЙФШ РПУФ\">x</a>]</font> ".$status." <a href=\"user_edit.php?id=".$uid."&amp;l=2&amp;r=".$r."\" target=_top title=\"".$agent." ".$host."\"> * [".$mtime."]</a> ".$name." ".$message."<br>\n";
		} else {
			print "<font size=1>[<a href=\"chat_del.php?id=".$id."&amp;r=".$r."\" title=\"хДБМЙФШ РПУФ\">x</a>]</font> ".$status." <a href=\"user_edit.php?id=".$uid."&amp;l=2&amp;r=".$r."\" target=_top title=\"".$agent." ".$host."\">".$name." ".$mtime." &gt;</a> ".$message."<br>\n";
		}
  }

#  print "<center>уФТБОЙГЩ: ";
#  for ($i=0;$i<=$mp;$i++) if ($i==$p) print $i." "; else print "<a href=\"book.php?p=".$i."\">".$i."</a>\n";
#  print "<font size=1 face=arial>(чЩЧПД РП ".$ppp." РПУФПЧ ОБ УФТБОЙГХ)</font></center>\n";
print "</body>\n";

}

if ($action=='add') { ?>
<html><head>
</head><body>

<script language=javascript type=text/javascript>
<!--
function ins(name){
var input=window.document.message.message;
input.value=input.value+name+", ";
}
function insp(name){
var input=window.document.message.to;
input.value=name;
}
-->
</script>

<FORM NAME="message" METHOD=POST ACTION="chat_add.php">
<input name="to" type="text" size="10" value="">
<input type="text" name="message" size="70">
<?php print "<input type=\"hidden\" name=\"r\" value=\"".$r."\">\n"; ?>
<INPUT TYPE=SUBMIT VALUE="рЕТЕУМБФШ">
</FORM>
</body>
<?php }

if (($action=='users')||($action=='rooms')) {
  header("Cache-Control: no-cache"); ?>
<html>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="60">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" content="no-cache">
</head>
<body>

<center>
<?php
	$res=pg_query($conn,"select id,name_eng,name_rus from chat_rooms order by id;");
	$rows=pg_numrows($res);
	$timex=time()-300;
	for ($i=0; $i<$rows; $i++) {
		$room=pg_result($res,$i,2);
		$id=pg_result($res,$i,0);
#		if (($id==16)&&($aid!=1)&&($aid!=18172)) continue;
		if ($room=='') $room=pg_result($res,$i,1);
		if ($id==$r) {
			if ($r!=18) {
				$res_who=pg_query($conn,"select distinct chat.fr_u,users.login,users.access from chat,users where chat.time > '$timex' and chat.room='$r' and users.id=chat.fr_u and users.moder=0;");
			} else {
				$res_who=pg_query($conn,"select distinct chat_tet.fr_u,users.login,users.access from chat_tet,users where chat_tet.time > '$timex' and users.id=chat_tet.fr_u and users.moder=0;");
			}
			$rows_who=pg_numrows($res_who);
			if ($action=='rooms') print $room." (".$rows_who.")<br>\n";
		} else {
			$res_cnt=pg_query($conn,"select distinct chat.fr_u from chat where chat.time > '$timex' and chat.room='$id';");
			$rows_cnt=pg_numrows($res_cnt);
			if ($action=='rooms') print "<a href=\"chat.php?r=".$id."\" target=_top title=\"рЕТЕКФЙ Ч ЛПНОБФХ\">".$room." (".$rows_cnt.")</a><br>\n";
		}
	}
	if ($action=='users') {
	for ($i=0; $i<$rows_who; $i++) {
		$uid=pg_result($res_who,$i,0);
		$access=pg_result($res_who,$i,2);
		$name=pg_result($res_who,$i,1);
		$iname=pg_result($res_who,$i,1);
		if ($access==1) $name=sprintf("<i>%s</i>", pg_result($res_who,$i,1));
		if ($access==4) $name=sprintf("<b><i>%s</i></b>", pg_result($res_who,$i,1));
		if (($access==2)||($access==3)) $name=sprintf("<b>%s</b>", pg_result($res_who,$i,1));
		print "<a href=\"javascript:top.commands.ins('".$iname."');\")\" title=\"чУФБЧЙФШ ОЙЛ\">".$name."</a> <a href=\"javascript:top.commands.insp('".$iname."');\")\" title=\"пФРТБЧЙФШ ру\">ру</a><br>\n";
	}
	}
?>
	</center>
</body>
<?php }

pg_close($conn); ?>
</html>