<?php
try
{
/* CONFIG */
$fid = 7; // FIDY DZIAŁÓW Z NEWSAMI
$podziel = 3; // ILOŚĆ NEWSÓW NA STRONIE
$adres_strony_full = 'http://www.piecdwa.pl/index.php'; // PEŁEN ADRES DO PLIKU, W KTÓRYM WYŚWIETLANE SĄ NEWSY
$adres_forum_full = 'http://www.piecdwa.pl/forum'; // PEŁEN ADRES FORUM
$adres_forum_short = '/forum'; // ŚCIEŻKA WZGLĘDNA FORUM
/* KONIEC CONFIGU */
define('IN_MYBB', NULL);
define('NO_ONLINE', 1);
require_once($_SERVER["DOCUMENT_ROOT"].$adres_forum_short.'/global.php');
require_once($_SERVER["DOCUMENT_ROOT"].$adres_forum_short.'/inc/class_parser.php');
$parser = new postParser;
$parser_options = array(
'allow_html' => 0,
'allow_mycode' => 1,
'allow_imgcode' => 1,
'filter_badwords' => 1,
'allow_smilies' => 0
);
if (isset($_GET['show']))
{
$ile = trim(strip_tags($_GET['show']));
if ($ile <= 0)
{
$ile = 1;
}
}
else
{
$ile = 1;
}
$sql = $db->simple_select('posts', 'COUNT(`tid`)', '`fid` IN ('.$fid.') AND `visible` = 1 AND `replyto` = 0');
$row = $db->fetch_array($sql);
if ($row['COUNT(`tid`)'] <= 0)
{
throw new Exception('<div class="box"><h2 class="title">Brak newsów</h2><div class="content">Brak newsów w tej kategorii.</div></div>');
}
$count_rekords = $row['COUNT(`tid`)'];
$podstron = ceil($count_rekords / $podziel);
if ($ile >= $podstron)
{
$ile = $podstron;
}
$begin = $podziel * $ile - $podziel;
$sql = $db->simple_select('posts', '`tid`, `subject`, `uid`, `username`, `dateline`, `message`', '`fid` IN ('.$fid.') AND `visible` = 1 AND `replyto` = 0', array('order_by' => '`tid` DESC', 'limit' => $podziel, 'limit_start' => $begin));
if ($ile > 1)
{
$previous = $ile - 1;
}
else
{
$previous = $ile;
}
if ($ile < $podstron)
{
$next = $ile + 1;
}
else
{
$next = $ile;
}
switch ($ile)
{
case 1:
$before = 1;
break;
case 2:
$before = 1;
break;
case 3:
$before = 1;
break;
default:
$before = $ile - 3;
break;
}
switch ($ile)
{
case $podstron:
$site = $ile;
break;
case $podstron - 1:
$site = $ile + 1;
break;
case $podstron - 2:
$site = $ile + 2;
break;
default:
$site = $ile + 3;
break;
}
echo '<div class="content">';
echo '<p><a href="'.$adres_strony_full.'?show=1">1</a> ';
echo '<a href="'.$adres_strony_full.'?show='.$previous.'">«</a> ';
for ($link = $before; $link <= $site; $link++)
{
echo '<a href="'.$adres_strony_full.'?show='.$link.'">'.$link.'</a> ';
}
echo '<a href="'.$adres_strony_full.'?show='.$next.'">»</a> ';
echo '<a href="'.$adres_strony_full.'?show='.$podstron.'">'.$podstron.'</a>';
echo '</p></div>';
while ($news = $db->fetch_array($sql))
{
echo '<h2 style="background-image: url(asd2.jpg); background-repeat: repeat; text-decoration: none; font-size: 14px; text-align: left; padding: 5px; border-width: 1px; border-style: groove; border-color: white; font-weight: bold;"><a href="'.$adres_forum_full.'/'.get_thread_link($news['tid']).'">'.htmlspecialchars_uni($parser->parse_badwords($news['subject'])).'</a></h2>';
echo '<div style="background-color: none; background-repeat: repeat;" class="content">'.$parser->parse_message($news['message'], $parser_options);
echo '<p style="text-align: right;"><hr><b>N</b>apisane '.my_date($mybb->settings['dateformat'], $news['dateline']).' o godzinie '.my_date($mybb->settings['timeformat'], $news['dateline']).', przez <strong><a href="'.$adres_forum_full.get_profile_link($news['uid']).'">'.$news['username'].'</a></strong>.</p>';
echo '</div>';
}
echo '<div class="content">';
echo '<p><a href="'.$adres_strony_full.'?show=1">1</a> ';
echo '<a href="'.$adres_strony_full.'?show='.$previous.'">«</a> ';
for ($link = $before; $link <= $site; $link++)
{
echo '<a href="'.$adres_strony_full.'?show='.$link.'">'.$link.'</a> ';
}
echo '<a href="'.$adres_strony_full.'?show='.$next.'">»</a> ';
echo '<a href="'.$adres_strony_full.'?show='.$podstron.'">'.$podstron.'</a>';
echo '</p></div></div>';
}
catch(Exception $e)
{
echo $e->getMessage();
}
?>