| [ Index ] |
PHP Cross Reference of E107 v0.7.22 code documentation |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvs_backup/e107_0.7/submitnews.php,v $ 14 | $Revision: 11346 $ 15 | $Date: 2010-02-17 13:56:14 -0500 (Wed, 17 Feb 2010) $ 16 | $Author: secretr $ 17 +----------------------------------------------------------------------------+ 18 */ 19 20 require_once ("class2.php"); 21 $e_wysiwyg = varsettrue($pref['subnews_htmlarea']) ? "submitnews_item" : ""; 22 require_once(HEADERF); 23 24 if (!isset($pref['subnews_class'])) 25 { 26 $pref['subnews_class'] = e_UC_MEMBER; 27 } 28 29 if (!check_class($pref['subnews_class'])) 30 { 31 $ns->tablerender(NWSLAN_12, NWSLAN_11); 32 require_once(FOOTERF); 33 exit; 34 } 35 36 if (isset($_POST['submitnews_submit']) && $_POST['submitnews_title'] && $_POST['submitnews_item']) 37 { 38 $ip = $e107->getip(); 39 $fp = new floodprotect; 40 if ($fp->flood("submitnews", "submitnews_datestamp") == FALSE) 41 { 42 header("location:".e_BASE."index.php"); 43 exit; 44 } 45 46 $submitnews_user = (USER ? USERNAME : trim($tp->toDB($_POST['submitnews_name']))); 47 $submitnews_email = (USER ? USEREMAIL : trim(check_email($tp->toDB($_POST['submitnews_email'])))); 48 $submitnews_title = $tp->toDB($_POST['submitnews_title']); 49 $submitnews_item = $tp->toDB($_POST['submitnews_item']); 50 $submitnews_item = str_replace("src="e107_images", "src="".SITEURL."e107_images", $submitnews_item); 51 $submitnews_file = ""; 52 $submitnews_error = FALSE; 53 if (!$submitnews_user || !$submitnews_email) 54 { 55 $message = SUBNEWSLAN_7; 56 $submitnews_error = TRUE; 57 } 58 59 // ==== Process File Upload ==== 60 if (FILE_UPLOADS && $_FILES['file_userfile'] && varsettrue($pref['subnews_attach']) && varsettrue($pref['upload_enabled']) && check_class($pref['upload_class'])) 61 { 62 require_once(e_HANDLER.'upload_handler.php'); 63 $uploaded = process_uploaded_files(e_IMAGE . 'newspost_images/', FALSE, array('file_mask' => 'jpg,gif,png', 'max_file_count' => 1)); 64 65 /* 66 if ($filename && $fileext != "jpg" && $fileext != "gif" && $fileext != "png") 67 { 68 $message = SUBNEWSLAN_3; 69 $submitnews_error = TRUE; 70 } 71 72 if (!$pref['upload_maxfilesize']) 73 { 74 $pref['upload_maxfilesize'] = ini_get('upload_max_filesize') * 1048576; 75 } 76 77 if ($filesize > $pref['upload_maxfilesize']) 78 { 79 $message = SUBNEWSLAN_4; 80 $submitnews_error = TRUE; 81 } 82 */ 83 if (($uploaded === FALSE) || !is_array($uploaded)) 84 { // Non-specific error 85 $submitnews_error = TRUE; 86 $message = SUBNEWSLAN_8; 87 } 88 elseif (varset($uploaded[0]['error'],0) != 0) 89 { 90 $submitnews_error = TRUE; 91 $message = handle_upload_messages($uploaded); 92 } 93 else 94 { 95 if (isset($uploaded[0]['name']) && isset($uploaded[0]['type']) && isset($uploaded[0]['size'])) 96 { 97 $filename = $uploaded[0]['name']; 98 $filetype = $uploaded[0]['type']; 99 $filesize = $uploaded[0]['size']; 100 $fileext = substr(strrchr($filename, "."), 1); 101 $today = getdate(); 102 $submitnews_file = USERID."_".$today[0]."_".str_replace(" ", "_", substr($submitnews_title, 0, 6)).".".$fileext; 103 if (is_numeric($pref['subnews_resize']) && ($pref['subnews_resize'] > 30) && ($pref['subnews_resize'] < 5000)) 104 { 105 require_once(e_HANDLER.'resize_handler.php'); 106 107 if (!resize_image(e_IMAGE.'newspost_images/'.$filename, e_IMAGE.'newspost_images/'.$submitnews_file, $pref['subnews_resize'])) 108 { 109 rename(e_IMAGE.'newspost_images/'.$filename, e_IMAGE.'newspost_images/'.$submitnews_file); 110 } 111 } 112 elseif ($filename) 113 { 114 rename(e_IMAGE.'newspost_images/'.$filename, e_IMAGE.'newspost_images/'.$submitnews_file); 115 } 116 } 117 } 118 119 if ($filename && !file_exists(e_IMAGE."newspost_images/".$submitnews_file)) 120 { 121 $submitnews_file = ""; 122 } 123 } 124 125 if ($submitnews_error === FALSE) 126 { 127 $sql->db_Insert("submitnews", "0, '$submitnews_user', '$submitnews_email', '$submitnews_title', '".intval($_POST['cat_id'])."', '$submitnews_item', '".time()."', '$ip', '0', '$submitnews_file' "); 128 $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); 129 $e_event->trigger("subnews", $edata_sn); 130 $ns->tablerender(LAN_133, "<div style='text-align:center'>".LAN_134."</div>"); 131 require_once(FOOTERF); 132 exit; 133 } 134 else 135 { 136 require_once(e_HANDLER."message_handler.php"); 137 message_handler("P_ALERT", $message); 138 } 139 } 140 141 if (!defined("USER_WIDTH")) { define("USER_WIDTH","width:95%"); } 142 143 $text = " 144 <div style='text-align:center'> 145 <form id='dataform' method='post' action='".e_SELF."' enctype='multipart/form-data' onsubmit='return frmVerify()'> 146 <table style='".USER_WIDTH."' class='fborder'>"; 147 148 if (!empty($pref['news_subheader'])) 149 { 150 $text .= " 151 <tr> 152 <td colspan='2' class='forumheader3'>".$tp->toHTML($pref['news_subheader'], TRUE, "TITLE")."<br /></td> 153 </tr>"; 154 } 155 156 if (!USER) 157 { 158 $text .= " 159 <tr> 160 <td style='width:20%' class='forumheader3'>".LAN_7."</td> 161 <td style='width:80%' class='forumheader3'> 162 <input class='tbox' type='text' name='submitnews_name' size='60' value='".$tp->toHTML($submitnews_user,FALSE,'USER_TITLE')."' maxlength='100' /> 163 </td> 164 </tr> 165 <tr> 166 <td style='width:20%' class='forumheader3'>".LAN_112."</td> 167 <td style='width:80%' class='forumheader3'> 168 <input class='tbox' type='text' name='submitnews_email' size='60' value='".$tp->toHTML($submitnews_email, FALSE, 'LINKTEXT')."' maxlength='100' /> 169 </td> 170 </tr>"; 171 } 172 173 $text .= " 174 <tr> 175 <td style='width:20%' class='forumheader3'>".NWSLAN_6.": </td> 176 <td style='width:80%' class='forumheader3'>"; 177 178 if (!$sql->db_Select("news_category")) 179 { 180 $text .= NWSLAN_10; 181 } 182 else 183 { 184 $text .= " 185 <select name='cat_id' class='tbox'>"; 186 while (list($cat_id, $cat_name, $cat_icon) = $sql->db_Fetch()) 187 { 188 $sel = (varset($_POST['cat_id'],'') == $cat_id) ? "selected='selected'" : ""; 189 $text .= "<option value='{$cat_id}' {$sel}>".$tp->toHTML($cat_name, FALSE, "defs")."</option>"; 190 } 191 $text .= "</select>"; 192 } 193 194 $text .= " 195 </td> 196 </tr> 197 <tr> 198 <td style='width:20%' class='forumheader3'>".LAN_62."</td> 199 <td style='width:80%' class='forumheader3'> 200 <input class='tbox' type='text' id='submitnews_title' name='submitnews_title' size='60' value='".$tp->toHTML($_POST['submitnews_title'],TRUE,'USER_TITLE')."' maxlength='200' style='width:90%' /> 201 </td> 202 </tr>"; 203 204 if (e_WYSIWYG) 205 { 206 $insertjs = "rows='25'"; 207 } 208 else 209 { 210 require_once(e_HANDLER."ren_help.php"); 211 $insertjs = "rows='15' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'"; 212 } 213 214 $text .= " 215 <tr> 216 <td style='width:20%' class='forumheader3'>".LAN_135."</td> 217 <td style='width:80%' class='forumheader3'> 218 <textarea class='tbox' id='submitnews_item' name='submitnews_item' cols='80' style='max-width:95%' {$insertjs}>".$tp->toHTML($_POST['submitnews_item'],TRUE,'USER_BODY')."</textarea><br />"; 219 220 if (!e_WYSIWYG) 221 { 222 $text .= display_help("helpb","submitnews"); 223 } 224 225 $text .= " 226 </td> 227 </tr>"; 228 229 if ($pref['subnews_attach'] && $pref['upload_enabled'] && check_class($pref['upload_class']) && FILE_UPLOADS) 230 { 231 $text .= " 232 <tr> 233 <td style='width:20%' class='forumheader3'>".SUBNEWSLAN_5."<br /><span class='smalltext'>".SUBNEWSLAN_6."</span></td> 234 <td style='width:80%' class='forumheader3'> 235 <input class='tbox' type='file' name='file_userfile[]' style='width:90%' /> 236 </td> 237 </tr>"; 238 } 239 240 $text .= " 241 <tr> 242 <td colspan='2' style='text-align:center' class='forumheader'> 243 <input class='button' type='submit' name='submitnews_submit' value='".LAN_136."' /> 244 </td> 245 </tr> 246 </table> 247 </form> 248 </div>"; 249 250 $ns->tablerender(LAN_136, $text); 251 require_once(FOOTERF); 252 253 function headerjs() 254 { 255 $adder = ""; 256 if (e_WYSIWYG) $adder = 'tinyMCE.triggerSave();'; 257 $script = " 258 <script type=\"text/javascript\"> 259 function frmVerify() 260 { 261 {$adder} 262 if(document.getElementById('submitnews_title').value == \"\") 263 { 264 alert('".SUBNEWSLAN_1."'); 265 return false; 266 } 267 268 if(document.getElementById('submitnews_item').value == \"\") 269 { 270 alert('".SUBNEWSLAN_2."'); 271 return false; 272 } 273 } 274 </script>"; 275 return $script; 276 } 277 278 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Aug 3 00:19:13 2010 |