home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 March / PCWorld_2001-03_cd.bin / KOMUNIK / progweb / progweb.exe / phpnuke / html / admin / stories.php < prev    next >
PHP Script  |  2000-12-05  |  17KB  |  422 lines

  1. <?PHP
  2.  
  3. ######################################################################
  4. # PHP-NUKE: Web Portal System
  5. # ===========================
  6. #
  7. # Copyright (c) 2000 by Francisco Burzi (fburzi@ncc.org.ve)
  8. # http://phpnuke.org
  9. #
  10. # This modules is the main administration part
  11. #
  12. # This program is free software. You can redistribute it and/or modify
  13. # it under the terms of the GNU General Public License as published by
  14. # the Free Software Foundation; either version 2 of the License.
  15. ######################################################################
  16.  
  17. if (!eregi("admin.php", $PHP_SELF)) { die ("Access Denied"); }
  18. $result = mysql_query("select radminarticle, radminsuper from authors where aid='$aid'");
  19. list($radminarticle, $radminsuper) = mysql_fetch_row($result);
  20. if (($radminsurvey==1) OR ($radminsuper==1)) {
  21.  
  22. /*********************************************************/
  23. /* Story/News Functions                                  */
  24. /*********************************************************/
  25.  
  26. function deleteStory($qid) {
  27.     $result = mysql_query("delete from queue where qid=$qid");
  28.         if (!$result)
  29.         {
  30.             echo mysql_errno(). ": ".mysql_error(). "<br>";
  31.             return;
  32.         }    Header("Location: admin.php?op=submissions");
  33. }
  34.  
  35. function displayStory ($qid) {
  36.     global $user, $subject, $story, $tipath;
  37.     include ('header.php');
  38.     GraphicAdmin($hlpfile);
  39.     $result = mysql_query("SELECT qid, uid, uname, subject, story, topic FROM queue where qid=$qid");
  40.     list($qid, $uid, $uname, $subject, $story, $topic) = mysql_fetch_row($result);
  41.     mysql_free_result($result);
  42.     $subject = stripslashes($subject);
  43.     $story = stripslashes($story);
  44.     OpenTable();
  45.     ?>
  46.     <font size=3>
  47.     <form action="admin.php" method="post">
  48.     <p><b><?php echo translate("Name"); ?></b><br>
  49.     <input class=textbox type="text" NAME="author" SIZE=50 value="<?PHP echo "$uname"; ?>">
  50.     <p><b><?php echo translate("Subject"); ?></b><br>
  51.     <input class=textbox type=text name=subject size=50 value="<?PHP echo"$subject"; ?>">
  52.     <?PHP
  53.     if($topic=="") {
  54.         $topic = 1;
  55.     }
  56.     $result = mysql_query("select topicimage from topics where topicid=$topic");
  57.     list($topicimage) = mysql_fetch_row($result);
  58.     echo "<br><br><center>
  59.     <table border=0 width=70% cellpadding=0 cellspacing=1 bgcolor=000000><tr><td>
  60.     <table border=0 width=100% cellpadding=8 cellspacing=1 bgcolor=FFFFFF><tr><td>
  61.     <img src=$tipath$topicimage border=0 align=right>";
  62.     themepreview($subject, $story);
  63.     echo "</td></tr></table></td></tr></table></center>";
  64.     ?>
  65.     <p><b>Topic</b> <select name=topic>
  66.     <?PHP
  67.     $toplist = mysql_query("select topicid, topictext from topics order by topictext");
  68.         echo "<OPTION VALUE=\"\">".translate("Select Topic")."</option>\n";
  69.         while(list($topicid, $topics) = mysql_fetch_row($toplist)) {
  70.         if ($topicid==$topic) { $sel = "selected "; }
  71.             echo "<option $sel value=\"$topicid\">$topics</option>\n";
  72.         $sel = "";
  73.         }
  74.     ?>
  75.     </select>
  76.     <p><b><?php echo translate("Intro Text"); ?></b><br>
  77.     <textarea class=textbox wrap=virtual cols=50 rows=7 name=hometext><?PHP echo "$story"; ?></textarea>
  78.     <p><b><?php echo translate("Full Text"); ?></b><br>
  79.     <textarea class=textbox wrap=virtual cols=50 rows=8 name=bodytext></textarea><BR>
  80.     <FONT size=2><?php echo translate("(Did you check URLs?)"); ?></FONT><P>
  81.  
  82.     <p><b><?php echo translate("Notes"); ?></b><br>
  83.     <textarea class=textbox wrap=virtual cols=50 rows=4 name=notes></textarea><br>
  84.  
  85.     <input type="hidden" NAME="qid" SIZE=50 value="<?PHP echo "$qid"; ?>">
  86.     <input type="hidden" NAME="uid" SIZE=50 value="<?PHP echo "$uid"; ?>">
  87.     <select name="op">
  88.         <option value="DeleteStory"><?php echo translate("DeleteStory"); ?></option>
  89.         <option value="PreviewAgain" SELECTED><?php echo translate("PreviewAgain"); ?></option>
  90.         <option value="PostStory"><?php echo translate("PostStory"); ?></option>
  91.     </select>
  92.     <INPUT type="submit" value="<?php echo translate("Go!"); ?>">
  93.     </form></td></tr></table></td></tr></table>
  94.     <?PHP
  95.     include ('footer.php');
  96. }
  97.  
  98. function previewStory($qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes) {
  99.     global $user, $boxstuff, $tipath;
  100.     include ('header.php');
  101.     GraphicAdmin($hlpfile);
  102.     $subject = stripslashes($subject);
  103.     $hometext = stripslashes($hometext);
  104.     $bodytext = stripslashes($bodytext);
  105.     $notes = stripslashes($notes);
  106.     OpenTable();
  107.     ?>
  108.     <font size=3>
  109.     <form action="admin.php" method=post>
  110.     <p><b><?php echo translate("Name"); ?></b><br>
  111.     <input class=textbox type="text" NAME="author" SIZE=50 value="<?PHP echo"$author"; ?>">
  112.     <p><b><?php echo translate("Subject"); ?></b><br>
  113.     <input class=textbox type=text name=subject size=50 value="<?PHP echo"$subject"; ?>">
  114.     <?PHP
  115.     $result = mysql_query("select topicimage from topics where topicid=$topic");
  116.     list($topicimage) = mysql_fetch_row($result);
  117.     echo "<br><br><center><table width=70% bgcolor=000000 cellpadding=0 cellspacing=1 border=0><tr><td>";
  118.     echo "<table width=100% bgcolor=FFFFFF cellpadding=8 cellspacing=1 border=0><tr><td>";
  119.     echo "<img src=$tipath$topicimage border=0 align=right>";
  120.     themepreview($subject, $hometext, $bodytext, $notes);
  121.     echo "</td></tr></table></td></tr></table></center>";
  122.     ?>
  123.     <p><b><?php echo translate("Topic"); ?></b> <select name=topic>
  124.     <?PHP
  125.     $toplist = mysql_query("select topicid, topictext from topics order by topictext");
  126.         echo "<OPTION VALUE=\"\">".translate("All Topics")."</option>\n";
  127.         while(list($topicid, $topics) = mysql_fetch_row($toplist)) {
  128.         if ($topicid==$topic) { $sel = "selected "; }
  129.             echo "<option $sel value=\"$topicid\">$topics</option>\n";
  130.         $sel = "";
  131.         }
  132.     ?>
  133.     </select>    
  134.     <p><b><?php echo translate("Intro Text"); ?></b><br>
  135.     <textarea class=textbox wrap=virtual cols=50 rows=7 name=hometext><?PHP echo"$hometext"; ?></textarea>
  136.     <p><b><?php echo translate("Full Text"); ?></b><br>
  137.     <textarea class=textbox wrap=virtual cols=50 rows=10 name=bodytext><?PHP echo"$bodytext"; ?></textarea><BR>
  138.     <FONT size=2><?php echo translate("(Did you check URLs?)"); ?></FONT><P>
  139.     <p><b><?php echo translate("Notes"); ?></b><br>
  140.     <textarea class=textbox wrap=virtual cols=50 rows=4 name=notes><?PHP echo"$notes"; ?></textarea><br>
  141.     <input type="hidden" NAME="qid" SIZE=50 value="<?PHP echo"$qid"; ?>">
  142.     <input type="hidden" NAME="uid" SIZE=50 value="<?PHP echo "$uid"; ?>">
  143.     <select name="op">
  144.         <option value="DeleteStory"><?php echo translate("DeleteStory"); ?></option>
  145.         <option value="PreviewAgain" SELECTED><?php echo translate("PreviewAgain"); ?></option>
  146.         <option value="PostStory"><?php echo translate("PostStory"); ?></option>
  147.     </select>
  148.     <INPUT type="submit" value="<?php echo translate("Go!"); ?>"></FORM>
  149.     </td></tr></table></td></tr></table>
  150.     <?PHP
  151.     include ('footer.php');
  152. }
  153.  
  154. function postStory($qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes) {
  155.     global $aid, $ultramode;
  156.     if ($uid == -1) $author = "";
  157.     if ($hometext == $bodytext) $bodytext = "";
  158.     $subject = stripslashes(FixQuotes($subject));
  159.     $hometext = stripslashes(FixQuotes($hometext));
  160.     $bodytext = stripslashes(FixQuotes($bodytext));
  161.     $notes = stripslashes(FixQuotes($notes));
  162.     $result = mysql_query("insert into stories values (NULL, '$aid', '$subject', now(), '$hometext', '$bodytext', '0', '0', '$topic','$author', '$notes')");
  163.     if (!$result) {
  164.         echo mysql_errno(). ": ".mysql_error(). "<br>";
  165.         return;
  166.     }
  167.     if ($uid == -1) {
  168.     } else {
  169.         mysql_query("update users set counter=counter+1 where uid='$uid'");
  170.     }
  171.         mysql_query("update authors set counter=counter+1 where aid='$aid'");
  172.     if ($ultramode) {
  173.             ultramode();
  174.     }
  175.     deleteStory($qid);
  176. }
  177.  
  178. function editStory ($sid) {
  179.     global $user, $tipath;
  180.     include ('header.php');
  181.     GraphicAdmin($hlpfile);
  182.     $result = mysql_query("SELECT title, hometext, bodytext, topic, notes FROM stories where sid=$sid");
  183.     list($subject, $hometext, $bodytext, $topic, $notes) = mysql_fetch_row($result);
  184.     mysql_free_result($result);
  185.     
  186.     $subject = stripslashes($subject);
  187.     $hometext = stripslashes($hometext);
  188.     $bodytext = stripslashes($bodytext);
  189.     $notes = stripslashes($notes);
  190.  
  191.     $result=mysql_query("select topicimage from topics where topicid=$topic");
  192.     list($topicimage) = mysql_fetch_row($result);
  193.     echo "<center><font size=4><b>".translate("Edit Article")."</b></center><br><br>";
  194.     OpenTable();
  195.     echo "<br><center><table width=80% border=0 cellpadding=0 cellspacing=1 bgcolor=000000><tr><td>
  196.     <table width=100% border=0 cellpadding=8 cellspacing=1 bgcolor=FFFFFF><tr><td>";
  197.     echo "<img src=$tipath$topicimage border=0 align=right>";
  198.     themepreview($subject, $hometext, $bodytext);
  199.     echo "</td></tr></table></td></tr></table></center><br><br>";
  200.     echo "<form action=admin.php method=post>";
  201.     echo "<P><B>".translate("Subject")."</B><br>";
  202.     ?>
  203.     <input class=textbox type=text name=subject size=50 value="<?php echo "$subject"; ?>"><BR>
  204.     <p><b><?php echo translate("Topic"); ?></b> <select name=topic>
  205.     <?PHP
  206.     $toplist = mysql_query("select topicid, topictext from topics order by topictext");
  207.         echo "<OPTION VALUE=\"\">".translate("All Topics")."</option>\n";
  208.         while(list($topicid, $topics) = mysql_fetch_row($toplist)) {
  209.         if ($topicid==$topic) { $sel = "selected "; }
  210.             echo "<option $sel value=\"$topicid\">$topics</option>\n";
  211.         $sel = "";
  212.         }
  213.     ?>
  214.     </select>
  215.     <P><B><?php echo translate("Intro Text"); ?></B><br>
  216.     <textarea class=textbox wrap=virtual cols=50 rows=7 name=hometext><?PHP echo"$hometext"; ?></textarea>
  217.     <P><B><?php echo translate("Full Text"); ?></B><br>
  218.     <textarea class=textbox wrap=virtual cols=50 rows=10 name=bodytext><?PHP echo"$bodytext"; ?></textarea><BR>
  219.     <FONT size=2><?php echo translate("(Did you check URLs?)"); ?></FONT><P>
  220.     <P><B><?php echo translate("Notes"); ?></B><br>
  221.     <textarea class=textbox wrap=virtual cols=50 rows=4 name=notes><?php echo "$notes"; ?></textarea><br>
  222.     <input type="hidden" NAME="sid" SIZE=50 value="<?PHP echo"$sid"; ?>">
  223.     <INPUT type="hidden" name="op" value="ChangeStory">
  224.     <INPUT type="submit" value="<?php echo translate("ChangeStory"); ?>">
  225.     </form></td></tr></table></td></tr></table>
  226.     <?PHP
  227.     include ('footer.php');
  228. }
  229.  
  230. function removeStory ($sid, $ok=0) {
  231.     global $ultramode;
  232.     if($ok) {
  233.         mysql_query("DELETE FROM stories where sid=$sid");
  234.         mysql_query("DELETE FROM comments where sid=$sid");
  235.         if ($ultramode) {
  236.             ultramode();
  237.         }
  238.         Header("Location: admin.php");
  239.     } else {
  240.         include("header.php");
  241.         GraphicAdmin($hlpfile);
  242.         echo "<center>".translate("Are you sure you want to remove Story ID #")." $sid ".translate("and all it's comments?")."";
  243.         echo "<br><br>[ <a href=\"admin.php\">".translate("No")."</a> | <a href=\"admin.php?op=RemoveStory&sid=$sid&ok=1\">".translate("Yes")."</a> ]</center>";
  244.         include("footer.php");
  245.     }
  246. }
  247.  
  248.  
  249. function changeStory($sid, $subject, $hometext, $bodytext, $topic, $notes) {
  250.     global $aid, $ultramode;
  251.     $subject = stripslashes(FixQuotes($subject));
  252.     $hometext = stripslashes(FixQuotes($hometext));
  253.     $bodytext = stripslashes(FixQuotes($bodytext));
  254.     $notes = stripslashes(FixQuotes($notes));
  255.     mysql_query("update stories set title='$subject', hometext='$hometext', bodytext='$bodytext', topic='$topic', notes='$notes' where sid=$sid");
  256.     if ($ultramode) {
  257.         ultramode();
  258.     }
  259.     Header("Location: admin.php?op=adminMain");
  260. }
  261.  
  262. function adminStory() {
  263.     global $hlpfile, $admin;
  264.     $hlpfile = "manual/newarticle.html";
  265.     include ('header.php');
  266.     GraphicAdmin($hlpfile);
  267.     OpenTable();
  268.     echo "
  269.     <a name=new></a>
  270.     <center><font size=4><b>".translate("New Article")."</b></font></center><br><br>"; ?>
  271.     <form action="admin.php" method=post>
  272.     <p><b><?php echo translate("Title"); ?></b><br>
  273.     <input class=textbox type=text name=subject size=50 value=""><BR>
  274.     <BR>
  275.     <p><b><?php echo translate("Topic"); ?></b>
  276.         <?php
  277.         $toplist = mysql_query("select topicid, topictext from topics order by topictext");
  278.         echo "<SELECT class=textbox NAME=\"topic\">";
  279.         echo "<OPTION VALUE=\"\">".translate("Select Topic")."</option>\n";
  280.         while(list($topicid, $topics) = mysql_fetch_row($toplist)) {
  281.             if ($topicid==$topic) { $sel = "selected "; }
  282.             echo "<option $sel value=\"$topicid\">$topics</option>\n";
  283.         $sel = "";
  284.             }
  285.         echo "</SELECT>";
  286.     ?>
  287.     <P><B><?php echo translate("The Story"); ?></B><br>
  288.     <textarea class=textbox wrap=virtual cols=70 rows=12 name=hometext></textarea><BR>
  289.     <P><B><?php echo translate("Extended Text"); ?></B><br>
  290.     <textarea class=textbox wrap=virtual cols=70 rows=12 name=bodytext></textarea><BR>
  291.     <FONT size=2><?php echo translate("(Are you sure you included a URL? Did ya test them for typos?)"); ?></FONT><P>
  292.     <select class=textbox name="op">
  293.     <option value="PreviewAdminStory" SELECTED><?php echo translate("PreviewAdminStory"); ?></option>
  294.     <option value="PostAdminStory"><?php echo translate("PostAdminStory"); ?></option>
  295.     </select>
  296.     <INPUT type="submit" value="<?php echo translate("Go!"); ?>">
  297.     </form></td></tr></table></td></tr></table>
  298.     <?PHP
  299.     include ('footer.php');
  300. }
  301.  
  302. function previewAdminStory($subject, $hometext, $bodytext, $topic) {
  303.     global $user, $tipath;
  304.     include ('header.php');
  305.     if ($topic<1) {
  306.         $topic = 1;
  307.     }
  308.     GraphicAdmin($hlpfile);
  309.     OpenTable();
  310.     echo "
  311.     <font size=4><b><center>".translate("Preview Story")."</b></font><br><br><br>
  312.     <form action=\"admin.php\" method=post>
  313.     </b></center>
  314.     ";
  315.     $subject = stripslashes($subject);
  316.     $hometext = stripslashes($hometext);
  317.     $bodytext = stripslashes($bodytext);
  318.     $result=mysql_query("select topicimage from topics where topicid=$topic");
  319.     list($topicimage) = mysql_fetch_row($result);
  320.     echo "<center><br>
  321.     <table border=0 width=75% cellpadding=0 cellspacing=1 bgcolor=000000><tr><td>
  322.     <table border=0 width=100% cellpadding=8 cellspacing=1 bgcolor=FFFFFF><tr><td>";
  323.     echo "";
  324.     echo "<img src=$tipath$topicimage border=0 align=right>";
  325.     themepreview($subject, $hometext, $bodytext);
  326.     echo "</td></tr></table></td></tr></table></center>";
  327.     ?>
  328.     <p><b><?php echo translate("Title"); ?></b><br>
  329.     <input class=textbox type=text name=subject size=50 value="<?PHP echo"$subject"; ?>"><BR>
  330.     <p><b><?php echo translate("Topic"); ?></b> <select name=topic>
  331.     <?PHP
  332.     $toplist = mysql_query("select topicid, topictext from topics order by topictext");
  333.         echo "<OPTION VALUE=\"\">".translate("All Topics")."</option>\n";
  334.         while(list($topicid, $topics) = mysql_fetch_row($toplist)) {
  335.         if ($topicid==$topic) { $sel = "selected "; }
  336.             echo "<option $sel value=\"$topicid\">$topics</option>\n";
  337.         $sel = "";
  338.         }
  339.     ?>
  340.     </select>
  341.     <p><b><?php echo translate("The Story"); ?></b><br>
  342.     <textarea class=textbox wrap=virtual cols=50 rows=12 name=hometext><?PHP echo "$hometext"; ?></textarea><BR><BR>
  343.     <p><b><?php echo translate("Extended Text"); ?></b><br>
  344.     <textarea class=textbox wrap=virtual cols=50 rows=12 name=bodytext><?PHP echo "$bodytext"; ?></textarea><BR>
  345.     <select class=textbox name="op">
  346.     <option value="PreviewAdminStory" SELECTED><?php echo translate("PreviewAdminStory"); ?></option>
  347.     <option value="PostAdminStory"><?php echo translate("PostAdminStory"); ?></option>
  348.     </select>
  349.     <INPUT type="submit" value="<?php echo translate("Go!"); ?>">
  350.     </form></td></tr></table></td></tr></table>
  351.     <?PHP
  352.     include ('footer.php');
  353.  
  354. }
  355.  
  356. function postAdminStory($subject, $introstory, $fullstory, $topic) {
  357.     global $aid;
  358.     $subject = stripslashes(FixQuotes($subject));
  359.     $introstory = stripslashes(FixQuotes($introstory));
  360.     $fullstory = stripslashes(FixQuotes($fullstory));
  361.     $result = mysql_query("insert into stories values (NULL, '$aid', '$subject', now(), '$introstory', '$fullstory', '0', '0', '$topic', '$aid', '$notes')");
  362.     if (!$result)
  363.     {
  364.         echo mysql_errno(). ": ".mysql_error(). "<br>";
  365.         exit();
  366.     }
  367.     $result = mysql_query("update authors set counter=counter+1 where aid='$aid'");
  368.     if ($ultramode) {
  369.         ultramode();
  370.     }
  371.     Header("Location: admin.php?op=adminMain");
  372. }
  373.  
  374. switch($op) {
  375.  
  376.         case "DisplayStory":
  377.             displayStory($qid);
  378.             break;
  379.  
  380.         case "PreviewAgain":
  381.             previewStory($qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes);
  382.             break;
  383.  
  384.         case "PostStory":
  385.             postStory($qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes);
  386.             break;
  387.  
  388.         case "EditStory":
  389.             editStory($sid);
  390.             break;
  391.  
  392.         case "RemoveStory":
  393.             removeStory($sid, $ok);
  394.             break;
  395.  
  396.         case "ChangeStory":
  397.             changeStory($sid, $subject, $hometext, $bodytext, $topic, $notes);
  398.             break;
  399.  
  400.         case "DeleteStory":
  401.             deleteStory($qid);
  402.             break;
  403.  
  404.         case "adminStory":
  405.             adminStory($sid);
  406.             break;
  407.  
  408.         case "PreviewAdminStory":
  409.             previewAdminStory($subject, $hometext, $bodytext, $topic);
  410.             break;
  411.  
  412.         case "PostAdminStory":
  413.             postAdminStory($subject, $hometext, $bodytext, $topic);
  414.             break;
  415.  
  416. }
  417.  
  418. } else {
  419.     echo "Access Denied";
  420. }
  421.  
  422. ?>