mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 17:59:55 +02:00
udpates
This commit is contained in:
parent
fa395eadfa
commit
d8a0397c7e
6 changed files with 167 additions and 32 deletions
|
@ -356,6 +356,11 @@ function base64DataToImage($imgBase64)
|
||||||
return base64_decode($img);
|
return base64_decode($img);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveBase64DataToPNGImage($imgBase64, $filePath){
|
||||||
|
$fileData = base64DataToImage($imgBase64);
|
||||||
|
return _file_put_contents($filePath, $fileData);
|
||||||
|
}
|
||||||
|
|
||||||
function getRealIpAddr()
|
function getRealIpAddr()
|
||||||
{
|
{
|
||||||
if (isCommandLineInterface()) {
|
if (isCommandLineInterface()) {
|
||||||
|
@ -9046,6 +9051,9 @@ function listAllWordsToTranslate()
|
||||||
|
|
||||||
function secondsInterval($time1, $time2)
|
function secondsInterval($time1, $time2)
|
||||||
{
|
{
|
||||||
|
if(!isset($time1) || !isset($time2)){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (!is_numeric($time1)) {
|
if (!is_numeric($time1)) {
|
||||||
$time1 = strtotime($time1);
|
$time1 = strtotime($time1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,8 +232,7 @@ class sqlDAL
|
||||||
" preparedStatement = " . json_encode($preparedStatement) .
|
" preparedStatement = " . json_encode($preparedStatement) .
|
||||||
" formats = " . json_encode($formats) .
|
" formats = " . json_encode($formats) .
|
||||||
" values = " . json_encode($values) .
|
" values = " . json_encode($values) .
|
||||||
" refreshCache = " . json_encode($refreshCache) .
|
" refreshCache = " . json_encode($refreshCache));
|
||||||
" stmt = " . json_encode($stmt));
|
|
||||||
//log_error("[sqlDAL::readSql] trying close and reconnect");
|
//log_error("[sqlDAL::readSql] trying close and reconnect");
|
||||||
_mysql_close();
|
_mysql_close();
|
||||||
_mysql_connect();
|
_mysql_connect();
|
||||||
|
|
|
@ -33,11 +33,11 @@ class API extends PluginAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
$obj->hasMore = true;
|
$obj->hasMore = true;
|
||||||
if(!empty($obj->rows) && is_array($obj->rows)){
|
if (!empty($obj->rows) && is_array($obj->rows)) {
|
||||||
if (count($obj->rows) < $obj->rowCount) {
|
if (count($obj->rows) < $obj->rowCount) {
|
||||||
$obj->hasMore = false;
|
$obj->hasMore = false;
|
||||||
}
|
}
|
||||||
}else if(!empty($obj->videos) && is_array($obj->videos)){
|
} else if (!empty($obj->videos) && is_array($obj->videos)) {
|
||||||
if (count($obj->videos) < $obj->rowCount) {
|
if (count($obj->videos) < $obj->rowCount) {
|
||||||
$obj->hasMore = false;
|
$obj->hasMore = false;
|
||||||
}
|
}
|
||||||
|
@ -473,9 +473,9 @@ class API extends PluginAbstract {
|
||||||
public function get_api_video($parameters) {
|
public function get_api_video($parameters) {
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
|
|
||||||
$cacheParameters = array('noRelated','APIName', 'catName', 'rowCount', 'APISecret', 'sort', 'searchPhrase', 'current', 'tags_id', 'channelName', 'videoType', 'is_serie', 'user', 'videos_id', 'playlist');
|
$cacheParameters = array('noRelated', 'APIName', 'catName', 'rowCount', 'APISecret', 'sort', 'searchPhrase', 'current', 'tags_id', 'channelName', 'videoType', 'is_serie', 'user', 'videos_id', 'playlist');
|
||||||
|
|
||||||
$cacheVars = array('users_id'=>User::getId());
|
$cacheVars = array('users_id' => User::getId());
|
||||||
foreach ($cacheParameters as $value) {
|
foreach ($cacheParameters as $value) {
|
||||||
$cacheVars[$value] = @$_REQUEST[$value];
|
$cacheVars[$value] = @$_REQUEST[$value];
|
||||||
}
|
}
|
||||||
|
@ -600,11 +600,12 @@ class API extends PluginAbstract {
|
||||||
$rows[$key]['isSubscribed'] = false;
|
$rows[$key]['isSubscribed'] = false;
|
||||||
|
|
||||||
//make playlist compatible
|
//make playlist compatible
|
||||||
if(!empty($parameters['playlist'])){
|
if (!empty($parameters['playlist'])) {
|
||||||
$rows[$key]['mp3'] = convertVideoToMP3FileIfNotExists($value['id']);
|
$rows[$key]['mp3'] = convertVideoToMP3FileIfNotExists($value['id']);
|
||||||
$rows[$key]['category_name'] = $value['category'];
|
$rows[$key]['category_name'] = $value['category'];
|
||||||
$rows[$key]['category'] = array('name'=>$rows[$key]['category_name']);
|
$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()) {
|
if (User::isLogged()) {
|
||||||
|
@ -663,9 +664,9 @@ class API extends PluginAbstract {
|
||||||
}
|
}
|
||||||
$obj->totalRows = $totalRows;
|
$obj->totalRows = $totalRows;
|
||||||
|
|
||||||
if(!empty($parameters['playlist'])){
|
if (!empty($parameters['playlist'])) {
|
||||||
$obj->videos = $rows;
|
$obj->videos = $rows;
|
||||||
}else{
|
} else {
|
||||||
$obj->rows = $rows;
|
$obj->rows = $rows;
|
||||||
}
|
}
|
||||||
$obj = self::addRowInfo($obj);
|
$obj = self::addRowInfo($obj);
|
||||||
|
@ -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
|
* @param string $parameters
|
||||||
* 'videos_id' the video id that will be deleted
|
* 'videos_id' the video id that will be deleted
|
||||||
|
@ -1836,7 +1961,7 @@ class SectionFirstPage {
|
||||||
$this->nextEndpoint = addQueryStringParameter($endpoint, 'current', 2);
|
$this->nextEndpoint = addQueryStringParameter($endpoint, 'current', 2);
|
||||||
$this->rowCount = $rowCount;
|
$this->rowCount = $rowCount;
|
||||||
$endpointURL = addQueryStringParameter($endpoint, 'rowCount', $rowCount);
|
$endpointURL = addQueryStringParameter($endpoint, 'rowCount', $rowCount);
|
||||||
if(User::isLogged()){
|
if (User::isLogged()) {
|
||||||
|
|
||||||
$endpointURL = addQueryStringParameter($endpointURL, 'user', User::getUserName());
|
$endpointURL = addQueryStringParameter($endpointURL, 'user', User::getUserName());
|
||||||
$endpointURL = addQueryStringParameter($endpointURL, 'pass', User::getUserPass());
|
$endpointURL = addQueryStringParameter($endpointURL, 'pass', User::getUserPass());
|
||||||
|
|
|
@ -3899,7 +3899,10 @@ class LiveStreamObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->key = $parts['cleanKey'];
|
$this->key = $parts['cleanKey'];
|
||||||
$this->live_index = preg_replace('/[^0-9a-z]/i', '', $this->live_index);
|
if(!isset($this->live_index)){
|
||||||
|
$this->live_index = '';
|
||||||
|
}
|
||||||
|
$this->live_index = preg_replace('/[^0-9a-z]/i', '',$this->live_index);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
|
|
|
@ -144,7 +144,7 @@ class Live_schedule extends ObjectYPT
|
||||||
if(!preg_match('/order by/i', $sql)){
|
if(!preg_match('/order by/i', $sql)){
|
||||||
$sql .= ' ORDER BY scheduled_time ASC';
|
$sql .= ' ORDER BY scheduled_time ASC';
|
||||||
}
|
}
|
||||||
|
//echo $sql;exit;
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
|
|
|
@ -34,10 +34,10 @@ $o->setTitle($_POST['title']);
|
||||||
$o->setDescription($_POST['description']);
|
$o->setDescription($_POST['description']);
|
||||||
//$o->setKey($_POST['key']);
|
//$o->setKey($_POST['key']);
|
||||||
$o->setUsers_id(User::getId());
|
$o->setUsers_id(User::getId());
|
||||||
$o->setLive_servers_id($_POST['live_servers_id']);
|
$o->setLive_servers_id(@$_POST['live_servers_id']);
|
||||||
$o->setScheduled_time($_POST['scheduled_time']);
|
$o->setScheduled_time(@$_POST['scheduled_time']);
|
||||||
$o->setStatus($_POST['status']);
|
$o->setStatus(@$_POST['status']);
|
||||||
$o->setScheduled_password($_POST['scheduled_password']);
|
$o->setScheduled_password(@$_POST['scheduled_password']);
|
||||||
//$o->setPoster($_POST['poster']);
|
//$o->setPoster($_POST['poster']);
|
||||||
//$o->setPublic($_POST['public']);
|
//$o->setPublic($_POST['public']);
|
||||||
//$o->setSaveTransmition($_POST['saveTransmition']);
|
//$o->setSaveTransmition($_POST['saveTransmition']);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue