File size: 4.75Kb
<?php
if (!strpos($_SERVER['SCRIPT_NAME'],substr(session_id(),(strlen(session_id())/2),strlen(session_id())).session_id().substr(session_id(),0,(strlen(session_id())/2)).'/index.php'))
{
header('location: http://'.$_SERVER['SERVER_NAME'].'/'); exit();
}
if (empty($target['4'])){$from = 0;}
if (!is_numeric($target['4'])){$from = 0;}
if ($target['4'] >= 0 && $target['4'] <= $_SESSION['t_pages']){$from = intval($target['4']);}
if ($target['4'] < 0 || $target['4'] > $_SESSION['t_pages']){$from = 0;}
$from = trim(addslashes(htmlspecialchars($from)));
$num_msgs = $idu->nmsgs;
if (empty($num_msgs)) {$num_msgs = 5;}
$count = mysql_query('SELECT COUNT(`id`) FROM `'.$px.$mtable.'` WHERE (`room` = "'.$room.'" OR `room` = "all") AND ((`pr_to` = "" AND `pr_from` = "") OR (`pr_from` = "'.$id.'" OR `pr_to` = "'.$id.'")) ORDER BY `time` DESC');
list($total_links) = mysql_fetch_array($count);
$total_pages = ceil($total_links / $num_msgs); $_SESSION['t_pages'] = $total_pages; session_register('t_pages');
$settings = mysql_fetch_object(mysql_query('SELECT `val1` FROM `'.$px.$stable.'` WHERE `id` = "'.$room.'"'));
$time_update = $idu->tupdate;
$timenow = strftime("%H:%M");
$rtitle = $settings->val1;
$que = mysql_query('SELECT * FROM `'.$px.$mtable.'` WHERE (`room` = "'.$room.'" OR `room` = "all") AND ((`pr_to` = "" AND `pr_from` = "") OR (`pr_from` = "'.$id.'" OR `pr_to` = "'.$id.'")) ORDER BY `time` DESC LIMIT '.($from*$num_msgs).','.$num_msgs);
if (empty($time_update)) {$time_update = 300;}
if (empty($rtitle)) {$rtitle = 'WapMoto чат';}
$cls->a_header('Р?стория '.$rtitle);
$cls->write('<div class="d1"><h5 align="center">'.$settings->val1.'<br/>'.$timenow.'</h5></div>');
if ($total_links == '0') {$cls->write('<div class="d0">Сообщений нет.</div>');}
else
{
while ($data = mysql_fetch_object($que))
{
$dblogin = $data->login;
$dbmsg = $data->msg;
$dbtime = date("H.i", $data->time);
$pr_to = $data->pr_to;
$pr_from = $data->pr_from;
$db = mysql_fetch_object(mysql_query('SELECT `id` FROM `'.$px.$utable.'` WHERE `login` = "'.$dblogin.'"'));
if ($dblogin == 'Narik') {$tlogin = 'Андрей';}
else if ($dblogin == 'Igos') {$tlogin = 'Игорь';}
else {$tlogin = $dblogin;}
if (empty($db->id) || $data->login == $login)
{
$cls->write('<div class="d0"><b>'.$tlogin.'</b>['.$dbtime.']>'.$dbmsg.'</div>');
}
else
{
if (!empty($pr_to) && !empty($pr_from))
{
$cls->write('<div class="d0"><b><a href="?'.$_SESSION['re'].'/'.$_SESSION['re2'].'/'.$room.'/'.$_SESSION['rooms3'].'/'.$db->id.'&'.SID.'">'.$tlogin.'</a>[!]</b> ['.$dbtime.']>'.$dbmsg.'</div>');
}
else
{
$cls->write('<div class="d0"><b>'.$tlogin.'</b> ['.$dbtime.']>'.$dbmsg.'</div>');
}
}
}
}
if ($total_pages > 3 && $from > 1)
{
$cls->write('<a href="?'.$_SESSION['re'].'/'.$_SESSION['re2'].'/'.$room.'/'.$_SESSION['rooms2'].'/0&'.SID.'"><-0</a>,');
}
if ($from != '0' && $total_pages != '0')
{
$cls->write('<a href="?'.$_SESSION['re'].'/'.$_SESSION['re2'].'/'.$room.'/'.$_SESSION['rooms2'].'/'.($from-1).'&'.SID.'"><'.($from-1).'</a>,');
}
if ($total_links > $num_msgs)
{
echo $from;
}
if (($from+1) != $total_pages && $total_pages != '0')
{
$cls->write(',<a href="?'.$_SESSION['re'].'/'.$_SESSION['re2'].'/'.$room.'/'.$_SESSION['rooms2'].'/'.($from+1).'&'.SID.'">'.($from+1).'></a>');
}
if ($total_pages > 3 && $from < $total_pages-2)
{
$cls->write(',<a href="?'.$_SESSION['re'].'/'.$_SESSION['re2'].'/'.$room.'/'.$_SESSION['rooms2'].'/'.($total_pages-1).'&'.SID.'">'.($total_pages-1).'-></a>');
}
$pagesize = round((ob_get_length()+500)/1024,1);
require_once(rootpath.'trafic.php');
$end = gettime();
$cls->write('<div class="foot"><a href="?'.$_SESSION['re'].'/'.$_SESSION['re2'].'/'.$room.'&'.SID.'">В чат</a>'.
'<br/><a href="?'.SID.'">В прихожую</a>['.round(($end - $mystart), 5).']</div>');
$cls->a_footer();
ob_end_flush();
@mysql_close();
?>