" rel="self" type="application/rss+xml" />
- Rss Feed
+
hourly
1
diff --git a/install/checkConfiguration.php b/install/checkConfiguration.php
index 3716f2791e7d..b97fa1e187cf 100644
--- a/install/checkConfiguration.php
+++ b/install/checkConfiguration.php
@@ -145,6 +145,16 @@
\$global['ddosSecondTimeout'] = 5;
\$global['strictDDOSprotection'] = 0;
\$global['noDebug'] = 0;
+\$global['webSiteRootPath'] = '';
+if(empty(\$global['webSiteRootPath'])){
+ preg_match('/https?:\/\/[^\/]+(.*)/i', \$global['webSiteRootURL'], \$matches);
+ if(!empty(\$matches[1])){
+ \$global['webSiteRootPath'] = \$matches[1];
+ }
+}
+if(empty(\$global['webSiteRootPath'])){
+ die('Please configure your webSiteRootPath');
+}
\$mysqlHost = '{$_POST['databaseHost']}';
\$mysqlPort = '{$_POST['databasePort']}';
diff --git a/install/index.php b/install/index.php
index 5339ecf1618e..48e5f709b0ea 100644
--- a/install/index.php
+++ b/install/index.php
@@ -14,7 +14,7 @@
-
+
diff --git a/install/makeAdmin.php b/install/makeAdmin.php
new file mode 100644
index 000000000000..6764a4374c78
--- /dev/null
+++ b/install/makeAdmin.php
@@ -0,0 +1,36 @@
+getBdId())){
+ $sql = "UPDATE users SET isAdmin = 1, status = 'a' where id = ".$user->getBdId();
+
+ $insert_row = sqlDAL::writeSql($sql);
+ if($insert_row){
+ echo "Your user {$userName} is admin now";
+ echo "\n";
+ die();
+ }
+ }else{
+ echo "User ({$userName}) Not found";
+ echo "\n";
+ die();
+ }
+}
+echo "Bye";
+echo "\n";
+die();
+
+
+
+
diff --git a/install/removeRepeatedPlaylists.php b/install/removeRepeatedPlaylists.php
new file mode 100644
index 000000000000..3b6d0fa55a5e
--- /dev/null
+++ b/install/removeRepeatedPlaylists.php
@@ -0,0 +1,76 @@
+ $row) {
+ $users_ids[] = $row['users_id'];
+ }
+} else {
+ die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
+}
+
+
+foreach ($users_ids as $user_id) {
+ echo "Process user_id = {$user_id}\n";
+ ob_flush();
+ $sql = "SELECT * FROM playlists WHERE users_id = {$user_id} AND status = 'favorite' ORDER BY created ";
+ $res = sqlDAL::readSql($sql);
+ $fullData = sqlDAL::fetchAllAssoc($res);
+ sqlDAL::close($res);
+ $rows = array();
+ if ($res != false) {
+ foreach ($fullData as $key => $row) {
+ if ($key === 0) {
+ continue;
+ }
+
+ if(!empty(PlayList::getVideosIDFromPlaylistLight($row['id']))){
+ continue;
+ }
+
+ $sql = "DELETE FROM playlists ";
+ $sql .= " WHERE id = ?";
+
+ echo $sql." = {$row['id']}\n";
+ ob_flush();
+ sqlDAL::writeSql($sql, "i", array($row['id']));
+ }
+ } else {
+ die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
+ }
+
+
+ $sql = "SELECT * FROM playlists WHERE users_id = {$user_id} AND status = 'watch_later' ORDER BY created ";
+ $res = sqlDAL::readSql($sql);
+ $fullData = sqlDAL::fetchAllAssoc($res);
+ sqlDAL::close($res);
+ $rows = array();
+ if ($res != false) {
+ foreach ($fullData as $key => $row) {
+ if ($key === 0) {
+ continue;
+ }
+ $sql = "DELETE FROM playlists ";
+ $sql .= " WHERE id = ?";
+ echo $sql." = {$row['id']}\n";
+ ob_flush();
+ sqlDAL::writeSql($sql, "i", array($row['id']));
+ }
+ } else {
+ die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
+ }
+
+}
diff --git a/locale/de.php b/locale/de.php
index c1c10f9683a9..7ead87419f98 100644
--- a/locale/de.php
+++ b/locale/de.php
@@ -1,8 +1,8 @@
%s was uploaded to your YouTube Account
'] = "Dein Video wurde hochgeladen auf Deinen ";
$t['Your video download is complete, it is encoding now'] = "Dein Video Download ist ok und wird nun enkodiert";
@@ -731,7 +732,7 @@
$t['about'] = "über";
$t['ago'] = "her";
$t['arrow'] = "Pfeil";
-$t['audioOnly'] = "Nur audio";
+$t['audioOnly'] = "Nur Audio";
$t['cat'] = "";
$t['categories'] = "Kategorien";
$t['channel'] = "Kanal";
@@ -776,4 +777,4 @@
$t['weeks'] = "Wochen";
$t['year'] = "Jahr";
$t['years'] = "Jahre";
-$t['youtube-dl uses Python and some servers does not came with python as dafault, to install Python type:'] = "Youtube-dl verwendet Python und einige Server haben Python nicht als Standard installiert, um Python zu installieren tippe:";
\ No newline at end of file
+$t['youtube-dl uses Python and some servers does not came with python as dafault, to install Python type:'] = "Youtube-dl verwendet Python und einige Server haben Python nicht als Standard installiert, um Python zu installieren tippe:";
diff --git a/objects/Object.php b/objects/Object.php
index e698ef42d22f..d2451a967726 100644
--- a/objects/Object.php
+++ b/objects/Object.php
@@ -221,7 +221,8 @@ function save() {
}
return $id;
} else {
- die($sql . ' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
+ _error_log("ObjectYPT::save Error on save: ".$sql . ' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
+ return false;
}
}
diff --git a/objects/configuration.php b/objects/configuration.php
index a400a42f4abd..066efc11ef44 100644
--- a/objects/configuration.php
+++ b/objects/configuration.php
@@ -320,9 +320,9 @@ static function rewriteConfigFile() {
$global['salt'] = uniqid();
}
$content = " $source['url'],
'type' => 'image',
);
- } else if($type!='image') {
+ } else if ($type != 'image') {
$files["pjpg"] = array(
'filename' => "{$type}_portrait.png",
'path' => "{$global['systemRootPath']}view/img/{$type}_portrait.png",
@@ -2805,57 +2805,63 @@ function getUsageFromFilename($filename, $dir = "") {
$totalSize = 0;
_error_log("getUsageFromFilename: start {$dir}{$filename}");
$files = glob("{$dir}{$filename}*");
+ session_write_close();
foreach ($files as $f) {
if (is_dir($f)) {
_error_log("getUsageFromFilename: {$f} is Dir");
$dirSize = getDirSize($f);
$totalSize += $dirSize;
- if($dirSize<10000 && AVideoPlugin::isEnabledByName('YPTStorage')){
+ if ($dirSize < 10000 && AVideoPlugin::isEnabledByName('YPTStorage')) {
// probably the HLS file is hosted on the YPTStorage
$info = YPTStorage::getFileInfo($filename);
- if(!empty($info->size)){
+ if (!empty($info->size)) {
$totalSize += $info->size;
}
}
} else if (is_file($f)) {
$filesize = filesize($f);
if ($filesize < 20) { // that means it is a dummy file
- _error_log("getUsageFromFilename: {$f} is Dummy file ({$filesize})");
- $aws_s3 = AVideoPlugin::loadPluginIfEnabled('AWS_S3');
- //$bb_b2 = AVideoPlugin::loadPluginIfEnabled('Blackblaze_B2');
- if (!empty($aws_s3)) {
- _error_log("getUsageFromFilename: Get from S3");
- $filesize += $aws_s3->getFilesize($filename);
- } else if (!empty($bb_b2)) {
- // TODO
- } else {
- $urls = Video::getVideosPaths($filename, true);
- _error_log("getUsageFromFilename: Paths " . json_encode($urls));
- if (!empty($urls["m3u8"]['url'])) {
- $filesize+=getUsageFromURL($urls["m3u8"]['url']);
- }
- if (!empty($urls['mp4'])) {
- foreach ($urls['mp4'] as $mp4) {
- $filesize+=getUsageFromURL($mp4);
+ $lockFile = $f . ".size.lock";
+ if (!file_exists($lockFile) || (time() - 600) > filemtime($cachefile)) {
+ file_put_contents($lockFile, time());
+ _error_log("getUsageFromFilename: {$f} is Dummy file ({$filesize})");
+ $aws_s3 = AVideoPlugin::loadPluginIfEnabled('AWS_S3');
+ //$bb_b2 = AVideoPlugin::loadPluginIfEnabled('Blackblaze_B2');
+ if (!empty($aws_s3)) {
+ _error_log("getUsageFromFilename: Get from S3");
+ $filesize += $aws_s3->getFilesize($filename);
+ } else if (!empty($bb_b2)) {
+ // TODO
+ } else {
+ $urls = Video::getVideosPaths($filename, true);
+ _error_log("getUsageFromFilename: Paths " . json_encode($urls));
+ if (!empty($urls["m3u8"]['url'])) {
+ $filesize += getUsageFromURL($urls["m3u8"]['url']);
}
- }
- if (!empty($urls['webm'])) {
- foreach ($urls['webm'] as $mp4) {
- $filesize+=getUsageFromURL($mp4);
+ if (!empty($urls['mp4'])) {
+ foreach ($urls['mp4'] as $mp4) {
+ $filesize += getUsageFromURL($mp4);
+ }
+ }
+ if (!empty($urls['webm'])) {
+ foreach ($urls['webm'] as $mp4) {
+ $filesize += getUsageFromURL($mp4);
+ }
+ }
+ if (!empty($urls["pdf"]['url'])) {
+ $filesize += getUsageFromURL($urls["pdf"]['url']);
+ }
+ if (!empty($urls["image"]['url'])) {
+ $filesize += getUsageFromURL($urls["image"]['url']);
+ }
+ if (!empty($urls["zip"]['url'])) {
+ $filesize += getUsageFromURL($urls["zip"]['url']);
+ }
+ if (!empty($urls["mp3"]['url'])) {
+ $filesize += getUsageFromURL($urls["mp3"]['url']);
}
}
- if (!empty($urls["pdf"]['url'])) {
- $filesize+=getUsageFromURL($urls["pdf"]['url']);
- }
- if (!empty($urls["image"]['url'])) {
- $filesize+=getUsageFromURL($urls["image"]['url']);
- }
- if (!empty($urls["zip"]['url'])) {
- $filesize+=getUsageFromURL($urls["zip"]['url']);
- }
- if (!empty($urls["mp3"]['url'])) {
- $filesize+=getUsageFromURL($urls["mp3"]['url']);
- }
+ unlink($lockFile);
}
} else {
_error_log("getUsageFromFilename: {$f} is File ({$filesize})");
@@ -2987,6 +2993,9 @@ function encrypt_decrypt($string, $action) {
}
function encryptString($string) {
+ if(is_object($string)){
+ $string = json_encode($string);
+ }
return encrypt_decrypt($string, 'encrypt');
}
@@ -2994,6 +3003,44 @@ function decryptString($string) {
return encrypt_decrypt($string, 'decrypt');
}
+function getToken($timeout=0, $salt=""){
+ global $global;
+ $obj = new stdClass();
+ $obj->salt = $global['salt'].$salt;
+
+ if(!empty($timeout)){
+ $obj->time = time();
+ $obj->timeout = $obj->time+$timeout;
+ }else{
+ $obj->time = strtotime("Today 00:00:00");
+ $obj->timeout = strtotime("Today 23:59:59");
+ $obj->timeout += cacheExpirationTime();
+ }
+ $strObj = json_encode($obj);
+ //_error_log("Token created: {$strObj}");
+
+ return encryptString($strObj);
+}
+
+function verifyToken($token, $salt=""){
+ global $global;
+ $obj = json_decode(decryptString($token));
+ if(empty($obj)){
+ _error_log("verifyToken invalid token");
+ return false;
+ }
+ if($obj->salt !== $global['salt'].$salt){
+ _error_log("verifyToken salt fail");
+ return false;
+ }
+ $time = $time();
+ if(!($time>=$obj->time && $obj->timeout<=$time)){
+ _error_log("verifyToken token timout");
+ return false;
+ }
+ return true;
+}
+
class YPTvideoObject {
public $id, $title, $description, $thumbnails, $channelTitle, $videoLink;
@@ -3009,11 +3056,17 @@ function __construct($id, $title, $description, $thumbnails, $channelTitle, $vid
}
-function isToShowDuration($type){
- $notShowTo = array('pdf','article','serie','zip','image');
- if(in_array($type, $notShowTo)){
+function isToShowDuration($type) {
+ $notShowTo = array('pdf', 'article', 'serie', 'zip', 'image');
+ if (in_array($type, $notShowTo)) {
return false;
- }else{
+ } else {
return true;
}
-}
\ No newline at end of file
+}
+
+function _dieAndLogObject($obj, $prefix = "") {
+ $objString = json_encode($obj);
+ _error_log($prefix . $objString);
+ die($objString);
+}
diff --git a/objects/include_config.php b/objects/include_config.php
index 5e8c0b3f4e8b..9c61748be217 100644
--- a/objects/include_config.php
+++ b/objects/include_config.php
@@ -35,8 +35,8 @@
require_once $global['systemRootPath'] . 'objects/security.php';
$config = new Configuration();
-// for update config from old versions
-if (empty($global['configurationVersion']) || $global['configurationVersion'] < 2) {
+// for update config from old versions 2020-05-11
+if (empty($global['webSiteRootPath']) || $global['configurationVersion'] < 3) {
Configuration::rewriteConfigFile();
}
diff --git a/objects/mysql_dal.php b/objects/mysql_dal.php
index cdf32e1be350..2ec82c2c0649 100644
--- a/objects/mysql_dal.php
+++ b/objects/mysql_dal.php
@@ -77,7 +77,11 @@ static function writeSql($preparedStatement, $formats = "", $values = array()) {
if (empty($debug[2]['class']) || $debug[2]['class'] !== "AuditTable") {
$audit = AVideoPlugin::loadPluginIfEnabled('Audit');
if (!empty($audit)) {
- $audit->exec(@$debug[1]['function'], @$debug[1]['class'], $preparedStatement, $formats, json_encode($values), User::getId());
+ try {
+ $audit->exec(@$debug[1]['function'], @$debug[1]['class'], $preparedStatement, $formats, json_encode($values), User::getId());
+ } catch (Exception $exc) {
+ echo log_error($exc->getTraceAsString());
+ }
}
}
@@ -134,6 +138,8 @@ static function readSql($preparedStatement, $formats = "", $values = array(), $r
log_error("[sqlDAL::readSql] (mysqlnd) eval_mysql_bind failed: values and params in stmt don't match
\r\n{$preparedStatement} with formats {$formats}");
return false;
}
+ $TimeLog = "[$preparedStatement], $formats, ". json_encode($values).", $refreshCache";
+ TimeLogStart($TimeLog);
$stmt->execute();
$readSqlCached[$crc] = $stmt->get_result();
if ($stmt->errno != 0) {
@@ -141,8 +147,11 @@ static function readSql($preparedStatement, $formats = "", $values = array(), $r
$stmt->close();
$disableMysqlNdMethods = true;
// try again with noMysqlND
- return self::readSql($preparedStatement, $formats, $values, $refreshCache);
+ $read = self::readSql($preparedStatement, $formats, $values, $refreshCache);
+ TimeLogEnd($TimeLog, "mysql_dal", 0.5);
+ return $read;
}
+ TimeLogEnd($TimeLog, "mysql_dal", 0.5);
$stmt->close();
} else if (is_object($readSqlCached[$crc])) {
diff --git a/objects/playlist.php b/objects/playlist.php
index 7470ea3e455a..080d9c48c5e1 100644
--- a/objects/playlist.php
+++ b/objects/playlist.php
@@ -96,7 +96,7 @@ static function getAllFromUser($userId, $publicOnly = true, $status = false, $pl
$rows[] = $row;
}
}
- if (empty($status) && $config->currentVersionGreaterThen("6.4")) {
+ if (empty($_POST['current']) && empty($status) && $config->currentVersionGreaterThen("6.4")) {
if (empty($favorite)) {
$pl = new PlayList(0);
$pl->setName("Favorite");
@@ -142,9 +142,7 @@ static function getAllFromUserVideo($userId, $videos_id, $publicOnly = true, $st
$rows[$key]['isOnPlaylist'] = in_array($videos_id, $videos);
}
- if (session_status() == PHP_SESSION_NONE) {
- session_start();
- }
+ _session_start();
$_SESSION['getAllFromUserVideo'][$videos_id][$userId][intval($publicOnly)][intval($status)] = $rows;
} else {
$rows = $_SESSION['getAllFromUserVideo'][$videos_id][$userId][intval($publicOnly)][intval($status)];
@@ -155,14 +153,8 @@ static function getAllFromUserVideo($userId, $videos_id, $publicOnly = true, $st
static private function removeCache($videos_id) {
$close = false;
- if (session_status() == PHP_SESSION_NONE) {
- session_start();
- $close = true;
- }
+ _session_start();
unset($_SESSION['getAllFromUserVideo'][$videos_id]);
- if (!empty($close)) {
- session_write_close();
- }
}
static function getVideosIDFromPlaylistLight($playlists_id) {
diff --git a/objects/playlists.json.php b/objects/playlists.json.php
index 67a4b52cd34b..a2228d07539a 100644
--- a/objects/playlists.json.php
+++ b/objects/playlists.json.php
@@ -3,6 +3,7 @@
if(!isset($global['systemRootPath'])){
require_once '../videos/configuration.php';
}
+session_write_close();
if(!User::isLogged()){
die();
}
diff --git a/objects/playlistsFromUser.json.php b/objects/playlistsFromUser.json.php
index 60829cb229af..35ae0110e0f2 100644
--- a/objects/playlistsFromUser.json.php
+++ b/objects/playlistsFromUser.json.php
@@ -3,6 +3,7 @@
if(!isset($global['systemRootPath'])){
require_once '../videos/configuration.php';
}
+session_write_close();
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Content-Type");
header('Content-Type: application/json');
diff --git a/objects/user.php b/objects/user.php
index cbcb0d0357f0..caf230688c67 100644
--- a/objects/user.php
+++ b/objects/user.php
@@ -735,16 +735,14 @@ static function isCaptchaNeed() {
static function checkLoginAttempts() {
global $advancedCustomUser, $global;
- if (session_status() == PHP_SESSION_NONE) {
- session_start();
- }
// check for multiple logins attempts to prevent hacking
if (empty($_SESSION['loginAttempts'])) {
+ _session_start();
$_SESSION['loginAttempts'] = 0;
}
if (!empty($advancedCustomUser->requestCaptchaAfterLoginsAttempts)) {
+ _session_start();
$_SESSION['loginAttempts'] ++;
- session_write_close();
if ($_SESSION['loginAttempts'] > $advancedCustomUser->requestCaptchaAfterLoginsAttempts) {
if (empty($_POST['captcha'])) {
return false;
@@ -755,7 +753,6 @@ static function checkLoginAttempts() {
}
}
}
- session_write_close();
return true;
}
diff --git a/objects/video.php b/objects/video.php
index c2af8a9d9a41..f35a9315ce09 100644
--- a/objects/video.php
+++ b/objects/video.php
@@ -125,15 +125,8 @@ function addViewPercent($percent = 25) {
static function unsetAddView($videos_id) {
// allow users to count a view again in case it is refreshed
if (!empty($_SESSION['addViewCount'][$videos_id]['time']) && $_SESSION['addViewCount'][$videos_id]['time'] <= time()) {
- $close = false;
- if (session_status() == PHP_SESSION_NONE) {
- session_start();
- $close = true;
- }
+ _session_start();
unset($_SESSION['addViewCount'][$videos_id]);
- if (!empty($close)) {
- session_write_close();
- }
}
}
@@ -145,7 +138,7 @@ function load($id) {
$this->$key = $value;
}
}
-
+
function getEncoderURL() {
return $this->encoderURL;
}
@@ -169,7 +162,7 @@ function setFilepath($filepath) {
function setFilesize($filesize) {
$this->filesize = intval($filesize);
}
-
+
function setUsers_id($users_id) {
$this->users_id = $users_id;
}
@@ -271,7 +264,7 @@ function save($updateVideoGroups = false, $allowOfflineUser = false) {
}
if (empty($this->filename)) {
- $this->filename = $this->type."_".uniqid();
+ $this->filename = $this->type . "_" . uniqid();
}
$this->can_download = intval($this->can_download);
@@ -741,16 +734,16 @@ static function getVideo($id = "", $status = "viewable", $ignoreGroup = false, $
//echo $sql;exit;
$res = sqlDAL::readSql($sql);
$video = sqlDAL::fetchAssoc($res);
-
+
// if there is a search, and there is no data and is inside a channel try again without a channel
- if(!empty($_GET['search']) && empty($video) && !empty($_GET['channelName'])){
- $channelName = $_GET['channelName'];
+ if (!empty($_GET['search']) && empty($video) && !empty($_GET['channelName'])) {
+ $channelName = $_GET['channelName'];
unset($_GET['channelName']);
$return = self::getVideo($id, $status, $ignoreGroup, $random, $suggestedOnly, $showUnlisted, $ignoreTags, $activeUsersOnly);
- $_GET['channelName'] = $channelName;
+ $_GET['channelName'] = $channelName;
return $return;
}
-
+
sqlDAL::close($res);
if ($res != false) {
require_once $global['systemRootPath'] . 'objects/userGroups.php';
@@ -760,7 +753,7 @@ static function getVideo($id = "", $status = "viewable", $ignoreGroup = false, $
$video['title'] = UTF8encode($video['title']);
$video['description'] = UTF8encode($video['description']);
$video['progress'] = self::getVideoPogressPercent($video['id']);
- if(empty($video['filesize']) && ($video['type']=="video" || $video['type']=="audio")){
+ if (empty($video['filesize']) && ($video['type'] == "video" || $video['type'] == "audio")) {
$video['filesize'] = Video::updateFilesize($video['id']);
}
if (!$ignoreTags) {
@@ -794,16 +787,16 @@ static function getVideoLight($id) {
sqlDAL::close($res);
return $video;
}
-
+
static function getTotalVideosSizeFromUser($users_id) {
global $global, $config;
$users_id = intval($users_id);
$sql = "SELECT sum(filesize) as total FROM videos WHERE 1=1 ";
-
- if(!empty($users_id)){
+
+ if (!empty($users_id)) {
$sql .= " AND users_id = '$users_id'";
}
-
+
$res = sqlDAL::readSql($sql, "", array(), true);
$video = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
@@ -814,11 +807,11 @@ static function getTotalVideosFromUser($users_id) {
global $global, $config;
$users_id = intval($users_id);
$sql = "SELECT count(*) as total FROM videos WHERE 1=1 ";
-
- if(!empty($users_id)){
+
+ if (!empty($users_id)) {
$sql .= " AND users_id = '$users_id'";
}
-
+
$res = sqlDAL::readSql($sql, "", array(), true);
$video = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
@@ -903,7 +896,9 @@ static function getAllVideos($status = "viewable", $showOnlyLoggedUserVideos = f
}
if (AVideoPlugin::isEnabledByName("VideoTags")) {
if (!empty($_GET['tags_id']) && empty($videosArrayId)) {
+ TimeLogStart("video::getAllVideos::getAllVideosIdFromTagsId({$_GET['tags_id']})");
$videosArrayId = VideoTags::getAllVideosIdFromTagsId($_GET['tags_id']);
+ TimeLogEnd("video::getAllVideos::getAllVideosIdFromTagsId({$_GET['tags_id']})", __LINE__);
}
}
$status = str_replace("'", "", $status);
@@ -937,10 +932,12 @@ static function getAllVideos($status = "viewable", $showOnlyLoggedUserVideos = f
$sql .= static::getVideoQueryFileter();
if (!$ignoreGroup) {
+ TimeLogStart("video::getAllVideos::getAllVideosExcludeVideosIDArray");
$arrayNotIN = AVideoPlugin::getAllVideosExcludeVideosIDArray();
if (!empty($arrayNotIN) && is_array($arrayNotIN)) {
$sql .= " AND v.id NOT IN ( '" . implode("', '", $arrayNotIN) . "') ";
}
+ TimeLogEnd("video::getAllVideos::getAllVideosExcludeVideosIDArray", __LINE__);
}
if (!$ignoreGroup) {
$sql .= self::getUserGroupsCanSeeSQL();
@@ -948,6 +945,8 @@ static function getAllVideos($status = "viewable", $showOnlyLoggedUserVideos = f
if (!empty($_SESSION['type'])) {
if ($_SESSION['type'] == 'video' || $_SESSION['type'] == 'linkVideo') {
$sql .= " AND (v.type = 'video' OR v.type = 'embed' OR v.type = 'linkVideo')";
+ } else if ($_SESSION['type'] == 'videoOnly') {
+ $sql .= " AND (v.type = 'video')";
} else if ($_SESSION['type'] == 'audio') {
$sql .= " AND (v.type = 'audio' OR v.type = 'linkAudio')";
} else {
@@ -1008,10 +1007,13 @@ static function getAllVideos($status = "viewable", $showOnlyLoggedUserVideos = f
unset($_POST['sort']['trending']);
unset($_GET['sort']['trending']);
$_POST['sort']['created'] = 'DESC';
+ $current = $_POST['current'];
$rowCount = $_POST['rowCount'];
+ $_POST['current'] = 1;
$_POST['rowCount'] *= 2; // double it to make it random
$rows = self::getAllVideosLight($status, $showOnlyLoggedUserVideos, $showUnlisted);
$_POST['rowCount'] = $rowCount;
+ $_POST['current'] = $current;
$ids = array();
foreach ($rows as $row) {
$ids[] = $row['id'];
@@ -1025,25 +1027,32 @@ static function getAllVideos($status = "viewable", $showOnlyLoggedUserVideos = f
$sql .= " LIMIT 1";
unset($_GET['limitOnceToOne']);
}
-
-//echo $sql;exit;
-//_error_log("getAllVideos($status, $showOnlyLoggedUserVideos , $ignoreGroup , ". json_encode($videosArrayId).")" . $sql);
+ if (strpos(strtolower($sql), 'limit') === false) {
+ if(empty($global['limitForUnlimitedVideos'])){
+ $global['limitForUnlimitedVideos'] = 12;
+ }
+ $sql .= " LIMIT {$global['limitForUnlimitedVideos']}";
+ }
+
+ //echo $sql;exit;
+ //_error_log("getAllVideos($status, $showOnlyLoggedUserVideos , $ignoreGroup , ". json_encode($videosArrayId).")" . $sql);
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
// if there is a search, and there is no data and is inside a channel try again without a channel
- if(!empty($_GET['search']) && empty($fullData) && !empty($_GET['channelName'])){
- $channelName = $_GET['channelName'];
+ if (!empty($_GET['search']) && empty($fullData) && !empty($_GET['channelName'])) {
+ $channelName = $_GET['channelName'];
unset($_GET['channelName']);
$return = self::getAllVideos($status, $showOnlyLoggedUserVideos, $ignoreGroup, $videosArrayId, $getStatistcs, $showUnlisted, $activeUsersOnly, $suggestedOnly);
- $_GET['channelName'] = $channelName;
+ $_GET['channelName'] = $channelName;
return $return;
}
-
+
sqlDAL::close($res);
$videos = array();
if ($res != false) {
require_once 'userGroups.php';
+ TimeLogStart("video::getAllVideos foreach");
foreach ($fullData as $row) {
unset($row['password']);
unset($row['recoverPass']);
@@ -1055,6 +1064,7 @@ static function getAllVideos($status = "viewable", $showOnlyLoggedUserVideos = f
}
}
if ($getStatistcs) {
+ TimeLogStart("video::getAllVideos getStatistcs");
$previewsMonth = date("Y-m-d 00:00:00", strtotime("-30 days"));
$previewsWeek = date("Y-m-d 00:00:00", strtotime("-7 days"));
$today = date('Y-m-d 23:59:59');
@@ -1063,19 +1073,26 @@ static function getAllVideos($status = "viewable", $showOnlyLoggedUserVideos = f
$row['statistc_week'] = VideoStatistic::getStatisticTotalViews($row['id'], false, $previewsWeek, $today);
$row['statistc_month'] = VideoStatistic::getStatisticTotalViews($row['id'], false, $previewsMonth, $today);
$row['statistc_unique_user'] = VideoStatistic::getStatisticTotalViews($row['id'], true);
+ TimeLogEnd("video::getAllVideos getStatistcs", __LINE__);
}
+ TimeLogStart("video::getAllVideos otherInfo");
$row['progress'] = self::getVideoPogressPercent($row['id']);
$row['category'] = xss_esc_back($row['category']);
$row['groups'] = UserGroups::getVideoGroups($row['id']);
$row['tags'] = self::getTags($row['id']);
$row['title'] = UTF8encode($row['title']);
$row['description'] = UTF8encode($row['description']);
- if(empty($row['filesize'])){
+ if (empty($row['filesize'])) {
$row['filesize'] = Video::updateFilesize($row['id']);
}
+ TimeLogEnd("video::getAllVideos otherInfo", __LINE__);
+
+ TimeLogStart("video::getAllVideos getAllVideosArray");
$row = array_merge($row, AVideoPlugin::getAllVideosArray($row['id']));
+ TimeLogEnd("video::getAllVideos getAllVideosArray", __LINE__);
$videos[] = $row;
}
+ TimeLogEnd("video::getAllVideos foreach", __LINE__);
//$videos = $res->fetch_all(MYSQLI_ASSOC);
} else {
$videos = false;
@@ -1083,42 +1100,44 @@ static function getAllVideos($status = "viewable", $showOnlyLoggedUserVideos = f
}
return $videos;
}
-
- static function updateFilesize($videos_id){
+
+ static function updateFilesize($videos_id) {
global $config;
if ($config->currentVersionLowerThen('8.5')) {
return false;
}
- ini_set('max_execution_time', 300);// 5
+ TimeLogStart("Video::updateFilesize {$videos_id}");
+ ini_set('max_execution_time', 300); // 5
set_time_limit(300);
$video = new Video("", "", $videos_id);
$filename = $video->getFilename();
- if(empty($filename) || !($video->getType()=="video" || $video->getType()=="audio" || $video->getType()=="zip" || $video->getType()=="image")){
+ if (empty($filename) || !($video->getType() == "video" || $video->getType() == "audio" || $video->getType() == "zip" || $video->getType() == "image")) {
//_error_log("updateFilesize: Not updated, this filetype is ".$video->getType());
return false;
}
$filesize = getUsageFromFilename($filename);
- if(empty($filesize)){
+ if (empty($filesize)) {
$obj = AVideoPlugin::getObjectDataIfEnabled("DiskUploadQuota");
- if(!empty($obj->deleteVideosWith0Bytes)){
+ if (!empty($obj->deleteVideosWith0Bytes)) {
try {
_error_log("updateFilesize: DELETE videos_id=$videos_id filename=$filename filesize=$filesize");
return $video->delete();
} catch (Exception $exc) {
- _error_log("updateFilesize: ERROR ".$exc->getTraceAsString());
+ _error_log("updateFilesize: ERROR " . $exc->getTraceAsString());
return false;
}
}
}
- if($video->getFilesize()==$filesize){
+ if ($video->getFilesize() == $filesize) {
//_error_log("updateFilesize: No need to update videos_id=$videos_id filename=$filename filesize=$filesize");
return $filesize;
}
$video->setFilesize($filesize);
- if($video->save(false, true)){
+ TimeLogEnd("Video::updateFilesize {$videos_id}", $line);
+ if ($video->save(false, true)) {
_error_log("updateFilesize: videos_id=$videos_id filename=$filename filesize=$filesize");
return $filesize;
- }else{
+ } else {
_error_log("updateFilesize: ERROR videos_id=$videos_id filename=$filename filesize=$filesize");
return false;
}
@@ -1199,24 +1218,27 @@ static function getAllVideosLight($status = "viewable", $showOnlyLoggedUserVideo
$sql .= " AND v.isSuggested = 1 ";
$sql .= " ORDER BY RAND() ";
}
+ if (strpos(strtolower($sql), 'limit') === false) {
+ $sql .= " LIMIT 24";
+ }
//echo $sql;
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
-
+
// if there is a search, and there is no data and is inside a channel try again without a channel
- if(!empty($_GET['search']) && empty($fullData) && !empty($_GET['channelName'])){
- $channelName = $_GET['channelName'];
+ if (!empty($_GET['search']) && empty($fullData) && !empty($_GET['channelName'])) {
+ $channelName = $_GET['channelName'];
unset($_GET['channelName']);
$return = self::getAllVideosLight($status, $showOnlyLoggedUserVideos, $showUnlisted, $suggestedOnly);
- $_GET['channelName'] = $channelName;
+ $_GET['channelName'] = $channelName;
return $return;
}
-
+
sqlDAL::close($res);
$videos = array();
if ($res != false) {
foreach ($fullData as $row) {
- if(empty($row['filesize'])){
+ if (empty($row['filesize'])) {
$row['filesize'] = Video::updateFilesize($row['id']);
}
$videos[] = $row;
@@ -1305,14 +1327,14 @@ static function getTotalVideos($status = "viewable", $showOnlyLoggedUserVideos =
sqlDAL::close($res);
// if there is a search, and there is no data and is inside a channel try again without a channel
- if(!empty($_GET['search']) && empty($numRows) && !empty($_GET['channelName'])){
- $channelName = $_GET['channelName'];
+ if (!empty($_GET['search']) && empty($numRows) && !empty($_GET['channelName'])) {
+ $channelName = $_GET['channelName'];
unset($_GET['channelName']);
$return = self::getTotalVideos($status, $showOnlyLoggedUserVideos, $ignoreGroup, $showUnlisted, $activeUsersOnly, $suggestedOnly);
- $_GET['channelName'] = $channelName;
+ $_GET['channelName'] = $channelName;
return $return;
}
-
+
return $numRows;
}
@@ -2007,10 +2029,15 @@ static function getTags_($video_id, $type = "") {
if (empty($type) || $type === "category") {
require_once 'category.php';
+ $sort = null;
if (!empty($_POST['sort']['title'])) {
+ $sort = $_POST['sort'];
unset($_POST['sort']);
}
$category = Category::getCategory($video->getCategories_id());
+ if (!empty($sort)) {
+ $_POST['sort'] = $sort;
+ }
$objTag = new stdClass();
$objTag->label = __("Category");
if (!empty($category)) {
@@ -2310,7 +2337,7 @@ function setTitle($title) {
$this->title = substr($this->title, 0, 187) . '...';
}
- function setFilename($filename, $force=false) {
+ function setFilename($filename, $force = false) {
if ($force || empty($this->filename)) {
$this->filename = $filename;
}
@@ -2325,7 +2352,7 @@ function setNext_videos_id($next_videos_id) {
$this->next_videos_id = $next_videos_id;
}
- function queue($types=array()) {
+ function queue($types = array()) {
global $config;
if (!User::canUpload()) {
return false;
@@ -2346,7 +2373,7 @@ function queue($types=array()) {
if (empty($types) && AVideoPlugin::isEnabledByName("VideoHLS")) {
$postFields['inputHLS'] = 1;
- }else if(!empty ($types)){
+ } else if (!empty($types)) {
foreach ($types as $key => $value) {
$postFields[$key] = $value;
}
@@ -2447,8 +2474,8 @@ static function getSourceFile($filename, $type = ".jpg", $includeS3 = false) {
if (!empty($secure)) {
$vars[] = $secure->getToken($filename);
}
- if(!empty($vars)){
- $token = "?".implode("&", $vars);
+ if (!empty($vars)) {
+ $token = "?" . implode("&", $vars);
}
}
$source = array();
@@ -2585,12 +2612,12 @@ static function getPoster($videos_id) {
}
static function clearImageCache($filename, $type = "video") {
- $cacheFileName = "getImageFromFilename_".$filename . $type . (get_browser_name() == 'Safari' ? "s" : "");
+ $cacheFileName = "getImageFromFilename_" . $filename . $type . (get_browser_name() == 'Safari' ? "s" : "");
return ObjectYPT::deleteCache($cacheFileName);
}
-
+
static function getImageFromFilename_($filename, $type = "video") {
- $cacheFileName = "getImageFromFilename_".$filename . $type . (get_browser_name() == 'Safari' ? "s" : "");
+ $cacheFileName = "getImageFromFilename_" . $filename . $type . (get_browser_name() == 'Safari' ? "s" : "");
$cache = ObjectYPT::getCache($cacheFileName, 0);
if (!empty($cache)) {
return $cache;
@@ -2630,18 +2657,18 @@ static function getImageFromFilename_($filename, $type = "video") {
if (!file_exists($jpegPortraitThumbs['path']) && filesize($jpegPortraitSource['path']) > 1024) {
_error_log("Resize JPG {$jpegPortraitSource['path']}, {$jpegPortraitThumbs['path']}");
if (!empty($advancedCustom->useFFMPEGToGenerateThumbs)) {
- im_resizeV3($jpegPortraitSource['path'], $jpegPortraitThumbs['path'], 170, 250);
+ im_resizeV3($jpegPortraitSource['path'], $jpegPortraitThumbs['path'], $advancedCustom->thumbsWidthPortrait, $advancedCustom->thumbsHeightPortrait);
} else {
- im_resizeV2($jpegPortraitSource['path'], $jpegPortraitThumbs['path'], 170, 250);
+ im_resizeV2($jpegPortraitSource['path'], $jpegPortraitThumbs['path'], $advancedCustom->thumbsWidthPortrait, $advancedCustom->thumbsHeightPortrait);
}
}
// create thumbs
if (!file_exists($jpegPortraitThumbsSmall['path']) && filesize($jpegPortraitSource['path']) > 1024) {
_error_log("Resize JPG {$jpegPortraitSource['path']}, {$jpegPortraitThumbsSmall['path']}");
if (!empty($advancedCustom->useFFMPEGToGenerateThumbs)) {
- im_resizeV3($jpegPortraitSource['path'], $jpegPortraitThumbsSmall['path'], 170, 250);
+ im_resizeV3($jpegPortraitSource['path'], $jpegPortraitThumbsSmall['path'], $advancedCustom->thumbsWidthPortrait, $advancedCustom->thumbsHeightPortrait);
} else {
- im_resizeV2($jpegPortraitSource['path'], $jpegPortraitThumbsSmall['path'], 170, 250, 5);
+ im_resizeV2($jpegPortraitSource['path'], $jpegPortraitThumbsSmall['path'], $advancedCustom->thumbsWidthPortrait, $advancedCustom->thumbsHeightPortrait, 5);
}
}
} else {
@@ -2656,11 +2683,11 @@ static function getImageFromFilename_($filename, $type = "video") {
$obj->posterPortraitThumbs = "{$global['webSiteRootURL']}view/img/pdf_portrait.png";
$obj->posterPortraitThumbsSmall = "{$global['webSiteRootURL']}view/img/pdf_portrait.png";
} /* else if ($type == "image") {
- $obj->posterPortrait = "{$global['webSiteRootURL']}view/img/image_portrait.png";
- $obj->posterPortraitPath = "{$global['systemRootPath']}view/img/image_portrait.png";
- $obj->posterPortraitThumbs = "{$global['webSiteRootURL']}view/img/image_portrait.png";
- $obj->posterPortraitThumbsSmall = "{$global['webSiteRootURL']}view/img/image_portrait.png";
- } */ else if ($type == "zip") {
+ $obj->posterPortrait = "{$global['webSiteRootURL']}view/img/image_portrait.png";
+ $obj->posterPortraitPath = "{$global['systemRootPath']}view/img/image_portrait.png";
+ $obj->posterPortraitThumbs = "{$global['webSiteRootURL']}view/img/image_portrait.png";
+ $obj->posterPortraitThumbsSmall = "{$global['webSiteRootURL']}view/img/image_portrait.png";
+ } */ else if ($type == "zip") {
$obj->posterPortrait = "{$global['webSiteRootURL']}view/img/zip_portrait.png";
$obj->posterPortraitPath = "{$global['systemRootPath']}view/img/zip_portrait.png";
$obj->posterPortraitThumbs = "{$global['webSiteRootURL']}view/img/zip_portrait.png";
@@ -2680,18 +2707,18 @@ static function getImageFromFilename_($filename, $type = "video") {
if (!file_exists($thumbsSource['path']) && filesize($jpegSource['path']) > 1024) {
_error_log("Resize JPG {$jpegSource['path']}, {$thumbsSource['path']}");
if (!empty($advancedCustom->useFFMPEGToGenerateThumbs)) {
- im_resizeV3($jpegSource['path'], $thumbsSource['path'], 250, 140);
+ im_resizeV3($jpegSource['path'], $thumbsSource['path'], $advancedCustom->thumbsWidthLandscape, $advancedCustom->thumbsHeightLandscape);
} else {
- im_resizeV2($jpegSource['path'], $thumbsSource['path'], 250, 140);
+ im_resizeV2($jpegSource['path'], $thumbsSource['path'], $advancedCustom->thumbsWidthLandscape, $advancedCustom->thumbsHeightLandscape);
}
}
// create thumbs
if (!file_exists($thumbsSmallSource['path']) && filesize($jpegSource['path']) > 1024) {
_error_log("Resize Small JPG {$jpegSource['path']}, {$thumbsSmallSource['path']}");
if (!empty($advancedCustom->useFFMPEGToGenerateThumbs)) {
- im_resizeV3($jpegSource['path'], $thumbsSmallSource['path'], 250, 140);
+ im_resizeV3($jpegSource['path'], $thumbsSmallSource['path'], $advancedCustom->thumbsWidthLandscape, $advancedCustom->thumbsHeightLandscape);
} else {
- im_resizeV2($jpegSource['path'], $thumbsSmallSource['path'], 250, 140, 5);
+ im_resizeV2($jpegSource['path'], $thumbsSmallSource['path'], $advancedCustom->thumbsWidthLandscape, $advancedCustom->thumbsHeightLandscape, 5);
}
}
} else {
@@ -2703,11 +2730,11 @@ static function getImageFromFilename_($filename, $type = "video") {
$obj->poster = "{$global['webSiteRootURL']}view/img/pdf.png";
$obj->thumbsJpg = "{$global['webSiteRootURL']}view/img/pdf.png";
$obj->thumbsJpgSmall = "{$global['webSiteRootURL']}view/img/pdf.png";
- } else if ($type == "image") {
+ } else if ($type == "image") {
$obj->poster = "{$global['webSiteRootURL']}view/img/image.png";
$obj->thumbsJpg = "{$global['webSiteRootURL']}view/img/image.png";
$obj->thumbsJpgSmall = "{$global['webSiteRootURL']}view/img/image.png";
- } else if ($type == "zip") {
+ } else if ($type == "zip") {
$obj->poster = "{$global['webSiteRootURL']}view/img/zip.png";
$obj->thumbsJpg = "{$global['webSiteRootURL']}view/img/zip.png";
$obj->thumbsJpgSmall = "{$global['webSiteRootURL']}view/img/zip.png";
@@ -2970,7 +2997,7 @@ static function deleteThumbs($filename, $doNotDeleteSprit = false) {
$files = glob("{$filePath}*_thumbs*.jpg");
foreach ($files as $file) {
if (file_exists($file)) {
- if($doNotDeleteSprit && strpos($file, '_thumbsSprit.jpg') !== false){
+ if ($doNotDeleteSprit && strpos($file, '_thumbsSprit.jpg') !== false) {
continue;
}
@unlink($file);
@@ -2985,6 +3012,7 @@ static function deleteThumbs($filename, $doNotDeleteSprit = false) {
Video::clearImageCache($filename, "pdf");
Video::clearImageCache($filename, "audio");
clearVideosURL($filename);
+ return true;
}
static function getVideoPogress($videos_id, $users_id = 0) {
@@ -3088,17 +3116,21 @@ static function isPublic($videos_id) {
}
static function userGroupAndVideoGroupMatch($users_id, $videos_id) {
-
if (empty($videos_id)) {
return false;
}
+
+ $ppv = AVideoPlugin::loadPluginIfEnabled("PayPerView");
+ if ($ppv) {
+ $ppv->userCanWatchVideo($users_id, $videos_id);
+ }
// check if the video is not public
$rows = UserGroups::getVideoGroups($videos_id);
if (empty($rows)) {
return true;
}
- if (empty($users_id) || empty($videos_id)) {
+ if (empty($users_id)) {
return false;
}
diff --git a/objects/videoSwap.json.php b/objects/videoSwap.json.php
index d9793da02d35..a8a9c50a35bf 100644
--- a/objects/videoSwap.json.php
+++ b/objects/videoSwap.json.php
@@ -10,6 +10,10 @@
$obj->msg = "";
$obj->error = true;
+if (empty($advancedCustom->disableVideoSwap) && (empty($advancedCustom->makeSwapVideosOnlyForAdmin) || User::isAdmin())) {
+ $obj->msg = __("Swap Disabled");
+ die(json_encode($obj));
+}
if (!User::canUpload()) {
$obj->msg = __("Permission denied");
diff --git a/objects/videos.json.php b/objects/videos.json.php
index 21146f8c93f5..0908ba84bb16 100644
--- a/objects/videos.json.php
+++ b/objects/videos.json.php
@@ -4,6 +4,7 @@
if(!isset($global['systemRootPath'])){
require_once '../videos/configuration.php';
}
+session_write_close();
require_once $global['systemRootPath'] . 'objects/video.php';
require_once $global['systemRootPath'] . 'objects/functions.php';
header('Content-Type: application/json');
diff --git a/plugin/AD_Server/Objects/VastCampaigns.php b/plugin/AD_Server/Objects/VastCampaigns.php
index 0de7ab84116e..d56fac4d3fe3 100644
--- a/plugin/AD_Server/Objects/VastCampaigns.php
+++ b/plugin/AD_Server/Objects/VastCampaigns.php
@@ -202,15 +202,16 @@ function addVideo($videos_id, $status = 'a') {
static public function getValidCampaigns() {
global $global;
-
$ad_server_location = AVideoPlugin::loadPluginIfEnabled('AD_Server_Location');
+ AVideoPlugin::loadPlugin('User_Location');
+ $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 ";
- if(!empty($ad_server_location) && !empty($_SESSION['User_Location']) && $_SESSION['User_Location']['country_name'] !== '-'){
+ if(!empty($ad_server_location) && !empty($User_Location) && $User_Location['country_name'] !== '-'){
// 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 "
- . " (country_name = \"{$_SESSION['User_Location']['country_name']}\" AND region_name = 'All') OR "
- . " (country_name = \"{$_SESSION['User_Location']['country_name']}\" AND region_name = \"{$_SESSION['User_Location']['region_name']}\" AND city_name = 'All') OR"
- . " (country_name = \"{$_SESSION['User_Location']['country_name']}\" AND region_name = \"{$_SESSION['User_Location']['region_name']}\" AND city_name = \"{$_SESSION['User_Location']['city_name']}\") ) ) "
+ . " (country_name = \"{$User_Location['country_name']}\" AND region_name = 'All') OR "
+ . " (country_name = \"{$User_Location['country_name']}\" AND region_name = \"{$User_Location['region_name']}\" AND city_name = 'All') OR"
+ . " (country_name = \"{$User_Location['country_name']}\" AND region_name = \"{$User_Location['region_name']}\" AND city_name = \"{$User_Location['city_name']}\") ) ) "
. " OR vc.id NOT IN(SELECT vast_campaigns_id FROM campaign_locations) )";
}
diff --git a/plugin/API/API.php b/plugin/API/API.php
index cd2772443b02..c264bfcbdbd0 100644
--- a/plugin/API/API.php
+++ b/plugin/API/API.php
@@ -173,14 +173,14 @@ public function get_api_video($parameters) {
if (empty($value['filename'])) {
continue;
}
- if($value['type']=='serie'){
+ if ($value['type'] == 'serie') {
require_once $global['systemRootPath'] . 'objects/playlist.php';
$rows[$key]['playlist'] = PlayList::getVideosFromPlaylist($value['serie_playlists_id']);
}
$images = Video::getImageFromFilename($rows[$key]['filename'], $rows[$key]['type']);
$rows[$key]['images'] = $images;
$rows[$key]['videos'] = Video::getVideosPaths($value['filename'], true);
- if(empty($rows[$key]['videos'])){
+ if (empty($rows[$key]['videos'])) {
$rows[$key]['videos'] = new stdClass();
}
$rows[$key]['Poster'] = !empty($objMob->portraitImage) ? $images->posterPortrait : $images->poster;
@@ -193,7 +193,7 @@ public function get_api_video($parameters) {
if ($SubtitleSwitcher) {
$rows[$key]['subtitles'] = getVTTTracks($value['filename'], true);
- foreach ($rows[$key]['subtitles'] as $key2=>$value) {
+ foreach ($rows[$key]['subtitles'] as $key2 => $value) {
$rows[$key]['subtitlesSRT'][] = convertSRTTrack($value);
}
}
@@ -235,7 +235,7 @@ public function get_api_video($parameters) {
$obj->rows = $rows;
return new ApiObject("", false, $obj);
}
-
+
/**
* @param type $parameters
* ['APISecret' to list all videos]
@@ -261,7 +261,7 @@ public function get_api_videosCount($parameters) {
$obj->totalRows = $totalRows;
return new ApiObject("", false, $obj);
}
-
+
/**
* Return a user information
* @param type $parameters
@@ -277,30 +277,29 @@ public function get_api_user($parameters) {
$obj = $this->startResponseObject($parameters);
$dataObj = $this->getDataObject();
if ($dataObj->APISecret === @$_GET['APISecret']) {
- if(!empty($_GET['users_id'])){
+ if (!empty($_GET['users_id'])) {
$user = new User($_GET['users_id']);
- }else if(!empty($_GET['user'])){
+ } else if (!empty($_GET['user'])) {
$user = new User(0, $_GET['user'], false);
- }else{
+ } else {
return new ApiObject("User Not defined");
}
-
- if(empty($user) || empty($user->getId())){
+
+ if (empty($user) || empty($user->getId())) {
return new ApiObject("User Not found");
}
$p = AVideoPlugin::loadPlugin("Live");
-
+
$obj->user = User::getUserFromID($user->getBdId());
$obj->livestream = LiveTransmition::getFromDbByUser($user->getBdId());
- $obj->livestream["server"] = $p->getServer()."?p=".$user->getPassword();
-
+ $obj->livestream["server"] = $p->getServer() . "?p=" . $user->getPassword();
+
return new ApiObject("", false, $obj);
} else {
return new ApiObject("API Secret is not valid");
}
}
-
-
+
/**
* @param type $parameters
* @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
@@ -311,7 +310,7 @@ public function get_api_livestreams($parameters) {
require_once $global['systemRootPath'] . 'plugin/Live/stats.json.php';
exit;
}
-
+
/**
* @param type $parameters
* ['APISecret' to list all videos]
@@ -358,6 +357,79 @@ public function get_api_videosViewsCount($parameters) {
return new ApiObject("", false, $obj);
}
+ /**
+ * @param type $parameters
+ * Return all channels on this site
+ * @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
+ * @return \ApiObject
+ */
+ public function get_api_channels($parameters) {
+ global $global;
+ require_once $global['systemRootPath'] . 'objects/Channel.php';
+ $channels = Channel::getChannels();
+ $list = array();
+ foreach ($channels as $value) {
+ $obj = new stdClass();
+ $obj->id = $value['id'];
+ $obj->photo = User::getPhoto($value['id']);
+ $obj->channelLink = User::getChannelLink($value['id']);
+ $obj->name = User::getNameIdentificationById($value['id']);
+ $list[] = $obj;
+ }
+ return new ApiObject("", false, $list);
+ }
+
+ /**
+ * @param type $parameters
+ * Return all Programs (Playlists) on this site
+ * @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
+ * @return \ApiObject
+ */
+ public function get_api_programs($parameters) {
+ global $global;
+ require_once $global['systemRootPath'] . 'objects/category.php';
+ $playlists = PlayList::getAll();
+ foreach ($playlists as $value) {
+ $videosArrayId = PlayList::getVideosIdFromPlaylist($value['id']);
+ if (empty($videosArrayId) || $value['status'] == "favorite" || $value['status'] == "watch_later") {
+ continue;
+ }
+ $obj = new stdClass();
+ $obj->id = $value['id'];
+ $obj->photo = User::getPhoto($value['users_id']);
+ $obj->channelLink = User::getChannelLink($value['users_id']);
+ $obj->username = User::getNameIdentificationById($value['users_id']);
+ $obj->name = $value['name'];
+ $obj->link = PlayLists::getLink($value['id']);
+ $list[] = $obj;
+ }
+ return new ApiObject("", false, $list);
+ }
+
+ /**
+ * @param type $parameters
+ * Return all categories on this site
+ * @example {webSiteRootURL}plugin/API/{getOrSet}.json.php?APIName={APIName}
+ * @return \ApiObject
+ */
+ public function get_api_categories($parameters) {
+ global $global;
+ require_once $global['systemRootPath'] . 'objects/category.php';
+ $categories = Category::getAllCategories();
+ array_multisort(array_column($categories, 'hierarchyAndName'), SORT_ASC, $categories);
+ $list = array();
+ foreach ($categories as $value) {
+ $obj = new stdClass();
+ $obj->id = $value['id'];
+ $obj->iconClass = $value['iconClass'];
+ $obj->hierarchyAndName = $value['hierarchyAndName'];
+ $obj->name = $value['name'];
+ $obj->fullTotal = $value['fullTotal'];
+ $obj->total = $value['total'];
+ $list[] = $obj;
+ }
+ return new ApiObject("", false, $list);
+ }
/**
* @param type $parameters
diff --git a/plugin/API/status.json.php b/plugin/API/status.json.php
new file mode 100644
index 000000000000..36f9b02930a1
--- /dev/null
+++ b/plugin/API/status.json.php
@@ -0,0 +1,22 @@
+showAds($videos_id);
+ $showAds = $p->showAds($videos_id);
+ if(!$showAds){
+ _error_log("showAds: {$value['dirName']} said NOT to show ads on {$videos_id}");
+ return false;
+ }
}
self::YPTend("{$value['dirName']}::".__FUNCTION__);
}
@@ -1065,23 +1069,23 @@ public static function getVideoTags($videos_id){
if(empty($videos_id)){
return array();
}
+ TimeLogStart("AVideoPlugin::getVideoTags($videos_id)");
if(true || empty($_SESSION['getVideoTags'][$videos_id])){
$plugins = Plugin::getAllEnabled();
$array = array();
foreach ($plugins as $value) {
- self::YPTstart();
+ $TimeLog = "AVideoPlugin::getVideoTags($videos_id) {$value['dirName']} ";
+ TimeLogStart($TimeLog);
$p = static::loadPlugin($value['dirName']);
if (is_object($p)) {
$array = array_merge($array, $p->getVideoTags($videos_id));
}
- self::YPTend("{$value['dirName']}::".__FUNCTION__);
- }
- if (session_status() == PHP_SESSION_NONE) {
- session_start();
+ TimeLogEnd($TimeLog, __LINE__, 0.1);
}
+ _session_start();
$_SESSION['getVideoTags'][$videos_id] = $array;
- session_write_close();
}
+ TimeLogEnd("AVideoPlugin::getVideoTags($videos_id)", __LINE__);
return $_SESSION['getVideoTags'][$videos_id];
}
diff --git a/plugin/Cache/Cache.php b/plugin/Cache/Cache.php
index 0bd7e7871bed..1d7ba15ca15f 100644
--- a/plugin/Cache/Cache.php
+++ b/plugin/Cache/Cache.php
@@ -198,12 +198,12 @@ private function start() {
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
- $global['start'] = $time;
+ $global['cachePluginStart'] = $time;
}
private function end($type = "No Cache") {
global $global;
- if (empty($global['start'])) {
+ if (empty($global['cachePluginStart'])) {
return false;
}
require_once $global['systemRootPath'] . 'objects/user.php';
@@ -217,7 +217,7 @@ private function end($type = "No Cache") {
} else {
$type = "User: Not Logged - " . $type;
}
- $t = (floatval($finish) - floatval($global['start']));
+ $t = (floatval($finish) - floatval($global['cachePluginStart']));
$total_time = round($t, 4);
_error_log("Page generated in {$total_time} seconds. {$type} ({$_SERVER['REQUEST_URI']}) FROM: {$_SERVER['REMOTE_ADDR']} Browser: {$_SERVER['HTTP_USER_AGENT']}");
}
diff --git a/plugin/CloneSite/cloneClient.json.php b/plugin/CloneSite/cloneClient.json.php
index e90a9ce1f976..978fc2c536ca 100644
--- a/plugin/CloneSite/cloneClient.json.php
+++ b/plugin/CloneSite/cloneClient.json.php
@@ -27,6 +27,7 @@
$log->add("Clone: Clone Start");
$objClone = AVideoPlugin::getObjectDataIfEnabled("CloneSite");
+$argv[1] = preg_replace("/[^A-Za-z0-9 ]/", '', @$argv[1]);
if (empty($objClone) || empty($argv[1]) || $objClone->myKey !== $argv[1]) {
if (!User::isAdmin()) {
diff --git a/plugin/CustomizeAdvanced/CustomizeAdvanced.php b/plugin/CustomizeAdvanced/CustomizeAdvanced.php
index b1bddeca9ef2..35cf4a2e1aa4 100644
--- a/plugin/CustomizeAdvanced/CustomizeAdvanced.php
+++ b/plugin/CustomizeAdvanced/CustomizeAdvanced.php
@@ -109,6 +109,10 @@ public function getEmptyDataObject() {
$obj->disableNavbar= false;
$obj->videosCDN = "";
$obj->useFFMPEGToGenerateThumbs = false;
+ $obj->thumbsWidthPortrait = 170;
+ $obj->thumbsHeightPortrait = 250;
+ $obj->thumbsWidthLandscape = 250;
+ $obj->thumbsHeightLandscape = 140;
$obj->showImageDownloadOption = false;
$obj->doNotDisplayViews = false;
$obj->doNotDisplayLikes = false;
@@ -153,6 +157,7 @@ public function getEmptyDataObject() {
$obj->disableHTMLDescription = false;
$obj->disableTopMenusInsideIframe = true;
$obj->disableVideoSwap = false;
+ $obj->makeSwapVideosOnlyForAdmin = false;
$parse = parse_url($global['webSiteRootURL']);
$domain = str_replace(".", "", $parse['host']);
@@ -231,7 +236,8 @@ public static function getVideoWhereClause() {
public function getVideosManagerListButton(){
$btn = "";
if(User::isAdmin()){
- $btn = '
';
+ $btn = '';
+ $btn .= '';
}
return $btn;
}
@@ -263,6 +269,30 @@ public function getHeadCode(){
modal.hidePleaseWait();
}
});}";
+ $js .= "";
}
return $js;
}
diff --git a/plugin/CustomizeAdvanced/deleteThumbs.php b/plugin/CustomizeAdvanced/deleteThumbs.php
new file mode 100644
index 000000000000..7452149aa6ec
--- /dev/null
+++ b/plugin/CustomizeAdvanced/deleteThumbs.php
@@ -0,0 +1,24 @@
+error = true;
+$obj->msg = "";
+
+
+if (!User::isAdmin()) {
+ $obj->msg = __("Permission denied");
+ die(json_encode($obj));
+}
+if(empty($_POST['videos_id'])){
+ $obj->msg = __("Video Not found");
+ die(json_encode($obj));
+}
+
+$videos_id = intval($_POST['videos_id']);
+$video = new Video("","", $videos_id);
+$obj->error = empty(Video::deleteThumbs($video->getFilename()));
+
+die(json_encode($obj));
+
diff --git a/plugin/CustomizeUser/CustomizeUser.php b/plugin/CustomizeUser/CustomizeUser.php
index d5af18d6be82..6ca299e6543b 100644
--- a/plugin/CustomizeUser/CustomizeUser.php
+++ b/plugin/CustomizeUser/CustomizeUser.php
@@ -29,6 +29,7 @@ public function getEmptyDataObject() {
$obj->userCanAllowFilesShare = false;
$obj->userCanAllowFilesDownloadSelectPerVideo = false;
$obj->userCanAllowFilesShareSelectPerVideo = false;
+ $obj->blockEmbedFromSharedVideos = true;
$obj->userCanProtectVideosWithPassword = true;
$obj->usersCanCreateNewCategories = !isset($advancedCustom->usersCanCreateNewCategories) ? false : $advancedCustom->usersCanCreateNewCategories;
@@ -149,6 +150,7 @@ static function canShareVideosFromUser($users_id) {
global $advancedCustom;
if (!empty($advancedCustom->disableShareAndPlaylist)) {
+ _error_log("CustomizeUser::canShareVideosFromUser disableShareAndPlaylist");
return false;
}
@@ -258,15 +260,18 @@ static function canDownloadVideosFromVideo($videos_id) {
static function canShareVideosFromVideo($videos_id) {
$video = new Video("", "", $videos_id);
if (empty($video)) {
+ _error_log("CustomizeUser::canShareVideosFromVideo video not found");
return false;
}
$users_id = $video->getUsers_id();
if (!self::canShareVideosFromUser($users_id)) {
+ _error_log("CustomizeUser::canShareVideosFromVideo canShareVideosFromUser($users_id) = false");
return false;
}
$obj = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser");
- if (!empty($obj->userCanAllowFilesShareSelectPerVideo)) {
+ if (!empty($obj->userCanAllowFilesShareSelectPerVideo) && !empty($obj->blockEmbedFromSharedVideos)) {
if (empty($video->getCan_share())) {
+ _error_log("CustomizeUser::canShareVideosFromVideo video->getCan_share() = false");
return false;
}
}
diff --git a/plugin/FBTube/view/getVideos.php b/plugin/FBTube/view/getVideos.php
index d391e6c0d51c..ec61c7501da7 100644
--- a/plugin/FBTube/view/getVideos.php
+++ b/plugin/FBTube/view/getVideos.php
@@ -138,7 +138,7 @@ class="embed-responsive-item video-js vjs-default-skin
-
+