관리-도구
편집 파일: stream_control.php
<?php require "vendor/autoload.php"; use Micilini\VideoStream\VideoStream; class Stream_control { var $mysqli; var $dbpref; var $load; var $media; function __construct($arr) { $this->mysqli=$arr['mysqli']; $this->dbpref=$arr['dbpref']; if(isset($arr['load'])) { $this->load=$arr['load']; } $this->media= false; } function setMedia($media) { $media->ext= pathinfo($media->file_path, PATHINFO_EXTENSION); $this->media= $media; } function hasPermission() { $media= $this->media; if($media->permission =='public' || isset($_SESSION['qfnl_media_lock_'.get_option('site_token')]) || isset($_SESSION['user'.get_option('site_token')]) ) { return true; } else { return false; } } function readFile($file) { if(is_file($file)) { $fp=fopen($file,'r'); $data=fread($fp,filesize($file)); fclose($fp); return $data; } return false; } function doStreaming() { if(!$this->hasPermission()) { die('Unauthorized access'); } if($this->media) { $media= $this->media; header('content-type: '.$media->file_type); if(in_array($media->type, array('document', 'other'))) { $title= str_replace(" ", "_", urlencode($media->title)); if(strpos(strrev($title), strrev('.'.$media->ext)) !==0) { $title .= '.'.$media->ext; } header('content-disposition: inline; filename="'.$title.'"'); echo $this->readFile($media->file_path); } else if(in_array($media->type, array('image'))) { echo $this->readFile($media->file_path); } else if($media->type =='video') { $this->doVideoStreaming( $media->size ); } else if($media->type =='audio') { $this->doAudioStreaming( $media->size ); } return true; } return false; } function getChunkSize($size) { $mb= round($size/(1024*1024)); $len= 0.5; if($mb>1) { } return round($len*(1024*1024)); } function doVideoStreaming($size) { $Vid_ob= new CF_Video_Streaming($this->media->file_path, $this->media->file_type, $size); $Vid_ob->start(); } function doAudioStreaming($size) { $Vid_ob= new CF_Video_Streaming($this->media->file_path, $this->media->file_type, $size ); $Vid_ob->start(); } } class CF_Video_Streaming { var $path; var $ext; var $size; function __construct($filePath, $ext= "video/mp4",$size=5) { $this->path = $filePath; $this->ext= $ext; $this->size= $size; } function start() { $options = array( 'is_localPath' => true, 'is_https' => false, 'video_size' => $this->size, 'video_buffer' => 512, 'content_type' => $this->ext, 'cache_control' => 'max-age=2592000, public', 'expires' => gmdate('D, d M Y H:i:s', time()+2592000).' GMT', 'last_modified' => gmdate('D, d M Y H:i:s', @filemtime($this->path)).' GMT' ); $videoStream = new VideoStream(); $videoStream->streamVideo($this->path, $options); // die(); } } ?>