| Server IP : 104.21.17.213 / Your IP : 216.73.217.141 Web Server : Apache System : Linux hosting01.arsenalhost.com 4.18.0-425.13.1.lve.el8.x86_64 #1 SMP Mon Feb 27 15:23:24 EST 2023 x86_64 User : corbizre ( 1013) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/corbizre/findnextproperty.com/frontend/controllers/ |
Upload File : |
<?php
namespace frontend\controllers;
use console\models\Housestable;
use Yii;
use yii\helpers\FileHelper;
use yii\web\Controller;
class VideoController extends Controller
{
const TOKEN = '77a854d36b7193981ec12f21f71d4880b6c7395d69bd6ee6601761338c5c3dee2a3dc7ff74cf6c61fe00ecfc3b5ad9e028a8e1b588dcf76400256992b36b9aaf';
const URL = 'http://144.76.33.130/help/api/v2';
public function actionStep1()
{
//$json = $this->prepareJsonFile();
//$data = $json;
//vd($json,false);
$data = file_get_contents(Yii::getAlias('@json') . '/test_json.txt');
$task_file = Yii::getAlias('@json') . '/tasks.txt';
$ch = curl_init('http://144.76.33.130/api/v2/tasks/create');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
$result = curl_exec($ch);
$otvet = json_decode($result, true);
curl_close($ch);
vd($otvet, false);
$taskId = $otvet['task'];
//vd('Task id: ' . $taskId, false);
file_put_contents($task_file, $taskId);
}
public function actionStep2()
{
$task = file_get_contents(Yii::getAlias('@json') . '/tasks.txt');
//vd($task);
$data = '{
"token":"77a854d36b7193981ec12f21f71d4880b6c7395d69bd6ee6601761338c5c3dee2a3dc7ff74cf6c61fe00ecfc3b5ad9e028a8e1b588dcf76400256992b36b9aaf",
"task":"' . $task . '"
}';
$ch = curl_init('http://144.76.33.130/api/v2/tasks');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data))
);
$result = curl_exec($ch);
$json = json_decode($result);
vd($json, false);
if($json->status == 3){
echo "error code = " . 'Не готово.. ждите!', PHP_EOL;
}else{
$urlUpload = $json->result[0]->url;
vd($urlUpload, false);
$destination_dir = yii::getAlias('@frontend') . '/web/static/video';
FileHelper::createDirectory($destination_dir);
$command = 'wget -P ' . $destination_dir . '/ ' . $urlUpload;
echo $command;
exec($command, $out, $result);
if ($result == 0) {
echo 'success' . PHP_EOL;
} else {
echo "error code= " . $result, PHP_EOL;
}
}
}
public function prepareJsonFile()
{
// ToDo получить список фоток и сформировать json file
//$model = Housestable::getHouseImages();
$json = '{
"token":"77a854d36b7193981ec12f21f71d4880b6c7395d69bd6ee6601761338c5c3dee2a3dc7ff74cf6c61fe00ecfc3b5ad9e028a8e1b588dcf76400256992b36b9aaf",
"options":{"resolution":"1200x480"},
"source":
[
{
"type":"image",
"url":"http:\/\/findnextproperty.com\/slider\/index",
"params":{"position":0,"duration":15}
},
]
}';
return $json;
}
}