Ignore:
Timestamp:
Dec 31, 2012, 2:04:43 AM (12 years ago)
Author:
julien1311
Message:

bug fix for non supported files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/File_Uploader/admin/admin_upload.php

    r19621 r19681  
    1919       
    2020        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']);
    2222                if(count($file_uploader_upload_thumbnail['errors']) != 0)
    2323                        $file_uploader_errors['thumbnail'] = $file_uploader_upload_thumbnail['errors'];
     
    4747        $file_uploader_file_extension = strtolower(substr(strrchr($file_uploader_file['name'], '.'),1));
    4848        $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;
    5157        $file_uploader_errors = array();
    5258        $return = array();
     
    5460        $return['name_wo_extension'] = $file_uploader_file_name_wo_extension;
    5561        $return['extension'] = $file_uploader_file_extension;
    56         $return['folder'] = $file_uploader_destination_folder[$file_uploader_file_extension];
     62        $return['folder'] = $file_uploader_file_category;
    5763        $return['destination'] = $file_uploader_file_destination;
    5864        $return['size'] = $file_uploader_file_size;
     
    6066       
    6167        //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;
    6571        //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){
    6773                $next_id = pwg_db_nextval('id', CATEGORIES_TABLE);
    6874                $category_rank = pwg_db_fetch_assoc(pwg_query('SELECT MAX(rank) FROM '.CATEGORIES_TABLE.';'));
    6975                $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.');');
    7177        }
    7278       
     
    9399                        default:
    94100                                $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                }
    98102        } else if (file_exists($file_uploader_file_destination)) {
    99103                if ($conf_file_uploader['overwrite'] == 1)
     
    111115
    112116
    113 function file_uploader_upload_thumbnail($file_uploader_thumbnail, $file_uploader_file_name_wo_extension, $file_uploader_file_extension) {
     117function file_uploader_upload_thumbnail($file_uploader_thumbnail, $file_uploader_file_name_wo_extension, $file_uploader_file_extension, $file_uploader_file_folder) {
    114118        include('static.inc.php');
    115119       
     
    117121        $file_uploader_thumbnail_extension = strtolower(substr(strrchr($file_uploader_thumbnail['name'], '.'),1));
    118122        $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';
    120124        $file_uploader_thumbnail_destination = $file_uploader_thumbnail_directory.'/'.$file_uploader_file_name_wo_extension.'.'.$file_uploader_thumbnail_extension;
    121125        $file_uploader_errors = array();
Note: See TracChangeset for help on using the changeset viewer.