* * $Id: submit.php,v 1.1 2001/02/10 19:03:01 haakon Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ function prepareContrib() { global $config, $postedbyemail, $postedbyname, $summary, $usrname; if ($config["registered-only-submissions"] == 0) { $ret = ($postedbyemail != ""? "$postedbyname" : $postedbyname); } else { $ret = "$postedbyname"; } $ret .= " " .i18n("writes") ." \"$summary\""; return stripslashes($ret); } function previewPost() { global $title, $keyword, $topic, $summary, $body, $postedbyname, $postedbyemail, $usr; $a = constructStory($title, $topic, $keyword, $summary, $body); $a["PostedByUser"] = "Somebody"; $a["Summary"] = prepareContrib(); $a["Body"] = $body; $a["Time"] = serverToLocal(time(), $usr["Timezone"]); print("\n
\n"); if (strlen($body) > 0) printLongStory($a); else printShortStory("", $a, ""); print("\n
\n"); } function cleanup($str) { $str = str_replace("\r\n", "
", $str); //changes all newlines to HTML breaklines $str = str_replace("", "?>", $str); return $str; } function submitStory($title, $keyword, $topic, $summary, $body, $postedbyname, $postedbyemail) { $fp = fopen("admin/stories/contrib/" .uniqid($topic), "w"); fwrite($fp, "Title::$title\n"); fwrite($fp, "Time::" . time() . "\n"); if ($keyword != "") fwrite($fp, "Keyword::$keyword\n"); fwrite($fp, "Topic::$topic\n"); $summary = prepareContrib(); $summary = cleanup($summary); fwrite($fp, "Summary::$summary\n"); if ($body != "") fwrite($fp, "Body::" .cleanup($body) ."\n"); if ($postedbyemail != "") fwrite($fp, "Posted-by-email::$postedbyemail\n"); fclose($fp); } function formValidates() { // checks that required fields are filled, returns boolean global $title, $summary, $postedbyname; return (($title != "") && ($summary != "") && ($postedbyname != "")); } function printReqFields() { print("" .i18n("You have to fill out all the required fields!") ."

"); } function printForm($postallowed) { global $config, $title, $keyword, $topic, $summary, $body, $postedbyname, $postedbyemail, $HTTP_COOKIE_VARS, $usr; if ($postedbyname == "") $postedbyname = $usr["Realname"]; if ($postedbyemail == "") $postedbyemail = $usr["FakeEmail"]; if ($config["registered-only-submissions"] == 0) { $extrafields = "

" .i18n("Your #B#name#/B#") .": (" .i18n("Required") .")\n

" .i18n("Your #B#e-mail address#/B#") .": (" .i18n("Optional") .")\n
"; } else { $extrafields = "\n\n"; } $extrafields .= ""; if ($postallowed) $extrafields .= ""; printFilledSubmitForm("", "submit.php", $title, $keyword, $topic, $summary, $body, $extrafields); } include ".sipsconfig.php"; include $config["sipssys"] ."/code/stories.inc.php"; printTop(i18n("submit story")); $fullpage = implode("", file($config["sipssys"] ."/themes/" .$usr["Theme"] ."/submit")); $pagepart = explode("#FORM#", $fullpage); print($pagepart[0]); if ($submit == i18n("Preview")) { if (formValidates()) { previewPost(); printForm(true); } else { printReqFields(); printForm(false); } } else if ($submit == i18n("Post this")) { if (formValidates()) { submitStory($title, $keyword, $topic, $summary, $body, $postedbyname, $postedbyemail); print("

" .i18n("Story Submitted") ."

\n" .i18n("Your story was submitted.") ." " .i18n("We will go through it as soon as possible, and quite possibly post it to #1#.", $config["sitename"]) ." " .i18n("Thanks for your submission!") ."\n

" .i18n("Front page") .""); if ($config["notify-submissions"] == 1) mail($config["siteadmin"], $config["sitename"] .": $title", i18n("A story titled #1# was just submitted to #2#.", "\"$title\"", $config["sitename"]) ." " .i18n("It has to be approved for publishing. Please go to #1# to approve it.", $config["httpbase"] ."/admin/"), "From: " .$config["siteadmin"] ."\nReply-To: dev@null"); } else { printReqFields(); printForm(true); } } else { if ($config["registered-only-submissions"] == 0) { printForm(false); } else { if ($usrname == "default") { print(i18n("Sorry, only registered users of #SITENAME# are allowed to submit stories.")); } else { printForm(false); } } } print($pagepart[1]); printBottom(); ?>