mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-06 03:50:04 +02:00
Refactor some plugins code.
This commit is contained in:
parent
ab8fd13a56
commit
43c00721ca
223 changed files with 12595 additions and 11447 deletions
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://support.google.com/adsense/answer/4455881
|
* https://support.google.com/adsense/answer/4455881
|
||||||
* https://support.google.com/adsense/answer/1705822
|
* https://support.google.com/adsense/answer/1705822
|
||||||
|
@ -10,34 +9,40 @@ global $global;
|
||||||
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaigns.php';
|
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaigns.php';
|
||||||
|
|
||||||
class AD_Server extends PluginAbstract {
|
class AD_Server extends PluginAbstract
|
||||||
|
{
|
||||||
public function getTags() {
|
public function getTags()
|
||||||
return array(
|
{
|
||||||
|
return [
|
||||||
PluginTags::$MONETIZATION,
|
PluginTags::$MONETIZATION,
|
||||||
PluginTags::$ADS,
|
PluginTags::$ADS,
|
||||||
PluginTags::$FREE,
|
PluginTags::$FREE,
|
||||||
PluginTags::$PLAYER,
|
PluginTags::$PLAYER,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription() {
|
public function getDescription()
|
||||||
|
{
|
||||||
return "VAST Ad Server<br><small><a href='https://github.com/WWBN/AVideo/wiki/Ad-Server-Plugin' target='__blank'><i class='fas fa-question-circle'></i> Help</a></small>";
|
return "VAST Ad Server<br><small><a href='https://github.com/WWBN/AVideo/wiki/Ad-Server-Plugin' target='__blank'><i class='fas fa-question-circle'></i> Help</a></small>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return "AD_Server";
|
return "AD_Server";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUUID() {
|
public function getUUID()
|
||||||
|
{
|
||||||
return "3f2a707f-3c06-4b78-90f9-a22f2fda92ef";
|
return "3f2a707f-3c06-4b78-90f9-a22f2fda92ef";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginVersion() {
|
public function getPluginVersion()
|
||||||
|
{
|
||||||
return "1.0";
|
return "1.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmptyDataObject() {
|
public function getEmptyDataObject()
|
||||||
|
{
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->start = true;
|
$obj->start = true;
|
||||||
self::addDataObjectHelper('start', 'Show Pre-Roll ads');
|
self::addDataObjectHelper('start', 'Show Pre-Roll ads');
|
||||||
|
@ -51,7 +56,7 @@ class AD_Server extends PluginAbstract {
|
||||||
self::addDataObjectHelper('end', 'Show Post-Roll ads');
|
self::addDataObjectHelper('end', 'Show Post-Roll ads');
|
||||||
|
|
||||||
$o = new stdClass();
|
$o = new stdClass();
|
||||||
$o->type = array();
|
$o->type = [];
|
||||||
for ($i = 0; $i <= 100; $i++) {
|
for ($i = 0; $i <= 100; $i++) {
|
||||||
$o->type[$i . '%'] = "The skip button will appear when you watch {$i}% of the video";
|
$o->type[$i . '%'] = "The skip button will appear when you watch {$i}% of the video";
|
||||||
}
|
}
|
||||||
|
@ -63,7 +68,7 @@ class AD_Server extends PluginAbstract {
|
||||||
self::addDataObjectHelper('showMarkers', 'Show Markers', 'Check it if you want to show the yellow markers on the video, where the advertising should appear');
|
self::addDataObjectHelper('showMarkers', 'Show Markers', 'Check it if you want to show the yellow markers on the video, where the advertising should appear');
|
||||||
|
|
||||||
$o = new stdClass();
|
$o = new stdClass();
|
||||||
$o->type = array(1 => 'Every video');
|
$o->type = [1 => 'Every video'];
|
||||||
for ($i = 2; $i < 10; $i++) {
|
for ($i = 2; $i < 10; $i++) {
|
||||||
$o->type[$i] = "Show ads on each {$i} videos";
|
$o->type[$i] = "Show ads on each {$i} videos";
|
||||||
}
|
}
|
||||||
|
@ -72,7 +77,7 @@ class AD_Server extends PluginAbstract {
|
||||||
self::addDataObjectHelper('showAdsOnEachVideoView', 'Show Ads on', 'This defines how often advertisements will appear, for example: if it is set to 2, you will see ads each 2 videos, but if it is set to 1 you will see ads on every video');
|
self::addDataObjectHelper('showAdsOnEachVideoView', 'Show Ads on', 'This defines how often advertisements will appear, for example: if it is set to 2, you will see ads each 2 videos, but if it is set to 1 you will see ads on every video');
|
||||||
|
|
||||||
$o = new stdClass();
|
$o = new stdClass();
|
||||||
$o->type = array(0 => 'All positions');
|
$o->type = [0 => 'All positions'];
|
||||||
for ($i = 1; $i < 5; $i++) {
|
for ($i = 1; $i < 5; $i++) {
|
||||||
$o->type[$i] = "Show ads on {$i} random positions";
|
$o->type[$i] = "Show ads on {$i} random positions";
|
||||||
}
|
}
|
||||||
|
@ -83,9 +88,9 @@ class AD_Server extends PluginAbstract {
|
||||||
|
|
||||||
|
|
||||||
$o = new stdClass();
|
$o = new stdClass();
|
||||||
$o->type = array(0 => 'Do not auto add new videos on campaign');
|
$o->type = [0 => 'Do not auto add new videos on campaign'];
|
||||||
$rows = VastCampaigns::getAllActive();
|
$rows = VastCampaigns::getAllActive();
|
||||||
if(!is_array($rows)){
|
if (!is_array($rows)) {
|
||||||
$o->value = 0;
|
$o->value = 0;
|
||||||
$obj->autoAddNewVideosInCampaignId = $o;
|
$obj->autoAddNewVideosInCampaignId = $o;
|
||||||
return $obj;
|
return $obj;
|
||||||
|
@ -100,7 +105,8 @@ class AD_Server extends PluginAbstract {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function afterNewVideo($videos_id) {
|
public function afterNewVideo($videos_id)
|
||||||
|
{
|
||||||
_error_log("AD_Server:afterNewVideo start");
|
_error_log("AD_Server:afterNewVideo start");
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
if (!empty($obj->autoAddNewVideosInCampaignId)) {
|
if (!empty($obj->autoAddNewVideosInCampaignId)) {
|
||||||
|
@ -129,7 +135,8 @@ class AD_Server extends PluginAbstract {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function canLoadAds() {
|
public function canLoadAds()
|
||||||
|
{
|
||||||
//if (empty($_GET['videoName']) && empty($_GET['u'])) {
|
//if (empty($_GET['videoName']) && empty($_GET['u'])) {
|
||||||
$videos_id = getVideos_id();
|
$videos_id = getVideos_id();
|
||||||
if (!empty($videos_id)) {
|
if (!empty($videos_id)) {
|
||||||
|
@ -161,7 +168,8 @@ class AD_Server extends PluginAbstract {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeadCode() {
|
public function getHeadCode()
|
||||||
|
{
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
if (!$this->canLoadAds()) {
|
if (!$this->canLoadAds()) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -179,7 +187,8 @@ class AD_Server extends PluginAbstract {
|
||||||
return $css;
|
return $css;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getVideoLength() {
|
private static function getVideoLength()
|
||||||
|
{
|
||||||
$video_length = 3600; // 1 hour
|
$video_length = 3600; // 1 hour
|
||||||
$videos_id = getVideos_id();
|
$videos_id = getVideos_id();
|
||||||
$video = new Video('', '', $videos_id);
|
$video = new Video('', '', $videos_id);
|
||||||
|
@ -190,7 +199,8 @@ class AD_Server extends PluginAbstract {
|
||||||
return $video_length;
|
return $video_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getVMAPSFromRequest() {
|
public static function getVMAPSFromRequest()
|
||||||
|
{
|
||||||
if (!empty($_REQUEST['vmaps'])) {
|
if (!empty($_REQUEST['vmaps'])) {
|
||||||
$vmaps = _json_decode(base64_decode($_REQUEST['vmaps']));
|
$vmaps = _json_decode(base64_decode($_REQUEST['vmaps']));
|
||||||
} else {
|
} else {
|
||||||
|
@ -201,7 +211,8 @@ class AD_Server extends PluginAbstract {
|
||||||
return object_to_array($vmaps);
|
return object_to_array($vmaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function addVMAPS($url, $vmaps) {
|
public static function addVMAPS($url, $vmaps)
|
||||||
|
{
|
||||||
if (empty($vmaps)) {
|
if (empty($vmaps)) {
|
||||||
$vmaps = self::getVMAPSFromRequest();
|
$vmaps = self::getVMAPSFromRequest();
|
||||||
}
|
}
|
||||||
|
@ -210,8 +221,8 @@ class AD_Server extends PluginAbstract {
|
||||||
return $vmapURL;
|
return $vmapURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function afterVideoJS() {
|
public function afterVideoJS()
|
||||||
|
{
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
if (!$this->canLoadAds() || empty($_GET['vmap_id'])) {
|
if (!$this->canLoadAds() || empty($_GET['vmap_id'])) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -246,7 +257,7 @@ class AD_Server extends PluginAbstract {
|
||||||
foreach ($vmaps as $value) {
|
foreach ($vmaps as $value) {
|
||||||
$vastCampaingVideos = new VastCampaignsVideos($value['VAST']['campaing']);
|
$vastCampaingVideos = new VastCampaignsVideos($value['VAST']['campaing']);
|
||||||
$video = new Video("", "", $vastCampaingVideos->getVideos_id());
|
$video = new Video("", "", $vastCampaingVideos->getVideos_id());
|
||||||
if(!empty($video_length) && $value['timeOffsetSeconds'] >= $video_length){
|
if (!empty($video_length) && $value['timeOffsetSeconds'] >= $video_length) {
|
||||||
$value['timeOffsetSeconds'] = $video_length-5;
|
$value['timeOffsetSeconds'] = $video_length-5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,8 +279,8 @@ class AD_Server extends PluginAbstract {
|
||||||
return $js;
|
return $js;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getRandomPositions() {
|
private function getRandomPositions()
|
||||||
|
{
|
||||||
if (empty($_GET['vmap_id'])) {
|
if (empty($_GET['vmap_id'])) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -282,7 +293,7 @@ class AD_Server extends PluginAbstract {
|
||||||
if (session_status() == PHP_SESSION_NONE) {
|
if (session_status() == PHP_SESSION_NONE) {
|
||||||
session_start();
|
session_start();
|
||||||
}
|
}
|
||||||
$options = array();
|
$options = [];
|
||||||
|
|
||||||
if (!empty($obj->start)) {
|
if (!empty($obj->start)) {
|
||||||
$options[] = 1;
|
$options[] = 1;
|
||||||
|
@ -300,7 +311,7 @@ class AD_Server extends PluginAbstract {
|
||||||
$options[] = 5;
|
$options[] = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
$selectedOptions = array();
|
$selectedOptions = [];
|
||||||
if (empty($_SESSION['lastAdRandomPositions']) || $_SESSION['lastAdRandomPositions'] + 20 <= time()) {
|
if (empty($_SESSION['lastAdRandomPositions']) || $_SESSION['lastAdRandomPositions'] + 20 <= time()) {
|
||||||
$_SESSION['lastAdRandomPositions'] = time();
|
$_SESSION['lastAdRandomPositions'] = time();
|
||||||
|
|
||||||
|
@ -327,8 +338,9 @@ class AD_Server extends PluginAbstract {
|
||||||
return $adRandomPositions;
|
return $adRandomPositions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVMAPs($video_length) {
|
public function getVMAPs($video_length)
|
||||||
$vmaps = array();
|
{
|
||||||
|
$vmaps = [];
|
||||||
|
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
|
|
||||||
|
@ -356,7 +368,8 @@ class AD_Server extends PluginAbstract {
|
||||||
return $vmaps;
|
return $vmaps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function VMAPsHasVideos() {
|
public function VMAPsHasVideos()
|
||||||
|
{
|
||||||
$vmaps = $this->getVMAPs(100);
|
$vmaps = $this->getVMAPs(100);
|
||||||
//var_dump($vmaps);exit;
|
//var_dump($vmaps);exit;
|
||||||
foreach ($vmaps as $value) {
|
foreach ($vmaps as $value) {
|
||||||
|
@ -367,61 +380,67 @@ class AD_Server extends PluginAbstract {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function showAdsNow() {
|
public function showAdsNow()
|
||||||
|
{
|
||||||
if (!$this->VMAPsHasVideos()) {
|
if (!$this->VMAPsHasVideos()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getVideos() {
|
public static function getVideos()
|
||||||
|
{
|
||||||
$campaings = VastCampaigns::getValidCampaigns();
|
$campaings = VastCampaigns::getValidCampaigns();
|
||||||
//var_dump($campaings);
|
//var_dump($campaings);
|
||||||
$videos = array();
|
$videos = [];
|
||||||
foreach ($campaings as $key => $value) {
|
foreach ($campaings as $key => $value) {
|
||||||
$v = VastCampaignsVideos::getValidVideos($value['id']);
|
$v = VastCampaignsVideos::getValidVideos($value['id']);
|
||||||
$videos = array_merge($videos, $v);
|
$videos = array_merge($videos, $v);
|
||||||
$campaings[$key]['videos'] = $v;
|
$campaings[$key]['videos'] = $v;
|
||||||
}
|
}
|
||||||
return array('campaigns' => $campaings, 'videos' => $videos);
|
return ['campaigns' => $campaings, 'videos' => $videos];
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getRandomVideo() {
|
public static function getRandomVideo()
|
||||||
|
{
|
||||||
$result = static::getVideos();
|
$result = static::getVideos();
|
||||||
$videos = $result['videos'];
|
$videos = $result['videos'];
|
||||||
shuffle($videos);
|
shuffle($videos);
|
||||||
return array_pop($videos);
|
return array_pop($videos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getRandomCampaign() {
|
public static function getRandomCampaign()
|
||||||
|
{
|
||||||
$result = static::getVideos();
|
$result = static::getVideos();
|
||||||
$campaing = $result['campaigns'];
|
$campaing = $result['campaigns'];
|
||||||
shuffle($campaing);
|
shuffle($campaing);
|
||||||
return array_pop($campaing);
|
return array_pop($campaing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginMenu() {
|
public function getPluginMenu()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$filename = $global['systemRootPath'] . 'plugin/AD_Server/pluginMenu.html';
|
$filename = $global['systemRootPath'] . 'plugin/AD_Server/pluginMenu.html';
|
||||||
return file_get_contents($filename);
|
return file_get_contents($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValidCampaignsFromVideo($videos_id) {
|
public function getValidCampaignsFromVideo($videos_id)
|
||||||
|
{
|
||||||
return VastCampaigns::getValidCampaignsFromVideo($videos_id);
|
return VastCampaigns::getValidCampaignsFromVideo($videos_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class VMAP {
|
class VMAP
|
||||||
|
{
|
||||||
public $timeOffset;
|
public $timeOffset;
|
||||||
public $timeOffsetSeconds;
|
public $timeOffsetSeconds;
|
||||||
public $VAST;
|
public $VAST;
|
||||||
public $idTag = "preroll-ad";
|
public $idTag = "preroll-ad";
|
||||||
|
|
||||||
function __construct($time, VAST $VAST, $video_length = 0) {
|
public function __construct($time, VAST $VAST, $video_length = 0)
|
||||||
|
{
|
||||||
if ($time === 'start') {
|
if ($time === 'start') {
|
||||||
$this->timeOffsetSeconds = 0;
|
$this->timeOffsetSeconds = 0;
|
||||||
} else if ($time === 'end') {
|
} elseif ($time === 'end') {
|
||||||
$this->timeOffsetSeconds = $video_length;
|
$this->timeOffsetSeconds = $video_length;
|
||||||
} else {
|
} else {
|
||||||
$this->timeOffsetSeconds = $time;
|
$this->timeOffsetSeconds = $time;
|
||||||
|
@ -430,16 +449,17 @@ class VMAP {
|
||||||
$this->setTimeOffset($time);
|
$this->setTimeOffset($time);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTimeOffset($time) {
|
public function setTimeOffset($time)
|
||||||
|
{
|
||||||
if (empty($time)) {
|
if (empty($time)) {
|
||||||
//$time = "start";
|
//$time = "start";
|
||||||
}
|
}
|
||||||
// if is longer then the video length will be END
|
// if is longer then the video length will be END
|
||||||
if (empty($time) || $time == "start") {
|
if (empty($time) || $time == "start") {
|
||||||
$this->idTag = "preroll-ad-" . $this->VAST->id;
|
$this->idTag = "preroll-ad-" . $this->VAST->id;
|
||||||
} else if ($time == "end") {
|
} elseif ($time == "end") {
|
||||||
$this->idTag = "postroll-ad-" . $this->VAST->id;
|
$this->idTag = "postroll-ad-" . $this->VAST->id;
|
||||||
} else if (is_numeric($time)) {
|
} elseif (is_numeric($time)) {
|
||||||
$time = $this->format($time);
|
$time = $this->format($time);
|
||||||
$this->idTag = "midroll-" . $this->VAST->id;
|
$this->idTag = "midroll-" . $this->VAST->id;
|
||||||
}
|
}
|
||||||
|
@ -447,21 +467,22 @@ class VMAP {
|
||||||
$this->timeOffset = $time;
|
$this->timeOffset = $time;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function format($seconds) {
|
private function format($seconds)
|
||||||
|
{
|
||||||
$hours = floor($seconds / 3600);
|
$hours = floor($seconds / 3600);
|
||||||
$mins = floor($seconds / 60 % 60);
|
$mins = floor($seconds / 60 % 60);
|
||||||
$secs = floor($seconds % 60);
|
$secs = floor($seconds % 60);
|
||||||
return sprintf('%02d:%02d:%02d.000', $hours, $mins, $secs);
|
return sprintf('%02d:%02d:%02d.000', $hours, $mins, $secs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class VAST {
|
class VAST
|
||||||
|
{
|
||||||
public $id;
|
public $id;
|
||||||
public $campaing;
|
public $campaing;
|
||||||
|
|
||||||
function __construct($id) {
|
public function __construct($id)
|
||||||
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$row = AD_Server::getRandomVideo();
|
$row = AD_Server::getRandomVideo();
|
||||||
if (!empty($row)) {
|
if (!empty($row)) {
|
||||||
|
@ -470,5 +491,4 @@ class VAST {
|
||||||
$this->campaing = false;
|
$this->campaing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,168 +6,224 @@ require_once dirname(__FILE__) . '/../../../objects/user.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsVideos.php';
|
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsVideos.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsLogs.php';
|
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsLogs.php';
|
||||||
|
|
||||||
class VastCampaigns extends ObjectYPT {
|
class VastCampaigns extends ObjectYPT
|
||||||
|
{
|
||||||
|
protected $id;
|
||||||
|
protected $name;
|
||||||
|
protected $type;
|
||||||
|
protected $status;
|
||||||
|
protected $start_date;
|
||||||
|
protected $end_date;
|
||||||
|
protected $pricing_model;
|
||||||
|
protected $price;
|
||||||
|
protected $max_impressions;
|
||||||
|
protected $max_clicks;
|
||||||
|
protected $priority;
|
||||||
|
protected $users_id;
|
||||||
|
protected $visibility;
|
||||||
|
protected $cpc_budget_type;
|
||||||
|
protected $cpc_total_budget;
|
||||||
|
protected $cpc_max_price_per_click;
|
||||||
|
protected $cpm_max_prints;
|
||||||
|
protected $cpm_current_prints;
|
||||||
|
|
||||||
protected $id, $name, $type, $status, $start_date, $end_date, $pricing_model,
|
public static function getSearchFieldsNames()
|
||||||
$price, $max_impressions, $max_clicks, $priority, $users_id, $visibility, $cpc_budget_type, $cpc_total_budget, $cpc_max_price_per_click, $cpm_max_prints, $cpm_current_prints;
|
{
|
||||||
|
return ['name'];
|
||||||
static function getSearchFieldsNames() {
|
|
||||||
return array('name');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTableName() {
|
public static function getTableName()
|
||||||
|
{
|
||||||
return 'vast_campaigns';
|
return 'vast_campaigns';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() {
|
public function getType()
|
||||||
|
{
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatus() {
|
public function getStatus()
|
||||||
|
{
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStart_date() {
|
public function getStart_date()
|
||||||
|
{
|
||||||
return $this->start_date;
|
return $this->start_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEnd_date() {
|
public function getEnd_date()
|
||||||
|
{
|
||||||
return $this->end_date;
|
return $this->end_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPricing_model() {
|
public function getPricing_model()
|
||||||
|
{
|
||||||
return $this->pricing_model;
|
return $this->pricing_model;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPrice() {
|
public function getPrice()
|
||||||
|
{
|
||||||
return $this->price;
|
return $this->price;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMax_impressions() {
|
public function getMax_impressions()
|
||||||
|
{
|
||||||
return $this->max_impressions;
|
return $this->max_impressions;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMax_clicks() {
|
public function getMax_clicks()
|
||||||
|
{
|
||||||
return $this->max_clicks;
|
return $this->max_clicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPriority() {
|
public function getPriority()
|
||||||
|
{
|
||||||
return $this->priority;
|
return $this->priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsers_id() {
|
public function getUsers_id()
|
||||||
|
{
|
||||||
return $this->users_id;
|
return $this->users_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVisibility() {
|
public function getVisibility()
|
||||||
|
{
|
||||||
return $this->visibility;
|
return $this->visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCpc_budget_type() {
|
public function getCpc_budget_type()
|
||||||
|
{
|
||||||
return $this->cpc_budget_type;
|
return $this->cpc_budget_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCpc_total_budget() {
|
public function getCpc_total_budget()
|
||||||
|
{
|
||||||
return $this->cpc_total_budget;
|
return $this->cpc_total_budget;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCpc_max_price_per_click() {
|
public function getCpc_max_price_per_click()
|
||||||
|
{
|
||||||
return $this->cpc_max_price_per_click;
|
return $this->cpc_max_price_per_click;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCpm_max_prints() {
|
public function getCpm_max_prints()
|
||||||
|
{
|
||||||
return $this->cpm_max_prints;
|
return $this->cpm_max_prints;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCpm_current_prints() {
|
public function getCpm_current_prints()
|
||||||
|
{
|
||||||
return $this->cpm_current_prints;
|
return $this->cpm_current_prints;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPrintsLeft() {
|
public function getPrintsLeft()
|
||||||
|
{
|
||||||
return ($this->cpm_max_prints-$this->cpm_current_prints);
|
return ($this->cpm_max_prints-$this->cpm_current_prints);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setName($name) {
|
public function setName($name)
|
||||||
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setType($type) {
|
public function setType($type)
|
||||||
|
{
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStatus($status) {
|
public function setStatus($status)
|
||||||
|
{
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStart_date($start_date) {
|
public function setStart_date($start_date)
|
||||||
|
{
|
||||||
$this->start_date = $start_date;
|
$this->start_date = $start_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setEnd_date($end_date) {
|
public function setEnd_date($end_date)
|
||||||
|
{
|
||||||
$this->end_date = $end_date;
|
$this->end_date = $end_date;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPricing_model($pricing_model) {
|
public function setPricing_model($pricing_model)
|
||||||
|
{
|
||||||
$this->pricing_model = $pricing_model;
|
$this->pricing_model = $pricing_model;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPrice($price) {
|
public function setPrice($price)
|
||||||
|
{
|
||||||
$this->price = $price;
|
$this->price = $price;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMax_impressions($max_impressions) {
|
public function setMax_impressions($max_impressions)
|
||||||
|
{
|
||||||
$this->max_impressions = $max_impressions;
|
$this->max_impressions = $max_impressions;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMax_clicks($max_clicks) {
|
public function setMax_clicks($max_clicks)
|
||||||
|
{
|
||||||
$this->max_clicks = $max_clicks;
|
$this->max_clicks = $max_clicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPriority($priority) {
|
public function setPriority($priority)
|
||||||
|
{
|
||||||
$this->priority = $priority;
|
$this->priority = $priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUsers_id($users_id) {
|
public function setUsers_id($users_id)
|
||||||
|
{
|
||||||
$this->users_id = $users_id;
|
$this->users_id = $users_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVisibility($visibility) {
|
public function setVisibility($visibility)
|
||||||
|
{
|
||||||
$this->visibility = $visibility;
|
$this->visibility = $visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCpc_budget_type($cpc_budget_type) {
|
public function setCpc_budget_type($cpc_budget_type)
|
||||||
|
{
|
||||||
$this->cpc_budget_type = $cpc_budget_type;
|
$this->cpc_budget_type = $cpc_budget_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCpc_total_budget($cpc_total_budget) {
|
public function setCpc_total_budget($cpc_total_budget)
|
||||||
|
{
|
||||||
$this->cpc_total_budget = $cpc_total_budget;
|
$this->cpc_total_budget = $cpc_total_budget;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCpc_max_price_per_click($cpc_max_price_per_click) {
|
public function setCpc_max_price_per_click($cpc_max_price_per_click)
|
||||||
|
{
|
||||||
$this->cpc_max_price_per_click = $cpc_max_price_per_click;
|
$this->cpc_max_price_per_click = $cpc_max_price_per_click;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCpm_max_prints($cpm_max_prints) {
|
public function setCpm_max_prints($cpm_max_prints)
|
||||||
|
{
|
||||||
$this->cpm_max_prints = $cpm_max_prints;
|
$this->cpm_max_prints = $cpm_max_prints;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCpm_current_prints($cpm_current_prints) {
|
public function setCpm_current_prints($cpm_current_prints)
|
||||||
|
{
|
||||||
$this->cpm_current_prints = $cpm_current_prints;
|
$this->cpm_current_prints = $cpm_current_prints;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getId() {
|
public function getId()
|
||||||
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setId($id) {
|
public function setId($id)
|
||||||
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
public function save()
|
||||||
|
{
|
||||||
$this->cpm_current_prints = intval($this->cpm_current_prints);
|
$this->cpm_current_prints = intval($this->cpm_current_prints);
|
||||||
if (empty($this->visibility)) {
|
if (empty($this->visibility)) {
|
||||||
$this->visibility = 'listed';
|
$this->visibility = 'listed';
|
||||||
|
@ -188,7 +244,8 @@ class VastCampaigns extends ObjectYPT {
|
||||||
return parent::save();
|
return parent::save();
|
||||||
}
|
}
|
||||||
|
|
||||||
function addVideo($videos_id, $status = 'a') {
|
public function addVideo($videos_id, $status = 'a')
|
||||||
|
{
|
||||||
$vast_campaigns_id = $this->getId();
|
$vast_campaigns_id = $this->getId();
|
||||||
if (empty($vast_campaigns_id)) {
|
if (empty($vast_campaigns_id)) {
|
||||||
$this->setId($this->save());
|
$this->setId($this->save());
|
||||||
|
@ -200,13 +257,14 @@ class VastCampaigns extends ObjectYPT {
|
||||||
return $campainVideos->save();
|
return $campainVideos->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getValidCampaigns() {
|
public static function getValidCampaigns()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$ad_server_location = AVideoPlugin::loadPluginIfEnabled('AD_Server_Location');
|
$ad_server_location = AVideoPlugin::loadPluginIfEnabled('AD_Server_Location');
|
||||||
AVideoPlugin::loadPlugin('User_Location');
|
AVideoPlugin::loadPlugin('User_Location');
|
||||||
$User_Location = User_Location::getSessionLocation();
|
$User_Location = User_Location::getSessionLocation();
|
||||||
$sql = "SELECT * from " . static::getTableName() . " vc WHERE status = 'a' AND start_date <= now() AND end_date >=now() AND cpm_max_prints > cpm_current_prints ";
|
$sql = "SELECT * from " . static::getTableName() . " vc WHERE status = 'a' AND start_date <= now() AND end_date >=now() AND cpm_max_prints > cpm_current_prints ";
|
||||||
if(!empty($ad_server_location) && !empty($User_Location) && $User_Location['country_name'] !== '-'){
|
if (!empty($ad_server_location) && !empty($User_Location) && $User_Location['country_name'] !== '-') {
|
||||||
// show only campaign for the user location
|
// show only campaign for the user location
|
||||||
$sql .= " AND ( (vc.id IN (SELECT vast_campaigns_id FROM campaign_locations WHERE (country_name = 'All' OR country_name IS NULL OR country_name = '') OR "
|
$sql .= " AND ( (vc.id IN (SELECT vast_campaigns_id FROM campaign_locations WHERE (country_name = 'All' OR country_name IS NULL OR country_name = '') OR "
|
||||||
. " (country_name = \"{$User_Location['country_name']}\" AND region_name = 'All') OR "
|
. " (country_name = \"{$User_Location['country_name']}\" AND region_name = 'All') OR "
|
||||||
|
@ -221,7 +279,7 @@ class VastCampaigns extends ObjectYPT {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$rows = sqlDAL::fetchAllAssoc($res);
|
$rows = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$r = array();
|
$r = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$row['printsLeft'] = $row['cpm_max_prints'] - $row['cpm_current_prints'];
|
$row['printsLeft'] = $row['cpm_max_prints'] - $row['cpm_current_prints'];
|
||||||
|
@ -232,7 +290,8 @@ class VastCampaigns extends ObjectYPT {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAll() {
|
public static function getAll()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$ad_server_location = AVideoPlugin::loadPluginIfEnabled('AD_Server_Location');
|
$ad_server_location = AVideoPlugin::loadPluginIfEnabled('AD_Server_Location');
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE 1=1 ";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE 1=1 ";
|
||||||
|
@ -241,7 +300,7 @@ class VastCampaigns extends ObjectYPT {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$row['data'] = VastCampaignsLogs::getDataFromCampaign($row['id']);
|
$row['data'] = VastCampaignsLogs::getDataFromCampaign($row['id']);
|
||||||
|
@ -257,39 +316,42 @@ class VastCampaigns extends ObjectYPT {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addView() {
|
public function addView()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (!empty($this->id)) {
|
if (!empty($this->id)) {
|
||||||
$sql = "UPDATE " . static::getTableName() . " SET cpm_current_prints = cpm_current_prints+1 ";
|
$sql = "UPDATE " . static::getTableName() . " SET cpm_current_prints = cpm_current_prints+1 ";
|
||||||
$sql .= " WHERE id = ?";
|
$sql .= " WHERE id = ?";
|
||||||
$global['lastQuery'] = $sql;
|
$global['lastQuery'] = $sql;
|
||||||
//_error_log("Delete Query: ".$sql);
|
//_error_log("Delete Query: ".$sql);
|
||||||
return sqlDAL::writeSql($sql, "i", array($this->id));
|
return sqlDAL::writeSql($sql, "i", [$this->id]);
|
||||||
}
|
}
|
||||||
_error_log("Id for table " . static::getTableName() . " not defined for add view");
|
_error_log("Id for table " . static::getTableName() . " not defined for add view");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete() {
|
public function delete()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (!empty($this->id)) {
|
if (!empty($this->id)) {
|
||||||
$sql = "DELETE FROM vast_campaigns_logs ";
|
$sql = "DELETE FROM vast_campaigns_logs ";
|
||||||
$sql .= " WHERE vast_campaigns_has_videos_id IN (SELECT id FROM vast_campaigns_has_videos WHERE vast_campaigns_id = ?)";
|
$sql .= " WHERE vast_campaigns_has_videos_id IN (SELECT id FROM vast_campaigns_has_videos WHERE vast_campaigns_id = ?)";
|
||||||
$global['lastQuery'] = $sql;
|
$global['lastQuery'] = $sql;
|
||||||
//_error_log("Delete Query: ".$sql);
|
//_error_log("Delete Query: ".$sql);
|
||||||
$campaigns_video_log = sqlDAL::writeSql($sql, "i", array($this->id));
|
$campaigns_video_log = sqlDAL::writeSql($sql, "i", [$this->id]);
|
||||||
|
|
||||||
|
|
||||||
$sql = "DELETE FROM vast_campaigns_has_videos ";
|
$sql = "DELETE FROM vast_campaigns_has_videos ";
|
||||||
$sql .= " WHERE vast_campaigns_id = ?";
|
$sql .= " WHERE vast_campaigns_id = ?";
|
||||||
$global['lastQuery'] = $sql;
|
$global['lastQuery'] = $sql;
|
||||||
//_error_log("Delete Query: ".$sql);
|
//_error_log("Delete Query: ".$sql);
|
||||||
$campaigns_video = sqlDAL::writeSql($sql, "i", array($this->id));
|
$campaigns_video = sqlDAL::writeSql($sql, "i", [$this->id]);
|
||||||
}
|
}
|
||||||
return parent::delete();
|
return parent::delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getValidCampaignsFromVideo($videos_id) {
|
public static function getValidCampaignsFromVideo($videos_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
|
|
||||||
$sql = "SELECT vchv.*, vc.* from " . static::getTableName() . " vc LEFT JOIN vast_campaigns_has_videos vchv ON vchv.vast_campaigns_id = vc.id WHERE vc.status = 'a' "
|
$sql = "SELECT vchv.*, vc.* from " . static::getTableName() . " vc LEFT JOIN vast_campaigns_has_videos vchv ON vchv.vast_campaigns_id = vc.id WHERE vc.status = 'a' "
|
||||||
|
@ -298,7 +360,7 @@ class VastCampaigns extends ObjectYPT {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$rows = sqlDAL::fetchAllAssoc($res);
|
$rows = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$r = array();
|
$r = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$row['printsLeft'] = $row['cpm_max_prints'] - $row['cpm_current_prints'];
|
$row['printsLeft'] = $row['cpm_max_prints'] - $row['cpm_current_prints'];
|
||||||
|
@ -308,5 +370,4 @@ class VastCampaigns extends ObjectYPT {
|
||||||
|
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,60 +4,77 @@ require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
require_once dirname(__FILE__) . '/../../../objects/user.php';
|
require_once dirname(__FILE__) . '/../../../objects/user.php';
|
||||||
require_once dirname(__FILE__) . '/../../../objects/video.php';
|
require_once dirname(__FILE__) . '/../../../objects/video.php';
|
||||||
|
|
||||||
class VastCampaignsLogs extends ObjectYPT {
|
class VastCampaignsLogs extends ObjectYPT
|
||||||
|
{
|
||||||
|
protected $id;
|
||||||
|
protected $users_id;
|
||||||
|
protected $type;
|
||||||
|
protected $vast_campaigns_has_videos_id;
|
||||||
|
protected $ip;
|
||||||
|
|
||||||
protected $id, $users_id, $type, $vast_campaigns_has_videos_id, $ip;
|
public static function getSearchFieldsNames()
|
||||||
|
{
|
||||||
static function getSearchFieldsNames() {
|
return [];
|
||||||
return array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTableName() {
|
public static function getTableName()
|
||||||
|
{
|
||||||
return 'vast_campaigns_logs';
|
return 'vast_campaigns_logs';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getId() {
|
public function getId()
|
||||||
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsers_id() {
|
public function getUsers_id()
|
||||||
|
{
|
||||||
return $this->users_id;
|
return $this->users_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getType() {
|
public function getType()
|
||||||
|
{
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVast_campaigns_has_videos_id() {
|
public function getVast_campaigns_has_videos_id()
|
||||||
|
{
|
||||||
return $this->vast_campaigns_has_videos_id;
|
return $this->vast_campaigns_has_videos_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setId($id) {
|
public function setId($id)
|
||||||
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUsers_id($users_id) {
|
public function setUsers_id($users_id)
|
||||||
|
{
|
||||||
$this->users_id = $users_id;
|
$this->users_id = $users_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setType($type) {
|
public function setType($type)
|
||||||
|
{
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVast_campaigns_has_videos_id($vast_campaigns_has_videos_id) {
|
public function setVast_campaigns_has_videos_id($vast_campaigns_has_videos_id)
|
||||||
|
{
|
||||||
$this->vast_campaigns_has_videos_id = $vast_campaigns_has_videos_id;
|
$this->vast_campaigns_has_videos_id = $vast_campaigns_has_videos_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIp() {
|
public function getIp()
|
||||||
|
{
|
||||||
return $this->ip;
|
return $this->ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
public function save()
|
||||||
|
{
|
||||||
$this->ip = getRealIpAddr();
|
$this->ip = getRealIpAddr();
|
||||||
return parent::save();
|
return parent::save();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getViews(){
|
public static function getViews()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "SELECT count(*) as total FROM vast_campaigns_logs WHERE `type` = 'start'";
|
$sql = "SELECT count(*) as total FROM vast_campaigns_logs WHERE `type` = 'start'";
|
||||||
|
|
||||||
|
@ -72,14 +89,15 @@ class VastCampaignsLogs extends ObjectYPT {
|
||||||
return $row['total'];
|
return $row['total'];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getData($vast_campaigns_has_videos_id){
|
public static function getData($vast_campaigns_has_videos_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "SELECT `type`, count(*) as total FROM vast_campaigns_logs WHERE vast_campaigns_has_videos_id = $vast_campaigns_has_videos_id GROUP BY `type`";
|
$sql = "SELECT `type`, count(*) as total FROM vast_campaigns_logs WHERE vast_campaigns_has_videos_id = $vast_campaigns_has_videos_id GROUP BY `type`";
|
||||||
|
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$data = array();
|
$data = [];
|
||||||
if ($res!=false) {
|
if ($res!=false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$data[$row['type']] = $row['total'];
|
$data[$row['type']] = $row['total'];
|
||||||
|
@ -90,16 +108,17 @@ class VastCampaignsLogs extends ObjectYPT {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getDataFromCampaign($vast_campaigns_id){
|
public static function getDataFromCampaign($vast_campaigns_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "SELECT `type`, count(vast_campaigns_id) as total FROM vast_campaigns_logs vcl "
|
$sql = "SELECT `type`, count(vast_campaigns_id) as total FROM vast_campaigns_logs vcl "
|
||||||
. " LEFT JOIN vast_campaigns_has_videos vchv ON vast_campaigns_has_videos_id = vchv.id "
|
. " LEFT JOIN vast_campaigns_has_videos vchv ON vast_campaigns_has_videos_id = vchv.id "
|
||||||
. " WHERE vast_campaigns_id = $vast_campaigns_id GROUP BY `type`";
|
. " WHERE vast_campaigns_id = $vast_campaigns_id GROUP BY `type`";
|
||||||
//echo $sql."\n";
|
//echo $sql."\n";
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$data = array();
|
$data = [];
|
||||||
if ($res!=false) {
|
if ($res!=false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$data[$row['type']] = $row['total'];
|
$data[$row['type']] = $row['total'];
|
||||||
|
@ -109,7 +128,4 @@ class VastCampaignsLogs extends ObjectYPT {
|
||||||
}
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,35 +5,45 @@ require_once dirname(__FILE__) . '/../../../objects/user.php';
|
||||||
require_once dirname(__FILE__) . '/../../../objects/video.php';
|
require_once dirname(__FILE__) . '/../../../objects/video.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsLogs.php';
|
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsLogs.php';
|
||||||
|
|
||||||
class VastCampaignsVideos extends ObjectYPT {
|
class VastCampaignsVideos extends ObjectYPT
|
||||||
|
{
|
||||||
|
protected $id;
|
||||||
|
protected $vast_campaigns_id;
|
||||||
|
protected $videos_id;
|
||||||
|
protected $status;
|
||||||
|
protected $link;
|
||||||
|
protected $ad_title;
|
||||||
|
|
||||||
protected $id, $vast_campaigns_id, $videos_id, $status, $link, $ad_title;
|
public static function getSearchFieldsNames()
|
||||||
|
{
|
||||||
static function getSearchFieldsNames() {
|
return [];
|
||||||
return array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTableName() {
|
public static function getTableName()
|
||||||
|
{
|
||||||
return 'vast_campaigns_has_videos';
|
return 'vast_campaigns_has_videos';
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFromCampainVideo($vast_campaigns_id, $videos_id){
|
public function loadFromCampainVideo($vast_campaigns_id, $videos_id)
|
||||||
|
{
|
||||||
$row = self::getCampainVideo($vast_campaigns_id, $videos_id);
|
$row = self::getCampainVideo($vast_campaigns_id, $videos_id);
|
||||||
if (empty($row))
|
if (empty($row)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
foreach ($row as $key => $value) {
|
foreach ($row as $key => $value) {
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected function getCampainVideo($vast_campaigns_id, $videos_id) {
|
protected static function getCampainVideo($vast_campaigns_id, $videos_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$vast_campaigns_id = intval($vast_campaigns_id);
|
$vast_campaigns_id = intval($vast_campaigns_id);
|
||||||
$videos_id = intval($videos_id);
|
$videos_id = intval($videos_id);
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE vast_campaigns_id = ? , videos_id = ? LIMIT 1";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE vast_campaigns_id = ? , videos_id = ? LIMIT 1";
|
||||||
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
|
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
|
||||||
$res = sqlDAL::readSql($sql,"ii",array($vast_campaigns_id, $videos_id));
|
$res = sqlDAL::readSql($sql, "ii", [$vast_campaigns_id, $videos_id]);
|
||||||
$data = sqlDAL::fetchAssoc($res);
|
$data = sqlDAL::fetchAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
if ($res) {
|
if ($res) {
|
||||||
|
@ -44,19 +54,20 @@ class VastCampaignsVideos extends ObjectYPT {
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getRandomCampainVideo($vast_campaigns_id) {
|
public static function getRandomCampainVideo($vast_campaigns_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$vast_campaigns_id = intval($vast_campaigns_id);
|
$vast_campaigns_id = intval($vast_campaigns_id);
|
||||||
if(empty($vast_campaigns_id)){
|
if (empty($vast_campaigns_id)) {
|
||||||
$campaings = VastCampaigns::getValidCampaigns();
|
$campaings = VastCampaigns::getValidCampaigns();
|
||||||
if(empty($campaings[0])){
|
if (empty($campaings[0])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$vast_campaigns_id = $campaings[0]['id'];
|
$vast_campaigns_id = $campaings[0]['id'];
|
||||||
}
|
}
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE vast_campaigns_id = ? ORDER BY RAND() LIMIT 1";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE vast_campaigns_id = ? ORDER BY RAND() LIMIT 1";
|
||||||
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
|
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
|
||||||
$res = sqlDAL::readSql($sql,"i",array($vast_campaigns_id));
|
$res = sqlDAL::readSql($sql, "i", [$vast_campaigns_id]);
|
||||||
$data = sqlDAL::fetchAssoc($res);
|
$data = sqlDAL::fetchAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
if ($res) {
|
if ($res) {
|
||||||
|
@ -67,13 +78,14 @@ class VastCampaignsVideos extends ObjectYPT {
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAllFromCampaign($vast_campaigns_id, $getImages = false) {
|
public static function getAllFromCampaign($vast_campaigns_id, $getImages = false)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$vast_campaigns_id = intval($vast_campaigns_id);
|
$vast_campaigns_id = intval($vast_campaigns_id);
|
||||||
$sql = "SELECT v.*, c.* FROM " . static::getTableName() . " c "
|
$sql = "SELECT v.*, c.* FROM " . static::getTableName() . " c "
|
||||||
. " LEFT JOIN videos v ON videos_id = v.id WHERE 1=1 ";
|
. " LEFT JOIN videos v ON videos_id = v.id WHERE 1=1 ";
|
||||||
|
|
||||||
if(!empty($vast_campaigns_id)){
|
if (!empty($vast_campaigns_id)) {
|
||||||
$sql .= " AND vast_campaigns_id=$vast_campaigns_id ";
|
$sql .= " AND vast_campaigns_id=$vast_campaigns_id ";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,10 +93,10 @@ class VastCampaignsVideos extends ObjectYPT {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res!=false) {
|
if ($res!=false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
if($getImages){
|
if ($getImages) {
|
||||||
$row['poster'] = Video::getImageFromID($row['videos_id']);
|
$row['poster'] = Video::getImageFromID($row['videos_id']);
|
||||||
}
|
}
|
||||||
$row['data'] = VastCampaignsLogs::getDataFromCampaign($row['vast_campaigns_id']);
|
$row['data'] = VastCampaignsLogs::getDataFromCampaign($row['vast_campaigns_id']);
|
||||||
|
@ -96,17 +108,18 @@ class VastCampaignsVideos extends ObjectYPT {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getValidVideos($vast_campaigns_id){
|
public static function getValidVideos($vast_campaigns_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
|
|
||||||
$sql = "SELECT v.*, c.* from " . static::getTableName() . " c LEFT JOIN videos v ON v.id = videos_id WHERE vast_campaigns_id = ? AND c.status = 'a' ";
|
$sql = "SELECT v.*, c.* from " . static::getTableName() . " c LEFT JOIN videos v ON v.id = videos_id WHERE vast_campaigns_id = ? AND c.status = 'a' ";
|
||||||
|
|
||||||
$res = sqlDAL::readSql($sql,"i",array($vast_campaigns_id));
|
$res = sqlDAL::readSql($sql, "i", [$vast_campaigns_id]);
|
||||||
$rows = sqlDAL::fetchAllAssoc($res);
|
$rows = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$r = array();
|
$r = [];
|
||||||
if ($res!=false) {
|
if ($res!=false) {
|
||||||
foreach($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$r[] = $row;
|
$r[] = $row;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,72 +127,84 @@ class VastCampaignsVideos extends ObjectYPT {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getId() {
|
public function getId()
|
||||||
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVast_campaigns_id() {
|
public function getVast_campaigns_id()
|
||||||
|
{
|
||||||
return $this->vast_campaigns_id;
|
return $this->vast_campaigns_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getVideos_id() {
|
public function getVideos_id()
|
||||||
|
{
|
||||||
return $this->videos_id;
|
return $this->videos_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatus() {
|
public function getStatus()
|
||||||
|
{
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setId($id) {
|
public function setId($id)
|
||||||
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVast_campaigns_id($vast_campaigns_id) {
|
public function setVast_campaigns_id($vast_campaigns_id)
|
||||||
|
{
|
||||||
$this->vast_campaigns_id = $vast_campaigns_id;
|
$this->vast_campaigns_id = $vast_campaigns_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setVideos_id($videos_id) {
|
public function setVideos_id($videos_id)
|
||||||
|
{
|
||||||
$this->videos_id = $videos_id;
|
$this->videos_id = $videos_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStatus($status) {
|
public function setStatus($status)
|
||||||
|
{
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLink() {
|
public function getLink()
|
||||||
|
{
|
||||||
return $this->link;
|
return $this->link;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAd_title() {
|
public function getAd_title()
|
||||||
|
{
|
||||||
return $this->ad_title;
|
return $this->ad_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLink($link) {
|
public function setLink($link)
|
||||||
|
{
|
||||||
$this->link = $link;
|
$this->link = $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setAd_title($ad_title) {
|
public function setAd_title($ad_title)
|
||||||
|
{
|
||||||
$this->ad_title = $ad_title;
|
$this->ad_title = $ad_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete() {
|
public function delete()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (!empty($this->id)) {
|
if (!empty($this->id)) {
|
||||||
$sql = "DELETE FROM vast_campaigns_logs ";
|
$sql = "DELETE FROM vast_campaigns_logs ";
|
||||||
$sql .= " WHERE vast_campaigns_has_videos_id = ?";
|
$sql .= " WHERE vast_campaigns_has_videos_id = ?";
|
||||||
$global['lastQuery'] = $sql;
|
$global['lastQuery'] = $sql;
|
||||||
//_error_log("Delete Query: ".$sql);
|
//_error_log("Delete Query: ".$sql);
|
||||||
$campaigns_video_log = sqlDAL::writeSql($sql,"i",array($this->id));
|
$campaigns_video_log = sqlDAL::writeSql($sql, "i", [$this->id]);
|
||||||
}
|
}
|
||||||
return parent::delete();
|
return parent::delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save() {
|
public function save()
|
||||||
if(empty($this->vast_campaigns_id) || strtolower($this->vast_campaigns_id)=='null' ){
|
{
|
||||||
|
if (empty($this->vast_campaigns_id) || strtolower($this->vast_campaigns_id)=='null') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return parent::save();
|
return parent::save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ require_once $global['systemRootPath'] . 'objects/video.php';
|
||||||
$ad_server = AVideoPlugin::loadPlugin('AD_Server');
|
$ad_server = AVideoPlugin::loadPlugin('AD_Server');
|
||||||
$obj = AVideoPlugin::getObjectData('AD_Server');
|
$obj = AVideoPlugin::getObjectData('AD_Server');
|
||||||
|
|
||||||
if(empty($_GET['campaign_has_videos_id'])){
|
if (empty($_GET['campaign_has_videos_id'])) {
|
||||||
$video = VastCampaignsVideos::getRandomCampainVideo(intval(@$_GET['campaign_id']));
|
$video = VastCampaignsVideos::getRandomCampainVideo(intval(@$_GET['campaign_id']));
|
||||||
$_GET['campaign_has_videos_id'] = $video['id'];
|
$_GET['campaign_has_videos_id'] = $video['id'];
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ $video = new Video("", "", $vastCampaingVideos->getVideos_id());
|
||||||
</TrackingEvents>
|
</TrackingEvents>
|
||||||
<?php
|
<?php
|
||||||
$campaignVideo = new VastCampaignsVideos($_GET['campaign_has_videos_id']);
|
$campaignVideo = new VastCampaignsVideos($_GET['campaign_has_videos_id']);
|
||||||
if(!empty($campaignVideo)){
|
if (!empty($campaignVideo)) {
|
||||||
$link = $campaignVideo->getLink();
|
$link = $campaignVideo->getLink();
|
||||||
if (filter_var($link, FILTER_VALIDATE_URL)) {
|
if (filter_var($link, FILTER_VALIDATE_URL)) {
|
||||||
?>
|
?>
|
||||||
|
@ -55,7 +55,7 @@ $video = new Video("", "", $vastCampaingVideos->getVideos_id());
|
||||||
<ClickThrough id="GDFP"><![CDATA[<?php echo $global['webSiteRootURL']; ?>plugin/AD_Server/log.php?label=ClickThrough&campaign_has_videos_id=<?php echo $_GET['campaign_has_videos_id']; ?>]]></ClickThrough>
|
<ClickThrough id="GDFP"><![CDATA[<?php echo $global['webSiteRootURL']; ?>plugin/AD_Server/log.php?label=ClickThrough&campaign_has_videos_id=<?php echo $_GET['campaign_has_videos_id']; ?>]]></ClickThrough>
|
||||||
</VideoClicks>
|
</VideoClicks>
|
||||||
<?php
|
<?php
|
||||||
}else{
|
} else {
|
||||||
_error_log("VastCampaignsVideos has not a valid link: {$link}");
|
_error_log("VastCampaignsVideos has not a valid link: {$link}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ $video = new Video("", "", $vastCampaingVideos->getVideos_id());
|
||||||
$adsCount++;
|
$adsCount++;
|
||||||
echo "\n " . '<MediaFile id="GDFP" delivery="progressive" type="video/mp4" scalable="true" maintainAspectRatio="true"><![CDATA[' . ($value['url']) . ']]></MediaFile>';
|
echo "\n " . '<MediaFile id="GDFP" delivery="progressive" type="video/mp4" scalable="true" maintainAspectRatio="true"><![CDATA[' . ($value['url']) . ']]></MediaFile>';
|
||||||
}
|
}
|
||||||
if(!$adsCount){
|
if (!$adsCount) {
|
||||||
echo "\n " . '<MediaFile id="GDFP" delivery="progressive" type="video/mp4" scalable="true" maintainAspectRatio="true"><![CDATA[' . $global['webSiteRootURL'].'plugin/AD_Server/view/adswarning.mp4]]></MediaFile>';
|
echo "\n " . '<MediaFile id="GDFP" delivery="progressive" type="video/mp4" scalable="true" maintainAspectRatio="true"><![CDATA[' . $global['webSiteRootURL'].'plugin/AD_Server/view/adswarning.mp4]]></MediaFile>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -4,14 +4,14 @@ header('Content-type: application/xml');
|
||||||
require_once '../../videos/configuration.php';
|
require_once '../../videos/configuration.php';
|
||||||
allowOrigin();
|
allowOrigin();
|
||||||
$ad_server = AVideoPlugin::loadPluginIfEnabled('AD_Server');
|
$ad_server = AVideoPlugin::loadPluginIfEnabled('AD_Server');
|
||||||
if(empty($ad_server)){
|
if (empty($ad_server)) {
|
||||||
die("not enabled");
|
die("not enabled");
|
||||||
}
|
}
|
||||||
if(empty($_GET['video_length'])){
|
if (empty($_GET['video_length'])) {
|
||||||
$_GET['video_length'] = 300;
|
$_GET['video_length'] = 300;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($_GET['vmap_id'])){
|
if (empty($_GET['vmap_id'])) {
|
||||||
$_GET['vmap_id'] = uniqid();
|
$_GET['vmap_id'] = uniqid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +21,9 @@ $vmaps = AD_Server::getVMAPSFromRequest();
|
||||||
<vmap:VMAP xmlns:vmap="http://www.iab.net/videosuite/vmap" version="1.0">
|
<vmap:VMAP xmlns:vmap="http://www.iab.net/videosuite/vmap" version="1.0">
|
||||||
<?php
|
<?php
|
||||||
foreach ($vmaps as $value) {
|
foreach ($vmaps as $value) {
|
||||||
if(empty($value['VAST']['campaing'])){
|
if (empty($value['VAST']['campaing'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
} ?>
|
||||||
?>
|
|
||||||
<vmap:AdBreak timeOffset="<?php echo $value['timeOffset']; ?>" breakType="linear">
|
<vmap:AdBreak timeOffset="<?php echo $value['timeOffset']; ?>" breakType="linear">
|
||||||
<vmap:AdSource id="<?php echo $value['idTag']; ?>" allowMultipleAds="true" followRedirects="true" breakId="<?php echo $value['idTag']; ?>-break">
|
<vmap:AdSource id="<?php echo $value['idTag']; ?>" allowMultipleAds="true" followRedirects="true" breakId="<?php echo $value['idTag']; ?>-break">
|
||||||
<vmap:AdTagURI templateType="vast3"><![CDATA[<?php echo $global['webSiteRootURL']; ?>plugin/AD_Server/VAST.php?campaign_has_videos_id=<?php echo $value['VAST']['campaing']; ?>&vmap_id=<?php echo @$_GET['vmap_id']; ?>]]></vmap:AdTagURI>
|
<vmap:AdTagURI templateType="vast3"><![CDATA[<?php echo $global['webSiteRootURL']; ?>plugin/AD_Server/VAST.php?campaign_has_videos_id=<?php echo $value['VAST']['campaing']; ?>&vmap_id=<?php echo @$_GET['vmap_id']; ?>]]></vmap:AdTagURI>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
<?php
|
<?php
|
||||||
if (!empty($obj->showMarkers)) {
|
if (!empty($obj->showMarkers)) {
|
||||||
?>
|
?>
|
||||||
$.getScript("<?php echo $global['webSiteRootURL'] ?>plugin/AD_Server/videojs-markers/videojs-markers.js", function (data, textStatus, jqxhr) {
|
$.getScript("<?php echo $global['webSiteRootURL'] ?>plugin/AD_Server/videojs-markers/videojs-markers.js", function (data, textStatus, jqxhr) {
|
||||||
|
|
||||||
if (typeof player == 'undefined') {
|
if (typeof player == 'undefined') {
|
||||||
|
@ -30,12 +30,10 @@ if (!empty($obj->showMarkers)) {
|
||||||
<?php
|
<?php
|
||||||
foreach ($vmaps as $value) {
|
foreach ($vmaps as $value) {
|
||||||
$vastCampaingVideos = new VastCampaignsVideos($value->VAST->campaing);
|
$vastCampaingVideos = new VastCampaignsVideos($value->VAST->campaing);
|
||||||
$video = new Video("", "", $vastCampaingVideos->getVideos_id());
|
$video = new Video("", "", $vastCampaingVideos->getVideos_id()); ?>
|
||||||
?>
|
|
||||||
{time: <?php echo $value->timeOffsetSeconds; ?>, text: "<?php echo addcslashes($video->getTitle(), '"'); ?>"},
|
{time: <?php echo $value->timeOffsetSeconds; ?>, text: "<?php echo addcslashes($video->getTitle(), '"'); ?>"},
|
||||||
<?php
|
<?php
|
||||||
}
|
} ?>
|
||||||
?>
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@ $obj->error = true;
|
||||||
$obj->msg = "";
|
$obj->msg = "";
|
||||||
$obj->views = 0;
|
$obj->views = 0;
|
||||||
$ad_server = AVideoPlugin::loadPluginIfEnabled('AD_Server');
|
$ad_server = AVideoPlugin::loadPluginIfEnabled('AD_Server');
|
||||||
if(empty($ad_server)){
|
if (empty($ad_server)) {
|
||||||
$obj->msg = "not enabled";
|
$obj->msg = "not enabled";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ if (!User::isAdmin()) {
|
||||||
<html lang="<?php echo $_SESSION['language']; ?>">
|
<html lang="<?php echo $_SESSION['language']; ?>">
|
||||||
<head>
|
<head>
|
||||||
<?php
|
<?php
|
||||||
echo getHTMLTitle( __("VAST"));
|
echo getHTMLTitle(__("VAST"));
|
||||||
?>
|
?>
|
||||||
<?php
|
<?php
|
||||||
include $global['systemRootPath'] . 'view/include/head.php';
|
include $global['systemRootPath'] . 'view/include/head.php';
|
||||||
|
|
|
@ -474,7 +474,7 @@ if (!empty($ad_server_location)) {
|
||||||
?>
|
?>
|
||||||
$('#locationList').empty();
|
$('#locationList').empty();
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
$("#panelForm").trigger("reset");
|
$("#panelForm").trigger("reset");
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,12 @@ require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaigns
|
||||||
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsLogs.php';
|
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsLogs.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsVideos.php';
|
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsVideos.php';
|
||||||
|
|
||||||
if(empty($_GET['campaign_has_videos_id'])){
|
if (empty($_GET['campaign_has_videos_id'])) {
|
||||||
die('campaign_has_videos_id Can not be empty');
|
die('campaign_has_videos_id Can not be empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
$users_id = 'null';
|
$users_id = 'null';
|
||||||
if(User::isLogged()){
|
if (User::isLogged()) {
|
||||||
$users_id = User::getId();
|
$users_id = User::getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,14 +21,14 @@ $log->setVast_campaigns_has_videos_id($_GET['campaign_has_videos_id']);
|
||||||
$log->save();
|
$log->save();
|
||||||
|
|
||||||
$campaignVideo = new VastCampaignsVideos($_GET['campaign_has_videos_id']);
|
$campaignVideo = new VastCampaignsVideos($_GET['campaign_has_videos_id']);
|
||||||
if($_GET['label'] === 'Impression'){
|
if ($_GET['label'] === 'Impression') {
|
||||||
$campaign = new VastCampaigns($campaignVideo->getVast_campaigns_id());
|
$campaign = new VastCampaigns($campaignVideo->getVast_campaigns_id());
|
||||||
$campaign->addView();
|
$campaign->addView();
|
||||||
}
|
}
|
||||||
if($_GET['label'] === 'ClickThrough'){
|
if ($_GET['label'] === 'ClickThrough') {
|
||||||
// get the URL
|
// get the URL
|
||||||
$link = $campaignVideo->getLink();
|
$link = $campaignVideo->getLink();
|
||||||
if(filter_var($link, FILTER_VALIDATE_URL) ){
|
if (filter_var($link, FILTER_VALIDATE_URL)) {
|
||||||
header("Location: ".$link);
|
header("Location: ".$link);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
require_once '../../../videos/configuration.php';
|
require_once '../../../videos/configuration.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaigns.php';
|
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaigns.php';
|
||||||
|
@ -10,7 +11,7 @@ $obj->msg = "";
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled('AD_Server');
|
$plugin = AVideoPlugin::loadPluginIfEnabled('AD_Server');
|
||||||
$ad_server_location = AVideoPlugin::loadPluginIfEnabled('AD_Server_Location');
|
$ad_server_location = AVideoPlugin::loadPluginIfEnabled('AD_Server_Location');
|
||||||
|
|
||||||
if(!User::isAdmin()){
|
if (!User::isAdmin()) {
|
||||||
$obj->msg = "You can't do this";
|
$obj->msg = "You can't do this";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
@ -27,13 +28,13 @@ $o->setUsers_id(User::getId());
|
||||||
$o->setCpm_max_prints($_POST['maxPrints']);
|
$o->setCpm_max_prints($_POST['maxPrints']);
|
||||||
$o->setVisibility('listed');
|
$o->setVisibility('listed');
|
||||||
|
|
||||||
if($id = $o->save()){
|
if ($id = $o->save()) {
|
||||||
$obj->error = false;
|
$obj->error = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($ad_server_location) && !empty($id)){
|
if (!empty($ad_server_location) && !empty($id)) {
|
||||||
CampaignLocations::deleteFromCapmpaign($id);
|
CampaignLocations::deleteFromCapmpaign($id);
|
||||||
if(!empty($_POST['country_name'])){
|
if (!empty($_POST['country_name'])) {
|
||||||
$ad_server_location->addCampaignLocation($_POST['country_name'], $_POST['region_name'], $_POST['city_name'], $id);
|
$ad_server_location->addCampaignLocation($_POST['country_name'], $_POST['region_name'], $_POST['city_name'], $id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
require_once '../../../videos/configuration.php';
|
require_once '../../../videos/configuration.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsVideos.php';
|
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsVideos.php';
|
||||||
|
@ -9,7 +10,7 @@ $obj->msg = "";
|
||||||
|
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled('AD_Server');
|
$plugin = AVideoPlugin::loadPluginIfEnabled('AD_Server');
|
||||||
|
|
||||||
if(!User::isAdmin()){
|
if (!User::isAdmin()) {
|
||||||
$obj->msg = "You can't do this";
|
$obj->msg = "You can't do this";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
@ -23,7 +24,7 @@ $o->setLink($_POST['uri']);
|
||||||
$o->setAd_title($_POST['title']);
|
$o->setAd_title($_POST['title']);
|
||||||
$o->setStatus('a');
|
$o->setStatus('a');
|
||||||
|
|
||||||
if($o->save()){
|
if ($o->save()) {
|
||||||
$obj->error = false;
|
$obj->error = false;
|
||||||
}
|
}
|
||||||
echo json_encode($obj);
|
echo json_encode($obj);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../../../videos/configuration.php';
|
require_once '../../../videos/configuration.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaigns.php';
|
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaigns.php';
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
@ -8,15 +9,14 @@ $obj->error = true;
|
||||||
|
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled('AD_Server');
|
$plugin = AVideoPlugin::loadPluginIfEnabled('AD_Server');
|
||||||
|
|
||||||
if(!User::isAdmin()){
|
if (!User::isAdmin()) {
|
||||||
$obj->msg = "You can't do this";
|
$obj->msg = "You can't do this";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = intval($_POST['id']);
|
$id = intval($_POST['id']);
|
||||||
$row = new VastCampaigns($id);
|
$row = new VastCampaigns($id);
|
||||||
if($row->getUsers_id() == User::getId() || User::isAdmin()){
|
if ($row->getUsers_id() == User::getId() || User::isAdmin()) {
|
||||||
$obj->error = !$row->delete();
|
$obj->error = !$row->delete();
|
||||||
}
|
}
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
?>
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../../../videos/configuration.php';
|
require_once '../../../videos/configuration.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsVideos.php';
|
require_once $global['systemRootPath'] . 'plugin/AD_Server/Objects/VastCampaignsVideos.php';
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
@ -8,15 +9,15 @@ $obj->error = true;
|
||||||
|
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled('AD_Server');
|
$plugin = AVideoPlugin::loadPluginIfEnabled('AD_Server');
|
||||||
|
|
||||||
if(!User::isAdmin()){
|
if (!User::isAdmin()) {
|
||||||
$obj->msg = "You can't do this";
|
$obj->msg = "You can't do this";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = intval($_POST['id']);
|
$id = intval($_POST['id']);
|
||||||
$row = new VastCampaignsVideos($id);
|
$row = new VastCampaignsVideos($id);
|
||||||
if(User::isAdmin()){
|
if (User::isAdmin()) {
|
||||||
$obj->error = !$row->delete();;
|
$obj->error = !$row->delete();
|
||||||
|
;
|
||||||
}
|
}
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
?>
|
|
|
@ -2,49 +2,56 @@
|
||||||
|
|
||||||
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
||||||
|
|
||||||
class ADs extends PluginAbstract {
|
class ADs extends PluginAbstract
|
||||||
|
{
|
||||||
|
public static $AdsPositions = [
|
||||||
|
['leaderBoardBigVideo', 1],
|
||||||
|
['leaderBoardTop', 0],
|
||||||
|
['leaderBoardTop2', 0],
|
||||||
|
['channelLeaderBoardTop', 0],
|
||||||
|
['leaderBoardMiddle', 0],
|
||||||
|
['sideRectangle', 1],
|
||||||
|
['leaderBoardBigVideoMobile', 1],
|
||||||
|
['leaderBoardTopMobile', 1],
|
||||||
|
['leaderBoardTopMobile2', 1],
|
||||||
|
['channelLeaderBoardTopMobile', 1],
|
||||||
|
['leaderBoardMiddleMobile', 1],
|
||||||
|
];
|
||||||
|
|
||||||
static $AdsPositions = array(
|
public function getTags()
|
||||||
array('leaderBoardBigVideo', 1)
|
{
|
||||||
, array('leaderBoardTop', 0)
|
return [
|
||||||
, array('leaderBoardTop2', 0)
|
|
||||||
, array('channelLeaderBoardTop', 0)
|
|
||||||
, array('leaderBoardMiddle', 0)
|
|
||||||
, array('sideRectangle', 1)
|
|
||||||
, array('leaderBoardBigVideoMobile', 1)
|
|
||||||
, array('leaderBoardTopMobile', 1)
|
|
||||||
, array('leaderBoardTopMobile2', 1)
|
|
||||||
, array('channelLeaderBoardTopMobile', 1)
|
|
||||||
, array('leaderBoardMiddleMobile', 1));
|
|
||||||
|
|
||||||
public function getTags() {
|
|
||||||
return array(
|
|
||||||
PluginTags::$MONETIZATION,
|
PluginTags::$MONETIZATION,
|
||||||
PluginTags::$ADS,
|
PluginTags::$ADS,
|
||||||
PluginTags::$FREE
|
PluginTags::$FREE,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription() {
|
public function getDescription()
|
||||||
|
{
|
||||||
$txt = "Handle the ads system, like Adsense or similar";
|
$txt = "Handle the ads system, like Adsense or similar";
|
||||||
//$help = "<br><small><a href='https://github.com/WWBN/AVideo/wiki/AD_Overlay-Plugin' target='__blank'><i class='fas fa-question-circle'></i> Help</a></small>";
|
//$help = "<br><small><a href='https://github.com/WWBN/AVideo/wiki/AD_Overlay-Plugin' target='__blank'><i class='fas fa-question-circle'></i> Help</a></small>";
|
||||||
$help = "";
|
$help = "";
|
||||||
return $txt . $help;
|
return $txt . $help;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return "ADs";
|
return "ADs";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUUID() {
|
public function getUUID()
|
||||||
|
{
|
||||||
return "ADs73225-3807-4167-ba81-0509dd280e06";
|
return "ADs73225-3807-4167-ba81-0509dd280e06";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginVersion() {
|
public function getPluginVersion()
|
||||||
|
{
|
||||||
return "1.1";
|
return "1.1";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmptyDataObject() {
|
public function getEmptyDataObject()
|
||||||
|
{
|
||||||
global $global, $config;
|
global $global, $config;
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
|
|
||||||
|
@ -79,13 +86,15 @@ class ADs extends PluginAbstract {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginMenu() {
|
public function getPluginMenu()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$fileAPIName = $global['systemRootPath'] . 'plugin/ADs/pluginMenu.html';
|
$fileAPIName = $global['systemRootPath'] . 'plugin/ADs/pluginMenu.html';
|
||||||
return file_get_contents($fileAPIName);
|
return file_get_contents($fileAPIName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHeadCode() {
|
public function getHeadCode()
|
||||||
|
{
|
||||||
$head = "<script> var adsbygoogleTimeout; </script>";
|
$head = "<script> var adsbygoogleTimeout; </script>";
|
||||||
if (!empty($_GET['abkw'])) {
|
if (!empty($_GET['abkw'])) {
|
||||||
$abkw = preg_replace('/[^a-zA-Z0-9_ ,-]/', '', $_GET['abkw']);
|
$abkw = preg_replace('/[^a-zA-Z0-9_ ,-]/', '', $_GET['abkw']);
|
||||||
|
@ -99,7 +108,7 @@ class ADs extends PluginAbstract {
|
||||||
if (!empty($v)) {
|
if (!empty($v)) {
|
||||||
$channelName = $v["channelName"];
|
$channelName = $v["channelName"];
|
||||||
$category = $v["category"];
|
$category = $v["category"];
|
||||||
$head .= str_replace(array('{ChannelName}', '{Category}'), array(addcslashes($channelName, "'"), addcslashes($category, "'")), $obj->tags3rdParty);
|
$head .= str_replace(['{ChannelName}', '{Category}'], [addcslashes($channelName, "'"), addcslashes($category, "'")], $obj->tags3rdParty);
|
||||||
|
|
||||||
return $head;
|
return $head;
|
||||||
}
|
}
|
||||||
|
@ -109,21 +118,22 @@ class ADs extends PluginAbstract {
|
||||||
if (!empty($obj->tags3rdParty)) {
|
if (!empty($obj->tags3rdParty)) {
|
||||||
$v = Category::getCategoryByName($_GET['catName']);
|
$v = Category::getCategoryByName($_GET['catName']);
|
||||||
if (!empty($v)) {
|
if (!empty($v)) {
|
||||||
$head .= str_replace(array(',', '{ChannelName}', '{Category}'), array('', '', addcslashes($v["name"], "'")), $obj->tags3rdParty);
|
$head .= str_replace([',', '{ChannelName}', '{Category}'], ['', '', addcslashes($v["name"], "'")], $obj->tags3rdParty);
|
||||||
return $head;
|
return $head;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($_GET['channelName'])) {
|
if (!empty($_GET['channelName'])) {
|
||||||
if (!empty($obj->tags3rdParty)) {
|
if (!empty($obj->tags3rdParty)) {
|
||||||
$head .= str_replace(array(',', '{ChannelName}', '{Category}'), array('', addcslashes($_GET['channelName'], "'"), ''), $obj->tags3rdParty);
|
$head .= str_replace([',', '{ChannelName}', '{Category}'], ['', addcslashes($_GET['channelName'], "'"), ''], $obj->tags3rdParty);
|
||||||
return $head;
|
return $head;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "{$head}<script> window.abkw = 'home-page'; </script>";
|
return "{$head}<script> window.abkw = 'home-page'; </script>";
|
||||||
}
|
}
|
||||||
|
|
||||||
static function giveGoogleATimeout($adCode) {
|
public static function giveGoogleATimeout($adCode)
|
||||||
|
{
|
||||||
$videos_id = getVideos_id();
|
$videos_id = getVideos_id();
|
||||||
$showAds = AVideoPlugin::showAds($videos_id);
|
$showAds = AVideoPlugin::showAds($videos_id);
|
||||||
if (!$showAds) {
|
if (!$showAds) {
|
||||||
|
@ -136,15 +146,17 @@ class ADs extends PluginAbstract {
|
||||||
return $adCode;
|
return $adCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAds($videos_id){
|
public function showAds($videos_id)
|
||||||
|
{
|
||||||
$obj = AVideoPlugin::getDataObject('ADs');
|
$obj = AVideoPlugin::getDataObject('ADs');
|
||||||
if($obj->doNotShowAdsForPaidUsers && User::isLogged()){
|
if ($obj->doNotShowAdsForPaidUsers && User::isLogged()) {
|
||||||
return !AVideoPlugin::isPaidUser(User::getId());
|
return !AVideoPlugin::isPaidUser(User::getId());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAdsPath($type) {
|
public static function getAdsPath($type)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$typeFound = false;
|
$typeFound = false;
|
||||||
foreach (ADs::$AdsPositions as $key => $value) {
|
foreach (ADs::$AdsPositions as $key => $value) {
|
||||||
|
@ -161,10 +173,11 @@ class ADs extends PluginAbstract {
|
||||||
$videosURL = "{$global['webSiteRootURL']}videos/ADs/{$type}/";
|
$videosURL = "{$global['webSiteRootURL']}videos/ADs/{$type}/";
|
||||||
make_path($videosDir);
|
make_path($videosDir);
|
||||||
|
|
||||||
return array('path' => $videosDir, 'url' => $videosURL);
|
return ['path' => $videosDir, 'url' => $videosURL];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getNewAdsPath($type) {
|
public static function getNewAdsPath($type)
|
||||||
|
{
|
||||||
$paths = self::getAdsPath($type);
|
$paths = self::getAdsPath($type);
|
||||||
|
|
||||||
if (empty($paths)) {
|
if (empty($paths)) {
|
||||||
|
@ -173,10 +186,11 @@ class ADs extends PluginAbstract {
|
||||||
|
|
||||||
$fileName = uniqid();
|
$fileName = uniqid();
|
||||||
|
|
||||||
return array('fileName' => $fileName, 'path' => $paths['path'] . $fileName . '.png', 'url' => $paths['url'] . $fileName . '.png', 'txt' => $paths['path'] . $fileName . '.txt');
|
return ['fileName' => $fileName, 'path' => $paths['path'] . $fileName . '.png', 'url' => $paths['url'] . $fileName . '.png', 'txt' => $paths['path'] . $fileName . '.txt'];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAds($type) {
|
public static function getAds($type)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$paths = self::getAdsPath($type);
|
$paths = self::getAdsPath($type);
|
||||||
|
|
||||||
|
@ -189,29 +203,31 @@ class ADs extends PluginAbstract {
|
||||||
|
|
||||||
|
|
||||||
$files = _glob($paths['path'], '/.png$/');
|
$files = _glob($paths['path'], '/.png$/');
|
||||||
$return = array();
|
$return = [];
|
||||||
foreach ($files as $value) {
|
foreach ($files as $value) {
|
||||||
$fileName = str_replace($videosDir, '', $value);
|
$fileName = str_replace($videosDir, '', $value);
|
||||||
$fileName = str_replace('.png', '', $fileName);
|
$fileName = str_replace('.png', '', $fileName);
|
||||||
$return[] = array('type' => $type, 'fileName' => $fileName, 'url' => file_get_contents($videosDir . "{$fileName}.txt"), 'imageURL' => $videosURL . "{$fileName}.png", 'imagePath' => $value);
|
$return[] = ['type' => $type, 'fileName' => $fileName, 'url' => file_get_contents($videosDir . "{$fileName}.txt"), 'imageURL' => $videosURL . "{$fileName}.png", 'imagePath' => $value];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getSize($type) {
|
public static function getSize($type)
|
||||||
|
{
|
||||||
$obj = AVideoPlugin::getObjectData("ADs");
|
$obj = AVideoPlugin::getObjectData("ADs");
|
||||||
foreach (ADs::$AdsPositions as $key => $value) {
|
foreach (ADs::$AdsPositions as $key => $value) {
|
||||||
if ($type == $value[0]) {
|
if ($type == $value[0]) {
|
||||||
eval("\$width = \$obj->$value[0]Width;");
|
eval("\$width = \$obj->$value[0]Width;");
|
||||||
eval("\$height = \$obj->$value[0]Height;");
|
eval("\$height = \$obj->$value[0]Height;");
|
||||||
return array('width' => $width, 'height' => $height, 'isMobile' => preg_match('/mobile/i', $value[0]), 'isSquare' => $value[1]);
|
return ['width' => $width, 'height' => $height, 'isMobile' => preg_match('/mobile/i', $value[0]), 'isSquare' => $value[1]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return array('width' => null, 'height' => null);
|
return ['width' => null, 'height' => null];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAdsHTML($type) {
|
public static function getAdsHTML($type)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$paths = self::getAds($type);
|
$paths = self::getAds($type);
|
||||||
|
|
||||||
|
@ -238,7 +254,7 @@ class ADs extends PluginAbstract {
|
||||||
$validPaths = 0;
|
$validPaths = 0;
|
||||||
foreach ($paths as $value) {
|
foreach ($paths as $value) {
|
||||||
$fsize= filesize($value['imagePath']);
|
$fsize= filesize($value['imagePath']);
|
||||||
if($fsize<5000){
|
if ($fsize<5000) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$validPaths++;
|
$validPaths++;
|
||||||
|
@ -264,14 +280,15 @@ class ADs extends PluginAbstract {
|
||||||
<span class=\"glyphicon glyphicon-chevron-right\"></span>
|
<span class=\"glyphicon glyphicon-chevron-right\"></span>
|
||||||
<span class=\"sr-only\">Next</span>
|
<span class=\"sr-only\">Next</span>
|
||||||
</a>";
|
</a>";
|
||||||
}else if(empty($validPaths) && User::isAdmin()){
|
} elseif (empty($validPaths) && User::isAdmin()) {
|
||||||
$html .= "<div class='alert alert-warning'>{$type} ADs Area</div>";
|
$html .= "<div class='alert alert-warning'>{$type} ADs Area</div>";
|
||||||
}
|
}
|
||||||
$html .= "</div></div></center>";
|
$html .= "</div></div></center>";
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFooterCode() {
|
public function getFooterCode()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$js = "<script>$(function(){
|
$js = "<script>$(function(){
|
||||||
$('.carousel').carousel({
|
$('.carousel').carousel({
|
||||||
|
@ -281,12 +298,12 @@ class ADs extends PluginAbstract {
|
||||||
return $js;
|
return $js;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function saveAdsHTML($type) {
|
public static function saveAdsHTML($type)
|
||||||
|
{
|
||||||
$o = new stdClass();
|
$o = new stdClass();
|
||||||
$o->type = "textarea";
|
$o->type = "textarea";
|
||||||
$o->value = self::getAdsHTML($type);
|
$o->value = self::getAdsHTML($type);
|
||||||
$p = new ADs();
|
$p = new ADs();
|
||||||
return $p->updateParameter($type, $o);
|
return $p->updateParameter($type, $o);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ if (empty($type)) {
|
||||||
|
|
||||||
$typeFound = false;
|
$typeFound = false;
|
||||||
foreach (ADs::$AdsPositions as $key => $value) {
|
foreach (ADs::$AdsPositions as $key => $value) {
|
||||||
if($type===$value[0]){
|
if ($type===$value[0]) {
|
||||||
$typeFound = true;
|
$typeFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,12 +59,10 @@ if (empty($obj)) {
|
||||||
<?php
|
<?php
|
||||||
$active = ' in active';
|
$active = ' in active';
|
||||||
foreach (ADs::$AdsPositions as $key => $value) {
|
foreach (ADs::$AdsPositions as $key => $value) {
|
||||||
|
|
||||||
$size = ADs::getSize($value[0]);
|
$size = ADs::getSize($value[0]);
|
||||||
|
|
||||||
$width = $size['width'];
|
$width = $size['width'];
|
||||||
$height = $size['height'];
|
$height = $size['height']; ?>
|
||||||
?>
|
|
||||||
<div id="adsTabs<?php echo $key; ?>" class="tab-pane fade <?php echo $active; ?>">
|
<div id="adsTabs<?php echo $key; ?>" class="tab-pane fade <?php echo $active; ?>">
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
|
@ -76,8 +74,7 @@ if (empty($obj)) {
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<?php
|
<?php
|
||||||
$croppie1 = getCroppie(__("Upload Image") . ' ' . $value[0], "setImage_" . $value[0], $width, $height);
|
$croppie1 = getCroppie(__("Upload Image") . ' ' . $value[0], "setImage_" . $value[0], $width, $height);
|
||||||
echo $croppie1['html'];
|
echo $croppie1['html']; ?>
|
||||||
?>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="inputAdsURL<?php echo $value[0]; ?>"><?php echo __("URL"); ?></label>
|
<label for="inputAdsURL<?php echo $value[0]; ?>"><?php echo __("URL"); ?></label>
|
||||||
|
@ -98,13 +95,11 @@ if (empty($obj)) {
|
||||||
class="img img-responsive pull-left"
|
class="img img-responsive pull-left"
|
||||||
style="max-height: 60px; max-width: 150px; margin-right: 10px;">
|
style="max-height: 60px; max-width: 150px; margin-right: 10px;">
|
||||||
<?php
|
<?php
|
||||||
echo $item["url"];
|
echo $item["url"]; ?>
|
||||||
?>
|
|
||||||
<button class="btn btn-sm btn-danger pull-right" onclick="deleteAdsImage('<?php echo $item["type"]; ?>', '<?php echo $item["fileName"]; ?>')"><i class="fas fa-trash"></i></button>
|
<button class="btn btn-sm btn-danger pull-right" onclick="deleteAdsImage('<?php echo $item["type"]; ?>', '<?php echo $item["fileName"]; ?>')"><i class="fas fa-trash"></i></button>
|
||||||
</li>
|
</li>
|
||||||
<?php
|
<?php
|
||||||
}
|
} ?>
|
||||||
?>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -114,8 +109,7 @@ if (empty($obj)) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
<?php
|
<?php
|
||||||
echo $croppie1['getCroppieFunction'];
|
echo $croppie1['getCroppieFunction']; ?>
|
||||||
?>
|
|
||||||
}, 500);
|
}, 500);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -11,7 +11,6 @@ $result->msg = '';
|
||||||
$result->url = '';
|
$result->url = '';
|
||||||
$result->imageURL = '';
|
$result->imageURL = '';
|
||||||
|
|
||||||
|
|
||||||
if (!User::isAdmin()) {
|
if (!User::isAdmin()) {
|
||||||
$result->msg = __("You can not do this");
|
$result->msg = __("You can not do this");
|
||||||
die(json_encode($result));
|
die(json_encode($result));
|
||||||
|
@ -32,7 +31,7 @@ if (empty($type)) {
|
||||||
|
|
||||||
$typeFound = false;
|
$typeFound = false;
|
||||||
foreach (ADs::$AdsPositions as $key => $value) {
|
foreach (ADs::$AdsPositions as $key => $value) {
|
||||||
if($type===$value[0]){
|
if ($type===$value[0]) {
|
||||||
$typeFound = true;
|
$typeFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +42,7 @@ if (empty($typeFound)) {
|
||||||
die(json_encode($result));
|
die(json_encode($result));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!IsValidURL(@$_REQUEST['url'])){
|
if (!IsValidURL(@$_REQUEST['url'])) {
|
||||||
$_REQUEST['url'] = '';
|
$_REQUEST['url'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,43 +1,49 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
||||||
|
|
||||||
class API extends PluginAbstract {
|
class API extends PluginAbstract
|
||||||
|
{
|
||||||
public function getTags() {
|
public function getTags()
|
||||||
return array(
|
{
|
||||||
|
return [
|
||||||
PluginTags::$FREE,
|
PluginTags::$FREE,
|
||||||
PluginTags::$MOBILE
|
PluginTags::$MOBILE,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription() {
|
public function getDescription()
|
||||||
|
{
|
||||||
return "Handle APIs for third party Applications";
|
return "Handle APIs for third party Applications";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return "API";
|
return "API";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUUID() {
|
public function getUUID()
|
||||||
|
{
|
||||||
return "1apicbec-91db-4357-bb10-ee08b0913778";
|
return "1apicbec-91db-4357-bb10-ee08b0913778";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmptyDataObject() {
|
public function getEmptyDataObject()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->APISecret = md5($global['systemRootPath']);
|
$obj->APISecret = md5($global['systemRootPath']);
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginMenu() {
|
public function getPluginMenu()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$fileAPIName = $global['systemRootPath'] . 'plugin/API/pluginMenu.html';
|
$fileAPIName = $global['systemRootPath'] . 'plugin/API/pluginMenu.html';
|
||||||
return file_get_contents($fileAPIName);
|
return file_get_contents($fileAPIName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set($parameters) {
|
public function set($parameters)
|
||||||
|
{
|
||||||
if (empty($parameters['APIName'])) {
|
if (empty($parameters['APIName'])) {
|
||||||
$object = new ApiObject("Parameter APIName can not be empty (set)");
|
$object = new ApiObject("Parameter APIName can not be empty (set)");
|
||||||
} else {
|
} else {
|
||||||
|
@ -62,7 +68,8 @@ class API extends PluginAbstract {
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($parameters) {
|
public function get($parameters)
|
||||||
|
{
|
||||||
if (empty($parameters['APIName'])) {
|
if (empty($parameters['APIName'])) {
|
||||||
$object = new ApiObject("Parameter APIName can not be empty (get)");
|
$object = new ApiObject("Parameter APIName can not be empty (get)");
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,13 +94,14 @@ class API extends PluginAbstract {
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function startResponseObject($parameters) {
|
private function startResponseObject($parameters)
|
||||||
|
{
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
if (empty($parameters['sort']) && !empty($parameters['order'][0]['dir'])) {
|
if (empty($parameters['sort']) && !empty($parameters['order'][0]['dir'])) {
|
||||||
$index = intval($parameters['order'][0]['column']);
|
$index = intval($parameters['order'][0]['column']);
|
||||||
$parameters['sort'][$parameters['columns'][$index]['data']] = $_GET['order'][0]['dir'];
|
$parameters['sort'][$parameters['columns'][$index]['data']] = $_GET['order'][0]['dir'];
|
||||||
}
|
}
|
||||||
$array = array('sort', 'rowCount', 'current', 'searchPhrase');
|
$array = ['sort', 'rowCount', 'current', 'searchPhrase'];
|
||||||
foreach ($array as $value) {
|
foreach ($array as $value) {
|
||||||
if (!empty($parameters[$value])) {
|
if (!empty($parameters[$value])) {
|
||||||
$obj->$value = $parameters[$value];
|
$obj->$value = $parameters[$value];
|
||||||
|
@ -104,7 +112,8 @@ class API extends PluginAbstract {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getToPost() {
|
private function getToPost()
|
||||||
|
{
|
||||||
foreach ($_GET as $key => $value) {
|
foreach ($_GET as $key => $value) {
|
||||||
$_POST[$key] = $value;
|
$_POST[$key] = $value;
|
||||||
}
|
}
|
||||||
|
@ -117,7 +126,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&rowCount=3&APISecret={APISecret}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&rowCount=3&APISecret={APISecret}
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_plugin_parameters($parameters) {
|
public function get_api_plugin_parameters($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$name = "get_api_plugin_parameters" . json_encode($parameters);
|
$name = "get_api_plugin_parameters" . json_encode($parameters);
|
||||||
$obj = ObjectYPT::getCache($name, 3600);
|
$obj = ObjectYPT::getCache($name, 3600);
|
||||||
|
@ -148,7 +158,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&userAgent=Mozilla%2F5.0+%28Windows+NT+10.0%3B+Win64%3B+x64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F89.0.4389.82+Safari%2F537.36
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&userAgent=Mozilla%2F5.0+%28Windows+NT+10.0%3B+Win64%3B+x64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F89.0.4389.82+Safari%2F537.36
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_is_mobile($parameters) {
|
public function get_api_is_mobile($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = $this->startResponseObject($parameters);
|
$obj = $this->startResponseObject($parameters);
|
||||||
if (!empty($_REQUEST['httpHeaders'])) {
|
if (!empty($_REQUEST['httpHeaders'])) {
|
||||||
|
@ -156,7 +167,7 @@ class API extends PluginAbstract {
|
||||||
if (!empty($json)) {
|
if (!empty($json)) {
|
||||||
$_REQUEST['httpHeaders'] = $json;
|
$_REQUEST['httpHeaders'] = $json;
|
||||||
} else {
|
} else {
|
||||||
$_REQUEST['httpHeaders'] = array($_REQUEST['httpHeaders']);
|
$_REQUEST['httpHeaders'] = [$_REQUEST['httpHeaders']];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$obj->userAgent = @$_REQUEST['userAgent'];
|
$obj->userAgent = @$_REQUEST['userAgent'];
|
||||||
|
@ -175,7 +186,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&rowCount=3¤t=1&sort[created]=DESC
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&rowCount=3¤t=1&sort[created]=DESC
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_category($parameters) {
|
public function get_api_category($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/category.php';
|
require_once $global['systemRootPath'] . 'objects/category.php';
|
||||||
$obj = $this->startResponseObject($parameters);
|
$obj = $this->startResponseObject($parameters);
|
||||||
|
@ -195,7 +207,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&playlists_id=1&index=2&APISecret={APISecret}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&playlists_id=1&index=2&APISecret={APISecret}
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_video_from_program($parameters) {
|
public function get_api_video_from_program($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$playlists = AVideoPlugin::loadPlugin("PlayLists");
|
$playlists = AVideoPlugin::loadPlugin("PlayLists");
|
||||||
if (empty($parameters['playlists_id'])) {
|
if (empty($parameters['playlists_id'])) {
|
||||||
|
@ -239,7 +252,6 @@ class API extends PluginAbstract {
|
||||||
$parameters['totalPlaylistDuration'] = 0;
|
$parameters['totalPlaylistDuration'] = 0;
|
||||||
$parameters['currentPlaylistTime'] = 0;
|
$parameters['currentPlaylistTime'] = 0;
|
||||||
foreach ($parameters['videos'] as $key => $value) {
|
foreach ($parameters['videos'] as $key => $value) {
|
||||||
|
|
||||||
$parameters['videos'][$key]['path'] = Video::getHigherVideoPathFromID($value['id']);
|
$parameters['videos'][$key]['path'] = Video::getHigherVideoPathFromID($value['id']);
|
||||||
if ($key && $key <= $parameters['index']) {
|
if ($key && $key <= $parameters['index']) {
|
||||||
$parameters['currentPlaylistTime'] += durationToSeconds($parameters['videos'][$key - 1]['duration']);
|
$parameters['currentPlaylistTime'] += durationToSeconds($parameters['videos'][$key - 1]['duration']);
|
||||||
|
@ -270,7 +282,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&APISecret={APISecret}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&APISecret={APISecret}
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_video_file($parameters) {
|
public function get_api_video_file($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = $this->startResponseObject($parameters);
|
$obj = $this->startResponseObject($parameters);
|
||||||
$obj->videos_id = $parameters['videos_id'];
|
$obj->videos_id = $parameters['videos_id'];
|
||||||
|
@ -304,8 +317,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&catName=default&rowCount=10
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&catName=default&rowCount=10
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_video($parameters) {
|
public function get_api_video($parameters)
|
||||||
|
{
|
||||||
$rowCount = getRowCount();
|
$rowCount = getRowCount();
|
||||||
if ($rowCount > 100) {
|
if ($rowCount > 100) {
|
||||||
// use 1 hour cache
|
// use 1 hour cache
|
||||||
|
@ -327,12 +340,12 @@ class API extends PluginAbstract {
|
||||||
$status = "";
|
$status = "";
|
||||||
$ignoreGroup = true;
|
$ignoreGroup = true;
|
||||||
}
|
}
|
||||||
$rows = array(Video::getVideo($parameters['videos_id'], $status, $ignoreGroup));
|
$rows = [Video::getVideo($parameters['videos_id'], $status, $ignoreGroup)];
|
||||||
$totalRows = empty($rows) ? 0 : 1;
|
$totalRows = empty($rows) ? 0 : 1;
|
||||||
} else if ($dataObj->APISecret === @$_GET['APISecret']) {
|
} elseif ($dataObj->APISecret === @$_GET['APISecret']) {
|
||||||
$rows = Video::getAllVideos("viewable", false, true);
|
$rows = Video::getAllVideos("viewable", false, true);
|
||||||
$totalRows = Video::getTotalVideos("viewable", false, true);
|
$totalRows = Video::getTotalVideos("viewable", false, true);
|
||||||
} else if (!empty($parameters['clean_title'])) {
|
} elseif (!empty($parameters['clean_title'])) {
|
||||||
$rows = Video::getVideoFromCleanTitle($parameters['clean_title']);
|
$rows = Video::getVideoFromCleanTitle($parameters['clean_title']);
|
||||||
$totalRows = empty($rows) ? 0 : 1;
|
$totalRows = empty($rows) ? 0 : 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -427,7 +440,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_videosCount($parameters) {
|
public function get_api_videosCount($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/video.php';
|
require_once $global['systemRootPath'] . 'objects/video.php';
|
||||||
$obj = $this->startResponseObject($parameters);
|
$obj = $this->startResponseObject($parameters);
|
||||||
|
@ -452,7 +466,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123&APISecret={APISecret}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123&APISecret={APISecret}
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_video_delete($parameters) {
|
public function get_api_video_delete($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/video.php';
|
require_once $global['systemRootPath'] . 'objects/video.php';
|
||||||
$obj = $this->startResponseObject($parameters);
|
$obj = $this->startResponseObject($parameters);
|
||||||
|
@ -486,14 +501,15 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123&APISecret={APISecret}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123&APISecret={APISecret}
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function set_api_comment($parameters) {
|
public function set_api_comment($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = $this->startResponseObject($parameters);
|
$obj = $this->startResponseObject($parameters);
|
||||||
$dataObj = $this->getDataObject();
|
$dataObj = $this->getDataObject();
|
||||||
if (!empty($parameters['videos_id'])) {
|
if (!empty($parameters['videos_id'])) {
|
||||||
if (!empty($_GET['APISecret']) && $dataObj->APISecret !== $_GET['APISecret']) {
|
if (!empty($_GET['APISecret']) && $dataObj->APISecret !== $_GET['APISecret']) {
|
||||||
return new ApiObject("Secret does not match");
|
return new ApiObject("Secret does not match");
|
||||||
} else if (!User::canComment()) {
|
} elseif (!User::canComment()) {
|
||||||
return new ApiObject("Access denied");
|
return new ApiObject("Access denied");
|
||||||
}
|
}
|
||||||
$parameters['comments_id'] = intval(@$parameters['comments_id']);
|
$parameters['comments_id'] = intval(@$parameters['comments_id']);
|
||||||
|
@ -526,7 +542,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123&APISecret={APISecret}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123&APISecret={APISecret}
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function set_api_video_save($parameters) {
|
public function set_api_video_save($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/video.php';
|
require_once $global['systemRootPath'] . 'objects/video.php';
|
||||||
$obj = $this->startResponseObject($parameters);
|
$obj = $this->startResponseObject($parameters);
|
||||||
|
@ -561,7 +578,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_livestreams($parameters) {
|
public function get_api_livestreams($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'plugin/Live/stats.json.php';
|
require_once $global['systemRootPath'] . 'plugin/Live/stats.json.php';
|
||||||
exit;
|
exit;
|
||||||
|
@ -579,7 +597,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}&users_id=1
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}&users_id=1
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function set_api_livestream_save($parameters) {
|
public function set_api_livestream_save($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/video.php';
|
require_once $global['systemRootPath'] . 'objects/video.php';
|
||||||
$obj = $this->startResponseObject($parameters);
|
$obj = $this->startResponseObject($parameters);
|
||||||
|
@ -626,13 +645,13 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}&users_id=1
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}&users_id=1
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_user($parameters) {
|
public function get_api_user($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/video.php';
|
require_once $global['systemRootPath'] . 'objects/video.php';
|
||||||
$obj = $this->startResponseObject($parameters);
|
$obj = $this->startResponseObject($parameters);
|
||||||
$dataObj = $this->getDataObject();
|
$dataObj = $this->getDataObject();
|
||||||
if ($dataObj->APISecret === @$_GET['APISecret'] || User::isLogged()) {
|
if ($dataObj->APISecret === @$_GET['APISecret'] || User::isLogged()) {
|
||||||
|
|
||||||
if (!empty($parameters['users_id'])) {
|
if (!empty($parameters['users_id'])) {
|
||||||
if ($dataObj->APISecret !== @$_GET['APISecret']) {
|
if ($dataObj->APISecret !== @$_GET['APISecret']) {
|
||||||
$parameters['users_id'] = User::getId();
|
$parameters['users_id'] = User::getId();
|
||||||
|
@ -671,12 +690,12 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}&status=a&rowCount=3&searchPhrase=test
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}&status=a&rowCount=3&searchPhrase=test
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_users_list($parameters) {
|
public function get_api_users_list($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = $this->startResponseObject($parameters);
|
$obj = $this->startResponseObject($parameters);
|
||||||
$dataObj = $this->getDataObject();
|
$dataObj = $this->getDataObject();
|
||||||
if ($dataObj->APISecret === $_GET['APISecret']) {
|
if ($dataObj->APISecret === $_GET['APISecret']) {
|
||||||
|
|
||||||
$status = '';
|
$status = '';
|
||||||
if (!empty($_GET['status'])) {
|
if (!empty($_GET['status'])) {
|
||||||
if ($_GET['status'] === 'i') {
|
if ($_GET['status'] === 'i') {
|
||||||
|
@ -686,7 +705,7 @@ class API extends PluginAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$rows = User::getAllUsers(true, array('user', 'name'), $status);
|
$rows = User::getAllUsers(true, ['user', 'name'], $status);
|
||||||
|
|
||||||
return new ApiObject("", false, $rows);
|
return new ApiObject("", false, $rows);
|
||||||
} else {
|
} else {
|
||||||
|
@ -709,7 +728,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_videosViewsCount($parameters) {
|
public function get_api_videosViewsCount($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/video.php';
|
require_once $global['systemRootPath'] . 'objects/video.php';
|
||||||
$obj = $this->startResponseObject($parameters);
|
$obj = $this->startResponseObject($parameters);
|
||||||
|
@ -717,10 +737,10 @@ class API extends PluginAbstract {
|
||||||
if ($dataObj->APISecret === @$_GET['APISecret']) {
|
if ($dataObj->APISecret === @$_GET['APISecret']) {
|
||||||
$rows = Video::getAllVideos("viewable", false, true);
|
$rows = Video::getAllVideos("viewable", false, true);
|
||||||
$totalRows = Video::getTotalVideos("viewable", false, true);
|
$totalRows = Video::getTotalVideos("viewable", false, true);
|
||||||
} else if (!empty($parameters['videos_id'])) {
|
} elseif (!empty($parameters['videos_id'])) {
|
||||||
$rows = array(Video::getVideo($parameters['videos_id']));
|
$rows = [Video::getVideo($parameters['videos_id'])];
|
||||||
$totalRows = empty($rows) ? 0 : 1;
|
$totalRows = empty($rows) ? 0 : 1;
|
||||||
} else if (!empty($parameters['clean_title'])) {
|
} elseif (!empty($parameters['clean_title'])) {
|
||||||
$rows = Video::getVideoFromCleanTitle($parameters['clean_title']);
|
$rows = Video::getVideoFromCleanTitle($parameters['clean_title']);
|
||||||
$totalRows = empty($rows) ? 0 : 1;
|
$totalRows = empty($rows) ? 0 : 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -746,11 +766,12 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_channels($parameters) {
|
public function get_api_channels($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/Channel.php';
|
require_once $global['systemRootPath'] . 'objects/Channel.php';
|
||||||
$channels = Channel::getChannels();
|
$channels = Channel::getChannels();
|
||||||
$list = array();
|
$list = [];
|
||||||
foreach ($channels as $value) {
|
foreach ($channels as $value) {
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->id = $value['id'];
|
$obj->id = $value['id'];
|
||||||
|
@ -769,11 +790,12 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_programs($parameters) {
|
public function get_api_programs($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/playlist.php';
|
require_once $global['systemRootPath'] . 'objects/playlist.php';
|
||||||
$playlists = PlayList::getAll();
|
$playlists = PlayList::getAll();
|
||||||
$list = array();
|
$list = [];
|
||||||
foreach ($playlists as $value) {
|
foreach ($playlists as $value) {
|
||||||
$videosArrayId = PlayList::getVideosIdFromPlaylist($value['id']);
|
$videosArrayId = PlayList::getVideosIdFromPlaylist($value['id']);
|
||||||
if (empty($videosArrayId) || $value['status'] == "favorite" || $value['status'] == "watch_later") {
|
if (empty($videosArrayId) || $value['status'] == "favorite" || $value['status'] == "watch_later") {
|
||||||
|
@ -798,7 +820,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?users_id=1&APIName={APIName}&APISecret={APISecret}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?users_id=1&APIName={APIName}&APISecret={APISecret}
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_subscribers($parameters) {
|
public function get_api_subscribers($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
|
|
||||||
$name = "get_api_subscribers" . json_encode($parameters);
|
$name = "get_api_subscribers" . json_encode($parameters);
|
||||||
|
@ -825,12 +848,13 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_categories($parameters) {
|
public function get_api_categories($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/category.php';
|
require_once $global['systemRootPath'] . 'objects/category.php';
|
||||||
$categories = Category::getAllCategories();
|
$categories = Category::getAllCategories();
|
||||||
array_multisort(array_column($categories, 'hierarchyAndName'), SORT_ASC, $categories);
|
array_multisort(array_column($categories, 'hierarchyAndName'), SORT_ASC, $categories);
|
||||||
$list = array();
|
$list = [];
|
||||||
foreach ($categories as $value) {
|
foreach ($categories as $value) {
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->id = $value['id'];
|
$obj->id = $value['id'];
|
||||||
|
@ -850,7 +874,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function get_api_likes($parameters) {
|
public function get_api_likes($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/like.php';
|
require_once $global['systemRootPath'] . 'objects/like.php';
|
||||||
if (empty($parameters['videos_id'])) {
|
if (empty($parameters['videos_id'])) {
|
||||||
|
@ -867,7 +892,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function set_api_like($parameters) {
|
public function set_api_like($parameters)
|
||||||
|
{
|
||||||
return $this->like($parameters, 1);
|
return $this->like($parameters, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -879,7 +905,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function set_api_dislike($parameters) {
|
public function set_api_dislike($parameters)
|
||||||
|
{
|
||||||
return $this->like($parameters, -1);
|
return $this->like($parameters, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -891,7 +918,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=1&user=admin&pass=123
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function set_api_removelike($parameters) {
|
public function set_api_removelike($parameters)
|
||||||
|
{
|
||||||
return $this->like($parameters, 0);
|
return $this->like($parameters, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,7 +932,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function get_api_signIn($parameters) {
|
public function get_api_signIn($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$this->getToPost();
|
$this->getToPost();
|
||||||
require_once $global['systemRootPath'] . 'objects/login.json.php';
|
require_once $global['systemRootPath'] . 'objects/login.json.php';
|
||||||
|
@ -922,7 +951,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}&user=admin&pass=123&email=me@mysite.com&name=Yeshua
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}&user=admin&pass=123&email=me@mysite.com&name=Yeshua
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function set_api_signUp($parameters) {
|
public function set_api_signUp($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$this->getToPost();
|
$this->getToPost();
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
|
@ -934,7 +964,8 @@ class API extends PluginAbstract {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function like($parameters, $like) {
|
private function like($parameters, $like)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/like.php';
|
require_once $global['systemRootPath'] . 'objects/like.php';
|
||||||
if (empty($parameters['videos_id'])) {
|
if (empty($parameters['videos_id'])) {
|
||||||
|
@ -959,7 +990,8 @@ class API extends PluginAbstract {
|
||||||
* @example for JSON response: {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=3&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true&optionalAdTagUrl=2&json=1
|
* @example for JSON response: {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=3&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true&optionalAdTagUrl=2&json=1
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function get_api_vmap($parameters) {
|
public function get_api_vmap($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$this->getToPost();
|
$this->getToPost();
|
||||||
require_once $global['systemRootPath'] . 'plugin/GoogleAds_IMA/VMAP.php';
|
require_once $global['systemRootPath'] . 'plugin/GoogleAds_IMA/VMAP.php';
|
||||||
|
@ -977,7 +1009,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=3&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true&optionalAdTagUrl=2
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=3&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true&optionalAdTagUrl=2
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function get_api_vast($parameters) {
|
public function get_api_vast($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$this->getToPost();
|
$this->getToPost();
|
||||||
$vastOnly = 1;
|
$vastOnly = 1;
|
||||||
|
@ -993,7 +1026,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}&ip=2.20.147.123
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}&ip=2.20.147.123
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function get_api_IP2Location($parameters) {
|
public function get_api_IP2Location($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$this->getToPost();
|
$this->getToPost();
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
|
@ -1019,7 +1053,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function get_api_favorite($parameters) {
|
public function get_api_favorite($parameters)
|
||||||
|
{
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled("PlayLists");
|
$plugin = AVideoPlugin::loadPluginIfEnabled("PlayLists");
|
||||||
if (empty($plugin)) {
|
if (empty($plugin)) {
|
||||||
return new ApiObject("Plugin disabled");
|
return new ApiObject("Plugin disabled");
|
||||||
|
@ -1053,7 +1088,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=3&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=3&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function set_api_favorite($parameters) {
|
public function set_api_favorite($parameters)
|
||||||
|
{
|
||||||
$this->favorite($parameters, true);
|
$this->favorite($parameters, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1066,11 +1102,13 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=3&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=3&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function set_api_removeFavorite($parameters) {
|
public function set_api_removeFavorite($parameters)
|
||||||
|
{
|
||||||
$this->favorite($parameters, false);
|
$this->favorite($parameters, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function favorite($parameters, $add) {
|
private function favorite($parameters, $add)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled("PlayLists");
|
$plugin = AVideoPlugin::loadPluginIfEnabled("PlayLists");
|
||||||
if (empty($plugin)) {
|
if (empty($plugin)) {
|
||||||
|
@ -1095,7 +1133,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function get_api_watch_later($parameters) {
|
public function get_api_watch_later($parameters)
|
||||||
|
{
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled("PlayLists");
|
$plugin = AVideoPlugin::loadPluginIfEnabled("PlayLists");
|
||||||
if (empty($plugin)) {
|
if (empty($plugin)) {
|
||||||
return new ApiObject("Plugin disabled");
|
return new ApiObject("Plugin disabled");
|
||||||
|
@ -1134,7 +1173,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=3&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=3&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function set_api_watch_later($parameters) {
|
public function set_api_watch_later($parameters)
|
||||||
|
{
|
||||||
$this->watch_later($parameters, true);
|
$this->watch_later($parameters, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1147,11 +1187,13 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=3&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&videos_id=3&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function set_api_removeWatch_later($parameters) {
|
public function set_api_removeWatch_later($parameters)
|
||||||
|
{
|
||||||
$this->watch_later($parameters, false);
|
$this->watch_later($parameters, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function watch_later($parameters, $add) {
|
private function watch_later($parameters, $add)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled("PlayLists");
|
$plugin = AVideoPlugin::loadPluginIfEnabled("PlayLists");
|
||||||
if (empty($plugin)) {
|
if (empty($plugin)) {
|
||||||
|
@ -1180,7 +1222,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&message=HelloWorld&users_id=2&room_users_id=4&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&message=HelloWorld&users_id=2&room_users_id=4&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function set_api_chat2_message($parameters) {
|
public function set_api_chat2_message($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled("Chat2");
|
$plugin = AVideoPlugin::loadPluginIfEnabled("Chat2");
|
||||||
if (empty($plugin)) {
|
if (empty($plugin)) {
|
||||||
|
@ -1210,7 +1253,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&greater_then_id=88&lower_then_id=98&to_users_id=2&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&greater_then_id=88&lower_then_id=98&to_users_id=2&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function get_api_chat2_chat($parameters) {
|
public function get_api_chat2_chat($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled("Chat2");
|
$plugin = AVideoPlugin::loadPluginIfEnabled("Chat2");
|
||||||
if (empty($plugin)) {
|
if (empty($plugin)) {
|
||||||
|
@ -1224,10 +1268,10 @@ class API extends PluginAbstract {
|
||||||
|
|
||||||
if (!empty($parameters['greater_then_id'])) {
|
if (!empty($parameters['greater_then_id'])) {
|
||||||
if (empty($_SESSION['chatLog'])) {
|
if (empty($_SESSION['chatLog'])) {
|
||||||
$_SESSION['chatLog'] = array();
|
$_SESSION['chatLog'] = [];
|
||||||
}
|
}
|
||||||
if (empty($_SESSION['chatLog'][$_GET['to_users_id']])) {
|
if (empty($_SESSION['chatLog'][$_GET['to_users_id']])) {
|
||||||
$_SESSION['chatLog'][$_GET['to_users_id']] = array();
|
$_SESSION['chatLog'][$_GET['to_users_id']] = [];
|
||||||
}
|
}
|
||||||
$_SESSION['chatLog'][$_GET['to_users_id']][0]['id'] = $parameters['greater_then_id'];
|
$_SESSION['chatLog'][$_GET['to_users_id']][0]['id'] = $parameters['greater_then_id'];
|
||||||
}
|
}
|
||||||
|
@ -1250,7 +1294,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&greater_then_id=88&lower_then_id=98&room_users_id=2&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&greater_then_id=88&lower_then_id=98&room_users_id=2&user=admin&pass=f321d14cdeeb7cded7489f504fa8862b&encodedPass=true
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function get_api_chat2_room($parameters) {
|
public function get_api_chat2_room($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled("Chat2");
|
$plugin = AVideoPlugin::loadPluginIfEnabled("Chat2");
|
||||||
if (empty($plugin)) {
|
if (empty($plugin)) {
|
||||||
|
@ -1264,10 +1309,10 @@ class API extends PluginAbstract {
|
||||||
|
|
||||||
if (!empty($parameters['greater_then_id'])) {
|
if (!empty($parameters['greater_then_id'])) {
|
||||||
if (empty($_SESSION['chatLog'])) {
|
if (empty($_SESSION['chatLog'])) {
|
||||||
$_SESSION['chatLog'] = array();
|
$_SESSION['chatLog'] = [];
|
||||||
}
|
}
|
||||||
if (empty($_SESSION['chatLog'][$_GET['to_users_id']])) {
|
if (empty($_SESSION['chatLog'][$_GET['to_users_id']])) {
|
||||||
$_SESSION['chatLog'][$_GET['to_users_id']] = array();
|
$_SESSION['chatLog'][$_GET['to_users_id']] = [];
|
||||||
}
|
}
|
||||||
$_SESSION['chatLog'][$_GET['to_users_id']][0]['id'] = $parameters['greater_then_id'];
|
$_SESSION['chatLog'][$_GET['to_users_id']][0]['id'] = $parameters['greater_then_id'];
|
||||||
}
|
}
|
||||||
|
@ -1276,7 +1321,8 @@ class API extends PluginAbstract {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAPISecret() {
|
public static function getAPISecret()
|
||||||
|
{
|
||||||
$obj = AVideoPlugin::getDataObject("API");
|
$obj = AVideoPlugin::getDataObject("API");
|
||||||
return $obj->APISecret;
|
return $obj->APISecret;
|
||||||
}
|
}
|
||||||
|
@ -1287,7 +1333,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function get_api_locales($parameters) {
|
public function get_api_locales($parameters)
|
||||||
|
{
|
||||||
global $global, $config;
|
global $global, $config;
|
||||||
$langs = new stdClass();
|
$langs = new stdClass();
|
||||||
$langs->default = $config->getLanguage();
|
$langs->default = $config->getLanguage();
|
||||||
|
@ -1303,7 +1350,8 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&language=cn
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&language=cn
|
||||||
* @return type
|
* @return type
|
||||||
*/
|
*/
|
||||||
public function get_api_locale($parameters) {
|
public function get_api_locale($parameters)
|
||||||
|
{
|
||||||
global $global, $config;
|
global $global, $config;
|
||||||
$obj = $this->startResponseObject($parameters);
|
$obj = $this->startResponseObject($parameters);
|
||||||
|
|
||||||
|
@ -1332,13 +1380,13 @@ class API extends PluginAbstract {
|
||||||
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}&user=admin
|
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}&APISecret={APISecret}&user=admin
|
||||||
* @return \ApiObject
|
* @return \ApiObject
|
||||||
*/
|
*/
|
||||||
public function set_api_userImages($parameters) {
|
public function set_api_userImages($parameters)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/video.php';
|
require_once $global['systemRootPath'] . 'objects/video.php';
|
||||||
// $obj = $this->startResponseObject($parameters);
|
// $obj = $this->startResponseObject($parameters);
|
||||||
$dataObj = $this->getDataObject();
|
$dataObj = $this->getDataObject();
|
||||||
if ($dataObj->APISecret === @$_GET['APISecret']) {
|
if ($dataObj->APISecret === @$_GET['APISecret']) {
|
||||||
|
|
||||||
$user = new User("", $parameters['user'], false);
|
$user = new User("", $parameters['user'], false);
|
||||||
if (empty($user->getUser())) {
|
if (empty($user->getUser())) {
|
||||||
return new ApiObject("User Not defined");
|
return new ApiObject("User Not defined");
|
||||||
|
@ -1352,19 +1400,18 @@ class API extends PluginAbstract {
|
||||||
return new ApiObject("API Secret is not valid");
|
return new ApiObject("API Secret is not valid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ApiObject {
|
class ApiObject
|
||||||
|
{
|
||||||
public $error;
|
public $error;
|
||||||
public $message;
|
public $message;
|
||||||
public $response;
|
public $response;
|
||||||
|
|
||||||
function __construct($message = "api not started or not found", $error = true, $response = array()) {
|
public function __construct($message = "api not started or not found", $error = true, $response = [])
|
||||||
|
{
|
||||||
$this->error = $error;
|
$this->error = $error;
|
||||||
$this->message = $message;
|
$this->message = $message;
|
||||||
$this->response = $response;
|
$this->response = $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
$configFile = '../../videos/configuration.php';
|
$configFile = '../../videos/configuration.php';
|
||||||
if (!file_exists($configFile)) {
|
if (!file_exists($configFile)) {
|
||||||
list($scriptPath) = get_included_files();
|
[$scriptPath] = get_included_files();
|
||||||
$path = pathinfo($scriptPath);
|
$path = pathinfo($scriptPath);
|
||||||
$configFile = $path['dirname'] . "/" . $configFile;
|
$configFile = $path['dirname'] . "/" . $configFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once $configFile;
|
require_once $configFile;
|
||||||
require_once $global['systemRootPath'].'plugin/API/API.php';
|
require_once $global['systemRootPath'].'plugin/API/API.php';
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
@ -14,17 +15,17 @@ header("Access-Control-Allow-Headers: Content-Type");
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled("API");
|
$plugin = AVideoPlugin::loadPluginIfEnabled("API");
|
||||||
$objData = AVideoPlugin::getObjectDataIfEnabled("API");
|
$objData = AVideoPlugin::getObjectDataIfEnabled("API");
|
||||||
|
|
||||||
if(empty($plugin)){
|
if (empty($plugin)) {
|
||||||
$obj = new ApiObject("API Plugin disabled");
|
$obj = new ApiObject("API Plugin disabled");
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
// gettig the mobile submited value
|
// gettig the mobile submited value
|
||||||
$inputJSON = url_get_contents('php://input');
|
$inputJSON = url_get_contents('php://input');
|
||||||
$input = _json_decode($inputJSON, TRUE); //convert JSON into array
|
$input = _json_decode($inputJSON, true); //convert JSON into array
|
||||||
if(empty($input)){
|
if (empty($input)) {
|
||||||
$input = array();
|
$input = [];
|
||||||
}else{
|
} else {
|
||||||
$input = object_to_array($input);
|
$input = object_to_array($input);
|
||||||
}
|
}
|
||||||
$parameters = array_merge($_GET, $_POST, $input);
|
$parameters = array_merge($_GET, $_POST, $input);
|
||||||
|
|
|
@ -81,21 +81,20 @@ $reflector = new ReflectionClass('API');
|
||||||
foreach ($class_methods as $method_name) {
|
foreach ($class_methods as $method_name) {
|
||||||
if (!preg_match("/(get|set)_api_(.*)/", $method_name, $matches)) {
|
if (!preg_match("/(get|set)_api_(.*)/", $method_name, $matches)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
} ?>
|
||||||
?>
|
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<details>
|
<details>
|
||||||
<summary style="cursor: pointer;"><i class="fas fa-sign-<?php echo strtoupper($matches[1]) === "GET" ? "out" : "in" ?>-alt"></i> <?php echo strtoupper($matches[1]) ?> <?php echo $matches[2] ?></summary>
|
<summary style="cursor: pointer;"><i class="fas fa-sign-<?php echo strtoupper($matches[1]) === "GET" ? "out" : "in" ?>-alt"></i> <?php echo strtoupper($matches[1]) ?> <?php echo $matches[2] ?></summary>
|
||||||
<br>
|
<br>
|
||||||
<pre><?php
|
<pre><?php
|
||||||
$comment = $reflector->getMethod($method_name)->getDocComment();
|
$comment = $reflector->getMethod($method_name)->getDocComment();
|
||||||
$comment = str_replace(array('{webSiteRootURL}', '{getOrSet}', '{APIName}', '{APISecret}'), array($global['webSiteRootURL'], $matches[1], $matches[2], $obj->APISecret), $comment);
|
$comment = str_replace(['{webSiteRootURL}', '{getOrSet}', '{APIName}', '{APISecret}'], [$global['webSiteRootURL'], $matches[1], $matches[2], $obj->APISecret], $comment);
|
||||||
preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $comment, $match2);
|
preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $comment, $match2);
|
||||||
//var_dump($match2[0]);
|
//var_dump($match2[0]);
|
||||||
$link = "<a target='_blank' href='{$match2[0][0]}'>" . htmlentities($match2[0][0]) . "</a>";
|
$link = "<a target='_blank' href='{$match2[0][0]}'>" . htmlentities($match2[0][0]) . "</a>";
|
||||||
$comment = str_replace(array($match2[0][0], " *"), array($link, "*"), $comment);
|
$comment = str_replace([$match2[0][0], " *"], [$link, "*"], $comment);
|
||||||
|
|
||||||
echo ($comment);
|
echo($comment);
|
||||||
//{webSiteRootURL}plugin/API/{getOrSet}.json.php?name={name}
|
//{webSiteRootURL}plugin/API/{getOrSet}.json.php?name={name}
|
||||||
?>
|
?>
|
||||||
</pre>
|
</pre>
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
$configFile = '../../videos/configuration.php';
|
$configFile = '../../videos/configuration.php';
|
||||||
if (!file_exists($configFile)) {
|
if (!file_exists($configFile)) {
|
||||||
list($scriptPath) = get_included_files();
|
[$scriptPath] = get_included_files();
|
||||||
$path = pathinfo($scriptPath);
|
$path = pathinfo($scriptPath);
|
||||||
$configFile = $path['dirname'] . "/" . $configFile;
|
$configFile = $path['dirname'] . "/" . $configFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once $configFile;
|
require_once $configFile;
|
||||||
require_once $global['systemRootPath'].'plugin/API/API.php';
|
require_once $global['systemRootPath'].'plugin/API/API.php';
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
@ -14,17 +15,17 @@ header("Access-Control-Allow-Headers: Content-Type");
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled("API");
|
$plugin = AVideoPlugin::loadPluginIfEnabled("API");
|
||||||
$objData = AVideoPlugin::getObjectDataIfEnabled("API");
|
$objData = AVideoPlugin::getObjectDataIfEnabled("API");
|
||||||
|
|
||||||
if(empty($plugin)){
|
if (empty($plugin)) {
|
||||||
$obj = new ApiObject("API Plugin disabled");
|
$obj = new ApiObject("API Plugin disabled");
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
// gettig the mobile submited value
|
// gettig the mobile submited value
|
||||||
$inputJSON = url_get_contents('php://input');
|
$inputJSON = url_get_contents('php://input');
|
||||||
$input = _json_decode($inputJSON, TRUE); //convert JSON into array
|
$input = _json_decode($inputJSON, true); //convert JSON into array
|
||||||
if(empty($input)){
|
if (empty($input)) {
|
||||||
$input = array();
|
$input = [];
|
||||||
}else{
|
} else {
|
||||||
$input = object_to_array($input);
|
$input = object_to_array($input);
|
||||||
}
|
}
|
||||||
$parameters = array_merge($_GET, $_POST, $input);
|
$parameters = array_merge($_GET, $_POST, $input);
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
$configFile = '../../videos/configuration.php';
|
$configFile = '../../videos/configuration.php';
|
||||||
if (!file_exists($configFile)) {
|
if (!file_exists($configFile)) {
|
||||||
list($scriptPath) = get_included_files();
|
[$scriptPath] = get_included_files();
|
||||||
$path = pathinfo($scriptPath);
|
$path = pathinfo($scriptPath);
|
||||||
$configFile = $path['dirname'] . "/" . $configFile;
|
$configFile = $path['dirname'] . "/" . $configFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once $configFile;
|
require_once $configFile;
|
||||||
require_once $global['systemRootPath'].'plugin/API/API.php';
|
require_once $global['systemRootPath'].'plugin/API/API.php';
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
@ -12,9 +13,9 @@ header('Content-Type: application/json');
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled("API");
|
$plugin = AVideoPlugin::loadPluginIfEnabled("API");
|
||||||
$objData = AVideoPlugin::getObjectDataIfEnabled("API");
|
$objData = AVideoPlugin::getObjectDataIfEnabled("API");
|
||||||
|
|
||||||
if(empty($plugin)){
|
if (empty($plugin)) {
|
||||||
$obj = new ApiObject("API Plugin disabled");
|
$obj = new ApiObject("API Plugin disabled");
|
||||||
}else{
|
} else {
|
||||||
$obj = new ApiObject("API Plugin enabled", false);
|
$obj = new ApiObject("API Plugin enabled", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3,18 +3,20 @@
|
||||||
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/CDN/Storage/CDNStorage.php';
|
require_once $global['systemRootPath'] . 'plugin/CDN/Storage/CDNStorage.php';
|
||||||
|
|
||||||
class CDN extends PluginAbstract {
|
class CDN extends PluginAbstract
|
||||||
|
{
|
||||||
public function getTags() {
|
public function getTags()
|
||||||
return array(
|
{
|
||||||
|
return [
|
||||||
PluginTags::$RECOMMENDED,
|
PluginTags::$RECOMMENDED,
|
||||||
PluginTags::$LIVE,
|
PluginTags::$LIVE,
|
||||||
PluginTags::$PLAYER,
|
PluginTags::$PLAYER,
|
||||||
PluginTags::$STORAGE
|
PluginTags::$STORAGE,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription() {
|
public function getDescription()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$txt = "With our CDN we will provide you a highly-distributed platform of servers that helps minimize delays in loading web page content "
|
$txt = "With our CDN we will provide you a highly-distributed platform of servers that helps minimize delays in loading web page content "
|
||||||
. "by reducing the physical distance between the server and the user. This helps users around the world view the same high-quality "
|
. "by reducing the physical distance between the server and the user. This helps users around the world view the same high-quality "
|
||||||
|
@ -25,19 +27,23 @@ class CDN extends PluginAbstract {
|
||||||
return $txt . $help;
|
return $txt . $help;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return "CDN";
|
return "CDN";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUUID() {
|
public function getUUID()
|
||||||
|
{
|
||||||
return "CDN73225-3807-4167-ba81-0509dd280e06";
|
return "CDN73225-3807-4167-ba81-0509dd280e06";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginVersion() {
|
public function getPluginVersion()
|
||||||
|
{
|
||||||
return "2.0";
|
return "2.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmptyDataObject() {
|
public function getEmptyDataObject()
|
||||||
|
{
|
||||||
global $global, $config;
|
global $global, $config;
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->key = "";
|
$obj->key = "";
|
||||||
|
@ -60,15 +66,17 @@ class CDN extends PluginAbstract {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVideosManagerListButton() {
|
public function getVideosManagerListButton()
|
||||||
if(!self::userCanMoveVideoStorage()){
|
{
|
||||||
|
if (!self::userCanMoveVideoStorage()) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
$btn = '<button type="button" class="btn btn-default btn-light btn-sm btn-xs btn-block " onclick="avideoModalIframeSmall(webSiteRootURL+\\\'plugin/CDN/Storage/syncVideo.php?videos_id=\'+ row.id +\'\\\');" ><i class="fas fa-project-diagram"></i> CDN Storage</button>';
|
$btn = '<button type="button" class="btn btn-default btn-light btn-sm btn-xs btn-block " onclick="avideoModalIframeSmall(webSiteRootURL+\\\'plugin/CDN/Storage/syncVideo.php?videos_id=\'+ row.id +\'\\\');" ><i class="fas fa-project-diagram"></i> CDN Storage</button>';
|
||||||
return $btn;
|
return $btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginMenu() {
|
public function getPluginMenu()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$fileAPIName = $global['systemRootPath'] . 'plugin/CDN/pluginMenu.html';
|
$fileAPIName = $global['systemRootPath'] . 'plugin/CDN/pluginMenu.html';
|
||||||
$content = file_get_contents($fileAPIName);
|
$content = file_get_contents($fileAPIName);
|
||||||
|
@ -81,7 +89,7 @@ class CDN extends PluginAbstract {
|
||||||
|
|
||||||
$cdnMenu = str_replace('{url}', $url, $content);
|
$cdnMenu = str_replace('{url}', $url, $content);
|
||||||
$storageMenu = '';
|
$storageMenu = '';
|
||||||
if(self::userCanMoveVideoStorage()){
|
if (self::userCanMoveVideoStorage()) {
|
||||||
$fileStorageMenu = $global['systemRootPath'] . 'plugin/CDN/Storage/pluginMenu.html';
|
$fileStorageMenu = $global['systemRootPath'] . 'plugin/CDN/Storage/pluginMenu.html';
|
||||||
$storageMenu = file_get_contents($fileStorageMenu);
|
$storageMenu = file_get_contents($fileStorageMenu);
|
||||||
}
|
}
|
||||||
|
@ -94,8 +102,8 @@ class CDN extends PluginAbstract {
|
||||||
* @param type $id the ID of the URL in case the CDN is an array
|
* @param type $id the ID of the URL in case the CDN is an array
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
static public function getURL($type = 'CDN', $id = 0) {
|
public static function getURL($type = 'CDN', $id = 0)
|
||||||
|
{
|
||||||
$obj = AVideoPlugin::getObjectData('CDN');
|
$obj = AVideoPlugin::getObjectData('CDN');
|
||||||
|
|
||||||
if (empty($obj->{$type})) {
|
if (empty($obj->{$type})) {
|
||||||
|
@ -139,7 +147,8 @@ class CDN extends PluginAbstract {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getCDN_S3URL() {
|
public static function getCDN_S3URL()
|
||||||
|
{
|
||||||
$plugin = AVideoPlugin::getDataObjectIfEnabled('AWS_S3');
|
$plugin = AVideoPlugin::getDataObjectIfEnabled('AWS_S3');
|
||||||
$CDN_S3 = '';
|
$CDN_S3 = '';
|
||||||
if (!empty($plugin)) {
|
if (!empty($plugin)) {
|
||||||
|
@ -148,7 +157,7 @@ class CDN extends PluginAbstract {
|
||||||
$endpoint = trim($plugin->endpoint);
|
$endpoint = trim($plugin->endpoint);
|
||||||
if (!empty($endpoint)) {
|
if (!empty($endpoint)) {
|
||||||
$CDN_S3 = str_replace('https://', "https://{$bucket_name}.", $endpoint);
|
$CDN_S3 = str_replace('https://', "https://{$bucket_name}.", $endpoint);
|
||||||
} else if (!empty($plugin->region)) {
|
} elseif (!empty($plugin->region)) {
|
||||||
$CDN_S3 = "https://{$bucket_name}.s3-accesspoint.{$region}.amazonaws.com";
|
$CDN_S3 = "https://{$bucket_name}.s3-accesspoint.{$region}.amazonaws.com";
|
||||||
}
|
}
|
||||||
if (!empty($resp->CDN_S3)) {
|
if (!empty($resp->CDN_S3)) {
|
||||||
|
@ -158,7 +167,8 @@ class CDN extends PluginAbstract {
|
||||||
return $CDN_S3;
|
return $CDN_S3;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getCDN_B2URL() {
|
public static function getCDN_B2URL()
|
||||||
|
{
|
||||||
$CDN_B2 = '';
|
$CDN_B2 = '';
|
||||||
$plugin = AVideoPlugin::getDataObjectIfEnabled('Blackblaze_B2');
|
$plugin = AVideoPlugin::getDataObjectIfEnabled('Blackblaze_B2');
|
||||||
if (!empty($plugin)) {
|
if (!empty($plugin)) {
|
||||||
|
@ -171,7 +181,8 @@ class CDN extends PluginAbstract {
|
||||||
return $CDN_B2;
|
return $CDN_B2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getCDN_FTPURL() {
|
public static function getCDN_FTPURL()
|
||||||
|
{
|
||||||
$CDN_FTP = '';
|
$CDN_FTP = '';
|
||||||
$plugin = AVideoPlugin::getDataObjectIfEnabled('CDN');
|
$plugin = AVideoPlugin::getDataObjectIfEnabled('CDN');
|
||||||
if (!empty($plugin)) {
|
if (!empty($plugin)) {
|
||||||
|
@ -180,13 +191,14 @@ class CDN extends PluginAbstract {
|
||||||
return $CDN_FTP;
|
return $CDN_FTP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getVideoTags($videos_id) {
|
public static function getVideoTags($videos_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (empty($videos_id)) {
|
if (empty($videos_id)) {
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
if (!Video::canEdit($videos_id)) {
|
if (!Video::canEdit($videos_id)) {
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
$video = Video::getVideoLight($videos_id);
|
$video = Video::getVideoLight($videos_id);
|
||||||
$sites_id = $video['sites_id'];
|
$sites_id = $video['sites_id'];
|
||||||
|
@ -197,7 +209,7 @@ class CDN extends PluginAbstract {
|
||||||
if ($isMoving) {
|
if ($isMoving) {
|
||||||
$obj->type = "danger";
|
$obj->type = "danger";
|
||||||
$obj->text = '<i class="fas fa-sync fa-spin"></i> ' . __('Moving');
|
$obj->text = '<i class="fas fa-sync fa-spin"></i> ' . __('Moving');
|
||||||
} else if (empty($sites_id)) {
|
} elseif (empty($sites_id)) {
|
||||||
$obj->type = "success";
|
$obj->type = "success";
|
||||||
$obj->text = '<i class="fas fa-map-marker-alt"></i> ' . __('Local');
|
$obj->text = '<i class="fas fa-map-marker-alt"></i> ' . __('Local');
|
||||||
} else {
|
} else {
|
||||||
|
@ -205,33 +217,37 @@ class CDN extends PluginAbstract {
|
||||||
$obj->text = "<i class=\"fas fa-project-diagram\"></i> " . __('Storage');
|
$obj->text = "<i class=\"fas fa-project-diagram\"></i> " . __('Storage');
|
||||||
}
|
}
|
||||||
//var_dump($obj);exit;
|
//var_dump($obj);exit;
|
||||||
return array($obj);
|
return [$obj];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function onEncoderNotifyIsDone($videos_id) {
|
public function onEncoderNotifyIsDone($videos_id)
|
||||||
|
{
|
||||||
return $this->processNewVideo($videos_id);
|
return $this->processNewVideo($videos_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUploadIsDone($videos_id) {
|
public function onUploadIsDone($videos_id)
|
||||||
|
{
|
||||||
return $this->processNewVideo($videos_id);
|
return $this->processNewVideo($videos_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processNewVideo($videos_id) {
|
private function processNewVideo($videos_id)
|
||||||
|
{
|
||||||
$obj = AVideoPlugin::getDataObjectIfEnabled('CDN');
|
$obj = AVideoPlugin::getDataObjectIfEnabled('CDN');
|
||||||
if($obj->enable_storage){
|
if ($obj->enable_storage) {
|
||||||
if($obj->storage_autoupload_new_videos){
|
if ($obj->storage_autoupload_new_videos) {
|
||||||
CDNStorage::moveLocalToRemote($videos_id, false);
|
CDNStorage::moveLocalToRemote($videos_id, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function userCanMoveVideoStorage(){
|
public static function userCanMoveVideoStorage()
|
||||||
|
{
|
||||||
$obj = AVideoPlugin::getDataObjectIfEnabled('CDN');
|
$obj = AVideoPlugin::getDataObjectIfEnabled('CDN');
|
||||||
if(empty($obj->enable_storage)){
|
if (empty($obj->enable_storage)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(User::isAdmin()){
|
if (User::isAdmin()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!empty($obj->storage_users_can_choose_storage) && User::canUpload()) {
|
if (!empty($obj->storage_users_can_choose_storage) && User::canUpload()) {
|
||||||
|
@ -240,11 +256,11 @@ class CDN extends PluginAbstract {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFooterCode() {
|
public function getFooterCode()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if(self::userCanMoveVideoStorage()){
|
if (self::userCanMoveVideoStorage()) {
|
||||||
include $global['systemRootPath'] . 'plugin/CDN/Storage/footer.php';
|
include $global['systemRootPath'] . 'plugin/CDN/Storage/footer.php';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,10 @@
|
||||||
*
|
*
|
||||||
* @copyright Nicolas Tallefourtane http://nicolab.net
|
* @copyright Nicolas Tallefourtane http://nicolab.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FtpClient;
|
namespace FtpClient;
|
||||||
|
|
||||||
use \Countable;
|
use Countable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The FTP and SSL-FTP client for PHP.
|
* The FTP and SSL-FTP client for PHP.
|
||||||
|
@ -280,7 +281,7 @@ class FtpClient implements Countable
|
||||||
throw new FtpException('Unable to list directory');
|
throw new FtpException('Unable to list directory');
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = array();
|
$result = [];
|
||||||
$dir_len = strlen($directory);
|
$dir_len = strlen($directory);
|
||||||
|
|
||||||
// if it's the current
|
// if it's the current
|
||||||
|
@ -289,7 +290,7 @@ class FtpClient implements Countable
|
||||||
}
|
}
|
||||||
|
|
||||||
// if it's the parent
|
// if it's the parent
|
||||||
if(false !== ($kdot = array_search('..', $files))) {
|
if (false !== ($kdot = array_search('..', $files))) {
|
||||||
unset($files[$kdot]);
|
unset($files[$kdot]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +335,6 @@ class FtpClient implements Countable
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
$result[] = $item;
|
$result[] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$result[] = $file;
|
$result[] = $file;
|
||||||
}
|
}
|
||||||
|
@ -618,7 +618,6 @@ class FtpClient implements Countable
|
||||||
|
|
||||||
// do the following if it is a directory
|
// do the following if it is a directory
|
||||||
if (is_dir($source_directory.'/'.$file)) {
|
if (is_dir($source_directory.'/'.$file)) {
|
||||||
|
|
||||||
if (!$this->isDir($target_directory.'/'.$file)) {
|
if (!$this->isDir($target_directory.'/'.$file)) {
|
||||||
|
|
||||||
// create directories that do not yet exist
|
// create directories that do not yet exist
|
||||||
|
@ -627,14 +626,16 @@ class FtpClient implements Countable
|
||||||
|
|
||||||
// recursive part
|
// recursive part
|
||||||
$this->putAll(
|
$this->putAll(
|
||||||
$source_directory.'/'.$file, $target_directory.'/'.$file,
|
$source_directory.'/'.$file,
|
||||||
|
$target_directory.'/'.$file,
|
||||||
$mode
|
$mode
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// put the files
|
// put the files
|
||||||
$this->ftp->put(
|
$this->ftp->put(
|
||||||
$target_directory.'/'.$file, $source_directory.'/'.$file,
|
$target_directory.'/'.$file,
|
||||||
|
$source_directory.'/'.$file,
|
||||||
$mode
|
$mode
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -670,7 +671,7 @@ class FtpClient implements Countable
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = $this->ftp->rawlist($directory);
|
$list = $this->ftp->rawlist($directory);
|
||||||
$items = array();
|
$items = [];
|
||||||
|
|
||||||
if (!$list) {
|
if (!$list) {
|
||||||
return $items;
|
return $items;
|
||||||
|
@ -718,8 +719,7 @@ class FtpClient implements Countable
|
||||||
|
|
||||||
// ".."
|
// ".."
|
||||||
or $item[$len-1] == '.' && $item[$len-2] == '.' && $item[$len-3] == ' ')
|
or $item[$len-1] == '.' && $item[$len-2] == '.' && $item[$len-3] == ' ')
|
||||||
){
|
) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -769,7 +769,7 @@ class FtpClient implements Countable
|
||||||
*/
|
*/
|
||||||
public function parseRawList(array $rawlist)
|
public function parseRawList(array $rawlist)
|
||||||
{
|
{
|
||||||
$items = array();
|
$items = [];
|
||||||
$path = '';
|
$path = '';
|
||||||
|
|
||||||
foreach ($rawlist as $key => $child) {
|
foreach ($rawlist as $key => $child) {
|
||||||
|
@ -825,7 +825,6 @@ class FtpClient implements Countable
|
||||||
}
|
}
|
||||||
|
|
||||||
$items[$key] = $item;
|
$items[$key] = $item;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// the key is the path, behavior of FtpClient::rawlist() method()
|
// the key is the path, behavior of FtpClient::rawlist() method()
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
*
|
*
|
||||||
* @copyright Nicolas Tallefourtane http://nicolab.net
|
* @copyright Nicolas Tallefourtane http://nicolab.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FtpClient;
|
namespace FtpClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,4 +18,6 @@ namespace FtpClient;
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
* @author Nicolas Tallefourtane <dev@nicolab.net>
|
* @author Nicolas Tallefourtane <dev@nicolab.net>
|
||||||
*/
|
*/
|
||||||
class FtpException extends \Exception {}
|
class FtpException extends \Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
*
|
*
|
||||||
* @copyright Nicolas Tallefourtane http://nicolab.net
|
* @copyright Nicolas Tallefourtane http://nicolab.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace FtpClient;
|
namespace FtpClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,15 +6,17 @@ if (!class_exists('FtpClient')) {
|
||||||
require_once $global['systemRootPath'] . 'plugin/CDN/FtpClient/FtpException.php';
|
require_once $global['systemRootPath'] . 'plugin/CDN/FtpClient/FtpException.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
class CDNStorage {
|
class CDNStorage
|
||||||
|
{
|
||||||
|
public static $allowedFiles = ['mp4', 'webm', 'mp3', 'm3u8', 'ts', 'pdf', 'zip'];
|
||||||
|
|
||||||
static $allowedFiles = array('mp4', 'webm', 'mp3', 'm3u8', 'ts', 'pdf', 'zip');
|
private function getClient($try = 0)
|
||||||
|
{
|
||||||
private function getClient($try = 0) {
|
|
||||||
return self::getStorageClient();
|
return self::getStorageClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getStorageClient() {
|
public static function getStorageClient()
|
||||||
|
{
|
||||||
$obj = AVideoPlugin::getDataObject('CDN');
|
$obj = AVideoPlugin::getDataObject('CDN');
|
||||||
$CDNstorage = new \FtpClient\FtpClient();
|
$CDNstorage = new \FtpClient\FtpClient();
|
||||||
try {
|
try {
|
||||||
|
@ -29,7 +31,8 @@ class CDNStorage {
|
||||||
return $CDNstorage;
|
return $CDNstorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function xsendfilePreVideoPlay() {
|
public function xsendfilePreVideoPlay()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
|
|
||||||
$path_parts = pathinfo($_GET['file']);
|
$path_parts = pathinfo($_GET['file']);
|
||||||
|
@ -47,10 +50,11 @@ class CDNStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getFilesListBoth($videos_id) {
|
public static function getFilesListBoth($videos_id)
|
||||||
|
{
|
||||||
global $_getFilesListBoth;
|
global $_getFilesListBoth;
|
||||||
if (!isset($_getFilesListBoth)) {
|
if (!isset($_getFilesListBoth)) {
|
||||||
$_getFilesListBoth = array();
|
$_getFilesListBoth = [];
|
||||||
}
|
}
|
||||||
if (!empty($_getFilesListBoth[$videos_id])) {
|
if (!empty($_getFilesListBoth[$videos_id])) {
|
||||||
return $_getFilesListBoth[$videos_id];
|
return $_getFilesListBoth[$videos_id];
|
||||||
|
@ -61,7 +65,7 @@ class CDNStorage {
|
||||||
$searchThis = $localList;
|
$searchThis = $localList;
|
||||||
$compareThis = $remoteList;
|
$compareThis = $remoteList;
|
||||||
$searchingLocal = true;
|
$searchingLocal = true;
|
||||||
$files = array();
|
$files = [];
|
||||||
foreach ($localList as $key => $value) {
|
foreach ($localList as $key => $value) {
|
||||||
$isLocal = true;
|
$isLocal = true;
|
||||||
|
|
||||||
|
@ -69,7 +73,7 @@ class CDNStorage {
|
||||||
$isLocal = false;
|
$isLocal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$files[$key] = array('isLocal' => $isLocal, 'local' => @$localList[$key], 'remote' => @$remoteList[$key]);
|
$files[$key] = ['isLocal' => $isLocal, 'local' => @$localList[$key], 'remote' => @$remoteList[$key]];
|
||||||
unset($remoteList[$key]);
|
unset($remoteList[$key]);
|
||||||
}
|
}
|
||||||
foreach ($remoteList as $key => $value) {
|
foreach ($remoteList as $key => $value) {
|
||||||
|
@ -81,7 +85,7 @@ class CDNStorage {
|
||||||
$isLocal = false;
|
$isLocal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$files[$key] = array('isLocal' => $isLocal, 'local' => @$localList[$key], 'remote' => @$remoteList[$key]);
|
$files[$key] = ['isLocal' => $isLocal, 'local' => @$localList[$key], 'remote' => @$remoteList[$key]];
|
||||||
unset($localList[$key]);
|
unset($localList[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,26 +93,28 @@ class CDNStorage {
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getPZ() {
|
public static function getPZ()
|
||||||
|
{
|
||||||
$obj = AVideoPlugin::getDataObject('CDN');
|
$obj = AVideoPlugin::getDataObject('CDN');
|
||||||
return addLastSlash($obj->storage_username . '.cdn.ypt.me');
|
return addLastSlash($obj->storage_username . '.cdn.ypt.me');
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getFilesListRemote($videos_id, $client = null) {
|
public static function getFilesListRemote($videos_id, $client = null)
|
||||||
|
{
|
||||||
global $global, $_getFilesListRemote;
|
global $global, $_getFilesListRemote;
|
||||||
if(empty($videos_id)){
|
if (empty($videos_id)) {
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
if (!isset($_getFilesListRemote)) {
|
if (!isset($_getFilesListRemote)) {
|
||||||
$_getFilesListRemote = array();
|
$_getFilesListRemote = [];
|
||||||
}
|
}
|
||||||
if (!empty($_getFilesListRemote[$videos_id])) {
|
if (!empty($_getFilesListRemote[$videos_id])) {
|
||||||
return $_getFilesListRemote[$videos_id];
|
return $_getFilesListRemote[$videos_id];
|
||||||
}
|
}
|
||||||
$video = Video::getVideoLight($videos_id);
|
$video = Video::getVideoLight($videos_id);
|
||||||
|
|
||||||
if(empty($video)){
|
if (empty($video)) {
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
//$paths = Video::getPaths($video['filename']);
|
//$paths = Video::getPaths($video['filename']);
|
||||||
|
@ -118,7 +124,7 @@ class CDNStorage {
|
||||||
$dir = self::filenameToRemotePath($video['filename']);
|
$dir = self::filenameToRemotePath($video['filename']);
|
||||||
try {
|
try {
|
||||||
if (!$client->isDir($dir)) {
|
if (!$client->isDir($dir)) {
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
} catch (Exception $exc) {
|
} catch (Exception $exc) {
|
||||||
_error_log("CDNStorage::getFilesListRemote ({$dir}) " . $exc->getTraceAsString());
|
_error_log("CDNStorage::getFilesListRemote ({$dir}) " . $exc->getTraceAsString());
|
||||||
|
@ -129,10 +135,10 @@ class CDNStorage {
|
||||||
try {
|
try {
|
||||||
$list = $client->rawlist($video['filename'], true);
|
$list = $client->rawlist($video['filename'], true);
|
||||||
} catch (Exception $exc) {
|
} catch (Exception $exc) {
|
||||||
$list = array();
|
$list = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = array();
|
$files = [];
|
||||||
foreach ($list as $key => $value) {
|
foreach ($list as $key => $value) {
|
||||||
$parts1 = explode('#', $key);
|
$parts1 = explode('#', $key);
|
||||||
if ($parts1[0] == 'directory') {
|
if ($parts1[0] == 'directory') {
|
||||||
|
@ -149,7 +155,7 @@ class CDNStorage {
|
||||||
$path_parts = pathinfo($local_path);
|
$path_parts = pathinfo($local_path);
|
||||||
$extension = $path_parts['extension'];
|
$extension = $path_parts['extension'];
|
||||||
|
|
||||||
$file = array(
|
$file = [
|
||||||
'extension' => $path_parts['extension'],
|
'extension' => $path_parts['extension'],
|
||||||
'videos_id' => $videos_id,
|
'videos_id' => $videos_id,
|
||||||
'local_path' => $local_path,
|
'local_path' => $local_path,
|
||||||
|
@ -159,7 +165,7 @@ class CDNStorage {
|
||||||
'relative' => $relative,
|
'relative' => $relative,
|
||||||
'local_filesize' => $local_filesize,
|
'local_filesize' => $local_filesize,
|
||||||
'remote_filesize' => $remote_filesize,
|
'remote_filesize' => $remote_filesize,
|
||||||
'video' => $video);
|
'video' => $video, ];
|
||||||
|
|
||||||
$files[$relative] = $file;
|
$files[$relative] = $file;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +173,8 @@ class CDNStorage {
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getRemoteDirectorySize($videos_id, $client = null) {
|
public static function getRemoteDirectorySize($videos_id, $client = null)
|
||||||
|
{
|
||||||
$list = self::getFilesListRemote($videos_id, $client);
|
$list = self::getFilesListRemote($videos_id, $client);
|
||||||
$total = 0;
|
$total = 0;
|
||||||
foreach ($list as $value) {
|
foreach ($list as $value) {
|
||||||
|
@ -176,21 +183,22 @@ class CDNStorage {
|
||||||
return $total;
|
return $total;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getFilesListInfo($local_path, $storage_pullzone, $videos_id, $skipDummyFiles = true) {
|
public static function getFilesListInfo($local_path, $storage_pullzone, $videos_id, $skipDummyFiles = true)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if ($skipDummyFiles && filesize($local_path) < 20) {
|
if ($skipDummyFiles && filesize($local_path) < 20) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(empty($local_path)){
|
if (empty($local_path)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!is_string($local_path)){
|
if (!is_string($local_path)) {
|
||||||
//debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
//debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
//var_dump($local_path);
|
//var_dump($local_path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$path_parts = pathinfo($local_path);
|
$path_parts = pathinfo($local_path);
|
||||||
if(empty($path_parts) || empty($path_parts['extension'])){
|
if (empty($path_parts) || empty($path_parts['extension'])) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$extension = $path_parts['extension'];
|
$extension = $path_parts['extension'];
|
||||||
|
@ -203,7 +211,7 @@ class CDNStorage {
|
||||||
$local_filesize = filesize($local_path);
|
$local_filesize = filesize($local_path);
|
||||||
$remote_path = self::filenameToRemotePath($relative);
|
$remote_path = self::filenameToRemotePath($relative);
|
||||||
$pz = self::getPZ();
|
$pz = self::getPZ();
|
||||||
$file = array(
|
$file = [
|
||||||
'extension' => $path_parts['extension'],
|
'extension' => $path_parts['extension'],
|
||||||
'videos_id' => $videos_id,
|
'videos_id' => $videos_id,
|
||||||
'local_path' => $local_path,
|
'local_path' => $local_path,
|
||||||
|
@ -211,18 +219,19 @@ class CDNStorage {
|
||||||
'local_url' => "{$global['webSiteRootURL']}videos/{$relative}",
|
'local_url' => "{$global['webSiteRootURL']}videos/{$relative}",
|
||||||
'remote_utl' => "https://{$pz}{$relative}",
|
'remote_utl' => "https://{$pz}{$relative}",
|
||||||
'relative' => $relative,
|
'relative' => $relative,
|
||||||
'local_filesize' => $local_filesize);
|
'local_filesize' => $local_filesize, ];
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getLocalFolder($videos_id) {
|
public static function getLocalFolder($videos_id)
|
||||||
if(empty($videos_id)){
|
{
|
||||||
return array();
|
if (empty($videos_id)) {
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
$video = Video::getVideoLight($videos_id);
|
$video = Video::getVideoLight($videos_id);
|
||||||
|
|
||||||
if(empty($video)){
|
if (empty($video)) {
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$paths = Video::getPaths($video['filename']);
|
$paths = Video::getPaths($video['filename']);
|
||||||
|
@ -230,7 +239,8 @@ class CDNStorage {
|
||||||
return listFolderFiles($paths['path']);
|
return listFolderFiles($paths['path']);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getOrCreateSite() {
|
public static function getOrCreateSite()
|
||||||
|
{
|
||||||
$status = 'y';
|
$status = 'y';
|
||||||
$row = Sites::getFromStatus($status);
|
$row = Sites::getFromStatus($status);
|
||||||
if (empty($row)) {
|
if (empty($row)) {
|
||||||
|
@ -250,7 +260,8 @@ class CDNStorage {
|
||||||
return $row[0];
|
return $row[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function setSite($videos_id, $isOnTheStorage) {
|
public static function setSite($videos_id, $isOnTheStorage)
|
||||||
|
{
|
||||||
_mysql_connect();
|
_mysql_connect();
|
||||||
$v = new Video('', '', $videos_id);
|
$v = new Video('', '', $videos_id);
|
||||||
if ($isOnTheStorage) {
|
if ($isOnTheStorage) {
|
||||||
|
@ -263,7 +274,8 @@ class CDNStorage {
|
||||||
return $v->save(false, true);
|
return $v->save(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function moveRemoteToLocal($videos_id, $runInBackground = true, $deleteWhenIsDone = true) {
|
public static function moveRemoteToLocal($videos_id, $runInBackground = true, $deleteWhenIsDone = true)
|
||||||
|
{
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
self::addToLog($videos_id, "Start moveRemoteToLocal videos_id={$videos_id}");
|
self::addToLog($videos_id, "Start moveRemoteToLocal videos_id={$videos_id}");
|
||||||
$client = self::getStorageClient();
|
$client = self::getStorageClient();
|
||||||
|
@ -329,10 +341,11 @@ class CDNStorage {
|
||||||
}
|
}
|
||||||
$end = microtime(true) - $start;
|
$end = microtime(true) - $start;
|
||||||
_error_log("Finish moveRemoteToLocal videos_id=($videos_id) filesCopied={$filesCopied} in {$end} Seconds");
|
_error_log("Finish moveRemoteToLocal videos_id=($videos_id) filesCopied={$filesCopied} in {$end} Seconds");
|
||||||
return array('filesCopied' => $filesCopied, 'totalBytesTransferred' => $totalBytesTransferred);
|
return ['filesCopied' => $filesCopied, 'totalBytesTransferred' => $totalBytesTransferred];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function deleteRemoteDirectory($videos_id, $client = null, $recursive = true) {
|
public static function deleteRemoteDirectory($videos_id, $client = null, $recursive = true)
|
||||||
|
{
|
||||||
if (empty($videos_id)) {
|
if (empty($videos_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -343,7 +356,8 @@ class CDNStorage {
|
||||||
return self::deleteRemoteDirectoryFromFilename($video['filename'], $client, $recursive);
|
return self::deleteRemoteDirectoryFromFilename($video['filename'], $client, $recursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function deleteRemoteDirectoryFromFilename($filename, $client = null, $recursive = true) {
|
public static function deleteRemoteDirectoryFromFilename($filename, $client = null, $recursive = true)
|
||||||
|
{
|
||||||
if (empty($filename)) {
|
if (empty($filename)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -359,7 +373,8 @@ class CDNStorage {
|
||||||
return $client->rmdir($dir, $recursive);
|
return $client->rmdir($dir, $recursive);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function filenameToRemotePath($filename, $addUsernameFolder = true) {
|
public static function filenameToRemotePath($filename, $addUsernameFolder = true)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = AVideoPlugin::getDataObject('CDN');
|
$obj = AVideoPlugin::getDataObject('CDN');
|
||||||
$filename = str_replace(getVideosDir(), '', $filename);
|
$filename = str_replace(getVideosDir(), '', $filename);
|
||||||
|
@ -369,7 +384,8 @@ class CDNStorage {
|
||||||
return $filename;
|
return $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function moveLocalToRemote($videos_id, $runInBackground = true) {
|
public static function moveLocalToRemote($videos_id, $runInBackground = true)
|
||||||
|
{
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
self::addToLog($videos_id, "Start moveLocalToRemote videos_id={$videos_id}");
|
self::addToLog($videos_id, "Start moveLocalToRemote videos_id={$videos_id}");
|
||||||
$list = self::getFilesListLocal($videos_id);
|
$list = self::getFilesListLocal($videos_id);
|
||||||
|
@ -462,21 +478,22 @@ class CDNStorage {
|
||||||
$end = microtime(true) - $start;
|
$end = microtime(true) - $start;
|
||||||
_error_log("Finish moveLocalToRemote videos_id=($videos_id) filesCopied={$filesCopied} in {$end} Seconds");
|
_error_log("Finish moveLocalToRemote videos_id=($videos_id) filesCopied={$filesCopied} in {$end} Seconds");
|
||||||
|
|
||||||
return array('filesCopied' => $filesCopied, 'totalBytesTransferred' => $totalBytesTransferred);
|
return ['filesCopied' => $filesCopied, 'totalBytesTransferred' => $totalBytesTransferred];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function put($videos_id, $totalSameTime, $onlyExtension = '') {
|
public static function put($videos_id, $totalSameTime, $onlyExtension = '')
|
||||||
|
{
|
||||||
global $_uploadInfo;
|
global $_uploadInfo;
|
||||||
if(empty($videos_id)){
|
if (empty($videos_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$list = self::getFilesListBoth($videos_id);
|
$list = self::getFilesListBoth($videos_id);
|
||||||
$filesToUpload = array();
|
$filesToUpload = [];
|
||||||
$totalFilesize = 0;
|
$totalFilesize = 0;
|
||||||
$totalBytesTransferred = 0;
|
$totalBytesTransferred = 0;
|
||||||
$fileUploadCount = 0;
|
$fileUploadCount = 0;
|
||||||
foreach ($list as $value) {
|
foreach ($list as $value) {
|
||||||
if(empty($value['local'])){
|
if (empty($value['local'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$ext = pathinfo($value['local']['local_path'], PATHINFO_EXTENSION);
|
$ext = pathinfo($value['local']['local_path'], PATHINFO_EXTENSION);
|
||||||
|
@ -487,7 +504,7 @@ class CDNStorage {
|
||||||
$filesize = filesize($value['local']['local_path']);
|
$filesize = filesize($value['local']['local_path']);
|
||||||
if ($value['isLocal'] && $filesize > 20) {
|
if ($value['isLocal'] && $filesize > 20) {
|
||||||
if (empty($value) || empty($value['remote']) || $filesize != $value['remote']['remote_filesize']) {
|
if (empty($value) || empty($value['remote']) || $filesize != $value['remote']['remote_filesize']) {
|
||||||
if(!empty($value['remote']['remote_filesize'])){
|
if (!empty($value['remote']['remote_filesize'])) {
|
||||||
_error_log("CDNStorage:: add {$value['remote']['relative']} {$filesize} != {$value['remote']['remote_filesize']}");
|
_error_log("CDNStorage:: add {$value['remote']['relative']} {$filesize} != {$value['remote']['remote_filesize']}");
|
||||||
}
|
}
|
||||||
$filesToUpload[] = $value['local']['local_path'];
|
$filesToUpload[] = $value['local']['local_path'];
|
||||||
|
@ -504,8 +521,8 @@ class CDNStorage {
|
||||||
_error_log("CDNStorage::put videos_id={$videos_id} There is no file to upload ");
|
_error_log("CDNStorage::put videos_id={$videos_id} There is no file to upload ");
|
||||||
} else {
|
} else {
|
||||||
_error_log("CDNStorage::put videos_id={$videos_id} totalSameTime=$totalSameTime totalFiles={$totalFiles} totalFilesize=" . humanFileSize($totalFilesize));
|
_error_log("CDNStorage::put videos_id={$videos_id} totalSameTime=$totalSameTime totalFiles={$totalFiles} totalFilesize=" . humanFileSize($totalFilesize));
|
||||||
$conn_id = array();
|
$conn_id = [];
|
||||||
$ret = array();
|
$ret = [];
|
||||||
for ($i = 0; $i < $totalSameTime; $i++) {
|
for ($i = 0; $i < $totalSameTime; $i++) {
|
||||||
$file = array_shift($filesToUpload);
|
$file = array_shift($filesToUpload);
|
||||||
if (empty($file)) {
|
if (empty($file)) {
|
||||||
|
@ -578,13 +595,14 @@ class CDNStorage {
|
||||||
} else {
|
} else {
|
||||||
_error_log("CDNStorage::put finished ERROR ");
|
_error_log("CDNStorage::put finished ERROR ");
|
||||||
}
|
}
|
||||||
return array('filesCopied' => $fileUploadCount, 'totalBytesTransferred' => $totalBytesTransferred);
|
return ['filesCopied' => $fileUploadCount, 'totalBytesTransferred' => $totalBytesTransferred];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function get($videos_id, $totalSameTime) {
|
public static function get($videos_id, $totalSameTime)
|
||||||
|
{
|
||||||
global $_downloadInfo;
|
global $_downloadInfo;
|
||||||
$list = self::getFilesListBoth($videos_id);
|
$list = self::getFilesListBoth($videos_id);
|
||||||
$filesToDownload = array();
|
$filesToDownload = [];
|
||||||
$totalFilesize = 0;
|
$totalFilesize = 0;
|
||||||
$totalBytesTransferred = 0;
|
$totalBytesTransferred = 0;
|
||||||
foreach ($list as $value) {
|
foreach ($list as $value) {
|
||||||
|
@ -593,9 +611,9 @@ class CDNStorage {
|
||||||
_error_log("CDNStorage::get Local {$value['local']['local_path']} {$filesize} ");
|
_error_log("CDNStorage::get Local {$value['local']['local_path']} {$filesize} ");
|
||||||
if ($filesize > $value['remote']['remote_filesize']) {
|
if ($filesize > $value['remote']['remote_filesize']) {
|
||||||
_error_log("CDNStorage::get Local filesize is too big");
|
_error_log("CDNStorage::get Local filesize is too big");
|
||||||
} else if ($value['remote']['remote_filesize'] < 20) {
|
} elseif ($value['remote']['remote_filesize'] < 20) {
|
||||||
_error_log("CDNStorage::get remote filesize is too small");
|
_error_log("CDNStorage::get remote filesize is too small");
|
||||||
} else if ($filesize == $value['remote']['remote_filesize']) {
|
} elseif ($filesize == $value['remote']['remote_filesize']) {
|
||||||
_error_log("CDNStorage::get same size {$value['remote']['remote_filesize']} {$value['remote']['relative']}");
|
_error_log("CDNStorage::get same size {$value['remote']['remote_filesize']} {$value['remote']['relative']}");
|
||||||
} else {
|
} else {
|
||||||
$filesToDownload[] = $value['local']['local_path'];
|
$filesToDownload[] = $value['local']['local_path'];
|
||||||
|
@ -614,8 +632,8 @@ class CDNStorage {
|
||||||
|
|
||||||
_error_log("CDNStorage::get videos_id={$videos_id} totalSameTime=$totalSameTime totalFiles={$totalFiles} totalFilesize=" . humanFileSize($totalFilesize));
|
_error_log("CDNStorage::get videos_id={$videos_id} totalSameTime=$totalSameTime totalFiles={$totalFiles} totalFilesize=" . humanFileSize($totalFilesize));
|
||||||
|
|
||||||
$conn_id = array();
|
$conn_id = [];
|
||||||
$ret = array();
|
$ret = [];
|
||||||
$fileDownloadCount = 0;
|
$fileDownloadCount = 0;
|
||||||
for ($i = 0; $i < $totalSameTime; $i++) {
|
for ($i = 0; $i < $totalSameTime; $i++) {
|
||||||
$file = array_shift($filesToDownload);
|
$file = array_shift($filesToDownload);
|
||||||
|
@ -687,10 +705,11 @@ class CDNStorage {
|
||||||
} else {
|
} else {
|
||||||
_error_log("CDNStorage::get finished ERROR ");
|
_error_log("CDNStorage::get finished ERROR ");
|
||||||
}
|
}
|
||||||
return array('filesCopied' => $fileDownloadCount, 'totalBytesTransferred' => $totalBytesTransferred);
|
return ['filesCopied' => $fileDownloadCount, 'totalBytesTransferred' => $totalBytesTransferred];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getConnID($index, &$conn_id) {
|
private static function getConnID($index, &$conn_id)
|
||||||
|
{
|
||||||
if (empty($conn_id[$index])) {
|
if (empty($conn_id[$index])) {
|
||||||
$obj = AVideoPlugin::getDataObject('CDN');
|
$obj = AVideoPlugin::getDataObject('CDN');
|
||||||
$conn_id[$index] = ftp_connect($obj->storage_hostname);
|
$conn_id[$index] = ftp_connect($obj->storage_hostname);
|
||||||
|
@ -707,10 +726,11 @@ class CDNStorage {
|
||||||
return $conn_id[$index];
|
return $conn_id[$index];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function downloadFromCDNStorage($local_path, $index, &$conn_id, &$ret) {
|
private static function downloadFromCDNStorage($local_path, $index, &$conn_id, &$ret)
|
||||||
|
{
|
||||||
global $_uploadInfo;
|
global $_uploadInfo;
|
||||||
if (!isset($_uploadInfo)) {
|
if (!isset($_uploadInfo)) {
|
||||||
$_uploadInfo = array();
|
$_uploadInfo = [];
|
||||||
}
|
}
|
||||||
if (empty($local_path)) {
|
if (empty($local_path)) {
|
||||||
_error_log("CDNStorage::downloadFromCDNStorage error empty local file name {$local_path}");
|
_error_log("CDNStorage::downloadFromCDNStorage error empty local file name {$local_path}");
|
||||||
|
@ -739,7 +759,7 @@ class CDNStorage {
|
||||||
}
|
}
|
||||||
_error_log("CDNStorage::downloadFromCDNStorage [$index] START {$remote_file} to {$local_path} ");
|
_error_log("CDNStorage::downloadFromCDNStorage [$index] START {$remote_file} to {$local_path} ");
|
||||||
//_error_log("CDNStorage::put:uploadToCDNStorage " . __LINE__);
|
//_error_log("CDNStorage::put:uploadToCDNStorage " . __LINE__);
|
||||||
$_uploadInfo[$index] = array('microtime' => microtime(true), 'filesize' => $filesize, 'local_path' => $local_path, 'remote_file' => $remote_file);
|
$_uploadInfo[$index] = ['microtime' => microtime(true), 'filesize' => $filesize, 'local_path' => $local_path, 'remote_file' => $remote_file];
|
||||||
$fp = fopen($local_path, 'w');
|
$fp = fopen($local_path, 'w');
|
||||||
//_error_log("CDNStorage::put:uploadToCDNStorage " . __LINE__);
|
//_error_log("CDNStorage::put:uploadToCDNStorage " . __LINE__);
|
||||||
$ret[$index] = ftp_nb_fget($connID, $fp, $remote_file, FTP_BINARY);
|
$ret[$index] = ftp_nb_fget($connID, $fp, $remote_file, FTP_BINARY);
|
||||||
|
@ -747,10 +767,11 @@ class CDNStorage {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function uploadToCDNStorage($local_path, $index, &$conn_id, &$ret) {
|
private static function uploadToCDNStorage($local_path, $index, &$conn_id, &$ret)
|
||||||
|
{
|
||||||
global $_uploadInfo;
|
global $_uploadInfo;
|
||||||
if (!isset($_uploadInfo)) {
|
if (!isset($_uploadInfo)) {
|
||||||
$_uploadInfo = array();
|
$_uploadInfo = [];
|
||||||
}
|
}
|
||||||
if (empty($local_path)) {
|
if (empty($local_path)) {
|
||||||
_error_log("CDNStorage::put:uploadToCDNStorage error empty local file name {$local_path}");
|
_error_log("CDNStorage::put:uploadToCDNStorage error empty local file name {$local_path}");
|
||||||
|
@ -771,14 +792,15 @@ class CDNStorage {
|
||||||
//_error_log("CDNStorage::put:uploadToCDNStorage [$index] START " . humanFileSize($filesize) . " {$remote_file} ");
|
//_error_log("CDNStorage::put:uploadToCDNStorage [$index] START " . humanFileSize($filesize) . " {$remote_file} ");
|
||||||
$connID = self::getConnID($index, $conn_id);
|
$connID = self::getConnID($index, $conn_id);
|
||||||
//_error_log("CDNStorage::put:uploadToCDNStorage " . __LINE__);
|
//_error_log("CDNStorage::put:uploadToCDNStorage " . __LINE__);
|
||||||
$_uploadInfo[$index] = array('microtime' => microtime(true), 'filesize' => $filesize, 'local_path' => $local_path, 'remote_file' => $remote_file);
|
$_uploadInfo[$index] = ['microtime' => microtime(true), 'filesize' => $filesize, 'local_path' => $local_path, 'remote_file' => $remote_file];
|
||||||
//_error_log("CDNStorage::put:uploadToCDNStorage " . __LINE__);
|
//_error_log("CDNStorage::put:uploadToCDNStorage " . __LINE__);
|
||||||
$ret[$index] = ftp_nb_put($connID, $remote_file, $local_path, FTP_BINARY);
|
$ret[$index] = ftp_nb_put($connID, $remote_file, $local_path, FTP_BINARY);
|
||||||
//_error_log("CDNStorage::put:uploadToCDNStorage SUCCESS [$index] {$remote_file} " . json_encode($_uploadInfo[$index]));
|
//_error_log("CDNStorage::put:uploadToCDNStorage SUCCESS [$index] {$remote_file} " . json_encode($_uploadInfo[$index]));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function createDummyFiles($videos_id) {
|
public static function createDummyFiles($videos_id)
|
||||||
|
{
|
||||||
$msg = "createDummyFiles($videos_id) ";
|
$msg = "createDummyFiles($videos_id) ";
|
||||||
self::addToLog($videos_id, $msg);
|
self::addToLog($videos_id, $msg);
|
||||||
global $_getFilesListBoth, $_getFilesListRemote, $_getFilesList_CDNSTORAGE;
|
global $_getFilesListBoth, $_getFilesListRemote, $_getFilesList_CDNSTORAGE;
|
||||||
|
@ -791,7 +813,7 @@ class CDNStorage {
|
||||||
foreach ($list as $key => $value) {
|
foreach ($list as $key => $value) {
|
||||||
if (empty($value['local']) || empty($value['local']['local_filesize']) || $value['local']['local_filesize'] <= 20) {
|
if (empty($value['local']) || empty($value['local']['local_filesize']) || $value['local']['local_filesize'] <= 20) {
|
||||||
continue;
|
continue;
|
||||||
} else if (@$value['local']['local_filesize'] == @$value['remote']['remote_filesize']) {
|
} elseif (@$value['local']['local_filesize'] == @$value['remote']['remote_filesize']) {
|
||||||
$msg = "createDummyFiles {$value['local']['local_path']} ";
|
$msg = "createDummyFiles {$value['local']['local_path']} ";
|
||||||
self::addToLog($videos_id, $msg);
|
self::addToLog($videos_id, $msg);
|
||||||
self::createDummy($value['local']['local_path']);
|
self::createDummy($value['local']['local_path']);
|
||||||
|
@ -803,12 +825,13 @@ class CDNStorage {
|
||||||
return $filesAffected;
|
return $filesAffected;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function sendSocketNotification($videos_id, $msg) {
|
public static function sendSocketNotification($videos_id, $msg)
|
||||||
if(empty($videos_id)){
|
{
|
||||||
|
if (empty($videos_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$v = Video::getVideoLight($videos_id);
|
$v = Video::getVideoLight($videos_id);
|
||||||
if(empty($v)){
|
if (empty($v)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$users_id = $v['users_id'];
|
$users_id = $v['users_id'];
|
||||||
|
@ -819,7 +842,8 @@ class CDNStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function setProgress($videos_id, $isOnTheStorage, $finished) {
|
private static function setProgress($videos_id, $isOnTheStorage, $finished)
|
||||||
|
{
|
||||||
self::setSite($videos_id, $isOnTheStorage);
|
self::setSite($videos_id, $isOnTheStorage);
|
||||||
if ($finished) {
|
if ($finished) {
|
||||||
Video::updateFilesize($videos_id);
|
Video::updateFilesize($videos_id);
|
||||||
|
@ -827,7 +851,8 @@ class CDNStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function isMoving($videos_id) {
|
public static function isMoving($videos_id)
|
||||||
|
{
|
||||||
$file = self::getLogFile($videos_id);
|
$file = self::getLogFile($videos_id);
|
||||||
if (empty($file) || !file_exists($file)) {
|
if (empty($file) || !file_exists($file)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -840,17 +865,18 @@ class CDNStorage {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return array('modified' => $modified, 'created' => filectime($file));
|
return ['modified' => $modified, 'created' => filectime($file)];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function createDummy($file_path) {
|
public static function createDummy($file_path)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$path_parts = pathinfo($file_path);
|
$path_parts = pathinfo($file_path);
|
||||||
$extension = strtolower($path_parts['extension']);
|
$extension = strtolower($path_parts['extension']);
|
||||||
|
|
||||||
if ($extension == 'ts') {
|
if ($extension == 'ts') {
|
||||||
unlink($file_path);
|
unlink($file_path);
|
||||||
} else if (in_array($extension, CDNStorage::$allowedFiles)) {
|
} elseif (in_array($extension, CDNStorage::$allowedFiles)) {
|
||||||
file_put_contents($file_path, 'Dummy File');
|
file_put_contents($file_path, 'Dummy File');
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -859,13 +885,14 @@ class CDNStorage {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getFilesListLocal($videos_id, $skipDummyFiles = true) {
|
public static function getFilesListLocal($videos_id, $skipDummyFiles = true)
|
||||||
|
{
|
||||||
global $global, $_getFilesList_CDNSTORAGE;
|
global $global, $_getFilesList_CDNSTORAGE;
|
||||||
if(empty($videos_id)){
|
if (empty($videos_id)) {
|
||||||
return array();
|
return [];
|
||||||
}
|
}
|
||||||
if (!isset($_getFilesList_CDNSTORAGE)) {
|
if (!isset($_getFilesList_CDNSTORAGE)) {
|
||||||
$_getFilesList_CDNSTORAGE = array();
|
$_getFilesList_CDNSTORAGE = [];
|
||||||
}
|
}
|
||||||
if (!empty($_getFilesList_CDNSTORAGE[$videos_id])) {
|
if (!empty($_getFilesList_CDNSTORAGE[$videos_id])) {
|
||||||
return $_getFilesList_CDNSTORAGE[$videos_id];
|
return $_getFilesList_CDNSTORAGE[$videos_id];
|
||||||
|
@ -874,7 +901,7 @@ class CDNStorage {
|
||||||
$pz = self::getPZ();
|
$pz = self::getPZ();
|
||||||
$files = self::getLocalFolder($videos_id);
|
$files = self::getLocalFolder($videos_id);
|
||||||
$video = Video::getVideoLight($videos_id);
|
$video = Video::getVideoLight($videos_id);
|
||||||
$filesList = array();
|
$filesList = [];
|
||||||
$acumulative = 0;
|
$acumulative = 0;
|
||||||
foreach ($files as $value) {
|
foreach ($files as $value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
|
@ -899,16 +926,18 @@ class CDNStorage {
|
||||||
return $filesList;
|
return $filesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAddress($filename) {
|
public function getAddress($filename)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/video.php';
|
require_once $global['systemRootPath'] . 'objects/video.php';
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
$file = Video::getPathToFile($filename);
|
$file = Video::getPathToFile($filename);
|
||||||
$address = array('path' => $file, 'url' => $this->getURL($filename));
|
$address = ['path' => $file, 'url' => $this->getURL($filename)];
|
||||||
return $address;
|
return $address;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getURL($filename) {
|
public static function getURL($filename)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
|
|
||||||
// this is because sometimes I send filenames like this "videos/video_200721131007_6b3e/video_200721131007_6b3e_Low.mp4"
|
// this is because sometimes I send filenames like this "videos/video_200721131007_6b3e/video_200721131007_6b3e_Low.mp4"
|
||||||
|
@ -946,13 +975,14 @@ class CDNStorage {
|
||||||
return "https://{$pz}{$relativeFilename}";
|
return "https://{$pz}{$relativeFilename}";
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getLogFile($videos_id) {
|
public static function getLogFile($videos_id)
|
||||||
if(empty($videos_id)){
|
{
|
||||||
|
if (empty($videos_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$video = Video::getVideoLight($videos_id);
|
$video = Video::getVideoLight($videos_id);
|
||||||
|
|
||||||
if(empty($video)){
|
if (empty($video)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,8 +992,9 @@ class CDNStorage {
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function addToLog($videos_id, $message) {
|
public static function addToLog($videos_id, $message)
|
||||||
if(empty($videos_id)){
|
{
|
||||||
|
if (empty($videos_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (isCommandLineInterface()) {
|
if (isCommandLineInterface()) {
|
||||||
|
@ -971,27 +1002,28 @@ class CDNStorage {
|
||||||
}
|
}
|
||||||
_error_log($message);
|
_error_log($message);
|
||||||
$file = self::getLogFile($videos_id);
|
$file = self::getLogFile($videos_id);
|
||||||
if(empty($file)){
|
if (empty($file)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return file_put_contents($file, date('Y-m-d H:i:s: ') . $message . PHP_EOL, FILE_APPEND);
|
return file_put_contents($file, date('Y-m-d H:i:s: ') . $message . PHP_EOL, FILE_APPEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function deleteLog($videos_id) {
|
public static function deleteLog($videos_id)
|
||||||
if(empty($videos_id)){
|
{
|
||||||
|
if (empty($videos_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$file = self::getLogFile($videos_id);
|
$file = self::getLogFile($videos_id);
|
||||||
if(empty($file)){
|
if (empty($file)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return unlink($file);
|
return unlink($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function file_get_contents($remote_filename) {
|
public static function file_get_contents($remote_filename)
|
||||||
|
{
|
||||||
$obj = AVideoPlugin::getDataObject('CDN');
|
$obj = AVideoPlugin::getDataObject('CDN');
|
||||||
$filename = "ftp://{$obj->storage_username}:{$obj->storage_password}@{$obj->storage_hostname}/{$remote_filename}";
|
$filename = "ftp://{$obj->storage_username}:{$obj->storage_password}@{$obj->storage_hostname}/{$remote_filename}";
|
||||||
return file_get_contents($filename);
|
return file_get_contents($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ if (empty($_REQUEST['videos_id'])) {
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
if (!is_array($_REQUEST['videos_id'])) {
|
if (!is_array($_REQUEST['videos_id'])) {
|
||||||
$_REQUEST['videos_id'] = array($_REQUEST['videos_id']);
|
$_REQUEST['videos_id'] = [$_REQUEST['videos_id']];
|
||||||
}
|
}
|
||||||
|
|
||||||
_error_log('Start to move file ');
|
_error_log('Start to move file ');
|
||||||
|
@ -41,7 +41,6 @@ foreach ($_REQUEST['videos_id'] as $videos_id) {
|
||||||
$obj->error = false;
|
$obj->error = false;
|
||||||
//$obj->response = CDNStorage::moveLocalToRemote($videos_id);
|
//$obj->response = CDNStorage::moveLocalToRemote($videos_id);
|
||||||
$obj->response = CDNStorage::put($videos_id, 4);
|
$obj->response = CDNStorage::put($videos_id, 4);
|
||||||
|
|
||||||
}
|
}
|
||||||
_error_log('Finish to move file ');
|
_error_log('Finish to move file ');
|
||||||
echo json_encode($obj);
|
echo json_encode($obj);
|
||||||
|
|
|
@ -10,12 +10,12 @@ $obj->error = true;
|
||||||
$obj->msg = "";
|
$obj->msg = "";
|
||||||
|
|
||||||
$isEnabled = AVideoPlugin::isEnabledByName('CDN');
|
$isEnabled = AVideoPlugin::isEnabledByName('CDN');
|
||||||
if(!$isEnabled){
|
if (!$isEnabled) {
|
||||||
$obj->msg = "CDN is disabled";
|
$obj->msg = "CDN is disabled";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($_REQUEST['videos_id'])){
|
if (empty($_REQUEST['videos_id'])) {
|
||||||
$_REQUEST['videos_id'] = intval(@$argv[1]);
|
$_REQUEST['videos_id'] = intval(@$argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ if (empty($_REQUEST['videos_id'])) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_array($_REQUEST['videos_id'])) {
|
if (!is_array($_REQUEST['videos_id'])) {
|
||||||
$_REQUEST['videos_id'] = array($_REQUEST['videos_id']);
|
$_REQUEST['videos_id'] = [$_REQUEST['videos_id']];
|
||||||
}
|
}
|
||||||
|
|
||||||
_error_log('Start to move remote to local ');
|
_error_log('Start to move remote to local ');
|
||||||
|
@ -40,7 +40,6 @@ foreach ($_REQUEST['videos_id'] as $videos_id) {
|
||||||
|
|
||||||
$obj->error = false;
|
$obj->error = false;
|
||||||
$obj->response = CDNStorage::moveRemoteToLocal($videos_id);
|
$obj->response = CDNStorage::moveRemoteToLocal($videos_id);
|
||||||
|
|
||||||
}
|
}
|
||||||
_error_log('Finish to move remote to local ');
|
_error_log('Finish to move remote to local ');
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<?php
|
<?php
|
||||||
$totalL = $totalR = $totalFileSizeR = $totalFileSizeL = 0;
|
$totalL = $totalR = $totalFileSizeR = $totalFileSizeL = 0;
|
||||||
$list = CDNStorage::getFilesListBoth($videos_id);
|
$list = CDNStorage::getFilesListBoth($videos_id);
|
||||||
$listString = array();
|
$listString = [];
|
||||||
foreach ($list as $key => $value) {
|
foreach ($list as $key => $value) {
|
||||||
if (!empty($value['local']['local_filesize']) && $value['local']['local_filesize'] > 20 && $value['local']['local_filesize'] > 0) {
|
if (!empty($value['local']['local_filesize']) && $value['local']['local_filesize'] > 20 && $value['local']['local_filesize'] > 0) {
|
||||||
$totalL++;
|
$totalL++;
|
||||||
|
@ -34,8 +34,7 @@
|
||||||
<?php
|
<?php
|
||||||
printf(__('Upload %d files to storage'), $totalL);
|
printf(__('Upload %d files to storage'), $totalL);
|
||||||
$humanSize = humanFileSize($totalFileSizeL);
|
$humanSize = humanFileSize($totalFileSizeL);
|
||||||
echo ' (' . $humanSize . ')';
|
echo ' (' . $humanSize . ')'; ?>
|
||||||
?>
|
|
||||||
</button>
|
</button>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
@ -59,17 +58,15 @@
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if ($totalR) {
|
if ($totalR) {
|
||||||
if(empty($totalL)){
|
if (empty($totalL)) {
|
||||||
CDNStorage::setSite($videos_id, true);
|
CDNStorage::setSite($videos_id, true);
|
||||||
}
|
} ?>
|
||||||
?>
|
|
||||||
<button type="button" class="btn btn-success" onclick="CDNStorageDownload();">
|
<button type="button" class="btn btn-success" onclick="CDNStorageDownload();">
|
||||||
<i class="fas fa-project-diagram"></i>
|
<i class="fas fa-project-diagram"></i>
|
||||||
<?php
|
<?php
|
||||||
printf(__('Download %d files to disk'), $totalR);
|
printf(__('Download %d files to disk'), $totalR);
|
||||||
$humanSize = humanFileSize($totalFileSizeR);
|
$humanSize = humanFileSize($totalFileSizeR);
|
||||||
echo ' (' . $humanSize . ')';
|
echo ' (' . $humanSize . ')'; ?>
|
||||||
?>
|
|
||||||
</button>
|
</button>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,9 @@ $video = Video::getVideoLight($videos_id);
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<?php
|
<?php
|
||||||
$isMoving = CDNStorage::isMoving($videos_id);
|
$isMoving = CDNStorage::isMoving($videos_id);
|
||||||
if(!empty($isMoving)){
|
if (!empty($isMoving)) {
|
||||||
include './panelIsMoving.php';
|
include './panelIsMoving.php';
|
||||||
}else{
|
} else {
|
||||||
include './panelMove.php';
|
include './panelMove.php';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -34,27 +34,27 @@ foreach ($_REQUEST['par'] as $key => $value) {
|
||||||
// Update S3 CDN
|
// Update S3 CDN
|
||||||
if (AVideoPlugin::isEnabledByName('AWS_S3')) {
|
if (AVideoPlugin::isEnabledByName('AWS_S3')) {
|
||||||
$resp->CDN_S3 = CDN::getCDN_S3URL();
|
$resp->CDN_S3 = CDN::getCDN_S3URL();
|
||||||
}else{
|
} else {
|
||||||
$resp->CDN_S3 = '';
|
$resp->CDN_S3 = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update B2 CDN
|
// Update B2 CDN
|
||||||
if (AVideoPlugin::isEnabledByName('Blackblaze_B2')) {
|
if (AVideoPlugin::isEnabledByName('Blackblaze_B2')) {
|
||||||
$resp->CDN_B2 = CDN::getCDN_B2URL();
|
$resp->CDN_B2 = CDN::getCDN_B2URL();
|
||||||
}else{
|
} else {
|
||||||
$resp->CDN_B2 = '';
|
$resp->CDN_B2 = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update FTP CDN
|
// Update FTP CDN
|
||||||
if (AVideoPlugin::isEnabledByName('FTP_Storage')) {
|
if (AVideoPlugin::isEnabledByName('FTP_Storage')) {
|
||||||
$resp->CDN_FTP = CDN::getCDN_FTPURL();
|
$resp->CDN_FTP = CDN::getCDN_FTPURL();
|
||||||
}else{
|
} else {
|
||||||
$resp->CDN_FTP = '';
|
$resp->CDN_FTP = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Live CDN
|
// Update Live CDN
|
||||||
$resp->CDN_Live = '';
|
$resp->CDN_Live = '';
|
||||||
$resp->CDN_LiveServers = array();
|
$resp->CDN_LiveServers = [];
|
||||||
$plugin = AVideoPlugin::getDataObjectIfEnabled('Live');
|
$plugin = AVideoPlugin::getDataObjectIfEnabled('Live');
|
||||||
if (!empty($plugin)) {
|
if (!empty($plugin)) {
|
||||||
if ($plugin->useLiveServers) {
|
if ($plugin->useLiveServers) {
|
||||||
|
@ -63,10 +63,10 @@ if (!empty($plugin)) {
|
||||||
if (empty($value['playerServer'])) {
|
if (empty($value['playerServer'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$resp->CDN_LiveServers[] = array(
|
$resp->CDN_LiveServers[] = [
|
||||||
'id' => $value['id'],
|
'id' => $value['id'],
|
||||||
'url' => addLastSlash($value['playerServer'])
|
'url' => addLastSlash($value['playerServer']),
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$resp->CDN_Live = addLastSlash($plugin->playerServer);
|
$resp->CDN_Live = addLastSlash($plugin->playerServer);
|
||||||
|
@ -75,7 +75,7 @@ if (!empty($plugin)) {
|
||||||
|
|
||||||
|
|
||||||
// Update YPT Storage CDN
|
// Update YPT Storage CDN
|
||||||
$resp->CDN_YPTStorage = array();
|
$resp->CDN_YPTStorage = [];
|
||||||
$plugin = AVideoPlugin::getDataObjectIfEnabled('YPTStorage');
|
$plugin = AVideoPlugin::getDataObjectIfEnabled('YPTStorage');
|
||||||
if (!empty($plugin)) {
|
if (!empty($plugin)) {
|
||||||
$rows = Sites::getAllActive();
|
$rows = Sites::getAllActive();
|
||||||
|
@ -83,10 +83,10 @@ if (!empty($plugin)) {
|
||||||
if (empty($value['url'])) {
|
if (empty($value['url'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$resp->CDN_YPTStorage[] = array(
|
$resp->CDN_YPTStorage[] = [
|
||||||
'id' => $value['id'],
|
'id' => $value['id'],
|
||||||
'url' => addLastSlash($value['url'])
|
'url' => addLastSlash($value['url']),
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
require_once $config;
|
require_once $config;
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ var_dump($list);
|
||||||
$index = intval(@$argv[1]);
|
$index = intval(@$argv[1]);
|
||||||
|
|
||||||
$list = ftp_rawlist($conn_id[0], "/{$CDNObj->storage_username}/", true);
|
$list = ftp_rawlist($conn_id[0], "/{$CDNObj->storage_username}/", true);
|
||||||
for ($i=$index;$i<count($list);$i++){
|
for ($i=$index;$i<count($list);$i++) {
|
||||||
$value = $list[$i];
|
$value = $list[$i];
|
||||||
$parts = explode(' ', $value);
|
$parts = explode(' ', $value);
|
||||||
$dir = end($parts);
|
$dir = end($parts);
|
||||||
|
@ -37,7 +36,7 @@ for ($i=$index;$i<count($list);$i++){
|
||||||
$files = ftp_rawlist($conn_id[0], "/{$CDNObj->storage_username}/{$dir}/", true);
|
$files = ftp_rawlist($conn_id[0], "/{$CDNObj->storage_username}/{$dir}/", true);
|
||||||
foreach ($files as $file) {
|
foreach ($files as $file) {
|
||||||
trim($file);
|
trim($file);
|
||||||
if(preg_match('/enc_[0-9a-z]+.key$/i', $file)){
|
if (preg_match('/enc_[0-9a-z]+.key$/i', $file)) {
|
||||||
$parts = explode(' ', $file);
|
$parts = explode(' ', $file);
|
||||||
$file = end($parts);
|
$file = end($parts);
|
||||||
$file = "/{$CDNObj->storage_username}/{$dir}/{$file}";
|
$file = "/{$CDNObj->storage_username}/{$dir}/{$file}";
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
require_once $config;
|
require_once $config;
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
@ -27,7 +26,7 @@ $countSiteIdEmpty = 0;
|
||||||
$countStatusNotActive = 0;
|
$countStatusNotActive = 0;
|
||||||
$countMoved = 0;
|
$countMoved = 0;
|
||||||
|
|
||||||
$sites_id_to_move = array();
|
$sites_id_to_move = [];
|
||||||
|
|
||||||
foreach ($videos as $value) {
|
foreach ($videos as $value) {
|
||||||
$count++;
|
$count++;
|
||||||
|
@ -53,9 +52,9 @@ foreach ($sites_id_to_move as $key => $value) {
|
||||||
$startF = microtime(true);
|
$startF = microtime(true);
|
||||||
//$response = CDNStorage::get($value, 10);
|
//$response = CDNStorage::get($value, 10);
|
||||||
$response = CDNStorage::moveRemoteToLocal($value, false, false);
|
$response = CDNStorage::moveRemoteToLocal($value, false, false);
|
||||||
if(empty($response)){
|
if (empty($response)) {
|
||||||
echo "{$key}/{$total} ERROR " . PHP_EOL;
|
echo "{$key}/{$total} ERROR " . PHP_EOL;
|
||||||
}else{
|
} else {
|
||||||
$endF = microtime(true) - $startF;
|
$endF = microtime(true) - $startF;
|
||||||
$ETA = ($total - $key + 1) * $endF;
|
$ETA = ($total - $key + 1) * $endF;
|
||||||
$ps = humanFileSize($response['totalBytesTransferred'] / ($endF));
|
$ps = humanFileSize($response['totalBytesTransferred'] / ($endF));
|
||||||
|
@ -66,4 +65,3 @@ foreach ($sites_id_to_move as $key => $value) {
|
||||||
echo "SiteIdNotEmpty = $countSiteIdEmpty; StatusNotActive=$countStatusNotActive; Moved=$countMoved;" . PHP_EOL;
|
echo "SiteIdNotEmpty = $countSiteIdEmpty; StatusNotActive=$countStatusNotActive; Moved=$countMoved;" . PHP_EOL;
|
||||||
echo PHP_EOL . " Done! " . PHP_EOL;
|
echo PHP_EOL . " Done! " . PHP_EOL;
|
||||||
die();
|
die();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
require_once $config;
|
require_once $config;
|
||||||
|
|
||||||
|
@ -13,7 +12,7 @@ if (empty($isCDNEnabled)) {
|
||||||
return die('Plugin disabled');
|
return die('Plugin disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
$storages = array('https://storage.wetube.club/', 'https://storage1.wetube.club/');
|
$storages = ['https://storage.wetube.club/', 'https://storage1.wetube.club/'];
|
||||||
|
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
set_time_limit(300);
|
set_time_limit(300);
|
||||||
|
@ -43,14 +42,14 @@ foreach ($videos as $value) {
|
||||||
foreach ($file as $file2) {
|
foreach ($file as $file2) {
|
||||||
if (preg_match('/index.m3u8$/', $file2)) {
|
if (preg_match('/index.m3u8$/', $file2)) {
|
||||||
$m3u8 = true;
|
$m3u8 = true;
|
||||||
} else if (preg_match('/enc.*.key$/', $file2)) {
|
} elseif (preg_match('/enc.*.key$/', $file2)) {
|
||||||
$enckey = true;
|
$enckey = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (preg_match('/index.m3u8$/', $file)) {
|
if (preg_match('/index.m3u8$/', $file)) {
|
||||||
$m3u8 = true;
|
$m3u8 = true;
|
||||||
} else if (preg_match('/enc.*.key$/', $file)) {
|
} elseif (preg_match('/enc.*.key$/', $file)) {
|
||||||
$enckey = true;
|
$enckey = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,9 +64,9 @@ foreach ($videos as $value) {
|
||||||
$url = "{$s}tools/getenckey.json.php?folder={$value['filename']}";
|
$url = "{$s}tools/getenckey.json.php?folder={$value['filename']}";
|
||||||
echo "{$url}" . PHP_EOL;
|
echo "{$url}" . PHP_EOL;
|
||||||
$content = file_get_contents("{$s}tools/getenckey.json.php?folder={$value['filename']}");
|
$content = file_get_contents("{$s}tools/getenckey.json.php?folder={$value['filename']}");
|
||||||
if(!empty($content)){
|
if (!empty($content)) {
|
||||||
$json = json_decode($content);
|
$json = json_decode($content);
|
||||||
if(!empty($json->pathinfo)){
|
if (!empty($json->pathinfo)) {
|
||||||
file_put_contents("{$paths['path']}missingkey", time());
|
file_put_contents("{$paths['path']}missingkey", time());
|
||||||
file_put_contents("{$paths['path']}{$json->pathinfo->basename}", base64_decode($json->content));
|
file_put_contents("{$paths['path']}{$json->pathinfo->basename}", base64_decode($json->content));
|
||||||
echo "Saved from {$s} on {$paths['path']}{$json->pathinfo->basename}" . PHP_EOL;
|
echo "Saved from {$s} on {$paths['path']}{$json->pathinfo->basename}" . PHP_EOL;
|
||||||
|
@ -81,4 +80,3 @@ foreach ($videos as $value) {
|
||||||
|
|
||||||
echo PHP_EOL . " Done! " . PHP_EOL;
|
echo PHP_EOL . " Done! " . PHP_EOL;
|
||||||
die();
|
die();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
require_once $config;
|
require_once $config;
|
||||||
|
|
||||||
|
@ -29,7 +28,7 @@ $countSiteIdNotEmpty = 0;
|
||||||
$countStatusNotActive = 0;
|
$countStatusNotActive = 0;
|
||||||
$countMoved = 0;
|
$countMoved = 0;
|
||||||
|
|
||||||
$sites_id_to_move = array();
|
$sites_id_to_move = [];
|
||||||
|
|
||||||
foreach ($videos as $value) {
|
foreach ($videos as $value) {
|
||||||
$count++;
|
$count++;
|
||||||
|
@ -45,15 +44,15 @@ foreach ($videos as $value) {
|
||||||
|
|
||||||
$total = count($sites_id_to_move);
|
$total = count($sites_id_to_move);
|
||||||
foreach ($sites_id_to_move as $key => $value) {
|
foreach ($sites_id_to_move as $key => $value) {
|
||||||
if(!empty($index) && $key<$index){
|
if (!empty($index) && $key<$index) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
echo "{$key}/{$total} Start move {$value} " . PHP_EOL;
|
echo "{$key}/{$total} Start move {$value} " . PHP_EOL;
|
||||||
$startF = microtime(true);
|
$startF = microtime(true);
|
||||||
$response = CDNStorage::put($value, 4);
|
$response = CDNStorage::put($value, 4);
|
||||||
if(empty($response)){
|
if (empty($response)) {
|
||||||
echo "{$key}/{$total} ERROR " . PHP_EOL;
|
echo "{$key}/{$total} ERROR " . PHP_EOL;
|
||||||
}else{
|
} else {
|
||||||
$endF = microtime(true) - $startF;
|
$endF = microtime(true) - $startF;
|
||||||
$ETA = ($total - $key + 1) * $endF;
|
$ETA = ($total - $key + 1) * $endF;
|
||||||
$ps = humanFileSize($response['totalBytesTransferred'] / ($endF));
|
$ps = humanFileSize($response['totalBytesTransferred'] / ($endF));
|
||||||
|
@ -64,4 +63,3 @@ foreach ($sites_id_to_move as $key => $value) {
|
||||||
echo "SiteIdNotEmpty = $countSiteIdNotEmpty; StatusNotActive=$countStatusNotActive; Moved=$countMoved;" . PHP_EOL;
|
echo "SiteIdNotEmpty = $countSiteIdNotEmpty; StatusNotActive=$countStatusNotActive; Moved=$countMoved;" . PHP_EOL;
|
||||||
echo PHP_EOL . " Done! " . PHP_EOL;
|
echo PHP_EOL . " Done! " . PHP_EOL;
|
||||||
die();
|
die();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
require_once $config;
|
require_once $config;
|
||||||
|
|
||||||
|
@ -27,7 +26,7 @@ $countStatusNotActive = 0;
|
||||||
$countMoved = 0;
|
$countMoved = 0;
|
||||||
|
|
||||||
$videosDir = getVideosDir();
|
$videosDir = getVideosDir();
|
||||||
$errorsFound = array();
|
$errorsFound = [];
|
||||||
foreach ($videos as $value) {
|
foreach ($videos as $value) {
|
||||||
$count++;
|
$count++;
|
||||||
//echo "{$count}/{$total} Checking {$global['webSiteRootURL']}v/{$value['id']} {$value['title']}" . PHP_EOL;
|
//echo "{$count}/{$total} Checking {$global['webSiteRootURL']}v/{$value['id']} {$value['title']}" . PHP_EOL;
|
||||||
|
@ -48,24 +47,24 @@ foreach ($videos as $value) {
|
||||||
echo "Files found ".count($list) . PHP_EOL;
|
echo "Files found ".count($list) . PHP_EOL;
|
||||||
echo "Errors found ".count($errorsFound) . PHP_EOL;
|
echo "Errors found ".count($errorsFound) . PHP_EOL;
|
||||||
foreach ($list as $value) {
|
foreach ($list as $value) {
|
||||||
if(is_array($value)){
|
if (is_array($value)) {
|
||||||
foreach ($value as $value2) {
|
foreach ($value as $value2) {
|
||||||
if(preg_match('/index.m3u8$/', $value2)){
|
if (preg_match('/index.m3u8$/', $value2)) {
|
||||||
$remote_filename = str_replace($videosDir, '', $value2);
|
$remote_filename = str_replace($videosDir, '', $value2);
|
||||||
echo "Check {$value2}" . PHP_EOL;
|
echo "Check {$value2}" . PHP_EOL;
|
||||||
$content = trim(CDNStorage::file_get_contents($remote_filename));
|
$content = trim(CDNStorage::file_get_contents($remote_filename));
|
||||||
if($content=='Dummy File'){
|
if ($content=='Dummy File') {
|
||||||
$errorsFound[] = $value2;
|
$errorsFound[] = $value2;
|
||||||
//echo "Found ERROR {$value2}" . PHP_EOL;
|
//echo "Found ERROR {$value2}" . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
if(preg_match('/index.m3u8$/', $value)){
|
if (preg_match('/index.m3u8$/', $value)) {
|
||||||
$remote_filename = str_replace($videosDir, '', $value);
|
$remote_filename = str_replace($videosDir, '', $value);
|
||||||
echo "Check {$value}" . PHP_EOL;
|
echo "Check {$value}" . PHP_EOL;
|
||||||
$content = trim(CDNStorage::file_get_contents($remote_filename));
|
$content = trim(CDNStorage::file_get_contents($remote_filename));
|
||||||
if($content=='Dummy File'){
|
if ($content=='Dummy File') {
|
||||||
$errorsFound[] = $value;
|
$errorsFound[] = $value;
|
||||||
//echo "Found ERROR {$value}" . PHP_EOL;
|
//echo "Found ERROR {$value}" . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
@ -80,4 +79,3 @@ foreach ($errorsFound as $value) {
|
||||||
|
|
||||||
echo PHP_EOL . " Done! errorsFound = {$errorsFound} " . PHP_EOL;
|
echo PHP_EOL . " Done! errorsFound = {$errorsFound} " . PHP_EOL;
|
||||||
die();
|
die();
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$CDNObj = AVideoPlugin::getDataObject('CDN');
|
$CDNObj = AVideoPlugin::getDataObject('CDN');
|
||||||
|
|
||||||
function getConnID($index) {
|
function getConnID($index)
|
||||||
|
{
|
||||||
global $conn_id, $CDNObj;
|
global $conn_id, $CDNObj;
|
||||||
if (empty($conn_id[$index])) {
|
if (empty($conn_id[$index])) {
|
||||||
$conn_id[$index] = ftp_connect($CDNObj->storage_hostname);
|
$conn_id[$index] = ftp_connect($CDNObj->storage_hostname);
|
||||||
|
@ -18,7 +18,8 @@ function getConnID($index) {
|
||||||
return $conn_id[$index];
|
return $conn_id[$index];
|
||||||
}
|
}
|
||||||
|
|
||||||
function ftp_mlsd_recursive($ftp_stream, $directory) {
|
function ftp_mlsd_recursive($ftp_stream, $directory)
|
||||||
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
|
|
||||||
$files = ftp_mlsd($ftp_stream, $directory);
|
$files = ftp_mlsd($ftp_stream, $directory);
|
||||||
|
@ -31,7 +32,7 @@ function ftp_mlsd_recursive($ftp_stream, $directory) {
|
||||||
$filepath = $directory . "/" . $name;
|
$filepath = $directory . "/" . $name;
|
||||||
if (($file["type"] == "cdir") || ($file["type"] == "pdir")) {
|
if (($file["type"] == "cdir") || ($file["type"] == "pdir")) {
|
||||||
// noop
|
// noop
|
||||||
} else if ($file["type"] == "dir") {
|
} elseif ($file["type"] == "dir") {
|
||||||
$result = array_merge($result, ftp_mlsd_recursive($ftp_stream, $filepath));
|
$result = array_merge($result, ftp_mlsd_recursive($ftp_stream, $filepath));
|
||||||
} else {
|
} else {
|
||||||
$result[] = $filepath;
|
$result[] = $filepath;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
require_once $config;
|
require_once $config;
|
||||||
|
|
||||||
|
@ -32,7 +31,7 @@ $countSiteIdNotEmpty = 0;
|
||||||
$countStatusNotActive = 0;
|
$countStatusNotActive = 0;
|
||||||
$countMoved = 0;
|
$countMoved = 0;
|
||||||
|
|
||||||
$sites_id_to_move = array();
|
$sites_id_to_move = [];
|
||||||
|
|
||||||
foreach ($videos as $value) {
|
foreach ($videos as $value) {
|
||||||
$count++;
|
$count++;
|
||||||
|
@ -57,15 +56,15 @@ foreach ($videos as $value) {
|
||||||
|
|
||||||
$total = count($sites_id_to_move);
|
$total = count($sites_id_to_move);
|
||||||
foreach ($sites_id_to_move as $key => $value) {
|
foreach ($sites_id_to_move as $key => $value) {
|
||||||
if(!empty($index) && $key<$index){
|
if (!empty($index) && $key<$index) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
echo "{$key}/{$total} Start move {$value} onlyExtension={$onlyExtension}" . PHP_EOL;
|
echo "{$key}/{$total} Start move {$value} onlyExtension={$onlyExtension}" . PHP_EOL;
|
||||||
$startF = microtime(true);
|
$startF = microtime(true);
|
||||||
$response = CDNStorage::put($value, 4, $onlyExtension);
|
$response = CDNStorage::put($value, 4, $onlyExtension);
|
||||||
if(empty($response)){
|
if (empty($response)) {
|
||||||
echo "{$key}/{$total} ERROR " . PHP_EOL;
|
echo "{$key}/{$total} ERROR " . PHP_EOL;
|
||||||
}else{
|
} else {
|
||||||
$endF = microtime(true) - $startF;
|
$endF = microtime(true) - $startF;
|
||||||
$ETA = ($total - $key + 1) * $endF;
|
$ETA = ($total - $key + 1) * $endF;
|
||||||
$ps = humanFileSize($response['totalBytesTransferred'] / ($endF));
|
$ps = humanFileSize($response['totalBytesTransferred'] / ($endF));
|
||||||
|
@ -76,4 +75,3 @@ foreach ($sites_id_to_move as $key => $value) {
|
||||||
echo "SiteIdNotEmpty = $countSiteIdNotEmpty; StatusNotActive=$countStatusNotActive; Moved=$countMoved;" . PHP_EOL;
|
echo "SiteIdNotEmpty = $countSiteIdNotEmpty; StatusNotActive=$countStatusNotActive; Moved=$countMoved;" . PHP_EOL;
|
||||||
echo PHP_EOL . " Done! " . PHP_EOL;
|
echo PHP_EOL . " Done! " . PHP_EOL;
|
||||||
die();
|
die();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
require_once $config;
|
require_once $config;
|
||||||
|
|
||||||
|
@ -30,7 +29,7 @@ $countSiteIdNotEmpty = 0;
|
||||||
$countStatusNotActive = 0;
|
$countStatusNotActive = 0;
|
||||||
$countMoved = 0;
|
$countMoved = 0;
|
||||||
|
|
||||||
$sites_id_to_move = array();
|
$sites_id_to_move = [];
|
||||||
|
|
||||||
foreach ($videos as $value) {
|
foreach ($videos as $value) {
|
||||||
$count++;
|
$count++;
|
||||||
|
@ -78,4 +77,3 @@ foreach ($sites_id_to_move as $key => $value) {
|
||||||
echo "SiteIdNotEmpty = $countSiteIdNotEmpty; StatusNotActive=$countStatusNotActive; Moved=$countMoved;" . PHP_EOL;
|
echo "SiteIdNotEmpty = $countSiteIdNotEmpty; StatusNotActive=$countStatusNotActive; Moved=$countMoved;" . PHP_EOL;
|
||||||
echo PHP_EOL . " Done! " . PHP_EOL;
|
echo PHP_EOL . " Done! " . PHP_EOL;
|
||||||
die();
|
die();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
$config = dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
require_once $config;
|
require_once $config;
|
||||||
|
|
||||||
|
@ -24,22 +23,22 @@ $sql = "SELECT * FROM videos WHERE 1=1 ORDER BY id DESC ";
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
if ($row['status'] === Video::$statusActive) {
|
if ($row['status'] === Video::$statusActive) {
|
||||||
exec("rm /var/www/html/AVideo/videos/{$row['filename']}/*.tgz");
|
exec("rm /var/www/html/AVideo/videos/{$row['filename']}/*.tgz");
|
||||||
$localList = CDNStorage::getFilesListLocal($row['id'], false);
|
$localList = CDNStorage::getFilesListLocal($row['id'], false);
|
||||||
$last = end($localList);
|
$last = end($localList);
|
||||||
if(empty($last)){
|
if (empty($last)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if($last['acumulativeFilesize']<10000){
|
if ($last['acumulativeFilesize']<10000) {
|
||||||
//echo "SKIP videos_id = {$row['id']} sites_id is not empty {$row['sites_id']} [{$last['acumulativeFilesize']}] ".humanFileSize($last['acumulativeFilesize']) . PHP_EOL;
|
//echo "SKIP videos_id = {$row['id']} sites_id is not empty {$row['sites_id']} [{$last['acumulativeFilesize']}] ".humanFileSize($last['acumulativeFilesize']) . PHP_EOL;
|
||||||
}else{
|
} else {
|
||||||
if(CDNStorage::isMoving($row['id'])){
|
if (CDNStorage::isMoving($row['id'])) {
|
||||||
echo "videos_id = {$row['id']} {$row['title']} Is moving ". PHP_EOL;
|
echo "videos_id = {$row['id']} {$row['title']} Is moving ". PHP_EOL;
|
||||||
}else{
|
} else {
|
||||||
echo "videos_id = {$row['id']} {$row['title']} sites_id is not empty {$row['sites_id']} [{$last['acumulativeFilesize']}] ".humanFileSize($last['acumulativeFilesize']) . PHP_EOL;
|
echo "videos_id = {$row['id']} {$row['title']} sites_id is not empty {$row['sites_id']} [{$last['acumulativeFilesize']}] ".humanFileSize($last['acumulativeFilesize']) . PHP_EOL;
|
||||||
CDNStorage::put($row['id'], 4);
|
CDNStorage::put($row['id'], 4);
|
||||||
//CDNStorage::createDummyFiles($row['id']);
|
//CDNStorage::createDummyFiles($row['id']);
|
||||||
|
@ -52,4 +51,3 @@ if ($res != false) {
|
||||||
}
|
}
|
||||||
echo PHP_EOL . " Done! " . PHP_EOL;
|
echo PHP_EOL . " Done! " . PHP_EOL;
|
||||||
die();
|
die();
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,18 @@
|
||||||
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/Cache/Objects/CachesInDB.php';
|
require_once $global['systemRootPath'] . 'plugin/Cache/Objects/CachesInDB.php';
|
||||||
|
|
||||||
class Cache extends PluginAbstract {
|
class Cache extends PluginAbstract
|
||||||
|
{
|
||||||
public function getTags() {
|
public function getTags()
|
||||||
return array(
|
{
|
||||||
|
return [
|
||||||
PluginTags::$RECOMMENDED,
|
PluginTags::$RECOMMENDED,
|
||||||
PluginTags::$FREE
|
PluginTags::$FREE,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription() {
|
public function getDescription()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$txt = "AVideo application accelerator to cache pages.<br>Your website has 10,000 visitors who are online, and your dynamic page has to send 10,000 times the same queries to database on every page load. With this plugin, your page only sends 1 query to your DB, and uses the cache to serve the 9,999 other visitors.";
|
$txt = "AVideo application accelerator to cache pages.<br>Your website has 10,000 visitors who are online, and your dynamic page has to send 10,000 times the same queries to database on every page load. With this plugin, your page only sends 1 query to your DB, and uses the cache to serve the 9,999 other visitors.";
|
||||||
$txt .= "<br>To auto delete the old cache files you can use this crontab command <code>0 2 * * * php {$global['systemRootPath']}plugin/Cache/crontab.php</code> this will delete cache files that are 3 days old everyday at 2 AM";
|
$txt .= "<br>To auto delete the old cache files you can use this crontab command <code>0 2 * * * php {$global['systemRootPath']}plugin/Cache/crontab.php</code> this will delete cache files that are 3 days old everyday at 2 AM";
|
||||||
|
@ -20,19 +22,23 @@ class Cache extends PluginAbstract {
|
||||||
return $txt . $help;
|
return $txt . $help;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return "Cache";
|
return "Cache";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUUID() {
|
public function getUUID()
|
||||||
|
{
|
||||||
return "10573225-3807-4167-ba81-0509dd280e06";
|
return "10573225-3807-4167-ba81-0509dd280e06";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginVersion() {
|
public function getPluginVersion()
|
||||||
|
{
|
||||||
return "2.0";
|
return "2.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmptyDataObject() {
|
public function getEmptyDataObject()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->enableCachePerUser = false;
|
$obj->enableCachePerUser = false;
|
||||||
|
@ -45,7 +51,8 @@ class Cache extends PluginAbstract {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCacheDir($ignoreFirstPage = true) {
|
public function getCacheDir($ignoreFirstPage = true)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
if (!$ignoreFirstPage && $this->isFirstPage()) {
|
if (!$ignoreFirstPage && $this->isFirstPage()) {
|
||||||
|
@ -74,7 +81,8 @@ class Cache extends PluginAbstract {
|
||||||
return $obj->cacheDir;
|
return $obj->cacheDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getFileName() {
|
private function getFileName()
|
||||||
|
{
|
||||||
if (empty($_SERVER['REQUEST_URI'])) {
|
if (empty($_SERVER['REQUEST_URI'])) {
|
||||||
$_SERVER['REQUEST_URI'] = "";
|
$_SERVER['REQUEST_URI'] = "";
|
||||||
}
|
}
|
||||||
|
@ -100,11 +108,13 @@ class Cache extends PluginAbstract {
|
||||||
return $dir . User::getId() . "_{$compl}" . md5(@$_SESSION['channelName'] . $_SERVER['REQUEST_URI'] . $_SERVER['HTTP_HOST']) . "_" . $session_id . "_" . (!empty($_SERVER['HTTPS']) ? 'a' : '') . (@$_SESSION['language']) . '.cache';
|
return $dir . User::getId() . "_{$compl}" . md5(@$_SESSION['channelName'] . $_SERVER['REQUEST_URI'] . $_SERVER['HTTP_HOST']) . "_" . $session_id . "_" . (!empty($_SERVER['HTTPS']) ? 'a' : '') . (@$_SESSION['language']) . '.cache';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isFirstPage() {
|
private function isFirstPage()
|
||||||
|
{
|
||||||
return isFirstPage();
|
return isFirstPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStart() {
|
public function getStart()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
// ignore cache if it is command line
|
// ignore cache if it is command line
|
||||||
//var_dump($this->isFirstPage());exit;
|
//var_dump($this->isFirstPage());exit;
|
||||||
|
@ -116,8 +126,8 @@ class Cache extends PluginAbstract {
|
||||||
if (isCommandLineInterface()) {
|
if (isCommandLineInterface()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$whitelistedFiles = array('user.php', 'status.php', 'canWatchVideo.json.php', '/login', '/status');
|
$whitelistedFiles = ['user.php', 'status.php', 'canWatchVideo.json.php', '/login', '/status'];
|
||||||
$blacklistedFiles = array('videosAndroid.json.php');
|
$blacklistedFiles = ['videosAndroid.json.php'];
|
||||||
$baseName = basename($_SERVER["SCRIPT_FILENAME"]);
|
$baseName = basename($_SERVER["SCRIPT_FILENAME"]);
|
||||||
if (getVideos_id() || isVideo() || isLive() || isLiveLink() || in_array($baseName, $whitelistedFiles) || in_array($_SERVER['REQUEST_URI'], $whitelistedFiles)) {
|
if (getVideos_id() || isVideo() || isLive() || isLiveLink() || in_array($baseName, $whitelistedFiles) || in_array($_SERVER['REQUEST_URI'], $whitelistedFiles)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -127,7 +137,7 @@ class Cache extends PluginAbstract {
|
||||||
if ($this->isBlacklisted() || $this->isFirstPage() || !class_exists('User') || !User::isLogged() || !empty($obj->enableCacheForLoggedUsers)) {
|
if ($this->isBlacklisted() || $this->isFirstPage() || !class_exists('User') || !User::isLogged() || !empty($obj->enableCacheForLoggedUsers)) {
|
||||||
$cacheName = $this->getFileName();
|
$cacheName = $this->getFileName();
|
||||||
|
|
||||||
if($this->isFirstPage()){
|
if ($this->isFirstPage()) {
|
||||||
$cacheName = 'firstPage' . DIRECTORY_SEPARATOR . $cacheName;
|
$cacheName = 'firstPage' . DIRECTORY_SEPARATOR . $cacheName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +184,8 @@ class Cache extends PluginAbstract {
|
||||||
ob_start();
|
ob_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEnd() {
|
public function getEnd()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
echo PHP_EOL . '<!-- Page Generated in ' . getScriptRunMicrotimeInSeconds() . ' Seconds -->';
|
echo PHP_EOL . '<!-- Page Generated in ' . getScriptRunMicrotimeInSeconds() . ' Seconds -->';
|
||||||
|
@ -195,7 +206,7 @@ class Cache extends PluginAbstract {
|
||||||
if ($this->isBlacklisted() || $this->isFirstPage() || !class_exists('User') || !User::isLogged() || !empty($obj->enableCacheForLoggedUsers)) {
|
if ($this->isBlacklisted() || $this->isFirstPage() || !class_exists('User') || !User::isLogged() || !empty($obj->enableCacheForLoggedUsers)) {
|
||||||
$cacheName = $this->getFileName();
|
$cacheName = $this->getFileName();
|
||||||
|
|
||||||
if($this->isFirstPage()){
|
if ($this->isFirstPage()) {
|
||||||
$cacheName = 'firstPage' . DIRECTORY_SEPARATOR . $cacheName;
|
$cacheName = 'firstPage' . DIRECTORY_SEPARATOR . $cacheName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,8 +220,9 @@ class Cache extends PluginAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isREQUEST_URIWhitelisted() {
|
private function isREQUEST_URIWhitelisted()
|
||||||
$cacheBotWhitelist = array(
|
{
|
||||||
|
$cacheBotWhitelist = [
|
||||||
'aVideoEncoder',
|
'aVideoEncoder',
|
||||||
'plugin/Live/on_',
|
'plugin/Live/on_',
|
||||||
'plugin/YPTStorage',
|
'plugin/YPTStorage',
|
||||||
|
@ -223,7 +235,7 @@ class Cache extends PluginAbstract {
|
||||||
'mrss',
|
'mrss',
|
||||||
'/sitemap.xml',
|
'/sitemap.xml',
|
||||||
'plugin/Live/verifyToken.json.php',
|
'plugin/Live/verifyToken.json.php',
|
||||||
'control.json.php');
|
'control.json.php', ];
|
||||||
foreach ($cacheBotWhitelist as $value) {
|
foreach ($cacheBotWhitelist as $value) {
|
||||||
if (strpos($_SERVER['REQUEST_URI'], $value) !== false) {
|
if (strpos($_SERVER['REQUEST_URI'], $value) !== false) {
|
||||||
_error_log("Cache::isREQUEST_URIWhitelisted: ($value) is whitelisted");
|
_error_log("Cache::isREQUEST_URIWhitelisted: ($value) is whitelisted");
|
||||||
|
@ -233,13 +245,15 @@ class Cache extends PluginAbstract {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isBlacklisted() {
|
private function isBlacklisted()
|
||||||
$blacklistedFiles = array('videosAndroid.json.php');
|
{
|
||||||
|
$blacklistedFiles = ['videosAndroid.json.php'];
|
||||||
$baseName = basename($_SERVER["SCRIPT_FILENAME"]);
|
$baseName = basename($_SERVER["SCRIPT_FILENAME"]);
|
||||||
return in_array($baseName, $blacklistedFiles);
|
return in_array($baseName, $blacklistedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function start() {
|
private function start()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$time = microtime();
|
$time = microtime();
|
||||||
$time = explode(' ', $time);
|
$time = explode(' ', $time);
|
||||||
|
@ -247,7 +261,8 @@ class Cache extends PluginAbstract {
|
||||||
$global['cachePluginStart'] = $time;
|
$global['cachePluginStart'] = $time;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function end($type = "No Cache") {
|
private function end($type = "No Cache")
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (empty($global['cachePluginStart'])) {
|
if (empty($global['cachePluginStart'])) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -267,23 +282,26 @@ class Cache extends PluginAbstract {
|
||||||
_error_log("Page generated in {$total_time} seconds. {$type} ({$_SERVER['REQUEST_URI']}) FROM: {$_SERVER['REMOTE_ADDR']} Browser: {$_SERVER['HTTP_USER_AGENT']}");
|
_error_log("Page generated in {$total_time} seconds. {$type} ({$_SERVER['REQUEST_URI']}) FROM: {$_SERVER['REMOTE_ADDR']} Browser: {$_SERVER['HTTP_USER_AGENT']}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginMenu() {
|
public function getPluginMenu()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$fileAPIName = $global['systemRootPath'] . 'plugin/Cache/pluginMenu.html';
|
$fileAPIName = $global['systemRootPath'] . 'plugin/Cache/pluginMenu.html';
|
||||||
$content = file_get_contents($fileAPIName);
|
$content = file_get_contents($fileAPIName);
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFooterCode() {
|
public function getFooterCode()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (preg_match('/managerPlugins.php$/', $_SERVER["SCRIPT_FILENAME"])) {
|
if (preg_match('/managerPlugins.php$/', $_SERVER["SCRIPT_FILENAME"])) {
|
||||||
return "<script src=\"{$global['webSiteRootURL']}plugin/Cache/pluginMenu.js\"></script>";
|
return "<script src=\"{$global['webSiteRootURL']}plugin/Cache/pluginMenu.js\"></script>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCacheMetaData(){
|
public static function getCacheMetaData()
|
||||||
|
{
|
||||||
global $_getCacheMetaData;
|
global $_getCacheMetaData;
|
||||||
if(!empty($_getCacheMetaData)){
|
if (!empty($_getCacheMetaData)) {
|
||||||
return $_getCacheMetaData;
|
return $_getCacheMetaData;
|
||||||
}
|
}
|
||||||
$domain = getDomain();
|
$domain = getDomain();
|
||||||
|
@ -303,30 +321,33 @@ class Cache extends PluginAbstract {
|
||||||
$loggedType = CachesInDB::$loggedType_LOGGED;
|
$loggedType = CachesInDB::$loggedType_LOGGED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$_getCacheMetaData = array('domain'=>$domain, 'ishttps'=>$ishttps, 'user_location'=>$user_location, 'loggedType'=>$loggedType);
|
$_getCacheMetaData = ['domain'=>$domain, 'ishttps'=>$ishttps, 'user_location'=>$user_location, 'loggedType'=>$loggedType];
|
||||||
return $_getCacheMetaData;
|
return $_getCacheMetaData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function _getCache($name){
|
public static function _getCache($name)
|
||||||
|
{
|
||||||
$metadata = self::getCacheMetaData();
|
$metadata = self::getCacheMetaData();
|
||||||
return CachesInDB::_getCache($name, $metadata['domain'], $metadata['ishttps'], $metadata['user_location'], $metadata['loggedType']);
|
return CachesInDB::_getCache($name, $metadata['domain'], $metadata['ishttps'], $metadata['user_location'], $metadata['loggedType']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function _setCache($name, $value) {
|
public static function _setCache($name, $value)
|
||||||
|
{
|
||||||
$metadata = self::getCacheMetaData();
|
$metadata = self::getCacheMetaData();
|
||||||
return CachesInDB::_setCache($name, $value, $metadata['domain'], $metadata['ishttps'], $metadata['user_location'], $metadata['loggedType']);
|
return CachesInDB::_setCache($name, $value, $metadata['domain'], $metadata['ishttps'], $metadata['user_location'], $metadata['loggedType']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getCache($name, $lifetime = 60) {
|
public static function getCache($name, $lifetime = 60)
|
||||||
|
{
|
||||||
global $_getCacheDB, $global;
|
global $_getCacheDB, $global;
|
||||||
if(!empty($global['ignoreAllCache'])){
|
if (!empty($global['ignoreAllCache'])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if(!isset($_getCacheDB)){
|
if (!isset($_getCacheDB)) {
|
||||||
$_getCacheDB = array();
|
$_getCacheDB = [];
|
||||||
}
|
}
|
||||||
$index = "{$name}_{$lifetime}";
|
$index = "{$name}_{$lifetime}";
|
||||||
if(empty($_getCacheDB[$index])){
|
if (empty($_getCacheDB[$index])) {
|
||||||
$_getCacheDB[$index] = null;
|
$_getCacheDB[$index] = null;
|
||||||
$metadata = self::getCacheMetaData();
|
$metadata = self::getCacheMetaData();
|
||||||
$row = CachesInDB::_getCache($name, $metadata['domain'], $metadata['ishttps'], $metadata['user_location'], $metadata['loggedType']);
|
$row = CachesInDB::_getCache($name, $metadata['domain'], $metadata['ishttps'], $metadata['user_location'], $metadata['loggedType']);
|
||||||
|
@ -335,7 +356,7 @@ class Cache extends PluginAbstract {
|
||||||
if (!empty($lifetime) && ($time + $lifetime) < time()) {
|
if (!empty($lifetime) && ($time + $lifetime) < time()) {
|
||||||
$c = new CachesInDB($row['id']);
|
$c = new CachesInDB($row['id']);
|
||||||
$c->delete();
|
$c->delete();
|
||||||
}else{
|
} else {
|
||||||
$_getCacheDB[$index] = _json_decode($row['content']);
|
$_getCacheDB[$index] = _json_decode($row['content']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,36 +364,38 @@ class Cache extends PluginAbstract {
|
||||||
return $_getCacheDB[$index];
|
return $_getCacheDB[$index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function deleteCache($name) {
|
public static function deleteCache($name)
|
||||||
|
{
|
||||||
return CachesInDB::_deleteCache($name);
|
return CachesInDB::_deleteCache($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function deleteAllCache() {
|
public static function deleteAllCache()
|
||||||
|
{
|
||||||
return CachesInDB::_deleteAllCache();
|
return CachesInDB::_deleteAllCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function deleteFirstPageCache() {
|
public static function deleteFirstPageCache()
|
||||||
|
{
|
||||||
clearCache(true);
|
clearCache(true);
|
||||||
return CachesInDB::_deleteCacheStartingWith('firstPage');
|
return CachesInDB::_deleteCacheStartingWith('firstPage');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanitize_output($buffer) {
|
function sanitize_output($buffer)
|
||||||
|
{
|
||||||
$search = array(
|
$search = [
|
||||||
'/\>[^\S ]+/s', // strip whitespaces after tags, except space
|
'/\>[^\S ]+/s', // strip whitespaces after tags, except space
|
||||||
'/[^\S ]+\</s', // strip whitespaces before tags, except space
|
'/[^\S ]+\</s', // strip whitespaces before tags, except space
|
||||||
'/(\s)+/s', // shorten multiple whitespace sequences
|
'/(\s)+/s', // shorten multiple whitespace sequences
|
||||||
'/<!--(.|\s)*?-->/' // Remove HTML comments
|
'/<!--(.|\s)*?-->/', // Remove HTML comments
|
||||||
);
|
];
|
||||||
|
|
||||||
$replace = array(
|
$replace = [
|
||||||
'>',
|
'>',
|
||||||
'<',
|
'<',
|
||||||
'\\1',
|
'\\1',
|
||||||
''
|
'',
|
||||||
);
|
];
|
||||||
|
|
||||||
$len = strlen($buffer);
|
$len = strlen($buffer);
|
||||||
if ($len) {
|
if ($len) {
|
||||||
|
|
|
@ -2,105 +2,134 @@
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
|
|
||||||
class CachesInDB extends ObjectYPT {
|
class CachesInDB extends ObjectYPT
|
||||||
|
{
|
||||||
|
public static $loggedType_NOT_LOGGED = 'n';
|
||||||
|
public static $loggedType_LOGGED = 'l';
|
||||||
|
public static $loggedType_ADMIN = 'a';
|
||||||
|
public static $prefix = 'ypt_cache_';
|
||||||
|
protected $id;
|
||||||
|
protected $content;
|
||||||
|
protected $domain;
|
||||||
|
protected $ishttps;
|
||||||
|
protected $loggedType;
|
||||||
|
protected $user_location;
|
||||||
|
protected $expires;
|
||||||
|
protected $timezone;
|
||||||
|
protected $name;
|
||||||
|
|
||||||
static $loggedType_NOT_LOGGED = 'n';
|
public static function getSearchFieldsNames()
|
||||||
static $loggedType_LOGGED = 'l';
|
{
|
||||||
static $loggedType_ADMIN = 'a';
|
return ['domain', 'ishttps', 'user_location', 'timezone', 'name'];
|
||||||
static $prefix = 'ypt_cache_';
|
|
||||||
protected $id, $content, $domain, $ishttps, $loggedType, $user_location, $expires, $timezone, $name;
|
|
||||||
|
|
||||||
static function getSearchFieldsNames() {
|
|
||||||
return array('domain', 'ishttps', 'user_location', 'timezone', 'name');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTableName() {
|
public static function getTableName()
|
||||||
|
{
|
||||||
return 'CachesInDB';
|
return 'CachesInDB';
|
||||||
}
|
}
|
||||||
|
|
||||||
function setId($id) {
|
public function setId($id)
|
||||||
|
{
|
||||||
$this->id = intval($id);
|
$this->id = intval($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setContent($content) {
|
public function setContent($content)
|
||||||
|
{
|
||||||
$content = self::encodeContent($content);
|
$content = self::encodeContent($content);
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDomain($domain) {
|
public function setDomain($domain)
|
||||||
|
{
|
||||||
$this->domain = $domain;
|
$this->domain = $domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setIshttps($ishttps) {
|
public function setIshttps($ishttps)
|
||||||
|
{
|
||||||
$this->ishttps = $ishttps;
|
$this->ishttps = $ishttps;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLoggedType($loggedType) {
|
public function setLoggedType($loggedType)
|
||||||
|
{
|
||||||
$this->loggedType = $loggedType;
|
$this->loggedType = $loggedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUser_location($user_location) {
|
public function setUser_location($user_location)
|
||||||
|
{
|
||||||
$this->user_location = $user_location;
|
$this->user_location = $user_location;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setExpires($expires) {
|
public function setExpires($expires)
|
||||||
|
{
|
||||||
$this->expires = $expires;
|
$this->expires = $expires;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTimezone($timezone) {
|
public function setTimezone($timezone)
|
||||||
|
{
|
||||||
$this->timezone = $timezone;
|
$this->timezone = $timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setName($name) {
|
public function setName($name)
|
||||||
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getId() {
|
public function getId()
|
||||||
|
{
|
||||||
return intval($this->id);
|
return intval($this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContent() {
|
public function getContent()
|
||||||
|
{
|
||||||
$this->content = self::decodeContent($this->content);
|
$this->content = self::decodeContent($this->content);
|
||||||
return $this->content;
|
return $this->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDomain() {
|
public function getDomain()
|
||||||
|
{
|
||||||
return $this->domain;
|
return $this->domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getIshttps() {
|
public function getIshttps()
|
||||||
|
{
|
||||||
return $this->ishttps;
|
return $this->ishttps;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLoggedType() {
|
public function getLoggedType()
|
||||||
|
{
|
||||||
return $this->loggedType;
|
return $this->loggedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUser_location() {
|
public function getUser_location()
|
||||||
|
{
|
||||||
return $this->user_location;
|
return $this->user_location;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExpires() {
|
public function getExpires()
|
||||||
|
{
|
||||||
return $this->expires;
|
return $this->expires;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimezone() {
|
public function getTimezone()
|
||||||
|
{
|
||||||
return $this->timezone;
|
return $this->timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function _getCache($name, $domain, $ishttps, $user_location, $loggedType) {
|
public static function _getCache($name, $domain, $ishttps, $user_location, $loggedType)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE ishttps = ? AND loggedType = ? AND name = ? AND domain = ? AND user_location = ? LIMIT 1";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE ishttps = ? AND loggedType = ? AND name = ? AND domain = ? AND user_location = ? LIMIT 1";
|
||||||
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
|
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
|
||||||
$res = sqlDAL::readSql($sql, "issss", array($ishttps, $loggedType, $name, $domain, $user_location), true);
|
$res = sqlDAL::readSql($sql, "issss", [$ishttps, $loggedType, $name, $domain, $user_location], true);
|
||||||
$data = sqlDAL::fetchAssoc($res);
|
$data = sqlDAL::fetchAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
if ($res) {
|
if ($res) {
|
||||||
if(!empty($data) && !empty($data['content'])){
|
if (!empty($data) && !empty($data['content'])) {
|
||||||
$data['content'] = self::decodeContent($data['content']);
|
$data['content'] = self::decodeContent($data['content']);
|
||||||
}
|
}
|
||||||
$row = $data;
|
$row = $data;
|
||||||
|
@ -110,11 +139,12 @@ class CachesInDB extends ObjectYPT {
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function _setCache($name, $value, $domain, $ishttps, $user_location, $loggedType) {
|
public static function _setCache($name, $value, $domain, $ishttps, $user_location, $loggedType)
|
||||||
if(!is_string($value)){
|
{
|
||||||
|
if (!is_string($value)) {
|
||||||
$value = _json_encode($value);
|
$value = _json_encode($value);
|
||||||
}
|
}
|
||||||
if(empty($value)){
|
if (empty($value)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,21 +164,23 @@ class CachesInDB extends ObjectYPT {
|
||||||
return $c->save();
|
return $c->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function _deleteCache($name) {
|
public static function _deleteCache($name)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if(empty($name)){
|
if (empty($name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$sql = "DELETE FROM " . static::getTableName() . " ";
|
$sql = "DELETE FROM " . static::getTableName() . " ";
|
||||||
$sql .= " WHERE name = ?";
|
$sql .= " WHERE name = ?";
|
||||||
$global['lastQuery'] = $sql;
|
$global['lastQuery'] = $sql;
|
||||||
//_error_log("Delete Query: ".$sql);
|
//_error_log("Delete Query: ".$sql);
|
||||||
return sqlDAL::writeSql($sql, "s", array($name));
|
return sqlDAL::writeSql($sql, "s", [$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function _deleteCacheStartingWith($name) {
|
public static function _deleteCacheStartingWith($name)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if(empty($name)){
|
if (empty($name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$sql = "DELETE FROM " . static::getTableName() . " ";
|
$sql = "DELETE FROM " . static::getTableName() . " ";
|
||||||
|
@ -158,7 +190,8 @@ class CachesInDB extends ObjectYPT {
|
||||||
return sqlDAL::writeSql($sql);
|
return sqlDAL::writeSql($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function _deleteAllCache() {
|
public static function _deleteAllCache()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "TRUNCATE TABLE " . static::getTableName() . " ";
|
$sql = "TRUNCATE TABLE " . static::getTableName() . " ";
|
||||||
$global['lastQuery'] = $sql;
|
$global['lastQuery'] = $sql;
|
||||||
|
@ -166,25 +199,26 @@ class CachesInDB extends ObjectYPT {
|
||||||
return sqlDAL::writeSql($sql);
|
return sqlDAL::writeSql($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function encodeContent($content){
|
public static function encodeContent($content)
|
||||||
if(!is_string($content)){
|
{
|
||||||
|
if (!is_string($content)) {
|
||||||
$content = _json_encode($content);
|
$content = _json_encode($content);
|
||||||
}
|
}
|
||||||
$prefix = substr($content, 0, 10);
|
$prefix = substr($content, 0, 10);
|
||||||
if($prefix!== CachesInDB::$prefix){
|
if ($prefix!== CachesInDB::$prefix) {
|
||||||
$base64 = base64_encode($content);
|
$base64 = base64_encode($content);
|
||||||
$content = CachesInDB::$prefix.$base64;
|
$content = CachesInDB::$prefix.$base64;
|
||||||
}
|
}
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function decodeContent($content){
|
public static function decodeContent($content)
|
||||||
|
{
|
||||||
$prefix = substr($content, 0, 10);
|
$prefix = substr($content, 0, 10);
|
||||||
if($prefix === CachesInDB::$prefix){
|
if ($prefix === CachesInDB::$prefix) {
|
||||||
$content = str_replace(CachesInDB::$prefix, '', $content);
|
$content = str_replace(CachesInDB::$prefix, '', $content);
|
||||||
$content = base64_decode($content);
|
$content = base64_decode($content);
|
||||||
}
|
}
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ $daysLimit = 3;
|
||||||
|
|
||||||
// delete object cache
|
// delete object cache
|
||||||
$cacheDir = ObjectYPT::getCacheDir();
|
$cacheDir = ObjectYPT::getCacheDir();
|
||||||
if(empty($cacheDir) || !preg_match('/YPTObjectCache/', $cacheDir)){
|
if (empty($cacheDir) || !preg_match('/YPTObjectCache/', $cacheDir)) {
|
||||||
die('Wrong dir: '.$cacheDir);
|
die('Wrong dir: '.$cacheDir);
|
||||||
}
|
}
|
||||||
_error_log('crontab.php: '.json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)));
|
_error_log('crontab.php: '.json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)));
|
||||||
|
@ -22,7 +22,7 @@ exec($cmd);
|
||||||
|
|
||||||
//delete site cache
|
//delete site cache
|
||||||
$cacheDir = getCacheDir();
|
$cacheDir = getCacheDir();
|
||||||
if(empty($cacheDir) || !preg_match('/cache/', $cacheDir)){
|
if (empty($cacheDir) || !preg_match('/cache/', $cacheDir)) {
|
||||||
die('Wrong dir: '.$cacheDir);
|
die('Wrong dir: '.$cacheDir);
|
||||||
}
|
}
|
||||||
echo "deleting {$cacheDir}".PHP_EOL;
|
echo "deleting {$cacheDir}".PHP_EOL;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
require_once '../../videos/configuration.php';
|
require_once '../../videos/configuration.php';
|
||||||
|
|
||||||
|
@ -18,7 +17,7 @@ require_once $global['systemRootPath'] . 'objects/video_statistic.php';
|
||||||
$objC = AVideoPlugin::getDataObject('Cache');
|
$objC = AVideoPlugin::getDataObject('Cache');
|
||||||
|
|
||||||
$days = $objC->deleteStatisticsDaysOld;
|
$days = $objC->deleteStatisticsDaysOld;
|
||||||
if(empty($days)){
|
if (empty($days)) {
|
||||||
$days = 180;
|
$days = 180;
|
||||||
}
|
}
|
||||||
$obj->before = VideoStatistic::getTotalStatisticsRecords();
|
$obj->before = VideoStatistic::getTotalStatisticsRecords();
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
class CloneLog
|
||||||
class CloneLog{
|
{
|
||||||
public $file;
|
public $file;
|
||||||
|
|
||||||
function __construct() {
|
public function __construct()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$clonesDir = Video::getStoragePath()."cache/clones/";
|
$clonesDir = Video::getStoragePath()."cache/clones/";
|
||||||
$this->file = "{$clonesDir}client.log";
|
$this->file = "{$clonesDir}client.log";
|
||||||
|
@ -14,8 +15,9 @@ class CloneLog{
|
||||||
file_put_contents($this->file, "");
|
file_put_contents($this->file, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function add($message){
|
public function add($message)
|
||||||
|
{
|
||||||
_error_log($message);
|
_error_log($message);
|
||||||
file_put_contents($this->file, $message.PHP_EOL , FILE_APPEND | LOCK_EX);
|
file_put_contents($this->file, $message.PHP_EOL, FILE_APPEND | LOCK_EX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,49 +3,55 @@ global $global;
|
||||||
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/CloneSite/functions.php';
|
require_once $global['systemRootPath'] . 'plugin/CloneSite/functions.php';
|
||||||
|
|
||||||
class CloneSite extends PluginAbstract {
|
class CloneSite extends PluginAbstract
|
||||||
|
{
|
||||||
|
public function getTags()
|
||||||
public function getTags() {
|
{
|
||||||
return array(
|
return [
|
||||||
PluginTags::$SECURITY,
|
PluginTags::$SECURITY,
|
||||||
PluginTags::$FREE
|
PluginTags::$FREE,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
public function getDescription() {
|
public function getDescription()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
$txt = "Clone and Backup AVideo Sites";
|
$txt = "Clone and Backup AVideo Sites";
|
||||||
$txt .= "<br>Crontab every day at 1am:<br><code>0 1 * * * php {$global['systemRootPath']}plugin/CloneSite/cloneClient.json.php {$obj->myKey}</code>";
|
$txt .= "<br>Crontab every day at 1am:<br><code>0 1 * * * php {$global['systemRootPath']}plugin/CloneSite/cloneClient.json.php {$obj->myKey}</code>";
|
||||||
if(!isRsync()){
|
if (!isRsync()) {
|
||||||
$txt .= "<div class='alert alert-danger'>To use rsync feature you must install it <code>sudo apt-get install rsync</code></div>";
|
$txt .= "<div class='alert alert-danger'>To use rsync feature you must install it <code>sudo apt-get install rsync</code></div>";
|
||||||
}
|
}
|
||||||
if(!isSshpass()){
|
if (!isSshpass()) {
|
||||||
$txt .= "<div class='alert alert-danger'>To use rsync feature you must install sshpass <code>sudo apt-get install sshpass</code></div>";
|
$txt .= "<div class='alert alert-danger'>To use rsync feature you must install sshpass <code>sudo apt-get install sshpass</code></div>";
|
||||||
}
|
}
|
||||||
$help = "<br><small><a href='https://github.com/WWBN/AVideo/wiki/Clone-Site-Plugin' target='__blank'><i class='fas fa-question-circle'></i> Help</a></small>";
|
$help = "<br><small><a href='https://github.com/WWBN/AVideo/wiki/Clone-Site-Plugin' target='__blank'><i class='fas fa-question-circle'></i> Help</a></small>";
|
||||||
return $txt . $help;
|
return $txt . $help;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return "CloneSite";
|
return "CloneSite";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUUID() {
|
public function getUUID()
|
||||||
|
{
|
||||||
return "c0731de9-b4f7-4462-bda6-458b0736593d";
|
return "c0731de9-b4f7-4462-bda6-458b0736593d";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginVersion() {
|
public function getPluginVersion()
|
||||||
|
{
|
||||||
return "1.1";
|
return "1.1";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginMenu() {
|
public function getPluginMenu()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$filename = $global['systemRootPath'] . 'plugin/CloneSite/pluginMenu.html';
|
$filename = $global['systemRootPath'] . 'plugin/CloneSite/pluginMenu.html';
|
||||||
return file_get_contents($filename);
|
return file_get_contents($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmptyDataObject() {
|
public function getEmptyDataObject()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->cloneSiteURL = "";
|
$obj->cloneSiteURL = "";
|
||||||
|
@ -63,20 +69,21 @@ class CloneSite extends PluginAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getStart() {
|
public function getStart()
|
||||||
|
{
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
if($obj->MaintenanceMode){
|
if ($obj->MaintenanceMode) {
|
||||||
$m = AVideoPlugin::loadPlugin("MaintenanceMode");
|
$m = AVideoPlugin::loadPlugin("MaintenanceMode");
|
||||||
$m->getStart();
|
$m->getStart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFooterCode() {
|
public function getFooterCode()
|
||||||
|
{
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
if($obj->MaintenanceMode){
|
if ($obj->MaintenanceMode) {
|
||||||
$m = AVideoPlugin::loadPlugin("MaintenanceMode");
|
$m = AVideoPlugin::loadPlugin("MaintenanceMode");
|
||||||
$m->getFooterCode();
|
$m->getFooterCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,22 +3,29 @@
|
||||||
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
require_once dirname(__FILE__) . '/../../../objects/user.php';
|
require_once dirname(__FILE__) . '/../../../objects/user.php';
|
||||||
|
|
||||||
class Clones extends ObjectYPT {
|
class Clones extends ObjectYPT
|
||||||
|
{
|
||||||
|
protected $id;
|
||||||
|
protected $url;
|
||||||
|
protected $status;
|
||||||
|
protected $key;
|
||||||
|
protected $last_clone_request;
|
||||||
|
|
||||||
protected $id, $url, $status, $key, $last_clone_request;
|
public static function getSearchFieldsNames()
|
||||||
|
{
|
||||||
static function getSearchFieldsNames() {
|
return ['url'];
|
||||||
return array('url');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTableName() {
|
public static function getTableName()
|
||||||
|
{
|
||||||
return 'clone_SitesAllowed';
|
return 'clone_SitesAllowed';
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getFromURL($url){
|
public static function getFromURL($url)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE url = ? LIMIT 1";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE url = ? LIMIT 1";
|
||||||
$res = sqlDAL::readSql($sql,"s",array($url));
|
$res = sqlDAL::readSql($sql, "s", [$url]);
|
||||||
$data = sqlDAL::fetchAssoc($res);
|
$data = sqlDAL::fetchAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
if ($res) {
|
if ($res) {
|
||||||
|
@ -29,7 +36,8 @@ class Clones extends ObjectYPT {
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLastCloneRequest() {
|
public function updateLastCloneRequest()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (!empty($this->id)) {
|
if (!empty($this->id)) {
|
||||||
$sql = "UPDATE " . static::getTableName() . " SET last_clone_request = now() ";
|
$sql = "UPDATE " . static::getTableName() . " SET last_clone_request = now() ";
|
||||||
|
@ -47,17 +55,20 @@ class Clones extends ObjectYPT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFromURL($url) {
|
public function loadFromURL($url)
|
||||||
|
{
|
||||||
$row = self::getFromURL($url);
|
$row = self::getFromURL($url);
|
||||||
if (empty($row))
|
if (empty($row)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
foreach ($row as $key => $value) {
|
foreach ($row as $key => $value) {
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function thisURLCanCloneMe($url, $key){
|
public static function thisURLCanCloneMe($url, $key)
|
||||||
|
{
|
||||||
$resp = new stdClass();
|
$resp = new stdClass();
|
||||||
$resp->canClone = false;
|
$resp->canClone = false;
|
||||||
$resp->clone = null;
|
$resp->clone = null;
|
||||||
|
@ -65,16 +76,16 @@ class Clones extends ObjectYPT {
|
||||||
|
|
||||||
$clone = new Clones(0);
|
$clone = new Clones(0);
|
||||||
$clone->loadFromURL($url);
|
$clone->loadFromURL($url);
|
||||||
if(empty($clone->getId())){
|
if (empty($clone->getId())) {
|
||||||
$resp->msg = "The URL {$url} was just added in our server, ask the Server Manager to approve this URL on plugins->Clone Site->Clones Manager (The Blue Button) and Activate your client";
|
$resp->msg = "The URL {$url} was just added in our server, ask the Server Manager to approve this URL on plugins->Clone Site->Clones Manager (The Blue Button) and Activate your client";
|
||||||
self::addURL($url, $key);
|
self::addURL($url, $key);
|
||||||
return $resp;
|
return $resp;
|
||||||
}
|
}
|
||||||
if($clone->getKey() !== $key){
|
if ($clone->getKey() !== $key) {
|
||||||
$resp->msg = "Invalid Key";
|
$resp->msg = "Invalid Key";
|
||||||
return $resp;
|
return $resp;
|
||||||
}
|
}
|
||||||
if($clone->getStatus() !== 'a'){
|
if ($clone->getStatus() !== 'a') {
|
||||||
$resp->msg = "The URL {$url} is inactive in our Clone Server";
|
$resp->msg = "The URL {$url} is inactive in our Clone Server";
|
||||||
return $resp;
|
return $resp;
|
||||||
}
|
}
|
||||||
|
@ -83,10 +94,11 @@ class Clones extends ObjectYPT {
|
||||||
return $resp;
|
return $resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function addURL($url, $key){
|
public static function addURL($url, $key)
|
||||||
|
{
|
||||||
$clone = new Clones(0);
|
$clone = new Clones(0);
|
||||||
$clone->loadFromURL($url);
|
$clone->loadFromURL($url);
|
||||||
if(empty($clone->getId())){
|
if (empty($clone->getId())) {
|
||||||
$clone->setUrl($url);
|
$clone->setUrl($url);
|
||||||
$clone->setKey($key);
|
$clone->setKey($key);
|
||||||
return $clone->save();
|
return $clone->save();
|
||||||
|
@ -94,67 +106,77 @@ class Clones extends ObjectYPT {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
public function save()
|
||||||
if(empty($this->status)){
|
{
|
||||||
|
if (empty($this->status)) {
|
||||||
$this->status = 'i';
|
$this->status = 'i';
|
||||||
}
|
}
|
||||||
if(empty($this->last_clone_request)){
|
if (empty($this->last_clone_request)) {
|
||||||
$this->last_clone_request = 'null';
|
$this->last_clone_request = 'null';
|
||||||
}
|
}
|
||||||
return parent::save();
|
return parent::save();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getId() {
|
public function getId()
|
||||||
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUrl() {
|
public function getUrl()
|
||||||
|
{
|
||||||
return $this->url;
|
return $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatus() {
|
public function getStatus()
|
||||||
|
{
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getKey() {
|
public function getKey()
|
||||||
|
{
|
||||||
return $this->key;
|
return $this->key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLast_clone_request() {
|
public function getLast_clone_request()
|
||||||
|
{
|
||||||
return $this->last_clone_request;
|
return $this->last_clone_request;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setId($id) {
|
public function setId($id)
|
||||||
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUrl($url) {
|
public function setUrl($url)
|
||||||
|
{
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStatus($status) {
|
public function setStatus($status)
|
||||||
|
{
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setKey($key) {
|
public function setKey($key)
|
||||||
|
{
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLast_clone_request($last_clone_request) {
|
public function setLast_clone_request($last_clone_request)
|
||||||
|
{
|
||||||
$this->last_clone_request = $last_clone_request;
|
$this->last_clone_request = $last_clone_request;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toogleStatus(){
|
public function toogleStatus()
|
||||||
if(empty($this->id)){
|
{
|
||||||
|
if (empty($this->id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if($this->status==='i'){
|
if ($this->status==='i') {
|
||||||
$this->status='a';
|
$this->status='a';
|
||||||
}else{
|
} else {
|
||||||
$this->status='i';
|
$this->status='i';
|
||||||
}
|
}
|
||||||
return $this->save();
|
return $this->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,14 @@ $obj = new stdClass();
|
||||||
$obj->error = true;
|
$obj->error = true;
|
||||||
$obj->msg = "";
|
$obj->msg = "";
|
||||||
|
|
||||||
if(!User::isAdmin()){
|
if (!User::isAdmin()) {
|
||||||
$obj->msg = "You can't do this";
|
$obj->msg = "You can't do this";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
$o = new Clones($_POST['id']);
|
$o = new Clones($_POST['id']);
|
||||||
|
|
||||||
if($o->toogleStatus()){
|
if ($o->toogleStatus()) {
|
||||||
$obj->error = false;
|
$obj->error = false;
|
||||||
}
|
}
|
||||||
echo json_encode($obj);
|
echo json_encode($obj);
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$time_start = microtime(true);
|
$time_start = microtime(true);
|
||||||
$config = '../../videos/configuration.php';
|
$config = '../../videos/configuration.php';
|
||||||
session_write_close();
|
session_write_close();
|
||||||
if (!file_exists($config)) {
|
if (!file_exists($config)) {
|
||||||
list($scriptPath) = get_included_files();
|
[$scriptPath] = get_included_files();
|
||||||
$path = pathinfo($scriptPath);
|
$path = pathinfo($scriptPath);
|
||||||
$config = $path['dirname'] . "/" . $config;
|
$config = $path['dirname'] . "/" . $config;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +40,7 @@ if (empty($objClone->cloneSiteURL)) {
|
||||||
die(json_encode($resp));
|
die(json_encode($resp));
|
||||||
}
|
}
|
||||||
|
|
||||||
$objClone->cloneSiteURL = rtrim($objClone->cloneSiteURL,"/").'/';
|
$objClone->cloneSiteURL = rtrim($objClone->cloneSiteURL, "/").'/';
|
||||||
$objCloneOriginal = $objClone;
|
$objCloneOriginal = $objClone;
|
||||||
$argv[1] = preg_replace("/[^A-Za-z0-9 ]/", '', @$argv[1]);
|
$argv[1] = preg_replace("/[^A-Za-z0-9 ]/", '', @$argv[1]);
|
||||||
|
|
||||||
|
@ -160,7 +159,7 @@ if (empty($objClone->useRsync)) {
|
||||||
// decrypt the password now
|
// decrypt the password now
|
||||||
$objClone = Plugin::decryptIfNeed($objClone);
|
$objClone = Plugin::decryptIfNeed($objClone);
|
||||||
$port = intval($objClone->cloneSiteSSHPort);
|
$port = intval($objClone->cloneSiteSSHPort);
|
||||||
if(empty($port)){
|
if (empty($port)) {
|
||||||
$port = 22;
|
$port = 22;
|
||||||
}
|
}
|
||||||
$rsync = "sshpass -p '{password}' rsync -av -e 'ssh -p {$port} -o StrictHostKeyChecking=no' --exclude '*.php' --exclude 'cache' --exclude '*.sql' --exclude '*.log' {$objClone->cloneSiteSSHUser}@{$objClone->cloneSiteSSHIP}:{$json->videosDir} ". Video::getStoragePath()." --log-file='{$log->file}' ";
|
$rsync = "sshpass -p '{password}' rsync -av -e 'ssh -p {$port} -o StrictHostKeyChecking=no' --exclude '*.php' --exclude 'cache' --exclude '*.sql' --exclude '*.log' {$objClone->cloneSiteSSHUser}@{$objClone->cloneSiteSSHIP}:{$json->videosDir} ". Video::getStoragePath()." --log-file='{$log->file}' ";
|
||||||
|
@ -193,7 +192,7 @@ $log->add("Clone (7 of {$totalSteps}): Resotre the Clone Configuration");
|
||||||
$plugin = new CloneSite();
|
$plugin = new CloneSite();
|
||||||
$p = new Plugin(0);
|
$p = new Plugin(0);
|
||||||
$p->loadFromUUID($plugin->getUUID());
|
$p->loadFromUUID($plugin->getUUID());
|
||||||
$p->setObject_data(addcslashes(json_encode($objCloneOriginal),'\\'));
|
$p->setObject_data(addcslashes(json_encode($objCloneOriginal), '\\'));
|
||||||
$p->setStatus('active');
|
$p->setStatus('active');
|
||||||
$p->save();
|
$p->save();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../../videos/configuration.php';
|
require_once '../../videos/configuration.php';
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
session_write_close();
|
session_write_close();
|
||||||
|
@ -19,29 +18,29 @@ $resp->key = $_GET['key'];
|
||||||
$resp->useRsync = intval($_GET['useRsync']);
|
$resp->useRsync = intval($_GET['useRsync']);
|
||||||
$resp->videosDir = Video::getStoragePath()."";
|
$resp->videosDir = Video::getStoragePath()."";
|
||||||
$resp->sqlFile = "";
|
$resp->sqlFile = "";
|
||||||
$resp->videoFiles = array();
|
$resp->videoFiles = [];
|
||||||
$resp->photoFiles = array();
|
$resp->photoFiles = [];
|
||||||
|
|
||||||
$objClone = AVideoPlugin::getObjectDataIfEnabled("CloneSite");
|
$objClone = AVideoPlugin::getObjectDataIfEnabled("CloneSite");
|
||||||
if(empty($objClone)){
|
if (empty($objClone)) {
|
||||||
$resp->msg = "CloneSite is not enabled on the Master site";
|
$resp->msg = "CloneSite is not enabled on the Master site";
|
||||||
die(json_encode($resp));
|
die(json_encode($resp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(empty($resp->key)){
|
if (empty($resp->key)) {
|
||||||
$resp->msg = "Key cannot be blank";
|
$resp->msg = "Key cannot be blank";
|
||||||
die(json_encode($resp));
|
die(json_encode($resp));
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the url is allowed to clone it
|
// check if the url is allowed to clone it
|
||||||
$canClone = Clones::thisURLCanCloneMe($resp->url, $resp->key);
|
$canClone = Clones::thisURLCanCloneMe($resp->url, $resp->key);
|
||||||
if(empty($canClone->canClone)){
|
if (empty($canClone->canClone)) {
|
||||||
$resp->msg = $canClone->msg;
|
$resp->msg = $canClone->msg;
|
||||||
die(json_encode($resp));
|
die(json_encode($resp));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($_GET['deleteDump'])){
|
if (!empty($_GET['deleteDump'])) {
|
||||||
$resp->error = !unlink("{$clonesDir}{$_GET['deleteDump']}");
|
$resp->error = !unlink("{$clonesDir}{$_GET['deleteDump']}");
|
||||||
$resp->msg = "Delete Dump {$_GET['deleteDump']}";
|
$resp->msg = "Delete Dump {$_GET['deleteDump']}";
|
||||||
die(json_encode($resp));
|
die(json_encode($resp));
|
||||||
|
@ -64,7 +63,7 @@ if ($return_val !== 0) {
|
||||||
_error_log("Clone Error: ". print_r($output, true));
|
_error_log("Clone Error: ". print_r($output, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($resp->useRsync)){
|
if (empty($resp->useRsync)) {
|
||||||
$resp->videoFiles = getCloneFilesInfo($videosDir);
|
$resp->videoFiles = getCloneFilesInfo($videosDir);
|
||||||
$resp->photoFiles = getCloneFilesInfo($photosDir, "userPhoto/");
|
$resp->photoFiles = getCloneFilesInfo($photosDir, "userPhoto/");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,14 @@ $obj->error = true;
|
||||||
|
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled('CloneSite');
|
$plugin = AVideoPlugin::loadPluginIfEnabled('CloneSite');
|
||||||
|
|
||||||
if(!User::isAdmin()){
|
if (!User::isAdmin()) {
|
||||||
$obj->msg = "You can't do this";
|
$obj->msg = "You can't do this";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = intval($_POST['id']);
|
$id = intval($_POST['id']);
|
||||||
$row = new Clones($id);
|
$row = new Clones($id);
|
||||||
if(User::isAdmin()){
|
if (User::isAdmin()) {
|
||||||
$row->delete();
|
$row->delete();
|
||||||
$obj->error = false;
|
$obj->error = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
function getCloneFilesInfo($dir, $subdir = "", $extensionsToCopy = ['mp4', 'webm', 'gif', 'jpg', 'png'])
|
||||||
function getCloneFilesInfo($dir, $subdir = "", $extensionsToCopy = array('mp4', 'webm', 'gif', 'jpg', 'png')) {
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$files = array();
|
$files = [];
|
||||||
// get video files
|
// get video files
|
||||||
if ($handle = opendir($dir)) {
|
if ($handle = opendir($dir)) {
|
||||||
while (false !== ($entry = readdir($handle))) {
|
while (false !== ($entry = readdir($handle))) {
|
||||||
|
@ -31,14 +31,15 @@ function getCloneFilesInfo($dir, $subdir = "", $extensionsToCopy = array('mp4',
|
||||||
* @param type $clientArray a Json with the client files retrieve from getCloneFilesInfo function
|
* @param type $clientArray a Json with the client files retrieve from getCloneFilesInfo function
|
||||||
* @return type a Json with the new files
|
* @return type a Json with the new files
|
||||||
*/
|
*/
|
||||||
function detectNewFiles($serverArray, $clientArray){
|
function detectNewFiles($serverArray, $clientArray)
|
||||||
|
{
|
||||||
foreach ($serverArray as $key => $value) {
|
foreach ($serverArray as $key => $value) {
|
||||||
foreach ($clientArray as $key2 => $value2) {
|
foreach ($clientArray as $key2 => $value2) {
|
||||||
if(
|
if (
|
||||||
$value->filename===$value2->filename &&
|
$value->filename===$value2->filename &&
|
||||||
$value->filesize===$value2->filesize &&
|
$value->filesize===$value2->filesize &&
|
||||||
$value->filemtime<=$value2->filemtime
|
$value->filemtime<=$value2->filemtime
|
||||||
){
|
) {
|
||||||
unset($serverArray[$key]);
|
unset($serverArray[$key]);
|
||||||
unset($clientArray[$key2]);
|
unset($clientArray[$key2]);
|
||||||
}
|
}
|
||||||
|
@ -48,9 +49,11 @@ function detectNewFiles($serverArray, $clientArray){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function isRsync() {
|
function isRsync()
|
||||||
|
{
|
||||||
return trim(shell_exec('which rsync'));
|
return trim(shell_exec('which rsync'));
|
||||||
}
|
}
|
||||||
function isSshpass() {
|
function isSshpass()
|
||||||
|
{
|
||||||
return trim(shell_exec('which sshpass'));
|
return trim(shell_exec('which sshpass'));
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@ if (!User::isAdmin()) {
|
||||||
<html lang="<?php echo $_SESSION['language']; ?>">
|
<html lang="<?php echo $_SESSION['language']; ?>">
|
||||||
<head>
|
<head>
|
||||||
<?php
|
<?php
|
||||||
echo getHTMLTitle( __("Clone Site"));
|
echo getHTMLTitle(__("Clone Site"));
|
||||||
?>
|
?>
|
||||||
<?php
|
<?php
|
||||||
include $global['systemRootPath'] . 'view/include/head.php';
|
include $global['systemRootPath'] . 'view/include/head.php';
|
||||||
|
|
|
@ -1,40 +1,46 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
global $global;
|
global $global;
|
||||||
if (empty($global['systemRootPath'])) {
|
if (empty($global['systemRootPath'])) {
|
||||||
require_once '../../videos/configuration.php';
|
require_once '../../videos/configuration.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Categories_has_users_groups.php';
|
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Categories_has_users_groups.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_extra_info.php';
|
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_extra_info.php';
|
||||||
|
|
||||||
class CustomizeUser extends PluginAbstract {
|
class CustomizeUser extends PluginAbstract
|
||||||
|
{
|
||||||
public function getTags() {
|
public function getTags()
|
||||||
return array(
|
{
|
||||||
|
return [
|
||||||
PluginTags::$RECOMMENDED,
|
PluginTags::$RECOMMENDED,
|
||||||
PluginTags::$FREE
|
PluginTags::$FREE,
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDescription() {
|
public function getDescription()
|
||||||
|
{
|
||||||
$txt = "Fine Tuning User Profile";
|
$txt = "Fine Tuning User Profile";
|
||||||
return $txt;
|
return $txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return "CustomizeUser";
|
return "CustomizeUser";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUUID() {
|
public function getUUID()
|
||||||
|
{
|
||||||
return "55a4fa56-8a30-48d4-a0fb-8aa6b3fuser3";
|
return "55a4fa56-8a30-48d4-a0fb-8aa6b3fuser3";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginVersion() {
|
public function getPluginVersion()
|
||||||
|
{
|
||||||
return "3.0";
|
return "3.0";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmptyDataObject() {
|
public function getEmptyDataObject()
|
||||||
|
{
|
||||||
global $advancedCustom;
|
global $advancedCustom;
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->nonAdminCannotDownload = false;
|
$obj->nonAdminCannotDownload = false;
|
||||||
|
@ -51,7 +57,7 @@ class CustomizeUser extends PluginAbstract {
|
||||||
$obj->userCanNotChangeUserGroup = false;
|
$obj->userCanNotChangeUserGroup = false;
|
||||||
|
|
||||||
$o = new stdClass();
|
$o = new stdClass();
|
||||||
$o->type = array(0 => __("Default")) + UserGroups::getAllUsersGroupsArray();
|
$o->type = [0 => __("Default")] + UserGroups::getAllUsersGroupsArray();
|
||||||
$o->value = 0;
|
$o->value = 0;
|
||||||
$obj->userDefaultUserGroup = $o;
|
$obj->userDefaultUserGroup = $o;
|
||||||
$obj->userMustBeLoggedIn = !isset($advancedCustom->userMustBeLoggedIn) ? false : $advancedCustom->userMustBeLoggedIn;
|
$obj->userMustBeLoggedIn = !isset($advancedCustom->userMustBeLoggedIn) ? false : $advancedCustom->userMustBeLoggedIn;
|
||||||
|
@ -89,7 +95,7 @@ class CustomizeUser extends PluginAbstract {
|
||||||
|
|
||||||
|
|
||||||
$o = new stdClass();
|
$o = new stdClass();
|
||||||
$o->type = array(0 => '-- ' . __("None"), 1 => '-- ' . __("Random")) + self::getBGAnimationArray();
|
$o->type = [0 => '-- ' . __("None"), 1 => '-- ' . __("Random")] + self::getBGAnimationArray();
|
||||||
$o->value = 1;
|
$o->value = 1;
|
||||||
$obj->loginBackgroundAnimation = $o;
|
$obj->loginBackgroundAnimation = $o;
|
||||||
|
|
||||||
|
@ -153,16 +159,18 @@ class CustomizeUser extends PluginAbstract {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function autoIncludeBGAnimationFile() {
|
public static function autoIncludeBGAnimationFile()
|
||||||
|
{
|
||||||
$baseName = basename($_SERVER["SCRIPT_FILENAME"]);
|
$baseName = basename($_SERVER["SCRIPT_FILENAME"]);
|
||||||
$obj = AVideoPlugin::getObjectData('CustomizeUser');
|
$obj = AVideoPlugin::getObjectData('CustomizeUser');
|
||||||
Layout::includeBGAnimationFile($obj->loginBackgroundAnimation->value);
|
Layout::includeBGAnimationFile($obj->loginBackgroundAnimation->value);
|
||||||
//Layout::includeBGAnimationFile('Animated3');
|
//Layout::includeBGAnimationFile('Animated3');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserOptions() {
|
public function getUserOptions()
|
||||||
|
{
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
$userOptions = array();
|
$userOptions = [];
|
||||||
if ($obj->Checkmark1Enabled) {
|
if ($obj->Checkmark1Enabled) {
|
||||||
$userOptions["Checkmark 1"] = "checkmark1";
|
$userOptions["Checkmark 1"] = "checkmark1";
|
||||||
}
|
}
|
||||||
|
@ -175,19 +183,21 @@ class CustomizeUser extends PluginAbstract {
|
||||||
return $userOptions;
|
return $userOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getBGAnimationArray() {
|
public static function getBGAnimationArray()
|
||||||
|
{
|
||||||
if (!class_exists('Layout')) {
|
if (!class_exists('Layout')) {
|
||||||
$avideoLayout = AVideoPlugin::getObjectData('Layout');
|
$avideoLayout = AVideoPlugin::getObjectData('Layout');
|
||||||
}
|
}
|
||||||
$files = Layout::getBGAnimationFiles();
|
$files = Layout::getBGAnimationFiles();
|
||||||
$response = array();
|
$response = [];
|
||||||
foreach ($files as $key => $value) {
|
foreach ($files as $key => $value) {
|
||||||
$response[$value['name']] = ucfirst($value['name']);
|
$response[$value['name']] = ucfirst($value['name']);
|
||||||
}
|
}
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function canDownloadVideosFromUser($users_id) {
|
public static function canDownloadVideosFromUser($users_id)
|
||||||
|
{
|
||||||
global $config;
|
global $config;
|
||||||
$obj = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser");
|
$obj = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser");
|
||||||
if (!empty($obj->nonAdminCannotDownload) && !User::isAdmin()) {
|
if (!empty($obj->nonAdminCannotDownload) && !User::isAdmin()) {
|
||||||
|
@ -200,7 +210,8 @@ class CustomizeUser extends PluginAbstract {
|
||||||
return !empty($user->getExternalOption('userCanAllowFilesDownload'));
|
return !empty($user->getExternalOption('userCanAllowFilesDownload'));
|
||||||
}
|
}
|
||||||
|
|
||||||
static function canDownloadVideos() {
|
public static function canDownloadVideos()
|
||||||
|
{
|
||||||
global $config;
|
global $config;
|
||||||
$obj = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser");
|
$obj = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser");
|
||||||
if (!empty($obj->nonAdminCannotDownload) && !User::isAdmin()) {
|
if (!empty($obj->nonAdminCannotDownload) && !User::isAdmin()) {
|
||||||
|
@ -209,7 +220,8 @@ class CustomizeUser extends PluginAbstract {
|
||||||
return !empty($config->getAllow_download());
|
return !empty($config->getAllow_download());
|
||||||
}
|
}
|
||||||
|
|
||||||
static function setCanDownloadVideosFromUser($users_id, $value = true) {
|
public static function setCanDownloadVideosFromUser($users_id, $value = true)
|
||||||
|
{
|
||||||
$obj = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser");
|
$obj = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser");
|
||||||
if (empty($obj) || empty($obj->userCanAllowFilesDownload)) {
|
if (empty($obj) || empty($obj->userCanAllowFilesDownload)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -218,7 +230,8 @@ class CustomizeUser extends PluginAbstract {
|
||||||
return $user->addExternalOptions('userCanAllowFilesDownload', $value);
|
return $user->addExternalOptions('userCanAllowFilesDownload', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function canShareVideosFromUser($users_id) {
|
public static function canShareVideosFromUser($users_id)
|
||||||
|
{
|
||||||
global $advancedCustom;
|
global $advancedCustom;
|
||||||
|
|
||||||
if (!empty($advancedCustom->disableShareOnly)) {
|
if (!empty($advancedCustom->disableShareOnly)) {
|
||||||
|
@ -239,7 +252,8 @@ class CustomizeUser extends PluginAbstract {
|
||||||
return !empty($user->getExternalOption('userCanAllowFilesShare'));
|
return !empty($user->getExternalOption('userCanAllowFilesShare'));
|
||||||
}
|
}
|
||||||
|
|
||||||
static function setCanShareVideosFromUser($users_id, $value = true) {
|
public static function setCanShareVideosFromUser($users_id, $value = true)
|
||||||
|
{
|
||||||
$obj = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser");
|
$obj = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser");
|
||||||
if (empty($obj) || empty($obj->userCanAllowFilesShare)) {
|
if (empty($obj) || empty($obj->userCanAllowFilesShare)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -248,18 +262,20 @@ class CustomizeUser extends PluginAbstract {
|
||||||
return $user->addExternalOptions('userCanAllowFilesShare', $value);
|
return $user->addExternalOptions('userCanAllowFilesShare', $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getSwitchUserCanAllowFilesDownload($users_id) {
|
public static function getSwitchUserCanAllowFilesDownload($users_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
include $global['systemRootPath'] . 'plugin/CustomizeUser/switchUserCanAllowFilesDownload.php';
|
include $global['systemRootPath'] . 'plugin/CustomizeUser/switchUserCanAllowFilesDownload.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getSwitchUserCanAllowFilesShare($users_id) {
|
public static function getSwitchUserCanAllowFilesShare($users_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
include $global['systemRootPath'] . 'plugin/CustomizeUser/switchUserCanAllowFilesShare.php';
|
include $global['systemRootPath'] . 'plugin/CustomizeUser/switchUserCanAllowFilesShare.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMyAccount($users_id) {
|
public function getMyAccount($users_id)
|
||||||
|
{
|
||||||
$objcu = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser");
|
$objcu = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser");
|
||||||
|
|
||||||
if (!empty($objcu) && !empty($objcu->userCanAllowFilesDownload)) {
|
if (!empty($objcu) && !empty($objcu->userCanAllowFilesDownload)) {
|
||||||
|
@ -278,7 +294,8 @@ class CustomizeUser extends PluginAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getChannelButton() {
|
public function getChannelButton()
|
||||||
|
{
|
||||||
global $global, $isMyChannel;
|
global $global, $isMyChannel;
|
||||||
if (!$isMyChannel) {
|
if (!$isMyChannel) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -302,13 +319,15 @@ class CustomizeUser extends PluginAbstract {
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVideoManagerButton() {
|
public function getVideoManagerButton()
|
||||||
|
{
|
||||||
global $isMyChannel;
|
global $isMyChannel;
|
||||||
$isMyChannel = true;
|
$isMyChannel = true;
|
||||||
return self::getChannelButton();
|
return self::getChannelButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function canDownloadVideosFromVideo($videos_id) {
|
public static function canDownloadVideosFromVideo($videos_id)
|
||||||
|
{
|
||||||
if (!CustomizeUser::canDownloadVideos()) {
|
if (!CustomizeUser::canDownloadVideos()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -333,7 +352,8 @@ class CustomizeUser extends PluginAbstract {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function canShareVideosFromVideo($videos_id) {
|
public static function canShareVideosFromVideo($videos_id)
|
||||||
|
{
|
||||||
$video = new Video("", "", $videos_id);
|
$video = new Video("", "", $videos_id);
|
||||||
if (empty($video)) {
|
if (empty($video)) {
|
||||||
_error_log("CustomizeUser::canShareVideosFromVideo video not found");
|
_error_log("CustomizeUser::canShareVideosFromVideo video not found");
|
||||||
|
@ -354,7 +374,8 @@ class CustomizeUser extends PluginAbstract {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUserSignup($users_id) {
|
public function onUserSignup($users_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
|
|
||||||
|
@ -363,7 +384,8 @@ class CustomizeUser extends PluginAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWatchActionButton($videos_id) {
|
public function getWatchActionButton($videos_id)
|
||||||
|
{
|
||||||
global $global, $video;
|
global $global, $video;
|
||||||
if (!empty($videos_id) && empty($video)) {
|
if (!empty($videos_id) && empty($video)) {
|
||||||
$video = Video::getVideo($videos_id);
|
$video = Video::getVideo($videos_id);
|
||||||
|
@ -372,7 +394,8 @@ class CustomizeUser extends PluginAbstract {
|
||||||
include $global['systemRootPath'] . 'plugin/CustomizeUser/actionButton.php';
|
include $global['systemRootPath'] . 'plugin/CustomizeUser/actionButton.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getHTMLMenuRight() {
|
public function getHTMLMenuRight()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
if ($obj->keepViewerOnChannel) {
|
if ($obj->keepViewerOnChannel) {
|
||||||
|
@ -380,7 +403,8 @@ class CustomizeUser extends PluginAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getModeYouTube($videos_id) {
|
public function getModeYouTube($videos_id)
|
||||||
|
{
|
||||||
global $global, $config;
|
global $global, $config;
|
||||||
if (empty($videos_id)) {
|
if (empty($videos_id)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -404,7 +428,7 @@ class CustomizeUser extends PluginAbstract {
|
||||||
exit;
|
exit;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
} else if ($obj->userCanProtectVideosWithPassword) {
|
} elseif ($obj->userCanProtectVideosWithPassword) {
|
||||||
if (!$this->videoPasswordIsGood($videos_id)) {
|
if (!$this->videoPasswordIsGood($videos_id)) {
|
||||||
$video = Video::getVideoLight($videos_id);
|
$video = Video::getVideoLight($videos_id);
|
||||||
include "{$global['systemRootPath']}plugin/CustomizeUser/confirmVideoPassword.php";
|
include "{$global['systemRootPath']}plugin/CustomizeUser/confirmVideoPassword.php";
|
||||||
|
@ -413,7 +437,8 @@ class CustomizeUser extends PluginAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function videoPasswordIsGood($videos_id) {
|
public static function videoPasswordIsGood($videos_id)
|
||||||
|
{
|
||||||
$video = new Video("", "", $videos_id);
|
$video = new Video("", "", $videos_id);
|
||||||
$videoPassword = $video->getVideo_password();
|
$videoPassword = $video->getVideo_password();
|
||||||
if (empty($videoPassword)) {
|
if (empty($videoPassword)) {
|
||||||
|
@ -430,11 +455,13 @@ class CustomizeUser extends PluginAbstract {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEmbed($videos_id) {
|
public function getEmbed($videos_id)
|
||||||
|
{
|
||||||
$this->getModeYouTube($videos_id);
|
$this->getModeYouTube($videos_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getStart() {
|
public function getStart()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
$thisScriptFile = pathinfo($_SERVER["SCRIPT_FILENAME"]);
|
$thisScriptFile = pathinfo($_SERVER["SCRIPT_FILENAME"]);
|
||||||
|
@ -451,12 +478,14 @@ class CustomizeUser extends PluginAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginMenu() {
|
public function getPluginMenu()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
return '<button onclick="avideoModalIframe(webSiteRootURL +\'plugin/CustomizeUser/View/editor.php\');" class="btn btn-primary btn-sm btn-xs btn-block"><i class="fa fa-edit"></i> Edit</button>';
|
return '<button onclick="avideoModalIframe(webSiteRootURL +\'plugin/CustomizeUser/View/editor.php\');" class="btn btn-primary btn-sm btn-xs btn-block"><i class="fa fa-edit"></i> Edit</button>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function profileTabName($users_id) {
|
public static function profileTabName($users_id)
|
||||||
|
{
|
||||||
$p = AVideoPlugin::loadPlugin("CustomizeUser");
|
$p = AVideoPlugin::loadPlugin("CustomizeUser");
|
||||||
$obj = $p->getDataObject();
|
$obj = $p->getDataObject();
|
||||||
if (empty($obj->enableExtraInfo)) {
|
if (empty($obj->enableExtraInfo)) {
|
||||||
|
@ -465,7 +494,8 @@ class CustomizeUser extends PluginAbstract {
|
||||||
return '<li><a data-toggle="tab" href="#tabExtraInfo' . $p->getUUID() . '">' . __('Extra Info') . '</a></li>';
|
return '<li><a data-toggle="tab" href="#tabExtraInfo' . $p->getUUID() . '">' . __('Extra Info') . '</a></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function profileTabContent($users_id) {
|
public static function profileTabContent($users_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$p = AVideoPlugin::loadPlugin("CustomizeUser");
|
$p = AVideoPlugin::loadPlugin("CustomizeUser");
|
||||||
$obj = $p->getDataObject();
|
$obj = $p->getDataObject();
|
||||||
|
@ -477,7 +507,8 @@ class CustomizeUser extends PluginAbstract {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUsersManagerListButton() {
|
public function getUsersManagerListButton()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$p = AVideoPlugin::loadPlugin("CustomizeUser");
|
$p = AVideoPlugin::loadPlugin("CustomizeUser");
|
||||||
$obj = $p->getDataObject();
|
$obj = $p->getDataObject();
|
||||||
|
@ -495,13 +526,14 @@ class CustomizeUser extends PluginAbstract {
|
||||||
return $btn;
|
return $btn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function afterNewVideo($videos_id) {
|
public function afterNewVideo($videos_id)
|
||||||
|
{
|
||||||
$obj = $this->getDataObject();
|
$obj = $this->getDataObject();
|
||||||
if (!empty($obj->autoSaveUsersOnCategorySelectedGroups)) {
|
if (!empty($obj->autoSaveUsersOnCategorySelectedGroups)) {
|
||||||
$video = new Video("", "", $videos_id);
|
$video = new Video("", "", $videos_id);
|
||||||
$categories_id = $video->getCategories_id();
|
$categories_id = $video->getCategories_id();
|
||||||
$rows = Categories_has_users_groups::getAllFromCategory($categories_id);
|
$rows = Categories_has_users_groups::getAllFromCategory($categories_id);
|
||||||
$userGroups = array();
|
$userGroups = [];
|
||||||
foreach ($rows as $value) {
|
foreach ($rows as $value) {
|
||||||
$userGroups[] = $value['users_groups_id'];
|
$userGroups[] = $value['users_groups_id'];
|
||||||
}
|
}
|
||||||
|
@ -516,5 +548,4 @@ class CustomizeUser extends PluginAbstract {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,19 +2,25 @@
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
|
|
||||||
class Categories_has_users_groups extends ObjectYPT {
|
class Categories_has_users_groups extends ObjectYPT
|
||||||
|
{
|
||||||
|
protected $id;
|
||||||
|
protected $categories_id;
|
||||||
|
protected $users_groups_id;
|
||||||
|
protected $status;
|
||||||
|
|
||||||
protected $id,$categories_id,$users_groups_id,$status;
|
public static function getSearchFieldsNames()
|
||||||
|
{
|
||||||
static function getSearchFieldsNames() {
|
return [];
|
||||||
return array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTableName() {
|
public static function getTableName()
|
||||||
|
{
|
||||||
return 'categories_has_users_groups';
|
return 'categories_has_users_groups';
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAllCategories() {
|
public static function getAllCategories()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$table = "categories";
|
$table = "categories";
|
||||||
$sql = "SELECT * FROM {$table} WHERE 1=1 ";
|
$sql = "SELECT * FROM {$table} WHERE 1=1 ";
|
||||||
|
@ -23,7 +29,7 @@ class Categories_has_users_groups extends ObjectYPT {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
|
@ -33,7 +39,8 @@ class Categories_has_users_groups extends ObjectYPT {
|
||||||
}
|
}
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
static function getAllUsers_groups() {
|
public static function getAllUsers_groups()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$table = "users_groups";
|
$table = "users_groups";
|
||||||
$sql = "SELECT * FROM {$table} WHERE 1=1 ";
|
$sql = "SELECT * FROM {$table} WHERE 1=1 ";
|
||||||
|
@ -42,7 +49,7 @@ static function getAllUsers_groups() {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
|
@ -54,41 +61,50 @@ static function getAllUsers_groups() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function setId($id) {
|
public function setId($id)
|
||||||
|
{
|
||||||
$this->id = intval($id);
|
$this->id = intval($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCategories_id($categories_id) {
|
public function setCategories_id($categories_id)
|
||||||
|
{
|
||||||
$this->categories_id = intval($categories_id);
|
$this->categories_id = intval($categories_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUsers_groups_id($users_groups_id) {
|
public function setUsers_groups_id($users_groups_id)
|
||||||
|
{
|
||||||
$this->users_groups_id = intval($users_groups_id);
|
$this->users_groups_id = intval($users_groups_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStatus($status) {
|
public function setStatus($status)
|
||||||
|
{
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getId() {
|
public function getId()
|
||||||
|
{
|
||||||
return intval($this->id);
|
return intval($this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCategories_id() {
|
public function getCategories_id()
|
||||||
|
{
|
||||||
return intval($this->categories_id);
|
return intval($this->categories_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsers_groups_id() {
|
public function getUsers_groups_id()
|
||||||
|
{
|
||||||
return intval($this->users_groups_id);
|
return intval($this->users_groups_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatus() {
|
public function getStatus()
|
||||||
|
{
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getAll(){
|
public static function getAll()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (!static::isTableInstalled()) {
|
if (!static::isTableInstalled()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -102,7 +118,7 @@ static function getAllUsers_groups() {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
|
@ -113,13 +129,14 @@ static function getAllUsers_groups() {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllFromCategory($categories_id){
|
public static function getAllFromCategory($categories_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (!static::isTableInstalled()) {
|
if (!static::isTableInstalled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$categories_id = intval($categories_id);
|
$categories_id = intval($categories_id);
|
||||||
if(empty($categories_id)){
|
if (empty($categories_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$sql = "SELECT c.*, ug.*, cug.* FROM " . static::getTableName() . " cug "
|
$sql = "SELECT c.*, ug.*, cug.* FROM " . static::getTableName() . " cug "
|
||||||
|
@ -130,7 +147,7 @@ static function getAllUsers_groups() {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
|
@ -140,6 +157,4 @@ static function getAllUsers_groups() {
|
||||||
}
|
}
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,100 +2,127 @@
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
|
|
||||||
class Users_extra_info extends ObjectYPT {
|
class Users_extra_info extends ObjectYPT
|
||||||
|
{
|
||||||
|
protected $id;
|
||||||
|
protected $field_name;
|
||||||
|
protected $field_type;
|
||||||
|
protected $field_options;
|
||||||
|
protected $field_default_value;
|
||||||
|
protected $parameters;
|
||||||
|
protected $status;
|
||||||
|
protected $order;
|
||||||
|
|
||||||
protected $id, $field_name, $field_type, $field_options, $field_default_value, $parameters, $status, $order;
|
public static function getSearchFieldsNames()
|
||||||
|
{
|
||||||
static function getSearchFieldsNames() {
|
return ['field_name', 'field_type', 'field_options', 'field_default_value', 'parameters'];
|
||||||
return array('field_name', 'field_type', 'field_options', 'field_default_value', 'parameters');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTableName() {
|
public static function getTableName()
|
||||||
|
{
|
||||||
return 'users_extra_info';
|
return 'users_extra_info';
|
||||||
}
|
}
|
||||||
|
|
||||||
function setId($id) {
|
public function setId($id)
|
||||||
|
{
|
||||||
$this->id = intval($id);
|
$this->id = intval($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setField_name($field_name) {
|
public function setField_name($field_name)
|
||||||
|
{
|
||||||
$this->field_name = $field_name;
|
$this->field_name = $field_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setField_type($field_type) {
|
public function setField_type($field_type)
|
||||||
|
{
|
||||||
$this->field_type = $field_type;
|
$this->field_type = $field_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setField_options($field_options) {
|
public function setField_options($field_options)
|
||||||
|
{
|
||||||
$this->field_options = $field_options;
|
$this->field_options = $field_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setField_default_value($field_default_value) {
|
public function setField_default_value($field_default_value)
|
||||||
|
{
|
||||||
$this->field_default_value = $field_default_value;
|
$this->field_default_value = $field_default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setParameters($parameters) {
|
public function setParameters($parameters)
|
||||||
|
{
|
||||||
$this->parameters = $parameters;
|
$this->parameters = $parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStatus($status) {
|
public function setStatus($status)
|
||||||
|
{
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getId() {
|
public function getId()
|
||||||
|
{
|
||||||
return intval($this->id);
|
return intval($this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getField_name() {
|
public function getField_name()
|
||||||
|
{
|
||||||
return $this->field_name;
|
return $this->field_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getField_type() {
|
public function getField_type()
|
||||||
|
{
|
||||||
return $this->field_type;
|
return $this->field_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getField_options() {
|
public function getField_options()
|
||||||
|
{
|
||||||
return $this->field_options;
|
return $this->field_options;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getField_default_value() {
|
public function getField_default_value()
|
||||||
|
{
|
||||||
return $this->field_default_value;
|
return $this->field_default_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getParameters() {
|
public function getParameters()
|
||||||
|
{
|
||||||
return $this->parameters;
|
return $this->parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatus() {
|
public function getStatus()
|
||||||
|
{
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOrder() {
|
public function getOrder()
|
||||||
|
{
|
||||||
return $this->order;
|
return $this->order;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setOrder($order) {
|
public function setOrder($order)
|
||||||
|
{
|
||||||
$this->order = intval($order);
|
$this->order = intval($order);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTypesOptionArray() {
|
public static function getTypesOptionArray()
|
||||||
return array('input' => 'Text', 'number' => 'Number', 'select' => 'Predefined options (select one)', 'textarea' => 'Textarea');
|
{
|
||||||
|
return ['input' => 'Text', 'number' => 'Number', 'select' => 'Predefined options (select one)', 'textarea' => 'Textarea'];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function typeToHTML($row) {
|
public static function typeToHTML($row)
|
||||||
|
{
|
||||||
$html = "";
|
$html = "";
|
||||||
if(isset($row['value'])){
|
if (isset($row['value'])) {
|
||||||
$row['field_default_value'] = $row['value'];
|
$row['field_default_value'] = $row['value'];
|
||||||
}
|
}
|
||||||
if ($row['field_type'] == 'input') {
|
if ($row['field_type'] == 'input') {
|
||||||
$html .= "<label for=\"usersExtraInfo_{$row['id']}\">{$row['field_name']}:</label>";
|
$html .= "<label for=\"usersExtraInfo_{$row['id']}\">{$row['field_name']}:</label>";
|
||||||
$html .= "<input type=\"text\" id=\"usersExtraInfo_{$row['id']}\" name=\"usersExtraInfo[{$row['id']}]\" "
|
$html .= "<input type=\"text\" id=\"usersExtraInfo_{$row['id']}\" name=\"usersExtraInfo[{$row['id']}]\" "
|
||||||
. "class=\"form-control input-sm usersExtraInfoInput\" placeholder=\"{$row['field_name']}\" value=\"{$row['field_default_value']}\">";
|
. "class=\"form-control input-sm usersExtraInfoInput\" placeholder=\"{$row['field_name']}\" value=\"{$row['field_default_value']}\">";
|
||||||
} else if ($row['field_type'] == 'number') {
|
} elseif ($row['field_type'] == 'number') {
|
||||||
$html .= "<label for=\"usersExtraInfo_{$row['id']}\">{$row['field_name']}:</label>";
|
$html .= "<label for=\"usersExtraInfo_{$row['id']}\">{$row['field_name']}:</label>";
|
||||||
$html .= "<input type=\"number\" id=\"usersExtraInfo_{$row['id']}\" name=\"usersExtraInfo[{$row['id']}]\" "
|
$html .= "<input type=\"number\" id=\"usersExtraInfo_{$row['id']}\" name=\"usersExtraInfo[{$row['id']}]\" "
|
||||||
. "class=\"form-control input-sm usersExtraInfoInput\" placeholder=\"{$row['field_name']}\" value=\"{$row['field_default_value']}\">";
|
. "class=\"form-control input-sm usersExtraInfoInput\" placeholder=\"{$row['field_name']}\" value=\"{$row['field_default_value']}\">";
|
||||||
} else if ($row['field_type'] == 'select') {
|
} elseif ($row['field_type'] == 'select') {
|
||||||
$html = "<label for=\"usersExtraInfo_{$row['id']}\">{$row['field_name']}:</label>
|
$html = "<label for=\"usersExtraInfo_{$row['id']}\">{$row['field_name']}:</label>
|
||||||
<select class=\"form-control input-sm usersExtraInfoInput\" name=\"usersExtraInfo[{$row['id']}]\" id=\"usersExtraInfo_{$row['id']}\">";
|
<select class=\"form-control input-sm usersExtraInfoInput\" name=\"usersExtraInfo[{$row['id']}]\" id=\"usersExtraInfo_{$row['id']}\">";
|
||||||
foreach (preg_split("/((\r?\n)|(\r\n?))/", $row['field_options']) as $line) {
|
foreach (preg_split("/((\r?\n)|(\r\n?))/", $row['field_options']) as $line) {
|
||||||
|
@ -110,7 +137,7 @@ class Users_extra_info extends ObjectYPT {
|
||||||
$html .= "<option {$selected}>" . htmlentities($line) . "</option>";
|
$html .= "<option {$selected}>" . htmlentities($line) . "</option>";
|
||||||
}
|
}
|
||||||
$html .= "</select>";
|
$html .= "</select>";
|
||||||
} else if ($row['field_type'] == 'textarea') {
|
} elseif ($row['field_type'] == 'textarea') {
|
||||||
$html .= "<label for=\"usersExtraInfo_{$row['id']}\">{$row['field_name']}:</label>";
|
$html .= "<label for=\"usersExtraInfo_{$row['id']}\">{$row['field_name']}:</label>";
|
||||||
$html .= "<textarea type=\"text\" id=\"usersExtraInfo_{$row['id']}\" name=\"usersExtraInfo[{$row['id']}]\" "
|
$html .= "<textarea type=\"text\" id=\"usersExtraInfo_{$row['id']}\" name=\"usersExtraInfo[{$row['id']}]\" "
|
||||||
. "class=\"form-control input-sm usersExtraInfoInput\" placeholder=\"{$row['field_name']}\" rows=\"6\">{$row['field_default_value']}</textarea>";
|
. "class=\"form-control input-sm usersExtraInfoInput\" placeholder=\"{$row['field_name']}\" rows=\"6\">{$row['field_default_value']}</textarea>";
|
||||||
|
@ -118,7 +145,8 @@ class Users_extra_info extends ObjectYPT {
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllActive($users_id=0) {
|
public static function getAllActive($users_id=0)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (!static::isTableInstalled()) {
|
if (!static::isTableInstalled()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -127,16 +155,16 @@ class Users_extra_info extends ObjectYPT {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
if(!empty($users_id)){
|
if (!empty($users_id)) {
|
||||||
$extraInfo = self::getFromUser($users_id);
|
$extraInfo = self::getFromUser($users_id);
|
||||||
}
|
}
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
if(!empty($extraInfo) && !empty($extraInfo[$row['id']])){
|
if (!empty($extraInfo) && !empty($extraInfo[$row['id']])) {
|
||||||
$row['value'] = $extraInfo[$row['id']];
|
$row['value'] = $extraInfo[$row['id']];
|
||||||
$row['current_value'] = $row['value'];
|
$row['current_value'] = $row['value'];
|
||||||
}else{
|
} else {
|
||||||
$row['current_value'] = $row['field_default_value'];
|
$row['current_value'] = $row['field_default_value'];
|
||||||
}
|
}
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
|
@ -147,9 +175,9 @@ class Users_extra_info extends ObjectYPT {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getFromUser($users_id) {
|
public static function getFromUser($users_id)
|
||||||
|
{
|
||||||
$u = new User($users_id);
|
$u = new User($users_id);
|
||||||
return object_to_array(_json_decode($u->getExtra_info()));
|
return object_to_array(_json_decode($u->getExtra_info()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
require_once '../../../../videos/configuration.php';
|
require_once '../../../../videos/configuration.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Categories_has_users_groups.php';
|
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Categories_has_users_groups.php';
|
||||||
|
@ -9,7 +10,7 @@ $obj->msg = "";
|
||||||
|
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
|
$plugin = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
|
||||||
|
|
||||||
if(!User::isAdmin()){
|
if (!User::isAdmin()) {
|
||||||
$obj->msg = "You can't do this";
|
$obj->msg = "You can't do this";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
@ -19,7 +20,7 @@ $o->setCategories_id($_POST['categories_id']);
|
||||||
$o->setUsers_groups_id($_POST['users_groups_id']);
|
$o->setUsers_groups_id($_POST['users_groups_id']);
|
||||||
$o->setStatus($_POST['status']);
|
$o->setStatus($_POST['status']);
|
||||||
|
|
||||||
if($id = $o->save()){
|
if ($id = $o->save()) {
|
||||||
$obj->error = false;
|
$obj->error = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../../../../videos/configuration.php';
|
require_once '../../../../videos/configuration.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Categories_has_users_groups.php';
|
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Categories_has_users_groups.php';
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
@ -8,7 +9,7 @@ $obj->error = true;
|
||||||
|
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
|
$plugin = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
|
||||||
|
|
||||||
if(!User::isAdmin()){
|
if (!User::isAdmin()) {
|
||||||
$obj->msg = "You can't do this";
|
$obj->msg = "You can't do this";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
@ -17,4 +18,3 @@ $id = intval($_POST['id']);
|
||||||
$row = new Categories_has_users_groups($id);
|
$row = new Categories_has_users_groups($id);
|
||||||
$obj->error = !$row->delete();
|
$obj->error = !$row->delete();
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
?>
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
require_once '../../../../videos/configuration.php';
|
require_once '../../../../videos/configuration.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_extra_info.php';
|
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_extra_info.php';
|
||||||
|
@ -9,7 +10,7 @@ $obj->msg = "";
|
||||||
|
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
|
$plugin = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
|
||||||
|
|
||||||
if(!User::isAdmin()){
|
if (!User::isAdmin()) {
|
||||||
$obj->msg = "You can't do this";
|
$obj->msg = "You can't do this";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
@ -23,7 +24,7 @@ $o->setParameters($_POST['parameters']);
|
||||||
$o->setStatus($_POST['status']);
|
$o->setStatus($_POST['status']);
|
||||||
$o->setOrder($_POST['order']);
|
$o->setOrder($_POST['order']);
|
||||||
|
|
||||||
if($id = $o->save()){
|
if ($id = $o->save()) {
|
||||||
$obj->error = false;
|
$obj->error = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../../../../videos/configuration.php';
|
require_once '../../../../videos/configuration.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_extra_info.php';
|
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_extra_info.php';
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
@ -8,7 +9,7 @@ $obj->error = true;
|
||||||
|
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
|
$plugin = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
|
||||||
|
|
||||||
if(!User::isAdmin()){
|
if (!User::isAdmin()) {
|
||||||
$obj->msg = "You can't do this";
|
$obj->msg = "You can't do this";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
@ -17,4 +18,3 @@ $id = intval($_POST['id']);
|
||||||
$row = new Users_extra_info($id);
|
$row = new Users_extra_info($id);
|
||||||
$obj->error = !$row->delete();
|
$obj->error = !$row->delete();
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
?>
|
|
|
@ -30,7 +30,7 @@ if (!User::isAdmin()) {
|
||||||
<label for="order"><?php echo __("order"); ?>:</label>
|
<label for="order"><?php echo __("order"); ?>:</label>
|
||||||
<select class="form-control input-sm" name="order" id="Users_extra_infoorder">
|
<select class="form-control input-sm" name="order" id="Users_extra_infoorder">
|
||||||
<?php
|
<?php
|
||||||
for($i=0;$i<20;$i++){
|
for ($i=0;$i<20;$i++) {
|
||||||
echo '<option value="'.$i.'">'.$i.'</option>';
|
echo '<option value="'.$i.'">'.$i.'</option>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
require_once '../../../../videos/configuration.php';
|
require_once '../../../../videos/configuration.php';
|
||||||
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_extra_info.php';
|
require_once $global['systemRootPath'] . 'plugin/CustomizeUser/Objects/Users_extra_info.php';
|
||||||
|
@ -10,12 +11,12 @@ $obj->id = 0;
|
||||||
|
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
|
$plugin = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
|
||||||
|
|
||||||
if(!User::isLogged()){
|
if (!User::isLogged()) {
|
||||||
$obj->msg = "You can't do this";
|
$obj->msg = "You can't do this";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($_POST['usersExtraInfo'])){
|
if (empty($_POST['usersExtraInfo'])) {
|
||||||
$obj->msg = "Extra info is empty";
|
$obj->msg = "Extra info is empty";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ $rows = Users_extra_info::getAllActive(User::getId());
|
||||||
?>
|
?>
|
||||||
<div id="<?php echo $tabId; ?>" class="tab-pane fade in" style="padding: 10px 0;">
|
<div id="<?php echo $tabId; ?>" class="tab-pane fade in" style="padding: 10px 0;">
|
||||||
<?php
|
<?php
|
||||||
if(User::isAdmin()){
|
if (User::isAdmin()) {
|
||||||
echo "<a href='{$global['webSiteRootURL']}plugin/CustomizeUser/View/editor.php' class='btn btn-default btn-block'>".__('Add more fields')."</a>";
|
echo "<a href='{$global['webSiteRootURL']}plugin/CustomizeUser/View/editor.php' class='btn btn-default btn-block'>".__('Add more fields')."</a>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -15,12 +15,10 @@ $rows = Users_extra_info::getAllActive(User::getId());
|
||||||
$class = "col-sm-4";
|
$class = "col-sm-4";
|
||||||
if ($value['field_type'] == 'textarea') {
|
if ($value['field_type'] == 'textarea') {
|
||||||
$class = "col-sm-12";
|
$class = "col-sm-12";
|
||||||
}
|
} ?>
|
||||||
?>
|
|
||||||
<div class="<?php echo $class; ?>">
|
<div class="<?php echo $class; ?>">
|
||||||
<?php
|
<?php
|
||||||
echo Users_extra_info::typeToHTML($value);
|
echo Users_extra_info::typeToHTML($value); ?>
|
||||||
?>
|
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,10 @@ if ($obj->allowWalletDirectTransferDonation && !empty($video['users_id']) && cla
|
||||||
<i class="fas fa-donate"></i> <small class="hidden-sm hidden-xs"><?php echo __("Please login to donate"); ?></small>
|
<i class="fas fa-donate"></i> <small class="hidden-sm hidden-xs"><?php echo __("Please login to donate"); ?></small>
|
||||||
</a>
|
</a>
|
||||||
<?php
|
<?php
|
||||||
} else if (class_exists("YPTWallet")) {
|
} elseif (class_exists("YPTWallet")) {
|
||||||
$u = new User($video['users_id']);
|
$u = new User($video['users_id']);
|
||||||
$uid = uniqid();
|
$uid = uniqid();
|
||||||
$captcha = User::getCaptchaForm($uid);
|
$captcha = User::getCaptchaForm($uid); ?>
|
||||||
?>
|
|
||||||
<button class="btn btn-success no-outline" onclick="openDonationMoodal<?php echo $uid; ?>();">
|
<button class="btn btn-success no-outline" onclick="openDonationMoodal<?php echo $uid; ?>();">
|
||||||
<i class="fas fa-donate"></i> <small class="hidden-sm hidden-xs"><?php echo __($obj->donationWalletButtonLabel); ?></small>
|
<i class="fas fa-donate"></i> <small class="hidden-sm hidden-xs"><?php echo __($obj->donationWalletButtonLabel); ?></small>
|
||||||
</button>
|
</button>
|
||||||
|
@ -56,8 +55,7 @@ if ($obj->allowWalletDirectTransferDonation && !empty($video['users_id']) && cla
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
} ?>
|
||||||
?>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
if (!empty($_SESSION['channelName'])) {
|
if (!empty($_SESSION['channelName'])) {
|
||||||
unset($_GET['channelName']);
|
unset($_GET['channelName']);
|
||||||
$params = array_merge($_GET, array('leaveChannel' => '1'));
|
$params = array_merge($_GET, ['leaveChannel' => '1']);
|
||||||
$_GET['channelName'] = $_SESSION['channelName'];
|
$_GET['channelName'] = $_SESSION['channelName'];
|
||||||
$new_query_string = http_build_query($params);
|
$new_query_string = http_build_query($params);
|
||||||
$request_uri = explode("?", $_SERVER['REQUEST_URI']);
|
$request_uri = explode("?", $_SERVER['REQUEST_URI']);
|
||||||
$leaveLink = $request_uri[0] . '?' . $new_query_string;
|
$leaveLink = $request_uri[0] . '?' . $new_query_string;
|
||||||
if(!empty($obj->showLeaveChannelButton)){
|
if (!empty($obj->showLeaveChannelButton)) {
|
||||||
?>
|
?>
|
||||||
<li>
|
<li>
|
||||||
<a href="<?php echo $leaveLink; ?>" class="btn btn-default navbar-btn" data-toggle="tooltip" title="<?php echo __("Leave Channel"); ?>" data-placement="bottom" >
|
<a href="<?php echo $leaveLink; ?>" class="btn btn-default navbar-btn" data-toggle="tooltip" title="<?php echo __("Leave Channel"); ?>" data-placement="bottom" >
|
||||||
|
@ -14,8 +14,7 @@ if (!empty($_SESSION['channelName'])) {
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<?php
|
<?php
|
||||||
}
|
} ?>
|
||||||
?>
|
|
||||||
<script>
|
<script>
|
||||||
$('#mainNavbarLogo').on('click', function (e) {
|
$('#mainNavbarLogo').on('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -4,7 +4,7 @@ session_write_close();
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
$name = "customizeUser.json.php";
|
$name = "customizeUser.json.php";
|
||||||
$obj = ObjectYPT::getCache($name, 60);
|
$obj = ObjectYPT::getCache($name, 60);
|
||||||
if(empty($obj)){
|
if (empty($obj)) {
|
||||||
$obj = AVideoPlugin::getObjectData("CustomizeUser");
|
$obj = AVideoPlugin::getObjectData("CustomizeUser");
|
||||||
ObjectYPT::setCache($name, $obj);
|
ObjectYPT::setCache($name, $obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../../videos/configuration.php';
|
require_once '../../videos/configuration.php';
|
||||||
require_once $global['systemRootPath'] . 'objects/captcha.php';
|
require_once $global['systemRootPath'] . 'objects/captcha.php';
|
||||||
session_write_close();
|
session_write_close();
|
||||||
|
@ -32,7 +33,7 @@ if (empty($wallet)) {
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($cu->disableCaptchaOnWalletDirectTransferDonation)){
|
if (empty($cu->disableCaptchaOnWalletDirectTransferDonation)) {
|
||||||
$valid = Captcha::validation(@$_POST['captcha']);
|
$valid = Captcha::validation(@$_POST['captcha']);
|
||||||
|
|
||||||
if (empty($valid)) {
|
if (empty($valid)) {
|
||||||
|
@ -58,8 +59,7 @@ if (!empty($_POST['videos_id'])) {
|
||||||
$obj->error = false;
|
$obj->error = false;
|
||||||
AVideoPlugin::afterDonation(User::getId(), $value, $videos_id, 0);
|
AVideoPlugin::afterDonation(User::getId(), $value, $videos_id, 0);
|
||||||
}
|
}
|
||||||
} else if (!empty($_POST['users_id'])) {
|
} elseif (!empty($_POST['users_id'])) {
|
||||||
|
|
||||||
$users_id = intval($_POST['users_id']);
|
$users_id = intval($_POST['users_id']);
|
||||||
if (empty($users_id)) {
|
if (empty($users_id)) {
|
||||||
$obj->msg = "User id is empty";
|
$obj->msg = "User id is empty";
|
||||||
|
|
|
@ -2,25 +2,26 @@
|
||||||
require_once '../../videos/configuration.php';
|
require_once '../../videos/configuration.php';
|
||||||
session_write_close();
|
session_write_close();
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->error = true;
|
$obj->error = true;
|
||||||
$obj->msg = "";
|
$obj->msg = "";
|
||||||
if(!User::isLogged()){
|
if (!User::isLogged()) {
|
||||||
$obj->msg = "Not logged";
|
$obj->msg = "Not logged";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
if(empty($_POST['type'])){
|
if (empty($_POST['type'])) {
|
||||||
$obj->msg = "Type is empty";
|
$obj->msg = "Type is empty";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
if(!isset($_POST['value'])){
|
if (!isset($_POST['value'])) {
|
||||||
$obj->msg = "value is empty";
|
$obj->msg = "value is empty";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
$cu = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
|
$cu = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
|
||||||
|
|
||||||
if(empty($cu)){
|
if (empty($cu)) {
|
||||||
$obj->msg = "Plugin not enabled";
|
$obj->msg = "Plugin not enabled";
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
@ -28,10 +29,10 @@ if(empty($cu)){
|
||||||
$obj->error = false;
|
$obj->error = false;
|
||||||
switch ($_POST['type']) {
|
switch ($_POST['type']) {
|
||||||
case 'userCanAllowFilesDownload':
|
case 'userCanAllowFilesDownload':
|
||||||
CustomizeUser::setCanDownloadVideosFromUser(User::getId(), $_POST['value']=="true"?true:false);
|
CustomizeUser::setCanDownloadVideosFromUser(User::getId(), $_POST['value']=="true" ? true : false);
|
||||||
break;
|
break;
|
||||||
case 'userCanAllowFilesShare':
|
case 'userCanAllowFilesShare':
|
||||||
CustomizeUser::setCanShareVideosFromUser(User::getId(), $_POST['value']=="true"?true:false);
|
CustomizeUser::setCanShareVideosFromUser(User::getId(), $_POST['value']=="true" ? true : false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
require_once '../../videos/configuration.php';
|
require_once '../../videos/configuration.php';
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->error = true;
|
$obj->error = true;
|
||||||
$obj->msg = '';
|
$obj->msg = '';
|
||||||
|
|
||||||
if(!User::isAdmin()){
|
if (!User::isAdmin()) {
|
||||||
$obj->msg = ('Must be admin');
|
$obj->msg = ('Must be admin');
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
$users_id = intval(@$_REQUEST['users_id']);
|
$users_id = intval(@$_REQUEST['users_id']);
|
||||||
if(empty($users_id)){
|
if (empty($users_id)) {
|
||||||
$obj->msg = ('Empty users_id');
|
$obj->msg = ('Empty users_id');
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ require_once '../../videos/configuration.php';
|
||||||
if (!User::isAdmin()) {
|
if (!User::isAdmin()) {
|
||||||
forbiddenPage('Must be admin');
|
forbiddenPage('Must be admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
$users_id = intval(@$_REQUEST['users_id']);
|
$users_id = intval(@$_REQUEST['users_id']);
|
||||||
if (empty($users_id)) {
|
if (empty($users_id)) {
|
||||||
forbiddenPage('Empty users_id');
|
forbiddenPage('Empty users_id');
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
<?php
|
<?php
|
||||||
require_once '../../videos/configuration.php';
|
require_once '../../videos/configuration.php';
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
$obj = new stdClass();
|
$obj = new stdClass();
|
||||||
$obj->error = true;
|
$obj->error = true;
|
||||||
$obj->msg = '';
|
$obj->msg = '';
|
||||||
|
|
||||||
if(!User::isAdmin()){
|
if (!User::isAdmin()) {
|
||||||
$obj->msg = ('Must be admin');
|
$obj->msg = ('Must be admin');
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
$users_id = intval(@$_REQUEST['users_id']);
|
$users_id = intval(@$_REQUEST['users_id']);
|
||||||
if(empty($users_id)){
|
if (empty($users_id)) {
|
||||||
$obj->msg = ('Empty users_id');
|
$obj->msg = ('Empty users_id');
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
require_once '../../videos/configuration.php';
|
require_once '../../videos/configuration.php';
|
||||||
|
|
||||||
if (!User::isAdmin()) {
|
if (!User::isAdmin()) {
|
||||||
forbiddenPage('Must be admin');
|
forbiddenPage('Must be admin');
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -4,111 +4,143 @@ require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
require_once dirname(__FILE__) . '/../../../objects/bootGrid.php';
|
require_once dirname(__FILE__) . '/../../../objects/bootGrid.php';
|
||||||
require_once dirname(__FILE__) . '/../../../objects/user.php';
|
require_once dirname(__FILE__) . '/../../../objects/user.php';
|
||||||
|
|
||||||
class LiveTransmition extends ObjectYPT {
|
class LiveTransmition extends ObjectYPT
|
||||||
|
{
|
||||||
|
protected $id;
|
||||||
|
protected $title;
|
||||||
|
protected $public;
|
||||||
|
protected $saveTransmition;
|
||||||
|
protected $users_id;
|
||||||
|
protected $categories_id;
|
||||||
|
protected $key;
|
||||||
|
protected $description;
|
||||||
|
protected $showOnTV;
|
||||||
|
protected $password;
|
||||||
|
|
||||||
protected $id, $title, $public, $saveTransmition, $users_id, $categories_id, $key, $description, $showOnTV, $password;
|
public static function getSearchFieldsNames()
|
||||||
|
{
|
||||||
static function getSearchFieldsNames() {
|
return ['title'];
|
||||||
return array('title');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTableName() {
|
public static function getTableName()
|
||||||
|
{
|
||||||
return 'live_transmitions';
|
return 'live_transmitions';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getId() {
|
public function getId()
|
||||||
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTitle() {
|
public function getTitle()
|
||||||
|
{
|
||||||
return $this->title;
|
return $this->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPublic() {
|
public function getPublic()
|
||||||
|
{
|
||||||
return $this->public;
|
return $this->public;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSaveTransmition() {
|
public function getSaveTransmition()
|
||||||
|
{
|
||||||
return $this->saveTransmition;
|
return $this->saveTransmition;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsers_id() {
|
public function getUsers_id()
|
||||||
|
{
|
||||||
return $this->users_id;
|
return $this->users_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCategories_id() {
|
public function getCategories_id()
|
||||||
|
{
|
||||||
return $this->categories_id;
|
return $this->categories_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getKey() {
|
public function getKey()
|
||||||
|
{
|
||||||
return $this->key;
|
return $this->key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDescription() {
|
public function getDescription()
|
||||||
|
{
|
||||||
return $this->description;
|
return $this->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setId($id) {
|
public function setId($id)
|
||||||
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTitle($title) {
|
public function setTitle($title)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
//$title = $global['mysqli']->real_escape_string($title);
|
//$title = $global['mysqli']->real_escape_string($title);
|
||||||
$this->title = xss_esc($title);
|
$this->title = xss_esc($title);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPublic($public) {
|
public function setPublic($public)
|
||||||
|
{
|
||||||
$this->public = intval($public);
|
$this->public = intval($public);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSaveTransmition($saveTransmition) {
|
public function setSaveTransmition($saveTransmition)
|
||||||
|
{
|
||||||
$this->saveTransmition = $saveTransmition;
|
$this->saveTransmition = $saveTransmition;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUsers_id($users_id) {
|
public function setUsers_id($users_id)
|
||||||
|
{
|
||||||
$this->users_id = $users_id;
|
$this->users_id = $users_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCategories_id($categories_id) {
|
public function setCategories_id($categories_id)
|
||||||
|
{
|
||||||
$this->categories_id = $categories_id;
|
$this->categories_id = $categories_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setKey($key) {
|
public function setKey($key)
|
||||||
|
{
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDescription($description) {
|
public function setDescription($description)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
//$description = $global['mysqli']->real_escape_string($description);
|
//$description = $global['mysqli']->real_escape_string($description);
|
||||||
$this->description = xss_esc($description);
|
$this->description = xss_esc($description);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadByUser($user_id) {
|
public function loadByUser($user_id)
|
||||||
|
{
|
||||||
$user = self::getFromDbByUser($user_id);
|
$user = self::getFromDbByUser($user_id);
|
||||||
if (empty($user))
|
if (empty($user)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
foreach ($user as $key => $value) {
|
foreach ($user as $key => $value) {
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadByKey($uuid) {
|
public function loadByKey($uuid)
|
||||||
|
{
|
||||||
$row = self::getFromKey($uuid);
|
$row = self::getFromKey($uuid);
|
||||||
if (empty($row))
|
if (empty($row)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
foreach ($row as $key => $value) {
|
foreach ($row as $key => $value) {
|
||||||
$this->$key = $value;
|
$this->$key = $value;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getFromDbByUser($user_id) {
|
public static function getFromDbByUser($user_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$user_id = intval($user_id);
|
$user_id = intval($user_id);
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = ? LIMIT 1";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = ? LIMIT 1";
|
||||||
$res = sqlDAL::readSql($sql, "i", array($user_id), true);
|
$res = sqlDAL::readSql($sql, "i", [$user_id], true);
|
||||||
$data = sqlDAL::fetchAssoc($res);
|
$data = sqlDAL::fetchAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
|
@ -119,7 +151,8 @@ class LiveTransmition extends ObjectYPT {
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function createTransmitionIfNeed($user_id) {
|
public static function createTransmitionIfNeed($user_id)
|
||||||
|
{
|
||||||
if (empty($user_id)) {
|
if (empty($user_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -137,41 +170,44 @@ class LiveTransmition extends ObjectYPT {
|
||||||
return static::getFromDbByUser($user_id);
|
return static::getFromDbByUser($user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function resetTransmitionKey($user_id) {
|
public static function resetTransmitionKey($user_id)
|
||||||
|
{
|
||||||
$row = static::getFromDbByUser($user_id);
|
$row = static::getFromDbByUser($user_id);
|
||||||
|
|
||||||
$l = new LiveTransmition($row['id']);
|
$l = new LiveTransmition($row['id']);
|
||||||
$newKey = uniqid();
|
$newKey = uniqid();
|
||||||
$l->setKey($newKey);
|
$l->setKey($newKey);
|
||||||
if($l->save()){
|
if ($l->save()) {
|
||||||
return $newKey;
|
return $newKey;
|
||||||
}else{
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getFromRequest() {
|
public static function getFromRequest()
|
||||||
if(!empty($_REQUEST['live_schedule'])){
|
{
|
||||||
|
if (!empty($_REQUEST['live_schedule'])) {
|
||||||
return LiveTransmition::getFromDbBySchedule($_REQUEST['live_schedule']);
|
return LiveTransmition::getFromDbBySchedule($_REQUEST['live_schedule']);
|
||||||
}else if(!empty($_REQUEST['u'])){
|
} elseif (!empty($_REQUEST['u'])) {
|
||||||
return LiveTransmition::getFromDbByUserName($_REQUEST['u']);
|
return LiveTransmition::getFromDbByUserName($_REQUEST['u']);
|
||||||
}else if(!empty($_REQUEST['c'])){
|
} elseif (!empty($_REQUEST['c'])) {
|
||||||
return LiveTransmition::getFromDbByChannelName($_REQUEST['c']);
|
return LiveTransmition::getFromDbByChannelName($_REQUEST['c']);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getFromDbByUserName($userName) {
|
public static function getFromDbByUserName($userName)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
_mysql_connect();
|
_mysql_connect();
|
||||||
$userName = $global['mysqli']->real_escape_string($userName);
|
$userName = $global['mysqli']->real_escape_string($userName);
|
||||||
$sql = "SELECT * FROM users WHERE user = ? LIMIT 1";
|
$sql = "SELECT * FROM users WHERE user = ? LIMIT 1";
|
||||||
$res = sqlDAL::readSql($sql, "s", array($userName), true);
|
$res = sqlDAL::readSql($sql, "s", [$userName], true);
|
||||||
$data = sqlDAL::fetchAssoc($res);
|
$data = sqlDAL::fetchAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
$user = $data;
|
$user = $data;
|
||||||
if(empty($user)){
|
if (empty($user)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return static::getFromDbByUser($user['id']);
|
return static::getFromDbByUser($user['id']);
|
||||||
|
@ -180,17 +216,18 @@ class LiveTransmition extends ObjectYPT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getFromDbByChannelName($channelName) {
|
public static function getFromDbByChannelName($channelName)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
_mysql_connect();
|
_mysql_connect();
|
||||||
$channelName = $global['mysqli']->real_escape_string($channelName);
|
$channelName = $global['mysqli']->real_escape_string($channelName);
|
||||||
$sql = "SELECT * FROM users WHERE channelName = ? LIMIT 1";
|
$sql = "SELECT * FROM users WHERE channelName = ? LIMIT 1";
|
||||||
$res = sqlDAL::readSql($sql, "s", array($channelName), true);
|
$res = sqlDAL::readSql($sql, "s", [$channelName], true);
|
||||||
$data = sqlDAL::fetchAssoc($res);
|
$data = sqlDAL::fetchAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
$user = $data;
|
$user = $data;
|
||||||
if(empty($user)){
|
if (empty($user)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return static::getFromDbByUser($user['id']);
|
return static::getFromDbByUser($user['id']);
|
||||||
|
@ -199,13 +236,14 @@ class LiveTransmition extends ObjectYPT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getFromDbBySchedule($live_schedule_id) {
|
public static function getFromDbBySchedule($live_schedule_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$live_schedule_id = intval($live_schedule_id);
|
$live_schedule_id = intval($live_schedule_id);
|
||||||
$sql = "SELECT lt.*, ls.* FROM live_schedule ls "
|
$sql = "SELECT lt.*, ls.* FROM live_schedule ls "
|
||||||
. " LEFT JOIN " . static::getTableName() . " lt ON lt.users_id = ls.users_id "
|
. " LEFT JOIN " . static::getTableName() . " lt ON lt.users_id = ls.users_id "
|
||||||
. " WHERE ls.id = ? LIMIT 1";
|
. " WHERE ls.id = ? LIMIT 1";
|
||||||
$res = sqlDAL::readSql($sql, "i", array($live_schedule_id), true);
|
$res = sqlDAL::readSql($sql, "i", [$live_schedule_id], true);
|
||||||
$data = sqlDAL::fetchAssoc($res);
|
$data = sqlDAL::fetchAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
|
@ -216,12 +254,13 @@ class LiveTransmition extends ObjectYPT {
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function keyExists($key, $checkSchedule = true) {
|
public static function keyExists($key, $checkSchedule = true)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (!is_string($key)) {
|
if (!is_string($key)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(Live::isAdaptiveTransmition($key)){
|
if (Live::isAdaptiveTransmition($key)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$key = Live::cleanUpKey($key);
|
$key = Live::cleanUpKey($key);
|
||||||
|
@ -233,10 +272,10 @@ class LiveTransmition extends ObjectYPT {
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
if ($res) {
|
if ($res) {
|
||||||
$row = $data;
|
$row = $data;
|
||||||
if(!empty($row)){
|
if (!empty($row)) {
|
||||||
$row['scheduled'] = 0;
|
$row['scheduled'] = 0;
|
||||||
}
|
}
|
||||||
if(!empty($row)){
|
if (!empty($row)) {
|
||||||
$p = $row['live_password'];
|
$p = $row['live_password'];
|
||||||
$row = cleanUpRowFromDatabase($row);
|
$row = cleanUpRowFromDatabase($row);
|
||||||
$row['live_password'] = $p;
|
$row['live_password'] = $p;
|
||||||
|
@ -245,9 +284,9 @@ class LiveTransmition extends ObjectYPT {
|
||||||
$row = false;
|
$row = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($checkSchedule && empty($row)){
|
if ($checkSchedule && empty($row)) {
|
||||||
$row = Live_schedule::keyExists($key);
|
$row = Live_schedule::keyExists($key);
|
||||||
if(!empty($row)){
|
if (!empty($row)) {
|
||||||
$row['scheduled'] = 1;
|
$row['scheduled'] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,49 +294,54 @@ class LiveTransmition extends ObjectYPT {
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
public function save()
|
||||||
|
{
|
||||||
$this->public = intval($this->public);
|
$this->public = intval($this->public);
|
||||||
$this->saveTransmition = intval($this->saveTransmition);
|
$this->saveTransmition = intval($this->saveTransmition);
|
||||||
$this->showOnTV = intval($this->showOnTV);
|
$this->showOnTV = intval($this->showOnTV);
|
||||||
if(empty($this->password)){
|
if (empty($this->password)) {
|
||||||
$this->password = '';
|
$this->password = '';
|
||||||
}
|
}
|
||||||
$id = parent::save();
|
$id = parent::save();
|
||||||
Category::clearCacheCount();
|
Category::clearCacheCount();
|
||||||
Live::deleteStatsCache(true);
|
Live::deleteStatsCache(true);
|
||||||
|
|
||||||
$socketObj = sendSocketMessageToAll(array('stats'=>getStatsNotifications()), "socketLiveONCallback");
|
$socketObj = sendSocketMessageToAll(['stats'=>getStatsNotifications()], "socketLiveONCallback");
|
||||||
|
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteGroupsTrasmition() {
|
public function deleteGroupsTrasmition()
|
||||||
|
{
|
||||||
if (empty($this->id)) {
|
if (empty($this->id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "DELETE FROM live_transmitions_has_users_groups WHERE live_transmitions_id = ?";
|
$sql = "DELETE FROM live_transmitions_has_users_groups WHERE live_transmitions_id = ?";
|
||||||
return sqlDAL::writeSql($sql, "i", array($this->id));
|
return sqlDAL::writeSql($sql, "i", [$this->id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertGroup($users_groups_id) {
|
public function insertGroup($users_groups_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "INSERT INTO live_transmitions_has_users_groups (live_transmitions_id, users_groups_id) VALUES (?,?)";
|
$sql = "INSERT INTO live_transmitions_has_users_groups (live_transmitions_id, users_groups_id) VALUES (?,?)";
|
||||||
return sqlDAL::writeSql($sql, "ii", array($this->id, $users_groups_id));
|
return sqlDAL::writeSql($sql, "ii", [$this->id, $users_groups_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAPrivateLive(){
|
public function isAPrivateLive()
|
||||||
|
{
|
||||||
return !empty($this->getGroups());
|
return !empty($this->getGroups());
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGroups() {
|
public function getGroups()
|
||||||
$rows = array();
|
{
|
||||||
|
$rows = [];
|
||||||
if (empty($this->id)) {
|
if (empty($this->id)) {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "SELECT * FROM live_transmitions_has_users_groups WHERE live_transmitions_id = ?";
|
$sql = "SELECT * FROM live_transmitions_has_users_groups WHERE live_transmitions_id = ?";
|
||||||
$res = sqlDAL::readSql($sql, "i", array($this->id));
|
$res = sqlDAL::readSql($sql, "i", [$this->id]);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
|
@ -310,7 +354,8 @@ class LiveTransmition extends ObjectYPT {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
function userCanSeeTransmition() {
|
public function userCanSeeTransmition()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
require_once $global['systemRootPath'] . 'objects/userGroups.php';
|
require_once $global['systemRootPath'] . 'objects/userGroups.php';
|
||||||
require_once $global['systemRootPath'] . 'objects/user.php';
|
require_once $global['systemRootPath'] . 'objects/user.php';
|
||||||
|
@ -350,43 +395,49 @@ class LiveTransmition extends ObjectYPT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getFromKey($key) {
|
public static function getFromKey($key)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
return self::keyExists($key);
|
return self::keyExists($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function keyNameFix($key){
|
public static function keyNameFix($key)
|
||||||
|
{
|
||||||
$key = str_replace('/', '', $key);
|
$key = str_replace('/', '', $key);
|
||||||
if(!empty($_REQUEST['live_index']) && !preg_match("/.*-([0-9a-zA-Z]+)/", $key)){
|
if (!empty($_REQUEST['live_index']) && !preg_match("/.*-([0-9a-zA-Z]+)/", $key)) {
|
||||||
if(!empty($_REQUEST['live_index']) && $_REQUEST['live_index']!=='false'){
|
if (!empty($_REQUEST['live_index']) && $_REQUEST['live_index']!=='false') {
|
||||||
$key .= "-{$_REQUEST['live_index']}";
|
$key .= "-{$_REQUEST['live_index']}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!empty($_REQUEST['playlists_id_live']) && !preg_match("/.*_([0-9]+)/", $key)){
|
if (!empty($_REQUEST['playlists_id_live']) && !preg_match("/.*_([0-9]+)/", $key)) {
|
||||||
$key .= "_{$_REQUEST['playlists_id_live']}";
|
$key .= "_{$_REQUEST['playlists_id_live']}";
|
||||||
}
|
}
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getShowOnTV() {
|
public function getShowOnTV()
|
||||||
|
{
|
||||||
return $this->showOnTV;
|
return $this->showOnTV;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setShowOnTV($showOnTV) {
|
public function setShowOnTV($showOnTV)
|
||||||
|
{
|
||||||
$this->showOnTV = $showOnTV;
|
$this->showOnTV = $showOnTV;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPassword() {
|
public function getPassword()
|
||||||
|
{
|
||||||
return $this->password;
|
return $this->password;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPassword($password): void {
|
public function setPassword($password): void
|
||||||
|
{
|
||||||
$this->password = trim($password);
|
$this->password = trim($password);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function canSaveTransmition($users_id){
|
public static function canSaveTransmition($users_id)
|
||||||
|
{
|
||||||
$lt = self::getFromDbByUser($users_id);
|
$lt = self::getFromDbByUser($users_id);
|
||||||
return !empty($lt['saveTransmition']);
|
return !empty($lt['saveTransmition']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,103 +4,136 @@ require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
require_once dirname(__FILE__) . '/../../../objects/bootGrid.php';
|
require_once dirname(__FILE__) . '/../../../objects/bootGrid.php';
|
||||||
require_once dirname(__FILE__) . '/../../../objects/user.php';
|
require_once dirname(__FILE__) . '/../../../objects/user.php';
|
||||||
|
|
||||||
class LiveTransmitionHistory extends ObjectYPT {
|
class LiveTransmitionHistory extends ObjectYPT
|
||||||
|
{
|
||||||
|
protected $id;
|
||||||
|
protected $title;
|
||||||
|
protected $description;
|
||||||
|
protected $key;
|
||||||
|
protected $created;
|
||||||
|
protected $modified;
|
||||||
|
protected $users_id;
|
||||||
|
protected $live_servers_id;
|
||||||
|
protected $finished;
|
||||||
|
protected $domain;
|
||||||
|
protected $json;
|
||||||
|
|
||||||
protected $id, $title, $description, $key, $created, $modified, $users_id, $live_servers_id, $finished, $domain, $json;
|
public static function getSearchFieldsNames()
|
||||||
|
{
|
||||||
static function getSearchFieldsNames() {
|
return ['title', 'description'];
|
||||||
return array('title', 'description');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTableName() {
|
public static function getTableName()
|
||||||
|
{
|
||||||
return 'live_transmitions_history';
|
return 'live_transmitions_history';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getId() {
|
public function getId()
|
||||||
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTitle() {
|
public function getTitle()
|
||||||
|
{
|
||||||
return $this->title;
|
return $this->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDescription() {
|
public function getDescription()
|
||||||
|
{
|
||||||
return $this->description;
|
return $this->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getKey() {
|
public function getKey()
|
||||||
|
{
|
||||||
return $this->key;
|
return $this->key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCreated() {
|
public function getCreated()
|
||||||
|
{
|
||||||
return $this->created;
|
return $this->created;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getModified() {
|
public function getModified()
|
||||||
|
{
|
||||||
return $this->modified;
|
return $this->modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsers_id() {
|
public function getUsers_id()
|
||||||
|
{
|
||||||
return $this->users_id;
|
return $this->users_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setId($id) {
|
public function setId($id)
|
||||||
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFinished() {
|
public function getFinished()
|
||||||
|
{
|
||||||
return $this->finished;
|
return $this->finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDomain() {
|
public function getDomain()
|
||||||
|
{
|
||||||
return $this->domain;
|
return $this->domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getJson() {
|
public function getJson()
|
||||||
|
{
|
||||||
return $this->json;
|
return $this->json;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDomain($domain) {
|
public function setDomain($domain)
|
||||||
|
{
|
||||||
$this->domain = $domain;
|
$this->domain = $domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setJson($json) {
|
public function setJson($json)
|
||||||
|
{
|
||||||
$this->json = $json;
|
$this->json = $json;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTitle($title) {
|
public function setTitle($title)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$title = $global['mysqli']->real_escape_string($title);
|
$title = $global['mysqli']->real_escape_string($title);
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDescription($description) {
|
public function setDescription($description)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$description = $global['mysqli']->real_escape_string($description);
|
$description = $global['mysqli']->real_escape_string($description);
|
||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setKey($key) {
|
public function setKey($key)
|
||||||
|
{
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCreated($created) {
|
public function setCreated($created)
|
||||||
|
{
|
||||||
$this->created = $created;
|
$this->created = $created;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setModified($modified) {
|
public function setModified($modified)
|
||||||
|
{
|
||||||
$this->modified = $modified;
|
$this->modified = $modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUsers_id($users_id) {
|
public function setUsers_id($users_id)
|
||||||
|
{
|
||||||
$this->users_id = $users_id;
|
$this->users_id = $users_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLive_servers_id() {
|
public function getLive_servers_id()
|
||||||
|
{
|
||||||
return intval($this->live_servers_id);
|
return intval($this->live_servers_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLive_index() {
|
public function getLive_index()
|
||||||
|
{
|
||||||
if (empty($this->key)) {
|
if (empty($this->key)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -108,7 +141,8 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return $parameters['live_index'];
|
return $parameters['live_index'];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLive_cleanKey() {
|
public function getLive_cleanKey()
|
||||||
|
{
|
||||||
if (empty($this->key)) {
|
if (empty($this->key)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -116,7 +150,8 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return $parameters['cleanKey'];
|
return $parameters['cleanKey'];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getApplicationObject($liveTransmitionHistory_id) {
|
public static function getApplicationObject($liveTransmitionHistory_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$lth = new LiveTransmitionHistory($liveTransmitionHistory_id);
|
$lth = new LiveTransmitionHistory($liveTransmitionHistory_id);
|
||||||
|
|
||||||
|
@ -149,7 +184,8 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return Live::getLiveApplicationModelArray($users_id, $title, $link, $imgJPG, $imgGIF, $type, $LiveUsersLabelLive, $uid, '', '', "live_{$key}");
|
return Live::getLiveApplicationModelArray($users_id, $title, $link, $imgJPG, $imgGIF, $type, $LiveUsersLabelLive, $uid, '', '', "live_{$key}");
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getStatsAndAddApplication($liveTransmitionHistory_id) {
|
public static function getStatsAndAddApplication($liveTransmitionHistory_id)
|
||||||
|
{
|
||||||
$stats = getStatsNotifications();
|
$stats = getStatsNotifications();
|
||||||
$lth = new LiveTransmitionHistory($liveTransmitionHistory_id);
|
$lth = new LiveTransmitionHistory($liveTransmitionHistory_id);
|
||||||
|
|
||||||
|
@ -194,10 +230,11 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return $stats;
|
return $stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getCleankeyName($key) {
|
public static function getCleankeyName($key)
|
||||||
|
{
|
||||||
$parts = explode("_", $key);
|
$parts = explode("_", $key);
|
||||||
if (!empty($parts[1])) {
|
if (!empty($parts[1])) {
|
||||||
$adaptive = array('hi', 'low', 'mid');
|
$adaptive = ['hi', 'low', 'mid'];
|
||||||
if (in_array($parts[1], $adaptive)) {
|
if (in_array($parts[1], $adaptive)) {
|
||||||
return $parts[0];
|
return $parts[0];
|
||||||
}
|
}
|
||||||
|
@ -205,7 +242,8 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getStatsAndRemoveApplication($liveTransmitionHistory_id) {
|
public static function getStatsAndRemoveApplication($liveTransmitionHistory_id)
|
||||||
|
{
|
||||||
$stats = getStatsNotifications();
|
$stats = getStatsNotifications();
|
||||||
$lth = new LiveTransmitionHistory($liveTransmitionHistory_id);
|
$lth = new LiveTransmitionHistory($liveTransmitionHistory_id);
|
||||||
|
|
||||||
|
@ -218,7 +256,7 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($stats['hidden_applications'])) {
|
if (empty($stats['hidden_applications'])) {
|
||||||
$stats['hidden_applications'] = array();
|
$stats['hidden_applications'] = [];
|
||||||
} else {
|
} else {
|
||||||
foreach ($stats['hidden_applications'] as $k => $value) {
|
foreach ($stats['hidden_applications'] as $k => $value) {
|
||||||
$value = object_to_array($value);
|
$value = object_to_array($value);
|
||||||
|
@ -233,19 +271,21 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return $stats;
|
return $stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLive_servers_id($live_servers_id) {
|
public function setLive_servers_id($live_servers_id)
|
||||||
|
{
|
||||||
$this->live_servers_id = intval($live_servers_id);
|
$this->live_servers_id = intval($live_servers_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAllFromUser($users_id) {
|
public static function getAllFromUser($users_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = ? ";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = ? ";
|
||||||
|
|
||||||
$sql .= self::getSqlFromPost();
|
$sql .= self::getSqlFromPost();
|
||||||
$res = sqlDAL::readSql($sql, "i", array($users_id));
|
$res = sqlDAL::readSql($sql, "i", [$users_id]);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$log = LiveTransmitionHistoryLog::getAllFromHistory($row['id']);
|
$log = LiveTransmitionHistoryLog::getAllFromHistory($row['id']);
|
||||||
|
@ -258,7 +298,8 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function isLive($key) {
|
public static function isLive($key)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
|
|
||||||
$row = self::getActiveLiveFromUser(0, '', $key);
|
$row = self::getActiveLiveFromUser(0, '', $key);
|
||||||
|
@ -268,7 +309,8 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return self::getApplicationObject($row['id']);
|
return self::getApplicationObject($row['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getLatest($key, $live_servers_id = null) {
|
public static function getLatest($key, $live_servers_id = null)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
|
|
||||||
$key = $global['mysqli']->real_escape_string($key);
|
$key = $global['mysqli']->real_escape_string($key);
|
||||||
|
@ -300,7 +342,8 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function finish($key) {
|
public static function finish($key)
|
||||||
|
{
|
||||||
$row = self::getLatest($key);
|
$row = self::getLatest($key);
|
||||||
if (empty($row) || empty($row['id']) || !empty($row['finished'])) {
|
if (empty($row) || empty($row['id']) || !empty($row['finished'])) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -309,7 +352,8 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return self::finishFromTransmitionHistoryId($row['id']);
|
return self::finishFromTransmitionHistoryId($row['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function finishFromTransmitionHistoryId($live_transmitions_history_id) {
|
public static function finishFromTransmitionHistoryId($live_transmitions_history_id)
|
||||||
|
{
|
||||||
$live_transmitions_history_id = intval($live_transmitions_history_id);
|
$live_transmitions_history_id = intval($live_transmitions_history_id);
|
||||||
if (empty($live_transmitions_history_id)) {
|
if (empty($live_transmitions_history_id)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -323,10 +367,11 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static function finishALL($olderThan = '') {
|
public static function finishALL($olderThan = '')
|
||||||
|
{
|
||||||
$sql = "UPDATE " . static::getTableName() . " SET finished = now() WHERE finished IS NULL ";
|
$sql = "UPDATE " . static::getTableName() . " SET finished = now() WHERE finished IS NULL ";
|
||||||
|
|
||||||
if(!empty($olderThan)){
|
if (!empty($olderThan)) {
|
||||||
$sql .= " modified < ".date('Y-m-d H:i:s', strtotime($olderThan));
|
$sql .= " modified < ".date('Y-m-d H:i:s', strtotime($olderThan));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,12 +380,14 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return $insert_row;
|
return $insert_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getLatestFromUser($users_id) {
|
public static function getLatestFromUser($users_id)
|
||||||
|
{
|
||||||
$rows = self::getLastsLiveHistoriesFromUser($users_id, 1);
|
$rows = self::getLastsLiveHistoriesFromUser($users_id, 1);
|
||||||
return @$rows[0];
|
return @$rows[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getLatestFromKey($key) {
|
public static function getLatestFromKey($key)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$parts = Live::getLiveParametersFromKey($key);
|
$parts = Live::getLiveParametersFromKey($key);
|
||||||
$key = $parts['cleanKey'];
|
$key = $parts['cleanKey'];
|
||||||
|
@ -359,19 +406,21 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getLatestIndexFromKey($key) {
|
public static function getLatestIndexFromKey($key)
|
||||||
|
{
|
||||||
$row = self::getLatestFromKey($key);
|
$row = self::getLatestFromKey($key);
|
||||||
return Live::getLiveIndexFromKey(@$row['key']);
|
return Live::getLiveIndexFromKey(@$row['key']);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getLastsLiveHistoriesFromUser($users_id, $count = 10) {
|
public static function getLastsLiveHistoriesFromUser($users_id, $count = 10)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE `users_id` = ? ORDER BY created DESC LIMIT ?";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE `users_id` = ? ORDER BY created DESC LIMIT ?";
|
||||||
|
|
||||||
$res = sqlDAL::readSql($sql, "ii", array($users_id, $count));
|
$res = sqlDAL::readSql($sql, "ii", [$users_id, $count]);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$log = LiveTransmitionHistoryLog::getAllFromHistory($row['id']);
|
$log = LiveTransmitionHistoryLog::getAllFromHistory($row['id']);
|
||||||
|
@ -384,12 +433,13 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getActiveLiveFromUser($users_id, $live_servers_id = '', $key = '', $count = 1) {
|
public static function getActiveLiveFromUser($users_id, $live_servers_id = '', $key = '', $count = 1)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE finished IS NULL ";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE finished IS NULL ";
|
||||||
|
|
||||||
$formats = "";
|
$formats = "";
|
||||||
$values = array();
|
$values = [];
|
||||||
|
|
||||||
if (!empty($users_id)) {
|
if (!empty($users_id)) {
|
||||||
$sql .= ' AND `users_id` = ? ';
|
$sql .= ' AND `users_id` = ? ';
|
||||||
|
@ -424,7 +474,7 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
} else {
|
} else {
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
$total = count($fullData);
|
$total = count($fullData);
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
|
@ -432,11 +482,11 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
// check if the m3u8 file still exists
|
// check if the m3u8 file still exists
|
||||||
$m3u8 = Live::getM3U8File($row['key']);
|
$m3u8 = Live::getM3U8File($row['key']);
|
||||||
$isURL200 = isValidM3U8Link($m3u8);
|
$isURL200 = isValidM3U8Link($m3u8);
|
||||||
if(empty($isURL200)){
|
if (empty($isURL200)) {
|
||||||
self::finishFromTransmitionHistoryId($row['id']);
|
self::finishFromTransmitionHistoryId($row['id']);
|
||||||
//var_dump($isURL200, $m3u8, $row);exit;
|
//var_dump($isURL200, $m3u8, $row);exit;
|
||||||
continue;
|
continue;
|
||||||
}else{
|
} else {
|
||||||
// update it to make sure the modified date is updated
|
// update it to make sure the modified date is updated
|
||||||
$lth = new LiveTransmitionHistory($row['id']);
|
$lth = new LiveTransmitionHistory($row['id']);
|
||||||
$lth->save();
|
$lth->save();
|
||||||
|
@ -453,7 +503,8 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save() {
|
public function save()
|
||||||
|
{
|
||||||
if (empty($this->live_servers_id)) {
|
if (empty($this->live_servers_id)) {
|
||||||
$this->live_servers_id = 'NULL';
|
$this->live_servers_id = 'NULL';
|
||||||
}
|
}
|
||||||
|
@ -464,7 +515,8 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
return parent::save();
|
return parent::save();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function deleteAllFromLiveServer($live_servers_id) {
|
public static function deleteAllFromLiveServer($live_servers_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$live_servers_id = intval($live_servers_id);
|
$live_servers_id = intval($live_servers_id);
|
||||||
if (!empty($live_servers_id)) {
|
if (!empty($live_servers_id)) {
|
||||||
|
@ -472,10 +524,10 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
$sql = "SELECT id FROM " . static::getTableName() . " WHERE live_servers_id = ? ";
|
$sql = "SELECT id FROM " . static::getTableName() . " WHERE live_servers_id = ? ";
|
||||||
|
|
||||||
$sql .= self::getSqlFromPost();
|
$sql .= self::getSqlFromPost();
|
||||||
$res = sqlDAL::readSql($sql, "i", array($live_servers_id));
|
$res = sqlDAL::readSql($sql, "i", [$live_servers_id]);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$lt = new LiveTransmitionHistory($row['id']);
|
$lt = new LiveTransmitionHistory($row['id']);
|
||||||
|
@ -485,11 +537,11 @@ class LiveTransmitionHistory extends ObjectYPT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete()
|
||||||
|
{
|
||||||
if (!empty($this->id)) {
|
if (!empty($this->id)) {
|
||||||
LiveTransmitionHistoryLog::deleteAllFromHistory($this->id);
|
LiveTransmitionHistoryLog::deleteAllFromHistory($this->id);
|
||||||
}
|
}
|
||||||
return parent::delete();
|
return parent::delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,43 +4,55 @@ require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
require_once dirname(__FILE__) . '/../../../objects/bootGrid.php';
|
require_once dirname(__FILE__) . '/../../../objects/bootGrid.php';
|
||||||
require_once dirname(__FILE__) . '/../../../objects/user.php';
|
require_once dirname(__FILE__) . '/../../../objects/user.php';
|
||||||
|
|
||||||
class LiveTransmitionHistoryLog extends ObjectYPT {
|
class LiveTransmitionHistoryLog extends ObjectYPT
|
||||||
|
{
|
||||||
|
protected $id;
|
||||||
|
protected $live_transmitions_history_id;
|
||||||
|
protected $users_id;
|
||||||
|
protected $session_id;
|
||||||
|
|
||||||
protected $id, $live_transmitions_history_id, $users_id, $session_id;
|
public static function getSearchFieldsNames()
|
||||||
|
{
|
||||||
static function getSearchFieldsNames() {
|
return [];
|
||||||
return array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTableName() {
|
public static function getTableName()
|
||||||
|
{
|
||||||
return 'live_transmition_history_log';
|
return 'live_transmition_history_log';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLive_transmitions_history_id() {
|
public function getLive_transmitions_history_id()
|
||||||
|
{
|
||||||
return $this->live_transmitions_history_id;
|
return $this->live_transmitions_history_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsers_id() {
|
public function getUsers_id()
|
||||||
|
{
|
||||||
return $this->users_id;
|
return $this->users_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSession_id() {
|
public function getSession_id()
|
||||||
|
{
|
||||||
return $this->session_id;
|
return $this->session_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLive_transmitions_history_id($live_transmitions_history_id) {
|
public function setLive_transmitions_history_id($live_transmitions_history_id)
|
||||||
|
{
|
||||||
$this->live_transmitions_history_id = $live_transmitions_history_id;
|
$this->live_transmitions_history_id = $live_transmitions_history_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUsers_id($users_id) {
|
public function setUsers_id($users_id)
|
||||||
|
{
|
||||||
$this->users_id = $users_id;
|
$this->users_id = $users_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSession_id($session_id) {
|
public function setSession_id($session_id)
|
||||||
|
{
|
||||||
$this->session_id = $session_id;
|
$this->session_id = $session_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function addLog($live_transmitions_history_id){
|
public static function addLog($live_transmitions_history_id)
|
||||||
|
{
|
||||||
$session_id = session_id();
|
$session_id = session_id();
|
||||||
$users_id = intval(User::getId());
|
$users_id = intval(User::getId());
|
||||||
|
|
||||||
|
@ -49,14 +61,14 @@ class LiveTransmitionHistoryLog extends ObjectYPT {
|
||||||
$log->setUsers_id($users_id);
|
$log->setUsers_id($users_id);
|
||||||
$log->setSession_id($session_id);
|
$log->setSession_id($session_id);
|
||||||
$log->save();
|
$log->save();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFromHistoryAndSession($live_transmitions_history_id, $session_id){
|
public function getFromHistoryAndSession($live_transmitions_history_id, $session_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE live_transmitions_history_id = ? AND session_id = ? ORDER BY created LIMIT 1";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE live_transmitions_history_id = ? AND session_id = ? ORDER BY created LIMIT 1";
|
||||||
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
|
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
|
||||||
$res = sqlDAL::readSql($sql,"is",array($live_transmitions_history_id, $session_id));
|
$res = sqlDAL::readSql($sql, "is", [$live_transmitions_history_id, $session_id]);
|
||||||
$data = sqlDAL::fetchAssoc($res);
|
$data = sqlDAL::fetchAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
if ($res) {
|
if ($res) {
|
||||||
|
@ -67,14 +79,15 @@ class LiveTransmitionHistoryLog extends ObjectYPT {
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAllFromHistory($live_transmitions_history_id) {
|
public static function getAllFromHistory($live_transmitions_history_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE live_transmitions_history_id={$live_transmitions_history_id} ";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE live_transmitions_history_id={$live_transmitions_history_id} ";
|
||||||
|
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res!=false) {
|
if ($res!=false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
|
@ -85,16 +98,18 @@ class LiveTransmitionHistoryLog extends ObjectYPT {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
public function save()
|
||||||
|
{
|
||||||
$row = $this->getFromHistoryAndSession($this->live_transmitions_history_id, $this->session_id);
|
$row = $this->getFromHistoryAndSession($this->live_transmitions_history_id, $this->session_id);
|
||||||
if(!empty($row)){
|
if (!empty($row)) {
|
||||||
$this->id = $row['id'];
|
$this->id = $row['id'];
|
||||||
}
|
}
|
||||||
return parent::save();
|
return parent::save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static function deleteAllFromHistory($live_transmitions_history_id) {
|
public static function deleteAllFromHistory($live_transmitions_history_id)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$live_transmitions_history_id = intval($live_transmitions_history_id);
|
$live_transmitions_history_id = intval($live_transmitions_history_id);
|
||||||
if (!empty($live_transmitions_history_id)) {
|
if (!empty($live_transmitions_history_id)) {
|
||||||
|
@ -102,9 +117,8 @@ class LiveTransmitionHistoryLog extends ObjectYPT {
|
||||||
$sql .= " WHERE live_transmitions_history_id = ?";
|
$sql .= " WHERE live_transmitions_history_id = ?";
|
||||||
$global['lastQuery'] = $sql;
|
$global['lastQuery'] = $sql;
|
||||||
//_error_log("Delete Query: ".$sql);
|
//_error_log("Delete Query: ".$sql);
|
||||||
return sqlDAL::writeSql($sql, "i", array($live_transmitions_history_id));
|
return sqlDAL::writeSql($sql, "i", [$live_transmitions_history_id]);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,90 +2,113 @@
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
|
|
||||||
class Live_restreams extends ObjectYPT {
|
class Live_restreams extends ObjectYPT
|
||||||
|
{
|
||||||
|
protected $id;
|
||||||
|
protected $name;
|
||||||
|
protected $stream_url;
|
||||||
|
protected $stream_key;
|
||||||
|
protected $status;
|
||||||
|
protected $parameters;
|
||||||
|
protected $users_id;
|
||||||
|
|
||||||
protected $id,$name,$stream_url,$stream_key,$status,$parameters,$users_id;
|
public static function getSearchFieldsNames()
|
||||||
|
{
|
||||||
static function getSearchFieldsNames() {
|
return ['name','stream_url','stream_key','parameters'];
|
||||||
return array('name','stream_url','stream_key','parameters');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTableName() {
|
public static function getTableName()
|
||||||
|
{
|
||||||
return 'live_restreams';
|
return 'live_restreams';
|
||||||
}
|
}
|
||||||
|
|
||||||
function setId($id) {
|
public function setId($id)
|
||||||
|
{
|
||||||
$this->id = intval($id);
|
$this->id = intval($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setName($name) {
|
public function setName($name)
|
||||||
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStream_url($stream_url) {
|
public function setStream_url($stream_url)
|
||||||
|
{
|
||||||
$this->stream_url = $stream_url;
|
$this->stream_url = $stream_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStream_key($stream_key) {
|
public function setStream_key($stream_key)
|
||||||
|
{
|
||||||
$this->stream_key = $stream_key;
|
$this->stream_key = $stream_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStatus($status) {
|
public function setStatus($status)
|
||||||
|
{
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setParameters($parameters) {
|
public function setParameters($parameters)
|
||||||
|
{
|
||||||
$this->parameters = $parameters;
|
$this->parameters = $parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUsers_id($users_id) {
|
public function setUsers_id($users_id)
|
||||||
|
{
|
||||||
$this->users_id = intval($users_id);
|
$this->users_id = intval($users_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getId() {
|
public function getId()
|
||||||
|
{
|
||||||
return intval($this->id);
|
return intval($this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStream_url() {
|
public function getStream_url()
|
||||||
|
{
|
||||||
return $this->stream_url;
|
return $this->stream_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStream_key() {
|
public function getStream_key()
|
||||||
|
{
|
||||||
return $this->stream_key;
|
return $this->stream_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatus() {
|
public function getStatus()
|
||||||
|
{
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getParameters() {
|
public function getParameters()
|
||||||
|
{
|
||||||
return $this->parameters;
|
return $this->parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsers_id() {
|
public function getUsers_id()
|
||||||
|
{
|
||||||
return intval($this->users_id);
|
return intval($this->users_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static function getAllFromUser($users_id, $status = 'a') {
|
public static function getAllFromUser($users_id, $status = 'a')
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (!static::isTableInstalled()) {
|
if (!static::isTableInstalled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$users_id = intval($users_id);
|
$users_id = intval($users_id);
|
||||||
if(empty($users_id)){
|
if (empty($users_id)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = $users_id ";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = $users_id ";
|
||||||
|
|
||||||
if(!empty($status)){
|
if (!empty($status)) {
|
||||||
$sql .= " AND status = '$status' " ;
|
$sql .= " AND status = '$status' " ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +116,7 @@ class Live_restreams extends ObjectYPT {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
|
@ -103,5 +126,4 @@ class Live_restreams extends ObjectYPT {
|
||||||
}
|
}
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,19 +2,34 @@
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
|
|
||||||
class Live_schedule extends ObjectYPT {
|
class Live_schedule extends ObjectYPT
|
||||||
|
{
|
||||||
|
protected $id;
|
||||||
|
protected $title;
|
||||||
|
protected $description;
|
||||||
|
protected $key;
|
||||||
|
protected $users_id;
|
||||||
|
protected $live_servers_id;
|
||||||
|
protected $scheduled_time;
|
||||||
|
protected $timezone;
|
||||||
|
protected $status;
|
||||||
|
protected $poster;
|
||||||
|
protected $public;
|
||||||
|
protected $saveTransmition;
|
||||||
|
protected $showOnTV;
|
||||||
|
|
||||||
protected $id, $title, $description, $key, $users_id, $live_servers_id, $scheduled_time, $timezone, $status, $poster, $public, $saveTransmition, $showOnTV;
|
public static function getSearchFieldsNames()
|
||||||
|
{
|
||||||
static function getSearchFieldsNames() {
|
return ['title', 'description', 'key', 'timezone', 'poster'];
|
||||||
return array('title', 'description', 'key', 'timezone', 'poster');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTableName() {
|
public static function getTableName()
|
||||||
|
{
|
||||||
return 'live_schedule';
|
return 'live_schedule';
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAllUsers() {
|
public static function getAllUsers()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$table = "users";
|
$table = "users";
|
||||||
$sql = "SELECT * FROM {$table} WHERE 1=1 ";
|
$sql = "SELECT * FROM {$table} WHERE 1=1 ";
|
||||||
|
@ -23,7 +38,7 @@ class Live_schedule extends ObjectYPT {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
|
@ -34,7 +49,8 @@ class Live_schedule extends ObjectYPT {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAllLive_servers() {
|
public static function getAllLive_servers()
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
$table = "live_servers";
|
$table = "live_servers";
|
||||||
$sql = "SELECT * FROM {$table} WHERE 1=1 ";
|
$sql = "SELECT * FROM {$table} WHERE 1=1 ";
|
||||||
|
@ -43,7 +59,7 @@ class Live_schedule extends ObjectYPT {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
|
@ -54,7 +70,8 @@ class Live_schedule extends ObjectYPT {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getPosterPaths($live_schedule_id) {
|
public static function getPosterPaths($live_schedule_id)
|
||||||
|
{
|
||||||
$live_schedule_id = intval($live_schedule_id);
|
$live_schedule_id = intval($live_schedule_id);
|
||||||
if (empty($live_schedule_id)) {
|
if (empty($live_schedule_id)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -62,7 +79,7 @@ class Live_schedule extends ObjectYPT {
|
||||||
|
|
||||||
$subdir = "live_schedule_posters";
|
$subdir = "live_schedule_posters";
|
||||||
|
|
||||||
$array = array();
|
$array = [];
|
||||||
|
|
||||||
$array['path'] = getVideosDir() . $subdir . DIRECTORY_SEPARATOR;
|
$array['path'] = getVideosDir() . $subdir . DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
|
@ -79,7 +96,8 @@ class Live_schedule extends ObjectYPT {
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getPosterURL($live_schedule_id) {
|
public static function getPosterURL($live_schedule_id)
|
||||||
|
{
|
||||||
$paths = self::getPosterPaths($live_schedule_id);
|
$paths = self::getPosterPaths($live_schedule_id);
|
||||||
if (file_exists($paths['path'])) {
|
if (file_exists($paths['path'])) {
|
||||||
return $paths['url'];
|
return $paths['url'];
|
||||||
|
@ -88,24 +106,25 @@ class Live_schedule extends ObjectYPT {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAll($users_id=0, $activeHoursAgo=false) {
|
public static function getAll($users_id=0, $activeHoursAgo=false)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (!static::isTableInstalled()) {
|
if (!static::isTableInstalled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$users_id = intval($users_id);
|
$users_id = intval($users_id);
|
||||||
$sql = "SELECT * FROM " . static::getTableName() . " WHERE 1=1 ";
|
$sql = "SELECT * FROM " . static::getTableName() . " WHERE 1=1 ";
|
||||||
if(!empty($users_id)){
|
if (!empty($users_id)) {
|
||||||
$sql .= " AND users_id = $users_id ";
|
$sql .= " AND users_id = $users_id ";
|
||||||
}
|
}
|
||||||
if($activeHoursAgo){
|
if ($activeHoursAgo) {
|
||||||
$sql .= " AND scheduled_time > DATE_SUB(NOW(), INTERVAL {$activeHoursAgo} HOUR) ";
|
$sql .= " AND scheduled_time > DATE_SUB(NOW(), INTERVAL {$activeHoursAgo} HOUR) ";
|
||||||
}
|
}
|
||||||
$sql .= self::getSqlFromPost();
|
$sql .= self::getSqlFromPost();
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$row['future'] = isTimeForFuture($row['scheduled_time'], $row['timezone']);
|
$row['future'] = isTimeForFuture($row['scheduled_time'], $row['timezone']);
|
||||||
|
@ -122,7 +141,8 @@ class Live_schedule extends ObjectYPT {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getAllActiveLimit($limit = 10) {
|
public static function getAllActiveLimit($limit = 10)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (!static::isTableInstalled()) {
|
if (!static::isTableInstalled()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -136,7 +156,7 @@ class Live_schedule extends ObjectYPT {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
|
@ -147,112 +167,138 @@ class Live_schedule extends ObjectYPT {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setId($id) {
|
public function setId($id)
|
||||||
|
{
|
||||||
$this->id = intval($id);
|
$this->id = intval($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTitle($title) {
|
public function setTitle($title)
|
||||||
|
{
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDescription($description) {
|
public function setDescription($description)
|
||||||
|
{
|
||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setKey($key) {
|
public function setKey($key)
|
||||||
|
{
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUsers_id($users_id) {
|
public function setUsers_id($users_id)
|
||||||
|
{
|
||||||
$this->users_id = intval($users_id);
|
$this->users_id = intval($users_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setLive_servers_id($live_servers_id) {
|
public function setLive_servers_id($live_servers_id)
|
||||||
|
{
|
||||||
$this->live_servers_id = intval($live_servers_id);
|
$this->live_servers_id = intval($live_servers_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setScheduled_time($scheduled_time) {
|
public function setScheduled_time($scheduled_time)
|
||||||
|
{
|
||||||
$this->scheduled_time = $scheduled_time;
|
$this->scheduled_time = $scheduled_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _setTimezone($timezone) {
|
private function _setTimezone($timezone)
|
||||||
|
{
|
||||||
$this->timezone = $timezone;
|
$this->timezone = $timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStatus($status) {
|
public function setStatus($status)
|
||||||
|
{
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPoster($poster) {
|
public function setPoster($poster)
|
||||||
|
{
|
||||||
$this->poster = $poster;
|
$this->poster = $poster;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPublic($public) {
|
public function setPublic($public)
|
||||||
|
{
|
||||||
$this->public = intval($public);
|
$this->public = intval($public);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSaveTransmition($saveTransmition) {
|
public function setSaveTransmition($saveTransmition)
|
||||||
|
{
|
||||||
$this->saveTransmition = intval($saveTransmition);
|
$this->saveTransmition = intval($saveTransmition);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setShowOnTV($showOnTV) {
|
public function setShowOnTV($showOnTV)
|
||||||
|
{
|
||||||
$this->showOnTV = intval($showOnTV);
|
$this->showOnTV = intval($showOnTV);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getId() {
|
public function getId()
|
||||||
|
{
|
||||||
return intval($this->id);
|
return intval($this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTitle() {
|
public function getTitle()
|
||||||
|
{
|
||||||
return $this->title;
|
return $this->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDescription() {
|
public function getDescription()
|
||||||
|
{
|
||||||
return $this->description;
|
return $this->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getKey() {
|
public function getKey()
|
||||||
|
{
|
||||||
return $this->key;
|
return $this->key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUsers_id() {
|
public function getUsers_id()
|
||||||
|
{
|
||||||
return intval($this->users_id);
|
return intval($this->users_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLive_servers_id() {
|
public function getLive_servers_id()
|
||||||
|
{
|
||||||
return intval($this->live_servers_id);
|
return intval($this->live_servers_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getScheduled_time() {
|
public function getScheduled_time()
|
||||||
|
{
|
||||||
return $this->scheduled_time;
|
return $this->scheduled_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimezone() {
|
public function getTimezone()
|
||||||
|
{
|
||||||
return $this->timezone;
|
return $this->timezone;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatus() {
|
public function getStatus()
|
||||||
|
{
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPoster() {
|
public function getPoster()
|
||||||
|
{
|
||||||
return $this->poster;
|
return $this->poster;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPublic() {
|
public function getPublic()
|
||||||
|
{
|
||||||
return intval($this->public);
|
return intval($this->public);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSaveTransmition() {
|
public function getSaveTransmition()
|
||||||
|
{
|
||||||
return intval($this->saveTransmition);
|
return intval($this->saveTransmition);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getShowOnTV() {
|
public function getShowOnTV()
|
||||||
|
{
|
||||||
return intval($this->showOnTV);
|
return intval($this->showOnTV);
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
public function save()
|
||||||
|
{
|
||||||
if (empty($this->live_servers_id)) {
|
if (empty($this->live_servers_id)) {
|
||||||
$this->live_servers_id = 'NULL';
|
$this->live_servers_id = 'NULL';
|
||||||
}
|
}
|
||||||
|
@ -281,7 +327,7 @@ class Live_schedule extends ObjectYPT {
|
||||||
$id = parent::save();
|
$id = parent::save();
|
||||||
|
|
||||||
if (!empty($id)) {
|
if (!empty($id)) {
|
||||||
$array = array();
|
$array = [];
|
||||||
$array['users_id'] = $this->users_id;
|
$array['users_id'] = $this->users_id;
|
||||||
$array['stats'] = getStatsNotifications(true);
|
$array['stats'] = getStatsNotifications(true);
|
||||||
$array['key'] = $this->key;
|
$array['key'] = $this->key;
|
||||||
|
@ -293,7 +339,8 @@ class Live_schedule extends ObjectYPT {
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete()
|
||||||
|
{
|
||||||
$t = new Live_schedule($this->id);
|
$t = new Live_schedule($this->id);
|
||||||
$array = setLiveKey($t->key, $t->live_servers_id);
|
$array = setLiveKey($t->key, $t->live_servers_id);
|
||||||
$id = parent::delete();
|
$id = parent::delete();
|
||||||
|
@ -305,14 +352,16 @@ class Live_schedule extends ObjectYPT {
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function clearScheduleCache(){
|
public static function clearScheduleCache()
|
||||||
|
{
|
||||||
clearCache(true);
|
clearCache(true);
|
||||||
deleteStatsNotifications();
|
deleteStatsNotifications();
|
||||||
//ObjectYPT::deleteAllSessionCache();
|
//ObjectYPT::deleteAllSessionCache();
|
||||||
ObjectYPT::deleteALLCache();
|
ObjectYPT::deleteALLCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
static function keyExists($key) {
|
public static function keyExists($key)
|
||||||
|
{
|
||||||
global $global;
|
global $global;
|
||||||
if (!is_string($key)) {
|
if (!is_string($key)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -2,146 +2,193 @@
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
|
||||||
|
|
||||||
class Live_servers extends ObjectYPT {
|
class Live_servers extends ObjectYPT
|
||||||
|
{
|
||||||
|
protected $id;
|
||||||
|
protected $name;
|
||||||
|
protected $url;
|
||||||
|
protected $status;
|
||||||
|
protected $rtmp_server;
|
||||||
|
protected $playerServer;
|
||||||
|
protected $stats_url;
|
||||||
|
protected $disableDVR;
|
||||||
|
protected $disableGifThumbs;
|
||||||
|
protected $useAadaptiveMode;
|
||||||
|
protected $protectLive;
|
||||||
|
protected $getRemoteFile;
|
||||||
|
protected $restreamerURL;
|
||||||
|
protected $controlURL;
|
||||||
|
protected $webRTC_server;
|
||||||
|
|
||||||
protected $id, $name, $url, $status, $rtmp_server, $playerServer, $stats_url, $disableDVR, $disableGifThumbs, $useAadaptiveMode, $protectLive, $getRemoteFile, $restreamerURL, $controlURL, $webRTC_server;
|
public static function getSearchFieldsNames()
|
||||||
|
{
|
||||||
static function getSearchFieldsNames() {
|
return ['name', 'url', 'rtmp_server', 'playerServer', 'stats_url', 'getRemoteFile'];
|
||||||
return array('name', 'url', 'rtmp_server', 'playerServer', 'stats_url', 'getRemoteFile');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getTableName() {
|
public static function getTableName()
|
||||||
|
{
|
||||||
return 'live_servers';
|
return 'live_servers';
|
||||||
}
|
}
|
||||||
|
|
||||||
function setId($id) {
|
public function setId($id)
|
||||||
|
{
|
||||||
$this->id = intval($id);
|
$this->id = intval($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setName($name) {
|
public function setName($name)
|
||||||
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUrl($url) {
|
public function setUrl($url)
|
||||||
|
{
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStatus($status) {
|
public function setStatus($status)
|
||||||
|
{
|
||||||
$this->status = $status;
|
$this->status = $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRtmp_server($rtmp_server) {
|
public function setRtmp_server($rtmp_server)
|
||||||
|
{
|
||||||
$this->rtmp_server = $rtmp_server;
|
$this->rtmp_server = $rtmp_server;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPlayerServer($playerServer) {
|
public function setPlayerServer($playerServer)
|
||||||
|
{
|
||||||
$this->playerServer = $playerServer;
|
$this->playerServer = $playerServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStats_url($stats_url) {
|
public function setStats_url($stats_url)
|
||||||
|
{
|
||||||
$this->stats_url = $stats_url;
|
$this->stats_url = $stats_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDisableDVR($disableDVR) {
|
public function setDisableDVR($disableDVR)
|
||||||
|
{
|
||||||
$this->disableDVR = intval($disableDVR);
|
$this->disableDVR = intval($disableDVR);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDisableGifThumbs($disableGifThumbs) {
|
public function setDisableGifThumbs($disableGifThumbs)
|
||||||
|
{
|
||||||
$this->disableGifThumbs = intval($disableGifThumbs);
|
$this->disableGifThumbs = intval($disableGifThumbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUseAadaptiveMode($useAadaptiveMode) {
|
public function setUseAadaptiveMode($useAadaptiveMode)
|
||||||
|
{
|
||||||
$this->useAadaptiveMode = intval($useAadaptiveMode);
|
$this->useAadaptiveMode = intval($useAadaptiveMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setProtectLive($protectLive) {
|
public function setProtectLive($protectLive)
|
||||||
|
{
|
||||||
$this->protectLive = intval($protectLive);
|
$this->protectLive = intval($protectLive);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setGetRemoteFile($getRemoteFile) {
|
public function setGetRemoteFile($getRemoteFile)
|
||||||
|
{
|
||||||
$this->getRemoteFile = $getRemoteFile;
|
$this->getRemoteFile = $getRemoteFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getId() {
|
public function getId()
|
||||||
|
{
|
||||||
return intval($this->id);
|
return intval($this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getName() {
|
public function getName()
|
||||||
|
{
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUrl() {
|
public function getUrl()
|
||||||
|
{
|
||||||
return $this->url;
|
return $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStatus() {
|
public function getStatus()
|
||||||
|
{
|
||||||
return $this->status;
|
return $this->status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRtmp_server() {
|
public function getRtmp_server()
|
||||||
|
{
|
||||||
return trim($this->rtmp_server);
|
return trim($this->rtmp_server);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPlayerServer() {
|
public function getPlayerServer()
|
||||||
|
{
|
||||||
return $this->playerServer;
|
return $this->playerServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getStats_url() {
|
public function getStats_url()
|
||||||
|
{
|
||||||
return $this->stats_url;
|
return $this->stats_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDisableDVR() {
|
public function getDisableDVR()
|
||||||
|
{
|
||||||
return intval($this->disableDVR);
|
return intval($this->disableDVR);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDisableGifThumbs() {
|
public function getDisableGifThumbs()
|
||||||
|
{
|
||||||
return intval($this->disableGifThumbs);
|
return intval($this->disableGifThumbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUseAadaptiveMode() {
|
public function getUseAadaptiveMode()
|
||||||
|
{
|
||||||
return intval($this->useAadaptiveMode);
|
return intval($this->useAadaptiveMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getProtectLive() {
|
public function getProtectLive()
|
||||||
|
{
|
||||||
return intval($this->protectLive);
|
return intval($this->protectLive);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGetRemoteFile() {
|
public function getGetRemoteFile()
|
||||||
|
{
|
||||||
return $this->getRemoteFile;
|
return $this->getRemoteFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRestreamerURL() {
|
public function getRestreamerURL()
|
||||||
|
{
|
||||||
return $this->restreamerURL;
|
return $this->restreamerURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setRestreamerURL($restreamerURL) {
|
public function setRestreamerURL($restreamerURL)
|
||||||
|
{
|
||||||
$this->restreamerURL = $restreamerURL;
|
$this->restreamerURL = $restreamerURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getControlURL() {
|
public function getControlURL()
|
||||||
|
{
|
||||||
return $this->controlURL;
|
return $this->controlURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setControlURL($controlURL) {
|
public function setControlURL($controlURL)
|
||||||
|
{
|
||||||
$this->controlURL = $controlURL;
|
$this->controlURL = $controlURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getwebRTC_server() {
|
public function getwebRTC_server()
|
||||||
|
{
|
||||||
return $this->webRTC_server;
|
return $this->webRTC_server;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setwebRTC_server($webRTC_server) {
|
public function setwebRTC_server($webRTC_server)
|
||||||
|
{
|
||||||
$this->webRTC_server = addLastSlash($webRTC_server);
|
$this->webRTC_server = addLastSlash($webRTC_server);
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getStatsFromId($live_servers_id, $force_recreate = false) {
|
public static function getStatsFromId($live_servers_id, $force_recreate = false)
|
||||||
|
{
|
||||||
global $_getStatsFromId;
|
global $_getStatsFromId;
|
||||||
if(empty($force_recreate)){
|
if (empty($force_recreate)) {
|
||||||
if(!isset($_getStatsFromId)){
|
if (!isset($_getStatsFromId)) {
|
||||||
$_getStatsFromId = array();
|
$_getStatsFromId = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($_getStatsFromId[$live_servers_id])){
|
if (isset($_getStatsFromId[$live_servers_id])) {
|
||||||
return $_getStatsFromId[$live_servers_id];
|
return $_getStatsFromId[$live_servers_id];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,15 +196,16 @@ class Live_servers extends ObjectYPT {
|
||||||
if (empty($ls->getStatus()) || $ls->getStatus()=='i') {
|
if (empty($ls->getStatus()) || $ls->getStatus()=='i') {
|
||||||
_error_log("Live_servers:: getStatsFromId ERROR ".json_encode($ls));
|
_error_log("Live_servers:: getStatsFromId ERROR ".json_encode($ls));
|
||||||
$_getStatsFromId[$live_servers_id] = false;
|
$_getStatsFromId[$live_servers_id] = false;
|
||||||
}else{
|
} else {
|
||||||
$_getStatsFromId[$live_servers_id] = Live::_getStats($live_servers_id, $force_recreate);
|
$_getStatsFromId[$live_servers_id] = Live::_getStats($live_servers_id, $force_recreate);
|
||||||
}
|
}
|
||||||
return $_getStatsFromId[$live_servers_id];
|
return $_getStatsFromId[$live_servers_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getAllActive() {
|
public static function getAllActive()
|
||||||
|
{
|
||||||
global $global, $liveServersgetAllActive;
|
global $global, $liveServersgetAllActive;
|
||||||
if(isset($liveServersgetAllActive)){
|
if (isset($liveServersgetAllActive)) {
|
||||||
return $liveServersgetAllActive;
|
return $liveServersgetAllActive;
|
||||||
}
|
}
|
||||||
if (!static::isTableInstalled()) {
|
if (!static::isTableInstalled()) {
|
||||||
|
@ -169,7 +217,7 @@ class Live_servers extends ObjectYPT {
|
||||||
$res = sqlDAL::readSql($sql);
|
$res = sqlDAL::readSql($sql);
|
||||||
$fullData = sqlDAL::fetchAllAssoc($res);
|
$fullData = sqlDAL::fetchAllAssoc($res);
|
||||||
sqlDAL::close($res);
|
sqlDAL::close($res);
|
||||||
$rows = array();
|
$rows = [];
|
||||||
if ($res != false) {
|
if ($res != false) {
|
||||||
foreach ($fullData as $row) {
|
foreach ($fullData as $row) {
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
|
@ -181,9 +229,10 @@ class Live_servers extends ObjectYPT {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getServerFromRTMPHost($rtmpHostURI) {
|
public static function getServerFromRTMPHost($rtmpHostURI)
|
||||||
|
{
|
||||||
$obj = AVideoPlugin::getObjectData('Live');
|
$obj = AVideoPlugin::getObjectData('Live');
|
||||||
if(empty($obj->useLiveServers)){
|
if (empty($obj->useLiveServers)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
global $global;
|
global $global;
|
||||||
|
@ -203,7 +252,8 @@ class Live_servers extends ObjectYPT {
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function getServerIdFromRTMPHost($rtmpHostURI) {
|
public static function getServerIdFromRTMPHost($rtmpHostURI)
|
||||||
|
{
|
||||||
$data = self::getServerFromRTMPHost($rtmpHostURI);
|
$data = self::getServerFromRTMPHost($rtmpHostURI);
|
||||||
if ($data) {
|
if ($data) {
|
||||||
$row = $data['id'];
|
$row = $data['id'];
|
||||||
|
@ -213,23 +263,23 @@ class Live_servers extends ObjectYPT {
|
||||||
return intval($row);
|
return intval($row);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save() {
|
public function save()
|
||||||
|
{
|
||||||
$id = parent::save();
|
$id = parent::save();
|
||||||
if($id){
|
if ($id) {
|
||||||
_session_start();
|
_session_start();
|
||||||
$_SESSION['useAadaptiveMode'] = array();
|
$_SESSION['useAadaptiveMode'] = [];
|
||||||
$_SESSION['playerServer'] = array();
|
$_SESSION['playerServer'] = [];
|
||||||
}
|
}
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete() {
|
public function delete()
|
||||||
|
{
|
||||||
if(!empty($this->id)){
|
if (!empty($this->id)) {
|
||||||
LiveTransmitionHistory::deleteAllFromLiveServer($this->id);
|
LiveTransmitionHistory::deleteAllFromLiveServer($this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::delete();
|
return parent::delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once dirname(__FILE__) . '/../../videos/configuration.php';
|
require_once dirname(__FILE__) . '/../../videos/configuration.php';
|
||||||
if (!isset($global['systemRootPath'])) {
|
if (!isset($global['systemRootPath'])) {
|
||||||
$configFile = '../../videos/configuration.php';
|
$configFile = '../../videos/configuration.php';
|
||||||
|
|
|
@ -19,12 +19,12 @@ foreach ($files as $file) {
|
||||||
preg_match($pattern, $file, $matches);
|
preg_match($pattern, $file, $matches);
|
||||||
if (!empty($matches[1])) {
|
if (!empty($matches[1])) {
|
||||||
$filePath = $file;
|
$filePath = $file;
|
||||||
$postFields = array(
|
$postFields = [
|
||||||
"app" => "live",
|
"app" => "live",
|
||||||
"tcurl" => "rtmp://$liveServerURL:1935/live",
|
"tcurl" => "rtmp://$liveServerURL:1935/live",
|
||||||
"name" => $matches[1],
|
"name" => $matches[1],
|
||||||
"path" => $filePath
|
"path" => $filePath,
|
||||||
);
|
];
|
||||||
$target = $streamerServerURL . "plugin/Live/on_record_done.php?secretRecorderKey={$secretRecorderKey}";
|
$target = $streamerServerURL . "plugin/Live/on_record_done.php?secretRecorderKey={$secretRecorderKey}";
|
||||||
echo "Sending to $target filesize=". humanFileSize(filesize($filePath))." ". json_encode($postFields).PHP_EOL;
|
echo "Sending to $target filesize=". humanFileSize(filesize($filePath))." ". json_encode($postFields).PHP_EOL;
|
||||||
$curl = curl_init();
|
$curl = curl_init();
|
||||||
|
@ -33,8 +33,8 @@ foreach ($files as $file) {
|
||||||
curl_setopt($curl, CURLOPT_POST, 1);
|
curl_setopt($curl, CURLOPT_POST, 1);
|
||||||
curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true);
|
curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true);
|
||||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||||
$r = curl_exec($curl);
|
$r = curl_exec($curl);
|
||||||
if ($errno = curl_errno($curl)) {
|
if ($errno = curl_errno($curl)) {
|
||||||
$error_message = curl_strerror($errno);
|
$error_message = curl_strerror($errno);
|
||||||
|
@ -44,12 +44,13 @@ foreach ($files as $file) {
|
||||||
echo " **** Success ".$r.PHP_EOL;
|
echo " **** Success ".$r.PHP_EOL;
|
||||||
}
|
}
|
||||||
curl_close($curl);
|
curl_close($curl);
|
||||||
}else{
|
} else {
|
||||||
echo "ERROR pattern does not match ".PHP_EOL;
|
echo "ERROR pattern does not match ".PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function humanFileSize($size, $unit = "") {
|
function humanFileSize($size, $unit = "")
|
||||||
|
{
|
||||||
if ((!$unit && $size >= 1 << 30) || $unit == "GB") {
|
if ((!$unit && $size >= 1 << 30) || $unit == "GB") {
|
||||||
return number_format($size / (1 << 30), 2) . "GB";
|
return number_format($size / (1 << 30), 2) . "GB";
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ require_once '../../videos/configuration.php';
|
||||||
|
|
||||||
$key = @$_REQUEST['key'];
|
$key = @$_REQUEST['key'];
|
||||||
|
|
||||||
if(empty($key)){
|
if (empty($key)) {
|
||||||
forbiddenPage('Key is undefined');
|
forbiddenPage('Key is undefined');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,7 @@ switch ($obj->command) {
|
||||||
break;
|
break;
|
||||||
case "drop_publisher_reset_key":
|
case "drop_publisher_reset_key":
|
||||||
$obj->newkey = LiveTransmition::resetTransmitionKey($l->getUsers_id());
|
$obj->newkey = LiveTransmition::resetTransmitionKey($l->getUsers_id());
|
||||||
|
// no break
|
||||||
case "drop_publisher":
|
case "drop_publisher":
|
||||||
//http://server.com/control/drop/publisher|subscriber|client?srv=SRV&app=APP&name=NAME&addr=ADDR&clientid=CLIENTID
|
//http://server.com/control/drop/publisher|subscriber|client?srv=SRV&app=APP&name=NAME&addr=ADDR&clientid=CLIENTID
|
||||||
$obj->commandURL = Live::getDropURL($obj->key, $obj->live_servers_id);
|
$obj->commandURL = Live::getDropURL($obj->key, $obj->live_servers_id);
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$lifetime = 300;
|
$lifetime = 300;
|
||||||
|
|
||||||
if (empty($_REQUEST['format'])) {
|
if (empty($_REQUEST['format'])) {
|
||||||
$_REQUEST['format'] = "png";
|
$_REQUEST['format'] = "png";
|
||||||
header('Content-Type: image/x-png');
|
header('Content-Type: image/x-png');
|
||||||
} else if ($_REQUEST['format'] === 'jpg') {
|
} elseif ($_REQUEST['format'] === 'jpg') {
|
||||||
header('Content-Type: image/jpg');
|
header('Content-Type: image/jpg');
|
||||||
} else if ($_REQUEST['format'] === 'gif') {
|
} elseif ($_REQUEST['format'] === 'gif') {
|
||||||
header('Content-Type: image/gif');
|
header('Content-Type: image/gif');
|
||||||
$lifetime *= 3;
|
$lifetime *= 3;
|
||||||
} else if ($_REQUEST['format'] === 'webp') {
|
} elseif ($_REQUEST['format'] === 'webp') {
|
||||||
header('Content-Type: image/webp');
|
header('Content-Type: image/webp');
|
||||||
$lifetime *= 3;
|
$lifetime *= 3;
|
||||||
} else {
|
} else {
|
||||||
|
@ -23,7 +24,7 @@ $f = md5(@$_REQUEST['u'] . @$_REQUEST['live_servers_id'] . @$_REQUEST['live_inde
|
||||||
$cacheFileImageName = dirname(__FILE__) . "/../../videos/cache/liveImage_{$f}.{$_REQUEST['format']}";
|
$cacheFileImageName = dirname(__FILE__) . "/../../videos/cache/liveImage_{$f}.{$_REQUEST['format']}";
|
||||||
if (file_exists($cacheFileImageName) && (time() - $lifetime <= filemtime($cacheFileImageName))) {
|
if (file_exists($cacheFileImageName) && (time() - $lifetime <= filemtime($cacheFileImageName))) {
|
||||||
$content = file_get_contents($cacheFileImageName);
|
$content = file_get_contents($cacheFileImageName);
|
||||||
if(!empty($content)){
|
if (!empty($content)) {
|
||||||
echo $content;
|
echo $content;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +42,7 @@ if (!empty($_GET['c'])) {
|
||||||
}
|
}
|
||||||
$livet = LiveTransmition::getFromRequest();
|
$livet = LiveTransmition::getFromRequest();
|
||||||
//header('Content-Type: text/plain');var_dump($livet);exit;
|
//header('Content-Type: text/plain');var_dump($livet);exit;
|
||||||
if(!empty($_REQUEST['live_schedule']) && !empty($livet['scheduled_time']) && isTimeForFuture($livet['scheduled_time'], $livet['timezone'])){
|
if (!empty($_REQUEST['live_schedule']) && !empty($livet['scheduled_time']) && isTimeForFuture($livet['scheduled_time'], $livet['timezone'])) {
|
||||||
$array = Live_schedule::getPosterPaths($_REQUEST['live_schedule']);
|
$array = Live_schedule::getPosterPaths($_REQUEST['live_schedule']);
|
||||||
$uploadedPoster = $array['path'];
|
$uploadedPoster = $array['path'];
|
||||||
header('Content-Type: image/jpg');
|
header('Content-Type: image/jpg');
|
||||||
|
@ -61,7 +62,7 @@ if (empty($livet)) {
|
||||||
} else {
|
} else {
|
||||||
_error_log('getImage: File NOT exists 1 ' . $uploadedPoster);
|
_error_log('getImage: File NOT exists 1 ' . $uploadedPoster);
|
||||||
}
|
}
|
||||||
} else if (!Live::isLive($livet['users_id'])) {
|
} elseif (!Live::isLive($livet['users_id'])) {
|
||||||
$uploadedPoster = $global['systemRootPath'] . Live::getPoster($livet['users_id'], $_REQUEST['live_servers_id']);
|
$uploadedPoster = $global['systemRootPath'] . Live::getPoster($livet['users_id'], $_REQUEST['live_servers_id']);
|
||||||
//var_dump($livet['users_id'], $_REQUEST['live_servers_id'],$uploadedPoster, empty($livet), Live::isLive($livet['users_id']) );exit;
|
//var_dump($livet['users_id'], $_REQUEST['live_servers_id'],$uploadedPoster, empty($livet), Live::isLive($livet['users_id']) );exit;
|
||||||
if (file_exists($uploadedPoster)) {
|
if (file_exists($uploadedPoster)) {
|
||||||
|
@ -95,7 +96,7 @@ if (!empty($_REQUEST['live_index']) && $_REQUEST['live_index'] !== 'false') {
|
||||||
$name = "getLiveImage_{$uuid}_{$_REQUEST['format']}";
|
$name = "getLiveImage_{$uuid}_{$_REQUEST['format']}";
|
||||||
$result = ObjectYPT::getCache($name, $lifetime, true);
|
$result = ObjectYPT::getCache($name, $lifetime, true);
|
||||||
|
|
||||||
$socketMessage = array();
|
$socketMessage = [];
|
||||||
$socketMessage['cacheName1'] = $name;
|
$socketMessage['cacheName1'] = $name;
|
||||||
$socketMessage['iscache'] = !empty($result);
|
$socketMessage['iscache'] = !empty($result);
|
||||||
$socketMessage['src'] = getSelfURI();
|
$socketMessage['src'] = getSelfURI();
|
||||||
|
@ -131,7 +132,6 @@ if (!empty($result) && !Live::isDefaultImage($result)) {
|
||||||
if (empty($content)) {
|
if (empty($content)) {
|
||||||
echo file_get_contents($filename);
|
echo file_get_contents($filename);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
|
@ -150,9 +150,8 @@ if (!empty($result) && !Live::isDefaultImage($result)) {
|
||||||
//$socketObj = sendSocketMessageToAll($socketMessage, 'socketLiveImageUpdateCallback');
|
//$socketObj = sendSocketMessageToAll($socketMessage, 'socketLiveImageUpdateCallback');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$result = file_get_contents($filename);
|
$result = file_get_contents($filename);
|
||||||
if(!Live::isDefaultImage($result)){
|
if (!Live::isDefaultImage($result)) {
|
||||||
copy($filename, $cacheFileImageName);
|
copy($filename, $cacheFileImageName);
|
||||||
}
|
}
|
||||||
echo $result;
|
echo $result;
|
||||||
|
|
|
@ -21,16 +21,16 @@ if (!empty($_GET['c'])) {
|
||||||
if (!empty($_GET['u']) && !empty($_GET['embedv2'])) {
|
if (!empty($_GET['u']) && !empty($_GET['embedv2'])) {
|
||||||
include $global['systemRootPath'] . 'plugin/Live/view/videoEmbededV2.php';
|
include $global['systemRootPath'] . 'plugin/Live/view/videoEmbededV2.php';
|
||||||
exit;
|
exit;
|
||||||
} else if (!empty($_GET['u']) && !empty($_GET['embed'])) {
|
} elseif (!empty($_GET['u']) && !empty($_GET['embed'])) {
|
||||||
include $global['systemRootPath'] . 'plugin/Live/view/videoEmbeded.php';
|
include $global['systemRootPath'] . 'plugin/Live/view/videoEmbeded.php';
|
||||||
exit;
|
exit;
|
||||||
} else if (!empty($_GET['u'])) {
|
} elseif (!empty($_GET['u'])) {
|
||||||
include $global['systemRootPath'] . 'plugin/Live/view/modeYoutubeLive.php';
|
include $global['systemRootPath'] . 'plugin/Live/view/modeYoutubeLive.php';
|
||||||
exit;
|
exit;
|
||||||
} else if (!User::isLogged()) {
|
} elseif (!User::isLogged()) {
|
||||||
gotToLoginAndComeBackHere("");
|
gotToLoginAndComeBackHere("");
|
||||||
exit;
|
exit;
|
||||||
} else if (!User::canStream()) {
|
} elseif (!User::canStream()) {
|
||||||
forbiddenPage(__($obj->streamDeniedMsg));
|
forbiddenPage(__($obj->streamDeniedMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ if (!empty($_GET['users_id']) && User::isAdmin()) {
|
||||||
|
|
||||||
// if user already have a key
|
// if user already have a key
|
||||||
$trasnmition = LiveTransmition::createTransmitionIfNeed($users_id);
|
$trasnmition = LiveTransmition::createTransmitionIfNeed($users_id);
|
||||||
$getLiveKey = array('key' => $trasnmition['key'], 'live_servers_id' => Live::getLiveServersIdRequest());
|
$getLiveKey = ['key' => $trasnmition['key'], 'live_servers_id' => Live::getLiveServersIdRequest()];
|
||||||
setLiveKey($trasnmition['key'], Live::getLiveServersIdRequest(), @$_REQUEST['live_index']);
|
setLiveKey($trasnmition['key'], Live::getLiveServersIdRequest(), @$_REQUEST['live_index']);
|
||||||
if (!empty($_GET['resetKey'])) {
|
if (!empty($_GET['resetKey'])) {
|
||||||
LiveTransmition::resetTransmitionKey($users_id);
|
LiveTransmition::resetTransmitionKey($users_id);
|
||||||
|
@ -127,8 +127,7 @@ if (!empty($chat2) && !empty($chat2->useStaticLayout)) {
|
||||||
$liveStreamObject = new LiveStreamObject($trasnmition['key'], 0, @$_REQUEST['live_index'], 0);
|
$liveStreamObject = new LiveStreamObject($trasnmition['key'], 0, @$_REQUEST['live_index'], 0);
|
||||||
$key = $liveStreamObject->getKeyWithIndex(true);
|
$key = $liveStreamObject->getKeyWithIndex(true);
|
||||||
$activeServerFound = true;
|
$activeServerFound = true;
|
||||||
$_REQUEST['live_servers_id'] = 0;
|
$_REQUEST['live_servers_id'] = 0; ?>
|
||||||
?>
|
|
||||||
<li class="active <?php echo getCSSAnimationClassAndStyle('animate__fadeInLeft', 'menu'); ?>">
|
<li class="active <?php echo getCSSAnimationClassAndStyle('animate__fadeInLeft', 'menu'); ?>">
|
||||||
<a href="<?php echo $global['webSiteRootURL']; ?>plugin/Live/?live_servers_id=0">
|
<a href="<?php echo $global['webSiteRootURL']; ?>plugin/Live/?live_servers_id=0">
|
||||||
<i class="fas fa-broadcast-tower"></i> <?php echo __("Local Server"); ?>
|
<i class="fas fa-broadcast-tower"></i> <?php echo __("Local Server"); ?>
|
||||||
|
@ -147,12 +146,11 @@ if (!empty($chat2) && !empty($chat2->useStaticLayout)) {
|
||||||
$activeServerFound = true;
|
$activeServerFound = true;
|
||||||
$active = "active";
|
$active = "active";
|
||||||
}
|
}
|
||||||
} else if ($index == 0) {
|
} elseif ($index == 0) {
|
||||||
$_REQUEST['live_servers_id'] = $value['id'];
|
$_REQUEST['live_servers_id'] = $value['id'];
|
||||||
$activeServerFound = true;
|
$activeServerFound = true;
|
||||||
$active = "active";
|
$active = "active";
|
||||||
}
|
} ?>
|
||||||
?>
|
|
||||||
<li class="<?php echo $active; ?> <?php echo getCSSAnimationClassAndStyle('animate__fadeInLeft', 'menu'); ?>">
|
<li class="<?php echo $active; ?> <?php echo getCSSAnimationClassAndStyle('animate__fadeInLeft', 'menu'); ?>">
|
||||||
<a href="<?php echo $global['webSiteRootURL']; ?>plugin/Live/?live_servers_id=<?php echo $value['id']; ?>">
|
<a href="<?php echo $global['webSiteRootURL']; ?>plugin/Live/?live_servers_id=<?php echo $value['id']; ?>">
|
||||||
<i class="fas fa-broadcast-tower"></i> <?php echo $value['name']; ?>
|
<i class="fas fa-broadcast-tower"></i> <?php echo $value['name']; ?>
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
include $global['systemRootPath'] . 'plugin/Live/tabs/tabStreamSettings.php';
|
include $global['systemRootPath'] . 'plugin/Live/tabs/tabStreamSettings.php';
|
||||||
?>
|
|
|
@ -9,7 +9,7 @@ if (!empty($obj->experimentalWebcam)) {
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
<li class="active" data-toggle="tooltip" data-placement="bottom" title="<?php echo __("Use streaming software or hardware"); ?>"><a data-toggle="tab" href="#tabStreamKey"><i class="fas fa-key"></i> <?php echo __("Stream Key"); ?></a></li>
|
<li class="active" data-toggle="tooltip" data-placement="bottom" title="<?php echo __("Use streaming software or hardware"); ?>"><a data-toggle="tab" href="#tabStreamKey"><i class="fas fa-key"></i> <?php echo __("Stream Key"); ?></a></li>
|
||||||
<?php
|
<?php
|
||||||
if(empty($objLive->hideShare)){
|
if (empty($objLive->hideShare)) {
|
||||||
?>
|
?>
|
||||||
<li class="" data-toggle="tooltip" data-placement="bottom" title="<?php echo __("Share information about your live"); ?>"><a data-toggle="tab" href="#tabShare"><i class="fa fa-share"></i> <?php echo __("Share"); ?></a></li>
|
<li class="" data-toggle="tooltip" data-placement="bottom" title="<?php echo __("Share information about your live"); ?>"><a data-toggle="tab" href="#tabShare"><i class="fa fa-share"></i> <?php echo __("Share"); ?></a></li>
|
||||||
<?php
|
<?php
|
||||||
|
@ -37,8 +37,7 @@ if (!empty($obj->experimentalWebcam)) {
|
||||||
?>
|
?>
|
||||||
<div id="tabRestream" class="tab-pane fade">
|
<div id="tabRestream" class="tab-pane fade">
|
||||||
<?php
|
<?php
|
||||||
include $global['systemRootPath'] . 'plugin/Live/view/Live_restreams/livePanel.php';
|
include $global['systemRootPath'] . 'plugin/Live/view/Live_restreams/livePanel.php'; ?>
|
||||||
?>
|
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
require_once '../../videos/configuration.php';
|
require_once '../../videos/configuration.php';
|
||||||
session_write_close();
|
session_write_close();
|
||||||
|
@ -8,14 +9,14 @@ $obj->error = true;
|
||||||
$obj->msg = "";
|
$obj->msg = "";
|
||||||
$obj->online = false;
|
$obj->online = false;
|
||||||
|
|
||||||
if(empty($_GET['name'])){
|
if (empty($_GET['name'])) {
|
||||||
$obj->msg = __("Key is empty");
|
$obj->msg = __("Key is empty");
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
$p = AVideoPlugin::loadPluginIfEnabled("Live");
|
$p = AVideoPlugin::loadPluginIfEnabled("Live");
|
||||||
|
|
||||||
if(empty($p)){
|
if (empty($p)) {
|
||||||
$obj->msg = __("Live plugin is not enabled");
|
$obj->msg = __("Live plugin is not enabled");
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
@ -24,24 +25,24 @@ $xml = json_encode($xml);
|
||||||
$xml = _json_decode($xml);
|
$xml = _json_decode($xml);
|
||||||
|
|
||||||
$stream = false;
|
$stream = false;
|
||||||
$lifeStream = array();
|
$lifeStream = [];
|
||||||
//$obj->server = $xml->server;
|
//$obj->server = $xml->server;
|
||||||
if(!empty($xml->server->application) && !is_array($xml->server->application)){
|
if (!empty($xml->server->application) && !is_array($xml->server->application)) {
|
||||||
$application = $xml->server->application;
|
$application = $xml->server->application;
|
||||||
$xml->server->application = array();
|
$xml->server->application = [];
|
||||||
$xml->server->application[] = $application;
|
$xml->server->application[] = $application;
|
||||||
}
|
}
|
||||||
if(!empty($xml->server->application[0]->live->stream)){
|
if (!empty($xml->server->application[0]->live->stream)) {
|
||||||
$lifeStream = $xml->server->application[0]->live->stream;
|
$lifeStream = $xml->server->application[0]->live->stream;
|
||||||
if(!is_array($xml->server->application[0]->live->stream)){
|
if (!is_array($xml->server->application[0]->live->stream)) {
|
||||||
$lifeStream = array();
|
$lifeStream = [];
|
||||||
$lifeStream[0] = $xml->server->application[0]->live->stream;
|
$lifeStream[0] = $xml->server->application[0]->live->stream;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($lifeStream as $value){
|
foreach ($lifeStream as $value) {
|
||||||
if(!empty($value->name)){
|
if (!empty($value->name)) {
|
||||||
if($_GET['name']==$value->name){
|
if ($_GET['name']==$value->name) {
|
||||||
$obj->online = true;
|
$obj->online = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once '../../videos/configuration.php';
|
require_once '../../videos/configuration.php';
|
||||||
$pobj = AVideoPlugin::getDataObject("Live");
|
$pobj = AVideoPlugin::getDataObject("Live");
|
||||||
|
|
||||||
|
@ -12,16 +13,16 @@ if (!User::isAdmin()) {
|
||||||
|
|
||||||
$row = LiveTransmition::keyExists($_REQUEST['key']);
|
$row = LiveTransmition::keyExists($_REQUEST['key']);
|
||||||
|
|
||||||
if(!empty($row)){
|
if (!empty($row)) {
|
||||||
if(empty($_REQUEST['json'])){
|
if (empty($_REQUEST['json'])) {
|
||||||
foreach ($row as $key => $value) {
|
foreach ($row as $key => $value) {
|
||||||
echo "<b>{$key}</b> {$value}<br>";
|
echo "<b>{$key}</b> {$value}<br>";
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
echo json_encode($row);
|
echo json_encode($row);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
echo "Key not found";
|
echo "Key not found";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$recheckTolerance = 600; // 10 min
|
$recheckTolerance = 600; // 10 min
|
||||||
require_once dirname(__FILE__) . '/../../videos/configuration.php';
|
require_once dirname(__FILE__) . '/../../videos/configuration.php';
|
||||||
error_reporting(0);
|
error_reporting(0);
|
||||||
|
@ -32,13 +33,13 @@ if (empty($_SESSION['m3u8Verified']) || $_SESSION['m3u8Verified'] + $recheckTole
|
||||||
unset($_SESSION['m3u8Verified']);
|
unset($_SESSION['m3u8Verified']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($_SESSION['playerServer']) || !is_array($_SESSION['playerServer'])){
|
if (!isset($_SESSION['playerServer']) || !is_array($_SESSION['playerServer'])) {
|
||||||
_session_start();
|
_session_start();
|
||||||
$_SESSION['playerServer'] = array();
|
$_SESSION['playerServer'] = [];
|
||||||
}
|
}
|
||||||
if(!isset($_SESSION['useAadaptiveMode']) || !is_array($_SESSION['useAadaptiveMode'])){
|
if (!isset($_SESSION['useAadaptiveMode']) || !is_array($_SESSION['useAadaptiveMode'])) {
|
||||||
_session_start();
|
_session_start();
|
||||||
$_SESSION['useAadaptiveMode'] = array();
|
$_SESSION['useAadaptiveMode'] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$live_servers_id = Live::getCurrentLiveServersId();
|
$live_servers_id = Live::getCurrentLiveServersId();
|
||||||
|
@ -75,7 +76,7 @@ if (empty($_SESSION['useAadaptiveMode'][$live_servers_id]) && empty($content)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($content)){ // get the default loop
|
if (empty($content)) { // get the default loop
|
||||||
//$complement = "{$global['webSiteRootURL']}plugin/Live/view/loopBGHLS/";
|
//$complement = "{$global['webSiteRootURL']}plugin/Live/view/loopBGHLS/";
|
||||||
//$content = file_get_contents("{$global['systemRootPath']}plugin/Live/view/loopBGHLS/index.m3u8");
|
//$content = file_get_contents("{$global['systemRootPath']}plugin/Live/view/loopBGHLS/index.m3u8");
|
||||||
include "{$global['systemRootPath']}plugin/Live/view/loopBGHLS/index.m3u8.php";
|
include "{$global['systemRootPath']}plugin/Live/view/loopBGHLS/index.m3u8.php";
|
||||||
|
|
|
@ -17,35 +17,34 @@ if (empty($url)) {
|
||||||
$url = $_POST['swfurl'];
|
$url = $_POST['swfurl'];
|
||||||
}
|
}
|
||||||
$parts = parse_url($url);
|
$parts = parse_url($url);
|
||||||
if(!empty($parts["query"])){
|
if (!empty($parts["query"])) {
|
||||||
parse_str($parts["query"], $_GET);
|
parse_str($parts["query"], $_GET);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($_GET['e']) && empty($_GET['p'])){
|
if (!empty($_GET['e']) && empty($_GET['p'])) {
|
||||||
if (strpos($_GET['e'], '/') !== false) {
|
if (strpos($_GET['e'], '/') !== false) {
|
||||||
$parts = explode("/", $_GET['e']);
|
$parts = explode("/", $_GET['e']);
|
||||||
if (!empty($parts[1])) {
|
if (!empty($parts[1])) {
|
||||||
if(empty($_POST['name'])){
|
if (empty($_POST['name'])) {
|
||||||
$_POST['name'] = $parts[1];
|
$_POST['name'] = $parts[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$_GET['e'] = $parts[0];
|
$_GET['e'] = $parts[0];
|
||||||
}
|
}
|
||||||
$objE = _json_decode(decryptString($_GET['e']));
|
$objE = _json_decode(decryptString($_GET['e']));
|
||||||
if(empty($objE)){
|
if (empty($objE)) {
|
||||||
|
|
||||||
$objE = _json_decode(decryptString(base64_decode($_GET['e'])));
|
$objE = _json_decode(decryptString(base64_decode($_GET['e'])));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($objE->users_id)){
|
if (!empty($objE->users_id)) {
|
||||||
$user = new User($objE->users_id);
|
$user = new User($objE->users_id);
|
||||||
$_GET['p'] = $user->getPassword();
|
$_GET['p'] = $user->getPassword();
|
||||||
}else{
|
} else {
|
||||||
_error_log("NGINX ON Publish encryption token error: " . json_encode($objE));
|
_error_log("NGINX ON Publish encryption token error: " . json_encode($objE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($_GET['p']) && !empty($_POST['p'])){
|
if (empty($_GET['p']) && !empty($_POST['p'])) {
|
||||||
$_GET['p'] = $_POST['p'];
|
$_GET['p'] = $_POST['p'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +73,7 @@ if (strpos($_GET['p'], '/') !== false) {
|
||||||
$parts = explode("/", $_GET['p']);
|
$parts = explode("/", $_GET['p']);
|
||||||
if (!empty($parts[1])) {
|
if (!empty($parts[1])) {
|
||||||
$_GET['p'] = $parts[0];
|
$_GET['p'] = $parts[0];
|
||||||
if(empty($_POST['name'])){
|
if (empty($_POST['name'])) {
|
||||||
$_POST['name'] = $parts[1];
|
$_POST['name'] = $parts[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +99,7 @@ if (!empty($_GET['p'])) {
|
||||||
$user = new User($obj->row['users_id']);
|
$user = new User($obj->row['users_id']);
|
||||||
if (!$user->thisUserCanStream()) {
|
if (!$user->thisUserCanStream()) {
|
||||||
_error_log("NGINX ON Publish User [{$obj->row['users_id']}] can not stream");
|
_error_log("NGINX ON Publish User [{$obj->row['users_id']}] can not stream");
|
||||||
} else if (!empty($_GET['p']) && $_GET['p'] === $user->getPassword()) {
|
} elseif (!empty($_GET['p']) && $_GET['p'] === $user->getPassword()) {
|
||||||
_error_log("NGINX ON Publish get LiveTransmitionHistory");
|
_error_log("NGINX ON Publish get LiveTransmitionHistory");
|
||||||
$lth = new LiveTransmitionHistory();
|
$lth = new LiveTransmitionHistory();
|
||||||
$lth->setTitle($obj->row['title']);
|
$lth->setTitle($obj->row['title']);
|
||||||
|
@ -113,7 +112,7 @@ if (!empty($_GET['p'])) {
|
||||||
$obj->liveTransmitionHistory_id = $lth->save();
|
$obj->liveTransmitionHistory_id = $lth->save();
|
||||||
_error_log("NGINX ON Publish saved LiveTransmitionHistory");
|
_error_log("NGINX ON Publish saved LiveTransmitionHistory");
|
||||||
$obj->error = false;
|
$obj->error = false;
|
||||||
} else if (empty($_GET['p'])) {
|
} elseif (empty($_GET['p'])) {
|
||||||
_error_log("NGINX ON Publish error, Password is empty");
|
_error_log("NGINX ON Publish error, Password is empty");
|
||||||
} else {
|
} else {
|
||||||
_error_log("NGINX ON Publish error, Password does not match ({$_GET['p']}) expect (" . $user->getPassword() . ")");
|
_error_log("NGINX ON Publish error, Password does not match ({$_GET['p']}) expect (" . $user->getPassword() . ")");
|
||||||
|
@ -158,7 +157,7 @@ if (!empty($obj) && empty($obj->error)) {
|
||||||
$liveTransmitionHistory_id = $obj->liveTransmitionHistory_id;
|
$liveTransmitionHistory_id = $obj->liveTransmitionHistory_id;
|
||||||
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
|
||||||
include "{$global['systemRootPath']}plugin/Live/on_publish_socket_notification.php";
|
include "{$global['systemRootPath']}plugin/Live/on_publish_socket_notification.php";
|
||||||
}else{
|
} else {
|
||||||
$command = "php {$global['systemRootPath']}plugin/Live/on_publish_socket_notification.php '$users_id' '$m3u8' '{$obj->liveTransmitionHistory_id}'";
|
$command = "php {$global['systemRootPath']}plugin/Live/on_publish_socket_notification.php '$users_id' '$m3u8' '{$obj->liveTransmitionHistory_id}'";
|
||||||
|
|
||||||
_error_log("NGINX Live::on_publish YPTSocket start ($command)");
|
_error_log("NGINX Live::on_publish YPTSocket start ($command)");
|
||||||
|
|
|
@ -20,12 +20,12 @@ _error_log("NGINX ON Publish Done parse_str: " . json_encode($_GET));
|
||||||
|
|
||||||
$_GET = object_to_array($_GET);
|
$_GET = object_to_array($_GET);
|
||||||
|
|
||||||
if(!empty($_GET['e']) && empty($_GET['p'])){
|
if (!empty($_GET['e']) && empty($_GET['p'])) {
|
||||||
$obj = json_decode(decryptString($_GET['e']));
|
$obj = json_decode(decryptString($_GET['e']));
|
||||||
if(empty($objE)){
|
if (empty($objE)) {
|
||||||
$objE = json_decode(decryptString(base64_decode($_GET['e'])));
|
$objE = json_decode(decryptString(base64_decode($_GET['e'])));
|
||||||
}
|
}
|
||||||
if(!empty($obj->users_id)){
|
if (!empty($obj->users_id)) {
|
||||||
$user = new User($obj->users_id);
|
$user = new User($obj->users_id);
|
||||||
$_GET['p'] = $user->getPassword();
|
$_GET['p'] = $user->getPassword();
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ if (strpos($_GET['p'], '/') !== false) {
|
||||||
$parts = explode("/", $_GET['p']);
|
$parts = explode("/", $_GET['p']);
|
||||||
if (!empty($parts[1])) {
|
if (!empty($parts[1])) {
|
||||||
$_GET['p'] = $parts[0];
|
$_GET['p'] = $parts[0];
|
||||||
if(empty($_POST['name'])){
|
if (empty($_POST['name'])) {
|
||||||
$_POST['name'] = $parts[1];
|
$_POST['name'] = $parts[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,4 +66,3 @@ $parameters = Live::getLiveParametersFromKey($array['key']);
|
||||||
$array['cleanKey'] = $parameters['cleanKey'];
|
$array['cleanKey'] = $parameters['cleanKey'];
|
||||||
$array['stats'] = LiveTransmitionHistory::getStatsAndRemoveApplication($row['id']);
|
$array['stats'] = LiveTransmitionHistory::getStatsAndRemoveApplication($row['id']);
|
||||||
$socketObj = Live::notifySocketStats("socketLiveOFFCallback", $array);
|
$socketObj = Live::notifySocketStats("socketLiveOFFCallback", $array);
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ if (AVideoPlugin::isEnabledByName('YPTSocket')) {
|
||||||
}
|
}
|
||||||
$obj->error = false;
|
$obj->error = false;
|
||||||
|
|
||||||
if(empty($array['key']) && !empty($liveTransmitionHistory_id)){
|
if (empty($array['key']) && !empty($liveTransmitionHistory_id)) {
|
||||||
$lt = new LiveTransmitionHistory($liveTransmitionHistory_id);
|
$lt = new LiveTransmitionHistory($liveTransmitionHistory_id);
|
||||||
$array['key'] = $lt->getKey();
|
$array['key'] = $lt->getKey();
|
||||||
$array['live_servers_id'] = $lt->getLive_servers_id();
|
$array['live_servers_id'] = $lt->getLive_servers_id();
|
||||||
|
|
|
@ -4,6 +4,6 @@ require_once '../../videos/configuration.php';
|
||||||
require_once '../AVideoPlugin.php';
|
require_once '../AVideoPlugin.php';
|
||||||
_error_log("Record Finish");
|
_error_log("Record Finish");
|
||||||
$plugin = AVideoPlugin::loadPluginIfEnabled('SendRecordedToEncoder');
|
$plugin = AVideoPlugin::loadPluginIfEnabled('SendRecordedToEncoder');
|
||||||
if($plugin){
|
if ($plugin) {
|
||||||
$plugin->on_record_done();
|
$plugin->on_record_done();
|
||||||
}
|
}
|
|
@ -9,7 +9,7 @@ $obj = new stdClass();
|
||||||
$obj->error = true;
|
$obj->error = true;
|
||||||
|
|
||||||
$live_servers_id = intval($_REQUEST['live_servers_id']);
|
$live_servers_id = intval($_REQUEST['live_servers_id']);
|
||||||
if(empty($live_servers_id)){
|
if (empty($live_servers_id)) {
|
||||||
$obj->msg = 'live_servers_id is empty';
|
$obj->msg = 'live_servers_id is empty';
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ if (!User::isLogged()) {
|
||||||
|
|
||||||
$live = AVideoPlugin::loadPluginIfEnabled("Live");
|
$live = AVideoPlugin::loadPluginIfEnabled("Live");
|
||||||
|
|
||||||
if(empty($live)){
|
if (empty($live)) {
|
||||||
$obj->msg = 'Plugin not enabled';
|
$obj->msg = 'Plugin not enabled';
|
||||||
die(json_encode($obj));
|
die(json_encode($obj));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,8 +10,8 @@ if (!User::canViewChart()) {
|
||||||
|
|
||||||
$lives = LiveTransmitionHistory::getAllFromUser(User::getId());
|
$lives = LiveTransmitionHistory::getAllFromUser(User::getId());
|
||||||
|
|
||||||
$labelsArray = array();
|
$labelsArray = [];
|
||||||
$valueArray = array();
|
$valueArray = [];
|
||||||
|
|
||||||
foreach ($lives as $value) {
|
foreach ($lives as $value) {
|
||||||
$labelsArray[] = $value['created'] . "\n" . $value['title'];
|
$labelsArray[] = $value['created'] . "\n" . $value['title'];
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue