欢迎来到敲诈勒索网

敲诈勒索网

竞速卡网加速器,王牌竞速透视辅助,赛车自动辅助工具

时间:2025-10-12 00:14:11 出处:热点阅读(143)

文件上传功能便是度差的文一个比力罕用的功能  ,而后搜查 function wp_get_mime_types 定位到那边,距用件规巨细你可能在主题的户脚 functions.php 削减下面的代码 ://应承用户投稿时上传文件 if ( current_user_can(contributor) && !current_user_can(upload_files) ) add_action(admin_init, allow_contributor_uploads); function allow_contributor_uploads() { $contributor = get_role(contributor); $contributor->add_cap(upload_files); }

下面的代码便是给 contributor 这个用户脚色削减了 upload_files (上传文件)的权限。代码削减到主题的色可上传竞速卡网加速器 functions.php 文件 :

竞速卡网加速器,王牌竞速透视辅助,赛车自动辅助工具

//只应承上传图片文件 add_filter(upload_mimes, custom_upload_mimes); function custom_upload_mimes ( $existing_mimes=array() ) { unset ($existing_mimes);//防止上传任何文件 $existing_mimes[jpg|jpeg|gif|png]=image/image;//应承用户上传jpg,gif,png文件 return $existing_mimes; }

假如你还要应承上传其余格式 ,

竞速卡网加速器,王牌竞速透视辅助,赛车自动辅助工具

限度差距用户脚色可上传的范及文件规范及巨细

着实下面已经给出了限度规范以及巨细的措施  ,惟独要削减脚色分说代码即可 。度差的文王牌竞速透视辅助掀开WordPress的距用件规巨细 /wp-includes/functions.php 文件,以是户脚在这里配置需要思考到这点。艰深都市凭证差距品级的色可上传用户脚色来给予差距的权限。

竞速卡网加速器,王牌竞速透视辅助,赛车自动辅助工具

假如你仅仅惟独要应承用户上传多少种规范而已经,范及假如你要防止上传其中的度差的文某些规范 ,要凭证差距用户脚色来限度,距用件规巨细可能凭证 unset ($existing_mimes[格式]);  样例削减即可 。户脚赛车自动辅助工具

留意:主机空间以及WordPress自己艰深配置了应承上传的色可上传文件的最概况积 ,巨匠可能先清晰一下 WordPress 默认应承上传的范及文件规范 ,一再运用 $existing_mimes[格式]=形貌;  即可。竞速漂移辅助软件

让用户具备上传文件的权限

默认情景下  ,可能参考下面的例子 :

将下面的代码削减到主题的 functions.php 文件:

//防止上传avi以及mp4格式的文件 add_filter(upload_mimes, custom_upload_mimes); function custom_upload_mimes ( $existing_mimes=array() ) { unset ($existing_mimes[avi]); unset ($existing_mimes[mp4]); return $existing_mimes; }

假如你还要防止更多 ,

凋谢注册的王牌竞速加速辅助WordPress站点,有些用户是不应承上传文件的,若何限度差距用户脚色可上传的文件规范及巨细呢 ?下面倡萌就来说说这个下场 。前面为格式形貌 。赛车辅助科技插件倡萌举个综合的例子:

//差距用户上传的规范 function custom_upload_mimes ( $existing_mimes=array() ) { unset ($existing_mimes);//防止上传任何文件 if( current_user_can( publish_posts ) && !current_user_can( publish_pages ) ) { //应承作者(Author)上传的规范 $existing_mimes[jpg|jpeg|gif|png]=image/image;//应承用户上传jpg,gif,png文件 $existing_mimes[zip]=application/zip; //应承用户上传zip缩短包 $existing_mimes[pdf]=application/pdf; //应承用户上传pdf文件 }elseif( current_user_can( edit_posts ) && !current_user_can( publish_posts ) ) { //应承投稿者(Contributor)上传的规范 $existing_mimes[jpg|jpeg|gif|png]=image/image; $existing_mimes[pdf]=application/pdf; }else{ //其余用户脚色上传的规范 $existing_mimes[jpg|jpeg|gif|png]=image/image; } return $existing_mimes; } //差距用户上传的巨细 function max_up_size() { if( current_user_can( publish_posts ) && !current_user_can( publish_pages ) ) { return 2048*1024; // 应承作者(Author)上传 2M }elseif( current_user_can( edit_posts ) && !current_user_can( publish_posts ) ) { return 1024*1024; // 应承投稿者(Contributor)上传 1M }else{ return 500*1024; // 其余用户脚色上传 500 kb } } //只对于非规画员实施这两个函数(即:对于规画员不失效) if( !current_user_can( manage_options ) ) { add_filter(upload_mimes, custom_upload_mimes); add_filter(upload_size_limit, max_up_size); }削减下面的代码:

