1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00
This commit is contained in:
Daniel Neto 2023-03-20 16:37:36 -03:00
parent fa395eadfa
commit d8a0397c7e
6 changed files with 167 additions and 32 deletions

View file

@ -356,6 +356,11 @@ function base64DataToImage($imgBase64)
return base64_decode($img);
}
function saveBase64DataToPNGImage($imgBase64, $filePath){
$fileData = base64DataToImage($imgBase64);
return _file_put_contents($filePath, $fileData);
}
function getRealIpAddr()
{
if (isCommandLineInterface()) {
@ -9046,6 +9051,9 @@ function listAllWordsToTranslate()
function secondsInterval($time1, $time2)
{
if(!isset($time1) || !isset($time2)){
return 0;
}
if (!is_numeric($time1)) {
$time1 = strtotime($time1);
}

View file

@ -232,8 +232,7 @@ class sqlDAL
" preparedStatement = " . json_encode($preparedStatement) .
" formats = " . json_encode($formats) .
" values = " . json_encode($values) .
" refreshCache = " . json_encode($refreshCache) .
" stmt = " . json_encode($stmt));
" refreshCache = " . json_encode($refreshCache));
//log_error("[sqlDAL::readSql] trying close and reconnect");
_mysql_close();
_mysql_connect();

View file

@ -604,7 +604,8 @@ class API extends PluginAbstract {
$rows[$key]['mp3'] = convertVideoToMP3FileIfNotExists($value['id']);
$rows[$key]['category_name'] = $value['category'];
$rows[$key]['category'] = array('name' => $rows[$key]['category_name']);
$rows[$key]['channel_name'] = User::_getChannelName($rows[$key]['users_id']);;
$rows[$key]['channel_name'] = User::_getChannelName($rows[$key]['users_id']);
;
}
if (User::isLogged()) {
@ -808,6 +809,130 @@ class API extends PluginAbstract {
}
}
/**
* @param string $parameters
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
* ['live_schedule_id' if you pass it will return a specific live_schedule record]
* 'user' username of the user that will like the video
* 'pass' password of the user that will like the video
* @return \ApiObject
*/
public function get_api_live_schedule($parameters) {
if (!User::canStream()) {
return new ApiObject("You cannot stream");
} else {
$users_id = User::getId();
$_POST['sort'] = array('scheduled_time'=>'DESC');
if (empty($parameters['live_schedule_id'])) {
$obj = Live_schedule::getAll($users_id);
} else {
$row = Live_schedule::getFromDb($parameters['live_schedule_id']);
if ($row['users_id'] != $users_id) {
return new ApiObject("This live schedule does not belong to you");
} else {
$obj = $row;
}
}
}
return new ApiObject("", false, $obj);
}
/**
* @param string $parameters
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
* ['live_schedule_id' if you pass it will return a specific live_schedule record]
* 'user' username of the user that will like the video
* 'pass' password of the user that will like the video
* @return \ApiObject
*/
public function set_api_live_schedule_delete($parameters) {
if (!User::canStream()) {
return new ApiObject("You cannot stream");
} else {
$users_id = User::getId();
if (empty($parameters['live_schedule_id'])) {
$obj = false;
} else {
$row = new Live_schedule($parameters['live_schedule_id']);
if ($row->getUsers_id() != $users_id) {
return new ApiObject("This live schedule does not belong to you");
} else {
$obj = $row->delete();
}
}
}
return new ApiObject("", false, $obj);
}
/**
* @param string $parameters
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
* ['live_servers_id' by default it is 0]
* ['live_schedule_id' if you pass it want to edit a specific record]
* ['base64PNGImageRegular' a png image base64 encoded]
* ['base64PNGImagePreRoll' a png image base64 encoded]
* ['base64PNGImagePostRoll' a png image base64 encoded]
* 'title'
* 'description'
* 'scheduled_time' pass it in the YYYY-mm-dd HH:ii:ss format
* 'status' a for active or i for inactive
* 'scheduled_password'
* 'user' username of the user that will like the video
* 'pass' password of the user that will like the video
* @return \ApiObject
*/
public function set_api_live_schedule($parameters) {
$id = 0;
if (!User::canStream()) {
return new ApiObject("You cannot stream");
} else {
$users_id = User::getId();
if (empty($parameters['live_schedule_id'])) {
$o = new Live_schedule(0);
} else {
$row = Live_schedule::getFromDb($parameters['live_schedule_id']);
if ($row['users_id'] != $users_id) {
return new ApiObject("This live schedule does not belong to you");
} else {
$o = new Live_schedule($parameters['live_schedule_id']);
}
}
if(empty($parameters['title'])){
return new ApiObject("Title cannot be empty");
}
if(empty($parameters['scheduled_time'])){
return new ApiObject("scheduled_time cannot be empty");
}
if(empty($parameters['status']) || $parameters['status'] !== 'i'){
$parameters['status'] = 'a';
}
$o->setTitle($parameters['title']);
$o->setDescription($parameters['description']);
$o->setUsers_id($users_id);
$o->setLive_servers_id(@$parameters['live_servers_id']);
$o->setScheduled_time($parameters['scheduled_time']);
$o->setStatus($parameters['status']);
$o->setScheduled_password($parameters['scheduled_password']);
$live_schedule_id = $o->save();
if($live_schedule_id){
if(!empty($parameters['base64PNGImageRegular'])){
$image = Live_schedule::getPosterPaths($live_schedule_id, Live::$posterType_regular);
saveBase64DataToPNGImage($parameters['base64PNGImageRegular'], $image['path']);
}
if(!empty($parameters['base64PNGImagePreRoll'])){
$image = Live_schedule::getPosterPaths($live_schedule_id, Live::$posterType_preroll);
saveBase64DataToPNGImage($parameters['base64PNGImagePreRoll'], $image['path']);
}
if(!empty($parameters['base64PNGImagePostRoll'])){
$image = Live_schedule::getPosterPaths($live_schedule_id, Live::$posterType_postroll);
saveBase64DataToPNGImage($parameters['base64PNGImagePostRoll'], $image['path']);
}
}
}
return new ApiObject("", empty($live_schedule_id), $live_schedule_id);
}
/**
* @param string $parameters
* 'videos_id' the video id that will be deleted

View file

@ -3899,6 +3899,9 @@ class LiveStreamObject {
}
}
$this->key = $parts['cleanKey'];
if(!isset($this->live_index)){
$this->live_index = '';
}
$this->live_index = preg_replace('/[^0-9a-z]/i', '',$this->live_index);
}
/**

View file

@ -144,7 +144,7 @@ class Live_schedule extends ObjectYPT
if(!preg_match('/order by/i', $sql)){
$sql .= ' ORDER BY scheduled_time ASC';
}
//echo $sql;exit;
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);

View file

@ -34,10 +34,10 @@ $o->setTitle($_POST['title']);
$o->setDescription($_POST['description']);
//$o->setKey($_POST['key']);
$o->setUsers_id(User::getId());
$o->setLive_servers_id($_POST['live_servers_id']);
$o->setScheduled_time($_POST['scheduled_time']);
$o->setStatus($_POST['status']);
$o->setScheduled_password($_POST['scheduled_password']);
$o->setLive_servers_id(@$_POST['live_servers_id']);
$o->setScheduled_time(@$_POST['scheduled_time']);
$o->setStatus(@$_POST['status']);
$o->setScheduled_password(@$_POST['scheduled_password']);
//$o->setPoster($_POST['poster']);
//$o->setPublic($_POST['public']);
//$o->setSaveTransmition($_POST['saveTransmition']);