submit.php 6.82 KB
Newer Older
Dries's avatar
 
Dries committed
1
<?
Dries's avatar
Dries committed
2

Dries's avatar
 
Dries committed
3
function submit_enter() {
Dries's avatar
 
Dries committed
4
  global $anonymous, $categories, $allowed_html, $theme, $user;
Dries's avatar
 
Dries committed
5
  
Dries's avatar
 
Dries committed
6
  ### Guidlines:
Dries's avatar
 
Dries committed
7 8 9
  $output .= "<P>Got some news or some thoughts you would like to share? Fill out this form and they will automatically get whisked away to our submission queue where our moderators will frown at it, poke at it and hopefully post it. Every registered user is automatically a moderator and can vote whether or not your sumbission should be carried to the front page for discussion.</P>\n"; 
  $output .= "<P>Note that we do not revamp or extend your submission so it is up to you to make sure your submission is well-written: if you don't care enough to be clear and complete, your submission is likely to be moderated down by our army of moderators. Try to be complete, aim for clarity, organize and structure your text, and try to carry out your statements with examples. It is also encouraged to extend your submission with arguments that flow from your unique intellectual capability and experience: offer some insight or explanation as to why you think your submission is interesting. Make sure your submission has some meat on it!</P>\n";
  $output .= "<P>However, if you have bugs to report, complaints, personal questions or anything besides a public submission, we would prefer you to mail us instead, or your message is likely to get lost.</P><BR>\n"; 
Dries's avatar
 
Dries committed
10 11

  ### Submission form:
Dries's avatar
 
Dries committed
12
  $output .= "<FORM ACTION=\"submit.php\" METHOD=\"post\">\n";
Dries's avatar
Dries committed
13

Dries's avatar
 
Dries committed
14
  $output .= "<P>\n <B>Your name:</B><BR>\n";
Dries's avatar
 
Dries committed
15
  $output .= format_username($user->userid);
Dries's avatar
 
Dries committed
16 17 18 19
  $output .= "</P>\n";
 
  $output .= "<P>\n";
  $output .= " <B>Subject:</B><BR>\n";
Dries's avatar
 
Dries committed
20
  $output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\"><BR>\n";
Dries's avatar
 
Dries committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
  $output .= " <SMALL><I>Bad subjects are 'Check this out!' or 'An article'.  Be descriptive, clear and simple!</I></SMALL>\n";
  $output .= "</P>\n";

  $output .= "<P><B>Category:</B><BR>\n";
  $output .= " <SELECT NAME=\"category\">\n";
    
  for ($i = 0; $i < sizeof($categories); $i++) {
    $output .= "  <OPTION VALUE=\"$categories[$i]\">$categories[$i]</OPTION>\n";
  }
  
  $output .= " </SELECT>\n";
  $output .= "</P>\n";

  $output .= "<P>\n"; 
  $output .= " <B>Abstract:</B><BR>\n";
Dries's avatar
 
Dries committed
36
  $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"abstract\" MAXLENGTH=\"20\"></TEXTAREA><BR>\n";
Dries's avatar
 
Dries committed
37
  $output .= " <SMALL><I>Allowed HTML tags: ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
Dries's avatar
 
Dries committed
38 39 40 41
  $output .= "</P>\n";

  $output .= "<P>\n"; 
  $output .= " <B>Extended story:</B><BR>\n";
Dries's avatar
 
Dries committed
42
  $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"article\"></TEXTAREA><BR>\n";
Dries's avatar
 
Dries committed
43
  $output .= " <SMALL><I>Allowed HTML tags: ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
Dries's avatar
 
Dries committed
44
  $output .= "</P>\n";
Dries's avatar
Dries committed
45
 
Dries's avatar
 
Dries committed
46
  $output .= "<P>\n";
Dries's avatar
 
Dries committed
47 48
  $output .= " You must preview at least once before you can submit:<BR>\n";
  $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview submission\">\n";
Dries's avatar
 
Dries committed
49
  $output .= "</P>\n";
Dries's avatar
Dries committed
50
 
Dries's avatar
 
Dries committed
51 52 53 54 55
  $output .= "</FORM>\n";
  
  $theme->header();
  $theme->box("Submit a story", $output);
  $theme->footer();
Dries's avatar
Dries committed
56 57
}

Dries's avatar
 
