Changeset 19681 for extensions/File_Uploader/admin/admin_upload.php
- Timestamp:
- Dec 31, 2012, 2:04:43 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/File_Uploader/admin/admin_upload.php
r19621 r19681 19 19 20 20 if($_FILES['file_uploader_thumbnail']['size'] != 0 && $_FILES['file_uploader_file']['size'] != 0) { 21 $file_uploader_upload_thumbnail = file_uploader_upload_thumbnail($_FILES['file_uploader_thumbnail'], $file_uploader_upload_file['name_wo_extension'], $file_uploader_upload_file['extension'] );21 $file_uploader_upload_thumbnail = file_uploader_upload_thumbnail($_FILES['file_uploader_thumbnail'], $file_uploader_upload_file['name_wo_extension'], $file_uploader_upload_file['extension'], $file_uploader_upload_file['folder']); 22 22 if(count($file_uploader_upload_thumbnail['errors']) != 0) 23 23 $file_uploader_errors['thumbnail'] = $file_uploader_upload_thumbnail['errors']; … … 47 47 $file_uploader_file_extension = strtolower(substr(strrchr($file_uploader_file['name'], '.'),1)); 48 48 $file_uploader_file_size = filesize($file_uploader_file['tmp_name']); 49 $file_uploader_file_directory = $file_uploader_galleries_dir.$file_uploader_destination_folder[$file_uploader_file_extension]; 50 $file_uploader_file_destination = $file_uploader_file_directory.'/'.$file_uploader_file_name; 49 if (isset($file_uploader_destination_folder[$file_uploader_file_extension])) { 50 $file_uploader_file_category = $file_uploader_destination_folder[$file_uploader_file_extension]; 51 $file_uploader_file_directory_full = $file_uploader_galleries_dir.$file_uploader_file_category; 52 } else { 53 $file_uploader_file_category = $file_uploader_destination_folder['others']; 54 $file_uploader_file_directory_full = $file_uploader_galleries_dir.$file_uploader_file_category; 55 } 56 $file_uploader_file_destination = $file_uploader_file_directory_full.'/'.$file_uploader_file_name; 51 57 $file_uploader_errors = array(); 52 58 $return = array(); … … 54 60 $return['name_wo_extension'] = $file_uploader_file_name_wo_extension; 55 61 $return['extension'] = $file_uploader_file_extension; 56 $return['folder'] = $file_uploader_ destination_folder[$file_uploader_file_extension];62 $return['folder'] = $file_uploader_file_category; 57 63 $return['destination'] = $file_uploader_file_destination; 58 64 $return['size'] = $file_uploader_file_size; … … 60 66 61 67 //If the directory does not exist, we create it 62 if (!file_exists($file_uploader_file_directory ))63 if(!mkdir($file_uploader_file_directory ))64 $file_uploader_errors['upload_error'] = l10n('Unable to create folder ').$file_uploader_file_directory ;68 if (!file_exists($file_uploader_file_directory_full)) 69 if(!mkdir($file_uploader_file_directory_full)) 70 $file_uploader_errors['upload_error'] = l10n('Unable to create folder ').$file_uploader_file_directory_full; 65 71 //If the physical category si not in database, we add it 66 if (pwg_db_num_rows(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE name = "'.$file_uploader_ destination_folder[$file_uploader_file_extension].'";')) == 0){72 if (pwg_db_num_rows(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE name = "'.$file_uploader_file_category.'";')) == 0){ 67 73 $next_id = pwg_db_nextval('id', CATEGORIES_TABLE); 68 74 $category_rank = pwg_db_fetch_assoc(pwg_query('SELECT MAX(rank) FROM '.CATEGORIES_TABLE.';')); 69 75 $category_rank = $category_rank['MAX(rank)'] + 1; 70 pwg_query('INSERT INTO '.CATEGORIES_TABLE.' (id, name, dir, rank, status, visible, uppercats, global_rank) VALUES ('.$next_id.', "'.$file_uploader_ destination_folder[$file_uploader_file_extension].'", "'.$file_uploader_destination_folder[$file_uploader_file_extension].'", '.$category_rank.', "'.$conf['newcat_default_status'].'", "'.boolean_to_string($conf['newcat_default_visible']).'", "'.$next_id.'", '.$category_rank.');');76 pwg_query('INSERT INTO '.CATEGORIES_TABLE.' (id, name, dir, rank, status, visible, uppercats, global_rank) VALUES ('.$next_id.', "'.$file_uploader_file_category.'", "'.$file_uploader_file_category.'", '.$category_rank.', "'.$conf['newcat_default_status'].'", "'.boolean_to_string($conf['newcat_default_visible']).'", "'.$next_id.'", '.$category_rank.');'); 71 77 } 72 78 … … 93 99 default: 94 100 $file_uploader_errors['upload_error'] = l10n('Upload error'); 95 } 96 } else if(!in_array($file_uploader_file_extension, $file_uploader_allowed_file_extension)) { 97 $file_uploader_errors['filetype'] = l10n('Type of file not supported'); 101 } 98 102 } else if (file_exists($file_uploader_file_destination)) { 99 103 if ($conf_file_uploader['overwrite'] == 1) … … 111 115 112 116 113 function file_uploader_upload_thumbnail($file_uploader_thumbnail, $file_uploader_file_name_wo_extension, $file_uploader_file_extension ) {117 function file_uploader_upload_thumbnail($file_uploader_thumbnail, $file_uploader_file_name_wo_extension, $file_uploader_file_extension, $file_uploader_file_folder) { 114 118 include('static.inc.php'); 115 119 … … 117 121 $file_uploader_thumbnail_extension = strtolower(substr(strrchr($file_uploader_thumbnail['name'], '.'),1)); 118 122 $file_uploader_thumbnail_size = filesize($file_uploader_thumbnail['tmp_name']); 119 $file_uploader_thumbnail_directory = $file_uploader_galleries_dir.$file_uploader_ destination_folder[$file_uploader_file_extension].'/pwg_representative';123 $file_uploader_thumbnail_directory = $file_uploader_galleries_dir.$file_uploader_file_folder.'/pwg_representative'; 120 124 $file_uploader_thumbnail_destination = $file_uploader_thumbnail_directory.'/'.$file_uploader_file_name_wo_extension.'.'.$file_uploader_thumbnail_extension; 121 125 $file_uploader_errors = array();
Note: See TracChangeset
for help on using the changeset viewer.