<?php
/**
 * pragmaMx - Web Content Management System.
 * Copyright by pragmaMx Developer Team - http://www.pragmamx.org
 *
 * pragmaMx 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 3 of the License, or
 * (at your option) any later version.
 */

defined('mxMainFileLoaded') or die('access denied');

mxGetLangfile('Stories_Archive');

$a = 0;
$min = (isset($_GET['min'])) ? intval($_GET['min']) : 0;
$max = (isset($_GET['max'])) ? intval($_GET['max']) : 250;

$pagetitle = _STORIESARCHIVE . ", " . _ALLSTORIESARCH;
include("header.php");
title(_STORIESARCHIVE . ': ' . _ALLSTORIESARCH);
OpenTable();
echo "<table border=\"1\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\"><tr>"
 . "<th>" . _ARTICLES . "</th>"
 . "<th>" . _COMMENTS . "</th>"
 . "<th>" . _READS . "</th>"
 . "<th>" . _USCORE . "</th>"
 . "<th>" . _DATE . "</th>"
 . "<th>" . _ACTIONS . "</th></tr>";
$result = sql_query("select sid, catid, title, time, comments, counter, topic, alanguage, score, ratings from ${prefix}_stories WHERE `time` <= now() ORDER BY `time` DESC limit " . intval($min) . "," . intval($max));
$numrows = sql_num_rows(sql_query("select * from ${prefix}_stories WHERE `time` <= now()"));
while (list($sid, $catid, $title, $time, $comments, $counter, $topic, $alanguage, $score, $ratings) = sql_fetch_row($result)) {
    $time = explode(" ", $time);
    $actions = '';
    if (mxModuleAllowed('Recommend_Us')) {
        $actions = "<a href=\"modules.php?name=News&amp;file=print&amp;sid=$sid\">" . mxCreateImage('images/print.gif', _PRINTER) . "</a>&nbsp;<a href=\"modules.php?name=News&amp;file=friend&amp;sid=$sid\">" . mxCreateImage('images/friend.gif', _FRIEND) . "</a>";
    }
    if ($score != 0) {
        $rated = substr($score / $ratings, 0, 4);
    } else {
        $rated = 0;
    }
    if (empty($catid)) {
        $title = "<a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid\">$title</a>";
    } else {
        $res = sql_query("select title from ${prefix}_stories_cat where catid=" . intval($catid));
        list ($cat_title) = sql_fetch_row($res);
        $title = "<a href=\"modules.php?name=News&amp;file=categories&amp;catid=$catid\"><i>$cat_title</i></a>: <a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid\">$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\" width=\"15\" height=\"8\">";
    } else {
        $lang_img = "<strong><big><b>&middot;</b></big></strong>";
    }
    echo "<tr>"
     . "<td align=\"left\">$lang_img $title</td>"
     . "<td align=\"center\">$comments</td>"
     . "<td align=\"center\">$counter</td>"
     . "<td align=\"center\">$rated</td>"
     . "<td align=\"center\">$time[0]</td>"
     . "<td align=\"center\">$actions</td></tr>";
}
echo "</table>";
CloseTable();
include("footer.php");

?>