<?PHP
/************************************************************************/
/* DUNE by NPDS                                                         */
/* ===========================                                          */
/*                                                                      */
/* From ALL STORIES Add-On ... ver. 1.4.1a                              */
/*                                                                      */
/* NPDS Copyright (c) 2002-2007 by Philippe Brunier                     */
/*                                                                      */
/* 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.       */
/************************************************************************/
if (strstr($ModPath,"..") || strstr($ModStart,"..") || stristr($ModPath, "script") || stristr($ModPath, "cookie") || stristr($ModPath, "iframe") || stristr($ModPath, "applet") || stristr($ModPath, "object") || stristr($ModPath, "meta") || stristr($ModStart, "script") || stristr($ModStart, "cookie") || stristr($ModStart, "iframe") || stristr($ModStart, "applet") || stristr($ModStart, "object") || stristr($ModStart, "meta")) {
   die();
}
if (!function_exists("Mysql_Connexion")) {
   include ("mainfile.php");
}

   include ("modules/$ModPath/archive-stories.conf.php");
   include ("modules/$ModPath/cache.timings.php");
   if (!$start) {$start=0;}
   include("header.php");
   // Include cache manager
   if ($SuperCache) {
      $cache_obj = new cacheManager();
      $cache_obj->startCachingPage();
   }
   if (($cache_obj->genereting_output==1) or ($cache_obj->genereting_output==-1) or (!$SuperCache)) {
      opentable();
      echo "<table width=\"100%\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\">\n";
      echo "<tr class=\"header\" align=\"center\"><td>".translate("Articles")."&nbsp;</td><td>".translate("reads")."</td><td>".translate("Posted on")."</td><td>".translate("Author")."</td><td>&nbsp;</td></tr>";

      if (!$count) {
         $result0 = sql_query("SELECT sid FROM ".$NPDS_Prefix."stories where archive='0'");
         $count=sql_num_rows($result0);
      }
      $xtab=news_aff("libre", "where archive='0' ORDER BY sid DESC limit $start,$maxcount", $start, $maxcount);
      $ibid=0;
      $story_limit=0;
      if ($ibid=theme_image("box/print.gif")) {$imgtmpP=$ibid;} else {$imgtmpP="images/print.gif";}
      if ($ibid=theme_image("box/friend.gif")) {$imgtmpF=$ibid;} else {$imgtmpF="images/friend.gif";}
      while (($story_limit<$maxcount) and ($story_limit<sizeof($xtab))) {
        $rowcolor=tablos();
        list($s_sid, $catid, $aid, $title, $time, $hometext, $bodytext, $comments, $counter, $topic, $informant) = $xtab[$story_limit];
        $story_limit++;

        if ($catid!=0) {
            list($cattitle) = sql_fetch_row(sql_query("select title from ".$NPDS_Prefix."stories_cat where catid='$catid'"));
        }
        $printP = "<a href=\"print.php?sid=$s_sid\"><img src=\"".$imgtmpP."\" border=\"0\" Alt=\"".translate("Printer Friendly Page")."\"></a>&nbsp;";
        $sendF = "<a href=\"friend.php?op=FriendSend&amp;sid=$s_sid\"><img src=\"".$imgtmpF."\" border=\"0\" Alt=\"".translate("Send this Story to a Friend")."\"></a>";
        $sid = $s_sid;
        if ($catid != 0) {
            $resultm = sql_query("select title from ".$NPDS_Prefix."stories_cat where catid='$catid'");
            list($title1) = sql_fetch_row($resultm);
            $title = "<a href=\"article.php?sid=$sid&amp;mode=&amp;order=0\" class=\"noir\">$title</a> [ <a href=\"index.php?op=newindex&amp;catid=$catid\" class=\"ongl\">$title1</a> ]";
        }
        setlocale (LC_TIME, aff_langue($locale));
        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, $datetime);
        $datetime = strftime("%d-%m-%Y %T", mktime($datetime[4]+$gmt,$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
        if (cur_charset!="utf-8") {
           $datetime = ucfirst($datetime);
        }
        echo "<tr align=\"center\" $rowcolor>
        <td align=\"left\" width=\"50%\"><a href=\"article.php?sid=$sid&amp;mode=&amp;order=0\" class=\"noir\">".aff_langue($title)."</td>
        <td align=\"center\"><font size=\"1\">$counter</td>
        <td align=\"center\" align=\"25%\"><font size=\"1\">$datetime</font></td>
        <td align=\"left\"><a href=\"user.php?op=userinfo&amp;uname=$informant\" class=\"noir\"><font size=\"1\">$informant</font></a></td>
        <td align=\"center\">$printP&nbsp;$sendF</td>
        </tr>";
      }
      echo "</table><br />";
      $start=$start+$maxcount-1;
      if (($count-$start)>0) {
         if ($ibid=theme_image("box/right.gif")) {$imgtmp=$ibid;} else {$imgtmp="images/download/right.gif";}
         echo "<a href=\"modules.php?ModPath=archive-stories&amp;ModStart=archive-stories&amp;start=$start&amp;count=$count\" class=\"noir\">".translate("next matches")." <img src=\"".$imgtmp."\" border=\"0\" align=\"center\"></a>";
      }
      echo "<center><br />".translate("Nb of articles")." : $count :: [ <a href=\"modules.php?ModPath=archive-stories&amp;ModStart=archive-stories\" class=\"noir\">".translate("Go Back")."</a> ]</center>";
      closetable();
   }
   if ($SuperCache) {
      $cache_obj->endCachingPage();
   }
   include("footer.php");
?>