home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 March / PCWorld_2001-03_cd.bin / KOMUNIK / progweb / progweb.exe / phpnuke / html / submit.php < prev    next >
PHP Script  |  2000-12-05  |  6KB  |  159 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 to manage your visitor's news submissions
  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 (!isset($mainfile)) { include("mainfile.php"); }
  18.  
  19. function defaultDisplay() {
  20.     include ('header.php');
  21.     global $user, $cookie;
  22.     echo "<table border=0 width=100% cellpadding=0 cellspacing=1 bgcolor=000000><tr><td>";
  23.     echo "<table border=0 width=100% cellpadding=8 cellspacing=1 bgcolor=FFFFFF><tr><td>";
  24.     echo "<font size=4><b>".translate("Submit News")."</b><font size=2>";
  25.     if (isset($user)) getusrinfo($user);
  26.     echo "<p><FORM action=\"submit.php\" method=post>"
  27.         ."<b>".translate("Your Name")."</b> ";
  28.     if ($user) {
  29.         cookiedecode($user);
  30.         echo "<a href=\"user.php\">$cookie[1]</a> <font size=2>[ <a href=\"user.php?op=logout\">".translate("Logout")."</a> ]</font>";
  31.     } else {
  32.         echo "$anonymous <font size=2>[ <a href=\"user.php\">".translate("New User")."</a> ]</font>";
  33.     } ?>
  34.     <P><B><?php echo translate("Title"); ?></B>
  35.     (<?php echo translate ("Be Descriptive, Clear and Simple"); ?>)<BR>
  36.     <input class=textbox type="text" NAME="subject" SIZE=70 maxlength=80><BR><FONT size=2>(<?php echo translate("bad titles='Check This Out!' or 'An Article'."); ?>)</FONT>
  37.     <BR>
  38.     <p><b><?php echo translate("Topic"); ?></b> <SELECT class=textbox NAME=topic>
  39.     <?PHP
  40.     $toplist = mysql_query("select topicid, topictext from topics order by topictext");
  41.         echo "<OPTION VALUE=\"\">".translate("Select Topic")."</option>\n";
  42.         while(list($topicid, $topics) = mysql_fetch_row($toplist)) {
  43.             if ($topicid==$topic) { $sel = "selected "; }
  44.             echo "<option $sel value=\"$topicid\">$topics</option>\n";
  45.         $sel = "";
  46.         }
  47.     ?>
  48.     </select>
  49.     <P><B><?php echo translate("The Scoop"); ?></B>
  50.     (<?php echo translate("HTML is fine, but double check those URLs and HTML tags!"); ?>)<BR>
  51.     <TEXTAREA class=textbox wrap=virtual cols=70 rows=12 name=story></TEXTAREA><BR>
  52.     <FONT size=2>(<?php echo translate("Are you sure you included a URL? Did you test them for typos?"); ?>)</FONT><P>
  53.     <INPUT type=submit name=op value="Preview"> (<?php echo translate("You must preview once before you can submit"); ?>)</FORM>
  54.     </td></tr></table></td></tr></table>
  55.     <?PHP
  56.     include ('footer.php');
  57. }
  58.  
  59. function PreviewStory($name, $address, $subject, $story, $topic) {
  60.     global $user, $cookie, $tipath;
  61.     include ('header.php');
  62.     $subject = stripslashes($subject);
  63.     $story = stripslashes($story);
  64.     echo "<table border=0 width=100% cellpadding=0 cellspacing=1 bgcolor=000000><tr><td>";
  65.     echo "<table border=0 width=100% cellpadding=8 cellspacing=1 bgcolor=FFFFFF><tr><td>";
  66.     echo "<font size=3><b>".translate("Submit News")."</b></font><br><br>";
  67.     echo "<p><FORM action=\"submit.php\" method=post>"
  68.         ."<b>".translate("Your Name")."</b> ";
  69.     if ($user) {
  70.         cookiedecode($user);
  71.         echo "<a href=\"user.php\">$cookie[1]</a> <font size=2>[ <a href=\"user.php?op=logout\">".translate("Logout")."</a> ]</font>";
  72.     } else {
  73.         echo "$anonymous";
  74.     } ?>
  75.     <p><b><?php echo translate("Title"); ?></b><br>
  76.     <input class=textbox type="text" NAME="subject" SIZE=70 maxlength=80 value="<?PHP echo"$subject"; ?>">
  77.     <?PHP
  78.     
  79.     echo "<br><br><center><table border=0 width=75% cellpadding=0 cellspacing=1 bgcolor=000000><tr><td>";
  80.     echo "<table border=0 width=100% cellpadding=8 cellspacing=1 bgcolor=FFFFFF><tr><td>";
  81.     if ($topic=="") {
  82.         $topicimage="AllTopics.gif";
  83.         $warning = "<center><blink><b>".translate("Select Topic")."</b></blink></center>";
  84.     } else {
  85.         $warning = "";
  86.         $result = mysql_query("select topicimage from topics where topicid='$topic'");
  87.         list($topicimage) = mysql_fetch_row($result);
  88.     }
  89.     echo "<img src=$tipath$topicimage border=0 align=right>";
  90.     themepreview($subject, $story);
  91.     echo "$warning";
  92.     echo "</td></tr></table></td></tr></table></center>";
  93.     
  94.     ?>
  95.     <p><b><?php echo translate("Topic"); ?></b><select class=textbox name=topic>
  96.     <?PHP
  97.     $toplist = mysql_query("select topicid, topictext from topics order by topictext");
  98.     echo "<OPTION VALUE=\"\">".translate("Select Topic")."</option>\n";
  99.         while(list($topicid, $topics) = mysql_fetch_row($toplist)) {
  100.             if ($topicid==$topic) { $sel = "selected "; }
  101.             echo "<option $sel value=\"$topicid\">$topics</option>\n";
  102.         $sel = "";
  103.         }
  104.     ?>
  105.     </select>
  106.     <P><B><?php echo translate("The Scoop"); ?></B>
  107.     (<?php echo translate("HTML is fine, but double check those URLs and HTML tags!"); ?>)<BR>
  108.     <TEXTAREA class=textbox wrap=virtual cols=50 rows=12 name=story><?PHP echo"$story"; ?></TEXTAREA><BR>
  109.     <FONT size=2>(<?php echo translate("Are you sure you included a URL? Did you test them for typos?"); ?>)</FONT><P>
  110.     <INPUT type=submit name=op value="Preview"> <INPUT type=submit name=op value="Ok!">
  111.     </td></tr></table></td></tr></table></FORM>
  112.  
  113.     <?PHP
  114.     include ('footer.php');
  115. }
  116.  
  117. function submitStory($name, $address, $subject, $story, $topic) {
  118.     global $user, $EditedMessage, $cookie;
  119.     include ('header.php');
  120.     echo translate("Thanks for your submission.");
  121.     include ('footer.php');
  122.     if ($user) {
  123.         cookiedecode($user);
  124.         $uid = $cookie[0];
  125.         $name = $cookie[1];
  126.     } else {
  127.         $uid = -1;
  128.         $name = "Anonymous";
  129.     }
  130.     $subject = stripslashes(FixQuotes(check_html($subject, "nohtml")));
  131.     $story = stripslashes(FixQuotes($story));
  132.     $result = mysql_query("insert into queue values (NULL, '$uid', '$name', '$subject', '$story', now(), '$topic')");
  133.     if(!$result) {
  134.         echo mysql_errno(). ": ".mysql_error(). "<br>";
  135.         exit();
  136.     }
  137.     if($notify) {
  138.         mail($notify_email, $notify_subject, $notify_message, "From: $notify_from\nX-Mailer: PHP/" . phpversion());
  139.     }
  140. }
  141.  
  142. switch($op)
  143. {
  144.     case "Preview":
  145.         PreviewStory($name, $address, $subject, $story, $topic);
  146.         break;
  147.  
  148.     case "Ok!":
  149.         SubmitStory($name, $address, $subject, $story, $topic);
  150.         break;
  151.  
  152.     default:
  153.         defaultDisplay();
  154.         break;
  155.  
  156. }
  157.  
  158. ?>
  159.