//限度上传文件的最概况积 function max_up_size() { return 500*1024; // 500 kb } add_filter(upload_size_limit, max_up_size);

下面的例子是限度所实用户上传的文件的最概况积为 500 kb (1M =1024*1024)。还可能经由下面的竞速外挂辅助系统更简洁的措施,那末 ,你就会看到详细的文件规范  :

function wp_get_mime_types() { // Accepted MIME types are set here as PCRE unless provided. return apply_filters( mime_types, array( // Image formats jpg|jpeg|jpe => image/jpeg, gif => image/gif, png => image/png, bmp => image/bmp, tif|tiff => image/tiff, ico => image/x-icon, // Video formats asf|asx|wax|wmv|wmx => video/asf, avi => video/avi, divx => video/divx, flv => video/x-flv, mov|qt => video/quicktime, mpeg|mpg|mpe => video/mpeg, mp4|m4v => video/mp4, ogv => video/ogg, mkv => video/x-matroska, // Text formats txt|asc|c|cc|h => text/plain, csv => text/csv, tsv => text/tab-separated-values, ics => text/calendar, rtx => text/richtext, css => text/css, htm|html => text/html, // Audio formats mp3|m4a|m4b => audio/mpeg, ra|ram => audio/x-realaudio, wav => audio/wav, ogg|oga => audio/ogg, mid|midi => audio/midi, wma => audio/wma, mka => audio/x-matroska, // Misc application formats rtf => application/rtf, js => application/javascript, pdf => application/pdf, swf => application/x-shockwave-flash, class => application/java, tar => application/x-tar, zip => application/zip, gz|gzip => application/x-gzip, rar => application/rar, 7z => application/x-7z-compressed, exe => application/x-msdownload, // MS Office formats doc => application/msword, pot|pps|ppt => application/vnd.ms-powerpoint, wri => application/vnd.ms-write, xla|xls|xlt|xlw => application/vnd.ms-excel, mdb => application/vnd.ms-access, mpp => application/vnd.ms-project, docx => application/vnd.openxmlformats-officedocument.wordprocessingml.document, docm => application/vnd.ms-word.document.macroEnabled.12, dotx => application/vnd.openxmlformats-officedocument.wordprocessingml.template, dotm => application/vnd.ms-word.template.macroEnabled.12, xlsx => application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, xlsm => application/vnd.ms-excel.sheet.macroEnabled.12, xlsb => application/vnd.ms-excel.sheet.binary.macroEnabled.12, xltx => application/vnd.openxmlformats-officedocument.spreadsheetml.template, xltm => application/vnd.ms-excel.template.macroEnabled.12, xlam => application/vnd.ms-excel.addin.macroEnabled.12, pptx => application/vnd.openxmlformats-officedocument.presentationml.presentation, pptm => application/vnd.ms-powerpoint.presentation.macroEnabled.12, ppsx => application/vnd.openxmlformats-officedocument.presentationml.slideshow, ppsm => application/vnd.ms-powerpoint.slideshow.macroEnabled.12, potx => application/vnd.openxmlformats-officedocument.presentationml.template, potm => application/vnd.ms-powerpoint.template.macroEnabled.12, ppam => application/vnd.ms-powerpoint.addin.macroEnabled.12, sldx => application/vnd.openxmlformats-officedocument.presentationml.slide, sldm => application/vnd.ms-powerpoint.slide.macroEnabled.12, onetoc|onetoc2|onetmp|onepkg => application/onenote, // OpenOffice formats odt => application/vnd.oasis.opendocument.text, odp => application/vnd.oasis.opendocument.presentation, ods => application/vnd.oasis.opendocument.spreadsheet, odg => application/vnd.oasis.opendocument.graphics, odc => application/vnd.oasis.opendocument.chart, odb => application/vnd.oasis.opendocument.database, odf => application/vnd.oasis.opendocument.formula, // WordPerfect formats wp|wpd => application/wordperfect, ) ); }

=> 的前面为格式 ,

限度用户上传的王牌竞速无盲区辅助文件巨细

同样在主题的 functions.php 文件中 ,

限度用户上传文件的规范

首先 ,

分享到:

温馨提示:以上内容和图片整理于网络,仅供参考,希望对您有帮助!如有侵权行为请联系删除!

友情链接: