Changeset 19875 for extensions/File_Uploader/admin
- Timestamp:
- Jan 6, 2013, 1:53:17 AM (12 years ago)
- Location:
- extensions/File_Uploader/admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/File_Uploader/admin/admin_upload.php
r19835 r19875 3 3 4 4 include_once(PHPWG_ROOT_PATH . 'include/functions.inc.php'); 5 include_once(PHPWG_ROOT_PATH . 'admin/include/functions_upload.inc.php'); 5 6 6 7 global $template, $conf, $user, $page; … … 15 16 $file_uploader_errors['file'] = $file_uploader_upload_file['errors']; 16 17 } else { 17 $file_uploader_errors['file']['no_file'] = 'Specify a file to upload';18 $file_uploader_errors['file']['no_file'] = l10n('Specify a file to upload'); 18 19 } 19 20 … … 37 38 38 39 function file_uploader_upload_file($file_uploader_file) { 39 include_once(dirname(__FILE__).'/install/config_default.inc.php'); 40 require(FILE_UPLOADER_PATH.'install/config_default.inc.php'); 41 require_once(FILE_UPLOADER_PATH.'install/functions.inc.php'); 40 42 41 43 global $conf; … … 43 45 44 46 $file_uploader_file_tmp = $file_uploader_file['tmp_name']; 47 $file_uploader_file_title = substr($file_uploader_file['name'], 0, strrpos($file_uploader_file['name'], '.')); 45 48 $file_uploader_file_name = preg_replace('/[^a-zA-Z0-9s.]/', '_', $file_uploader_file['name']); 46 49 $file_uploader_file_name_wo_extension = substr($file_uploader_file_name, 0, strrpos($file_uploader_file_name, '.')); … … 58 61 $return = array(); 59 62 63 $return['title'] = $file_uploader_file_title; 60 64 $return['name_wo_extension'] = $file_uploader_file_name_wo_extension; 61 65 $return['extension'] = $file_uploader_file_extension; … … 64 68 $return['size'] = $file_uploader_file_size; 65 69 $return['overwrite'] = false; 70 71 //Check if the folder file_uploader exists 72 file_uploader_folder($file_uploader_galleries_folder, $file_uploader_galleries_dir, $file_uploader_galleries_folder_name); 66 73 67 74 //If the directory does not exist, we create it … … 74 81 $category_rank = pwg_db_fetch_assoc(pwg_query('SELECT MAX(rank) FROM '.CATEGORIES_TABLE.';')); 75 82 $category_rank = $category_rank['MAX(rank)'] + 1; 76 $file_uploader_physical_category_id = pwg_db_fetch_assoc(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE name = "'.$file_uploader_galleries_folder.'";')); 77 pwg_query('INSERT INTO '.CATEGORIES_TABLE.' (id, name, dir, rank, status, visible, uppercats, global_rank, site_id) VALUES ('.$next_id.', "'.$file_uploader_file_category.'", "'.$file_uploader_file_category.'", '.$category_rank.', "private", "'.boolean_to_string($conf['newcat_default_visible']).'", "'.$file_uploader_physical_category_id.'", '.$category_rank.', 1);'); 83 $file_uploader_physical_category = pwg_db_fetch_assoc(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE dir = "'.$file_uploader_galleries_folder.'";')); 84 $insert = array( 85 'id' => $next_id, 86 'name' => $file_uploader_file_category, 87 'id_uppercat' => $file_uploader_physical_category['id'], 88 'comment' => 'Created by the File Uploader plugin', 89 'dir' => $file_uploader_file_category, 90 'rank' => $category_rank, 91 'status' => 'private', 92 'visible' => boolean_to_string($conf['newcat_default_visible']), 93 'uppercats' => $next_id.','.$file_uploader_physical_category['id'], 94 'global_rank' => $category_rank, 95 'site_id' => '1', 96 ); 97 single_insert(CATEGORIES_TABLE, $insert); 78 98 } 79 99 … … 117 137 118 138 function file_uploader_upload_thumbnail($file_uploader_thumbnail, $file_uploader_file_name_wo_extension, $file_uploader_file_extension, $file_uploader_file_folder) { 119 include_once(dirname(__FILE__).'/install/config_default.inc.php');139 require(FILE_UPLOADER_PATH.'install/config_default.inc.php'); 120 140 121 141 $file_uploader_thumbnail_tmp = $file_uploader_thumbnail['tmp_name']; … … 179 199 $insert = array( 180 200 'file' => substr(strrchr($file_path, '/'), 1), 181 'name' => pwg_db_real_escape_string($file_uploader_file_properties['title']),201 'name' => ($file_uploader_file_properties['title'] != '') ? pwg_db_real_escape_string($file_uploader_file_properties['title']) : $file_uploader_file['title'], 182 202 'comment' => pwg_db_real_escape_string($file_uploader_file_properties['description']), 183 203 'date_available' => $dbnow, … … 199 219 } 200 220 221 if (!is_array($image_id)) 222 $image_id = array($image_id); 223 201 224 if(isset($file_uploader_file_properties['category']) and count($file_uploader_file_properties['category']) > 0) { 202 225 associate_images_to_categories( 203 array($image_id),226 $image_id, 204 227 array($file_uploader_file_properties['category'], $physical_category_id['id']) 205 228 ); 206 229 } 207 230 208 @fill_caddie( array($image_id));231 @fill_caddie($image_id); 209 232 } 210 233 … … 214 237 display_select_cat_wrapper($query, array(), 'category_parent_options'); 215 238 239 //Add parameters to template 240 $upload_max_filesize = min(get_ini_size('upload_max_filesize'), get_ini_size('post_max_size')); 241 if ($upload_max_filesize == get_ini_size('upload_max_filesize')) { 242 $upload_max_filesize = get_ini_size('upload_max_filesize', true); 243 } else { 244 $upload_max_filesize = get_ini_size('post_max_filesize', true); 245 } 246 $upload_max_filesize_display = round($upload_max_filesize/1024, 0, PHP_ROUND_HALF_DOWN); 247 248 $template->assign( 249 array( 250 'upload_max_filesize' => $upload_max_filesize, 251 'upload_max_filesize_display' => $upload_max_filesize_display, 252 ) 253 ); 254 216 255 $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin_upload.tpl')); 217 256 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); -
extensions/File_Uploader/admin/admin_upload.tpl
r19775 r19875 15 15 <input name="file_uploader_file" type="file" value=""{if isset($file_uploader_errors.file)} class="file_uploader_error"{/if}> 16 16 {foreach from=$file_uploader_errors.file item=error_description}<span class="file_uploader_error_description" title="{$error_description}">!</span>{/foreach} 17 <input type="hidden" name="MAX_FILE_SIZE" value="{$upload_max_filesize}"> 18 </p> 19 <p class="file_uploader_center"> 20 {'file_uploader_upload_max_filesize'|@translate} {$upload_max_filesize_display} Kio. 17 21 </p> 18 22 </fieldset>
Note: See TracChangeset
for help on using the changeset viewer.