<?php
/************************************************************************/
/* 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                                 */
/************************************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
    Header("Location: index.php");
}


incoh();
$var = $db->XMFnum($var);
menunews();
    $aid    = substr("$aid", 0,25);
    $result = $db->sql_query("SELECT `radminsuper`, `admlanguage` FROM `".TABLE_AUTHORS."` WHERE `aid`='$aid'");
    $row    = $db->sql_fetchrow($result);
    $radminsuper = $db->XMFbin($row['radminsuper']);
    $admlanguage = stripslashes($row['admlanguage']);
    $result1 = $db->sql_query("SELECT `admins` FROM `".TABLE_MODULES."` WHERE `title`='News'");
    $result2 = $db->sql_query("SELECT `name` FROM `".TABLE_AUTHORS."` WHERE `aid`='$aid'");
    $row2    = $db->sql_fetchrow($result2);
	while ($row = $db->sql_fetchrow($result1)) {
	$xadmins = stripslashes($row['admins']);
		$admins = explode(",", $xadmins);
		$auth_user = 0;
		for ($i=0; $i < sizeof($admins); $i++) {
		$xnames = stripslashes($row2['name']);
			if ($xnames == "$admins[$i]") {
				$auth_user = 1;
			}
		}
		if ($auth_user == 1) {
			$radminarticle = 1;
		} else { $radminarticle = 0; }
	}
    echo "<center><b>"._LAST." $var "._ARTICLES."</b></center><br />";
    $result6 = $db->sql_query("SELECT `sid`, `aid`, `title`, `time`, `topic`, `informant`, `alanguage` FROM `".TABLE_STORIES."` $queryalang ORDER BY `time` DESC LIMIT 0,$var");
    echo "<center><table border=\"1\" width=\"100%\" bgcolor=\"$bgcolor1\">";
    while ($row6 = $db->sql_fetchrow($result6)) {
		$sid   = $db->XMFnum($row6['sid']);
		$aid   = stripslashes($row6['aid']);
		$said  = substr("$aid", 0,25);
		$title = stripslashes($row6['title']);
		$time  = stripslashes($row6['time']);
		$topic = $db->XMFnum($row6['topic']);
		$informant = stripslashes($row6['informant']);
		$alanguage = stripslashes($row6['alanguage']);
		$result7 = $db->sql_query("SELECT `topicname` FROM `".TABLE_TOPICS."` WHERE `topicid`='$topic'");
		$row7    = $db->sql_fetchrow($result7);
		$topicname = stripslashes($row7['topicname']);
		if ($alanguage == "") {
		    $alanguage = ""._ALL."";
		}
		formatTimestamp($time);
		echo "<tr><td align=\"left\"><b>$sid</b>"
		    ."</td><td align=\"left\" width=\"80%\">&nbsp;<a href=\"modules.php?name=News&amp;file=article&amp;sid=$sid\">$title</a>"
		    ."</td><td align=\"center\">$alanguage"
		    ."</td><td width=\"20%\" align=\"center\">$topicname";
		if ($radminarticle == 1 OR $radminsuper == 1) {
		    if (($radminarticle==1) AND ($aid == $said) OR ($radminsuper==1)) {
				echo "</td><td align=\"right\">(<a href=\"".$admin_file.".php?op=EditStory&amp;sid=$sid\">"._EDIT."</a>-<a href=\"".$admin_file.".php?op=RemoveStory&amp;sid=$sid\">"._DELETE."</a>)"
			    	."</td></tr>";
		    } else {
				echo "</td><td align=\"right\" nowrap><font class=\"content\"><i>("._NOFUNCTIONS.")</i></font>"
			    	."</td></tr>";
		    }
		} else {
		    echo "</td></tr>";
		}
    }
    echo "</table>";
    if (($radminarticle==1) OR ($radminsuper==1)) {
	echo "<center>"
	    ."<form action=\"".$admin_file.".php\" method=\"post\">"
	    .""._STORYID.": <input type=\"text\" NAME=\"sid\" SIZE=\"10\">"
	    ."<select name=\"op\">"
	    ."<option value=\"EditStory\" SELECTED>"._EDIT."</option>"
	    ."<option value=\"RemoveStory\">"._DELETE."</option>"
	    ."</select>"
	    ."<input type=\"submit\" value=\""._GO."\" />"
	    ."</form></center>";
    }
    $result8 = $db->sql_query("SELECT `pollID`, `pollTitle` FROM `".TABLE_POLL_DESC."` WHERE `artid`='0' ORDER BY `pollID` DESC LIMIT 1");
    $row8      = $db->sql_fetchrow($result8);
    $pollID    = $db->XMFnum($row8['pollID']);
    $pollTitle = stripslashes($row8['pollTitle']);
    br('1');
    Max_OpenTable();
    echo "<center><b>"._CURRENTPOLL.":</b> $pollTitle [ <a href=\"".$admin_file.".php?op=polledit&amp;pollID=$pollID\">"._EDIT."</a> | <a href=\"".$admin_file.".php?op=create\">"._ADD."</a> ]</center>";
    Max_CloseTable();
incof();