<?php
/**
 * $Source: /home/cvs/nukescripts/modules/Stories_Archive/includes/show_all.php,v $
 * $Revision: 1.0.0-1 $
 * $Author: cyril $
 * $Date: 2006/08/01 12:01:10 $
 * Fix 'aucun article' ( Bug 133 ) xav
 */
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') or Header("Location: index.php");

	if (!isset($min) ||  $GLOBALS['db']->XMFnum($min) <= 0) {
		$min = 0;
	}
	else $min =  $GLOBALS['db']->XMFnum($min);
	$max = 250;

	incoh( 'ShowAll', 'html',  "".CACHE_VARCHIVES1."", '1');

	title(""._STORIESARCHIVE."");
	title("$sitename: "._ALLSTORIESARCH."");
	if (isset($cookie[4])) { $r_options .= "&amp;mode=$cookie[4]"; }
	if (isset($cookie[5])) { $r_options .= "&amp;order=$cookie[5]"; }
	if (isset($cookie[6])) { $r_options .= "&amp;thold=$cookie[6]"; }
	Max_OpenTable();
	echo "<table border='0' width='100%'><tr>"
	."<td bgcolor=\"$bgcolor2\" align='left'><b>"._ARTICLES."</b></td>"
	."<td bgcolor=\"$bgcolor2\" align='center'><b>"._COMMENTS."</b></td>"
	."<td bgcolor=\"$bgcolor2\" align='center'><b>"._READS."</b></td>"
	."<td bgcolor=\"$bgcolor2\" align='center'><b>"._USCORE."</b></td>"
	."<td bgcolor=\"$bgcolor2\" align='center'><b>"._DATE."</b></td>"
	."<td bgcolor=\"$bgcolor2\" align='center'><b>"._ACTIONS."</b></td></tr>";
	$sql = "SELECT `sid`, `catid`, `title`, `time`, `comments`, `counter`, `topic`, `alanguage`, `score`, `ratings` from `".TABLE_STORIES."` order by `sid` DESC limit $min,$max";
	if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(GENERAL_ERROR, 'Could not obtain stories', '', __LINE__, __FILE__, $sql);}
	$sql2 = "select `sid` from `".TABLE_STORIES."`";
	if ( !($result2 = $GLOBALS['db']->sql_query($sql2)) )
{ query_die(GENERAL_ERROR, 'Could not obtain stories', '', __LINE__, __FILE__, $sql2);}
	$numrows  = $GLOBALS['db']->sql_numrows($result2);
	while($row = $GLOBALS['db']->sql_fetchrow($result)) {
		$sid       =  $GLOBALS['db']->XMFnum($row['sid']);
		$catid     =  $GLOBALS['db']->XMFnum($row['catid']);
		$title     = stripslashes(check_html($row['title'], "nohtml"));
		$time      = stripslashes($row['time']);
		$comments  = stripslashes($row['comments']);
		$counter   =  $GLOBALS['db']->XMFnum($row['counter']);
		$topic     =  $GLOBALS['db']->XMFnum($row['topic']);
		$alanguage =  $GLOBALS['db']->XMFlang($row['alanguage']);
		$score     =  $GLOBALS['db']->XMFnum($row['score']);
		$ratings   =  $GLOBALS['db']->XMFnum($row['ratings']);
		$time      = explode(" ", $time);
		$actions = "<a href=\"modules.php?name=News&amp;file=print&amp;sid=$sid\" target='new'><img src='images/print.gif' border='0' alt=\""._PRINTER."\" title=\""._PRINTER."\" width='15' height='11' /></a>&nbsp;<a href=\"modules.php?name=News&amp;file=friend&amp;op=FriendSend&amp;sid=$sid\"><img src='images/friend.gif' border='0' alt=\""._FRIEND."\" title=\""._FRIEND."\" width='15' height='11' /></a>";
		if ($score != 0) {
			$rated = substr($score / $ratings, 0, 4);
		} else {
			$rated = 0;
		}
		if ($catid == 0) {
			$title = "<a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid$r_options\">$title</a>";
		} elseif ($catid != 0) {
			$sql3 = "SELECT `title` from `".TABLE_STORIES_CAT."` where `catid`='$catid'";
			if ( !($result3 = $GLOBALS['db']->sql_query($sql3)) )
{ query_die(GENERAL_ERROR, 'Could not obtain stories_cat', '', __LINE__, __FILE__, $sql3);}
			$row_res   = $GLOBALS['db']->sql_fetchrow($result3);
			$cat_title = stripslashes($row_res['title']);
			$title = "<a href=\"modules.php?name=News&amp;file=categories&amp;op=newindex&amp;catid=$catid\"><i>$cat_title</i></a>: <a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid$r_options\">$title</a>";
		}
		if ($multilingual == 1) {
			if ($alanguage == "") {
				$alanguage = $language;
			}
			$alt_language = ucfirst($alanguage);
			$lang_img = "<img src=\"images/language/flag-$alanguage.png\" border='0' hspace='2' alt=\"$alt_language\" title=\"$alt_language\" />";
		} else {
			$lang_img = "<strong><big><b>&middot;</b></big></strong>";
		}
		echo "<tr>"
		."<td bgcolor=\"$bgcolor1\" align='left'>$lang_img $title</td>"
		."<td bgcolor=\"$bgcolor1\" align='center'>$comments</td>"
		."<td bgcolor=\"$bgcolor1\" align='center'>$counter</td>"
		."<td bgcolor=\"$bgcolor1\" align='center'>$rated</td>"
		."<td bgcolor=\"$bgcolor1\" align='center'>$time[0]</td>"
		."<td bgcolor=\"$bgcolor1\" align='center'>$actions</td></tr>";
	}
	echo "</table>";
	br('3');
	if (($numrows > 250) AND ($min == 0)) {
		$min = $min+250;
		$a++;
		echo "<center>[ <a href=\"modules.php?name=$module_name&amp;sa=show_all&amp;min=$min\">"._NEXTPAGE."</a> ]</center><br />";
	}
	if (($numrows > 250) AND ($min >= 250) AND ($a != 1)) {
		$pmin = $min-250;
		$min = $min+250;
		$a++;
		echo "<center>[ <a href=\"modules.php?name=$module_name&amp;sa=show_all&amp;min=$pmin\">"._PREVIOUSPAGE."</a> | <a href=\"modules.php?name=$module_name&amp;sa=show_all&amp;min=$min\">"._NEXTPAGE."</a> ]</center><br />";
	}
	if (($numrows <= 250) AND ($a != 1) AND ($min != 0)) {
		$pmin = $min-250;
		echo "<center>[ <a href=\"modules.php?name=$module_name&amp;sa=show_all&amp;min=$pmin\">"._PREVIOUSPAGE."</a> ]</center><br />";
	}
	echo "<hr size='1' noshade>"
	."<font class='content'>"._SELECTMONTH2VIEW."</font><br />";
	$sql4 = "SELECT `time` from `".TABLE_STORIES."` order by `time` DESC";
	if ( !($result4 = $GLOBALS['db']->sql_query($sql4)) )
{ query_die(GENERAL_ERROR, 'Could not obtain stories', '', __LINE__, __FILE__, $sql4);}
	echo "<ul>";
	while($row4 = $GLOBALS['db']->sql_fetchrow($result4)) {
		$time = stripslashes($row4['time']);
		ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $getdate);
		if ($getdate[2] == "01") { $month = _JANUARY; } elseif ($getdate[2] == "02") { $month = _FEBRUARY; } elseif ($getdate[2] == "03") { $month = _MARCH; } elseif ($getdate[2] == "04") { $month = _APRIL; } elseif ($getdate[2] == "05") { $month = _MAY; } elseif ($getdate[2] == "06") { $month = _JUNE; } elseif ($getdate[2] == "07") { $month = _JULY; } elseif ($getdate[2] == "08") { $month = _AUGUST; } elseif ($getdate[2] == "09") { $month = _SEPTEMBER; } elseif ($getdate[2] == "10") { $month = _OCTOBER; } elseif ($getdate[2] == "11") { $month = _NOVEMBER; } elseif ($getdate[2] == "12") { $month = _DECEMBER; }
		if ($month != $thismonth) {
			$year = $getdate[1];
			echo "<li><a href=\"modules.php?name=$module_name&amp;sa=show_month&amp;year=$year&amp;month=$getdate[2]&amp;month_l=$month\">$month, $year</a>";
			$thismonth = $month;
		}
	}
	echo "</ul>";
	br('2');
	echo "<center>"
	."<form action='modules.php?name=Search' method='post'>"
	."<input type='text' name='query' size='30' />&nbsp;"
	."<input type='submit' value=\""._SEARCH."\" />"
	."</form>"
	."[ <a href=\"modules.php?name=$module_name\">"._ARCHIVESINDEX."</a> ]</center>";
	Max_CloseTable();

	incof( 'ShowAll', 'html',  "".CACHE_VARCHIVES1."", '1' );