本文整理汇总了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();
}
示例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();
}