本文整理汇总了PHP中UploadBase::detectScript方法的典型用法代码示例。如果您正苦于以下问题:PHP UploadBase::detectScript方法的具体用法?PHP UploadBase::detectScript怎么用?PHP UploadBase::detectScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UploadBase
的用法示例。
在下文中一共展示了UploadBase::detectScript方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}