当前位置: 首页>>代码示例>>PHP>>正文


PHP UploadBase::verifyExtension方法代码示例

本文整理汇总了PHP中UploadBase::verifyExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadBase::verifyExtension方法的具体用法?PHP UploadBase::verifyExtension怎么用?PHP UploadBase::verifyExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UploadBase的用法示例。


在下文中一共展示了UploadBase::verifyExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: verifyAttachment

 /**
  * Verifies that it's ok to include the uploaded file
  *
  * @param string $tmpfile the full path of the temporary file to verify
  * @param string $extension The filename extension that the file is to be served with
  * @return Status object
  */
 public static function verifyAttachment($tmpfile, $extension)
 {
     global $wgVerifyMimeType, $wgMimeTypeBlacklist;
     $magic =& MimeMagic::singleton();
     // magically determine mime type
     $mime = $magic->guessMimeType($tmpfile, false);
     # check mime type, if desired
     if ($wgVerifyMimeType) {
         wfDebug("\n\nmime: <{$mime}> extension: <{$extension}>\n\n");
         # Check mime type against file extension
         if (!UploadBase::verifyExtension($mime, $extension)) {
             return Status::newFatal('uploadcorrupt');
         }
         # Check mime type blacklist
         if (isset($wgMimeTypeBlacklist) && !is_null($wgMimeTypeBlacklist) && self::checkFileExtension($mime, $wgMimeTypeBlacklist)) {
             return Status::newFatal('filetype-badmime', $mime);
         }
     }
     wfDebug(__METHOD__ . ": all clear; passing.\n");
     return Status::newGood();
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:28,代码来源:ConfirmAccount.class.php

示例2: verify

 /**
  * Verifies that it's ok to include the uploaded file
  *
  * @param string $tmpfile the full path opf the temporary file to verify
  * @param string $extension The filename extension that the file is to be served with
  * @return Status object
  */
 function verify($tmpfile, $extension)
 {
     # magically determine mime type
     $magic = MimeMagic::singleton();
     $mime = $magic->guessMimeType($tmpfile, false);
     # check mime type, if desired
     global $wgVerifyMimeType;
     if ($wgVerifyMimeType) {
         # check mime type against file extension
         if (!UploadBase::verifyExtension($mime, $extension)) {
             return Status::newFatal('uploadcorrupt');
         }
         # check mime type blacklist
         global $wgMimeTypeBlacklist;
         if (isset($wgMimeTypeBlacklist) && !is_null($wgMimeTypeBlacklist) && UploadBase::checkFileExtension($mime, $wgMimeTypeBlacklist)) {
             return Status::newFatal('badfiletype', htmlspecialchars($mime));
         }
     }
     # check for htmlish code and javascript
     if (UploadBase::detectScript($tmpfile, $mime, $extension)) {
         return Status::newFatal('uploadscripted');
     }
     /**
      * Scan the uploaded file for viruses
      */
     $virus = UploadBase::detectVirus($tmpfile);
     if ($virus) {
         return Status::newFatal('uploadvirus', htmlspecialchars($virus));
     }
     wfDebug(__METHOD__ . ": all clear; passing.\n");
     return Status::newGood();
 }
开发者ID:Reasno,项目名称:SocialProfile,代码行数:39,代码来源:SpecialSystemGiftManagerLogo.php


注:本文中的UploadBase::verifyExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。