<?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();
    if ( $wysiwyg == 'fck' ) {
   		 include_once('FCKeditor/fckeditor.php');
   		 }
    Max_OpenTable();
    echo "<center><font class='title'><b>"._ARTICLEADMIN."</b></font></center>";
    Max_CloseTable();
    echo "<br />";
    $today = getdate();
    $tday = $today['mday'];
    if ($tday < 10){
        $tday = "0$tday";
    }
    $tmonth = $today['month'];
    $tyear = $today['year'];
    $thour = $today['hours'];
    if ($thour < 10){
        $thour = "0$thour";
    }
    $tmin = $today['minutes'];
    if ($tmin < 10){
        $tmin = "0$tmin";
    }
    $tsec = $today['seconds'];
    if ($tsec < 10){
        $tsec = "0$tsec";
    }
    $date = "$tmonth $tday, $tyear @ $thour:$tmin:$tsec";
    $subject = stripslashes($subject);
    $hometext = stripslashes($hometext);
    $bodytext = stripslashes($bodytext);
    $notes = stripslashes($notes);
    Max_OpenTable();
    echo "<font class=\"content\">"
        ."<form action=\"".$admin_file.".php\" method=\"post\">"
        ."<b>"._NAME."</b><br />"
        ."<input type=\"text\" name=\"author\" size=\"25\" value=\"$author\">";
    if ($author != $anonymous) {
        $res = $db->sql_query("select user_id, user_email from ".TABLE_USERS." where username='$author'");
        list($pm_userid, $email) = $db->sql_fetchrow($res);
        $pm_userid = $db->XMFnum($pm_userid);
        echo "&nbsp;&nbsp;<font class=\"content\">[ <a href=\"mailto:$email?Subject=Re: $subject\">"._EMAILUSER."</a> | <a href='modules.php?name=Your_Account&op=userinfo&username=$author'>"._USERPROFILE."</a> | <a href=\"modules.php?name=Private_Messages&amp;mode=post&amp;u=$uid\">"._SENDPM."</a> ]</font>";
    }
    echo "<br /><br /><b>"._TITLE."</b><br />"
        ."<input type=\"text\" name=\"subject\" size=\"50\" value=\"$subject\"><br /><br />";
    $result = $db->sql_query("select topicimage from ".TABLE_TOPICS." where topicid='$topic'");
    list($topicimage) = $db->sql_fetchrow($result);
    echo "<table width=\"70%\" bgcolor=\"$bgcolor2\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\"align=\"center\"><tr><td>"
        ."<table width=\"100%\" bgcolor=\"$bgcolor1\" cellpadding=\"8\" cellspacing=\"1\" border=\"0\"><tr><td>"
        ."<img src=\"images/topics/$topicimage\" border=\"0\" align=\"right\">";
    themepreview($subject, $hometext, $bodytext, $notes);
    echo "</td></tr></table></td></tr></table>"
        ."<br /><b>"._TOPIC."</b> <select name=\"topic\">";
    $toplist = $db->sql_query("select topicid, topictext from ".TABLE_TOPICS." order by topictext");
    echo "<option value=\"\">"._ALLTOPICS."</option>\n";
    while(list($topicid, $topics) = $db->sql_fetchrow($toplist)) {
            $topicid = $db->XMFnum($topicid);
        if ($topicid==$topic) {
            $sel = "selected ";
        }
        echo "<option $sel value=\"$topicid\">$topics</option>\n";
        $sel = "";
    }
    echo "</select>";
    echo "<br /><br />";
    // Copyright (c) 2000-2005 by NukeScripts Network
    if($Version_Num >= 6.6) {
        for ($i=0; $i<sizeof($assotop); $i++) { $associated .= "$assotop[$i]-"; }
        $asso_t = explode("-", $associated);
        echo "<table border='0' width='100%' cellspacing='0'><tr><td width='20%'><b>"._ASSOTOPIC."</b></td><td width='100%'>"
            ."<table border='1' cellspacing='3' cellpadding='8'><tr>";
        $sql = "SELECT topicid, topictext FROM ".TABLE_TOPICS." ORDER BY topictext";
        $result = $db->sql_query($sql);
        while ($row = $db->sql_fetchrow($result)) {
            if ($a == 3) {
                echo "</tr><tr>";
                $a = 0;
            }
            for ($i=0; $i<sizeof($asso_t); $i++) {
                if ($asso_t[$i] == $row[topicid]) {
                    $checked = "CHECKED";
                    break;
                }
            }
            echo "<td><input type='checkbox' name='assotop[]' value='$row[topicid]' $checked>$row[topictext]</td>";
            $checked = "";
            $a++;
        }
        echo "</tr></table></td></tr></table><br /><br />";
    }
    // Copyright (c) 2000-2005 by NukeScripts Network
    $cat = $catid;
    SelectCategory($cat);
    echo "<br />";
    puthome($ihome, $acomm);
    if ($multilingual == 1) {
        echo "<br /><b>"._LANGUAGE.": </b>"
            ."<select name=\"alanguage\">";
        $handle=opendir('language');
        while ($file = readdir($handle)) {
            if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
                $langFound = $matches[1];
                $languageslist .= "$langFound ";
            }
        }
        closedir($handle);
        $languageslist = explode(" ", $languageslist);
        sort($languageslist);
        for ($i=0; $i < sizeof($languageslist); $i++) {
            if($languageslist[$i]!="") {
                echo "<option value=\"$languageslist[$i]\" ";
                if($languageslist[$i]==$alanguage) echo "selected";
                echo ">".ucfirst($languageslist[$i])."</option>\n";
            }
        }
        if ($alanguage == "") {
            $sellang = "selected";
        } else {
                $sellang = "";
        }
        echo "<option value=\"\" $sellang>"._ALL."</option></select>";
    } else {
        echo "<input type=\"hidden\" name=\"alanguage\" value=\"$language\">";
    }
    echo "<br /><br /><b>"._STORYTEXT."</b><br />";

