本文整理汇总了PHP中FileModel::path方法的典型用法代码示例。如果您正苦于以下问题:PHP FileModel::path方法的具体用法?PHP FileModel::path怎么用?PHP FileModel::path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileModel
的用法示例。
在下文中一共展示了FileModel::path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
render('page/404');
exit;
}
$f = $_GET['f'];
if (!file_exists($f)) {
header('HTTP/1.1 404 Not Found');
render('page/404');
exit;
}
$file = new FileModel($_GET['f']);
switch ($file->mime()) {
case 'video/mp4':
case 'image/svg+xml':
case 'image/png':
case 'image/jpeg':
case 'image/gif':
$image = true;
break;
default:
$image = false;
break;
}
if (!$image || !is_readable($f)) {
header('HTTP/1.1 403 Permission denied');
render('page/403', array('message' => 'Permission denied'));
exit;
}
header('Content-Type: ' . $file->mime());
header('Content-Length: ' . $file->size());
readfile($file->path());
示例2: shell
$out = shell(sprintf('locate %s', escapeshellarg(trim($_GET['q']))));
$fields = array(new TableFieldIcon(), new TableFieldLink('Name', 'path', function (FileModel $file) {
return url(array('q' => false, 'f' => $file->path()));
}), new TableField('Type', 'type'), new TableFieldFormat('Size', 'size', 'format_bytes'), new TableField('MIME', 'mime'), new TableField('Permissions', 'perms'));
$rows = array();
foreach (explode("\n", $out) as $row) {
if (!empty($row)) {
$rows[] = new TableRow(new FileModel($row), $fields);
}
}
$middle = render_str('foobar/table', compact('fields', 'rows'));
} else {
$file = new FileModel($f);
if (is_dir($f)) {
$fields = array(new TableFieldIcon(), new TableFieldLink('Name', 'basename', function (FileModel $file) {
return url(array('q' => false, 'f' => $file->path()));
}), new TableField('Type', 'type'), new TableFieldFormat('Size', 'size', 'format_bytes'), new TableField('MIME', 'mime'), new TableField('Owner', 'owner'), new TableField('Group', 'group'), new TableField('Permissions', 'perms'));
$rows = $file->rows();
$middle = render_str('foobar/table', array('fields' => $fields, 'rows' => new TableRowGenerator($rows, $fields)));
} else {
switch ($file->mime()) {
case 'audio/mpeg':
if (begins($file->realpath(), $_SERVER['DOCUMENT_ROOT'])) {
$middle = render_str('foobar/audio', array('src' => replace_prefix($file->realpath(), $_SERVER['DOCUMENT_ROOT'], '/')));
} else {
$middle = render_str('foobar/audio', array('src' => 'image.php?' . http_build_query(array('f' => $file->realpath()))));
}
break;
case 'video/mp4':
if (begins($file->realpath(), $_SERVER['DOCUMENT_ROOT'])) {
$middle = render_str('foobar/video', array('src' => replace_prefix($file->realpath(), $_SERVER['DOCUMENT_ROOT'], '/')));