$newsorder = $archiv[news_order];
$numofnews = $archiv[numofnews];
if ($archiv[listexp] == 1){
$listexp = "AND (news_end='0'||news_end>=".time().")";
} else {
$listexp = "";
}
function listnews($var){
global $rows, $locale, $db_prefix, $rowstart, $listexp, $numofnews, $year, $month, $day, $PHP_SELF;
if ($rows !=0) {
echo "
";
echo "";
echo " ";
for ($i=$rowstart;$var[$i];$i++) {
$result2 = dbquery(
"SELECT tn.*, tu.user_id,user_name
FROM ".DB_PREFIX."news tn
LEFT JOIN ".DB_PREFIX."users tu ON tn.news_name=tu.user_id
WHERE news_id=$var[$i] AND (news_start='0'||news_start<=".time().") $listexp
GROUP BY news_id ORDER BY news_datestamp ASC"
);
$data = dbarray($result2);
echo "".$data['news_subject']." |
".$data['user_name']." |
".date('d.m.Y', $data[news_datestamp])." |
".$data['news_reads']." | ";
if ($i == $rowstart + ($numofnews - 1)) {
break;
}
}
echo " |
";
} else {
echo "
\n";
}
}
opentable(ARCHIWUM);
$splityears = array();
$result = dbquery("SELECT * FROM ".DB_PREFIX."news ORDER BY news_datestamp ASC");
if (dbrows($result)!=0) {
while ($date = dbarray($result)){
$allyears = date('Y', $date[news_datestamp]);
array_push($splityears, $allyears);
}
$yearsnum = array_count_values($splityears);
$years = array_unique($splityears);
$years = array_merge($years);
echo ". ostatnie 3 dni
";
echo ". ostatnie 7 dni
";
echo ". ostatnie 30 dni
";
echo "
";
for ($i=0;$years[$i];$i++) {
echo ". $years[$i] (".$yearsnum[$years[$i]].")
";
}
closetable();
if ($listtype == "last") {
tablebreak();
opentable($locale['NA_010']);
$newslastweek = array();
$result = dbquery("SELECT * FROM ".DB_PREFIX."news ORDER BY news_datestamp $newsorder");
if (!$rowstart) $rowstart = 0;
if (!$pre) $pre = 7;
$weektime = mktime(0, 0, 0, date("m") , date("d")-$pre, date("Y"));
while ($date = dbarray($result)){
$newstime = $date[news_datestamp];
if ($newstime >= $weektime){
$newsid = $date[news_id];
array_push($newslastweek, $newsid);
}
}
$rows = count($newslastweek);
listnews($newslastweek);
echo "
\n".makePageNav($rowstart,$numofnews,$rows,3,"$PHP_SELF?listtype=last&pre=$pre&")."\n
\n";
closetable();
} elseif (isset($year)) {
tablebreak();
opentable($year);
$splitmonths = array();
$result = dbquery("SELECT * FROM ".DB_PREFIX."news ORDER BY news_datestamp ASC");
while ($date = dbarray($result)){
$allyears = date('Y', $date[news_datestamp]);
if ($allyears == $year){
$allmonths = date('F', $date[news_datestamp]);
array_push($splitmonths, $allmonths);
}
}
$monthsnum = array_count_values($splitmonths);
$months = array_unique($splitmonths);
$months = array_merge($months);
$rows = count($months);
if ($rows !=0) {
for ($i=0;$months[$i];$i++) {
echo ". $months[$i] (".$monthsnum[$months[$i]].") - ()
";
}
} else {
echo "
\n";
}
closetable();
if ($listtype == "bymonth") {
tablebreak();
opentable($month);
$newsbymonth = array();
$result = dbquery("SELECT * FROM ".DB_PREFIX."news ORDER BY news_datestamp $newsorder");
if (!$rowstart) $rowstart = 0;
while ($date = dbarray($result)){
$allyears = date('Y', $date[news_datestamp]);
$allmonths = date('F', $date[news_datestamp]);
if ($allmonths == $month && $allyears == $year){
$newsid = $date[news_id];
array_push($newsbymonth, $newsid);
}
}
$rows = count($newsbymonth);
listnews($newsbymonth);
echo "
\n".makePageNav($rowstart,$numofnews,$rows,3,"$PHP_SELF?listtype=bymonth&year=$year&month=$month&")."\n
\n";
closetable();
} elseif (isset($month)) {
tablebreak();
opentable($month);
$splitdays = array();
$result = dbquery("SELECT * FROM ".DB_PREFIX."news ORDER BY news_datestamp ASC");
while ($date = dbarray($result)){
$allyears = date('Y', $date[news_datestamp]);
$allmonths = date('F', $date[news_datestamp]);
if ($allmonths == $month && $allyears == $year){
$alldays = date('d', $date[news_datestamp]);
array_push($splitdays, $alldays);
}
}
$daysnum = array_count_values($splitdays);
$days = array_unique($splitdays);
$days = array_merge($days);
$rows = count($days);
if ($rows !=0) {
for ($i=0;$days[$i];$i++) {
if ( $days[$i] == 1 or $days[$i] == 21 or $days[$i] == 31) {
$sub = "st";
} elseif ( $days[$i] == 2 or $days[$i] == 22) {
$sub = "nd";
} elseif ( $days[$i] == 3 or $days[$i] == 23) {
$sub = "rd";
} else {
$sub = "th";
}
echo ". $days[$i]$sub (".$daysnum[$days[$i]].")
";
}
} else {
echo "
\n";
}
closetable();
}
if (isset($day)) {
tablebreak();
opentable($day);
$news = array();
$result = dbquery("SELECT * FROM ".DB_PREFIX."news ORDER BY news_datestamp $newsorder");
if (!$rowstart) $rowstart = 0;
while ($date = dbarray($result)){
$allyears = date('Y', $date[news_datestamp]);
$allmonths = date('F', $date[news_datestamp]);
$alldays = date('d', $date[news_datestamp]);
if ($alldays == $day && $allmonths == $month && $allyears == $year){
$newsid = $date[news_id];
array_push($news, $newsid);
}
}
$rows = count($news);
listnews($news);
echo "
\n".makePageNav($rowstart,$numofnews,$rows,3,"$PHP_SELF?listtype=bymonth&year=$year&month=$month&day=$day&")."\n
\n";
closetable();
}
}
} else {
echo "
\n";
closetable();
}