本文整理汇总了PHP中wfUtils::fileOver2Gigs方法的典型用法代码示例。如果您正苦于以下问题:PHP wfUtils::fileOver2Gigs方法的具体用法?PHP wfUtils::fileOver2Gigs怎么用?PHP wfUtils::fileOver2Gigs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wfUtils
的用法示例。
在下文中一共展示了wfUtils::fileOver2Gigs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wfFunc_view
public static function wfFunc_view()
{
$localFile = ABSPATH . preg_replace('/^(?:\\.\\.|[\\/]+)/', '', sanitize_text_field($_GET['file']));
if (strpos($localFile, '..') !== false) {
echo "Invalid file requested. (Relative paths not allowed)";
exit;
}
if (preg_match('/[\'\\"<>\\!\\{\\}\\(\\)\\&\\@\\%\\$\\*\\+\\[\\]\\?]+/', $localFile)) {
echo "File contains illegal characters.";
exit;
}
$cont = @file_get_contents($localFile);
$isEmpty = false;
if (!$cont) {
if (file_exists($localFile) && filesize($localFile) === 0) {
//There's a remote possibility that very large files on 32 bit systems will return 0 here, but it's about 1 in 2 billion
$isEmpty = true;
} else {
$err = error_get_last();
echo "We could not open the requested file for reading. The error was: " . $err['message'];
exit(0);
}
}
$fileMTime = @filemtime($localFile);
$fileMTime = date('l jS \\of F Y h:i:s A', $fileMTime);
try {
if (wfUtils::fileOver2Gigs($localFile)) {
$fileSize = "Greater than 2 Gigs";
} else {
$fileSize = @filesize($localFile);
//Checked if over 2 gigs above
$fileSize = number_format($fileSize, 0, '', ',') . ' bytes';
}
} catch (Exception $e) {
$fileSize = 'Unknown file size.';
}
require 'wfViewResult.php';
exit(0);
}
示例2: wfFunc_view
public static function wfFunc_view()
{
$localFile = ABSPATH . '/' . preg_replace('/^(?:\\.\\.|[\\/]+)/', '', $_GET['file']);
if (strpos($localFile, '..') !== false) {
echo "Invalid file requested. (Relative paths not allowed)";
exit;
}
$lang = false;
$cont = @file_get_contents($localFile);
$isEmpty = false;
if (!$cont) {
if (file_exists($localFile) && filesize($localFile) === 0) {
//There's a remote possibility that very large files on 32 bit systems will return 0 here, but it's about 1 in 2 billion
$isEmpty = true;
} else {
$err = error_get_last();
echo "We could not open the requested file for reading. The error was: " . $err['message'];
exit(0);
}
}
$fileMTime = @filemtime($localFile);
$fileMTime = date('l jS \\of F Y h:i:s A', $fileMTime);
if (wfUtils::fileOver2Gigs($localFile)) {
$fileSize = "Greater than 2 Gigs";
} else {
$fileSize = @filesize($localFile);
//Checked if over 2 gigs above
$fileSize = number_format($fileSize, 0, '', ',') . ' bytes';
}
require 'wfViewResult.php';
exit(0);
}