<?php

if ( ! @include_once( './mainfile.php' ) ) { exit( '!! INCLUDE ERROR. ACCESS DENIED !!' ); }
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: allstories.php,v 1.5.2.2 2004/04/18 12:45:25 ajvwaay Exp $




######################################################################
# PHP-NUKE 4.4.1a : ALL STORIES Add-On ... ver. 1.4.1a
# ====================================================
#
# Adds a page listing from recent to old all stories
# in your Nuke database with categories , links, actions, counter, post date
#
# To install
#     1] copy this file as 'allstories.php' into your main directory.
#     2] add a link to 'allstories.php' using admin.php.
# See it in action at http://www.nexgear.com/allstories.php
#
#
# Original version from Ralph Roberts (ralph@abooks.com)
# Adapted for Categories and Actions for PHP-Nuke 4.4.1a
# by Denis Villechalane (duns1@free.fr)
# Copyright (c)2001
# Adapted for myPhpNuke by Brad Harris (shiloh@bmts.com)
#
# Modified by Kenneth Lee (kenneth@nexgear.com)
# [13-May-2001] to show limited stories from $fromsid to $tosid
#
# Release under GPL
# for more add-on :
# http://www.nexgear.com
######################################################################
# Version modifie
# [14-mai-2001] Pascal Le Boustouller - webmaster@i-annonces.net
######################################################################

//include("extention.inc");
//include("dbconf.$phpEx");
//if(!isset($mainfile)) { include("mainfile.php"); }
include("header.php");
OpenTable();


# articles per page
$nb_affichage = 20;


$start_time = time();



$count = 0;
$altbg = 0;

if (!isset($debut)) { $debut=0; }
   $TableRep=mysql_query("SELECT COUNT(*) FROM " . $mpnTables['stories'] . "");
   $nbe=mysql_result($TableRep, 0);

echo "<CENTER><B>".translate("All articles of"). " $sitename</B></CENTER><P>";
print ("<P>" . sprintf(translate("There are %s article(s) in total"), $nbe) . "<P>");
print ("<table width=\"100%\" cellpadding=2 border=0 cellspacing=2 bgcolor=$bgcolor3><tr bgcolor=$bgcolor2><td width=\"110\">" . translate("Topics") . "</td><td>" . translate("Articles") . "</td><td align=center width=\"50\">" . translate("Actions") . "</td><td width=\"30\" align=center>" . translate("Views") . "</td><td width=\"80\" align=center>" . translate("Posted") . "</td></tr>");

    $top=1;
    $topsuivant="allstories.php";

    $result = mysql_query("SELECT sid, catid, aid, title, time, counter, topic, informant FROM " . $mpnTables['stories'] . " ORDER BY sid DESC LIMIT $debut,$nb_affichage");
    if(!$result) {
    echo mysql_errno(). ": ".mysql_error(). "<br>"; exit();
    }
    while (list($s_sid, $catid, $aid, $title, $time, $counter, $topic, $informant) = mysql_fetch_row($result)) {
    $printP = "<a href=\"print.php?sid=$s_sid\"><img src=\"images/print.gif\" border=0 Alt=\"" . translate("Printer Friendly Page") . "\" width=15 height=11></a>";
    $sendF = "<a href=\"friend.php?op=FriendSend&sid=$s_sid\"><img src=\"images/friend.gif\" border=0 Alt=\"" . translate("Send this Story to a Friend") . "\" width=15 height=11></a>";
    $sid = $s_sid;
    if ($topic != 0) {
        $resultm = mysql_query("select topictext from " . $mpnTables['topics'] . " where topicid='$topic'");
        list($title1) = mysql_fetch_row($resultm);
        $title = "<a href=\"search.php?query=&topic=$topic\">$title1</a></td><td><a href=\"article.php?sid=$sid&mode=thread&order=0\">$title</a>";
    } else {
        $title = "&nbsp;</td><td><a href=\"article.php?sid=$sid&mode=thread&order=0\">$title</a>";
        }

if ($altbg==0) {
    print ("<tr bgcolor=$bgcolor1>");
    $altbg=1;
} else {
    print ("<tr>");
    $altbg=0;
}

echo "<td>$title</td><td align=center>$printP&nbsp;$sendF</td>
<td align=center><font size=1>$counter</td><td align=center><font size=1>".strftime(translate("datestring4"),strtotime($time)). "</font></td></tr>";
$count ++;
}

//mysql_close;

print ("</table><P>");

if ($top==1)
    {
    echo "<P><center>";

                if ($debut != 0)
                {
                echo "&lt;&lt; <a href=\"".$topsuivant."?debut=";
                $resultat = ($debut-$nb_affichage);
                        if ($resultat < 0)
                         {
                        $resultat = 0;
                        }
                echo "$resultat\">" . translate("Previous") . "</a> &lt;&lt; ";
                }

                if (($debut+$nb_affichage) < $nbe)
                {
                echo "&gt;&gt; <a href=\"".$topsuivant."?debut=";
                $final =($debut+$nb_affichage);
                        if ($final >= $nbe)
                        {
                        $final=($nbe - $nb_affichage);
                        }
                echo "$final\">" . translate("Next") . "</a> &gt;&gt;";


                }
  }
        CloseTable();
include("footer.php");
?>
