diff --git a/e107_languages/English/lan_submitnews.php b/e107_languages/English/lan_submitnews.php index 1b856df14..b695af3bb 100644 --- a/e107_languages/English/lan_submitnews.php +++ b/e107_languages/English/lan_submitnews.php @@ -4,17 +4,17 @@ | e107 website system - Language File. | | $Source: /cvs_backup/e107_0.8/e107_languages/English/lan_submitnews.php,v $ -| $Revision: 1.2 $ -| $Date: 2007-04-12 23:04:51 $ -| $Author: e107coders $ +| $Revision: 1.3 $ +| $Date: 2009-04-21 21:26:59 $ +| $Author: e107steved $ +----------------------------------------------------------------------------+ */ define("PAGE_NAME", "Submit News"); -define("LAN_7", "Username: "); -define("LAN_62", "Subject: "); +define("LAN_7", "Name: "); +define("LAN_62", "News Title: "); define("LAN_112", "Email Address: "); define("LAN_133", "Thank you"); -define("LAN_134", "Your item has been submitted and will be reviewed by one of the site administrators in due course."); +define("LAN_134", "Your item has been submitted for review by one of the site administrators."); define("LAN_135", "News Item: "); define("LAN_136", "Submit News Item"); define("NWSLAN_6", "Category"); @@ -28,5 +28,6 @@ define("SUBNEWSLAN_3", "Your attachment must be either a jpg, gif or png file"); define("SUBNEWSLAN_4", "File too Large"); define("SUBNEWSLAN_5", "Image File"); define("SUBNEWSLAN_6", "(jpg, gif or png)"); +define('SUBNEWSLAN_7', 'You must give your name and email address'); -?> \ No newline at end of file +?> diff --git a/submitnews.php b/submitnews.php index 6e46e09fe..c96cf8b9b 100644 --- a/submitnews.php +++ b/submitnews.php @@ -11,21 +11,21 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/submitnews.php,v $ -| $Revision: 1.8 $ -| $Date: 2009-01-22 01:58:29 $ -| $Author: mcfly_e107 $ +| $Revision: 1.9 $ +| $Date: 2009-04-21 21:26:59 $ +| $Author: e107steved $ +----------------------------------------------------------------------------+ */ + require_once("class2.php"); - -$e_wysiwyg = varsettrue($pref['subnews_htmlarea']) ? 'e107_submitnews_item' : ''; - +$e_wysiwyg = varsettrue($pref['subnews_htmlarea']) ? "submitnews_item" : ""; require_once(HEADERF); if (!isset($pref['subnews_class'])) { - $pref['subnews_class'] = "0"; + $pref['subnews_class'] = '0'; } + if (!check_class($pref['subnews_class'])) { $ns->tablerender(NWSLAN_12, NWSLAN_11); @@ -33,114 +33,134 @@ if (!check_class($pref['subnews_class'])) exit; } -$author_name = $tp->toDB($_POST['author_name']); -$author_email = $tp->toDB(check_email($_POST['author_email'])); - -if (isset($_POST['submit'])) +if (isset($_POST['submitnews_submit']) && $_POST['submitnews_title'] && $_POST['submitnews_item']) { - $user = (USER ? USERNAME : $author_name); - $email = (USER ? USEREMAIL : $author_email); - - if ($user && $email) + $ip = $e107->getip(); + $fp = new floodprotect; + if ($fp->flood("submitnews", "submitnews_datestamp") == FALSE) { - $ip = $e107->getip(); - $fp = new floodprotect; - if ($fp->flood("submitnews", "submitnews_datestamp") == false) + header("location:".e_BASE."index.php"); + exit; + } + + $submitnews_user = (USER ? USERNAME : trim($tp->toDB($_POST['submitnews_name']))); + $submitnews_email = (USER ? USEREMAIL : trim(check_email($tp->toDB($_POST['submitnews_email'])))); + $submitnews_title = $tp->toDB($_POST['submitnews_title']); + $submitnews_item = $tp->toDB($_POST['submitnews_item']); + $submitnews_item = str_replace("src="e107_images", "src="".SITEURL."e107_images", $submitnews_item); + $submitnews_file = ""; + $submitnews_error = FALSE; + if (!$submitnews_user || !$submitnews_email) + { + $message = SUBNEWSLAN_7; + $submitnews_error = TRUE; + } + + // ==== Process File Upload ==== + if ($_FILES['file_userfile'] && $pref['subnews_attach'] && $pref['upload_enabled'] && check_class($pref['upload_class']) && FILE_UPLOADS) + { + require_once(e_HANDLER."upload_handler.php"); + $uploaded = file_upload(e_IMAGE . "newspost_images/"); + $filename = $uploaded[0]['name']; + $filetype = $uploaded[0]['type']; + $filesize = $uploaded[0]['size']; + $fileext = substr(strrchr($filename, "."), 1); + + if ($filename && $fileext != "jpg" && $fileext != "gif" && $fileext != "png") { - header("location:" . e_BASE . "index.php"); - exit; + $message = SUBNEWSLAN_3; + $submitnews_error = TRUE; } - $itemtitle = $tp->toDB($_POST['itemtitle']); - $item = $tp->toDB($_POST['e107_submitnews_item']); - $item = str_replace("src="e107_images", "src="" . SITEURL . "e107_images", $item); - // Process File Upload ================================================= - if ($_FILES['file_userfile'] && $pref['subnews_attach'] && $pref['upload_enabled'] && check_class($pref['upload_class']) && FILE_UPLOADS) + + if (!$pref['upload_maxfilesize']) { - require_once(e_HANDLER . "upload_handler.php"); - $uploaded = file_upload(e_IMAGE . "newspost_images/"); - $file = $uploaded[0]['name']; - $filetype = $uploaded[0]['type']; - $filesize = $uploaded[0]['size']; - $fileext = substr(strrchr($file, "."), 1); - - if (!$pref['upload_maxfilesize']) + $pref['upload_maxfilesize'] = ini_get('upload_max_filesize') * 1048576; + } + + if ($filesize > $pref['upload_maxfilesize']) + { + $message = SUBNEWSLAN_4; + $submitnews_error = TRUE; + } + + if ($filename && !$submitnews_error) + { + $today = getdate(); + $submitnews_file = USERID."_".$today[0]."_".str_replace(" ", "_", substr($submitnews_title, 0, 6)).".".$fileext; + if ($pref['subnews_resize']) { - $pref['upload_maxfilesize'] = ini_get('upload_max_filesize') * 1048576; - } - - if ($uploaded && $fileext != "jpg" && $fileext != "gif" && $fileext != "png") - { - $message = SUBNEWSLAN_3; - $error = true; - } - - if ($filesize > $pref['upload_maxfilesize']) - { - $message = SUBNEWSLAN_4; - $error = true; - } - - if (!$error) - { - // $numberoffiles = count($uploaded); - $today = getdate(); - $newname = USERID . "_" . $today[0] . "_" . str_replace(" ", "_", substr($itemtitle, 0, 6)) . "." . $fileext; - if ($file && $pref['subnews_resize']) + require_once(e_HANDLER."resize_handler.php"); + + if (!resize_image(e_IMAGE."newspost_images/".$filename, e_IMAGE."newspost_images/".$submitnews_file, $pref['subnews_resize'])) { - require_once(e_HANDLER . "resize_handler.php"); - $rezwidth = $pref['subnews_resize']; - if (!resize_image(e_IMAGE . "newspost_images/" . $file, e_IMAGE . "newspost_images/" . $newname, $rezwidth)) - { - rename(e_IMAGE . "newspost_images/" . $file, e_IMAGE . "newspost_images/" . $newname); - } - } elseif ($file) - { - rename(e_IMAGE . "newspost_images/" . $file, e_IMAGE . "newspost_images/" . $newname); + rename(e_IMAGE."newspost_images/".$filename, e_IMAGE."newspost_images/".$submitnews_file); } } - } - - if ($error == false) - { - if (!file_exists(e_IMAGE . "newspost_images/" . $newname)) + elseif ($filename) { - $newname = ""; + rename(e_IMAGE."newspost_images/".$filename, e_IMAGE."newspost_images/".$submitnews_file); } - $sql->db_Insert("submitnews", "0, '$user', '$email', '$itemtitle', '".intval($_POST['cat_id'])."','$item', '" . time() . "', '$ip', '0', '$newname' "); - $edata_sn = array("user" => $user, "email" => $email, "itemtitle" => $itemtitle, "catid" => intval($_POST['cat_id']), "item" => $item, "ip" => $ip, "newname" => $newname); - $e_event->trigger("subnews", $edata_sn); - $ns->tablerender(LAN_133, "
" . LAN_134 . "
"); - require_once(FOOTERF); - exit; } - else + + if ($filename && !file_exists(e_IMAGE."newspost_images/".$submitnews_file)) { - require_once(e_HANDLER . "message_handler.php"); - message_handler("P_ALERT", $message); + $submitnews_file = ""; } } + + if ($submitnews_error == FALSE) + { + $sql->db_Insert("submitnews", "0, '$submitnews_user', '$submitnews_email', '$submitnews_title', '".intval($_POST['cat_id'])."', '$submitnews_item', '".time()."', '$ip', '0', '$submitnews_file' "); + $edata_sn = array("user" => $submitnews_user, "email" => $submitnews_email, "itemtitle" => $submitnews_title, "catid" => intval($_POST['cat_id']), "item" => $submitnews_item, "ip" => $ip, "newname" => $submitnews_file); + $e_event->trigger("subnews", $edata_sn); + $ns->tablerender(LAN_133, "
".LAN_134."
"); + require_once(FOOTERF); + exit; + } + else + { + require_once(e_HANDLER."message_handler.php"); + message_handler("P_ALERT", $message); + } } -if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:95%"); } +if (!defined("USER_WIDTH")) { define("USER_WIDTH","width:95%"); } -$text = "
-
\n -"; -if (!USER) -{ - $text .= "\n\n\n\n\n\n\n"; -} +$text = " +
+ +
" . LAN_7 . "\n\n
" . LAN_112 . "\n\n
"; if (!empty($pref['news_subheader'])) { - $text .= " - - "; + $text .= " + + + "; } -$text .= " - - + + + + + + + "; +} + +$text .= " + + + - - - -"; +$text .= " + + + + + +"; if (e_WYSIWYG) { - $insertjs = "rows='25' "; + $insertjs = "rows='25'"; } else { - require_once(e_HANDLER."ren_help.php"); - $insertjs = "rows='15' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'"; + require_once(e_HANDLER."ren_help.php"); + $insertjs = "rows='15' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'"; } $text .= " - - + -\n"; -if ($pref['subnews_attach'] && $pref['upload_enabled'] && check_class($pref['upload_class']) && FILE_UPLOADS) -{ - $text .= " - - - - \n"; + $text .= display_help("helpb","submitnews"); } $text .= " - - - -
" . $tp->toHTML($pref['news_subheader'], TRUE,'TITLE') . "
".$tp->toHTML($pref['news_subheader'], TRUE, "TITLE")."
" . NWSLAN_6 . ": "; +if (!USER) +{ + $text .= " +
".LAN_7." + +
".LAN_112." + +
".NWSLAN_6.": "; + if (!$sql->db_Select("news_category")) { $text .= NWSLAN_10; @@ -148,89 +168,97 @@ if (!$sql->db_Select("news_category")) else { $text .= " - "; while (list($cat_id, $cat_name, $cat_icon) = $sql->db_Fetch(MYSQL_NUM)) { - $sel = ($_POST['cat_id'] == $cat_id) ? "selected='selected'" : ""; - $text .= ""; + $sel = ($_POST['submitnews_category'] == $cat_id) ? "selected='selected'" : ""; + $text .= ""; } $text .= ""; } -$text .= "
" . LAN_62 . " - -
".LAN_62." + +
" . LAN_135 . " -
"; +
".LAN_135." +
"; if (!e_WYSIWYG) { - $text .= display_help("helpb","submitnews"); -} -$text .= "
" . SUBNEWSLAN_5 . "
" . SUBNEWSLAN_6 . "
- -
- -
-
+ +"; + +if ($pref['subnews_attach'] && $pref['upload_enabled'] && check_class($pref['upload_class']) && FILE_UPLOADS) +{ + $text .= " + + ".SUBNEWSLAN_5."
".SUBNEWSLAN_6." + + + + "; +} + +$text .= " + + + + + + +
"; + $ns->tablerender(LAN_136, $text); require_once(FOOTERF); function headerjs() { - $adder = ''; - if (e_WYSIWYG) $adder = 'triggerSave();'; - $script = ""; - return $script; + $adder = ""; + if (e_WYSIWYG) $adder = 'tinyMCE.triggerSave();'; + $script = " + "; + return $script; } ?>