ÿØÿà JFIF ÿÛ „ ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /var/www/html/vidoe.top/code/ |
<?php require '../123vid/vendor/autoload.php'; class upload{ public function __construct() { global $CORE,$print,$INFO; if(empty($_SESSION['user_id'])){ $print -> refresh($INFO['home_url']); } $code = ''; if (isset($CORE->input['code'])) { $code = $CORE->input['code']; } switch ($code) { default : $this -> goList(); break; case 'local' : $this->goLocal(); break; case 'upload' : $this-> goUpload(); break; case 'make_ts' : $this-> make_ts(); break; case 'logindaily' : $this->goLoginDaily(); break; } } function apiRequest($url, $post=FALSE, $headers=array()) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); $response = curl_exec($ch); if($post) { curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); } $headers[] = 'Accept: application/json'; if(isset($_SESSION['access_token'])) { $headers[] = 'Authorization: Bearer ' . $_SESSION['access_token']; } curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); return json_decode($response); } function goLoginDaily(){ $tokenPath = 'cache/tokendaily.json'; //$content = file_get_contents($tokenPath); $api_key = 'c7e5de46244ed6ae7f51'; $api_secret = '0edf7035a35d09633748011fec0051f1ff5a05e9'; $tokenURL = 'https://api.dailymotion.com/oauth/token'; $token = $this->apiRequest($tokenURL, array( "grant_type" => "password", 'client_id' => $api_key, 'client_secret' => $api_secret, 'username' => 'movieandtube@gmail.com', 'password' => 'iSchool!23' )); return $token->access_token; /*file_put_contents($tokenPath, json_encode($token)); return json_encode($token);*/ /*print_r($token); exit(); $token = $token->access_token; $r_token = $token->refresh_token; echo $r_token; exit(); $content = $func->get_content_page($url_get_code,''); echo $content; exit();*/ } function get_token_from_r_token($r_token){ $tokenPath = 'cache/tokendaily.json'; $api_key = 'c7e5de46244ed6ae7f51'; $api_secret = '0edf7035a35d09633748011fec0051f1ff5a05e9'; $tokenURL = 'https://api.dailymotion.com/oauth/token'; $token = $this->apiRequest($tokenURL, array( "grant_type" => "refresh_token", 'client_id' => $api_key, 'client_secret' => $api_secret, 'refresh_token' =>$r_token )); file_put_contents($tokenPath, json_encode($token)); return json_encode($token); } function getClient() { $client = new Google_Client(); $client->setApplicationName('Google Drive API PHP Quickstart'); $client->setScopes(Google_Service_Drive::DRIVE); $client->setAuthConfig('cache/credentials.json'); $client->setAccessType('offline'); $client->setPrompt('select_account consent'); // Load previously authorized token from a file, if it exists. // The file token.json stores the user's access and refresh tokens, and is // created automatically when the authorization flow completes for the first // time. $tokenPath = 'cache/token.json'; if (file_exists($tokenPath)) { $accessToken = json_decode(file_get_contents($tokenPath), true); $client->setAccessToken($accessToken); } // If there is no previous token or it's expired. if ($client->isAccessTokenExpired()) { // Refresh the token if possible, else fetch a new one. if ($client->getRefreshToken()) { $client->fetchAccessTokenWithRefreshToken($client->getRefreshToken()); } else { // Request authorization from the user. $authUrl = $client->createAuthUrl(); printf("Open the following link in your browser:\n%s\n", $authUrl); print 'Enter verification code: '; //$authCode = trim(fgets(STDIN)); $authCode = '4/0AF0ZtYZhsqM0sPB5Iq-VKgXpc4RpVafAj8k96Ul89Vo3o_QMk1N5zM'; // Exchange authorization code for an access token. $accessToken = $client->fetchAccessTokenWithAuthCode($authCode); $client->setAccessToken($accessToken); // Check to see if there was an error. if (array_key_exists('error', $accessToken)) { throw new Exception(join(', ', $accessToken)); } } // Save the token to a file. if (!file_exists(dirname($tokenPath))) { mkdir(dirname($tokenPath), 0777, true); } file_put_contents($tokenPath, json_encode($client->getAccessToken())); } return $client; } function goUpload(){ global $func,$CORE,$DB; $id = $CORE->input['file_id']; $file_name = $CORE->input['file_name']; $duration = $CORE->input['duration']; $thumb = $CORE->input['thumb']; $client = $this->getClient(); $service = new Google_Service_Drive($client); //Insert a file $file = new Google_Service_Drive_DriveFile(); $files_up = glob('cache/hls/*'); // get all file names $content_list = file_get_contents('cache/hls/filename_'.$id.'.m3u8'); foreach($files_up as $file_up){ // iterate files if(strpos($file_up,'output_720.mp4')===false && strpos($file_up,'filename_'.$id.'.m3u8')===false) { $file->setName(uniqid() . '.txt'); $file->setDescription('docs file'); $file->setMimeType('application/octet-stream'); $data = file_get_contents($file_up); $createdFile = $service->files->create($file, array( 'data' => $data, 'mimeType' => 'application/octet-stream', 'uploadType' => 'multipart' )); $id_return = $createdFile->id; $content_list = str_replace(basename($file_up),'https://st1.123vid.net/ts.php?id='.bin2hex($func->str_encode($id_return, 'ngocgiac')),$content_list); //$ob_id = json_decode($createdFile); if(is_file($file_up)) { unlink($file_up); } } flush(); ob_flush(); } $month_now = date('m-Y'); if(!is_dir("cache/hls/".$month_now."/")) { mkdir("cache/hls/".$month_now."/"); } if(!file_exists('cache/hls/'.$month_now.'/new_'.$id.'.m3u8')){ file_put_contents('cache/hls/'.$month_now.'/new_'.$id.'.m3u8', $content_list); } unlink('cache/hls/filename_'.$id.'.m3u8'); $arr['status'] = 'ok'; $arr['path'] = 'cache/hls/'.$month_now.'/new_'.$id.'.m3u8'; $arr['thumb'] = $thumb; $file_name = str_ireplace('.mp4','',$file_name); if(!empty($file_name) and !empty($thumb)) { $row_check = $DB->fetch_row($DB->query("SELECT * FROM gtdesign_video WHERE `play` = '" .$arr['path'] . "'")); if (!$row_check) { $DB->query("INSERT INTO `gtdesign_video` (`uid`,`theloai`, `title`, `img`, `play`, `des`, `duration`, `user_post`, `hit`, `time`, `status`) VALUES ('".$_SESSION['user_id']."','0', '" . $file_name . "', '" . $thumb . "', '" . $arr['path'] . "', '', '" . $duration . "', '" . $_SESSION['user_id'] . "', '1', '" . time() . "', '0');"); $arr['id_new'] = $DB->insert_id(); } else { $arr['id_new'] = $row_check['id']; } } /*echo json_encode([ 'status' => 'ok', 'path' => $createdFile ]);*/ echo json_encode($arr); exit(); } function make_ts(){ global $func,$CORE; $id = $CORE->input['file_id']; $file_name = $CORE->input['file_name']; $duration = $CORE->input['duration']; $thumb = $CORE->input['thumb']; ob_end_flush(); ob_start(); $out3 = shell_exec('ffmpeg -i /var/www/html/vidoe.top/cache/tmp.mp4 -codec: copy -bsf:v h264_mp4toannexb -start_number 0 -hls_time 20 -hls_list_size 0 -f hls /var/www/html/vidoe.top/cache/hls/filename_'.$id.'.m3u8'); $arr['status'] = 'ok'; $arr['file_name'] = $file_name; $arr['duration'] = $duration; $arr['thumb'] = $thumb; echo json_encode($arr); exit(); } function goLocal(){ set_time_limit(0); ob_end_flush(); ob_start(); $month_now = date('m-Y'); if(!is_dir("cache/thumb/".$month_now."/")) { mkdir("cache/thumb/".$month_now."/"); } /*$out1 = shell_exec('ffmpeg -i '.$_FILES['file']['tmp_name'].' /var/www/html/vidoe.top/cache/hls/output_720.mp4 -hide_banner');*/ $filepath = 'cache/tmp.mp4'; if (!move_uploaded_file($_FILES['file']['tmp_name'],$filepath )) { throw new RuntimeException('Failed to move uploaded file.'); } include('lib/getid3/getid3.php'); $getID3 = new getID3; $file_du = $getID3->analyze($filepath); $time_total_s = intval($file_du['playtime_seconds']); $second_f = rand(1,$time_total_s); flush(); ob_flush(); $out2 = shell_exec('ffmpeg -i /var/www/html/vidoe.top/cache/tmp.mp4 -vframes 1 -an -s 686x386 -ss '.$second_f.' /var/www/html/vidoe.top/cache/thumb/'.$month_now.'/tmp-'.md5($_FILES['file']['name']).'.jpg'); flush(); ob_flush(); $arr_res['status'] = 'ok'; $arr_res['thumb'] = 'cache/thumb/'.$month_now.'/tmp-'.md5($_FILES['file']['name']).'.jpg'; $arr_res['file_name'] = $_FILES['file']['name']; $arr_res['duration'] = $file_du['playtime_string']; echo json_encode($arr_res); exit(); $out3 = shell_exec('ffmpeg -i /var/www/html/vidoe.top/cache/hls/output_720.mp4 -codec: copy -bsf:v h264_mp4toannexb -start_number 0 -hls_time 20 -hls_list_size 0 -f hls /var/www/html/vidoe.top/cache/hls/filename.m3u8'); echo json_encode([ 'status' => 'ok', 'path' => 'cache/hls/filename.m3u8', 'thumb' => 'cache/tmp_720.jpg' ]); exit(); $client = $this->getClient(); $service = new Google_Service_Drive($client); //Insert a file $file = new Google_Service_Drive_DriveFile(); $files_up = glob('cache/hls/*'); // get all file names $content_list = file_get_contents('cache/hls/filename.m3u8'); foreach($files_up as $file_up){ // iterate files if(strpos($file_up,'output_720.mp4')===false && strpos($file_up,'filename.m3u8')===false) { $file->setName(uniqid() . '.txt'); $file->setDescription('docs file'); $file->setMimeType('application/octet-stream'); $data = file_get_contents($file_up); $createdFile = $service->files->create($file, array( 'data' => $data, 'mimeType' => 'application/octet-stream', 'uploadType' => 'multipart' )); $id = $createdFile->id; $content_list = str_replace(basename($file_up),'https://st1.123vid.net/ts.php?id='.bin2hex($func->str_encode($id, 'ngocgiac')),$content_list); //$ob_id = json_decode($createdFile); //unlink($file_up); echo json_encode([ 'status' => 'ok', 'path' => $file_up, 'id' => $createdFile->id ]); } flush(); ob_flush(); } if(!file_exists('cache/hls/new.m3u8')){ file_put_contents('cache/hls/new.m3u8', $content_list); } /*echo json_encode([ 'status' => 'ok', 'path' => $createdFile ]);*/ exit(); $file->setName(uniqid() . '.mp4'); $file->setDescription($_FILES['file']['name']); $file->setMimeType('video/mp4'); $data = file_get_contents('cache/output_720.mp4'); $createdFile = $service->files->create($file, array( 'data' => $data, 'mimeType' => 'video/mp4', 'uploadType' => 'multipart' )); $created_file = json_decode($createdFile); echo json_encode([ 'status' => 'ok', 'path' => $created_file->id ]); exit(); exit(); print_r($createdFile); /*$url = $api->uploadFile($_FILES['file']['tmp_name']); $post = $api->post( '/videos', array( 'url' => $url, 'title' => 'Dailymotion PHP SDK upload test', 'tags' => 'dailymotion,api,sdk,test', 'channel' => 'videogames', 'published' => true, ) ); if(isset($post['id']) && $post['id']!=''){ echo json_encode([ 'status' => 'ok', 'path' => $post['id'] ]); }else{ echo json_encode([ 'status' => 'error', 'thumb' => $_FILES['file']['name'], 'message' => $out ]); }*/ exit(); print_r($post); exit(); exit($upload_url); echo $upload_url; exit(); try { if ( !isset($_FILES['file']['error']) || is_array($_FILES['file']['error']) ) { throw new RuntimeException('Invalid parameters.'); } switch ($_FILES['file']['error']) { case UPLOAD_ERR_OK: break; case UPLOAD_ERR_NO_FILE: throw new RuntimeException('No file sent.'); case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: throw new RuntimeException('Exceeded filesize limit.'); default: throw new RuntimeException('Unknown errors.'); } $filepath = sprintf('files/%s_%s', uniqid(), $_FILES['file']['name']); if (!move_uploaded_file( $_FILES['file']['tmp_name'], $filepath )) { throw new RuntimeException('Failed to move uploaded file.'); } // All good, send the response echo json_encode([ 'status' => 'ok', 'path' => $filepath ]); exit(); } catch (RuntimeException $e) { // Something went wrong, send the err message as JSON http_response_code(400); echo json_encode([ 'status' => 'error', 'message' => $e->getMessage() ]); exit(); } } function goList(){ global $smarty,$DB,$func,$INFO,$print; $print->refresh('?act=user&code=upload_video'); exit(); $row_user = $DB->fetch_row($DB->query("SELECT id,fullname FROM gtdesign_user WHERE id = '".$_SESSION['user_id']."' ")); $smarty->assign('user',$row_user); $smarty->assign('title','Video upload'); if($_SESSION['lang'] != 'vi') { $smarty->assign('title', 'Local upload'); $smarty->assign('description','Watch free hd movies fast, fastest video updates, latest. Create a free video channel no ads. The world of movies, films, videos for everyone.'); }else{ $smarty->assign('title', 'Local upload'); $smarty->assign('description','Xem phim hd miá»…n phà tốc Ä‘á»™ nhanh, video cáºp nháºt nhanh nhất, má»›i nhất. Tạo kênh video miá»…n phà không quảng cáo. Thế giá»›i nghe nhìn cho má»i ngÆ°á»i.'); } $smarty->assign('cur_url',$func->current_url()); $smarty->assign('keywords','drama,movie,video'); $smarty->assign('image',$INFO['home_url'].'skin/'.$INFO['skin_folder'].'/img/vidoe-logo.png'); } }//end class // Run class $run = new upload(); ?>