<?php
include '../wap/config.php';
include 'acl.php';
list ($aid, $pl) = priv_level();
header("Cache-Control: no-cache");
$lang=$_GET['lang'];
$r=htmlspecialchars(trim($_GET['r']),ENT_QUOTES);
$mot=1;
?>
<html>
<head>
<title>лФП ЗДЕ</title>
<META HTTP-EQUIV="Refresh" CONTENT="300">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" content="no-cache">
</head>
<?php
if (!($conn=pg_connect("host=$dbhost port=$dbport dbname=$dbname user=$dbuser password=$dbpass")))
{ ?>
<body>
<p align="center">
Ошибка подключения к БД<br/>
<a href="/">На главную</a>
</p>
</body>
</html>
<?php
exit;
}
$uid=0;
$access=1;
print "<body>\n";
print "<p>\n";
pg_query($conn,"SET CLIENT_ENCODING TO 'KOI8';");
$res=pg_query($conn,"select id,name_eng,name_rus,flag from chat_rooms order by id;");
$rows=pg_numrows($res);
$timex=time()-300;
$res_cnt_t=pg_query($conn,"select distinct chat.fr_u,users.login,users.id,users.access from chat,users where users.id=chat.fr_u and users.moder=0 and chat.time > '$timex';");
$total=pg_numrows($res_cnt_t);
print "<table>\n";
print "<tr><td>лПНОБФБ</td><td>лФП ФХФ</td></tr>\n";
for ($i=0; $i<$rows; $i++) {
$flag=pg_result($res,$i,3);
$room='';
$rid=pg_result($res,$i,0);
if (($rid==16)&&($aid!=1)&&($aid!=2)) continue;
if ($lang!='eng') $room=pg_result($res,$i,2);
if (($flag!=1)||(($flag==1)&&($access))) {
if ($room=='') $room=pg_result($res,$i,1);
if ($rid!=18) {
$res_cnt=pg_query($conn,"select distinct chat.fr_u,users.login,users.id,users.access from chat,users where users.id=chat.fr_u and users.moder=0 and chat.time > '$timex' and chat.room='$rid';");
} else {
$res_cnt=pg_query($conn,"select distinct chat_tet.fr_u,users.login,users.id,users.access from chat_tet,users where users.id=chat_tet.fr_u and users.moder=0 and chat_tet.time > '$timex';");
}
$rows_cnt=pg_numrows($res_cnt);
print "<tr><td><a href=\"chat.php?r=".$rid."&lang=".$lang."\">".$room." (".$rows_cnt.")</a></td><td>\n";
if ((!$r)||($r==$rid)) {
for ($j=0; $j<$rows_cnt; $j++) {
$uid=pg_result($res_cnt,$j,2);
$acc=pg_result($res_cnt,$j,3);
$login=pg_result($res_cnt,$j,1);
if ($acc==1) $login=sprintf("<i>%s</i>", pg_result($res_cnt,$j,1));
if (($acc==2)||($acc==3)) $login=sprintf("<b>%s</b>", pg_result($res_cnt,$j,1));
if ($acc==4) $login=sprintf("<b><i>%s</i></b>", pg_result($res_cnt,$j,1));
print "<a href=\"user_edit.php?id=".$uid."&r=".$rid."&lang=".$lang."\">".$login."</a> \n";
}
print "</td></tr>\n";
}
}
}
print "</table>\n";
print "Total: ".$total."<br>\n";
pg_close($conn);
?>
</p>
</body>
</html>