2006-12-02 04:36:16 +00:00
|
|
|
<?php
|
|
|
|
/*
|
2013-02-27 17:18:33 +01:00
|
|
|
* e107 website system
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008-2013 e107 Inc (e107.org)
|
|
|
|
* Released under the terms and conditions of the
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
|
|
|
*
|
|
|
|
*/
|
2008-05-31 17:55:31 +00:00
|
|
|
|
2013-07-12 03:21:27 -07:00
|
|
|
|
|
|
|
if(!empty($_POST) && !isset($_POST['e-token']))
|
|
|
|
{
|
|
|
|
// set e-token so it can be processed by class2
|
|
|
|
$_POST['e-token'] = '';
|
|
|
|
}
|
2009-04-21 21:26:59 +00:00
|
|
|
require_once("class2.php");
|
2009-08-28 15:30:25 +00:00
|
|
|
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
|
2009-07-14 11:05:54 +00:00
|
|
|
|
2006-12-02 04:36:16 +00:00
|
|
|
require_once(HEADERF);
|
|
|
|
|
|
|
|
if (!isset($pref['subnews_class']))
|
|
|
|
{
|
2009-12-19 14:52:57 +00:00
|
|
|
$pref['subnews_class'] = e_UC_MEMBER;
|
2006-12-02 04:36:16 +00:00
|
|
|
}
|
2009-04-21 21:26:59 +00:00
|
|
|
|
2015-04-17 12:18:08 -07:00
|
|
|
|
|
|
|
|
2006-12-02 04:36:16 +00:00
|
|
|
if (!check_class($pref['subnews_class']))
|
|
|
|
{
|
2015-07-02 13:43:22 +01:00
|
|
|
$ns->tablerender(LAN_UI_403_TITLE_ERROR, LAN_UI_403_BODY_ERROR);
|
2009-01-22 01:58:29 +00:00
|
|
|
require_once(FOOTERF);
|
|
|
|
exit;
|
2006-12-02 04:36:16 +00:00
|
|
|
}
|
|
|
|
|
2009-04-21 21:26:59 +00:00
|
|
|
if (isset($_POST['submitnews_submit']) && $_POST['submitnews_title'] && $_POST['submitnews_item'])
|
2006-12-02 04:36:16 +00:00
|
|
|
{
|
2012-01-02 22:06:22 +00:00
|
|
|
$ip = e107::getIPHandler()->getIP(FALSE);
|
2009-04-21 21:26:59 +00:00
|
|
|
$fp = new floodprotect;
|
|
|
|
if ($fp->flood("submitnews", "submitnews_datestamp") == FALSE)
|
|
|
|
{
|
2016-01-13 19:17:37 -08:00
|
|
|
e107::redirect();
|
2009-04-21 21:26:59 +00:00
|
|
|
exit;
|
|
|
|
}
|
2009-01-22 01:58:29 +00:00
|
|
|
|
2009-04-21 21:26:59 +00:00
|
|
|
$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)
|
2009-01-22 01:58:29 +00:00
|
|
|
{
|
2009-04-21 21:26:59 +00:00
|
|
|
$message = SUBNEWSLAN_7;
|
|
|
|
$submitnews_error = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ==== Process File Upload ====
|
2015-02-14 23:34:15 -08:00
|
|
|
if (FILE_UPLOADS && $_FILES['file_userfile'] && vartrue($pref['subnews_attach']) && vartrue($pref['upload_enabled']) && check_class($pref['upload_class']))
|
2009-04-21 21:26:59 +00:00
|
|
|
{
|
2009-08-17 19:26:17 +00:00
|
|
|
require_once(e_HANDLER.'upload_handler.php');
|
2012-05-17 09:19:44 +00:00
|
|
|
$uploaded = process_uploaded_files(e_UPLOAD, FALSE, array('file_mask' => 'jpg,gif,png', 'max_file_count' => 1));
|
2009-04-21 21:26:59 +00:00
|
|
|
|
2009-08-17 19:26:17 +00:00
|
|
|
if (($uploaded === FALSE) || !is_array($uploaded))
|
|
|
|
{ // Non-specific error
|
|
|
|
$submitnews_error = TRUE;
|
|
|
|
$message = SUBNEWSLAN_8;
|
|
|
|
}
|
2011-05-03 22:11:03 +00:00
|
|
|
else
|
2009-08-17 19:26:17 +00:00
|
|
|
{
|
2011-05-03 22:11:03 +00:00
|
|
|
$submitnews_filearray = array();
|
|
|
|
|
|
|
|
foreach($uploaded as $c=>$v)
|
|
|
|
{
|
|
|
|
if (varset($uploaded[$c]['error'],0) != 0)
|
|
|
|
{
|
2012-05-17 09:19:44 +00:00
|
|
|
$submitnews_error = TRUE;
|
|
|
|
$message = handle_upload_messages($uploaded);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-03 22:11:03 +00:00
|
|
|
if (isset($uploaded[$c]['name']) && isset($uploaded[$c]['type']) && isset($uploaded[$c]['size']))
|
2012-05-17 09:19:44 +00:00
|
|
|
{
|
2011-05-03 22:11:03 +00:00
|
|
|
$filename = $uploaded[$c]['name'];
|
|
|
|
$filetype = $uploaded[$c]['type'];
|
|
|
|
$filesize = $uploaded[$c]['size'];
|
2012-05-17 09:19:44 +00:00
|
|
|
$fileext = substr(strrchr($filename, "."), 1);
|
|
|
|
$today = getdate();
|
2011-05-03 22:11:03 +00:00
|
|
|
$submitnews_file = USERID."_".$today[0]."_".$c."_".str_replace(" ", "_", substr($submitnews_title, 0, 6)).".".$fileext;
|
2012-05-17 09:19:44 +00:00
|
|
|
|
|
|
|
if (is_numeric($pref['subnews_resize']) && ($pref['subnews_resize'] > 30) && ($pref['subnews_resize'] < 5000))
|
|
|
|
{
|
|
|
|
require_once(e_HANDLER.'resize_handler.php');
|
|
|
|
|
|
|
|
if (!resize_image(e_UPLOAD.$filename, e_UPLOAD.$submitnews_file, $pref['subnews_resize']))
|
|
|
|
{
|
|
|
|
rename(e_UPLOAD.$filename, e_UPLOAD.$submitnews_file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elseif ($filename)
|
|
|
|
{
|
|
|
|
rename(e_UPLOAD.$filename, e_UPLOAD.$submitnews_file);
|
|
|
|
}
|
2009-09-28 21:22:16 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-21 21:26:59 +00:00
|
|
|
|
2012-05-17 09:19:44 +00:00
|
|
|
if ($filename && file_exists(e_UPLOAD.$submitnews_file))
|
|
|
|
{
|
2011-05-03 22:11:03 +00:00
|
|
|
$submitnews_filearray[] = $submitnews_file;
|
2012-05-17 09:19:44 +00:00
|
|
|
}
|
2011-05-03 22:11:03 +00:00
|
|
|
|
2012-05-17 09:19:44 +00:00
|
|
|
}
|
2009-01-22 01:58:29 +00:00
|
|
|
}
|
2011-05-03 22:11:03 +00:00
|
|
|
|
2009-01-22 01:58:29 +00:00
|
|
|
}
|
2009-04-21 21:26:59 +00:00
|
|
|
|
2009-08-17 19:26:17 +00:00
|
|
|
if ($submitnews_error === FALSE)
|
2009-04-21 21:26:59 +00:00
|
|
|
{
|
2013-07-12 03:21:27 -07:00
|
|
|
$sql->insert("submitnews", "0, '$submitnews_user', '$submitnews_email', '$submitnews_title', '".intval($_POST['cat_id'])."', '$submitnews_item', '".time()."', '$ip', '0', '".implode(',',$submitnews_filearray)."' ");
|
|
|
|
|
2011-05-03 22:11:03 +00:00
|
|
|
$edata_sn = array("user" => $submitnews_user, "email" => $submitnews_email, "itemtitle" => $submitnews_title, "catid" => intval($_POST['cat_id']), "item" => $submitnews_item, "image" => $submitnews_file, "ip" => $ip);
|
2015-02-15 16:07:27 -08:00
|
|
|
|
|
|
|
e107::getEvent()->trigger("subnews", $edata_sn); // bc
|
2015-02-13 02:30:31 -08:00
|
|
|
e107::getEvent()->trigger("user_news_submit", $edata_sn);
|
2013-07-12 03:21:27 -07:00
|
|
|
|
|
|
|
$mes = e107::getMessage();
|
|
|
|
$mes->addSuccess(LAN_134);
|
|
|
|
echo $mes->render();
|
|
|
|
|
|
|
|
// $ns->tablerender(LAN_133, "<div style='text-align:center'>".LAN_134."</div>");
|
2009-04-21 21:26:59 +00:00
|
|
|
require_once(FOOTERF);
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
message_handler("P_ALERT", $message);
|
|
|
|
}
|
2006-12-02 04:36:16 +00:00
|
|
|
}
|
|
|
|
|
2015-04-17 12:18:08 -07:00
|
|
|
$text = "";
|
|
|
|
|
2009-04-21 21:26:59 +00:00
|
|
|
if (!defined("USER_WIDTH")) { define("USER_WIDTH","width:95%"); }
|
2006-12-02 04:36:16 +00:00
|
|
|
|
2015-04-17 12:18:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
if (!empty($pref['news_subheader']))
|
|
|
|
{
|
|
|
|
$text .= "
|
|
|
|
<div class='alert alert-block alert-info '>
|
|
|
|
".$tp->toHTML($pref['news_subheader'], true, "BODY")."
|
|
|
|
</div>";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$text .= "
|
|
|
|
<div>
|
2009-04-21 21:26:59 +00:00
|
|
|
<form id='dataform' method='post' action='".e_SELF."' enctype='multipart/form-data' onsubmit='return frmVerify()'>
|
2013-07-10 06:17:28 -07:00
|
|
|
<table class='table fborder'>";
|
2009-04-21 21:26:59 +00:00
|
|
|
|
2015-04-17 12:18:08 -07:00
|
|
|
|
2007-04-15 20:56:28 +00:00
|
|
|
|
2009-04-21 21:26:59 +00:00
|
|
|
if (!USER)
|
2006-12-02 04:36:16 +00:00
|
|
|
{
|
2013-07-12 03:21:27 -07:00
|
|
|
$text .= "
|
|
|
|
<tr>
|
|
|
|
<td style='width:20%' class='forumheader3'>".LAN_7."</td>
|
|
|
|
<td style='width:80%' class='forumheader3'>
|
|
|
|
<input class='tbox' type='text' name='submitnews_name' size='60' value='".$tp->toHTML($submitnews_user,FALSE,'USER_TITLE')."' maxlength='100' required />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td style='width:20%' class='forumheader3'>".LAN_112."</td>
|
|
|
|
<td style='width:80%' class='forumheader3'>
|
|
|
|
<input class='tbox' type='text' name='submitnews_email' size='60' value='".$tp->toHTML($submitnews_email, FALSE, 'LINKTEXT')."' maxlength='100' required />
|
|
|
|
</td>
|
|
|
|
</tr>";
|
2006-12-02 04:36:16 +00:00
|
|
|
}
|
2007-04-15 20:56:28 +00:00
|
|
|
|
2009-04-21 21:26:59 +00:00
|
|
|
$text .= "
|
|
|
|
<tr>
|
|
|
|
<td style='width:20%' class='forumheader3'>".NWSLAN_6.": </td>
|
|
|
|
<td style='width:80%' class='forumheader3'>";
|
|
|
|
|
2015-04-17 12:18:08 -07:00
|
|
|
if (!$sql->select("news_category"))
|
2006-12-02 04:36:16 +00:00
|
|
|
{
|
2009-01-22 01:58:29 +00:00
|
|
|
$text .= NWSLAN_10;
|
2006-12-02 04:36:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-22 01:58:29 +00:00
|
|
|
$text .= "
|
2015-04-17 12:18:08 -07:00
|
|
|
<select name='cat_id' class='tbox form-control'>";
|
2016-02-15 01:07:34 -08:00
|
|
|
while (list($cat_id, $cat_name, $cat_icon) = $sql->fetch('num'))
|
2009-01-22 01:58:29 +00:00
|
|
|
{
|
2009-09-27 21:45:09 +00:00
|
|
|
$sel = (varset($_POST['cat_id'],'') == $cat_id) ? "selected='selected'" : "";
|
2009-04-21 21:26:59 +00:00
|
|
|
$text .= "<option value='{$cat_id}' {$sel}>".$tp->toHTML($cat_name, FALSE, "defs")."</option>";
|
2009-01-22 01:58:29 +00:00
|
|
|
}
|
|
|
|
$text .= "</select>";
|
2006-12-02 04:36:16 +00:00
|
|
|
}
|
2008-05-31 17:55:31 +00:00
|
|
|
|
2009-04-21 21:26:59 +00:00
|
|
|
$text .= "
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2015-07-02 14:15:17 -07:00
|
|
|
<td style='width:20%' class='forumheader3'>".LAN_TITLE."</td>
|
2009-04-21 21:26:59 +00:00
|
|
|
<td style='width:80%' class='forumheader3'>
|
2015-04-17 12:18:08 -07:00
|
|
|
<input class='tbox form-control' type='text' id='submitnews_title' name='submitnews_title' size='60' value='".$tp->toHTML(vartrue($_POST['submitnews_title']),TRUE,'USER_TITLE')."' maxlength='200' style='width:90%' required />
|
2009-04-21 21:26:59 +00:00
|
|
|
</td>
|
2013-06-24 19:17:22 +02:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td style='width:20%' class='forumheader3'>".LAN_135."</td>
|
|
|
|
<td style='width:80%' class='forumheader3'>
|
2013-07-12 03:21:27 -07:00
|
|
|
".e107::getForm()->bbarea('submitnews_item', $tp->toForm(vartrue($_POST['submitnews_item'])),null, null, 'large', 'required=1')."
|
2013-06-24 19:17:22 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
";
|
2008-05-31 17:55:31 +00:00
|
|
|
|
2006-12-02 04:36:16 +00:00
|
|
|
if ($pref['subnews_attach'] && $pref['upload_enabled'] && check_class($pref['upload_class']) && FILE_UPLOADS)
|
|
|
|
{
|
2009-04-21 21:26:59 +00:00
|
|
|
$text .= "
|
|
|
|
<tr>
|
|
|
|
<td style='width:20%' class='forumheader3'>".SUBNEWSLAN_5."<br /><span class='smalltext'>".SUBNEWSLAN_6."</span></td>
|
|
|
|
<td style='width:80%' class='forumheader3'>
|
2011-05-03 22:11:03 +00:00
|
|
|
<input class='tbox' type='file' name='file_userfile[]' style='width:90%' multiple='multiple' />
|
2009-04-21 21:26:59 +00:00
|
|
|
</td>
|
|
|
|
</tr>";
|
2006-12-02 04:36:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$text .= "
|
2009-04-21 21:26:59 +00:00
|
|
|
<tr>
|
|
|
|
<td colspan='2' style='text-align:center' class='forumheader'>
|
2013-02-20 17:53:40 -08:00
|
|
|
<input class='btn btn-success button' type='submit' name='submitnews_submit' value='".LAN_136."' />
|
2013-07-12 03:21:27 -07:00
|
|
|
<input type='hidden' name='e-token' value='".e_TOKEN."' />
|
2009-04-21 21:26:59 +00:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
2009-01-22 01:58:29 +00:00
|
|
|
</div>";
|
2009-04-21 21:26:59 +00:00
|
|
|
|
2006-12-02 04:36:16 +00:00
|
|
|
$ns->tablerender(LAN_136, $text);
|
2013-07-12 03:21:27 -07:00
|
|
|
|
2015-04-17 12:18:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
if(!vartrue($pref['subnews_htmlarea'])) // check after bbarea is called.
|
|
|
|
{
|
|
|
|
e107::wysiwyg(false);
|
|
|
|
}
|
|
|
|
|
2006-12-02 04:36:16 +00:00
|
|
|
require_once(FOOTERF);
|
2008-05-31 17:55:31 +00:00
|
|
|
|
2009-04-21 21:26:59 +00:00
|
|
|
|
2006-12-02 04:36:16 +00:00
|
|
|
|
2013-07-12 03:21:27 -07:00
|
|
|
?>
|