WordPress.org

Make WordPress Core

Ticket #2596: fileupload_maxk.patch

File fileupload_maxk.patch, 5.7 KB (added by 433, 7 years ago)

Changed: 1) store value in database and print value on form in KB, not bytes AND 2) ensure fileupload_maxk is an integer

  • admin-functions.php

     
    18531853        // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error']. 
    18541854        $upload_error_strings = array( false, 
    18551855                __( "The uploaded file exceeds the <code>upload_max_filesize</code> directive in <code>php.ini</code>." ), 
    1856                 __( "The uploaded file exceeds the <em>MAX_FILE_SIZE</em> directive that was specified in the HTML form." ), 
     1856                __("The uploaded file exceeds the <em>MAX_FILE_SIZE</em> value, which can be modified in the Options/Miscellaneous tab."), 
    18571857                __( "The uploaded file was only partially uploaded." ), 
    18581858                __( "No file was uploaded." ), 
    18591859                __( "Missing a temporary folder." ), 
  • options-misc.php

     
    1616<fieldset class="options"> 
    1717<legend><?php _e('Uploading'); ?></legend> 
    1818<table class="editform optiontable"> 
    19 <tr valign="top"> 
     19<tr valign="top"> 
    2020<th scope="row"><?php _e('Store uploads in this folder'); ?>:</th> 
    2121<td><input name="upload_path" type="text" id="upload_path" class="code" value="<?php echo wp_specialchars(str_replace(ABSPATH, '', get_option('upload_path')), 1); ?>" size="40" /> 
    2222<br /> 
     
    3232</label> 
    3333</td> 
    3434</tr> 
     35<tr valign="top"> 
     36<th scope="row"><?php _e('Max uploaded file size (in KB)'); ?>:</th> 
     37<td><input name="fileupload_maxk" type="text" id="fileupload_maxk" class="code" value="<?php echo wp_specialchars(str_replace(ABSPATH, '', get_settings('fileupload_maxk')), 1); ?>" size="20" /> 
     38</td> 
     39</tr> 
    3540</table> 
    3641</fieldset> 
    3742 
     
    4348 
    4449<p class="submit"> 
    4550<input type="hidden" name="action" value="update" /> 
    46 <input type="hidden" name="page_options" value="hack_file,use_linksupdate,uploads_use_yearmonth_folders,upload_path" /> 
     51<input type="hidden" name="page_options" value="hack_file,use_linksupdate,uploads_use_yearmonth_folders,upload_path,fileupload_maxk" />  
    4752<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" /> 
    4853</p> 
    4954</form> 
  • options.php

     
    7373                        $value = stripslashes($value); 
    7474                        $value = clean_url($value); 
    7575                        break; 
     76                case 'fileupload_maxk':                  
     77                        // ensure $value is an integer 
     78                        if(!ereg("^[0-9]+$",$value)) { 
     79                                $value = get_settings('fileupload_maxk'); 
     80                        } 
    7681                default : 
    7782                        $value = stripslashes($value); 
    7883                        break; 
  • upgrade-schema.php

     
    221221        } else { 
    222222                add_option('uploads_use_yearmonth_folders', 1); 
    223223                add_option('upload_path', 'wp-content/uploads'); 
    224         } 
     224        }        
    225225 
    226226        // 2.0.3 
    227227        add_option('secret', md5(uniqid(microtime()))); 
     
    230230        add_option('blog_public', '1'); 
    231231        add_option('default_link_category', 2); 
    232232        add_option('show_on_front', 'posts'); 
     233         
     234        // 10MB max by default 
     235        add_option('fileupload_maxk','10240'); 
    233236 
    234237        // Delete unused options 
    235238        $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing'); 
  • upload-functions.php

     
    134134<?php   else : ?> 
    135135                        <tr> 
    136136                                <th scope="row"><label for="upload"><?php _e('File'); ?></label></th> 
     137                                <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo wp_specialchars(str_replace(ABSPATH, '', get_settings('fileupload_maxk')), 1) * 1024; ?>" /> 
    137138                                <td><input type="file" id="upload" name="image" /></td> 
    138139                        </tr> 
    139140<?php   endif; ?> 
     
    151152                                        <input type="submit" name="delete" id="delete" class="delete alignleft" value="<?php _e('Delete File'); ?>" /> 
    152153<?php   endif; ?> 
    153154                                        <input type="hidden" name="from_tab" value="<?php echo $tab; ?>" /> 
    154                                         <input type="hidden" name="action" value="<?php echo $id ? 'save' : 'upload'; ?>" /> 
     155                                        <input type="hidden" name="action" value="<?php echo $id ? 'save' : 'upload'; ?>" />                                     
    155156<?php   if ( $post_id ) : ?> 
    156157                                        <input type="hidden" name="post_id" value="<?php echo $post_id; ?>" /> 
    157158<?php   endif; if ( $id ) : ?> 
    158159                                        <input type="hidden" name="ID" value="<?php echo $id; ?>" /> 
    159160<?php   endif; ?> 
    160161                                        <?php wp_nonce_field( 'inlineuploading' ); ?> 
    161                                         <div class="submit"> 
     162                                        <div class="submit">                                             
    162163                                                <input type="submit" value="<?php $id ? _e('Save') : _e('Upload'); ?> &raquo;" /> 
    163164                                        </div> 
    164165                                </td>