if ( $wysiwyg == 'fck' ) {
$oFCKeditor = new FCKeditor(hometext) ;
$oFCKeditor->InstanceName = "hometext" ;
$oFCKeditor->Value = "$hometext" ;
$oFCKeditor->Create() ;
} else {
   echo "<textarea wrap=\"virtual\" cols=\"100\" rows=\"30\" name=\"hometext\">$hometext</textarea><br /><br />";
}
	    echo "<b>"._EXTENDEDTEXT."</b><br />";
if ( $wysiwyg == 'fck' ) {
$oFCKeditor = new FCKeditor(bodytext) ;
$oFCKeditor->InstanceName = "bodytext" ;
$oFCKeditor->Value = "$bodytext" ;
$oFCKeditor->Create() ;
} else {
        echo "<textarea wrap=\"virtual\" cols=\"100\" rows=\"30\" name=\"bodytext\">$bodytext</textarea><br />";
}
	    echo "<font class=\"content\">"._AREYOUSURE."</font><br /><br />"
        ."<b>"._NOTES."</b><br />";
if ( $wysiwyg == 'fck' ) {
$oFCKeditor = new FCKeditor(notes) ;
$oFCKeditor->InstanceName = "notes" ;
$oFCKeditor->Value = "$notes" ;
$oFCKeditor->Create() ;
} else {
        echo "<textarea wrap=\"virtual\" cols=\"100\" rows=\"20\" name=\"notes\">$notes</textarea>";
}
	    echo "<br /><br /><input type=\"hidden\" NAME=\"qid\" size=\"50\" value=\"$qid\">"
        ."<input type=\"hidden\" NAME=\"uid\" size=\"50\" value=\"$uid\">";
    if ($automated == 1) {
        $sel1 = "checked";
        $sel2 = "";
    } else {
        $sel1 = "";
        $sel2 = "checked";
    }
    echo "<b>"._PROGRAMSTORY."</b>&nbsp;&nbsp;"
        ."<input type=\"radio\" name=\"automated\" value=\"1\" $sel1>"._YES." &nbsp;&nbsp;"
        ."<input type=\"radio\" name=\"automated\" value=\"0\" $sel2>"._NO."<br /><br />"
        .""._NOWIS.": $date<br /><br />";
    $xday = 1;
    echo ""._DAY.": <select name=\"day\">";
    while ($xday <= 31) {
        if ($xday == $day) {
            $sel = "selected";
        } else {
            $sel = "";
        }
        echo "<option name=\"day\" $sel>$xday</option>";
        $xday++;
    }
    echo "</select>";
    $xmonth = 1;
    echo ""._UMONTH.": <select name=\"month\">";
    while ($xmonth <= 12) {
        if ($xmonth == $month) {
            $sel = "selected";
        } else {
            $sel = "";
        }
        echo "<option name=\"month\" $sel>$xmonth</option>";
        $xmonth++;
    }
    echo "</select>";
    echo ""._YEAR.": <input type=\"text\" name=\"year\" value=\"$year\" size=\"5\" maxlength=\"4\">";
    echo "<br />"._HOUR.": <select name=\"hour\">";
    $xhour = 0;
    $cero = "0";
    while ($xhour <= 23) {
        $dummy = $xhour;
        if ($xhour < 10) {
            $xhour = "$cero$xhour";
        }
        if ($xhour == $hour) {
            $sel = "selected";
        } else {
            $sel = "";
        }
        echo "<option name=\"hour\" $sel>$xhour</option>";
        $xhour = $dummy;
        $xhour++;
    }
    echo "</select>";
    echo ": <select name=\"min\">";
    $xmin = 0;
    while ($xmin <= 59) {
        if (($xmin == 0) OR ($xmin == 5)) {
            $xmin = "0$xmin";
        }
        if ($xmin == $min) {
            $sel = "selected";
        } else {
            $sel = "";
        }
        echo "<option name=\"min\" $sel>$xmin</option>";
        $xmin = $xmin + 5;
    }
    echo "</select>";
    echo ": 00<br /><br />"
        ."<select name=\"op\">"
        ."<option value=\"DeleteStory\">"._DELETESTORY."</option>"
        ."<option value=\"PreviewAgain\" selected>"._PREVIEWSTORY."</option>"
        ."<option value=\"PostStory\">"._POSTSTORY."</option>"
        ."</select>"
        ."<input type=\"submit\" value=\""._OK."\">";
    Max_CloseTable();
    br('1');
    putpoll($pollTitle, $optionText);
    echo "</form>";
    incof();