本文整理汇总了PHP中Safe::fstat方法的典型用法代码示例。如果您正苦于以下问题:PHP Safe::fstat方法的具体用法?PHP Safe::fstat怎么用?PHP Safe::fstat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Safe
的用法示例。
在下文中一共展示了Safe::fstat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
// record surfer activity
Activities::post('file:' . $item['id'], 'fetch');
$anchor->touch('file:fetch', 'file:' . $item['id'], true);
// if we have an external reference, use it
if (isset($item['file_href']) && $item['file_href']) {
$target_href = $item['file_href'];
// we have direct access to the file
} else {
// ensure a valid file name
$file_name = utf8::to_ascii($item['file_name']);
// where the file is located
$path = Files::get_path($item['anchor']) . '/' . $item['file_name'];
// file attributes
$attributes = array();
// transmit file content
if (!headers_sent() && ($handle = Safe::fopen($context['path_to_root'] . $path, "rb")) && ($stat = Safe::fstat($handle))) {
// stream FLV files if required to do so
if (substr($item['file_name'], -4) == '.flv' && isset($_REQUEST['position']) && $_REQUEST['position'] > 0 && $_REQUEST['position'] < $stat['size']) {
Safe::header('Content-Length: ' . ($stat['size'] - $_REQUEST['position'] + 13));
echo 'FLV' . pack('C', 1) . pack('C', 1) . pack('N', 9) . pack('N', 9);
fseek($handle, $_REQUEST['position']);
echo fread($handle, $stat['size'] - $_REQUEST['position']);
fclose($handle);
return;
}
// load some file parser if one is available
$analyzer = NULL;
if (is_readable($context['path_to_root'] . 'included/getid3/getid3.php')) {
include_once $context['path_to_root'] . 'included/getid3/getid3.php';
$analyzer = new getid3();
}