Dries committed
58
function submit_preview($subject, $abstract, $article, $category) {
Dries's avatar
 
Dries committed
59
  global $categories, $allowed_html, $theme, $user;
Dries's avatar
 
Dries committed
60

Dries's avatar
 
Dries committed
61 62
  include "includes/story.inc";

Dries's avatar
 
Dries committed
63 64 65 66
  $output .= "<FORM ACTION=\"submit.php\" METHOD=\"post\">\n";

  $output .= "<P>\n";
  $output .= " <B>Your name:</B><BR>\n";
Dries's avatar
 
Dries committed
67
  $output .= format_username($user->userid);
Dries's avatar
 
Dries committed
68 69 70 71
  $output .= "</P>\n";

  $output .= "<P>\n";
  $output .= " <B>Subject:</B><BR>\n";
Dries's avatar
 
Dries committed
72
  $output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_output(check_field($subject)) ."\"><BR>\n";
Dries's avatar
 
Dries committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
  $output .= " <SMALL><I>Bad subjects are 'Check this out!' or 'An article'.  Be descriptive, clear and simple!</I></SMALL>\n";
  $output .= "</P>\n";

  $output .= "<P><B>Category:</B><BR>\n";
  $output .= " <SELECT NAME=\"category\">\n";
  for ($i = 0; $i < sizeof($categories); $i++) {
    $output .= "  <OPTION VALUE=\"$categories[$i]\" ";
    if ($category == $categories[$i]) $output .= "SELECTED";
    $output .= ">$categories[$i]</OPTION>\n";
  }
  $output .= "</SELECT>\n";
  $output .= "</P>\n";

  $output .= "<P>\n";
  $output .= "<B>Abstract:</B><BR>\n";
Dries's avatar
 
Dries committed
88
  $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"abstract\">". check_output($abstract) ."</TEXTAREA><BR>\n";
Dries's avatar
 
Dries committed
89
  $output .= " <SMALL><I>Allowed HTML tags: ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
Dries's avatar
 
Dries committed
90 91 92 93
  $output .= "</P>\n";

  $output .= "<P>\n";
  $output .= " <B>Extended story:</B><BR>\n";
Dries's avatar
 
Dries committed
94
  $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"article\">". check_output($article) ."</TEXTAREA><BR>\n";
Dries's avatar
 
Dries committed
95
  $output .= " <SMALL><I>Allowed HTML tags: ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
Dries's avatar
 
Dries committed
96
  $output .= "</P>\n";
Dries's avatar
 
Dries committed
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115

  if (empty($subject)) {
    $output .= "<P>\n";
    $output .= " <FONT COLOR=\"red\"><B>Warning:</B></FONT> you did not supply a <U>subject</U>.\n";
    $outout .= "</P>\n";
    $output .= "<P>\n";
    $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview submission\">\n";
    $output .= "</P>\n";
  }
  else if (empty($abstract)) {
    $output .= "<P>\n";
    $output .= " <FONT COLOR=\"red\"><B>Warning:</B></FONT> you did not supply an <U>abstract</U>.\n";
    $outout .= "</P>\n";
    $output .= "<P>\n";
    $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview submission\">\n";
    $output .= "</P>\n";
  }
  else { 
    $output .= "<P>\n";
Dries's avatar
 
Dries committed
116 117
    $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview submission\">\n";
    $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Submit submission\">\n";
Dries's avatar
 
Dries committed
118 119
    $output .= "</P>\n";
  }
Dries's avatar
Dries committed
120

Dries's avatar
 
Dries committed
121 122 123
  $output .= "</FORM>\n";
  
  $theme->header();
Dries's avatar
Dries committed
124
  $theme->article(new Story($user->userid, $subject, $abstract, $article, $category, time()));
Dries's avatar
 
Dries committed
125 126
  $theme->box("Submit a story", $output);
  $theme->footer();
Dries's avatar
Dries committed
127 128
}

Dries's avatar
 
Dries committed
129
function submit_submit($subject, $abstract, $article, $category) {
Dries's avatar
 
Dries committed
130
  global $user, $theme;
Dries's avatar
Dries committed
131

Dries's avatar
 
Dries committed
132 133 134
  ### Add log entry:
  watchdog("story", "added new story with subject `$subject'");
  
Dries's avatar
 
Dries committed
135
  ### Add submission to SQL table:
Dries's avatar
 
Dries committed
136
  db_query("INSERT INTO stories (author, subject, abstract, article, category, timestamp) VALUES ('$user->id', '". check_input($subject) ."', '". check_input($abstract) ."', '". check_input($article) ."', '". check_input($category) ."', '". time() ."')");
Dries's avatar
 
Dries committed
137
  
Dries's avatar
Dries committed
138 139
  ### Display confirmation message:
  $theme->header(); 
Dries's avatar
 
Dries committed
140
  $theme->box("Thank you for your submission.", "Thank you for your submission. Your submission has been whisked away to our submission queue where our registered users will frown at it, poke at it and hopefully carry it to the front page for discussion.");
Dries's avatar
Dries committed
141 142 143
  $theme->footer();
}

Dries's avatar
 
Dries committed
144
include "includes/common.inc";
Dries's avatar
 
Dries committed
145

Dries's avatar
Dries committed
146
switch($op) {
Dries's avatar
 
Dries committed
147
  case "Preview submission":
Dries's avatar
 
Dries committed
148
    submit_preview($subject, $abstract, $article, $category);
Dries's avatar
Dries committed
149
    break;
Dries's avatar
 
Dries committed
150
  case "Submit submission":
Dries's avatar
 
Dries committed
151
    submit_submit($subject, $abstract, $article, $category);
Dries's avatar
Dries committed
152 153
    break;
  default:
Dries's avatar
 
Dries committed
154
    submit_enter();
Dries's avatar
Dries committed
155 156 157
    break;
}

Dries's avatar
Dries committed
158
?>