$submitnews_error = TRUE; } // ==== Process File Upload ==== if (FILE_UPLOADS && $_FILES['file_userfile'] && vartrue($pref['subnews_attach']) && vartrue($pref['upload_enabled']) && check_class($pref['upload_class'])) { require_once e_HANDLER . 'upload_handler.php'; $uploaded = process_uploaded_files(e_UPLOAD, FALSE, array('file_mask' => 'jpg,gif,png', 'max_file_count' => 1)); if ($uploaded === FALSE || !is_array($uploaded)) { // Non-specific error $submitnews_error = TRUE; $message = SUBNEWSLAN_8; } else { $submitnews_filearray = array(); foreach ($uploaded as $c => $v) { if (varset($uploaded[$c]['error'], 0) != 0) { $submitnews_error = TRUE; $message = handle_upload_messages($uploaded); } else { if (isset($uploaded[$c]['name']) && isset($uploaded[$c]['type']) && isset($uploaded[$c]['size'])) { $filename = $uploaded[$c]['name']; $filetype = $uploaded[$c]['type']; $filesize = $uploaded[$c]['size']; $fileext = substr(strrchr($filename, "."), 1); $today = getdate(); $submitnews_file = USERID . "_" . $today[0] . "_" . $c . "_" . str_replace(" ", "_", substr($submitnews_title, 0, 6)) . "." . $fileext; 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);
function file_upload($uploaddir, $avatar = FALSE, $fileinfo = "", $overwrite = "") { $admin_log = e107::getAdminLog(); $options = array('extra_file_types' => TRUE); // As default, allow any filetype enabled in filetypes.php if (!$uploaddir) { $uploaddir = e_UPLOAD; } if (strpos($avatar, '=') !== FALSE) { list($avatar, $param) = explode('=', $avatar, 2); } else { $param = USERID; } switch ($avatar) { case 'attachment': $avatar = "attachment+" . $fileinfo; break; case 'avatar': $avatar = 'prefix+ap_' . $param . '_'; // Prefix unique to user $options['overwrite'] = TRUE; // Allow update of avatar with same file name break; } if (UH_DEBUG) { $admin_log->e_log_event(10, __FILE__ . "|" . __FUNCTION__ . "@" . __LINE__, "DEBUG", "Upload Handler test", "Legacy call, directory " . $uploaddir, FALSE, FALSE); } $ret = process_uploaded_files(getcwd() . "/" . $uploaddir, $avatar, $options); // Well, that's the way it was done before if ($ret === FALSE) { if (UH_DEBUG) { $admin_log->e_log_event(10, __FILE__ . "|" . __FUNCTION__ . "@" . __LINE__, "DEBUG", "Upload Handler test", "Legacy return FALSE", FALSE, FALSE); } return FALSE; } if (UH_DEBUG) { $admin_log->e_log_event(10, __FILE__ . "|" . __FUNCTION__ . "@" . __LINE__, "DEBUG", "Upload Handler test", "Legacy return with " . count($ret) . " files", FALSE, FALSE); } $messages = handle_upload_messages($ret, FALSE, TRUE); // Show all the error and acknowledgment messages define(F_MESSAGE, $messages); if (count($ret) == 1) { if ($ret[0]['error'] != 0) { return FALSE; } // Special case if errors } return $ret; }