本文整理汇总了PHP中app\Config::whereKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::whereKey方法的具体用法?PHP Config::whereKey怎么用?PHP Config::whereKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Config
的用法示例。
在下文中一共展示了Config::whereKey方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DownloadFile
public static function DownloadFile()
{
$id = intval(Input::get('file_id'));
$fileInfo = File::whereId($id)->whereBanned(false)->first();
if ($fileInfo == null) {
abort(404);
}
$config = Config::whereKey('file_dir')->whereApplied(true)->first();
$sourceFile = $config->value . $fileInfo->file_path;
$outFile = $fileInfo->filename;
if (!is_file($sourceFile)) {
abort(404);
}
LogController::LogDownload($id);
$len = filesize($sourceFile);
//获取文件大小
$filename = basename($sourceFile);
//获取文件名字
$ctype = FileDownloadController::GetFileExtension($outFile);
//echo $outFile;
header("Cache-Control: public");
header("Content-Type: {$ctype}");
header("Content-Disposition: attachment; filename=" . $outFile);
header("Accept-Ranges: bytes");
$size = filesize($sourceFile);
$range = 0;
if (isset($_SERVER['HTTP_RANGE'])) {
list($a, $range) = explode("=", $_SERVER['HTTP_RANGE']);
str_replace($range, "-", $range);
$size2 = $size - 1;
//文件总字节数
$new_length = $size2 - $range;
header("HTTP/1.1 206 Partial Content");
header("Content-Length: {$new_length}");
header("Content-Range: bytes {$range}{$size2}/{$size}");
} else {
$size2 = $size - 1;
header("Content-Range: bytes 0-{$size2}/{$size}");
header("Content-Length: " . $size);
}
$fp = fopen("{$sourceFile}", "rb");
fseek($fp, $range);
while (!feof($fp)) {
set_time_limit(0);
print fread($fp, 1024 * 8);
flush();
ob_flush();
}
fclose($fp);
exit;
}
示例2: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$domain = Config::whereKey('domain')->whereApplied(true)->first();
if ($domain == null) {
return $next($request);
}
if ($request->header('Referer') == "") {
LogController::LogLeech($request->fullUrl());
die("禁止盗链");
}
$referer = parse_url($request->header('Referer'));
if ($referer['host'] != $domain->value) {
LogController::LogLeech($request->fullUrl());
die("禁止盗链");
}
return $next($request);
}