home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 March / PCWorld_2001-03_cd.bin / KOMUNIK / progweb / progweb.exe / phpnuke / html / admin / topics.php < prev    next >
PHP Script  |  2000-12-05  |  11KB  |  261 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. $hlpfile = "manual/topics.html";
  19. $result = mysql_query("select radmintopic, radminsuper from authors where aid='$aid'");
  20. list($radmintopic, $radminsuper) = mysql_fetch_row($result);
  21. if (($radmintopic==1) OR ($radminsuper==1)) {
  22.  
  23. /*********************************************************/
  24. /* Topics Manager Functions                              */
  25. /*********************************************************/
  26.  
  27. function topicsmanager() {
  28.     global $hlpfile, $admin, $tipath;
  29.     include("header.php");
  30.     GraphicAdmin($hlpfile);
  31.     $result = mysql_query("select topicid, topicname, topicimage, topictext from topics order by topicname");
  32.     if (mysql_num_rows($result)==0) {
  33.         echo "
  34.         <table border=0 bgcolor=000000 cellpadding=0 cellspacing=1 width=95%><tr><td>
  35.         <table border=0 bgcolor=FFFFFF cellpadding=8 cellspacing=1 width=100%>";
  36.     }
  37.     if (mysql_num_rows($result) > 0) {
  38.     OpenTable();
  39.     echo "
  40.     <b><center>".translate("Current Active Topics")."</b><br>".translate("Click to Edit")."</center><br>
  41.     <center><table border=0 width=100% align=center cellpadding=2><tr>";
  42.         while(list($topicid, $topicname, $topicimage, $topictext) = mysql_fetch_array($result)) {
  43. ?>
  44.         <td align=center>
  45.         <?php echo "<a href=admin.php?op=topicedit&topicid=$topicid>"; ?><img src=<?php echo "$tipath$topicimage"; ?> border=0></a><br>
  46.         <font size=2><b><?php echo "$topictext"; ?>
  47.         </td>
  48.         <?php
  49.         
  50.         // Thanks to John Hoffmann from softlinux.org for the next 5 lines ;)
  51.         
  52.         $count++;
  53.         if ($count == 5) {
  54.             echo "</tr></tr>";
  55.             $count = 0;
  56.         }
  57.         }
  58.     echo "</tr></table>";
  59.     } 
  60.     ?>
  61.     </td></tr></table></td></tr></table>
  62.     <br><a name=Add>
  63.     <?php OpenTable(); ?>
  64.     <font size=4><b><?php echo translate("Add a New Topic"); ?></b><font size=2>
  65.     <br><br>
  66.     <form action="admin.php" method="post"><br>
  67.     <b><?php echo translate("Topic Name:"); ?></b> <?php echo translate("(just a name without spaces - max: 20 characters)"); ?><br>
  68.     <?php echo translate("for example: gamesandhobbies"); ?><br>
  69.     <input class=textbox type="text" name="topicname" size=20 maxlength=20 value="<?php echo "$topicname"; ?>"><br><br>
  70.     <b><?php echo translate("Topic Text:"); ?></b> <?php echo translate("(the full topic text or description - max: 40 characters)"); ?><br>
  71.     <?php echo translate("for example: Games and Hobbies"); ?><br>
  72.     <input class=textbox type="text" name="topictext" size=40 maxlength=40 value="<?php echo "$topictext"; ?>"><br><br>
  73.     <b><?php echo translate("Topic Image:"); ?></b> <?php echo translate("(image name + extension located in"); ?> <?php echo "$tipath"; ?>)<br>
  74.     <?php echo translate("for example: games.gif"); ?><br>
  75.     <input class=textbox type="text" name="topicimage" size=20 maxlength=20 value="<?php echo "$topicimage"; ?>"><br><br>
  76.     <input type=hidden name=op value=topicmake>
  77.     <INPUT type="submit" value="<?php echo translate("Add Topic!"); ?>">
  78.     </form>
  79.     </td></tr></table></td></tr></table>    
  80.     <?php
  81.     mysql_free_result($result);
  82.     include("footer.php");
  83. }
  84.  
  85. function topicedit($topicid) {
  86.     global $tipath;
  87.     include("header.php");
  88.     GraphicAdmin($hlpfile);
  89.     $result = mysql_query("select topicid, topicname, topicimage, topictext from topics where topicid=$topicid");
  90.     list($topicid, $topicname, $topicimage, $topictext) = mysql_fetch_array($result);
  91.     OpenTable();
  92.     ?>
  93.     <img src=<?php echo "$tipath$topicimage"; ?> border=0 align=right>
  94.     <font size=4><b><?php echo translate("Edit Topic:"); ?> <?php echo "$topictext"; ?></b><font size=2>
  95.     <br><br>
  96.     <form action="admin.php" method="post"><br>
  97.     <b><?php echo translate("Topic Name:"); ?></b> <?php echo translate("(just a name without spaces - max: 20 characters)"); ?><br>
  98.     <?php echo translate("for example: gamesandhobbies"); ?><br>
  99.     <input class=textbox type="text" name="topicname" size=20 maxlength=20 value="<?php echo "$topicname"; ?>"><br><br>
  100.     <b><?php echo translate("Topic Text:"); ?></b> <?php echo translate("(the full topic text or description - max: 40 characters)"); ?><br>
  101.     <?php echo translate("for example: Games and Hobbies"); ?><br>
  102.     <input class=textbox type="text" name="topictext" size=40 maxlength=40 value="<?php echo "$topictext"; ?>"><br><br>
  103.     <b><?php echo translate("Topic Image:"); ?></b> <?php echo translate("(image name + extension located in"); ?> <?php echo "$tipath"; ?>)<br>
  104.     <?php echo translate("for example: games.gif"); ?><br>
  105.     <input class=textbox type="text" name="topicimage" size=20 maxlength=20 value="<?php echo "$topicimage"; ?>"><br><br>
  106.  
  107.     <b><?php echo translate("Add Related Links:"); ?></b><br>
  108.     <?php echo translate("Site Name: "); ?><input class=textbox type="text" name="name" size=30 maxlength=30><br>
  109.     <?php echo translate("URL: "); ?><input class=textbox type="text" name="url" value="http://" size=50 maxlength=200><br><br>
  110.  
  111.     <b><?php echo translate("Active Related Links:"); ?></b><br>
  112.     <?php
  113.     $res=mysql_query("select rid, name, url from related where tid=$topicid");
  114.     echo "<table width=100% border=0><tr><td>";
  115.     while(list($rid, $name, $url) = mysql_fetch_row($res)) {
  116.         echo "<font size=1><li> <a href=$url>$name</a></td><td>";
  117.         echo "<font size=1><a href=$url>$url</a></td><td><font size=1>[ <a href=admin.php?op=relatededit&tid=$topicid&rid=$rid>".translate("Edit")."</a> | <a href=admin.php?op=relateddelete&tid=$topicid&rid=$rid>".translate("Delete")."</a> ]</td></tr><tr><td>";
  118.     }
  119.     echo "</td></tr></table>";
  120.     ?>
  121.     <input type=hidden name=topicid value="<?php echo "$topicid"; ?>">
  122.     <input type=hidden name=op value=topicchange>
  123.     <table border=0><tr><td>
  124.     <INPUT type="submit" value="<?php echo translate("Save Changes!"); ?>">
  125.     </form></td><td>
  126.     <form action="admin.php" method="post"><br>
  127.     <input type=hidden name=topicid value="<?php echo "$topicid"; ?>">
  128.     <input type=hidden name=op value=topicdelete>
  129.     <INPUT type="submit" value="<?php echo translate("Delete Topic!"); ?>">
  130.     </form></td></tr></table>
  131.     </td></tr></table></td></tr></table>
  132.     <?php
  133.     include("footer.php");
  134. }
  135.  
  136. function relatededit($tid, $rid) {
  137.     include("header.php");
  138.     GraphicAdmin($hlpfile);
  139.     $result=mysql_query("select name, url from related where rid=$rid");
  140.     list($name, $url) = mysql_fetch_row($result);
  141.     $result2=mysql_query("select topictext, topicimage from topics where topicid=$tid");
  142.     list($topictext, $topicimage) = mysql_fetch_row($result2);
  143.     OpenTable();    
  144.     echo "
  145.     <center><font size=4>
  146.     <img src=$tipath$topicimage border=0 Alt=\"$topictext\" align=right>
  147.     <b>".translate("Edit Related Link")."</b><br>
  148.     <font size=2><b>".translate("Topic:")."</b> $topictext</center>
  149.     <form action=admin.php method=post>
  150.     <font size=2>
  151.     ".translate("Site Name: ")."<input type=text class=textbox name=name value=\"$name\" size=30 maxlength=30><br><br>
  152.     ".translate("URL: ")."<input type=text class=textbox name=url value=\"$url\" size=60 maxlength=200><br><br>
  153.     <input type=hidden name=op value=relatedsave>
  154.     <input type=hidden name=tid value=$tid>
  155.     <input type=hidden name=rid value=$rid>
  156.     <input type=submit value=".translate("Save Changes").">
  157.     </form></td></tr></table></td></tr></table>";
  158.     include("footer.php");
  159. }
  160.  
  161. function relatedsave($tid, $rid, $name, $url) {
  162.     mysql_query("update related set name='$name', url='$url' where rid=$rid");
  163.     Header("Location: admin.php?op=topicedit&topicid=$tid");
  164. }
  165.  
  166. function relateddelete($tid, $rid) {
  167.     mysql_query("delete from related where rid='$rid'");
  168.     Header("Location: admin.php?op=topicedit&topicid=$tid");
  169. }
  170.  
  171. function topicmake($topicname, $topicimage, $topictext) {
  172.     $topicname = stripslashes(FixQuotes($topicname));
  173.     $topicimage = stripslashes(FixQuotes($topicimage));
  174.     $topictext = stripslashes(FixQuotes($topictext));
  175.     mysql_query("INSERT INTO topics VALUES (NULL,'$topicname','$topicimage','$topictext','0')");
  176.     Header("Location: admin.php?op=topicsmanager#Add");
  177. }
  178.  
  179. function topicchange($topicid, $topicname, $topicimage, $topictext, $name, $url) {
  180.     $topicname = stripslashes(FixQuotes($topicname));
  181.     $topicimage = stripslashes(FixQuotes($topicimage));
  182.     $topictext = stripslashes(FixQuotes($topictext));
  183.     $name = stripslashes(FixQuotes($name));
  184.     $url = stripslashes(FixQuotes($url));
  185.     mysql_query("update topics set topicname='$topicname', topicimage='$topicimage', topictext='$topictext' where topicid=$topicid");
  186.     if (!$name) {
  187.     } else {
  188.         mysql_query("insert into related VALUES (NULL, '$topicid','$name','$url')");
  189.     }
  190.     Header("Location: admin.php?op=topicedit&topicid=$topicid");
  191. }
  192.  
  193. function topicdelete($topicid, $ok=0) {
  194.     if ($ok==1) {
  195.         $result=mysql_query("select sid from stories where topic='$topicid'");
  196.         list($sid) = mysql_fetch_row($result);
  197.         mysql_query("delete from stories where topic='$topicid'");
  198.         mysql_query("delete from topics where topicid='$topicid'");
  199.         mysql_query("delete from related where tid='$topicid'");
  200.         $result=mysql_query("select sid from comments where sid='$sid'");
  201.         list($sid) = mysql_fetch_row($result);
  202.         mysql_query("delete from comments where sid='$sid'");
  203.         Header("Location: admin.php?op=topicsmanager");
  204.     } else {
  205.         include("header.php");
  206.         GraphicAdmin($hlpfile);
  207.         $result2=mysql_query("select topicimage, topictext from topics where topicid='$topicid'");
  208.         list($topicimage, $topictext) = mysql_fetch_row($result2);
  209.         OpenTable();
  210.         echo "
  211.         <center><img src=$tipath$topicimage border=0><br>
  212.         <b>".translate("Delete Topic")." $topictext</b><br><br>
  213.         ".translate("Are you sure you want to delete Topic")." $topictext?<br>
  214.         ".translate("This will delete ALL it's stories and it's comments!")."<br><br>
  215.         [ <a href=\"admin.php?op=topicsmanager\">".translate("No")."</a> | <a href=\"admin.php?op=topicdelete&topicid=$topicid&ok=1\">".translate("Yes")."</a> ]</center><br><br>
  216.         </td></tr></table></td></tr></table>";
  217.         include("footer.php");
  218.     }
  219. }
  220.  
  221. switch ($op) {
  222.  
  223.         case "topicsmanager":
  224.             topicsmanager();
  225.             break;
  226.  
  227.         case "topicedit":
  228.             topicedit($topicid);
  229.             break;
  230.  
  231.         case "topicmake":
  232.             topicmake($topicname, $topicimage, $topictext);
  233.             break;
  234.  
  235.         case "topicdelete":
  236.             topicdelete($topicid, $ok);
  237.             break;
  238.  
  239.         case "topicchange":
  240.             topicchange($topicid, $topicname, $topicimage, $topictext, $name, $url);
  241.             break;
  242.  
  243.     case "relatedsave":
  244.         relatedsave($tid, $rid, $name, $url);
  245.         break;
  246.         
  247.     case "relatededit":
  248.         relatededit($tid, $rid);
  249.         break;
  250.             
  251.     case "relateddelete":
  252.         relateddelete($tid, $rid);
  253.         break;
  254.  
  255. }
  256.  
  257. } else {
  258.     echo "Access Denied";
  259. }
  260.  
  261. ?>