How to use stream_open method of has class

Best VfsStream code snippet using has.stream_open

WrapperTest.php

Source:WrapperTest.php Github

copy

Full Screen

...499 {500 $fs = new FileSystem();501 $opened_path = null;502 $wrapper = new Wrapper();503 $this->assertFalse($wrapper->stream_open($fs->path('/file'), 'r', 0, $opened_path), 'No warning when no flag');504 @$wrapper->stream_open($fs->path('/file'), 'r', STREAM_REPORT_ERRORS, $opened_path);505 $error = error_get_last();506 $this->assertStringMatchesFormat(507 '%s: failed to open stream.',508 $error['message'],509 'Stream open errors when flag passed'510 );511 }512 public function testDirectoryOpensForReading()513 {514 $fs = new FileSystem();515 $fs->container()->createDir('/dir');516 $wrapper = new Wrapper();517 $handle = $wrapper->dir_opendir($fs->path('/dir'));518 $this->assertTrue($handle, 'Directory opened for reading');519 $handle = @$wrapper->dir_opendir($fs->path('/nonExistingDir'));520 $this->assertFalse($handle, 'Non existing directory not opened for reading');521 $error = error_get_last();522 $this->assertStringMatchesFormat(523 'opendir(%s): failed to open dir: No such file or directory',524 $error['message'],525 'Opening non existing directory triggers warning'526 );527 $handle = opendir($fs->path('/dir'));528 $this->assertTrue(is_resource($handle), 'opendir uses dir_opendir');529 }530 public function testDirectoryOpenDoesNotOpenFiles()531 {532 $fs = new FileSystem();533 $fs->container()->createFile('/file');534 $wrapper = new Wrapper();535 $handle = @$wrapper->dir_opendir($fs->path('/file'));536 $this->assertFalse($handle, 'Opening fiels with opendir fails');537 $error = error_get_last();538 $this->assertStringMatchesFormat(539 'opendir(%s): failed to open dir: Not a directory',540 $error['message'],541 'Opening fiels with opendir triggers warning'542 );543 }544 public function testDirectoryCloses()545 {546 $fs = new FileSystem();547 $fs->container()->createDir('/dir');548 $wrapper = new Wrapper();549 $this->assertFalse($wrapper->dir_closedir(), 'Returns false when no dir opened');550 $wrapper->dir_opendir($fs->path('/dir'));551 $this->assertTrue($wrapper->dir_closedir());552 }553 public function testDirectoryReading()554 {555 $fs = new FileSystem();556 $fs->container()->createDir('/dir1');557 $fs->container()->createDir('/dir2');558 $fs->container()->createDir('/dir3');559 $wr = new Wrapper();560 $wr->dir_opendir($fs->path('/'));561 $this->assertEquals('dir1', $wr->dir_readdir());562 $this->assertEquals('dir2', $wr->dir_readdir());563 $this->assertEquals('dir3', $wr->dir_readdir());564 $this->assertFalse($wr->dir_readdir());565 $wr->dir_rewinddir();566 $this->assertEquals('dir1', $wr->dir_readdir(), 'Directory rewound');567 }568 public function testDirectoryIterationWithDirectoryIterator()569 {570 $fs = new FileSystem();571 $fs->container()->createDir('/dir1');572 $fs->container()->createDir('/dir2');573 $fs->container()->createDir('/dir3');574 $result = array();575 foreach (new \DirectoryIterator($fs->path('/')) as $fileInfo) {576 $result[] = $fileInfo->getBasename();577 }578 $this->assertEquals(array('dir1', 'dir2', 'dir3'), $result, 'All directories found');579 }580 public function testStreamOpenDoesNotOpenDirectoriesForWriting()581 {582 $fs = new FileSystem();583 $fs->container()->createDir('/dir');584 $this->assertFalse(@fopen($fs->path('/dir'), 'w'));585 $this->assertFalse(@fopen($fs->path('/dir'), 'r+'));586 $this->assertFalse(@fopen($fs->path('/dir'), 'w+'));587 $this->assertFalse(@fopen($fs->path('/dir'), 'a'));588 $this->assertFalse(@fopen($fs->path('/dir'), 'a+'));589 $opened_path = null;590 $wr = new Wrapper();591 @$wr->stream_open($fs->path('/dir'), 'w', STREAM_REPORT_ERRORS, $opened_path);592 $error = error_get_last();593 $this->assertStringMatchesFormat(594 'fopen(%s): failed to open stream: Is a directory',595 $error['message'],596 'Stream does not open directories'597 );598 }599 public function testStreamOpenAllowsForDirectoryOpeningForReadingAndReturnsEmptyStrings()600 {601 $fs = new FileSystem();602 $fs->container()->createDir('/dir');603 $handle = fopen($fs->path('/dir'), 'r');604 $this->assertTrue(is_resource($handle));605 $this->assertEmpty(fread($handle, 1));606 }607 public function testPermissionsAreCheckedWhenOpeningFiles()608 {609 $fs = new FileSystem();610 $file = $fs->container()->createFile('/file');611 $openedPath = null;612 $wr = new Wrapper();613 $file->chmod(0000);614 $file->chown(0);615 $file->chgrp(0);616 $this->assertFalse($wr->stream_open($fs->path('/file'), 'r', 0, $openedPath));617 $this->assertFalse($wr->stream_open($fs->path('/file'), 'r+', 0, $openedPath));618 $this->assertFalse($wr->stream_open($fs->path('/file'), 'w', 0, $openedPath));619 $this->assertFalse($wr->stream_open($fs->path('/file'), 'w+', 0, $openedPath));620 $this->assertFalse($wr->stream_open($fs->path('/file'), 'a', 0, $openedPath));621 $this->assertFalse($wr->stream_open($fs->path('/file'), 'a+', 0, $openedPath));622 $file->chmod(0400);623 $file->chown($this->uid);624 $file->chgrp(0);625 $this->assertTrue($wr->stream_open($fs->path('/file'), 'r', 0, $openedPath));626 $this->assertFalse($wr->stream_open($fs->path('/file'), 'r+', 0, $openedPath));627 $this->assertFalse($wr->stream_open($fs->path('/file'), 'w', 0, $openedPath));628 $this->assertFalse($wr->stream_open($fs->path('/file'), 'w+', 0, $openedPath));629 $this->assertFalse($wr->stream_open($fs->path('/file'), 'a', 0, $openedPath));630 $this->assertFalse($wr->stream_open($fs->path('/file'), 'a+', 0, $openedPath));631 $file->chmod(0200);632 $file->chown($this->uid);633 $file->chgrp(0);634 $this->assertFalse($wr->stream_open($fs->path('/file'), 'r', 0, $openedPath));635 $this->assertFalse($wr->stream_open($fs->path('/file'), 'r+', 0, $openedPath));636 $this->assertTrue($wr->stream_open($fs->path('/file'), 'w', 0, $openedPath));637 $this->assertFalse($wr->stream_open($fs->path('/file'), 'w+', 0, $openedPath));638 $this->assertTrue($wr->stream_open($fs->path('/file'), 'a', 0, $openedPath));639 $this->assertFalse($wr->stream_open($fs->path('/file'), 'a+', 0, $openedPath));640 $file->chmod(0600);641 $file->chown($this->uid);642 $file->chgrp(0);643 $this->assertTrue($wr->stream_open($fs->path('/file'), 'r', 0, $openedPath));644 $this->assertTrue($wr->stream_open($fs->path('/file'), 'r+', 0, $openedPath));645 $this->assertTrue($wr->stream_open($fs->path('/file'), 'w', 0, $openedPath));646 $this->assertTrue($wr->stream_open($fs->path('/file'), 'w+', 0, $openedPath));647 $this->assertTrue($wr->stream_open($fs->path('/file'), 'a', 0, $openedPath));648 $this->assertTrue($wr->stream_open($fs->path('/file'), 'a+', 0, $openedPath));649 }650 public function testTemporaryFileCreatedToReadDirectoriesWithStreamOpenInheritsPermissions()651 {652 $fs = new FileSystem();653 $file = $fs->container()->createDir('/dir');654 $openedPath = null;655 $wr = new Wrapper();656 $file->chmod(0000);657 $file->chown(0);658 $file->chgrp(0);659 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'r', 0, $openedPath));660 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'r+', 0, $openedPath));661 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'w', 0, $openedPath));662 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'w+', 0, $openedPath));663 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'a', 0, $openedPath));664 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'a+', 0, $openedPath));665 $file->chmod(0400);666 $file->chown($this->uid);667 $file->chgrp(0);668 $this->assertTrue($wr->stream_open($fs->path('/dir'), 'r', 0, $openedPath));669 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'r+', 0, $openedPath));670 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'w', 0, $openedPath));671 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'w+', 0, $openedPath));672 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'a', 0, $openedPath));673 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'a+', 0, $openedPath));674 $file->chmod(0200);675 $file->chown($this->uid);676 $file->chgrp(0);677 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'r', 0, $openedPath));678 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'r+', 0, $openedPath));679 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'w', 0, $openedPath));680 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'w+', 0, $openedPath));681 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'a', 0, $openedPath));682 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'a+', 0, $openedPath));683 $file->chmod(0600);684 $file->chown($this->uid);685 $file->chgrp(0);686 $this->assertTrue($wr->stream_open($fs->path('/dir'), 'r', 0, $openedPath));687 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'r+', 0, $openedPath));688 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'w', 0, $openedPath));689 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'w+', 0, $openedPath));690 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'a', 0, $openedPath));691 $this->assertFalse($wr->stream_open($fs->path('/dir'), 'a+', 0, $openedPath));692 }693 public function testPermissionsAreCheckedWhenOpeningDirectories()694 {695 $fs = new FileSystem();696 $file = $fs->container()->createDir('/dir');697 $openedPath = null;698 $wr = new Wrapper();699 $file->chmod(0000);700 $file->chown(0);701 $file->chgrp(0);702 $this->assertFalse(@$wr->dir_opendir($fs->path('/dir'), 0, $openedPath));703 $file->chmod(0200);704 $file->chown($this->uid);705 $file->chgrp(0);706 $this->assertFalse(@$wr->dir_opendir($fs->path('/dir'), 0, $openedPath));707 $file->chmod(0400);708 $file->chown($this->uid);709 $file->chgrp(0);710 $this->assertTrue(@$wr->stream_open($fs->path('/dir'), 'r', 0, $openedPath));711 $file->chmod(0040);712 $file->chown(0);713 $file->chgrp($this->gid);714 $this->assertTrue(@$wr->stream_open($fs->path('/dir'), 'r', 0, $openedPath));715 }716 public function testPermissionsAreCheckedWhenCreatingFilesWithinDirectories()717 {718 $fs = new FileSystem();719 $dir = $fs->createDirectory('/dir');720 $dir->chmod(0000);721 $this->assertFalse(@file_put_contents($fs->path('/dir/file'), 'data'));722 $dir->chmod(0400);723 $this->assertFalse(@file_put_contents($fs->path('/dir/file'), 'data'));724 $dir->chmod(0200);725 $this->assertGreaterThan(0, @file_put_contents($fs->path('/dir/file'), 'data'));726 }727 public function testStreamOpenReportsErrorsOnPermissionDenied()728 {729 $fs = new FileSystem();730 $dir = $fs->createDirectory('/dir');731 $file = $fs->createFile('/file');732 $dir->chmod(0000);733 $na = [];734 $openedPath = null;735 $wr = new Wrapper();736 @$wr->stream_open($fs->path('/dir/file'), 'w', STREAM_REPORT_ERRORS, $openedPath);737 $error = error_get_last();738 $this->assertStringMatchesFormat(739 '%s: failed to open stream: Permission denied',740 $error['message']741 );742 @$na['n/a']; //putting error in known state743 $file->chmod(0000);744 @$wr->stream_open($fs->path('/file'), 'r', STREAM_REPORT_ERRORS, $openedPath);745 $error = error_get_last();746 $this->assertStringMatchesFormat(747 '%s: failed to open stream: Permission denied',748 $error['message']749 );750 @$na['n/a']; //putting error in known state751 $file->chmod(0000);752 @$wr->stream_open($fs->path('/file'), 'w', STREAM_REPORT_ERRORS, $openedPath);753 $error = error_get_last();754 $this->assertStringMatchesFormat(755 '%s: failed to open stream: Permission denied',756 $error['message']757 );758 @$na['n/a']; //putting error in known state759 $file->chmod(0000);760 @$wr->stream_open($fs->path('/file'), 'a', STREAM_REPORT_ERRORS, $openedPath);761 $error = error_get_last();762 $this->assertStringMatchesFormat(763 '%s: failed to open stream: Permission denied',764 $error['message']765 );766 @$na['n/a']; //putting error in known state767 $file->chmod(0000);768 @$wr->stream_open($fs->path('/file'), 'w+', STREAM_REPORT_ERRORS, $openedPath);769 $error = error_get_last();770 $this->assertStringMatchesFormat(771 '%s: failed to open stream: Permission denied',772 $error['message']773 );774 }775 public function testPermissionsAreCheckedWhenCreatingDirectories()776 {777 $fs = new FileSystem();778 $fs->createDirectory('/test', false, 0000);779 $wr = new Wrapper();780 $this->assertFalse(@$wr->mkdir($fs->path('/test/dir'), 0777, 0));781 $error = error_get_last();782 $this->assertStringMatchesFormat(...

Full Screen

Full Screen

stream.php

Source:stream.php Github

copy

Full Screen

...41 * @package stream42 * @version 2.5.92: Added function and documentation43 * @note Inspiration for this function taken from https://codesamplez.com/programming/php-html5-video-streaming-tutorial44 * @see http://codesamplez.com/programming/php-html5-video-streaming-tutorial45 * @see stream_open()46 * @see stream_close()47 * @see stream_video()48 * @see stream_audio()49 *50 * @param params $params The streaming parameters array51 */52function stream($params){53 global $_CONFIG;54 try{55 array_ensure($params, 'file,mimetype');56 array_default($params, 'strict' , $_CONFIG['stream']['strict']);57 array_default($params, 'cache_max_age', $_CONFIG['stream']['cache_max_age']);58 /*59 * Open the file to be streamed and determine its mimetype to know what60 * sub functions to use61 */62 stream_open($params);63 $mimetype = mime_content_type($params['file']);64 if($params['mimetype']){65 /*66 * Ensure the specified file maches the mimetype67 */68 if($params['strict']){69 /*70 * Match the entire mimetype71 */72 if($mimetype !== $params['mimetype']){73 throw new BException(tr('stream(): Specified file ":file" failed strict mimetype check. If has mimetype ":has" while ":requested" was requested', array(':has' => $mimetype, ':mimetype' => $params['mimetype'])), 'not-authorized');74 }75 }else{76 if(str_until($mimetype, '/') !== str_until($params['mimetype'], '/')){77 throw new BException(tr('stream(): Specified file ":file" failed lax mimetype check. If has mimetype ":has" while ":requested" was requested', array(':has' => str_until($mimetype, '/'), ':mimetype' => str_until($params['mimetype'], '/'))), 'not-authorized');78 }79 }80 }81 /*82 * Set mimetype in parameters, it will be required later83 */84 $params['mimetype'] = $mimetype;85 switch(str_until($mimetype, '/')){86 case 'audio':87 return stream_audio($params);88 case 'video':89 return stream_video($params);90 throw new BException(tr('stream(): Unsupported mimetype ":mimetype" encounered', array(':mimetype' => str_until($mimetype, '/'))), 'unsupported');91 }92 }catch(Exception $e){93 throw new BException(tr('stream(): Failed'), $e);94 }95}96/*97 * Open the file for streaming98 *99 * @author Sven Olaf Oostenbrink <sven@capmega.com>100 * @copyright Copyright (c) 2018 Capmega101 * @license http://opensource.org/licenses/GPL-2.0 GNU Public License, Version 2102 * @category Function reference103 * @package stream104 * @version 2.5.86: Added function and documentation105 * @see stream_close()106 *107 * @param params $params A parameters array108 * @return void109 */110function stream_open(&$params){111 try{112 if(empty($params['file'])){113 throw new BException(tr('stream_open(): No file specified'), 'not-specified');114 }115 if(!file_exists($params['file'])){116 throw new BException(tr('stream_open(): Specified file ":file" does not exist', array(':file' => $params['file'])), 'not-exist');117 }118 if(!is_readable($params['file'])){119 throw new BException(tr('stream_open(): Specified file ":file" is not readable', array(':file' => $params['file'])), 'not-readable');120 }121 $params['resource'] = fopen($this->path, 'rb');122 if(!$params['resource']){123 throw new BException(tr('stream_open(): Failed to open file ":file" for streaming', array(':file' => $params['file'])), $e);124 }125 $params['start'] = 0;126 $params['size'] = filesize($params['file']);127 $params['end'] = $params['size'];128 $params['filemtime'] = filemtime($params['file']);129 }catch(Exception $e){130 throw new BException(tr('stream_open(): Failed'), $e);131 }132}133/*134 * Closes the stream file135 *136 * @author Sven Olaf Oostenbrink <sven@capmega.com>137 * @copyright Copyright (c) 2018 Capmega138 * @license http://opensource.org/licenses/GPL-2.0 GNU Public License, Version 2139 * @category Function reference140 * @package stream141 * @version 2.5.92: Added function and documentation142 * @note Inspiration for this function taken from https://codesamplez.com/programming/php-html5-video-streaming-tutorial143 * @see http://codesamplez.com/programming/php-html5-video-streaming-tutorial144 * @see stream_open()145 *146 * @param params $params The streaming parameters array147 */148function stream_close($params){149 try{150 array_ensure($params);151 array_default($params, 'die', true);152 if(empty($params['resource'])){153 throw new BException(tr('stream_close(): No video file resource opened. Please open one first using stream_open(), or just use stream()'), 'not-specified');154 }155 fclose($params['resource']);156 if(empty($params['die'])){157 die();158 }159 }catch(Exception $e){160 throw new BException(tr('stream_close(): Failed'), $e);161 }162}163/*164 * Stream a audio file165 *166 * @author Sven Olaf Oostenbrink <sven@capmega.com>167 * @copyright Copyright (c) 2018 Capmega168 * @license http://opensource.org/licenses/GPL-2.0 GNU Public License, Version 2169 * @category Function reference170 * @package stream171 * @version 2.5.92: Added function and documentation172 * @note Inspiration for this function taken from https://codesamplez.com/programming/php-html5-audio-streaming-tutorial173 * @see http://codesamplez.com/programming/php-html5-audio-streaming-tutorial174 *175 * @param params $params The streaming parameters array176 */177function stream_audio($params){178 try{179under_construction('Audio streaming is still under construction');180 stream_audio_send_headers($params);181 stream_audio_send($params);182 stream_end($params);183 }catch(Exception $e){184 throw new BException(tr('stream_audio(): Failed'), $e);185 }186}187/*188 * Stream a video file189 *190 * @author Sven Olaf Oostenbrink <sven@capmega.com>191 * @copyright Copyright (c) 2018 Capmega192 * @license http://opensource.org/licenses/GPL-2.0 GNU Public License, Version 2193 * @category Function reference194 * @package stream195 * @version 2.5.92: Added function and documentation196 * @note Inspiration for this function taken from https://codesamplez.com/programming/php-html5-video-streaming-tutorial197 * @see http://codesamplez.com/programming/php-html5-video-streaming-tutorial198 *199 * @param params $params The streaming parameters array200 */201function stream_video($params){202 try{203 stream_video_data_headers($params);204 stream_video_data($params);205 stream_end($params);206 }catch(Exception $e){207 throw new BException(tr('stream_video(): Failed'), $e);208 }209}210/*211 * Send the video stream HTTP headers212 *213 * @author Rana214 * @author Sven Olaf Oostenbrink <sven@capmega.com>215 * @copyright Copyright (c) 2018 Capmega216 * @license http://opensource.org/licenses/GPL-2.0 GNU Public License, Version 2217 * @category Function reference218 * @package stream219 * @version 2.5.92: Added function and documentation220 * @note Inspiration for this function taken from https://codesamplez.com/programming/php-html5-video-streaming-tutorial221 * @see http://codesamplez.com/programming/php-html5-video-streaming-tutorial222 *223 * @param params $params The streaming parameters array224 * return void225 */226function stream_video_data_headers($params){227 try{228 array_ensure($params, 'mimetype,cache_max_age,start,end,size');229 if(empty($params['resource'])){230 throw new BException(tr('stream_video_data_headers(): No video file resource opened. Please open one first using stream_open(), or just use stream()'), 'not-specified');231 }232 if(empty($params['file'])){233 throw new BException(tr('stream_video_data_headers(): No video file specified'), 'not-specified');234 }235 /*236 * Clean the output buffer and start sending HTTP headers237 */238 ob_get_clean();239 header('Content-Type: '.$params['mimetype']);240 header('Cache-Control: max-age='.$params['cache_max_age'].', public');241 header('Expires: '.gmdate('D, d M Y H:i:s', time() + $params['cache_max_age']).' GMT');242 header('Last-Modified: '.gmdate('D, d M Y H:i:s', $params['filemtime']).' GMT');243 header('Accept-Ranges: 0-'.$params['end']);244 if(empty($_SERVER['HTTP_RANGE'])){245 header('Content-Length: '.$params['size']);246 return;247 }248 $c_start = $params['start'];249 $c_end = $params['end'];250 list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);251 if(strpos($range, ',') !== false){252 header('HTTP/1.1 416 Requested Range Not Satisfiable');253 header('Content-Range: bytes '.$params['start'].'-'.$params['end'].'/'.$params['size']);254 die();255 }256 if($range == '-'){257 $c_start = $params['size'] - substr($range, 1);258 }else{259 $range = explode('-', $range);260 $c_start = $range[0];261 $c_end = (isset($range[1]) and (is_numeric($range[1])) ? $range[1] : $c_end);262 }263 $c_end = (($c_end > $params['end']) ? $params['end'] : $c_end);264 if(($c_start > $c_end) || ($c_start > $params['size'] - 1) || ($c_end >= $params['size'])){265 header('HTTP/1.1 416 Requested Range Not Satisfiable');266 header('Content-Range: bytes '.$params['start'].'-'.$params['end'].'/'.$params['size']);267 die();268 }269 $params['start'] = $c_start;270 $params['end'] = $c_end;271 $length = $params['end'] - $params['start'] + 1;272 fseek($this->stream, $params['start']);273 header('HTTP/1.1 206 Partial Content');274 header('Content-Length: '.$length);275 header('Content-Range: bytes '.$params['start'].'-'.$params['end'].'/'.$params['size']);276 }catch(Exception $e){277 throw new BException(tr('stream_video_data_headers(): Failed'), $e);278 }279}280/*281 * Stream the video file data282 *283 * @author Rana284 * @author Sven Olaf Oostenbrink <sven@capmega.com>285 * @copyright Copyright (c) 2018 Capmega286 * @license http://opensource.org/licenses/GPL-2.0 GNU Public License, Version 2287 * @category Function reference288 * @package stream289 * @version 2.5.92: Added function and documentation290 * @note Inspiration for this function taken from https://codesamplez.com/programming/php-html5-video-streaming-tutorial291 * @see http://codesamplez.com/programming/php-html5-video-streaming-tutorial292 *293 * @param params $params The streaming parameters array294 */295function stream_video_data($params){296 global $_CONFIG;297 try{298 array_ensure($params);299 array_default($params, 'buffer', $_CONFIG['stream']['buffer']);300 if(empty($params['resource'])){301 throw new BException(tr('stream_video_data_headers(): No video file resource opened. Please open one first using stream_open(), or just use stream()'), 'not-specified');302 }303 if(empty($params['file'])){304 throw new BException(tr('stream_video_data_headers(): No video file specified'), 'not-specified');305 }306 /*307 * Disable timelimit because we might be streaming for a while308 */309 set_time_limit(0);310 $i = $params['start'];311 while(!feof($params['resource']) && $i <= $params['end']){312 $bytesToRead = $params['buffer'];313 if(($i + $bytesToRead) > $params['end']){314 $bytesToRead = $params['end'] - $i + 1;315 }...

Full Screen

Full Screen

stream_open

Using AI Code Generation

copy

Full Screen

1while (!feof($fp)) {2 echo fgets($fp);3}4fclose($fp);5while (!feof($fp)) {6 echo fgets($fp);7}8fclose($fp);9while (!feof($fp)) {10 echo fgets($fp);11}12fclose($fp);13while (!feof($fp)) {14 echo fgets($fp);15}16fclose($fp);17while (!feof($fp)) {18 echo fgets($fp);19}20fclose($fp);21while (!feof($fp)) {22 echo fgets($fp);23}24fclose($fp);25while (!feof($fp)) {26 echo fgets($fp);27}28fclose($fp);29while (!feof($fp)) {30 echo fgets($fp);31}32fclose($fp);33while (!feof($fp)) {34 echo fgets($fp);35}36fclose($fp);37while (!feof($fp)) {38 echo fgets($fp);39}40fclose($fp);

Full Screen

Full Screen

stream_open

Using AI Code Generation

copy

Full Screen

1echo fread($fp, 1000);2fclose($fp);3echo fread($fp, 1000);4fclose($fp);5echo fread($fp, 1000);6fclose($fp);7echo fread($fp, 1000);8fclose($fp);9echo fread($fp, 1000);10fclose($fp);11echo fread($fp, 1000);12fclose($fp);13echo fread($fp, 1000);14fclose($fp);15echo fread($fp, 1000);16fclose($fp);17echo fread($fp, 1000);18fclose($fp);19echo fread($fp, 1000);20fclose($fp);21echo fread($fp, 1000);22fclose($fp);

Full Screen

Full Screen

stream_open

Using AI Code Generation

copy

Full Screen

1while (!feof($fp)) {2 echo fgets($fp, 1024);3}4fclose($fp);5while (!feof($fp)) {6 echo fgets($fp, 1024);7}8fclose($fp);9while (!feof($fp)) {10 echo fgets($fp, 1024);11}12fclose($fp);13while (!feof($fp)) {14 echo fgets($fp, 1024);15}16fclose($fp);17while (!feof($fp)) {18 echo fgets($fp, 1024);19}20fclose($fp);21while (!feof($fp)) {22 echo fgets($fp, 1024);23}24fclose($fp);25while (!feof($fp)) {26 echo fgets($fp, 1024);27}28fclose($fp);29while (!feof($fp)) {30 echo fgets($fp, 1024);31}32fclose($fp);33while (!feof($fp)) {34 echo fgets($fp, 1024);35}36fclose($fp);37while (!feof($fp)) {

Full Screen

Full Screen

stream_open

Using AI Code Generation

copy

Full Screen

1require_once('has.php');2while (!feof($handle)) {3 echo fgets($handle, 1024);4}5fclose($handle);6require_once('has.php');7while (!feof($handle)) {8 echo fgets($handle, 1024);9}10fclose($handle);11require_once('has.php');12while (!feof($handle)) {13 echo fgets($handle, 1024);14}15fclose($handle);16require_once('has.php');17while (!feof($handle)) {18 echo fgets($handle, 1024);19}20fclose($handle);21require_once('has.php');22while (!feof($handle)) {23 echo fgets($handle, 1024);24}25fclose($handle);26require_once('has.php');27while (!feof($handle)) {28 echo fgets($handle, 1024);29}30fclose($handle);31require_once('has.php');32while (!feof($handle)) {33 echo fgets($handle, 1024);34}35fclose($handle);36require_once('has.php');37while (!feof($handle)) {38 echo fgets($handle, 1024);39}40fclose($handle);41require_once('has.php');42while (!feof($handle)) {43 echo fgets($handle, 1024);44}45fclose($handle);

Full Screen

Full Screen

stream_open

Using AI Code Generation

copy

Full Screen

1$has = new Has();2$has->stream_read(1024);3$has->stream_close();4$has = new Has();5$has->stream_read(1024);6$has->stream_close();7The above code will work as expected, but if you want to read the data from the stream, then you need to use stream_get_contents() function. The code will be as follows:8$has = new Has();9echo $has->stream_get_contents();10$has = new Has();11echo $has->stream_get_contents();12$has = new Has();13echo $has->stream_get_contents();14The above code will not work as expected. It will print the data from the first file only. This is because the data is already read from the stream and is not available for the next file to read. To avoid this, you need to use stream_seek() function to reset the pointer to the start of the stream before reading the data from the stream. The code will be as follows:15$has = new Has();16$has->stream_seek(0);17echo $has->stream_get_contents();18$has = new Has();19$has->stream_seek(0

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run VfsStream automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Trigger stream_open code on LambdaTest Cloud Grid

Execute automation tests with stream_open on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful