File size: 2.51Kb
<?php
require('includes/header.php');
require('includes/utils.php');
require('includes/db.php');
$max_pages = 5;
?>
<wml>
<head><meta http-equiv="Cache-Control" content="no-cache" forua="true"/></head>
<card id="news" title="Новости">
<do type="options" name="main" label="Меню"><go href="<?php echo $_GET['login']; ?>/index.wml"/></do>
<p>
<?php
$links_list = '';
if(isset($_GET['from']))
$from = $_GET['from'];
else
$from = 0;
$login = addslashes($_GET['login']);
$links = mysql_query('SELECT count(*) FROM news l, users u WHERE u.login = "' . $login . '" AND u.id = l.user_id ORDER by date DESC ');
list($total_links) = mysql_fetch_array($links);
$total_pages = ceil($total_links / $max_pages);
$links = mysql_query('SELECT l.id as id, l.text as text, l.date as date FROM news l, users u WHERE u.login = "' . $login . '" AND u.id = l.user_id ORDER by date DESC LIMIT ' . $from * $max_pages . ', ' . $max_pages);
$months = array('января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря');
if(($n = mysql_num_rows($links)) > 0)
{
while($link = mysql_fetch_array($links, MYSQL_ASSOC))
{
$raw_date = $link['date'];
$month = (int)substr($raw_date, 5, 2);
$month = $months[$month-1];
$day = (int)substr($raw_date, 8, 2);
$hour = (int)substr($raw_date, 11, 2);
$minute = (int)substr($raw_date, 14, 2);
$links_list .= "$link[text] [$day $month, $hour:$minute]\n<br/>\n";
}
}
$banners = mysql_query('SELECT banner FROM users WHERE login = "' . $login . '"');
list($banner) = mysql_fetch_array($banners);
?>
<?php
if($banner == 'top')
echo get_random_link();
?>
Всего новостей:<?php echo $total_links; ?>
Стр. <?php if($total_pages != 0) echo $from+1; else echo '0'; ?> из <?php echo $total_pages; ?><br/>
<?php echo $links_list; ?>
<?php
if($banner == 'bottom')
echo get_random_link();
?>
<br/>
<?php
if(($from+1) != $total_pages)
{
echo "<a href=\"news.php?login=$login&from=" . ($from+1) . "\">Далее</a>";
echo "<br/>";
}
if($from != 0)
{
echo "<a href=\"news.php?login=$login&from=" . ($from-1) . "\">Назад</a>";
echo "<br/>";
}
?>
</p>
<p align="center">
</p>
</card>
</wml>