/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright © 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: news_achrive.php
| CVS Version: 1.00
| Author: uaqboost
| Web: www.php-fusion.co.uk
+--------------------------------------------------------+
| V7 by Diemux
| www.phpfusion-mods.net
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "../../maincore.php";
require_once THEMES."templates/header.php";
include INFUSIONS."news_archive/infusion_db.php";
if (file_exists(INFUSIONS."news_archive/locale/".$settings['locale'].".php")) {
include INFUSIONS."news_archive/locale/".$settings['locale'].".php";
} else {
include INFUSIONS."news_archive/locale/English.php";
}
$nas = dbarray(dbquery("SELECT * FROM ".DB_NAS.""));
$newsorder = $nas[news_order];
$numofnews = $nas[numofnews];
if ($nas[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 "".$locale['NA_011']." | ".$locale['NA_012']." |
".$locale['NA_013']." | ".$locale['NA_002']." | ";
for ($i=$rowstart;$var[$i];$i++) {
$result2 = dbquery(
"SELECT tn.*, tu.user_id,user_name
FROM ".DB_NEWS." tn
LEFT JOIN ".DB_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 "
".$locale['NA_014']."
\n";
}
}
opentable($locale['NA_001']);
$splityears = array();
$result = dbquery("SELECT * FROM ".DB_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 ". ".$locale['NA_005']."
";
echo ". ".$locale['NA_006']."
";
echo ". ".$locale['NA_008']."
";
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_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_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]].") - (".$locale['NA_004'].")
";
}
} else {
echo "
".$locale['NA_015']."
\n";
}
closetable();
if ($listtype == "bymonth") {
tablebreak();
opentable($month);
$newsbymonth = array();
$result = dbquery("SELECT * FROM ".DB_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_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 "
".$locale['NA_009']."
\n";
}
closetable();
}
if (isset($day)) {
tablebreak();
opentable($day);
$news = array();
$result = dbquery("SELECT * FROM ".DB_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 "
".$locale['NA_003']."
\n";
closetable();
}
require_once THEMES."templates/footer.php";
?>