<?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");
}

    $aid = substr("$aid", 0,25);
    $result = $db->sql_query("select counter, radminsuper from ".TABLE_AUTHORS." where aid='$aid'");
    list($counter, $radminsuper) = $db->sql_fetchrow($result);
    $radminsuper = intval($radminsuper);
    $counter = intval($counter);
    $sid = intval($sid);
        $result = $db->sql_query("SELECT admins FROM ".TABLE_MODULES." WHERE title='News'");
        $row2 = $db->sql_fetchrow($db->sql_query("SELECT name FROM ".TABLE_AUTHORS." WHERE aid='$aid'"));
        while ($row = $db->sql_fetchrow($result)) {
            $admins = explode(",", $row['admins']);
            $auth_user = 0;
            for ($i=0; $i < sizeof($admins); $i++) { if ($row2[name] == "$admins[$i]") { $auth_user = 1; } }
            if ($auth_user == 1) { $radminarticle = 1; }
        }
    $result2 = $db->sql_query("select aid from ".TABLE_STORIES." where sid='$sid'");
    list($aaid) = $db->sql_fetchrow($result2);
    $aaid = substr("$aaid", 0,25);
    if (($radminarticle == 1) AND ($aaid == $aid) OR ($radminsuper == 1)) {
        if($ok) {
            $counter--;
                $db->sql_query("DELETE FROM ".TABLE_STORIES." where sid='$sid'");
            $db->sql_query("DELETE FROM ".TABLE_COMMENTS." where sid='$sid'");
            $db->sql_query("update ".TABLE_POLL_DESC." set artid='0' where artid='$sid'");
            $result = $db->sql_query("update ".TABLE_AUTHORS." set counter='$counter' where aid='$aid'");
            if ($ultramode) {
                ultramode();
            }
            redirect_url("".$admin_file.".php");
        } else {
            incoh();
            //GraphicAdmin();
            Max_OpenTable();
            echo "<center><font class='title'><b>"._ARTICLEADMIN."</b></font></center>";
            Max_CloseTable();
            BR('1');
            Max_OpenTable();
            echo "<center>"._REMOVESTORY." $sid "._ANDCOMMENTS."";
	    BR('2');
            echo "[ <a href=\"".$admin_file.".php\">"._NO."</a> | <a href=\"".$admin_file.".php?op=RemoveStory&amp;sid=$sid&amp;ok=1\">"._YES."</a> ]</center>";
                Max_CloseTable();
            incof();
        }
    } else {
        incoh();
       // GraphicAdmin();
        Max_OpenTable();
        echo "<center><font class='title'><b>"._ARTICLEADMIN."</b></font></center>";
        Max_CloseTable();
        BR('1');
        Max_OpenTable();
        echo "<center><b>"._NOTAUTHORIZED1."</b><br /><br />"
            .""._NOTAUTHORIZED2."<br /><br />"
            .""._GOBACK."";
        Max_CloseTable();
        incof();
    }