| [ 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/upload.php,v $ 14 | $Revision: 11346 $ 15 | $Date: 2010-02-17 13:56:14 -0500 (Wed, 17 Feb 2010) $ 16 | $Author: secretr $ 17 +----------------------------------------------------------------------------+ 18 */ 19 require_once ("class2.php"); 20 21 if (!$pref['upload_enabled'] || $pref['upload_class'] == 255) 22 { 23 header("location: ".e_BASE."index.php"); 24 exit; 25 } 26 27 require_once(HEADERF); 28 29 if (!defined("USER_WIDTH")){ define("USER_WIDTH","width:97%"); } 30 31 if (!check_class($pref['upload_class'])) 32 { 33 $text = "<div style='text-align:center'>".LAN_UL_002."</div>"; 34 $ns->tablerender(LAN_UL_020, $text); 35 require_once(FOOTERF); 36 exit; 37 } 38 39 40 $message = ''; 41 $postemail =''; 42 if (isset($_POST['upload'])) 43 { 44 if (($_POST['file_email'] || USER == TRUE) && $_POST['file_name'] && $_POST['file_description'] && $_POST['download_category']) 45 { 46 require_once(e_HANDLER."upload_handler.php"); 47 // $uploaded = file_upload(e_FILE."public/", "unique"); 48 $uploaded = process_uploaded_files(e_FILE."public/", "unique", array('max_file_count' => 2, 'extra_file_types' => TRUE)); 49 50 // First, see what errors the upload handler picked up 51 if ($uploaded === FALSE) 52 { 53 $message = LAN_UL_021.'<br />'; 54 } 55 56 // Now see if we have a code file 57 if (count($uploaded) > 0) 58 { 59 if ($uploaded[0]['error'] == 0) 60 { 61 $file = $uploaded[0]['name']; 62 $filesize = $uploaded[0]['size']; 63 } 64 else 65 { 66 $message .= $uploaded[0]['message'].'<br />'; 67 } 68 } 69 70 // Now see if we have an image file 71 if (count($uploaded) > 1) 72 { 73 if ($uploaded[1]['error'] == 0) 74 { 75 $image = $uploaded[1]['name']; 76 } 77 else 78 { 79 $message .= $uploaded[1]['message'].'<br />'; 80 } 81 } 82 83 // The upload handler checks max file size 84 $downloadCategory = intval($_POST['download_category']); 85 if (!$downloadCategory) 86 { 87 $message .= LAN_UL_037.'<br />'; 88 } 89 90 // $message non-null here indicates an error - delete the files to keep things tidy 91 if ($message) 92 { 93 @unlink($file); 94 @unlink($image); 95 } 96 else 97 { 98 if (USER) 99 { 100 $qry = "SELECT user_hideemail FROM #user WHERE user_id=".USERID; 101 if(!$sql->db_Select_gen($qry)) 102 { 103 echo "Fatal database error!"; 104 exit; 105 } 106 $poster = USERID.".".USERNAME; 107 $row = $sql->db_Fetch(); 108 if ($row['user_hideemail']) 109 { 110 $postemail = '-witheld-'; 111 } 112 else 113 { 114 $postemail = USEREMAIL; 115 } 116 } 117 else 118 { 119 $poster = "0".$tp -> toDB($_POST['file_poster']); 120 $postemail = $tp->toDB($_POST['file_email']); 121 } 122 if (($postemail != '-witheld-') && !check_email($postemail)) 123 { 124 $message = LAN_UL_001."<br />"; 125 } 126 else 127 { 128 if ($postemail == '-witheld-') $postemail = ''; 129 $_POST['file_description'] = $tp->toDB($_POST['file_description']); 130 $file_time = time(); 131 $sql->db_Insert("upload", "0, '".$poster."', '".$postemail."', '".$tp -> toDB($_POST['file_website'])."', '".$file_time."', '".$tp -> toDB($_POST['file_name'])."', '".$tp -> toDB($_POST['file_version'])."', '".$file."', '".$image."', '".$tp -> toDB($_POST['file_description'])."', '".$tp -> toDB($_POST['file_demo'])."', '".$filesize."', 0, '".$downloadCategory."'"); 132 $edata_fu = array("upload_user" => $poster, "upload_email" => $postemail, "upload_name" => $tp -> toDB($_POST['file_name']),"upload_file" => $file, "upload_version" => $_POST['file_version'], "upload_description" => $tp -> toDB($_POST['file_description']), "upload_size" => $filesize, "upload_category" => $downloadCategory, "upload_website" => $tp -> toDB($_POST['file_website']), "upload_image" => $image, "upload_demo" => $tp -> toDB($_POST['file_demo']), "upload_time" => $file_time); 133 $e_event->trigger("fileupload", $edata_fu); 134 $message .= "<br />".LAN_404; 135 } 136 } 137 } 138 else 139 { // Error - missing data 140 require_once(e_HANDLER."message_handler.php"); 141 message_handler("ALERT", 5); 142 } 143 } 144 145 if ($message) 146 { 147 $text = "<div style=\"text-align:center\"><b>".$message."</b></div>"; 148 $ns->tablerender("", $text); 149 require_once(FOOTERF); 150 exit; 151 } 152 153 154 $text = "<div style='text-align:center'> 155 <form enctype='multipart/form-data' method='post' onsubmit='return frmVerify()' action='".e_SELF."'> 156 <table style='".USER_WIDTH."' class='fborder'> 157 <colgroup> 158 <col style='width:30%' /> 159 <col style='width:70%' /> 160 </colgroup> 161 <tr> 162 <td class='forumheader3'>".DOWLAN_11.":</td> 163 <td class='forumheader3'>"; 164 165 require_once(e_FILE."shortcode/batch/download_shortcodes.php"); 166 $dlparm = (isset($download_category)) ? $download_category : ""; 167 $text .= $tp->parseTemplate("{DOWNLOAD_CATEGORY_SELECT={$dlparm}}",true,$download_shortcodes); 168 169 170 $text .= " 171 </td> 172 </tr> 173 174 <tr> 175 <td style='text-align:center' colspan='2' class='forumheader3'>"; 176 177 $text .= "<b>".LAN_406."</b><br />".LAN_419.":"; 178 179 if (is_readable(e_ADMIN.'filetypes.php')) 180 { 181 $a_filetypes = trim(file_get_contents(e_ADMIN.'filetypes.php')); 182 $a_filetypes = explode(',', $a_filetypes); 183 foreach ($a_filetypes as $ftype) 184 { 185 $sa_filetypes[] = '.'.trim(str_replace('.', '', $ftype)); 186 } 187 $allowed_filetypes = implode(' | ', $sa_filetypes); 188 } 189 190 $text .= " ".$allowed_filetypes."<br />".LAN_407."<br /> 191 ".LAN_418.($pref['upload_maxfilesize'] ? $pref['upload_maxfilesize'] : ini_get('upload_max_filesize'))."<br />"; 192 193 $text .= "<span style='text-decoration:underline'>".LAN_408."</span> ".LAN_420."</td> 194 </tr>"; 195 196 if (!USER) 197 { // Prompt for name, email 198 $text .= "<tr> 199 <td class='forumheader3'>".LAN_61."</td> 200 <td class='forumheader3'><input class='tbox' style='width:90%' name='file_poster' type='text' size='50' maxlength='100' value='{$poster}' /></td> 201 </tr> 202 203 <tr> 204 <td class='forumheader3'><span style='text-decoration:underline'>".LAN_112."</span></td> 205 <td class='forumheader3'><input class='tbox' style='width:90%' name='file_email' id='user_email' type='text' size='50' maxlength='100' value='".$postemail."' /></td> 206 </tr>"; 207 } 208 209 $text .= " 210 <tr> 211 <td class='forumheader3'><span style='text-decoration:underline'>".LAN_409."</span></td> 212 <td class='forumheader3'><input class='tbox' style='width:90%' name='file_name' id='file_name' type='text' size='50' maxlength='100' /></td> 213 </tr> 214 215 <tr> 216 <td class='forumheader3'>".LAN_410."</td> 217 <td class='forumheader3'><input class='tbox' style='width:90%' name='file_version' type='text' size='10' maxlength='10' /></td> 218 </tr> 219 220 221 <tr> 222 <td class='forumheader3'><span style='text-decoration:underline'>".LAN_411."</span></td> 223 <td class='forumheader3'><input class='tbox' style='width:90%' id='file_realpath' name='file_userfile[]' type='file' size='47' /></td> 224 </tr> 225 226 <tr> 227 <td class='forumheader3'>".LAN_412."</td> 228 <td class='forumheader3'><input class='tbox' style='width:90%' name='file_userfile[]' type='file' size='47' /></td> 229 </tr> 230 231 <tr> 232 <td class='forumheader3'><span style='text-decoration:underline'>".LAN_413."</span></td> 233 <td class='forumheader3'><textarea class='tbox' style='width:90%' name='file_description' id='file_description' cols='59' rows='6'></textarea></td> 234 </tr> 235 236 <tr> 237 <td class='forumheader3'>".LAN_144."</td> 238 <td class='forumheader3'><input class='tbox' style='width:90%' name='file_website' type='text' size='50' maxlength='100' value='".(defined(USERURL) ? USERURL : "")."' /></td> 239 </tr> 240 241 <tr> 242 <td class='forumheader3'>".LAN_414."<br /><span class='smalltext'>".LAN_415."</span></td> 243 <td class='forumheader3'><input class='tbox' style='width:90%' name='file_demo' type='text' size='50' maxlength='100' /></td> 244 </tr> 245 246 <tr> 247 <td style='text-align:center' colspan='2' class='forumheader'><input class='button' type='submit' name='upload' value='".LAN_416."' /></td> 248 </tr> 249 </table> 250 </form> 251 </div>"; 252 253 $ns->tablerender(LAN_417, $text); 254 255 require_once(FOOTERF); 256 257 258 function headerjs() 259 { 260 $script = "<script type=\"text/javascript\"> 261 function frmVerify() 262 { 263 var message = ''; 264 var spacer = ''; 265 var testObjects = new Array(\"download_category\", \"user_email\", \"file_name\", \"file_realpath\", \"file_description\"); 266 var errorMessages = new Array('".LAN_UL_032."', '".LAN_UL_033."', '".LAN_UL_034."', '".LAN_UL_036."', '".LAN_UL_035."'); 267 var temp; 268 var i; 269 for (i = 0; i < 5; i++) 270 { 271 temp = document.getElementById(testObjects[i]); 272 if (temp && (temp.value == \"\")) 273 { 274 message = message + spacer + errorMessages[i]; 275 spacer = '\\n'; 276 } 277 } 278 if (message) 279 { 280 alert(message); 281 return false; 282 } 283 } 284 </script>"; 285 return $script; 286 } 287 288 289 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Aug 3 00:19:13 2010 |