<?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);
    $sid = $db->XMFnum($sid);
    $result = $db->sql_query("select radminsuper from ".TABLE_AUTHORS." where aid='$aid'");
    list($radminsuper) = $db->sql_fetchrow($result);
    $radminsuper = $db->XMFbin($radminsuper);
        $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 ($day < 10) {
        $day = "0$day";
    }
    if ($month < 10) {
        $month = "0$month";
    }
    $sec = "00";
    $date = "$year-$month-$day $hour:$min:$sec";
    $title = stripslashes(FixQuotes($title));
    $hometext = stripslashes(FixQuotes($hometext));
    $bodytext = stripslashes(FixQuotes($bodytext));
    $notes = stripslashes(FixQuotes($notes));
    $result = $db->sql_query("update ".TABLE_AUTONEWS." set catid='$catid', title='$title', time='$date', hometext='$hometext', bodytext='$bodytext', topic='$topic', notes='$notes', ihome='$ihome', alanguage='$alanguage', acomm='$acomm' where anid='$anid'");
    if (!$result) {
        exit();
    }
    if ($ultramode) {
        ultramode();
    }
    redirect_url("".$admin_file.".php?op=homenews");
    } else {
        incoh();
        GraphicAdmin();
        Max_OpenTable();
        echo "<center><font class='title'><b>"._ARTICLEADMIN."</b></font></center>";
        Max_CloseTable();
        echo "<br />";
        Max_OpenTable();
        echo "<center><b>"._NOTAUTHORIZED1."</b><br /><br />"
            .""._NOTAUTHORIZED2."<br /><br />"
            .""._GOBACK."";
        Max_CloseTable();
        incof();
    }