<?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();
    menunews();
  if ( $wysiwyg == 'fck' ) {
   		 include_once('FCKeditor/fckeditor.php');
   		 }
    Max_OpenTable();
    echo "<center><font class='title'><b>"._SUBMISSIONSADMIN."</b></font></center>";
    Max_CloseTable();
    br('1');
    $today = getdate();
    $tday = $today['mday'];
    if ($tday < 10){
        $tday = "0$tday";
    }
    $tmonth = $today['month'];
    $ttmon = $today['mon'];
    if ($ttmon < 10){
        $ttmon = "0$ttmon";
    }
    $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";
    $qid = $GLOBALS['db']->XMFnum($qid);
    $result = $GLOBALS['db']->sql_query("SELECT `qid`, `uid`, `uname`, `subject`, `story`, `storyext`, `topic`, `alanguage` FROM `".TABLE_QUEUE."` where `qid`='$qid'");
    list($qid, $uid, $uname, $subject, $story, $storyext, $topic, $alanguage) = $GLOBALS['db']->sql_fetchrow($result);
        $qid  = $GLOBALS['db']->XMFnum($qid);
        $uid  = $GLOBALS['db']->XMFnum($uid);
    $subject  = stripslashes($subject);
    $story    = stripslashes($story);
    $storyext = stripslashes($storyext);

    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=\"$uname\" />";
    if ($uname != $anonymous) {
        $res = $GLOBALS['db']->sql_query("select `user_email` from `".TABLE_USERS."` where `username`='$uname'");
        list($email) = $GLOBALS['db']->sql_fetchrow($res);
        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=$uname'>"._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 />";
    if($topic=="") {
        $topic = 1;
    }
    $result = $GLOBALS['db']->sql_query("select `topicimage` from `".TABLE_TOPICS."` where `topicid`='$topic'");
    list($topicimage) = $GLOBALS['db']->sql_fetchrow($result);
    echo "<table border=\"0\" width=\"70%\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"$bgcolor2\" align=\"center\"><tr><td>"
        ."<table border=\"0\" width=\"100%\" cellpadding=\"8\" cellspacing=\"1\" bgcolor=\"$bgcolor1\"><tr><td>"
        ."<img src=\"images/topics/$topicimage\" border=\"0\" align=\"right\" alt=\"\" />";
    $storypre = "$story<br /><br />$storyext";
    themepreview($subject, $storypre);
    echo "</td></tr></table></td></tr></table>"
        ."<br /><b>"._TOPIC."</b> <select name=\"topic\">";
    $toplist = $GLOBALS['db']->sql_query("select `topicid`, `topictext` from `".TABLE_TOPICS."` order by `topictext`");
    echo "<option value=\"\">"._SELECTTOPIC."</option>\n";
    while(list($topicid, $topics) = $GLOBALS['db']->sql_fetchrow($toplist)) {
    $topicid = $GLOBALS['db']->XMFnum($topicid);
        if ($topicid==$topic) {
            $sel = "selected ";
        }
        echo "<option $sel value=\"$topicid\">$topics</option>\n";
        $sel = "";
    }
    echo "</select>";
    br('2');
    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 = $GLOBALS['db']->sql_query($sql);
    while ($row = $GLOBALS['db']->sql_fetchrow($result)) {
        if ($a == 3) {
            echo "</tr><tr>";
            $a = 0;
        }
        echo "<td><input type='checkbox' name='assotop[]' value='$row[topicid]' />$row[topictext]</td>";
        $a++;
    }
    echo "</tr></table></td></tr></table><br /><br />";
    SelectCategory($cat);
    br('1');
    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=\"\" />";
    }
    br('2');
    echo "<b>"._STORYTEXT."</b><br />";

if ( $wysiwyg == 'fck' ) {
$oFCKeditor = new FCKeditor(hometext) ;
$oFCKeditor->InstanceName = "hometext" ;
$oFCKeditor->Value = "$story" ;
$oFCKeditor->Create();
} else {
     echo "<textarea wrap=\"virtual\" cols=\"100\" rows=\"30\" name=\"hometext\">$story</textarea>";
     }
    echo "<br /><br /><b>"._EXTENDEDTEXT."</b><br />";
if ( $wysiwyg == 'fck' ) {
$oFCKeditor = new FCKeditor(bodytext) ;
$oFCKeditor->InstanceName = "bodytext" ;
$oFCKeditor->Value = "$storyext" ;
$oFCKeditor->Create() ;
} else {
    echo "<textarea wrap=\"virtual\" cols=\"100\" rows=\"30\" name=\"bodytext\">$storyext</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><br />";
}
echo     "<input type=\"hidden\" NAME=\"qid\" size=\"50\" value=\"$qid\" />"
        ."<input type=\"hidden\" NAME=\"uid\" size=\"50\" value=\"$uid\" />"
        ."<br /><b>"._PROGRAMSTORY."</b>&nbsp;&nbsp;"
        ."<input type=\"radio\" name=\"automated\" value=\"1\" />"._YES." &nbsp;&nbsp;"
        ."<input type=\"radio\" name=\"automated\" value=\"0\" checked />"._NO."<br /><br />"
        .""._NOWIS.": $date<br /><br />";
    $day = 1;
    echo ""._DAY.": <select name=\"day\">";
    while ($day <= 31) {
        if ($tday==$day) {
            $sel = "selected";
        } else {
            $sel = "";
        }
        echo "<option name=\"day\" $sel>$day</option>";
        $day++;
    }
    echo "</select>";
    $month = 1;
    echo "&nbsp;"._UMONTH.": <select name=\"month\">";
    while ($month <= 12) {
        if ($ttmon==$month) {
            $sel = "selected";
        } else {
            $sel = "";
        }
        echo "<option name=\"month\" $sel>$month</option>";
        $month++;
    }
    echo "</select>";
    $date = getdate();
    $year = $date['year'];
    echo "&nbsp;"._YEAR.": <input type=\"text\" name=\"year\" value=\"$year\" size=\"5\" maxlength=\"4\" />";
    echo "<br />"._HOUR.": <select name=\"hour\">";
    $hour = 0;
    $cero = "0";
    while ($hour <= 23) {
        $dummy = $hour;
        if ($hour < 10) {
            $hour = "$cero$hour";
        }
        echo "<option name=\"hour\">$hour</option>";
        $hour = $dummy;
        $hour++;
    }
    echo "</select>";
    echo ": <select name=\"min\">";
    $min = 0;
    while ($min <= 59) {
        if (($min == 0) OR ($min == 5)) {
            $min = "0$min";
        }
        echo "<option name=\"min\">$min</option>";
        $min = $min + 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."\" />&nbsp;&nbsp;[ <a href=\"".$admin_file.".php?op=DeleteStory&qid=$qid\">"._DELETE."</a> ]";
        Max_CloseTable();
    br('1');
    putpoll($pollTitle, $optionText);
    echo "</form>";
    incof();