2006-12-02 04:36:16 +00:00
|
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
+ ----------------------------------------------------------------------------+
|
|
|
|
|
| e107 website system
|
|
|
|
|
|
|
|
|
|
|
| <EFBFBD>Steve Dunstan 2001-2002
|
|
|
|
|
| http://e107.org
|
|
|
|
|
| jalist@e107.org
|
|
|
|
|
|
|
|
|
|
|
| Released under the terms and conditions of the
|
|
|
|
|
| GNU General Public License (http://gnu.org).
|
|
|
|
|
|
|
|
|
|
|
| $Source: /cvs_backup/e107_0.8/submitnews.php,v $
|
2008-06-02 18:29:09 +00:00
|
|
|
|
| $Revision: 1.7 $
|
|
|
|
|
| $Date: 2008-06-02 18:28:58 $
|
2008-05-31 17:55:31 +00:00
|
|
|
|
| $Author: e107steved $
|
2006-12-02 04:36:16 +00:00
|
|
|
|
+----------------------------------------------------------------------------+
|
|
|
|
|
*/
|
|
|
|
|
require_once("class2.php");
|
2008-05-31 17:55:31 +00:00
|
|
|
|
|
|
|
|
|
$e_wysiwyg = varsettrue($pref['subnews_htmlarea']) ? 'e107_submitnews_item' : '';
|
|
|
|
|
|
2006-12-02 04:36:16 +00:00
|
|
|
|
require_once(HEADERF);
|
|
|
|
|
|
|
|
|
|
if (!isset($pref['subnews_class']))
|
|
|
|
|
{
|
|
|
|
|
$pref['subnews_class'] = "0";
|
|
|
|
|
}
|
|
|
|
|
if (!check_class($pref['subnews_class']))
|
|
|
|
|
{
|
|
|
|
|
$ns->tablerender(NWSLAN_12, NWSLAN_11);
|
|
|
|
|
require_once(FOOTERF);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$author_name = $tp->toDB($_POST['author_name']);
|
|
|
|
|
$author_email = $tp->toDB(check_email($_POST['author_email']));
|
|
|
|
|
|
|
|
|
|
if (isset($_POST['submit']))
|
|
|
|
|
{
|
|
|
|
|
$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)
|
|
|
|
|
{
|
|
|
|
|
header("location:" . e_BASE . "index.php");
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
$itemtitle = $tp->toDB($_POST['itemtitle']);
|
2008-05-31 17:55:31 +00:00
|
|
|
|
$item = $tp->toDB($_POST['e107_submitnews_item']);
|
2006-12-02 04:36:16 +00:00
|
|
|
|
$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)
|
|
|
|
|
{
|
|
|
|
|
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 ($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");
|
|
|
|
|
$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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($error == false)
|
|
|
|
|
{
|
|
|
|
|
if (!file_exists(e_IMAGE . "newspost_images/" . $newname))
|
|
|
|
|
{
|
|
|
|
|
$newname = "";
|
|
|
|
|
}
|
|
|
|
|
$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, "<div style='text-align:center'>" . LAN_134 . "</div>");
|
|
|
|
|
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%"); }
|
|
|
|
|
|
|
|
|
|
$text = "<div style='text-align:center'>
|
|
|
|
|
<form id='dataform' method='post' action='" . e_SELF . "' enctype='multipart/form-data' onsubmit='return frmVerify()'>\n
|
|
|
|
|
<table style='".USER_WIDTH."' class='fborder'>";
|
|
|
|
|
if (!USER)
|
|
|
|
|
{
|
|
|
|
|
$text .= "<tr>\n<td style='width:20%' class='forumheader3'>" . LAN_7 . "</td>\n<td style='width:80%' class='forumheader3'>\n<input class='tbox' type='text' name='author_name' size='60' value='$author_name' maxlength='100' />\n</td>\n</tr>\n<tr>\n<td style='width:20%' class='forumheader3'>" . LAN_112 . "</td>\n<td style='width:80%' class='forumheader3'>\n<input class='tbox' type='text' name='author_email' size='60' value='$author_email' maxlength='100' />\n</td>\n</tr>";
|
|
|
|
|
}
|
2007-04-15 20:56:28 +00:00
|
|
|
|
|
2006-12-02 04:36:16 +00:00
|
|
|
|
if (!empty($pref['news_subheader']))
|
|
|
|
|
{
|
|
|
|
|
$text .= " <tr>
|
2007-04-15 20:56:28 +00:00
|
|
|
|
<td colspan='2' class='forumheader3'>" . $tp->toHTML($pref['news_subheader'], TRUE,'TITLE') . "</td>
|
2006-12-02 04:36:16 +00:00
|
|
|
|
</tr>";
|
|
|
|
|
}
|
2007-04-15 20:56:28 +00:00
|
|
|
|
|
2006-12-02 04:36:16 +00:00
|
|
|
|
$text .= " <tr>
|
|
|
|
|
<td style='width:20%' class='forumheader3'>" . NWSLAN_6 . ": </td>
|
|
|
|
|
<td style='width:80%' class='forumheader3'>";
|
|
|
|
|
if (!$sql->db_Select("news_category"))
|
|
|
|
|
{
|
|
|
|
|
$text .= NWSLAN_10;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$text .= "
|
2008-05-31 17:55:31 +00:00
|
|
|
|
<select name='cat_id' class='tbox'>";
|
2006-12-02 04:36:16 +00:00
|
|
|
|
while (list($cat_id, $cat_name, $cat_icon) = $sql->db_Fetch())
|
|
|
|
|
{
|
2007-02-13 23:50:45 +00:00
|
|
|
|
$sel = ($_POST['cat_id'] == $cat_id) ? "selected='selected'" : "";
|
2008-05-31 17:55:31 +00:00
|
|
|
|
$text .= "<option value='{$cat_id}' {$sel}>" . $tp->toHTML($cat_name,FALSE,"defs") . "</option>";
|
2006-12-02 04:36:16 +00:00
|
|
|
|
}
|
|
|
|
|
$text .= "</select>";
|
|
|
|
|
}
|
|
|
|
|
$text .= "</td>
|
|
|
|
|
</tr><tr>
|
|
|
|
|
<td style='width:20%' class='forumheader3'>" . LAN_62 . "</td>
|
|
|
|
|
<td style='width:80%' class='forumheader3'>
|
2008-05-31 17:55:31 +00:00
|
|
|
|
<input class='tbox' type='text' id='itemtitle' name='itemtitle' size='60' value='{$itemtitle}' maxlength='200' style='width:90%' />
|
2006-12-02 04:36:16 +00:00
|
|
|
|
</td>
|
|
|
|
|
</tr>";
|
2008-05-31 17:55:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (e_WYSIWYG)
|
2006-12-02 04:36:16 +00:00
|
|
|
|
{
|
2008-05-31 17:55:31 +00:00
|
|
|
|
$insertjs = "rows='25' ";
|
2006-12-02 04:36:16 +00:00
|
|
|
|
}
|
2007-02-11 19:39:07 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2008-05-31 17:55:31 +00:00
|
|
|
|
require_once(e_HANDLER."ren_help.php");
|
|
|
|
|
$insertjs = "rows='15' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'";
|
2007-02-11 19:39:07 +00:00
|
|
|
|
}
|
2006-12-02 04:36:16 +00:00
|
|
|
|
|
|
|
|
|
$text .= "
|
|
|
|
|
<tr>
|
|
|
|
|
<td style='width:20%' class='forumheader3'>" . LAN_135 . "</td>
|
|
|
|
|
<td style='width:80%' class='forumheader3'>
|
2008-05-31 17:55:31 +00:00
|
|
|
|
<textarea class='tbox' id='e107_submitnews_item' name='e107_submitnews_item' cols='80' style='max-width:95%' {$insertjs}></textarea><br />";
|
2007-11-13 07:54:33 +00:00
|
|
|
|
|
2008-05-31 17:55:31 +00:00
|
|
|
|
if (!e_WYSIWYG)
|
2007-02-11 19:39:07 +00:00
|
|
|
|
{
|
2007-11-13 07:54:33 +00:00
|
|
|
|
$text .= display_help("helpb","submitnews");
|
2007-02-11 19:39:07 +00:00
|
|
|
|
}
|
|
|
|
|
$text .= " </td>
|
2006-12-02 04:36:16 +00:00
|
|
|
|
</tr>\n";
|
|
|
|
|
if ($pref['subnews_attach'] && $pref['upload_enabled'] && check_class($pref['upload_class']) && FILE_UPLOADS)
|
|
|
|
|
{
|
|
|
|
|
$text .= "
|
|
|
|
|
<tr>
|
|
|
|
|
<td style='width:20%' class='forumheader3'>" . SUBNEWSLAN_5 . "<br /><span class='smalltext'>" . SUBNEWSLAN_6 . "</span></td>
|
|
|
|
|
<td style='width:80%' class='forumheader3'>
|
|
|
|
|
<input class='tbox' type='file' name='file_userfile[]' style='width:90%' />
|
|
|
|
|
</td>
|
|
|
|
|
</tr>\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$text .= "
|
|
|
|
|
<tr>
|
|
|
|
|
<td colspan='2' style='text-align:center' class='forumheader'>
|
|
|
|
|
<input class='button' type='submit' name='submit' value='" . LAN_136 . "' />
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</form>
|
|
|
|
|
</div>";
|
|
|
|
|
$ns->tablerender(LAN_136, $text);
|
|
|
|
|
require_once(FOOTERF);
|
2008-05-31 17:55:31 +00:00
|
|
|
|
|
2006-12-02 04:36:16 +00:00
|
|
|
|
function headerjs()
|
|
|
|
|
{
|
2008-06-02 18:29:09 +00:00
|
|
|
|
$adder = '';
|
|
|
|
|
if (e_WYSIWYG) $adder = 'triggerSave();';
|
2008-05-31 17:55:31 +00:00
|
|
|
|
$script = "<script type=\"text/javascript\">
|
2006-12-02 04:36:16 +00:00
|
|
|
|
function frmVerify()
|
|
|
|
|
{
|
2008-06-02 18:29:09 +00:00
|
|
|
|
{$adder}
|
|
|
|
|
if(document.getElementById('itemtitle').value == \"\")
|
|
|
|
|
{
|
|
|
|
|
alert('" . SUBNEWSLAN_1 . "');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if(document.getElementById('e107_submitnews_item').value == \"\")
|
|
|
|
|
{
|
|
|
|
|
alert('" . SUBNEWSLAN_2 . "');
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2006-12-02 04:36:16 +00:00
|
|
|
|
}
|
|
|
|
|
</script>";
|
|
|
|
|
return $script;
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-31 17:55:31 +00:00
|
|
|
|
?>
|