parent
5363714131
commit
d7c9baf791
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
class File extends Fuel\Core\File
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* To read file split by chunk
|
||||||
|
*
|
||||||
|
* @param string $file_path path to the file or url of the file
|
||||||
|
* @param int $speed_limit speed limit in KB/s
|
||||||
|
* @param boolean $return_bytes if you to return the totals bytes
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function readChunked(string $file_path, int $speed_limit, bool $return_bytes = TRUE)
|
||||||
|
{
|
||||||
|
$buffer = '';
|
||||||
|
$speed_limit += $speed_limit * 0.2;
|
||||||
|
$tickrate = 1024;
|
||||||
|
$cnt = 0;
|
||||||
|
|
||||||
|
$handle = fopen($file_path, "rb");
|
||||||
|
|
||||||
|
if ($handle === false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
while (!feof($handle)) {
|
||||||
|
$buffer = fread($handle, $speed_limit * 1024 / $tickrate);
|
||||||
|
print $buffer;
|
||||||
|
ob_flush();
|
||||||
|
flush();
|
||||||
|
|
||||||
|
if ($return_bytes) {
|
||||||
|
$cnt += strlen($buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
usleep(1000000 / $tickrate);
|
||||||
|
}
|
||||||
|
$status = fclose($handle);
|
||||||
|
|
||||||
|
if ($return_bytes && $status) {
|
||||||
|
return $cnt; // return num. bytes delivered like readfile() does.
|
||||||
|
}
|
||||||
|
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
return array(
|
return array(
|
||||||
'_root_' => 'index', // The default route
|
'_root_' => 'index', // The default route
|
||||||
'_404_' => 'error/404', // The main 404 route
|
'_404_' => 'error/404', // The main 404 route
|
||||||
|
|
||||||
'home(/:server_id)?'=> 'home/index',
|
'home(/:server_id)?' => 'home/index',
|
||||||
'movie/list' => 'movie/list',
|
'movie/list' => 'movie/list',
|
||||||
'library/:library_id' => 'library/index',
|
'library/:library_id' => 'library/index',
|
||||||
'tvshow/:tvshow_id' => 'tvshow/index',
|
'tvshow/:tvshow_id' => 'tvshow/index',
|
||||||
'season/:season_id' => 'season/index',
|
'season/:season_id' => 'season/index',
|
||||||
'episode/:episode_id' => 'episode/index',
|
'episode/:movie_id/download' => 'movie/download',
|
||||||
'movie/:movie_id' => 'movie/index',
|
'episode/:episode_id' => 'episode/index',
|
||||||
'settings/libraries/premissions/:library_id' => 'settings/libraries/permissions'
|
'movie/:movie_id/download' => 'movie/download',
|
||||||
|
'movie/:movie_id' => 'movie/index',
|
||||||
|
'settings/libraries/premissions/:library_id' => 'settings/libraries/permissions'
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in new issue