Ignore:
Timestamp:
Jan 4, 2013, 12:31:23 AM (11 years ago)
Author:
julien1311
Message:

some bug fixes/improvements
still buggy

File:
1 edited

Legend:

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

    r19735 r19775  
    3737
    3838function file_uploader_upload_file($file_uploader_file) {
    39         include('static.inc.php');
     39        include_once(dirname(__FILE__).'/install/config_default.inc.php');
    4040       
    4141        global $conf;
     
    6969                if(!mkdir($file_uploader_file_directory_full))
    7070                        $file_uploader_errors['upload_error'] = l10n('Unable to create folder ').$file_uploader_file_directory_full;
    71         //If the physical category si not in database, we add it
    72         if (pwg_db_num_rows(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE name = "'.$file_uploader_file_category.'";')) == 0){
    73                 $next_id = pwg_db_nextval('id', CATEGORIES_TABLE);
    74                 $category_rank = pwg_db_fetch_assoc(pwg_query('SELECT MAX(rank) FROM '.CATEGORIES_TABLE.';'));
    75                 $category_rank = $category_rank['MAX(rank)'] + 1;
    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.');');
    77         }
     71                //If the physical category si not in database, we add it
     72                else if (pwg_db_num_rows(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE name = "'.$file_uploader_file_category.'";')) == 0){
     73                        $next_id = pwg_db_nextval('id', CATEGORIES_TABLE);
     74                        $category_rank = pwg_db_fetch_assoc(pwg_query('SELECT MAX(rank) FROM '.CATEGORIES_TABLE.';'));
     75                        $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);');
     78                }
    7879       
    7980        if ($file_uploader_file['error'] !== UPLOAD_ERR_OK) {
     
    116117
    117118function file_uploader_upload_thumbnail($file_uploader_thumbnail, $file_uploader_file_name_wo_extension, $file_uploader_file_extension, $file_uploader_file_folder) {
    118         include('static.inc.php');
     119        include_once(dirname(__FILE__).'/install/config_default.inc.php');
    119120       
    120121        $file_uploader_thumbnail_tmp = $file_uploader_thumbnail['tmp_name'];
     
    175176        //Database registration
    176177        $file_path = pwg_db_real_escape_string($file_uploader_file['destination']);
     178        $physical_category_id = pwg_db_fetch_assoc(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE name = "'.$file_uploader_file['folder'].'";'));
    177179        $insert = array(
    178180                'file' => substr(strrchr($file_path, '/'), 1),
     
    183185                'representative_ext' => $file_uploader_thumbnail['extension'],
    184186                'filesize' => $file_uploader_file['size'],
     187                'storage_category_id' => $physical_category_id,
    185188                'md5sum' => md5_file($file_path),
    186189                'added_by' => $user['id'],
     
    195198                $image_id = pwg_db_insert_id(IMAGES_TABLE);
    196199        }
    197 
    198         $physical_category_id = pwg_db_fetch_assoc(pwg_query('SELECT id FROM '.CATEGORIES_TABLE.' WHERE name = "'.$file_uploader_file['folder'].'";'));
    199200       
    200201        if(isset($file_uploader_file_properties['category']) and count($file_uploader_file_properties['category']) > 0) {
Note: See TracChangeset for help on using the changeset viewer.