home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / admin / modules / stories.php < prev    next >
Encoding:
PHP Script  |  2002-09-16  |  61.3 KB  |  1,714 lines

  1. <?php
  2.  
  3. /************************************************************************/
  4. /* PHP-NUKE: Web Portal System                                          */
  5. /* ===========================                                          */
  6. /*                                                                      */
  7. /* Copyright (c) 2002 by Francisco Burzi                                */
  8. /* http://phpnuke.org                                                   */
  9. /*                                                                      */
  10. /* This program is free software. You can redistribute it and/or modify */
  11. /* it under the terms of the GNU General Public License as published by */
  12. /* the Free Software Foundation; either version 2 of the License.       */
  13. /************************************************************************/
  14.  
  15. if (!eregi("admin.php", $PHP_SELF)) { die ("Access Denied"); }
  16. $result = sql_query("select radminarticle, radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
  17. list($radminarticle, $radminsuper) = sql_fetch_row($result, $dbi);
  18. if (($radminarticle==1) OR ($radminsuper==1)) {
  19.  
  20. /*********************************************************/
  21. /* Story/News Functions                                  */
  22. /*********************************************************/
  23.  
  24. function puthome($ihome, $acomm) {
  25.     echo "<br><b>"._PUBLISHINHOME."</b>  ";
  26.     if (($ihome == 0) OR ($ihome == "")) {
  27.     $sel1 = "checked";
  28.     $sel2 = "";
  29.     }
  30.     if ($ihome == 1) {
  31.     $sel1 = "";
  32.     $sel2 = "checked";
  33.     }
  34.     echo "<input type=\"radio\" name=\"ihome\" value=\"0\" $sel1>"._YES." "
  35.     ."<input type=\"radio\" name=\"ihome\" value=\"1\" $sel2>"._NO.""
  36.     ."  <font class=\"content\">[ "._ONLYIFCATSELECTED." ]</font><br>";
  37.     
  38.     echo "<br><b>"._ACTIVATECOMMENTS."</b>  ";
  39.     if (($acomm == 0) OR ($acomm == "")) {
  40.     $sel1 = "checked";
  41.     $sel2 = "";
  42.     }
  43.     if ($acomm == 1) {
  44.     $sel1 = "";
  45.     $sel2 = "checked";    
  46.     }
  47.     echo "<input type=\"radio\" name=\"acomm\" value=\"0\" $sel1>"._YES." "
  48.     ."<input type=\"radio\" name=\"acomm\" value=\"1\" $sel2>"._NO."</font><br><br>";
  49.  
  50. }
  51.  
  52. function deleteStory($qid) {
  53.     global $prefix, $dbi;
  54.     $result = sql_query("delete from ".$prefix."_queue where qid=$qid", $dbi);
  55.     if (!$result) {
  56.     return;
  57.     }
  58.     Header("Location: admin.php?op=submissions");
  59. }
  60.  
  61. function SelectCategory($cat) {
  62.     global $prefix, $dbi;
  63.     $selcat = sql_query("select catid, title from ".$prefix."_stories_cat order by title", $dbi);
  64.     $a = 1;
  65.     echo "<b>"._CATEGORY."</b> ";
  66.     echo "<select name=\"catid\">";
  67.     if ($cat == 0) {
  68.     $sel = "selected";
  69.     } else {
  70.     $sel = "";
  71.     }
  72.     echo "<option name=\"catid\" value=\"0\" $sel>"._ARTICLES."</option>";
  73.     while(list($catid, $title) = sql_fetch_row($selcat, $dbi)) {
  74.     if ($catid == $cat) {
  75.         $sel = "selected";
  76.     } else {
  77.         $sel = "";
  78.     }
  79.     echo "<option name=\"catid\" value=\"$catid\" $sel>$title</option>";
  80.     $a++;
  81.     }
  82.     echo "</select> [ <a href=\"admin.php?op=AddCategory\">"._ADD."</a> | <a href=\"admin.php?op=EditCategory\">"._EDIT."</a> | <a href=\"admin.php?op=DelCategory\">"._DELETE."</a> ]";
  83. }
  84.  
  85. function putpoll($pollTitle, $optionText) {
  86.     OpenTable();
  87.     echo "<center><font class=\"title\"><b>"._ATTACHAPOLL."</b></font><br>"
  88.     ."<font class=\"tiny\">"._LEAVEBLANKTONOTATTACH."</font><br>"
  89.     ."<br><br>"._POLLTITLE.": <input type=\"text\" name=\"pollTitle\" size=\"50\" maxlength=\"100\" value=\"$pollTitle\"><br><br>"
  90.     ."<font class=\"content\">"._POLLEACHFIELD."<br>"
  91.     ."<table border=\"0\">";
  92.     for($i = 1; $i <= 12; $i++)    {
  93.     echo "<tr>"
  94.         ."<td>"._OPTION." $i:</td><td><input type=\"text\" name=\"optionText[$i]\" size=\"50\" maxlength=\"50\" value=\"$optionText[$i]\"></td>"
  95.         ."</tr>";
  96.     }
  97.     echo "</table>";
  98.     CloseTable();
  99. }
  100.  
  101. function AddCategory () {
  102.     include ("header.php");
  103.     GraphicAdmin();
  104.     OpenTable();
  105.     echo "<center><font class=\"title\"><b>"._CATEGORIESADMIN."</b></font></center>";
  106.     CloseTable();
  107.     echo "<br>";
  108.     OpenTable();
  109.     echo "<center><font class=\"option\"><b>"._CATEGORYADD."</b></font><br><br><br>"
  110.     ."<form action=\"admin.php\" method=\"post\">"
  111.     ."<b>"._CATNAME.":</b> "
  112.     ."<input type=\"text\" name=\"title\" size=\"22\" maxlength=\"20\"> "
  113.     ."<input type=\"hidden\" name=\"op\" value=\"SaveCategory\">"
  114.     ."<input type=\"submit\" value=\""._SAVE."\">"
  115.     ."</form></center>";
  116.     CloseTable();
  117.     include("footer.php");
  118. }
  119.  
  120. function EditCategory($catid) {
  121.     global $prefix, $dbi;
  122.     $result = sql_query("select title from ".$prefix."_stories_cat where catid='$catid'", $dbi);
  123.     list($title) = sql_fetch_row($result, $dbi);
  124.     include ("header.php");
  125.     GraphicAdmin();
  126.     OpenTable();
  127.     echo "<center><font class=\"title\"><b>"._CATEGORIESADMIN."</b></font></center>";
  128.     CloseTable();
  129.     echo "<br>";
  130.     OpenTable();
  131.     echo "<center><font class=\"option\"><b>"._EDITCATEGORY."</b></font><br>";
  132.     if (!$catid) {
  133.     $selcat = sql_query("select catid, title from ".$prefix."_stories_cat", $dbi);
  134.     echo "<form action=\"admin.php\" method=\"post\">";
  135.     echo "<b>"._ASELECTCATEGORY."</b>";
  136.     echo "<select name=\"catid\">";
  137.     echo "<option name=\"catid\" value=\"0\" $sel>Articles</option>";
  138.     while(list($catid, $title) = sql_fetch_row($selcat, $dbi)) {
  139.         echo "<option name=\"catid\" value=\"$catid\" $sel>$title</option>";
  140.     }
  141.     echo "</select>";
  142.     echo "<input type=\"hidden\" name=\"op\" value=\"EditCategory\">";
  143.     echo "<input type=\"submit\" value=\""._EDIT."\"><br><br>";
  144.     echo ""._NOARTCATEDIT."";
  145.     } else {
  146.     echo "<form action=\"admin.php\" method=\"post\">";
  147.     echo "<b>"._CATEGORYNAME.":</b> ";
  148.     echo "<input type=\"text\" name=\"title\" size=\"22\" maxlength=\"20\" value=\"$title\"> ";
  149.     echo "<input type=\"hidden\" name=\"catid\" value=\"$catid\">";
  150.     echo "<input type=\"hidden\" name=\"op\" value=\"SaveEditCategory\">";
  151.     echo "<input type=\"submit\" value=\""._SAVECHANGES."\"><br><br>";
  152.     echo ""._NOARTCATEDIT."";
  153.     echo "</form>";
  154.     }
  155.     echo "</center>";
  156.     CloseTable();
  157.     include("footer.php");
  158. }
  159.  
  160. function DelCategory($cat) {
  161.     global $prefix, $dbi;
  162.     $result = sql_query("select title from ".$prefix."_stories_cat where catid='$cat'", $dbi);
  163.     list($title) = sql_fetch_row($result, $dbi);
  164.     include ("header.php");
  165.     GraphicAdmin();
  166.     OpenTable();
  167.     echo "<center><font class=\"title\"><b>"._CATEGORIESADMIN."</b></font></center>";
  168.     CloseTable();
  169.     echo "<br>";
  170.     OpenTable();
  171.     echo "<center><font class=\"option\"><b>"._DELETECATEGORY."</b></font><br>";
  172.     if (!$cat) {
  173.     $selcat = sql_query("select catid, title from ".$prefix."_stories_cat", $dbi);
  174.     echo "<form action=\"admin.php\" method=\"post\">"
  175.         ."<b>"._SELECTCATDEL.": </b>"
  176.         ."<select name=\"cat\">";
  177.     while(list($catid, $title) = sql_fetch_row($selcat, $dbi)) {
  178.         echo "<option name=\"cat\" value=\"$catid\">$title</option>";
  179.     }
  180.     echo "</select>"
  181.         ."<input type=\"hidden\" name=\"op\" value=\"DelCategory\">"
  182.         ."<input type=\"submit\" value=\"Delete\">"
  183.         ."</form>";
  184.     } else {
  185.     $result2 = sql_query("select * from ".$prefix."_stories where catid='$cat'", $dbi);
  186.     $numrows = sql_num_rows($result2, $dbi);
  187.     if ($numrows == 0) {
  188.         sql_query("delete from ".$prefix."_stories_cat where catid='$cat'", $dbi);
  189.         echo "<br><br>"._CATDELETED."<br><br>"._GOTOADMIN."";
  190.     } else {
  191.         echo "<br><br><b>"._WARNING.":</b> "._THECATEGORY." <b>$title</b> "._HAS." <b>$numrows</b> "._STORIESINSIDE."<br>"
  192.         .""._DELCATWARNING1."<br>"
  193.         .""._DELCATWARNING2."<br><br>"
  194.         .""._DELCATWARNING3."<br><br>"
  195.         ."<b>[ <a href=\"admin.php?op=YesDelCategory&catid=$cat\">"._YESDEL."</a> | "
  196.         ."<a href=\"admin.php?op=NoMoveCategory&catid=$cat\">"._NOMOVE."</a> ]</b>";
  197.     }
  198.     }
  199.     echo "</center>";
  200.     CloseTable();
  201.     include("footer.php");
  202. }
  203.  
  204. function YesDelCategory($catid) {
  205.     global $prefix, $dbi;
  206.     sql_query("delete from ".$prefix."_stories_cat where catid='$catid'", $dbi);
  207.     $result = sql_query("select sid from ".$prefix."_stories where catid='$catid'", $dbi);
  208.     while(list($sid) = sql_fetch_row($result, $dbi)) {
  209.     sql_query("delete from ".$prefix."_stories where catid='$catid'", $dbi);
  210.     sql_query("delete from ".$prefix."_comments where sid='$sid'", $dbi);
  211.     }
  212.     Header("Location: admin.php");
  213. }
  214.  
  215. function NoMoveCategory($catid, $newcat) {
  216.     global $prefix, $dbi;
  217.     $result = sql_query("select title from ".$prefix."_stories_cat where catid='$catid'", $dbi);
  218.     list($title) = sql_fetch_row($result, $dbi);
  219.     include ("header.php");
  220.     GraphicAdmin();
  221.     OpenTable();
  222.     echo "<center><font class=\"title\"><b>"._CATEGORIESADMIN."</b></font></center>";
  223.     CloseTable();
  224.     echo "<br>";
  225.     OpenTable();
  226.     echo "<center><font class=\"option\"><b>"._MOVESTORIES."</b></font><br><br>";
  227.     if (!$newcat) {
  228.     echo ""._ALLSTORIES." <b>$title</b> "._WILLBEMOVED."<br><br>";
  229.     $selcat = sql_query("select catid, title from ".$prefix."_stories_cat", $dbi);
  230.     echo "<form action=\"admin.php\" method=\"post\">";
  231.     echo "<b>"._SELECTNEWCAT.":</b> ";
  232.     echo "<select name=\"newcat\">";
  233.         echo "<option name=\"newcat\" value=\"0\">"._ARTICLES."</option>";
  234.     while(list($newcat, $title) = sql_fetch_row($selcat, $dbi)) {
  235.             echo "<option name=\"newcat\" value=\"$newcat\">$title</option>";
  236.     }
  237.     echo "</select>";
  238.     echo "<input type=\"hidden\" name=\"catid\" value=\"$catid\">";
  239.     echo "<input type=\"hidden\" name=\"op\" value=\"NoMoveCategory\">";
  240.     echo "<input type=\"submit\" value=\""._OK."\">";
  241.     echo "</form>";
  242.     } else {
  243.     $resultm = sql_query("select sid from ".$prefix."_stories where catid='$catid'", $dbi);
  244.     while(list($sid) = sql_fetch_row($resultm, $dbi)) {
  245.         sql_query("update ".$prefix."_stories set catid='$newcat' where sid='$sid'", $dbi);
  246.     }
  247.     sql_query("delete from ".$prefix."_stories_cat where catid='$catid'", $dbi);
  248.     echo ""._MOVEDONE."";
  249.     }
  250.     CloseTable();
  251.     include("footer.php");
  252. }
  253.  
  254. function SaveEditCategory($catid, $title) {
  255.     global $prefix, $dbi;
  256.     $title = ereg_replace("\"","",$title);
  257.     $check = sql_query("select catid from ".$prefix."_stories_cat where title=$title", $dbi);
  258.     if ($check) {
  259.     $what1 = _CATEXISTS;
  260.     $what2 = _GOBACK;
  261.     } else {
  262.     $what1 = _CATSAVED;
  263.     $what2 = "[ <a href=\"admin.php\">"._GOTOADMIN."</a> ]";
  264.     $result = sql_query("update ".$prefix."_stories_cat set title='$title' where catid='$catid'", $dbi);
  265.     if (!$result) {
  266.         return;
  267.     }
  268.     }
  269.     include ("header.php");
  270.     GraphicAdmin();
  271.     OpenTable();
  272.     echo "<center><font class=\"title\"><b>"._CATEGORIESADMIN."</b></font></center>";
  273.     CloseTable();
  274.     echo "<br>";
  275.     OpenTable();
  276.     echo "<center><font class=\"content\"><b>$what1</b></font><br><br>";
  277.     echo "$what2</center>";
  278.     CloseTable();
  279.     include("footer.php");
  280. }
  281.  
  282. function SaveCategory($title) {
  283.     global $prefix, $dbi;
  284.     $title = ereg_replace("\"","",$title);
  285.     $check = sql_query("select catid from ".$prefix."_stories_cat where title=$title", $dbi);
  286.     if ($check) {
  287.     $what1 = _CATEXISTS;
  288.     $what2 = _GOBACK;
  289.     } else {
  290.     $what1 = _CATADDED;
  291.     $what2 = _GOTOADMIN;
  292.     $result = sql_query("insert into ".$prefix."_stories_cat values (NULL, '$title', '0')", $dbi);
  293.     if (!$result) {
  294.         return;
  295.     }
  296.     }
  297.     include ("header.php");
  298.     GraphicAdmin();
  299.     OpenTable();
  300.     echo "<center><font class=\"title\"><b>"._CATEGORIESADMIN."</b></font></center>";
  301.     CloseTable();
  302.     echo "<br>";
  303.     OpenTable();
  304.     echo "<center><font class=\"content\"><b>$what1</b></font><br><br>";
  305.     echo "$what2</center>";
  306.     CloseTable();
  307.     include("footer.php");
  308. }
  309.  
  310. function autodelete($anid) {
  311.     global $prefix, $dbi;
  312.     sql_query("delete from ".$prefix."_autonews where anid=$anid", $dbi);
  313.     Header("Location: admin.php?op=adminMain");
  314. }
  315.  
  316. function autoEdit($anid) {
  317.     global $aid, $bgcolor1, $bgcolor2, $prefix, $dbi, $multilingual;
  318.     $result = sql_query("select radminarticle, radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
  319.     list($radminarticle, $radminsuper) = sql_fetch_row($result, $dbi);
  320.     $result2 = sql_query("select aid from ".$prefix."_stories where sid='$sid'", $dbi);
  321.     list($aaid) = sql_fetch_row($result2, $dbi);
  322.     if (($radminarticle == 1) AND ($aaid == $aid) OR ($radminsuper == 1)) {
  323.     include ("header.php");
  324.     $result = sql_query("select catid, aid, title, time, hometext, bodytext, topic, informant, notes, ihome, alanguage, acomm from ".$prefix."_autonews where anid=$anid", $dbi);
  325.     list($catid, $aid, $title, $time, $hometext, $bodytext, $topic, $informant, $notes, $ihome, $alanguage, $acomm) = sql_fetch_row($result, $dbi);
  326.     ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
  327.     GraphicAdmin();
  328.     OpenTable();
  329.     echo "<center><font class=\"title\"><b>"._ARTICLEADMIN."</b></font></center>";
  330.     CloseTable();
  331.     echo "<br>";
  332.     OpenTable();
  333.     $today = getdate();
  334.     $tday = $today[mday];
  335.     if ($tday < 10){
  336.     $tday = "0$tday";
  337.     }
  338.     $tmonth = $today[month];
  339.     $tyear = $today[year];
  340.     $thour = $today[hours];
  341.     if ($thour < 10){
  342.     $thour = "0$thour";
  343.     }
  344.     $tmin = $today[minutes];
  345.     if ($tmin < 10){
  346.     $tmin = "0$tmin";
  347.     }
  348.     $tsec = $today[seconds];
  349.     if ($tsec < 10){
  350.     $tsec = "0$tsec";
  351.     }
  352.     $date = "$tmonth $tday, $tyear @ $thour:$tmin:$tsec";
  353.     echo "<center><font class=\"option\"><b>"._AUTOSTORYEDIT."</b></font></center><br><br>"
  354.     ."<form action=\"admin.php\" method=\"post\">";
  355.     $title = stripslashes($title);
  356.     $hometext = stripslashes($hometext);
  357.     $bodytext = stripslashes($bodytext);
  358.     $notes = stripslashes($notes);
  359.     $result=sql_query("select topicimage from ".$prefix."_topics where topicid=$topic", $dbi);
  360.     list($topicimage) = sql_fetch_row($result, $dbi);
  361.     echo "<table border=\"0\" width=\"75%\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"$bgcolor2\" align=\"center\"><tr><td>"
  362.     ."<table border=\"0\" width=\"100%\" cellpadding=\"8\" cellspacing=\"1\" bgcolor=\"$bgcolor1\"><tr><td>"
  363.     ."<img src=\"images/topics/$topicimage\" border=\"0\" align=\"right\">";
  364.     themepreview($title, $hometext, $bodytext);
  365.     echo "</td></tr></table></td></tr></table>"
  366.     ."<br><br><b>"._TITLE."</b><br>"
  367.     ."<input type=\"text\" name=\"title\" size=\"50\" value=\"$title\"><br><br>"
  368.     ."<b>"._TOPIC."</b> <select name=\"topic\">";
  369.     $toplist = sql_query("select topicid, topictext from ".$prefix."_topics order by topictext", $dbi);
  370.     echo "<option value=\"\">"._ALLTOPICS."</option>\n";
  371.     while(list($topicid, $topics) = sql_fetch_row($toplist, $dbi)) {
  372.     if ($topicid==$topic) { $sel = "selected "; }
  373.         echo "<option $sel value=\"$topicid\">$topics</option>\n";
  374.     $sel = "";
  375.     }
  376.     echo "</select><br><br>";
  377.     $cat = $catid;
  378.     SelectCategory($cat);
  379.     echo "<br>";
  380.     puthome($ihome, $acomm);
  381.     if ($multilingual == 1) {
  382.     echo "<br><b>"._LANGUAGE.": </b>"
  383.         ."<select name=\"alanguage\">";
  384.     $handle=opendir('language');
  385.     while ($file = readdir($handle)) {
  386.         if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
  387.         $langFound = $matches[1];
  388.             $languageslist .= "$langFound ";
  389.         }
  390.     }
  391.     closedir($handle);
  392.     $languageslist = explode(" ", $languageslist);
  393.     sort($languageslist);
  394.     for ($i=0; $i < sizeof($languageslist); $i++) {
  395.         if($languageslist[$i]!="") {
  396.         echo "<option value=\"$languageslist[$i]\" ";
  397.         if($languageslist[$i]==$alanguage) echo "selected";
  398.         echo ">".ucfirst($languageslist[$i])."</option>\n";
  399.         }
  400.     }
  401.     if ($alanguage == "") {
  402.         $sellang = "selected";
  403.     } else {
  404.             $sellang = "";
  405.     }
  406.     echo "<option value=\"\" $sellang>"._ALL."</option></select>";
  407.     } else {
  408.     echo "<input type=\"hidden\" name=\"alanguage\" value=\"\">";
  409.     }
  410.     echo "<br><br><b>"._STORYTEXT."</b><br>"
  411.     ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"12\" name=\"hometext\">$hometext</textarea><br><br>"
  412.     ."<b>"._EXTENDEDTEXT."</b><br>"
  413.     ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"12\" name=\"bodytext\">$bodytext</textarea><br>"
  414.     ."<font class=\"content\">"._ARESUREURL."</font><br><br>";
  415.     if ($aid != $informant) {
  416.         echo "<b>"._NOTES."</b><br>
  417.     <textarea wrap=\"virtual\" cols=\"50\" rows=\"4\" name=\"notes\">$notes</textarea><br><br>";
  418.     }
  419.     echo "<br><b>"._CHNGPROGRAMSTORY."</b><br><br>"
  420.     .""._NOWIS.": $date<br><br>";
  421.     $xday = 1;
  422.     echo ""._DAY.": <select name=\"day\">";
  423.     while ($xday <= 31) {
  424.     if ($xday == $datetime[3]) {
  425.         $sel = "selected";
  426.     } else {
  427.         $sel = "";
  428.     }
  429.     echo "<option name=\"day\" $sel>$xday</option>";
  430.     $xday++;
  431.     }
  432.     echo "</select>";
  433.     $xmonth = 1;
  434.     echo ""._UMONTH.": <select name=\"month\">";
  435.     while ($xmonth <= 12) {
  436.     if ($xmonth == $datetime[2]) {
  437.         $sel = "selected";
  438.     } else {
  439.         $sel = "";
  440.     }
  441.     echo "<option name=\"month\" $sel>$xmonth</option>";
  442.     $xmonth++;
  443.     }
  444.     echo "</select>";
  445.     echo ""._YEAR.": <input type=\"text\" name=\"year\" value=\"$datetime[1]\" size=\"5\" maxlength=\"4\">";
  446.     echo "<br>"._HOUR.": <select name=\"hour\">";
  447.     $xhour = 0;
  448.     $cero = "0";
  449.     while ($xhour <= 23) {
  450.     $dummy = $xhour;
  451.     if ($xhour < 10) {
  452.         $xhour = "$cero$xhour";
  453.     }
  454.     if ($xhour == $datetime[4]) {
  455.         $sel = "selected";
  456.     } else {
  457.         $sel = "";
  458.     }
  459.     echo "<option name=\"hour\" $sel>$xhour</option>";
  460.     $xhour = $dummy;
  461.     $xhour++;
  462.     }
  463.     echo "</select>";
  464.     echo ": <select name=\"min\">";
  465.     $xmin = 0;
  466.     while ($xmin <= 59) {
  467.     if (($xmin == 0) OR ($xmin == 5)) {
  468.         $xmin = "0$xmin";
  469.     }
  470.     if ($xmin == $datetime[5]) {
  471.         $sel = "selected";
  472.     } else {
  473.         $sel = "";
  474.     }
  475.     echo "<option name=\"min\" $sel>$xmin</option>";
  476.     $xmin = $xmin + 5;
  477.     }
  478.     echo "</select>";
  479.     echo ": 00<br><br>
  480.     <input type=\"hidden\" name=\"anid\" value=\"$anid\">
  481.     <input type=\"hidden\" name=\"op\" value=\"autoSaveEdit\">
  482.     <input type=\"submit\" value=\""._SAVECHANGES."\">
  483.     </form>";
  484.     CloseTable();
  485.     include ('footer.php');
  486.     } else {
  487.     include ('header.php');
  488.     GraphicAdmin();
  489.     OpenTable();
  490.     echo "<center><font class=\"title\"><b>"._ARTICLEADMIN."</b></font></center>";
  491.     CloseTable();
  492.     echo "<br>";
  493.     OpenTable();
  494.     echo "<center><b>"._NOTAUTHORIZED1."</b><br><br>"
  495.         .""._NOTAUTHORIZED2."<br><br>"
  496.         .""._GOBACK."";
  497.     CloseTable();
  498.     include("footer.php");
  499.     }
  500. }
  501.  
  502. function autoSaveEdit($anid, $year, $day, $month, $hour, $min, $title, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $alanguage, $acomm) {
  503.     global $aid, $ultramode, $prefix, $dbi;
  504.     $result = sql_query("select radminarticle, radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
  505.     list($radminarticle, $radminsuper) = sql_fetch_row($result, $dbi);
  506.     $result2 = sql_query("select aid from ".$prefix."_stories where sid='$sid'", $dbi);
  507.     list($aaid) = sql_fetch_row($result2, $dbi);
  508.     if (($radminarticle == 1) AND ($aaid == $aid) OR ($radminsuper == 1)) {
  509.     if ($day < 10) {
  510.     $day = "0$day";
  511.     }
  512.     if ($month < 10) {
  513.     $month = "0$month";
  514.     }
  515.     $sec = "00";
  516.     $date = "$year-$month-$day $hour:$min:$sec";
  517.     $title = stripslashes(FixQuotes($title));
  518.     $hometext = stripslashes(FixQuotes($hometext));
  519.     $bodytext = stripslashes(FixQuotes($bodytext));
  520.     $notes = stripslashes(FixQuotes($notes));
  521.     $result = sql_query("update ".$prefix."_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", $dbi);
  522.     if (!$result) {
  523.     exit();
  524.     }
  525.     if ($ultramode) {
  526.     ultramode();
  527.     }
  528.     Header("Location: admin.php?op=adminMain");
  529.     } else {
  530.     include ('header.php');
  531.     GraphicAdmin();
  532.     OpenTable();
  533.     echo "<center><font class=\"title\"><b>"._ARTICLEADMIN."</b></font></center>";
  534.     CloseTable();
  535.     echo "<br>";
  536.     OpenTable();
  537.     echo "<center><b>"._NOTAUTHORIZED1."</b><br><br>"
  538.         .""._NOTAUTHORIZED2."<br><br>"
  539.         .""._GOBACK."";
  540.     CloseTable();
  541.     include("footer.php");
  542.     }
  543. }
  544.  
  545. function displayStory($qid) {
  546.     global $user, $subject, $story, $bgcolor1, $bgcolor2, $anonymous, $prefix, $dbi, $multilingual;
  547.     include ('header.php');
  548.     GraphicAdmin();
  549.     OpenTable();
  550.     echo "<center><font class=\"title\"><b>"._SUBMISSIONSADMIN."</b></font></center>";
  551.     CloseTable();
  552.     echo "<br>";
  553.     $today = getdate();
  554.     $tday = $today[mday];
  555.     if ($tday < 10){
  556.     $tday = "0$tday";
  557.     }
  558.     $tmonth = $today[month];
  559.     $ttmon = $today[mon];
  560.     if ($ttmon < 10){
  561.     $ttmon = "0$ttmon";
  562.     }
  563.     $tyear = $today[year];
  564.     $thour = $today[hours];
  565.     if ($thour < 10){
  566.     $thour = "0$thour";
  567.     }
  568.     $tmin = $today[minutes];
  569.     if ($tmin < 10){
  570.     $tmin = "0$tmin";
  571.     }
  572.     $tsec = $today[seconds];
  573.     if ($tsec < 10){
  574.     $tsec = "0$tsec";
  575.     }
  576.     $date = "$tmonth $tday, $tyear @ $thour:$tmin:$tsec";
  577.     $result = sql_query("SELECT qid, uid, uname, subject, story, storyext, topic, alanguage FROM ".$prefix."_queue where qid=$qid", $dbi);
  578.     list($qid, $uid, $uname, $subject, $story, $storyext, $topic, $alanguage) = sql_fetch_row($result, $dbi);
  579.     $subject = stripslashes($subject);
  580.     $story = stripslashes($story);
  581.     $storyext = stripslashes($storyext);
  582.  
  583.     OpenTable();
  584.     echo "<font class=\"content\">"
  585.     ."<form action=\"admin.php\" method=\"post\">"
  586.     ."<b>"._NAME."</b><br>"
  587.     ."<input type=\"text\" NAME=\"author\" size=\"25\" value=\"$uname\">";
  588.     if ($uname != $anonymous) {
  589.     $res = sql_query("select email from ".$prefix."_users where uname='$uname'", $dbi);
  590.     list($email) = sql_fetch_row($res, $dbi);
  591.     echo "  <font class=\"content\">[ <a href=\"mailto:$email\">Email User</a> | <a href=\"modules.php?name=Private_Messages&file=reply&send=1&uname=$uname\">Send Private Message</a> ]</font>";
  592.     }
  593.     echo "<br><br><b>"._TITLE."</b><br>"
  594.     ."<input type=\"text\" name=\"subject\" size=\"50\" value=\"$subject\"><br><br>";
  595.     if($topic=="") {
  596.         $topic = 1;
  597.     }
  598.     $result = sql_query("select topicimage from ".$prefix."_topics where topicid=$topic", $dbi);
  599.     list($topicimage) = sql_fetch_row($result, $dbi);
  600.     echo "<table border=\"0\" width=\"70%\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"$bgcolor2\" align=\"center\"><tr><td>"
  601.     ."<table border=\"0\" width=\"100%\" cellpadding=\"8\" cellspacing=\"1\" bgcolor=\"$bgcolor1\"><tr><td>"
  602.     ."<img src=\"images/topics/$topicimage\" border=\"0\" align=\"right\" alt=\"\">";
  603.     $storypre = "$story<br><br>$storyext";
  604.     themepreview($subject, $storypre);
  605.     echo "</td></tr></table></td></tr></table>"
  606.     ."<br><b>"._TOPIC."</b> <select name=\"topic\">";
  607.     $toplist = sql_query("select topicid, topictext from ".$prefix."_topics order by topictext", $dbi);
  608.     echo "<option value=\"\">"._SELECTTOPIC."</option>\n";
  609.     while(list($topicid, $topics) = sql_fetch_row($toplist, $dbi)) {
  610.         if ($topicid==$topic) {
  611.         $sel = "selected ";
  612.     }
  613.         echo "<option $sel value=\"$topicid\">$topics</option>\n";
  614.     $sel = "";
  615.     }
  616.     echo "</select>";
  617.     echo "<br><br>";
  618.     SelectCategory($cat);
  619.     echo "<br>";
  620.     puthome($ihome, $acomm);
  621.     if ($multilingual == 1) {
  622.     echo "<br><b>"._LANGUAGE.": </b>"
  623.         ."<select name=\"alanguage\">";
  624.     $handle=opendir('language');
  625.     while ($file = readdir($handle)) {
  626.         if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
  627.             $langFound = $matches[1];
  628.             $languageslist .= "$langFound ";
  629.         }
  630.     }
  631.     closedir($handle);
  632.     $languageslist = explode(" ", $languageslist);
  633.     sort($languageslist);
  634.     for ($i=0; $i < sizeof($languageslist); $i++) {
  635.         if($languageslist[$i]!="") {
  636.         echo "<option value=\"$languageslist[$i]\" ";
  637.         if($languageslist[$i]==$alanguage) echo "selected";
  638.         echo ">".ucfirst($languageslist[$i])."</option>\n";
  639.         }
  640.     }
  641.     if ($alanguage == "") {
  642.         $sellang = "selected";
  643.     } else {
  644.             $sellang = "";
  645.     }
  646.     echo "<option value=\"\" $sellang>"._ALL."</option></select>";
  647.     } else {
  648.     echo "<input type=\"hidden\" name=\"alanguage\" value=\"\">";
  649.     }
  650.     echo "<br><br><b>"._STORYTEXT."</b><br>"
  651.     ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"7\" name=\"hometext\">$story</textarea><br><br>"
  652.     ."<b>"._EXTENDEDTEXT."</b><br>"
  653.     ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"8\" name=\"bodytext\">$storyext</textarea><BR>"
  654.     ."<font class=\"content\">"._AREYOUSURE."</font><br><br>"
  655.     ."<b>"._NOTES."</b><br>"
  656.     ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"4\" name=\"notes\"></textarea><br>"
  657.     ."<input type=\"hidden\" NAME=\"qid\" size=\"50\" value=\"$qid\">"
  658.     ."<input type=\"hidden\" NAME=\"uid\" size=\"50\" value=\"$uid\">"
  659.     ."<br><b>"._PROGRAMSTORY."</b>  "
  660.     ."<input type=\"radio\" name=\"automated\" value=\"1\">"._YES."   "
  661.     ."<input type=\"radio\" name=\"automated\" value=\"0\" checked>"._NO."<br><br>"
  662.     .""._NOWIS.": $date<br><br>";
  663.     $day = 1;
  664.     echo ""._DAY.": <select name=\"day\">";
  665.     while ($day <= 31) {
  666.     if ($tday==$day) {
  667.         $sel = "selected";
  668.     } else {
  669.         $sel = "";
  670.     }
  671.     echo "<option name=\"day\" $sel>$day</option>";
  672.     $day++;
  673.     }
  674.     echo "</select>";
  675.     $month = 1;
  676.     echo ""._UMONTH.": <select name=\"month\">";
  677.     while ($month <= 12) {
  678.     if ($ttmon==$month) {
  679.         $sel = "selected";
  680.     } else {
  681.         $sel = "";
  682.     }
  683.     echo "<option name=\"month\" $sel>$month</option>";
  684.     $month++;
  685.     }
  686.     echo "</select>";
  687.     $date = getdate();
  688.     $year = $date[year];
  689.     echo ""._YEAR.": <input type=\"text\" name=\"year\" value=\"$year\" size=\"5\" maxlength=\"4\">";
  690.     echo "<br>"._HOUR.": <select name=\"hour\">";
  691.     $hour = 0;
  692.     $cero = "0";
  693.     while ($hour <= 23) {
  694.     $dummy = $hour;
  695.     if ($hour < 10) {
  696.         $hour = "$cero$hour";
  697.     }
  698.     echo "<option name=\"hour\">$hour</option>";
  699.     $hour = $dummy;
  700.     $hour++;
  701.     }
  702.     echo "</select>";
  703.     echo ": <select name=\"min\">";
  704.     $min = 0;
  705.     while ($min <= 59) {
  706.     if (($min == 0) OR ($min == 5)) {
  707.         $min = "0$min";
  708.     }
  709.     echo "<option name=\"min\">$min</option>";
  710.     $min = $min + 5;
  711.     }
  712.     echo "</select>";
  713.     echo ": 00<br><br>"
  714.     ."<select name=\"op\">"
  715.     ."<option value=\"DeleteStory\">"._DELETESTORY."</option>"
  716.     ."<option value=\"PreviewAgain\" selected>"._PREVIEWSTORY."</option>"
  717.     ."<option value=\"PostStory\">"._POSTSTORY."</option>"
  718.     ."</select>"
  719.     ."<input type=\"submit\" value=\""._OK."\">    [ <a href=\"admin.php?op=DeleteStory&qid=$qid\">"._DELETE."</a> ]";
  720.     CloseTable();
  721.     echo "<br>";
  722.     putpoll($pollTitle, $optionText);
  723.     echo "</form>";
  724.     include ('footer.php');
  725. }
  726.  
  727. function previewStory($automated, $year, $day, $month, $hour, $min, $qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $alanguage, $acomm, $pollTitle, $optionText) {
  728.     global $user, $boxstuff, $anonymous, $bgcolor1, $bgcolor2, $prefix, $dbi, $multilingual;
  729.     include ('header.php');
  730.     GraphicAdmin();
  731.     OpenTable();
  732.     echo "<center><font class=\"title\"><b>"._ARTICLEADMIN."</b></font></center>";
  733.     CloseTable();
  734.     echo "<br>";
  735.     $today = getdate();
  736.     $tday = $today[mday];
  737.     if ($tday < 10){
  738.     $tday = "0$tday";
  739.     }
  740.     $tmonth = $today[month];
  741.     $tyear = $today[year];
  742.     $thour = $today[hours];
  743.     if ($thour < 10){
  744.     $thour = "0$thour";
  745.     }
  746.     $tmin = $today[minutes];
  747.     if ($tmin < 10){
  748.     $tmin = "0$tmin";
  749.     }
  750.     $tsec = $today[seconds];
  751.     if ($tsec < 10){
  752.     $tsec = "0$tsec";
  753.     }
  754.     $date = "$tmonth $tday, $tyear @ $thour:$tmin:$tsec";
  755.     $subject = stripslashes($subject);
  756.     $hometext = stripslashes($hometext);
  757.     $bodytext = stripslashes($bodytext);
  758.     $notes = stripslashes($notes);
  759.     OpenTable();
  760.     echo "<font class=\"content\">"
  761.     ."<form action=\"admin.php\" method=\"post\">"
  762.     ."<b>"._NAME."</b><br>"
  763.     ."<input type=\"text\" name=\"author\" size=\"25\" value=\"$author\">";
  764.     if ($author != $anonymous) {
  765.     $res = sql_query("select email from ".$prefix."_users where uname='$author'", $dbi);
  766.     list($email) = sql_fetch_row($res, $dbi);
  767.     echo "  <font class=\"content\">[ <a href=\"mailto:$email\">Email User</a> | <a href=\"modules.php?name=Private_Messages&file=reply&send=1&uname=$author\">Send Private Message</a> ]</font>";
  768.     }
  769.     echo "<br><br><b>"._TITLE."</b><br>"
  770.     ."<input type=\"text\" name=\"subject\" size=\"50\" value=\"$subject\"><br><br>";
  771.     $result = sql_query("select topicimage from ".$prefix."_topics where topicid=$topic", $dbi);
  772.     list($topicimage) = sql_fetch_row($result, $dbi);
  773.     echo "<table width=\"70%\" bgcolor=\"$bgcolor2\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\"align=\"center\"><tr><td>"
  774.     ."<table width=\"100%\" bgcolor=\"$bgcolor1\" cellpadding=\"8\" cellspacing=\"1\" border=\"0\"><tr><td>"
  775.     ."<img src=\"images/topics/$topicimage\" border=\"0\" align=\"right\">";
  776.     themepreview($subject, $hometext, $bodytext, $notes);
  777.     echo "</td></tr></table></td></tr></table>"
  778.     ."<br><b>"._TOPIC."</b> <select name=\"topic\">";
  779.     $toplist = sql_query("select topicid, topictext from ".$prefix."_topics order by topictext", $dbi);
  780.     echo "<option value=\"\">"._ALLTOPICS."</option>\n";
  781.     while(list($topicid, $topics) = sql_fetch_row($toplist, $dbi)) {
  782.         if ($topicid==$topic) {
  783.         $sel = "selected ";
  784.     }
  785.         echo "<option $sel value=\"$topicid\">$topics</option>\n";
  786.     $sel = "";
  787.     }
  788.     echo "</select>";
  789.     echo "<br><br>";
  790.     $cat = $catid;
  791.     SelectCategory($cat);
  792.     echo "<br>";
  793.     puthome($ihome, $acomm);
  794.     if ($multilingual == 1) {
  795.     echo "<br><b>"._LANGUAGE.": </b>"
  796.         ."<select name=\"alanguage\">";
  797.     $handle=opendir('language');
  798.     while ($file = readdir($handle)) {
  799.         if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
  800.             $langFound = $matches[1];
  801.             $languageslist .= "$langFound ";
  802.         }
  803.     }
  804.     closedir($handle);
  805.     $languageslist = explode(" ", $languageslist);
  806.     sort($languageslist);
  807.     for ($i=0; $i < sizeof($languageslist); $i++) {
  808.         if($languageslist[$i]!="") {
  809.         echo "<option value=\"$languageslist[$i]\" ";
  810.         if($languageslist[$i]==$alanguage) echo "selected";
  811.         echo ">".ucfirst($languageslist[$i])."</option>\n";
  812.         }
  813.     }
  814.     if ($alanguage == "") {
  815.         $sellang = "selected";
  816.     } else {
  817.             $sellang = "";
  818.     }
  819.     echo "<option value=\"\" $sellang>"._ALL."</option></select>";
  820.     } else {
  821.     echo "<input type=\"hidden\" name=\"alanguage\" value=\"$language\">";
  822.     }
  823.     echo "<br><br><b>"._STORYTEXT."</b><br>"
  824.     ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"7\" name=\"hometext\">$hometext</textarea><br><br>"
  825.     ."<b>"._EXTENDEDTEXT."</b><br>"
  826.     ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"10\" name=\"bodytext\">$bodytext</textarea><br>"
  827.     ."<font class=\"content\">"._AREYOUSURE."</font><br><br>"
  828.     ."<b>"._NOTES."</b><br>"
  829.     ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"4\" name=\"notes\">$notes</textarea><br><br>"
  830.     ."<input type=\"hidden\" NAME=\"qid\" size=\"50\" value=\"$qid\">"
  831.     ."<input type=\"hidden\" NAME=\"uid\" size=\"50\" value=\"$uid\">";
  832.     if ($automated == 1) {
  833.     $sel1 = "checked";
  834.     $sel2 = "";
  835.     } else {
  836.     $sel1 = "";
  837.     $sel2 = "checked";
  838.     }
  839.     echo "<b>"._PROGRAMSTORY."</b>  "
  840.     ."<input type=\"radio\" name=\"automated\" value=\"1\" $sel1>"._YES."   "
  841.     ."<input type=\"radio\" name=\"automated\" value=\"0\" $sel2>"._NO."<br><br>"
  842.     .""._NOWIS.": $date<br><br>";
  843.     $xday = 1;
  844.     echo ""._DAY.": <select name=\"day\">";
  845.     while ($xday <= 31) {
  846.     if ($xday == $day) {
  847.         $sel = "selected";
  848.     } else {
  849.         $sel = "";
  850.     }
  851.     echo "<option name=\"day\" $sel>$xday</option>";
  852.     $xday++;
  853.     }
  854.     echo "</select>";
  855.     $xmonth = 1;
  856.     echo ""._UMONTH.": <select name=\"month\">";
  857.     while ($xmonth <= 12) {
  858.     if ($xmonth == $month) {
  859.         $sel = "selected";
  860.     } else {
  861.         $sel = "";
  862.     }
  863.     echo "<option name=\"month\" $sel>$xmonth</option>";
  864.     $xmonth++;
  865.     }
  866.     echo "</select>";
  867.     echo ""._YEAR.": <input type=\"text\" name=\"year\" value=\"$year\" size=\"5\" maxlength=\"4\">";
  868.     echo "<br>"._HOUR.": <select name=\"hour\">";
  869.     $xhour = 0;
  870.     $cero = "0";
  871.     while ($xhour <= 23) {
  872.     $dummy = $xhour;
  873.     if ($xhour < 10) {
  874.         $xhour = "$cero$xhour";
  875.     }
  876.     if ($xhour == $hour) {
  877.         $sel = "selected";
  878.     } else {
  879.         $sel = "";
  880.     }
  881.     echo "<option name=\"hour\" $sel>$xhour</option>";
  882.     $xhour = $dummy;
  883.     $xhour++;
  884.     }
  885.     echo "</select>";
  886.     echo ": <select name=\"min\">";
  887.     $xmin = 0;
  888.     while ($xmin <= 59) {
  889.     if (($xmin == 0) OR ($xmin == 5)) {
  890.         $xmin = "0$xmin";
  891.     }
  892.     if ($xmin == $min) {
  893.         $sel = "selected";
  894.     } else {
  895.         $sel = "";
  896.     }
  897.     echo "<option name=\"min\" $sel>$xmin</option>";
  898.     $xmin = $xmin + 5;
  899.     }
  900.     echo "</select>";
  901.     echo ": 00<br><br>"
  902.     ."<select name=\"op\">"
  903.     ."<option value=\"DeleteStory\">"._DELETESTORY."</option>"
  904.     ."<option value=\"PreviewAgain\" selected>"._PREVIEWSTORY."</option>"
  905.     ."<option value=\"PostStory\">"._POSTSTORY."</option>"
  906.     ."</select>"
  907.     ."<input type=\"submit\" value=\""._OK."\">";
  908.     CloseTable();
  909.     echo "<br>";
  910.     putpoll($pollTitle, $optionText);
  911.     echo "</form>";
  912.     include ('footer.php');
  913. }
  914.  
  915. function postStory($automated, $year, $day, $month, $hour, $min, $qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $alanguage, $acomm, $pollTitle, $optionText) {
  916.     global $aid, $ultramode, $prefix, $dbi;
  917.     if ($automated == 1) {
  918.         if ($day < 10) {
  919.         $day = "0$day";
  920.     }
  921.     if ($month < 10) {
  922.         $month = "0$month";
  923.     }
  924.     $sec = "00";
  925.     $date = "$year-$month-$day $hour:$min:$sec";
  926.     if ($uid == 1) $author = "";
  927.     if ($hometext == $bodytext) $bodytext = "";
  928.     $subject = stripslashes(FixQuotes($subject));
  929.     $hometext = stripslashes(FixQuotes($hometext));
  930.     $bodytext = stripslashes(FixQuotes($bodytext));
  931.     $notes = stripslashes(FixQuotes($notes));
  932.     $result = sql_query("insert into ".$prefix."_autonews values (NULL, '$catid', '$aid', '$subject', '$date', '$hometext', '$bodytext', '$topic', '$author', '$notes', '$ihome', '$alanguage', '$acomm')", $dbi);
  933.     if (!$result) {
  934.         return;
  935.     }
  936.     if ($uid == 1) {
  937.     } else {
  938.         sql_query("update ".$prefix."_users set counter=counter+1 where uid='$uid'", $dbi);
  939.     }
  940.         sql_query("update ".$prefix."_authors set counter=counter+1 where aid='$aid'", $dbi);
  941.     if ($ultramode) {
  942.             ultramode();
  943.     }
  944.     sql_query("delete from ".$prefix."_queue where qid=$qid", $dbi);
  945.     Header("Location: admin.php?op=submissions");
  946.     } else {
  947.     if ($uid == 1) $author = "";
  948.     if ($hometext == $bodytext) $bodytext = "";
  949.     $subject = stripslashes(FixQuotes($subject));
  950.     $hometext = stripslashes(FixQuotes($hometext));
  951.     $bodytext = stripslashes(FixQuotes($bodytext));
  952.     $notes = stripslashes(FixQuotes($notes));
  953.     if (($pollTitle != "") AND ($optionText[1] != "") AND ($optionText[2] != "")) {
  954.         $haspoll = 1;
  955.         $timeStamp = time();
  956.         $pollTitle = FixQuotes($pollTitle);
  957.         if(!sql_query("INSERT INTO ".$prefix."_poll_desc VALUES (NULL, '$pollTitle', '$timeStamp', 0, '$alanguage', '0')", $dbi)) {
  958.         return;
  959.         }
  960.         $object = sql_fetch_object(sql_query("SELECT pollID FROM ".$prefix."_poll_desc WHERE pollTitle='$pollTitle'", $dbi), $dbi);
  961.         $id = $object->pollID;
  962.         for($i = 1; $i <= sizeof($optionText); $i++) {
  963.         if($optionText[$i] != "") {
  964.             $optionText[$i] = FixQuotes($optionText[$i]);
  965.         }
  966.         if(!sql_query("INSERT INTO ".$prefix."_poll_data (pollID, optionText, optionCount, voteID) VALUES ($id, '$optionText[$i]', 0, $i)", $dbi)) {
  967.             return;
  968.         }
  969.         }
  970.     } else {
  971.         $haspoll = 0;
  972.         $id = 0;
  973.     }
  974.     $result = sql_query("insert into ".$prefix."_stories values (NULL, '$catid', '$aid', '$subject', now(), '$hometext', '$bodytext', '0', '0', '$topic', '$author', '$notes', '$ihome', '$alanguage', '$acomm', '$haspoll', '$id', '0', '0')", $dbi);
  975.     $result = sql_query("select sid from ".$prefix."_stories WHERE title='$subject' order by time DESC limit 0,1", $dbi);
  976.     list($artid) = sql_fetch_row($result, $dbi);
  977.     sql_query("UPDATE ".$prefix."_poll_desc SET artid='$artid' WHERE pollID='$id'", $dbi);
  978.     if (!$result) {
  979.         return;
  980.     }
  981.     if ($uid == 1) {
  982.     } else {
  983.             sql_query("update ".$prefix."_users set counter=counter+1 where uid='$uid'", $dbi);
  984.     }
  985.     sql_query("update ".$prefix."_authors set counter=counter+1 where aid='$aid'", $dbi);
  986.     if ($ultramode) {
  987.             ultramode();
  988.     }
  989.     deleteStory($qid);
  990.     }
  991. }
  992.  
  993. function editStory($sid) {
  994.     global $user, $bgcolor1, $bgcolor2, $aid, $prefix, $dbi, $multilingual;
  995.     $result = sql_query("select radminarticle, radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
  996.     list($radminarticle, $radminsuper) = sql_fetch_row($result, $dbi);
  997.     $result2 = sql_query("select aid from ".$prefix."_stories where sid='$sid'", $dbi);
  998.     list($aaid) = sql_fetch_row($result2, $dbi);
  999.     if (($radminarticle == 1) AND ($aaid == $aid) OR ($radminsuper == 1)) {
  1000.     include ('header.php');
  1001.     GraphicAdmin();
  1002.     OpenTable();
  1003.     echo "<center><font class=\"title\"><b>"._ARTICLEADMIN."</b></font></center>";
  1004.     CloseTable();
  1005.     echo "<br>";
  1006.     $result = sql_query("SELECT catid, title, hometext, bodytext, topic, notes, ihome, alanguage, acomm FROM ".$prefix."_stories where sid=$sid", $dbi);
  1007.         list($catid, $subject, $hometext, $bodytext, $topic, $notes, $ihome, $alanguage, $acomm) = sql_fetch_row($result, $dbi);
  1008.     $subject = stripslashes($subject);
  1009.         $hometext = stripslashes($hometext);
  1010.         $bodytext = stripslashes($bodytext);
  1011.         $notes = stripslashes($notes);
  1012.         $result2=sql_query("select topicimage from ".$prefix."_topics where topicid=$topic", $dbi);
  1013.         list($topicimage) = sql_fetch_row($result2, $dbi);
  1014.         OpenTable();
  1015.         echo "<center><font class=\"option\"><b>"._EDITARTICLE."</b></font></center><br>"
  1016.         ."<table width=\"80%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"$bgcolor2\" align=\"center\"><tr><td>"
  1017.         ."<table width=\"100%\" border=\"0\" cellpadding=\"8\" cellspacing=\"1\" bgcolor=\"$bgcolor1\"><tr><td>"
  1018.         ."<img src=\"images/topics/$topicimage\" border=\"0\" align=\"right\">";
  1019.     themepreview($subject, $hometext, $bodytext, $notes);
  1020.     echo "</td></tr></table></td></tr></table><br><br>"
  1021.         ."<form action=\"admin.php\" method=\"post\">"
  1022.         ."<b>"._TITLE."</b><br>"
  1023.         ."<input type=\"text\" name=\"subject\" size=\"50\" value=\"$subject\"><br><br>"
  1024.         ."<b>"._TOPIC."</b> <select name=\"topic\">";
  1025.     $toplist = sql_query("select topicid, topictext from ".$prefix."_topics order by topictext", $dbi);
  1026.     echo "<option value=\"\">"._ALLTOPICS."</option>\n";
  1027.     while(list($topicid, $topics) = sql_fetch_row($toplist, $dbi)) {
  1028.             if ($topicid==$topic) { $sel = "selected "; }
  1029.             echo "<option $sel value=\"$topicid\">$topics</option>\n";
  1030.         $sel = "";
  1031.     }
  1032.     echo "</select>";
  1033.     echo "<br><br>";
  1034.     $cat = $catid;
  1035.     SelectCategory($cat);
  1036.     echo "<br>";
  1037.     puthome($ihome, $acomm);
  1038.     if ($multilingual == 1) {
  1039.         echo "<br><b>"._LANGUAGE.":</b>"
  1040.         ."<select name=\"alanguage\">";
  1041.         $handle=opendir('language');
  1042.         while ($file = readdir($handle)) {
  1043.         if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
  1044.                 $langFound = $matches[1];
  1045.                 $languageslist .= "$langFound ";
  1046.             }
  1047.         }
  1048.         closedir($handle);
  1049.         $languageslist = explode(" ", $languageslist);
  1050.         sort($languageslist);
  1051.         for ($i=0; $i < sizeof($languageslist); $i++) {
  1052.             if($languageslist[$i]!="") {
  1053.             echo "<option name=\"alanguage\" value=\"$languageslist[$i]\" ";
  1054.             if($languageslist[$i]==$alanguage) echo "selected";
  1055.             echo ">".ucfirst($languageslist[$i])."\n</option>";
  1056.         }
  1057.         }
  1058.         if ($alanguage == "") {
  1059.         $sellang = "selected";
  1060.         } else {
  1061.             $sellang = "";
  1062.         }
  1063.         echo "<option value=\"\" $sellang>"._ALL."</option></select>";
  1064.     } else {
  1065.         echo "<input type=\"hidden\" name=\"alanguage\" value=\"\">";
  1066.     }
  1067.     echo "<br><br><b>"._STORYTEXT."</b><br>"
  1068.         ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"7\" name=\"hometext\">$hometext</textarea><br><br>"
  1069.         ."<b>"._EXTENDEDTEXT."</b><br>"
  1070.         ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"10\" name=\"bodytext\">$bodytext</textarea><br>"
  1071.         ."<font class=\"content\">"._AREYOUSURE."</font><br><br>"
  1072.         ."<b>"._NOTES."</b><br>"
  1073.         ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"4\" name=\"notes\">$notes</textarea><br><br>"
  1074.         ."<input type=\"hidden\" NAME=\"sid\" size=\"50\" value=\"$sid\">"
  1075.         ."<input type=\"hidden\" name=\"op\" value=\"ChangeStory\">"
  1076.         ."<input type=\"submit\" value=\""._SAVECHANGES."\">"
  1077.         ."</form>";
  1078.     CloseTable();
  1079.     include ('footer.php');
  1080.     } else {
  1081.     include ('header.php');
  1082.     GraphicAdmin();
  1083.     OpenTable();
  1084.     echo "<center><font class=\"title\"><b>"._ARTICLEADMIN."</b></font></center>";
  1085.     CloseTable();
  1086.     echo "<br>";
  1087.     OpenTable();
  1088.     echo "<center><b>"._NOTAUTHORIZED1."</b><br><br>"
  1089.         .""._NOTAUTHORIZED2."<br><br>"
  1090.         .""._GOBACK."";
  1091.     CloseTable();
  1092.     include("footer.php");
  1093.     }
  1094. }
  1095.  
  1096. function removeStory($sid, $ok=0) {
  1097.     global $ultramode, $aid, $prefix, $dbi;
  1098.     $result = sql_query("select counter, radminarticle, radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
  1099.     list($counter, $radminarticle, $radminsuper) = sql_fetch_row($result, $dbi);
  1100.     $result2 = sql_query("select aid from ".$prefix."_stories where sid='$sid'", $dbi);
  1101.     list($aaid) = sql_fetch_row($result2, $dbi);
  1102.     if (($radminarticle == 1) AND ($aaid == $aid) OR ($radminsuper == 1)) {
  1103.     if($ok) {
  1104.         $counter--;
  1105.             sql_query("DELETE FROM ".$prefix."_stories where sid=$sid", $dbi);
  1106.         sql_query("DELETE FROM ".$prefix."_comments where sid=$sid", $dbi);
  1107.         sql_query("update ".$prefix."_poll_desc set artid='0' where artid='$sid'", $dbi);
  1108.         $result = sql_query("update ".$prefix."_authors set counter='$counter' where aid='$aid'", $dbi);
  1109.         if ($ultramode) {
  1110.             ultramode();
  1111.         }
  1112.         Header("Location: admin.php");
  1113.     } else {
  1114.         include("header.php");
  1115.         GraphicAdmin();
  1116.         OpenTable();
  1117.         echo "<center><font class=\"title\"><b>"._ARTICLEADMIN."</b></font></center>";
  1118.         CloseTable();
  1119.         echo "<br>";
  1120.         OpenTable();
  1121.         echo "<center>"._REMOVESTORY." $sid "._ANDCOMMENTS."";
  1122.         echo "<br><br>[ <a href=\"admin.php\">"._NO."</a> | <a href=\"admin.php?op=RemoveStory&sid=$sid&ok=1\">"._YES."</a> ]</center>";
  1123.             CloseTable();
  1124.         include("footer.php");
  1125.     }
  1126.     } else {
  1127.     include ('header.php');
  1128.     GraphicAdmin();
  1129.     OpenTable();
  1130.     echo "<center><font class=\"title\"><b>"._ARTICLEADMIN."</b></font></center>";
  1131.     CloseTable();
  1132.     echo "<br>";
  1133.     OpenTable();
  1134.     echo "<center><b>"._NOTAUTHORIZED1."</b><br><br>"
  1135.         .""._NOTAUTHORIZED2."<br><br>"
  1136.         .""._GOBACK."";
  1137.     CloseTable();
  1138.     include("footer.php");
  1139.     }
  1140. }
  1141.  
  1142.  
  1143. function changeStory($sid, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $alanguage, $acomm) {
  1144.     global $aid, $ultramode, $prefix, $dbi;
  1145.     $result = sql_query("select radminarticle, radminsuper from ".$prefix."_authors where aid='$aid'", $dbi);
  1146.     list($radminarticle, $radminsuper) = sql_fetch_row($result, $dbi);
  1147.     $result2 = sql_query("select aid from ".$prefix."_stories where sid='$sid'", $dbi);
  1148.     list($aaid) = sql_fetch_row($result2, $dbi);
  1149.     if (($radminarticle == 1) AND ($aaid == $aid) OR ($radminsuper == 1)) {
  1150.     $subject = stripslashes(FixQuotes($subject));
  1151.     $hometext = stripslashes(FixQuotes($hometext));
  1152.     $bodytext = stripslashes(FixQuotes($bodytext));
  1153.     $notes = stripslashes(FixQuotes($notes));
  1154.     sql_query("update ".$prefix."_stories set catid='$catid', title='$subject', hometext='$hometext', bodytext='$bodytext', topic='$topic', notes='$notes', ihome='$ihome', alanguage='$alanguage', acomm='$acomm' where sid=$sid", $dbi);
  1155.     if ($ultramode) {
  1156.             ultramode();
  1157.     }
  1158.     Header("Location: admin.php?op=adminMain");
  1159.     }
  1160. }
  1161.  
  1162. function adminStory() {
  1163.     global $prefix, $dbi, $language, $multilingual;
  1164.     
  1165.     include ('header.php');
  1166.     GraphicAdmin();
  1167.     OpenTable();
  1168.     echo "<center><font class=\"title\"><b>"._ARTICLEADMIN."</b></font></center>";
  1169.     CloseTable();
  1170.     echo "<br>";
  1171.     $today = getdate();
  1172.     $tday = $today[mday];
  1173.     if ($tday < 10){
  1174.     $tday = "0$tday";
  1175.     }
  1176.     $tmonth = $today[month];
  1177.     $ttmon = $today[mon];
  1178.     if ($ttmon < 10){
  1179.     $ttmon = "0$ttmon";
  1180.     }
  1181.     $tyear = $today[year];
  1182.     $thour = $today[hours];
  1183.     if ($thour < 10){
  1184.     $thour = "0$thour";
  1185.     }
  1186.     $tmin = $today[minutes];
  1187.     if ($tmin < 10){
  1188.     $tmin = "0$tmin";
  1189.     }
  1190.     $tsec = $today[seconds];
  1191.     if ($tsec < 10){
  1192.     $tsec = "0$tsec";
  1193.     }
  1194.     $date = "$tmonth $tday, $tyear @ $thour:$tmin:$tsec";
  1195.     OpenTable();
  1196.     echo "<center><font class=\"option\"><b>"._ADDARTICLE."</b></font></center><br><br>"
  1197.         ."<form action=\"admin.php\" method=\"post\">"
  1198.     ."<b>"._TITLE."</b><br>"
  1199.     ."<input type=\"text\" name=\"subject\" size=\"50\"><br><br>"
  1200.     ."<b>"._TOPIC."</b>";
  1201.     $toplist = sql_query("select topicid, topictext from ".$prefix."_topics order by topictext", $dbi);
  1202.     echo "<select name=\"topic\">";
  1203.     echo "<option value=\"\">"._SELECTTOPIC."</option>\n";
  1204.     while(list($topicid, $topics) = sql_fetch_row($toplist, $dbi)) {
  1205.         if ($topicid == $topic) {
  1206.         $sel = "selected ";
  1207.     }
  1208.         echo "<option $sel value=\"$topicid\">$topics</option>\n";
  1209.     $sel = "";
  1210.     }
  1211.     echo "</select><br><br>";
  1212.     $cat = 0;
  1213.     SelectCategory($cat);
  1214.     echo "<br>";
  1215.     puthome($ihome, $acomm);
  1216.     if ($multilingual == 1) {
  1217.     echo "<br><b>"._LANGUAGE.": </b>"
  1218.         ."<select name=\"alanguage\">";
  1219.     $handle=opendir('language');
  1220.     while ($file = readdir($handle)) {
  1221.         if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
  1222.             $langFound = $matches[1];
  1223.             $languageslist .= "$langFound ";
  1224.         }
  1225.     }
  1226.     closedir($handle);
  1227.     $languageslist = explode(" ", $languageslist);
  1228.     sort($languageslist);
  1229.     for ($i=0; $i < sizeof($languageslist); $i++) {
  1230.         if($languageslist[$i]!="") {
  1231.         echo "<option value=\"$languageslist[$i]\" ";
  1232.         if($languageslist[$i]==$language) echo "selected";
  1233.         echo ">".ucfirst($languageslist[$i])."</option>\n";
  1234.         }
  1235.     }
  1236.     echo "<option value=\"\">"._ALL."</option></select>";
  1237.     } else {
  1238.     echo "<input type=\"hidden\" name=\"alanguage\" value=\"$language\">";
  1239.     }
  1240.     echo "<br><br><b>"._STORYTEXT."</b><br>"
  1241.     ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"12\" name=\"hometext\"></textarea><br><br>"
  1242.     ."<b>"._EXTENDEDTEXT."</b><br>"
  1243.     ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"12\" name=\"bodytext\"></textarea><br>"
  1244.     ."<font class=\"content\">"._ARESUREURL."</font>"
  1245.     ."<br><br><b>"._PROGRAMSTORY."</b>  "
  1246.     ."<input type=radio name=automated value=1>"._YES."   "
  1247.     ."<input type=radio name=automated value=0 checked>"._NO."<br><br>"
  1248.     .""._NOWIS.": $date<br><br>";
  1249.     $day = 1;
  1250.     echo ""._DAY.": <select name=\"day\">";
  1251.     while ($day <= 31) {
  1252.     if ($tday==$day) {
  1253.         $sel = "selected";
  1254.     } else {
  1255.         $sel = "";
  1256.     }
  1257.     echo "<option name=\"day\" $sel>$day</option>";
  1258.     $day++;
  1259.     }
  1260.     echo "</select>";
  1261.     $month = 1;
  1262.     echo ""._UMONTH.": <select name=\"month\">";
  1263.     while ($month <= 12) {
  1264.     if ($ttmon==$month) {
  1265.         $sel = "selected";
  1266.     } else {
  1267.         $sel = "";
  1268.     }
  1269.     echo "<option name=\"month\" $sel>$month</option>";
  1270.     $month++;
  1271.     }
  1272.     echo "</select>";
  1273.     $date = getdate();
  1274.     $year = $date[year];
  1275.     echo ""._YEAR.": <input type=\"text\" name=\"year\" value=\"$year\" size=\"5\" maxlength=\"4\">"
  1276.     ."<br>"._HOUR.": <select name=\"hour\">";
  1277.     $hour = 0;
  1278.     $cero = "0";
  1279.     while ($hour <= 23) {
  1280.     $dummy = $hour;
  1281.     if ($hour < 10) {
  1282.         $hour = "$cero$hour";
  1283.     }
  1284.     echo "<option name=\"hour\">$hour</option>";
  1285.     $hour = $dummy;
  1286.     $hour++;
  1287.     }
  1288.     echo "</select>"
  1289.     .": <select name=\"min\">";
  1290.     $min = 0;
  1291.     while ($min <= 59) {
  1292.     if (($min == 0) OR ($min == 5)) {
  1293.         $min = "0$min";
  1294.     }
  1295.     echo "<option name=\"min\">$min</option>";
  1296.     $min = $min + 5;
  1297.     }
  1298.     echo "</select>";
  1299.     echo ": 00<br><br>"
  1300.     ."<select name=\"op\">"
  1301.     ."<option value=\"PreviewAdminStory\" selected>"._PREVIEWSTORY."</option>"
  1302.     ."<option value=\"PostAdminStory\">"._POSTSTORY."</option>"
  1303.     ."</select>"
  1304.     ."<input type=\"submit\" value=\""._OK."\">";
  1305.     CloseTable();
  1306.     echo "<br>";
  1307.     putpoll($pollTitle, $optionText);
  1308.     echo "</form>";
  1309.     include ('footer.php');
  1310. }
  1311.  
  1312. function previewAdminStory($automated, $year, $day, $month, $hour, $min, $subject, $hometext, $bodytext, $topic, $catid, $ihome, $alanguage, $acomm, $pollTitle, $optionText) {
  1313.     global $user, $bgcolor1, $bgcolor2, $prefix, $dbi, $alanguage, $multilingual;
  1314.     include ('header.php');
  1315.     if ($topic<1) {
  1316.         $topic = 1;
  1317.     }
  1318.     GraphicAdmin();
  1319.     OpenTable();
  1320.     echo "<center><font class=\"title\"><b>"._ARTICLEADMIN."</b></font></center>";
  1321.     CloseTable();
  1322.     echo "<br>";
  1323.     $today = getdate();
  1324.     $tday = $today[mday];
  1325.     if ($tday < 10){
  1326.     $tday = "0$tday";
  1327.     }
  1328.     $tmonth = $today[month];
  1329.     $tyear = $today[year];
  1330.     $thour = $today[hours];
  1331.     if ($thour < 10){
  1332.     $thour = "0$thour";
  1333.     }
  1334.     $tmin = $today[minutes];
  1335.     if ($tmin < 10){
  1336.     $tmin = "0$tmin";
  1337.     }
  1338.     $tsec = $today[seconds];
  1339.     if ($tsec < 10){
  1340.     $tsec = "0$tsec";
  1341.     }
  1342.     $date = "$tmonth $tday, $tyear @ $thour:$tmin:$tsec";
  1343.     OpenTable();
  1344.     echo "<center><font class=\"option\"><b>"._PREVIEWSTORY."</b></font></center><br><br>"
  1345.     ."<form action=\"admin.php\" method=\"post\">"
  1346.     ."<input type=\"hidden\" name=\"catid\" value=\"$catid\">";
  1347.     $subject = stripslashes($subject);
  1348.     $subject = ereg_replace("\"", "''", $subject);
  1349.     $hometext = stripslashes($hometext);
  1350.     $bodytext = stripslashes($bodytext);
  1351.     $result=sql_query("select topicimage from ".$prefix."_topics where topicid=$topic", $dbi);
  1352.     list($topicimage) = sql_fetch_row($result, $dbi);
  1353.     echo "<table border=\"0\" width=\"75%\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"$bgcolor2\" align=\"center\"><tr><td>"
  1354.     ."<table border=\"0\" width=\"100%\" cellpadding=\"8\" cellspacing=\"1\" bgcolor=\"$bgcolor1\"><tr><td>"
  1355.     ."<img src=\"images/topics/$topicimage\" border=\"0\" align=\"right\" alt=\"\">";
  1356.     themepreview($subject, $hometext, $bodytext);
  1357.     echo "</td></tr></table></td></tr></table>"
  1358.     ."<br><br><b>"._TITLE."</b><br>"
  1359.     ."<input type=\"text\" name=\"subject\" size=\"50\" value=\"$subject\"><br><br>"
  1360.     ."<b>"._TOPIC."</b><select name=\"topic\">";
  1361.     $toplist = sql_query("select topicid, topictext from ".$prefix."_topics order by topictext", $dbi);
  1362.     echo "<option value=\"\">"._ALLTOPICS."</option>\n";
  1363.     while(list($topicid, $topics) = sql_fetch_row($toplist, $dbi)) {
  1364.     if ($topicid==$topic) {
  1365.         $sel = "selected ";
  1366.     }
  1367.         echo "<option $sel value=\"$topicid\">$topics</option>\n";
  1368.     $sel = "";
  1369.     }
  1370.     echo "</select><br><br>";
  1371.     $cat = $catid;
  1372.     SelectCategory($cat);
  1373.     echo "<br>";
  1374.     puthome($ihome, $acomm);
  1375.     if ($multilingual == 1) {
  1376.     echo "<br><b>"._LANGUAGE.": </b>"
  1377.         ."<select name=\"alanguage\">";
  1378.     $handle=opendir('language');
  1379.     while ($file = readdir($handle)) {
  1380.         if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
  1381.             $langFound = $matches[1];
  1382.             $languageslist .= "$langFound ";
  1383.         }
  1384.     }
  1385.     closedir($handle);
  1386.     $languageslist = explode(" ", $languageslist);
  1387.     sort($languageslist);
  1388.     for ($i=0; $i < sizeof($languageslist); $i++) {
  1389.         if($languageslist[$i]!="") {
  1390.         echo "<option value=\"$languageslist[$i]\" ";
  1391.         if($languageslist[$i]==$alanguage) echo "selected";
  1392.         echo ">".ucfirst($languageslist[$i])."</option>\n";
  1393.         }
  1394.     }
  1395.     if ($alanguage == "") {
  1396.         $sellang = "selected";
  1397.     } else {
  1398.             $sellang = "";
  1399.     }
  1400.     echo "<option value=\"\" $sellang>"._ALL."</option></select>";
  1401.     } else {
  1402.     echo "<input type=\"hidden\" name=\"alanguage\" value=\"$language\">";
  1403.     }
  1404.     echo "<br><br><b>"._STORYTEXT."</b><br>"
  1405.     ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"12\" name=\"hometext\">$hometext</textarea><br><br>"
  1406.     ."<b>"._EXTENDEDTEXT."</b><br>"
  1407.     ."<textarea wrap=\"virtual\" cols=\"50\" rows=\"12\" name=\"bodytext\">$bodytext</textarea><br><br>";
  1408.     if ($automated == 1) {
  1409.     $sel1 = "checked";
  1410.     $sel2 = "";
  1411.     } else {
  1412.     $sel1 = "";
  1413.     $sel2 = "checked";
  1414.     }
  1415.     echo "<br><b>"._PROGRAMSTORY."</b>  "
  1416.     ."<input type=\"radio\" name=\"automated\" value=\"1\" $sel1>"._YES."   "
  1417.     ."<input type=\"radio\" name=\"automated\" value=\"0\" $sel2>"._NO."<br><br>"
  1418.     .""._NOWIS.": $date<br><br>";
  1419.     $xday = 1;
  1420.     echo ""._DAY.": <select name=\"day\">";
  1421.     while ($xday <= 31) {
  1422.     if ($xday == $day) {
  1423.         $sel = "selected";
  1424.     } else {
  1425.         $sel = "";
  1426.     }
  1427.     echo "<option name=\"day\" $sel>$xday</option>";
  1428.     $xday++;
  1429.     }
  1430.     echo "</select>";
  1431.     $xmonth = 1;
  1432.     echo ""._UMONTH.": <select name=\"month\">";
  1433.     while ($xmonth <= 12) {
  1434.     if ($xmonth == $month) {
  1435.         $sel = "selected";
  1436.     } else {
  1437.         $sel = "";
  1438.     }
  1439.     echo "<option name=\"month\" $sel>$xmonth</option>";
  1440.     $xmonth++;
  1441.     }
  1442.     echo "</select>";
  1443.     echo ""._YEAR.": <input type=\"text\" name=\"year\" value=\"$year\" size=\"5\" maxlength=\"4\">";
  1444.     echo "<br>"._HOUR.": <select name=\"hour\">";
  1445.     $xhour = 0;
  1446.     $cero = "0";
  1447.     while ($xhour <= 23) {
  1448.     $dummy = $xhour;
  1449.     if ($xhour < 10) {
  1450.         $xhour = "$cero$xhour";
  1451.     }
  1452.     if ($xhour == $hour) {
  1453.         $sel = "selected";
  1454.     } else {
  1455.         $sel = "";
  1456.     }
  1457.     echo "<option name=\"hour\" $sel>$xhour</option>";
  1458.     $xhour = $dummy;
  1459.     $xhour++;
  1460.     }
  1461.     echo "</select>";
  1462.     echo ": <select name=\"min\">";
  1463.     $xmin = 0;
  1464.     while ($xmin <= 59) {
  1465.     if (($xmin == 0) OR ($xmin == 5)) {
  1466.         $xmin = "0$xmin";
  1467.     }
  1468.     if ($xmin == $min) {
  1469.         $sel = "selected";
  1470.     } else {
  1471.         $sel = "";
  1472.     }
  1473.     echo "<option name=\"min\" $sel>$xmin</option>";
  1474.     $xmin = $xmin + 5;
  1475.     }
  1476.     echo "</select>";
  1477.     echo ": 00<br><br>"
  1478.     ."<select name=\"op\">"
  1479.     ."<option value=\"PreviewAdminStory\" selected>"._PREVIEWSTORY."</option>"
  1480.     ."<option value=\"PostAdminStory\">"._POSTSTORY."</option>"
  1481.     ."</select>"
  1482.     ."<input type=\"submit\" value=\""._OK."\">";
  1483.     CloseTable();
  1484.     echo "<br>";
  1485.     putpoll($pollTitle, $optionText);
  1486.     echo "</form>";
  1487.     include ('footer.php');
  1488. }
  1489.  
  1490. function postAdminStory($automated, $year, $day, $month, $hour, $min, $subject, $hometext, $bodytext, $topic, $catid, $ihome, $alanguage, $acomm, $pollTitle, $optionText) {
  1491.     global $aid, $prefix, $dbi;
  1492.     if ($automated == 1) {
  1493.     if ($day < 10) {
  1494.         $day = "0$day";
  1495.     }
  1496.     if ($month < 10) {
  1497.         $month = "0$month";
  1498.     }
  1499.     $sec = "00";
  1500.     $date = "$year-$month-$day $hour:$min:$sec";
  1501.     $notes = "";
  1502.     $author = $aid;
  1503.     $subject = stripslashes(FixQuotes($subject));
  1504.     $subject = ereg_replace("\"", "''", $subject);
  1505.     $hometext = stripslashes(FixQuotes($hometext));
  1506.     $bodytext = stripslashes(FixQuotes($bodytext));
  1507.     $result = sql_query("insert into ".$prefix."_autonews values (NULL, '$catid', '$aid', '$subject', '$date', '$hometext', '$bodytext', '$topic', '$author', '$notes', '$ihome', '$alanguage', '$acomm')", $dbi);
  1508.     if (!$result) {
  1509.         exit();
  1510.     }
  1511.     $result = sql_query("update ".$prefix."_authors set counter=counter+1 where aid='$aid'", $dbi);
  1512.     if ($ultramode) {
  1513.         ultramode();
  1514.     }
  1515.     Header("Location: admin.php?op=adminMain");
  1516.     } else {
  1517.     $subject = stripslashes(FixQuotes($subject));
  1518.     $hometext = stripslashes(FixQuotes($hometext));
  1519.     $bodytext = stripslashes(FixQuotes($bodytext));
  1520.     if (($pollTitle != "") AND ($optionText[1] != "") AND ($optionText[2] != "")) {
  1521.         $haspoll = 1;
  1522.         $timeStamp = time();
  1523.         $pollTitle = FixQuotes($pollTitle);
  1524.         if(!sql_query("INSERT INTO ".$prefix."_poll_desc VALUES (NULL, '$pollTitle', '$timeStamp', 0, '$alanguage', '0')", $dbi)) {
  1525.         return;
  1526.         }
  1527.         $object = sql_fetch_object(sql_query("SELECT pollID FROM ".$prefix."_poll_desc WHERE pollTitle='$pollTitle'", $dbi), $dbi);
  1528.         $id = $object->pollID;
  1529.         for($i = 1; $i <= sizeof($optionText); $i++) {
  1530.         if($optionText[$i] != "") {
  1531.             $optionText[$i] = FixQuotes($optionText[$i]);
  1532.         }
  1533.         if(!sql_query("INSERT INTO ".$prefix."_poll_data (pollID, optionText, optionCount, voteID) VALUES ($id, '$optionText[$i]', 0, $i)", $dbi)) {
  1534.             return;
  1535.         }
  1536.         }
  1537.     } else {
  1538.         $haspoll = 0;
  1539.         $id = 0;
  1540.     }
  1541.     $result = sql_query("insert into ".$prefix."_stories values (NULL, '$catid', '$aid', '$subject', now(), '$hometext', '$bodytext', '0', '0', '$topic', '$aid', '$notes', '$ihome', '$alanguage', '$acomm', '$haspoll', '$id', '0', '0')", $dbi);
  1542.     $result = sql_query("select sid from ".$prefix."_stories WHERE title='$subject' order by time DESC limit 0,1", $dbi);
  1543.     list($artid) = sql_fetch_row($result, $dbi);
  1544.     sql_query("UPDATE ".$prefix."_poll_desc SET artid='$artid' WHERE pollID='$id'", $dbi);
  1545.     if (!$result) {
  1546.         exit();
  1547.     }
  1548.     $result = sql_query("update ".$prefix."_authors set counter=counter+1 where aid='$aid'", $dbi);
  1549.     if ($ultramode) {
  1550.         ultramode();
  1551.     }
  1552.     Header("Location: admin.php?op=adminMain");
  1553.     }
  1554. }
  1555.  
  1556. function submissions() {
  1557.     global $admin, $bgcolor1, $bgcolor2, $prefix, $dbi, $radminsuper;
  1558.     $dummy = 0;
  1559.     include ("header.php");
  1560.     GraphicAdmin();
  1561.     OpenTable();
  1562.     echo "<center><font class=\"title\"><b>"._SUBMISSIONSADMIN."</b></font></center>";
  1563.     CloseTable();
  1564.     echo "<br>";
  1565.     OpenTable();
  1566.     $result = sql_query("SELECT qid, subject, timestamp, alanguage FROM ".$prefix."_queue order by timestamp DESC", $dbi);
  1567.     if(sql_num_rows($result, $dbi) == 0) {
  1568.         echo "<table width=\"100%\"><tr><td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NOSUBMISSIONS."</b></td></tr></table>\n";
  1569.     } else {
  1570.         echo "<center><font class=\"content\"><b>"._NEWSUBMISSIONS."</b></font><form action=\"admin.php\" method=\"post\"><table width=\"100%\" border=\"1\" bgcolor=\"$bgcolor2\">\n";
  1571.         while (list($qid, $subject, $timestamp, $alanguage) = sql_fetch_row($result, $dbi)) {
  1572.         $hour = "AM";
  1573.         ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $timestamp, $datetime);
  1574.         if ($datetime[4] > 12) { $datetime[4] = $datetime[4]-12; $hour = "PM"; }
  1575.         $datetime = date(""._DATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
  1576.         echo "<tr>\n"
  1577.             ."<td align=\"center\"><font class=\"content\"> (<a href=\"admin.php?op=DeleteStory&qid=$qid\">"._DELETE."</a>) </td>\n"
  1578.                 ."<td width=\"100%\"><font class=\"content\">\n";
  1579.         if ($subject == "") {
  1580.             echo " <a href=\"admin.php?op=DisplayStory&qid=$qid\">"._NOSUBJECT."</a></font>\n";
  1581.         } else {
  1582.             echo " <a href=\"admin.php?op=DisplayStory&qid=$qid\">$subject</a></font>\n";
  1583.         }
  1584.         if ($alanguage == "") {
  1585.             $alanguage = _ALL;
  1586.         }
  1587.         echo "</td><td align=\"center\"><font size=\"2\">$alanguage</font>\n";
  1588.         $timestamp = ereg_replace(" ", "@", $timestamp);
  1589.         echo "</td><td align=\"right\"><font class=\"content\"> $timestamp </font></td></tr>\n";
  1590.         $dummy++;
  1591.         }
  1592.         if ($dummy < 1) {
  1593.         echo "<tr><td bgcolor=\"$bgcolor1\" align=\"center\"><b>"._NOSUBMISSIONS."</b></form></td></tr></table>\n";
  1594.         } else {
  1595.         echo "</table></form>\n";
  1596.         }
  1597.     }
  1598.     if ($radminsuper==1) {
  1599.     echo "<br><center>"
  1600.         ."[ <a href=\"admin.php?op=subdelete\">"._DELETE."</a> ]"
  1601.         ."</center><br>";
  1602.     }
  1603.     CloseTable();
  1604.     include ("footer.php");
  1605. }
  1606.  
  1607. function subdelete() {
  1608.     global $prefix, $dbi;
  1609.     sql_query("delete from ".$prefix."_queue", $dbi);
  1610.     Header("Location: admin.php?op=adminMain");
  1611. }
  1612.  
  1613. switch($op) {
  1614.  
  1615.     case "EditCategory":
  1616.     EditCategory($catid);
  1617.     break;
  1618.  
  1619.     case "subdelete":
  1620.     subdelete();
  1621.     break;
  1622.  
  1623.     case "DelCategory":
  1624.     DelCategory($cat);
  1625.     break;
  1626.  
  1627.     case "YesDelCategory":
  1628.     YesDelCategory($catid);
  1629.     break;
  1630.  
  1631.     case "NoMoveCategory":
  1632.     NoMoveCategory($catid, $newcat);
  1633.     break;
  1634.  
  1635.     case "SaveEditCategory":
  1636.     SaveEditCategory($catid, $title);
  1637.     break;
  1638.  
  1639.     case "SelectCategory":
  1640.     SelectCategory($cat);
  1641.     break;
  1642.  
  1643.     case "AddCategory":
  1644.     AddCategory();
  1645.     break;
  1646.  
  1647.     case "SaveCategory":
  1648.     SaveCategory($title);
  1649.     break;
  1650.  
  1651.     case "DisplayStory":
  1652.     displayStory($qid);
  1653.     break;
  1654.  
  1655.     case "PreviewAgain":
  1656.     previewStory($automated, $year, $day, $month, $hour, $min, $qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $alanguage, $acomm, $pollTitle, $optionText);
  1657.     break;
  1658.  
  1659.     case "PostStory":
  1660.     postStory($automated, $year, $day, $month, $hour, $min, $qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $alanguage, $acomm, $pollTitle, $optionText);
  1661.     break;
  1662.  
  1663.     case "EditStory":
  1664.     editStory($sid);
  1665.     break;
  1666.  
  1667.     case "RemoveStory":
  1668.     removeStory($sid, $ok);
  1669.     break;
  1670.  
  1671.     case "ChangeStory":
  1672.     changeStory($sid, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $alanguage, $acomm);
  1673.     break;
  1674.  
  1675.     case "DeleteStory":
  1676.     deleteStory($qid);
  1677.     break;
  1678.  
  1679.     case "adminStory":
  1680.     adminStory($sid);
  1681.     break;
  1682.  
  1683.     case "PreviewAdminStory":
  1684.     previewAdminStory($automated, $year, $day, $month, $hour, $min, $subject, $hometext, $bodytext, $topic, $catid, $ihome, $alanguage, $acomm, $pollTitle, $optionText);
  1685.     break;
  1686.  
  1687.     case "PostAdminStory":
  1688.     postAdminStory($automated, $year, $day, $month, $hour, $min, $subject, $hometext, $bodytext, $topic, $catid, $ihome, $alanguage, $acomm, $pollTitle, $optionText);
  1689.     break;
  1690.  
  1691.     case "autoDelete":
  1692.     autodelete($anid);
  1693.     break;
  1694.  
  1695.     case "autoEdit":
  1696.     autoEdit($anid);
  1697.     break;
  1698.  
  1699.     case "autoSaveEdit":
  1700.     autoSaveEdit($anid, $year, $day, $month, $hour, $min, $title, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $alanguage, $acomm);
  1701.     break;
  1702.  
  1703.     case "submissions":
  1704.     submissions();
  1705.     break;
  1706.  
  1707. }
  1708.  
  1709. } else {
  1710.     echo "Access Denied";
  1711. }
  1712.  
  1713. ?>
  1714.