diff --git a/composer.lock b/composer.lock
index 1b796cca3d..7a32fa0b5c 100644
--- a/composer.lock
+++ b/composer.lock
@@ -281,16 +281,16 @@
},
{
"name": "aws/aws-sdk-php",
- "version": "3.275.7",
+ "version": "3.276.3",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
- "reference": "54dcef3349c81b46c0f5f6e54b5f9bfb5db19903"
+ "reference": "c8b38cfab677a3ec98e3f40bccd1a2bf851a014f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/54dcef3349c81b46c0f5f6e54b5f9bfb5db19903",
- "reference": "54dcef3349c81b46c0f5f6e54b5f9bfb5db19903",
+ "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/c8b38cfab677a3ec98e3f40bccd1a2bf851a014f",
+ "reference": "c8b38cfab677a3ec98e3f40bccd1a2bf851a014f",
"shasum": ""
},
"require": {
@@ -370,9 +370,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
- "source": "https://github.com/aws/aws-sdk-php/tree/3.275.7"
+ "source": "https://github.com/aws/aws-sdk-php/tree/3.276.3"
},
- "time": "2023-07-13T18:21:04+00:00"
+ "time": "2023-07-21T18:30:18+00:00"
},
{
"name": "brick/math",
@@ -3988,16 +3988,16 @@
},
{
"name": "stripe/stripe-php",
- "version": "v10.17.0",
+ "version": "v10.18.0",
"source": {
"type": "git",
"url": "https://github.com/stripe/stripe-php.git",
- "reference": "73383b44de153f4d602b90dad3ef075259bcecef"
+ "reference": "c32549e443a619d1b885b99d624568ecae82d6a0"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/stripe/stripe-php/zipball/73383b44de153f4d602b90dad3ef075259bcecef",
- "reference": "73383b44de153f4d602b90dad3ef075259bcecef",
+ "url": "https://api.github.com/repos/stripe/stripe-php/zipball/c32549e443a619d1b885b99d624568ecae82d6a0",
+ "reference": "c32549e443a619d1b885b99d624568ecae82d6a0",
"shasum": ""
},
"require": {
@@ -4043,9 +4043,9 @@
],
"support": {
"issues": "https://github.com/stripe/stripe-php/issues",
- "source": "https://github.com/stripe/stripe-php/tree/v10.17.0"
+ "source": "https://github.com/stripe/stripe-php/tree/v10.18.0"
},
- "time": "2023-07-13T22:12:18+00:00"
+ "time": "2023-07-20T16:59:49+00:00"
},
{
"name": "symfony/console",
diff --git a/objects/functions.php b/objects/functions.php
index 4e080d6523..66d58aa514 100644
--- a/objects/functions.php
+++ b/objects/functions.php
@@ -18,15 +18,16 @@ if (!isset($global) || !is_array($global)) {
*/
if (!function_exists('str_starts_with')) {
- function str_starts_with(string $Haystack, string $Needle): bool {
+ function str_starts_with(string $Haystack, string $Needle): bool
+ {
return substr($Haystack, 0, strlen($Needle)) === $Needle;
}
-
}
if (!function_exists('xss_esc')) {
- function xss_esc($text) {
+ function xss_esc($text)
+ {
if (empty($text)) {
return "";
}
@@ -45,10 +46,10 @@ if (!function_exists('xss_esc')) {
$result = str_ireplace(['&'], ['&'], $result);
return $result;
}
-
}
-function xss_esc_back($text) {
+function xss_esc_back($text)
+{
if (!isset($text)) {
return '';
}
@@ -58,23 +59,24 @@ function xss_esc_back($text) {
}
// Make sure SecureVideosDirectory will be the first
-function cmpPlugin($a, $b) {
+function cmpPlugin($a, $b)
+{
if (
- $a['name'] === 'SecureVideosDirectory' ||
- $a['name'] === 'GoogleAds_IMA' ||
- $a['name'] === 'Subscription' ||
- $a['name'] === 'PayPerView' ||
- $a['name'] === 'FansSubscriptions'
+ $a['name'] === 'SecureVideosDirectory' ||
+ $a['name'] === 'GoogleAds_IMA' ||
+ $a['name'] === 'Subscription' ||
+ $a['name'] === 'PayPerView' ||
+ $a['name'] === 'FansSubscriptions'
) {
return -1;
} elseif ($a['name'] === 'PlayerSkins') {
return 1;
} elseif (
- $b['name'] === 'SecureVideosDirectory' ||
- $b['name'] === 'GoogleAds_IMA' ||
- $b['name'] === 'Subscription' ||
- $b['name'] === 'PayPerView' ||
- $b['name'] === 'FansSubscriptions'
+ $b['name'] === 'SecureVideosDirectory' ||
+ $b['name'] === 'GoogleAds_IMA' ||
+ $b['name'] === 'Subscription' ||
+ $b['name'] === 'PayPerView' ||
+ $b['name'] === 'FansSubscriptions'
) {
return 1;
} elseif ($b['name'] === 'PlayerSkins') {
@@ -85,7 +87,8 @@ function cmpPlugin($a, $b) {
// Returns a file size limit in bytes based on the PHP upload_max_filesize
// and post_max_size
-function file_upload_max_size() {
+function file_upload_max_size()
+{
static $max_size = -1;
if ($max_size < 0) {
@@ -102,7 +105,8 @@ function file_upload_max_size() {
return $max_size;
}
-function parse_size($size) {
+function parse_size($size)
+{
$unit = preg_replace('/[^bkmgtpezy]/i', '', $size); // Remove the non-unit characters from the size.
$size = preg_replace('/[^0-9\.]/', '', $size); // Remove the non-numeric characters from the size.
if ($unit) {
@@ -113,7 +117,8 @@ function parse_size($size) {
}
}
-function humanFileSize($size, $unit = "") {
+function humanFileSize($size, $unit = "")
+{
if ((!$unit && $size >= 1 << 30) || $unit == "GB") {
return number_format($size / (1 << 30), 2) . "GB";
}
@@ -129,11 +134,13 @@ function humanFileSize($size, $unit = "") {
return number_format($size) . " bytes";
}
-function get_max_file_size() {
+function get_max_file_size()
+{
return humanFileSize(file_upload_max_size());
}
-function humanTiming($time, $precision = 0, $useDatabaseTime = true, $addAgo = false) {
+function humanTiming($time, $precision = 0, $useDatabaseTime = true, $addAgo = false)
+{
if (empty($time)) {
return '';
}
@@ -153,7 +160,8 @@ function humanTiming($time, $precision = 0, $useDatabaseTime = true, $addAgo = f
* @param string $useDatabaseTime good if you are checking the created time
* @return string
*/
-function humanTimingAgo($time, $precision = 0, $useDatabaseTime = true) {
+function humanTimingAgo($time, $precision = 0, $useDatabaseTime = true)
+{
$time = secondsIntervalFromNow($time, $useDatabaseTime);
if (empty($time)) {
return __("Now");
@@ -161,7 +169,8 @@ function humanTimingAgo($time, $precision = 0, $useDatabaseTime = true) {
return sprintf(__('%s ago'), secondsToHumanTiming($time, $precision));
}
-function humanTimingAfterwards($time, $precision = 0, $useDatabaseTime = true) {
+function humanTimingAfterwards($time, $precision = 0, $useDatabaseTime = true)
+{
if (!is_numeric($time)) {
$time = strtotime($time);
}
@@ -174,7 +183,8 @@ function humanTimingAfterwards($time, $precision = 0, $useDatabaseTime = true) {
return __('Coming in') . ' ' . secondsToHumanTiming($time, $precision);
}
-function secondsToHumanTiming($time, $precision = 0, $addAgo = false) {
+function secondsToHumanTiming($time, $precision = 0, $addAgo = false)
+{
if (empty($time)) {
return __("Now");
}
@@ -237,7 +247,8 @@ function secondsToHumanTiming($time, $precision = 0, $addAgo = false) {
}
}
-function checkVideosDir() {
+function checkVideosDir()
+{
$dir = "../videos";
if (file_exists($dir)) {
return is_writable($dir);
@@ -245,15 +256,18 @@ function checkVideosDir() {
return mkdir($dir);
}
-function isApache() {
+function isApache()
+{
return (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false);
}
-function isPHP($version = "'7.3.0'") {
+function isPHP($version = "'7.3.0'")
+{
return (version_compare(PHP_VERSION, $version) >= 0);
}
-function modEnabled($mod_name) {
+function modEnabled($mod_name)
+{
if (!function_exists('apache_get_modules')) {
_ob_start();
phpinfo(INFO_MODULES);
@@ -264,77 +278,91 @@ function modEnabled($mod_name) {
return in_array('mod_' . $mod_name, apache_get_modules());
}
-function modRewriteEnabled() {
+function modRewriteEnabled()
+{
return modEnabled("rewrite");
}
-function modAliasEnabled() {
+function modAliasEnabled()
+{
return modEnabled("alias");
}
-function isFFMPEG() {
+function isFFMPEG()
+{
return trim(shell_exec('which ffmpeg'));
}
-function isUnzip() {
+function isUnzip()
+{
return trim(shell_exec('which unzip'));
}
-function isExifToo() {
+function isExifToo()
+{
return trim(shell_exec('which exiftool'));
}
-function isAPPInstalled($appName) {
+function isAPPInstalled($appName)
+{
$appName = preg_replace('/[^a-z0-9_-]/i', '', $appName);
return trim(shell_exec("which {$appName}"));
}
-function getPathToApplication() {
+function getPathToApplication()
+{
return str_replace(['install/index.php', 'view/configurations.php'], '', $_SERVER['SCRIPT_FILENAME']);
}
-function getURLToApplication() {
+function getURLToApplication()
+{
$url = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$url = explode("install/index.php", $url);
return $url[0];
}
//max_execution_time = 7200
-function check_max_execution_time() {
+function check_max_execution_time()
+{
$max_size = ini_get('max_execution_time');
$recomended_size = 7200;
return ($recomended_size <= $max_size);
}
//post_max_size = 100M
-function check_post_max_size() {
+function check_post_max_size()
+{
$max_size = parse_size(ini_get('post_max_size'));
$recomended_size = parse_size('100M');
return ($recomended_size <= $max_size);
}
//upload_max_filesize = 100M
-function check_upload_max_filesize() {
+function check_upload_max_filesize()
+{
$max_size = parse_size(ini_get('upload_max_filesize'));
$recomended_size = parse_size('100M');
return ($recomended_size <= $max_size);
}
//memory_limit = 100M
-function check_memory_limit() {
+function check_memory_limit()
+{
$max_size = parse_size(ini_get('memory_limit'));
$recomended_size = parse_size('512M');
return ($recomended_size <= $max_size);
}
-function base64DataToImage($imgBase64) {
+function base64DataToImage($imgBase64)
+{
$img = $imgBase64;
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
return base64_decode($img);
}
-function saveBase64DataToPNGImage($imgBase64, $filePath) {
+function saveBase64DataToPNGImage($imgBase64, $filePath)
+{
$fileData = base64DataToImage($imgBase64);
if (empty($fileData)) {
return false;
@@ -342,7 +370,8 @@ function saveBase64DataToPNGImage($imgBase64, $filePath) {
return _file_put_contents($filePath, $fileData);
}
-function getRealIpAddr() {
+function getRealIpAddr()
+{
$ip = "127.0.0.1";
if (isCommandLineInterface()) {
@@ -355,14 +384,14 @@ function getRealIpAddr() {
'REMOTE_ADDR'
];
- foreach($headers as $header) {
+ foreach ($headers as $header) {
if (!empty($_SERVER[$header])) {
$ips = explode(',', $_SERVER[$header]);
- foreach($ips as $ipCandidate) {
+ foreach ($ips as $ipCandidate) {
$ipCandidate = trim($ipCandidate); // Just to be safe
- if(filter_var($ipCandidate, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
+ if (filter_var($ipCandidate, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
return $ipCandidate; // Return the first valid IPv4 we find
- } elseif($header === 'REMOTE_ADDR' && filter_var($ipCandidate, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
+ } elseif ($header === 'REMOTE_ADDR' && filter_var($ipCandidate, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
$ip = $ipCandidate; // In case no IPv4 is found, set the first IPv6 found from REMOTE_ADDR
}
}
@@ -371,7 +400,8 @@ function getRealIpAddr() {
return $ip;
}
-function cleanString($text) {
+function cleanString($text)
+{
if (empty($text)) {
return '';
}
@@ -427,7 +457,8 @@ function cleanString($text) {
* @param bool $strict (optional) Whether to apply strict sanitization. Defaults to false.
* @return string The sanitized string.
*/
-function safeString($text, $strict = false, $try = 0) {
+function safeString($text, $strict = false, $try = 0)
+{
if (empty($text)) {
return '';
}
@@ -453,7 +484,8 @@ function safeString($text, $strict = false, $try = 0) {
return $text;
}
-function cleanURLName($name, $replaceChar = '-') {
+function cleanURLName($name, $replaceChar = '-')
+{
$name = preg_replace('/[!#$&\'()*+,\\/:;=?@[\\]%"\/\\\\ ]+/', $replaceChar, trim(mb_strtolower(cleanString($name))));
return trim(preg_replace('/[\x00-\x1F\x7F\xD7\xE0]/u', $replaceChar, $name), $replaceChar);
}
@@ -463,7 +495,8 @@ function cleanURLName($name, $replaceChar = '-') {
* if is set $_GET['ignoreCommandLineInterface'] will return false
* @return boolean
*/
-function isCommandLineInterface() {
+function isCommandLineInterface()
+{
return (empty($_GET['ignoreCommandLineInterface']) && php_sapi_name() === 'cli');
}
@@ -473,15 +506,16 @@ function isCommandLineInterface() {
* @param array $statusarray associative array with type/message pairs
* @return string
*/
-function status($statusarray) {
+function status($statusarray)
+{
if (isCommandLineInterface()) {
foreach ($statusarray as $status => $message) {
echo $status . ":" . $message . "\n";
}
} else {
echo json_encode(array_map(function ($text) {
- return nl2br($text);
- }, $statusarray));
+ return nl2br($text);
+ }, $statusarray));
}
}
@@ -490,12 +524,14 @@ function status($statusarray) {
*
* @param array $statusarray associative array with type/message pairs
*/
-function croak($statusarray) {
+function croak($statusarray)
+{
status($statusarray);
die;
}
-function getSecondsTotalVideosLength() {
+function getSecondsTotalVideosLength()
+{
$configFile = dirname(__FILE__) . '/../videos/configuration.php';
require_once $configFile;
global $global;
@@ -523,7 +559,8 @@ function getSecondsTotalVideosLength() {
return $seconds;
}
-function getMinutesTotalVideosLength() {
+function getMinutesTotalVideosLength()
+{
$seconds = getSecondsTotalVideosLength();
return floor($seconds / 60);
}
@@ -534,7 +571,8 @@ function getMinutesTotalVideosLength() {
* @param int|float|string $seconds The duration in seconds to convert.
* @return string The formatted time string.
*/
-function secondsToVideoTime($seconds) {
+function secondsToVideoTime($seconds)
+{
if (!is_numeric($seconds)) {
return (string) $seconds;
}
@@ -547,7 +585,8 @@ function secondsToVideoTime($seconds) {
return sprintf('%02d:%02d:%02d', $hours, $minutes, $seconds);
}
-function parseSecondsToDuration($seconds) {
+function parseSecondsToDuration($seconds)
+{
return secondsToVideoTime($seconds);
}
@@ -557,7 +596,8 @@ function parseSecondsToDuration($seconds) {
* @param int|string $str The duration string to parse, in the format "HH:MM:SS".
* @return int The duration in seconds.
*/
-function parseDurationToSeconds($str) {
+function parseDurationToSeconds($str)
+{
if ($str == "00:00:00") {
return 0;
}
@@ -578,11 +618,13 @@ function parseDurationToSeconds($str) {
return intval($durationParts[2]) + ($minutes * 60);
}
-function durationToSeconds($str) {
+function durationToSeconds($str)
+{
return parseDurationToSeconds($str);
}
-function secondsToDuration($seconds) {
+function secondsToDuration($seconds)
+{
return parseSecondsToDuration($seconds);
}
@@ -592,7 +634,8 @@ function secondsToDuration($seconds) {
* @param string $mail
* call it before send mail to let AVideo decide the method
*/
-function setSiteSendMessage(\PHPMailer\PHPMailer\PHPMailer &$mail) {
+function setSiteSendMessage(\PHPMailer\PHPMailer\PHPMailer &$mail)
+{
global $global;
if (empty($mail)) {
$mail = new \PHPMailer\PHPMailer\PHPMailer();
@@ -643,11 +686,13 @@ function setSiteSendMessage(\PHPMailer\PHPMailer\PHPMailer &$mail) {
* @param array $array The input array.
* @return array The array with unique values.
*/
-function array_iunique(array $array): array {
+function array_iunique(array $array): array
+{
return array_intersect_key($array, array_unique(array_map('mb_strtolower', $array)));
}
-function partition(array $list, $totalItens) {
+function partition(array $list, $totalItens)
+{
$listlen = count($list);
_error_log("partition: listlen={$listlen} totalItens={$totalItens}");
$p = ceil($listlen / $totalItens);
@@ -663,7 +708,8 @@ function partition(array $list, $totalItens) {
return $partition;
}
-function sendSiteEmail($to, $subject, $message, $fromEmail = '', $fromName = '') {
+function sendSiteEmail($to, $subject, $message, $fromEmail = '', $fromName = '')
+{
global $advancedCustom;
$resp = false;
if (empty($to)) {
@@ -762,7 +808,8 @@ function sendSiteEmail($to, $subject, $message, $fromEmail = '', $fromName = '')
return $resp;
}
-function sendSiteEmailAsync($to, $subject, $message) {
+function sendSiteEmailAsync($to, $subject, $message)
+{
global $global;
// If $to is not an array, make it one
if (!is_array($to)) {
@@ -782,7 +829,8 @@ function sendSiteEmailAsync($to, $subject, $message) {
return $pid;
}
-function sendBulkEmail($users_id_array, $emails_array, $subject, $message) {
+function sendBulkEmail($users_id_array, $emails_array, $subject, $message)
+{
$obj = AVideoPlugin::getDataObjectIfEnabled('Scheduler');
if (!empty($users_id_array) && $obj->sendEmails) {
@@ -816,7 +864,8 @@ function sendBulkEmail($users_id_array, $emails_array, $subject, $message) {
}
}
-function createEmailMessageFromTemplate($message) {
+function createEmailMessageFromTemplate($message)
+{
//check if the message already have a HTML body
if (preg_match("/html>/i", $message)) {
return $message;
@@ -833,7 +882,8 @@ function createEmailMessageFromTemplate($message) {
return str_replace($replace, $words, $text);
}
-function sendEmailToSiteOwner($subject, $message) {
+function sendEmailToSiteOwner($subject, $message)
+{
global $advancedCustom, $global;
$subject = UTF8encode($subject);
$message = UTF8encode($message);
@@ -861,11 +911,13 @@ function sendEmailToSiteOwner($subject, $message) {
}
}
-function fixURL($url) {
+function fixURL($url)
+{
return str_replace(array('&%3B', '&'), array('&', '&'), $url);
}
-function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $showinfo = 0, $controls = 1, $time = 0, $objectFit = "") {
+function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $showinfo = 0, $controls = 1, $time = 0, $objectFit = "")
+{
global $global;
if (!empty($videoString)) {
$videoString = fixURL($videoString);
@@ -873,7 +925,7 @@ function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $
//_error_log("parseVideos: $videoString");
if (strpos($videoString, 'youtube.com/embed') !== false) {
return $videoString . (parse_url($videoString, PHP_URL_QUERY) ? '&' : '?') . 'modestbranding=1&showinfo='
- . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time&objectFit=$objectFit";
+ . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time&objectFit=$objectFit";
}
if (strpos($videoString, 'iframe') !== false) {
// retrieve the video url
@@ -889,12 +941,12 @@ function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $
if (stripos($link, 'embed') !== false) {
return $link . (parse_url($link, PHP_URL_QUERY) ? '&' : '?') . 'modestbranding=1&showinfo='
- . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time&objectFit=$objectFit";
+ . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time&objectFit=$objectFit";
} elseif (strpos($link, 'youtube.com') !== false) {
preg_match(
- '/[\\?\\&]v=([^\\?\\&]+)/',
- $link,
- $matches
+ '/[\\?\\&]v=([^\\?\\&]+)/',
+ $link,
+ $matches
);
//the ID of the YouTube URL: x6qe_kVaBpg
if (empty($matches[1])) {
@@ -902,18 +954,18 @@ function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $
}
$id = $matches[1];
return '//www.youtube.com/embed/' . $id . '?modestbranding=1&showinfo='
- . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&te=$time&objectFit=$objectFit";
+ . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&te=$time&objectFit=$objectFit";
} elseif (strpos($link, 'youtu.be') !== false) {
//https://youtu.be/9XXOBSsPoMU
preg_match(
- '/youtu.be\/([a-zA-Z0-9_]+)($|\/)/',
- $link,
- $matches
+ '/youtu.be\/([a-zA-Z0-9_]+)($|\/)/',
+ $link,
+ $matches
);
//the ID of the YouTube URL: x6qe_kVaBpg
$id = $matches[1];
return '//www.youtube.com/embed/' . $id . '?modestbranding=1&showinfo='
- . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&te=$time&objectFit=$objectFit";
+ . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&te=$time&objectFit=$objectFit";
} elseif (strpos($link, 'player.vimeo.com') !== false) {
// works on:
// http://player.vimeo.com/video/37985580?title=0&byline=0&portrait=0
@@ -924,9 +976,9 @@ function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $
} elseif (strpos($link, 'vimeo.com/channels') !== false) {
//extract the ID
preg_match(
- '/\/\/(www\.)?vimeo.com\/channels\/[a-z0-9-]+\/(\d+)($|\/)/i',
- $link,
- $matches
+ '/\/\/(www\.)?vimeo.com\/channels\/[a-z0-9-]+\/(\d+)($|\/)/i',
+ $link,
+ $matches
);
//the ID of the Vimeo URL: 71673549
@@ -935,9 +987,9 @@ function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $
} elseif (strpos($link, 'vimeo.com') !== false) {
//extract the ID
preg_match(
- '/\/\/(www\.)?vimeo.com\/(\d+)($|\/)/',
- $link,
- $matches
+ '/\/\/(www\.)?vimeo.com\/(\d+)($|\/)/',
+ $link,
+ $matches
);
//the ID of the Vimeo URL: 71673549
@@ -946,9 +998,9 @@ function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $
} elseif (strpos($link, 'dailymotion.com') !== false) {
//extract the ID
preg_match(
- '/\/\/(www\.)?dailymotion.com\/video\/([a-zA-Z0-9_]+)($|\/)/',
- $link,
- $matches
+ '/\/\/(www\.)?dailymotion.com\/video\/([a-zA-Z0-9_]+)($|\/)/',
+ $link,
+ $matches
);
//the ID of the Vimeo URL: 71673549
@@ -957,18 +1009,18 @@ function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $
} elseif (strpos($link, 'metacafe.com') !== false) {
//extract the ID
preg_match(
- '/\/\/(www\.)?metacafe.com\/watch\/([a-zA-Z0-9_\/-]+)$/',
- $link,
- $matches
+ '/\/\/(www\.)?metacafe.com\/watch\/([a-zA-Z0-9_\/-]+)$/',
+ $link,
+ $matches
);
$id = $matches[2];
return '//www.metacafe.com/embed/' . $id;
} elseif (strpos($link, 'vid.me') !== false) {
//extract the ID
preg_match(
- '/\/\/(www\.)?vid.me\/([a-zA-Z0-9_-]+)$/',
- $link,
- $matches
+ '/\/\/(www\.)?vid.me\/([a-zA-Z0-9_-]+)$/',
+ $link,
+ $matches
);
$id = $matches[2];
@@ -1053,7 +1105,7 @@ function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $
parse_str($url_parsed['query'], $new_qs_parsed);
// Here's the other query string
$other_query_string = 'modestbranding=1&showinfo='
- . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time";
+ . $showinfo . "&autoplay={$autoplay}&controls=$controls&loop=$loop&mute=$mute&t=$time";
$other_qs_parsed = [];
parse_str($other_query_string, $other_qs_parsed);
// Stitch the two query strings together
@@ -1066,11 +1118,11 @@ function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $
$scheme = "{$url_parsed['scheme']}:";
}
$new_url = $scheme
- . '//'
- . $url_parsed['host']
- . $url_parsed['path']
- . '?'
- . $final_query_string;
+ . '//'
+ . $url_parsed['host']
+ . $url_parsed['path']
+ . '?'
+ . $final_query_string;
return $new_url;
// return data
@@ -1078,7 +1130,8 @@ function parseVideos($videoString = null, $autoplay = 0, $loop = 0, $mute = 0, $
$canUseCDN = [];
-function canUseCDN($videos_id) {
+function canUseCDN($videos_id)
+{
if (empty($videos_id)) {
return false;
}
@@ -1097,7 +1150,8 @@ function canUseCDN($videos_id) {
return $canUseCDN[$videos_id];
}
-function clearVideosURL($fileName = "") {
+function clearVideosURL($fileName = "")
+{
global $global;
$path = getCacheDir() . "getVideosURL/";
if (empty($path)) {
@@ -1108,7 +1162,8 @@ function clearVideosURL($fileName = "") {
}
}
-function maxLifetime() {
+function maxLifetime()
+{
global $maxLifetime;
if (!isset($maxLifetime)) {
$aws_s3 = AVideoPlugin::getObjectDataIfEnabled('AWS_S3');
@@ -1133,7 +1188,8 @@ function maxLifetime() {
$cacheExpirationTime = false;
-function cacheExpirationTime() {
+function cacheExpirationTime()
+{
if (isBot()) {
return 604800; // 1 week
}
@@ -1145,7 +1201,8 @@ function cacheExpirationTime() {
return intval($cacheExpirationTime);
}
-function _getImagesURL($fileName, $type) {
+function _getImagesURL($fileName, $type)
+{
global $global;
$files = [];
$source = Video::getSourceFile($fileName, ".jpg");
@@ -1190,7 +1247,8 @@ function _getImagesURL($fileName, $type) {
return $files;
}
-function getVideosURLPDF($fileName) {
+function getVideosURLPDF($fileName)
+{
global $global;
if (empty($fileName)) {
return [];
@@ -1218,7 +1276,8 @@ function getVideosURLPDF($fileName) {
return $files;
}
-function getVideosURLIMAGE($fileName) {
+function getVideosURLIMAGE($fileName)
+{
global $global;
if (empty($fileName)) {
return [];
@@ -1254,7 +1313,8 @@ function getVideosURLIMAGE($fileName) {
return $files;
}
-function getVideosURLZIP($fileName) {
+function getVideosURLZIP($fileName)
+{
global $global;
if (empty($fileName)) {
return [];
@@ -1290,7 +1350,8 @@ function getVideosURLZIP($fileName) {
return $files;
}
-function getVideosURLArticle($fileName) {
+function getVideosURLArticle($fileName)
+{
global $global;
if (empty($fileName)) {
return [];
@@ -1310,7 +1371,8 @@ function getVideosURLArticle($fileName) {
return $files;
}
-function getVideosURLAudio($fileName, $fileNameisThePath = false) {
+function getVideosURLAudio($fileName, $fileNameisThePath = false)
+{
global $global;
if (empty($fileName)) {
return [];
@@ -1363,11 +1425,13 @@ function getVideosURLAudio($fileName, $fileNameisThePath = false) {
return $files;
}
-function getVideosURL($fileName, $cache = true) {
+function getVideosURL($fileName, $cache = true)
+{
return getVideosURL_V2($fileName); // disable this function soon
}
-function getVideosURLMP4Only($fileName) {
+function getVideosURLMP4Only($fileName)
+{
$allFiles = getVideosURL_V2($fileName);
if (is_array($allFiles)) {
foreach ($allFiles as $key => $value) {
@@ -1381,7 +1445,8 @@ function getVideosURLMP4Only($fileName) {
return [];
}
-function getVideosURLMP3Only($fileName) {
+function getVideosURLMP3Only($fileName)
+{
$allFiles = getVideosURL_V2($fileName);
if (is_array($allFiles)) {
foreach ($allFiles as $key => $value) {
@@ -1395,7 +1460,8 @@ function getVideosURLMP3Only($fileName) {
return [];
}
-function getVideosURLWEBMOnly($fileName) {
+function getVideosURLWEBMOnly($fileName)
+{
$allFiles = getVideosURL_V2($fileName); // disable this function soon
if (is_array($allFiles)) {
foreach ($allFiles as $key => $value) {
@@ -1409,15 +1475,18 @@ function getVideosURLWEBMOnly($fileName) {
return [];
}
-function getVideosURLMP4WEBMOnly($fileName) {
+function getVideosURLMP4WEBMOnly($fileName)
+{
return array_merge(getVideosURLMP4Only($fileName), getVideosURLWEBMOnly($fileName));
}
-function getVideosURLMP4WEBMMP3Only($fileName) {
+function getVideosURLMP4WEBMMP3Only($fileName)
+{
return array_merge(getVideosURLMP4Only($fileName), getVideosURLWEBMOnly($fileName), getVideosURLMP3Only($fileName));
}
-function getVideosURLOnly($fileName, $includeOffline = true) {
+function getVideosURLOnly($fileName, $includeOffline = true)
+{
$allFiles = getVideosURL_V2($fileName); // disable this function soon
foreach ($allFiles as $key => $value) {
if ($value['type'] !== 'video' || (!$includeOffline && preg_match('/offline/i', $key))) {
@@ -1427,7 +1496,8 @@ function getVideosURLOnly($fileName, $includeOffline = true) {
return $allFiles;
}
-function getAudioURLOnly($fileName) {
+function getAudioURLOnly($fileName)
+{
$allFiles = getVideosURL_V2($fileName); // disable this function soon
foreach ($allFiles as $key => $value) {
if ($value['type'] !== 'audio') {
@@ -1437,7 +1507,8 @@ function getAudioURLOnly($fileName) {
return $allFiles;
}
-function getAudioOrVideoURLOnly($fileName, $recreateCache = false) {
+function getAudioOrVideoURLOnly($fileName, $recreateCache = false)
+{
$allFiles = getVideosURL_V2($fileName, $recreateCache); // disable this function soon
if ($recreateCache) {
_error_log("getAudioOrVideoURLOnly($fileName) " . json_encode($allFiles));
@@ -1450,13 +1521,15 @@ function getAudioOrVideoURLOnly($fileName, $recreateCache = false) {
return $allFiles;
}
-function getVideosDir() {
+function getVideosDir()
+{
return Video::getStoragePath();
}
$getVideosURL_V2Array = [];
-function getVideosURL_V2($fileName, $recreateCache = false) {
+function getVideosURL_V2($fileName, $recreateCache = false)
+{
global $global, $getVideosURL_V2Array;
if (empty($fileName)) {
return [];
@@ -1489,9 +1562,9 @@ function getVideosURL_V2($fileName, $recreateCache = false) {
$pathFilesize = filesize($value['path']);
}
if (
- $value['type'] === 'video' && // is a video
- preg_match("/^{$preg_match_url}/", $value['url']) && // the URL is the same as the main domain
- $pathFilesize < 20
+ $value['type'] === 'video' && // is a video
+ preg_match("/^{$preg_match_url}/", $value['url']) && // the URL is the same as the main domain
+ $pathFilesize < 20
) { // file size is small
_error_log("getVideosURL_V2:: dummy file found, fix cache " . json_encode(["/^{$preg_match_url}/", $value['url'], preg_match("/^{$preg_match_url}video/", $value['url']), $pathFilesize, $value]));
unset($files);
@@ -1631,7 +1704,8 @@ function getVideosURL_V2($fileName, $recreateCache = false) {
}
//Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if they are equal.
-function sortVideosURL($a, $b) {
+function sortVideosURL($a, $b)
+{
if ($a['type'] === 'video' && $b['type'] === 'video') {
$aRes = getResolutionFromFilename($a['filename']);
$bRes = getResolutionFromFilename($b['filename']);
@@ -1646,7 +1720,8 @@ function sortVideosURL($a, $b) {
return 0;
}
-function getResolutionFromFilename($filename) {
+function getResolutionFromFilename($filename)
+{
global $getResolutionFromFilenameArray;
if (!isset($getResolutionFromFilenameArray)) {
@@ -1679,7 +1754,8 @@ function getResolutionFromFilename($filename) {
return $res;
}
-function getSources($fileName, $returnArray = false, $try = 0) {
+function getSources($fileName, $returnArray = false, $try = 0)
+{
if ($returnArray) {
$videoSources = $audioTracks = $subtitleTracks = [];
} else {
@@ -1753,7 +1829,8 @@ function getSources($fileName, $returnArray = false, $try = 0) {
* @param string $file_src
* @return array get image size with cache
*/
-function getimgsize($file_src) {
+function getimgsize($file_src)
+{
global $_getimagesize;
if (empty($file_src) || !file_exists($file_src)) {
return [0, 0];
@@ -1793,7 +1870,8 @@ function getimgsize($file_src) {
return $size;
}
-function getImageFormat($file) {
+function getImageFormat($file)
+{
$size = getimgsize($file);
if ($size === false) {
return false;
@@ -1831,7 +1909,8 @@ function getImageFormat($file) {
return ['format' => $format, 'extension' => $extension];
}
-function im_resize($file_src, $file_dest, $wd, $hd, $q = 80) {
+function im_resize($file_src, $file_dest, $wd, $hd, $q = 80)
+{
if (empty($file_dest)) {
return false;
}
@@ -1947,7 +2026,8 @@ function im_resize($file_src, $file_dest, $wd, $hd, $q = 80) {
return true;
}
-function scaleUpAndMantainAspectRatioFinalSizes($new_w, $old_w, $new_h, $old_h) {
+function scaleUpAndMantainAspectRatioFinalSizes($new_w, $old_w, $new_h, $old_h)
+{
if (empty($old_h)) {
$old_h = $new_h;
@@ -1982,7 +2062,8 @@ function scaleUpAndMantainAspectRatioFinalSizes($new_w, $old_w, $new_h, $old_h)
return ['w' => $thumb_w, 'h' => $thumb_h];
}
-function scaleUpImage($file_src, $file_dest, $wd, $hd) {
+function scaleUpImage($file_src, $file_dest, $wd, $hd)
+{
if (!file_exists($file_src)) {
return false;
}
@@ -2069,7 +2150,8 @@ function scaleUpImage($file_src, $file_dest, $wd, $hd) {
return $result;
}
-function resize_png_image($source_file_path, $destination_file_path, $target_width, $target_height) {
+function resize_png_image($source_file_path, $destination_file_path, $target_width, $target_height)
+{
// Check if the source file exists
if (!file_exists($source_file_path)) {
return false;
@@ -2089,16 +2171,16 @@ function resize_png_image($source_file_path, $destination_file_path, $target_wid
imagesavealpha($target_image, true);
imagecopyresampled(
- $target_image,
- $src_image,
- 0,
- 0,
- 0,
- 0,
- $target_width,
- $target_height,
- $src_width,
- $src_height
+ $target_image,
+ $src_image,
+ 0,
+ 0,
+ 0,
+ 0,
+ $target_width,
+ $target_height,
+ $src_width,
+ $src_height
);
$saved = imagepng($target_image, $destination_file_path);
@@ -2108,47 +2190,51 @@ function resize_png_image($source_file_path, $destination_file_path, $target_wid
if (false) {
- class Imagick {
+ class Imagick
+ {
public const FILTER_BOX = 1;
- public function getImageFormat() {
+ public function getImageFormat()
+ {
return '';
}
- public function coalesceImages() {
+ public function coalesceImages()
+ {
return new Imagick();
}
- public function nextImage() {
+ public function nextImage()
+ {
return true;
}
- public function resizeImage() {
-
+ public function resizeImage()
+ {
}
- public function deconstructImages() {
+ public function deconstructImages()
+ {
return new Imagick();
}
- public function clear() {
-
+ public function clear()
+ {
}
- public function destroy() {
-
+ public function destroy()
+ {
}
- public function writeImages() {
-
+ public function writeImages()
+ {
}
-
}
-
}
-function im_resize_gif($file_src, $file_dest, $max_width, $max_height) {
+function im_resize_gif($file_src, $file_dest, $max_width, $max_height)
+{
if (class_exists('Imagick')) {
$imagick = new Imagick($file_src);
@@ -2169,7 +2255,8 @@ function im_resize_gif($file_src, $file_dest, $max_width, $max_height) {
}
}
-function im_resize_max_size($file_src, $file_dest, $max_width, $max_height) {
+function im_resize_max_size($file_src, $file_dest, $max_width, $max_height)
+{
$fn = $file_src;
$extension = mb_strtolower(pathinfo($file_dest, PATHINFO_EXTENSION));
@@ -2238,7 +2325,8 @@ function im_resize_max_size($file_src, $file_dest, $max_width, $max_height) {
@unlink($tmpFile);
}
-function detect_image_type($file_path) {
+function detect_image_type($file_path)
+{
$image_info = @getimagesize($file_path);
if ($image_info !== false) {
@@ -2265,7 +2353,8 @@ function detect_image_type($file_path) {
}
}
-function convertImage($originalImage, $outputImage, $quality, $useExif = false) {
+function convertImage($originalImage, $outputImage, $quality, $useExif = false)
+{
ini_set('memory_limit', '512M');
if (!file_exists($originalImage) || empty(filesize($originalImage))) {
return false;
@@ -2378,7 +2467,8 @@ function convertImage($originalImage, $outputImage, $quality, $useExif = false)
return $response;
}
-function decideMoveUploadedToVideos($tmp_name, $filename, $type = "video") {
+function decideMoveUploadedToVideos($tmp_name, $filename, $type = "video")
+{
if ($filename == '.zip') {
return false;
}
@@ -2441,7 +2531,8 @@ function decideMoveUploadedToVideos($tmp_name, $filename, $type = "video") {
return $destinationFile;
}
-function unzipDirectory($filename, $destination) {
+function unzipDirectory($filename, $destination)
+{
// Set memory limit and execution time to avoid issues with large files
ini_set('memory_limit', '-1');
set_time_limit(0);
@@ -2481,7 +2572,8 @@ function unzipDirectory($filename, $destination) {
@unlink($filename);
}
-function make_path($path) {
+function make_path($path)
+{
$created = false;
if (substr($path, -1) !== DIRECTORY_SEPARATOR) {
$path = pathinfo($path, PATHINFO_DIRNAME);
@@ -2513,7 +2605,8 @@ function make_path($path) {
* @param string $allowedExtensions
* @return string
*/
-function cleanDirectory($dir, $allowedExtensions = ['key', 'm3u8', 'ts', 'vtt', 'jpg', 'gif', 'mp3', 'webm', 'webp']) {
+function cleanDirectory($dir, $allowedExtensions = ['key', 'm3u8', 'ts', 'vtt', 'jpg', 'gif', 'mp3', 'webm', 'webp'])
+{
$ffs = scandir($dir);
unset($ffs[array_search('.', $ffs, true)]);
@@ -2536,7 +2629,8 @@ function cleanDirectory($dir, $allowedExtensions = ['key', 'm3u8', 'ts', 'vtt',
}
}
-function isAnyStorageEnabled() {
+function isAnyStorageEnabled()
+{
if ($yptStorage = AVideoPlugin::loadPluginIfEnabled("YPTStorage")) {
return true;
} elseif ($aws_s3 = AVideoPlugin::loadPluginIfEnabled("AWS_S3")) {
@@ -2551,13 +2645,14 @@ function isAnyStorageEnabled() {
if (!function_exists('mime_content_type')) {
- function mime_content_type($filename) {
+ function mime_content_type($filename)
+ {
return mime_content_type_per_filename($filename);
}
-
}
-function fontAwesomeClassName($filename) {
+function fontAwesomeClassName($filename)
+{
$mime_type = mime_content_type_per_filename($filename);
// List of official MIME Types: http://www.iana.org/assignments/media-types/media-types.xhtml
$icon_classes = [
@@ -2592,7 +2687,8 @@ function fontAwesomeClassName($filename) {
return 'fas fa-file';
}
-function mime_content_type_per_filename($filename) {
+function mime_content_type_per_filename($filename)
+{
$mime_types = [
'txt' => 'text/plain',
'htm' => 'text/html',
@@ -2689,7 +2785,8 @@ function mime_content_type_per_filename($filename) {
return 'application/octet-stream';
}
-function combineFiles($filesArray, $extension = "js") {
+function combineFiles($filesArray, $extension = "js")
+{
global $global, $advancedCustom;
if ($extension == 'js' && isBot()) {
@@ -2755,7 +2852,8 @@ function combineFiles($filesArray, $extension = "js") {
return getURL($relativeDir . $md5FileName);
}
-function combineFilesHTML($filesArray, $extension = "js", $doNotCombine = false) {
+function combineFilesHTML($filesArray, $extension = "js", $doNotCombine = false)
+{
if (empty($doNotCombine)) {
$jsURL = combineFiles($filesArray, $extension);
}
@@ -2784,7 +2882,8 @@ function combineFilesHTML($filesArray, $extension = "js", $doNotCombine = false)
}
}
-function getTagIfExists($relativePath) {
+function getTagIfExists($relativePath)
+{
global $global;
$relativePath = str_replace('\\', '/', $relativePath);
$file = "{$global['systemRootPath']}{$relativePath}";
@@ -2805,7 +2904,8 @@ function getTagIfExists($relativePath) {
}
}
-function getImageTagIfExists($relativePath, $title = '', $id = '', $style = '', $class = 'img img-responsive', $lazyLoad = false, $preloadImage = false) {
+function getImageTagIfExists($relativePath, $title = '', $id = '', $style = '', $class = 'img img-responsive', $lazyLoad = false, $preloadImage = false)
+{
global $global;
$relativePathOriginal = $relativePath;
$relativePath = getRelativePath($relativePath);
@@ -2856,7 +2956,8 @@ function getImageTagIfExists($relativePath, $title = '', $id = '', $style = '',
return $img;
}
-function createWebPIfNotExists($path) {
+function createWebPIfNotExists($path)
+{
if (version_compare(PHP_VERSION, '8.0.0') < 0 || !file_exists($path)) {
return $path;
}
@@ -2872,7 +2973,8 @@ function createWebPIfNotExists($path) {
return $nextGenPath;
}
-function getVideoImagewithHoverAnimation($relativePath, $relativePathHoverAnimation = '', $title = '', $preloadImage = false, $doNotUseAnimatedGif = false) {
+function getVideoImagewithHoverAnimation($relativePath, $relativePathHoverAnimation = '', $title = '', $preloadImage = false, $doNotUseAnimatedGif = false)
+{
$id = uniqid();
//getImageTagIfExists($relativePath, $title = '', $id = '', $style = '', $class = 'img img-responsive', $lazyLoad = false, $preloadImage=false)
$img = getImageTagIfExists($relativePath, $title, "thumbsJPG{$id}", '', 'thumbsJPG img img-responsive', false, true) . PHP_EOL;
@@ -2882,7 +2984,8 @@ function getVideoImagewithHoverAnimation($relativePath, $relativePathHoverAnimat
return '
' . $img . '
';
}
-function getRelativePath($path) {
+function getRelativePath($path)
+{
global $global;
$relativePath = '';
$parts = explode('view/img/', $path);
@@ -2906,7 +3009,8 @@ function getRelativePath($path) {
return $parts2[0];
}
-function local_get_contents($path) {
+function local_get_contents($path)
+{
if (function_exists('fopen')) {
$myfile = fopen($path, "r") or die("Unable to open file! [{$path}]");
$text = fread($myfile, filesize($path));
@@ -2915,14 +3019,16 @@ function local_get_contents($path) {
}
}
-function getSelfUserAgent() {
+function getSelfUserAgent()
+{
global $global, $AVideoStreamer_UA;
$agent = $AVideoStreamer_UA . "_";
$agent .= md5($global['salt']);
return $agent;
}
-function isValidM3U8Link($url, $timeout = 3) {
+function isValidM3U8Link($url, $timeout = 3)
+{
if (!isValidURL($url)) {
return false;
}
@@ -2935,7 +3041,8 @@ function isValidM3U8Link($url, $timeout = 3) {
return false;
}
-function copy_remotefile_if_local_is_smaller($url, $destination) {
+function copy_remotefile_if_local_is_smaller($url, $destination)
+{
if (file_exists($destination)) {
$size = filesize($destination);
$remote_size = getUsageFromURL($url);
@@ -2949,7 +3056,8 @@ function copy_remotefile_if_local_is_smaller($url, $destination) {
return file_put_contents($destination, $content);
}
-function try_get_contents_from_local($url) {
+function try_get_contents_from_local($url)
+{
if (substr($url, 0, 1) === '/') {
// it is not a URL
return file_get_contents($url);
@@ -2972,7 +3080,8 @@ function try_get_contents_from_local($url) {
return false;
}
-function url_get_contents_with_cache($url, $lifeTime = 60, $ctx = "", $timeout = 0, $debug = false, $mantainSession = false) {
+function url_get_contents_with_cache($url, $lifeTime = 60, $ctx = "", $timeout = 0, $debug = false, $mantainSession = false)
+{
$url = removeQueryStringParameter($url, 'pass');
$cacheName = str_replace('/', '-', $url);
$cache = ObjectYPT::getCacheGlobal($cacheName, $lifeTime); // 24 hours
@@ -2987,7 +3096,8 @@ function url_get_contents_with_cache($url, $lifeTime = 60, $ctx = "", $timeout =
return $return;
}
-function url_get_contents($url, $ctx = "", $timeout = 0, $debug = false, $mantainSession = false) {
+function url_get_contents($url, $ctx = "", $timeout = 0, $debug = false, $mantainSession = false)
+{
global $global, $mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, $mysqlPort;
if (!isValidURLOrPath($url)) {
_error_log('url_get_contents Cannot download ' . $url);
@@ -3102,7 +3212,8 @@ function url_get_contents($url, $ctx = "", $timeout = 0, $debug = false, $mantai
return false;
}
-function getUpdatesFilesArray() {
+function getUpdatesFilesArray()
+{
global $config, $global;
if (!class_exists('User') || !User::isAdmin()) {
return [];
@@ -3123,7 +3234,8 @@ function getUpdatesFilesArray() {
return $updateFiles;
}
-function thereIsAnyUpdate() {
+function thereIsAnyUpdate()
+{
if (!User::isAdmin()) {
return false;
}
@@ -3138,7 +3250,8 @@ function thereIsAnyUpdate() {
return @$_SESSION['sessionCache'][$name];
}
-function thereIsAnyRemoteUpdate() {
+function thereIsAnyRemoteUpdate()
+{
if (!User::isAdmin()) {
return false;
}
@@ -3170,7 +3283,8 @@ function thereIsAnyRemoteUpdate() {
return $_SESSION['sessionCache'][$name];
}
-function UTF8encode($data) {
+function UTF8encode($data)
+{
if (emptyHTML($data)) {
return $data;
}
@@ -3193,7 +3307,8 @@ function UTF8encode($data) {
}
//detect search engine bots
-function isBot() {
+function isBot()
+{
global $_isBot;
if (empty($_SERVER['HTTP_USER_AGENT'])) {
return true;
@@ -3241,7 +3356,8 @@ function isBot() {
* @param string $adaptive
* @return boolean
*/
-function tail($filepath, $lines = 1, $adaptive = true, $returnArray = false) {
+function tail($filepath, $lines = 1, $adaptive = true, $returnArray = false)
+{
if (!function_exists('mb_strlen')) {
$msg = "AVideoLog::ERROR you need to install the mb_strlen function to make it work, please the command 'sudo apt install php-mbstring'";
if ($returnArray) {
@@ -3309,7 +3425,8 @@ function tail($filepath, $lines = 1, $adaptive = true, $returnArray = false) {
}
}
-function encryptPassword($password, $noSalt = false) {
+function encryptPassword($password, $noSalt = false)
+{
global $advancedCustom, $global, $advancedCustomUser;
if (!empty($advancedCustomUser->encryptPasswordsWithSalt) && !empty($global['salt']) && empty($noSalt)) {
$password .= $global['salt'];
@@ -3318,7 +3435,8 @@ function encryptPassword($password, $noSalt = false) {
return md5(hash("whirlpool", sha1($password)));
}
-function encryptPasswordVerify($password, $hash, $encodedPass = false) {
+function encryptPasswordVerify($password, $hash, $encodedPass = false)
+{
global $advancedCustom, $global;
if (!$encodedPass || $encodedPass === 'false') {
//_error_log("encryptPasswordVerify: encrypt");
@@ -3348,7 +3466,8 @@ function encryptPasswordVerify($password, $hash, $encodedPass = false) {
return $isValid;
}
-function isMobile($userAgent = null, $httpHeaders = null) {
+function isMobile($userAgent = null, $httpHeaders = null)
+{
if (empty($userAgent) && empty($_SERVER["HTTP_USER_AGENT"])) {
return false;
}
@@ -3359,7 +3478,8 @@ function isMobile($userAgent = null, $httpHeaders = null) {
return $detect->isMobile($userAgent, $httpHeaders);
}
-function isAndroid() {
+function isAndroid()
+{
global $global;
require_once $global['systemRootPath'] . 'objects/Mobile_Detect.php';
$detect = new Mobile_Detect();
@@ -3367,11 +3487,13 @@ function isAndroid() {
return $detect->is('AndroidOS');
}
-function isChannelPage() {
+function isChannelPage()
+{
return strpos($_SERVER["SCRIPT_NAME"], 'view/channel.php') !== false;
}
-function isAVideoMobileApp($user_agent = "") {
+function isAVideoMobileApp($user_agent = "")
+{
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
@@ -3389,7 +3511,8 @@ function isAVideoMobileApp($user_agent = "") {
return false;
}
-function isAVideoEncoder($user_agent = "") {
+function isAVideoEncoder($user_agent = "")
+{
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
@@ -3407,21 +3530,24 @@ function isAVideoEncoder($user_agent = "") {
return false;
}
-function isCDN() {
+function isCDN()
+{
if (empty($_SERVER['HTTP_CDN_HOST'])) {
return false;
}
return isFromCDN($_SERVER['HTTP_CDN_HOST']);
}
-function isFromCDN($url) {
+function isFromCDN($url)
+{
if (preg_match('/cdn.ypt.me/i', $url)) {
return true;
}
return false;
}
-function isAVideo($user_agent = "") {
+function isAVideo($user_agent = "")
+{
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
@@ -3439,7 +3565,8 @@ function isAVideo($user_agent = "") {
return false;
}
-function isAVideoEncoderOnSameDomain() {
+function isAVideoEncoderOnSameDomain()
+{
$url = isAVideoEncoder();
if (empty($url)) {
return false;
@@ -3448,7 +3575,8 @@ function isAVideoEncoderOnSameDomain() {
return isSameDomainAsMyAVideo($url);
}
-function isSameDomainAsMyAVideo($url) {
+function isSameDomainAsMyAVideo($url)
+{
global $global;
if (empty($url)) {
return false;
@@ -3456,7 +3584,8 @@ function isSameDomainAsMyAVideo($url) {
return isSameDomain($url, $global['webSiteRootURL']) || isSameDomain($url, getCDN());
}
-function getRefferOrOrigin() {
+function getRefferOrOrigin()
+{
$url = '';
if (!empty($_SERVER['HTTP_REFERER'])) {
$url = $_SERVER['HTTP_REFERER'];
@@ -3466,7 +3595,8 @@ function getRefferOrOrigin() {
return $url;
}
-function requestComesFromSameDomainAsMyAVideo() {
+function requestComesFromSameDomainAsMyAVideo()
+{
global $global;
$url = getRefferOrOrigin();
//var_dump($_SERVER);exit;
@@ -3474,14 +3604,16 @@ function requestComesFromSameDomainAsMyAVideo() {
return isSameDomain($url, $global['webSiteRootURL']) || isSameDomain($url, getCDN()) || isFromCDN($url);
}
-function forbidIfIsUntrustedRequest($logMsg = '', $approveAVideoUserAgent = true) {
+function forbidIfIsUntrustedRequest($logMsg = '', $approveAVideoUserAgent = true)
+{
global $global;
if (isUntrustedRequest($logMsg, $approveAVideoUserAgent)) {
forbiddenPage('Invalid Request ' . getRealIpAddr(), true);
}
}
-function isUntrustedRequest($logMsg = '', $approveAVideoUserAgent = true) {
+function isUntrustedRequest($logMsg = '', $approveAVideoUserAgent = true)
+{
global $global;
if (!empty($global['bypassSameDomainCheck']) || isCommandLineInterface()) {
return false;
@@ -3497,14 +3629,16 @@ function isUntrustedRequest($logMsg = '', $approveAVideoUserAgent = true) {
return false;
}
-function forbidIfItIsNotMyUsersId($users_id, $logMsg = '') {
+function forbidIfItIsNotMyUsersId($users_id, $logMsg = '')
+{
if (itIsNotMyUsersId($users_id)) {
_error_log("forbidIfItIsNotMyUsersId: [{$users_id}]!=[" . User::getId() . "] {$logMsg}");
forbiddenPage('It is not your user ' . getRealIpAddr(), true);
}
}
-function itIsNotMyUsersId($users_id) {
+function itIsNotMyUsersId($users_id)
+{
$users_id = intval($users_id);
if (empty($users_id)) {
return false;
@@ -3515,11 +3649,13 @@ function itIsNotMyUsersId($users_id) {
return User::getId() != $users_id;
}
-function requestComesFromSafePlace() {
+function requestComesFromSafePlace()
+{
return (requestComesFromSameDomainAsMyAVideo() || isAVideo());
}
-function addGlobalTokenIfSameDomain($url) {
+function addGlobalTokenIfSameDomain($url)
+{
if (!filter_var($url, FILTER_VALIDATE_URL) || (empty($_GET['livelink']) || !preg_match("/^http.*/i", $_GET['livelink']))) {
return $url;
}
@@ -3529,7 +3665,8 @@ function addGlobalTokenIfSameDomain($url) {
return addQueryStringParameter($url, 'globalToken', getToken(60));
}
-function isGlobalTokenValid() {
+function isGlobalTokenValid()
+{
if (empty($_REQUEST['globalToken'])) {
return false;
}
@@ -3544,7 +3681,8 @@ function isGlobalTokenValid() {
*
* @return string
*/
-function removeQueryStringParameter($url, $varname) {
+function removeQueryStringParameter($url, $varname)
+{
$parsedUrl = parse_url($url);
if (empty($parsedUrl) || empty($parsedUrl['host'])) {
return $url;
@@ -3575,7 +3713,8 @@ function removeQueryStringParameter($url, $varname) {
*
* @return string
*/
-function addQueryStringParameter($url, $varname, $value) {
+function addQueryStringParameter($url, $varname, $value)
+{
if ($value === null || $value === '') {
return removeQueryStringParameter($url, $varname);
}
@@ -3606,14 +3745,16 @@ function addQueryStringParameter($url, $varname, $value) {
return $scheme . '//' . $parsedUrl['host'] . $port . $path . $query;
}
-function isSameDomain($url1, $url2) {
+function isSameDomain($url1, $url2)
+{
if (empty($url1) || empty($url2)) {
return false;
}
return (get_domain($url1) === get_domain($url2));
}
-function isAVideoStreamer($user_agent = "") {
+function isAVideoStreamer($user_agent = "")
+{
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
@@ -3628,7 +3769,8 @@ function isAVideoStreamer($user_agent = "") {
return false;
}
-function isAVideoUserAgent($user_agent = "") {
+function isAVideoUserAgent($user_agent = "")
+{
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
@@ -3650,7 +3792,8 @@ function isAVideoUserAgent($user_agent = "") {
return false;
}
-function isAVideoStorage($user_agent = "") {
+function isAVideoStorage($user_agent = "")
+{
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
@@ -3668,7 +3811,8 @@ function isAVideoStorage($user_agent = "") {
return false;
}
-function get_domain($url, $ifEmptyReturnSameString = false) {
+function get_domain($url, $ifEmptyReturnSameString = false)
+{
$pieces = parse_url($url);
$domain = $pieces['host'] ?? '';
if (empty($domain)) {
@@ -3685,7 +3829,8 @@ function get_domain($url, $ifEmptyReturnSameString = false) {
return false;
}
-function verify($url) {
+function verify($url)
+{
global $global;
ini_set('default_socket_timeout', 5);
$cacheFile = sys_get_temp_dir() . '/' . md5($url) . "_verify.log";
@@ -3719,7 +3864,8 @@ function verify($url) {
return json_decode($result);
}
-function isVerified($url) {
+function isVerified($url)
+{
$resultV = verify($url);
if (!empty($resultV) && !$resultV->verified) {
error_log("Error on Login not verified");
@@ -3728,7 +3874,8 @@ function isVerified($url) {
return true;
}
-function siteMap() {
+function siteMap()
+{
_error_log("siteMap: start");
ini_set('memory_limit', '-1');
ini_set('max_execution_time', 0);
@@ -3929,7 +4076,8 @@ function siteMap() {
return $newXML5;
}
-function object_to_array($obj) {
+function object_to_array($obj)
+{
//only process if it's an object or array being passed to the function
if (is_object($obj) || is_array($obj)) {
$ret = (array) $obj;
@@ -3945,7 +4093,8 @@ function object_to_array($obj) {
}
}
-function allowOrigin() {
+function allowOrigin()
+{
global $global;
cleanUpAccessControlHeader();
$HTTP_ORIGIN = empty($_SERVER['HTTP_ORIGIN']) ? @$_SERVER['HTTP_REFERER'] : $_SERVER['HTTP_ORIGIN'];
@@ -3962,7 +4111,8 @@ function allowOrigin() {
header("Access-Control-Allow-Headers: Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers");
}
-function cleanUpAccessControlHeader() {
+function cleanUpAccessControlHeader()
+{
if (!headers_sent()) {
foreach (headers_list() as $header) {
if (preg_match('/Access-Control-Allow-Origin/i', $header)) {
@@ -3973,7 +4123,8 @@ function cleanUpAccessControlHeader() {
}
}
-function rrmdir($dir) {
+function rrmdir($dir)
+{
//if(preg_match('/cache/i', $dir)){_error_log("rrmdir($dir) ". json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)));exit;}
$dir = str_replace(['//', '\\\\'], DIRECTORY_SEPARATOR, $dir);
@@ -4024,7 +4175,8 @@ function rrmdir($dir) {
}
}
-function rrmdirCommandLine($dir, $async = false) {
+function rrmdirCommandLine($dir, $async = false)
+{
if (is_dir($dir)) {
$dir = escapeshellarg($dir);
if (isWindows()) {
@@ -4045,7 +4197,8 @@ function rrmdirCommandLine($dir, $async = false) {
* You can now configure it on the configuration.php
* @return boolean
*/
-function ddosProtection() {
+function ddosProtection()
+{
global $global;
$maxCon = empty($global['ddosMaxConnections']) ? 40 : $global['ddosMaxConnections'];
$secondTimeout = empty($global['ddosSecondTimeout']) ? 5 : $global['ddosSecondTimeout'];
@@ -4094,7 +4247,8 @@ function ddosProtection() {
return true;
}
-function getAdsLeaderBoardBigVideo() {
+function getAdsLeaderBoardBigVideo()
+{
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
$adCode = '';
if (!empty($ad)) {
@@ -4103,7 +4257,8 @@ function getAdsLeaderBoardBigVideo() {
return $adCode;
}
-function getAdsLeaderBoardTop() {
+function getAdsLeaderBoardTop()
+{
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
$adCode = '';
if (!empty($ad)) {
@@ -4112,7 +4267,8 @@ function getAdsLeaderBoardTop() {
return $adCode;
}
-function getAdsChannelLeaderBoardTop() {
+function getAdsChannelLeaderBoardTop()
+{
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
$adCode = '';
if (!empty($ad)) {
@@ -4121,7 +4277,8 @@ function getAdsChannelLeaderBoardTop() {
return $adCode;
}
-function getAdsLeaderBoardTop2() {
+function getAdsLeaderBoardTop2()
+{
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
$adCode = '';
if (!empty($ad)) {
@@ -4130,7 +4287,8 @@ function getAdsLeaderBoardTop2() {
return $adCode;
}
-function getAdsLeaderBoardMiddle() {
+function getAdsLeaderBoardMiddle()
+{
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
$adCode = '';
if (!empty($ad)) {
@@ -4139,7 +4297,8 @@ function getAdsLeaderBoardMiddle() {
return $adCode;
}
-function getAdsLeaderBoardFooter() {
+function getAdsLeaderBoardFooter()
+{
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
$adCode = '';
if (!empty($ad)) {
@@ -4148,7 +4307,8 @@ function getAdsLeaderBoardFooter() {
return $adCode;
}
-function getAdsSideRectangle() {
+function getAdsSideRectangle()
+{
$ad = AVideoPlugin::getObjectDataIfEnabled('ADs');
$adCode = '';
if (!empty($ad)) {
@@ -4157,7 +4317,8 @@ function getAdsSideRectangle() {
return $adCode;
}
-function isToHidePrivateVideos() {
+function isToHidePrivateVideos()
+{
$obj = AVideoPlugin::getObjectDataIfEnabled("Gallery");
if (!empty($obj)) {
return $obj->hidePrivateVideos;
@@ -4173,7 +4334,8 @@ function isToHidePrivateVideos() {
return false;
}
-function convertImageToOG($source, $destination) {
+function convertImageToOG($source, $destination)
+{
if (!file_exists($destination)) {
$w = 200;
$h = 200;
@@ -4189,11 +4351,13 @@ function convertImageToOG($source, $destination) {
return $destination;
}
-function convertImageToRoku($source, $destination) {
+function convertImageToRoku($source, $destination)
+{
return convertImageIfNotExists($source, $destination, 1280, 720, true);
}
-function convertImageIfNotExists($source, $destination, $width, $height, $scaleUp = true) {
+function convertImageIfNotExists($source, $destination, $width, $height, $scaleUp = true)
+{
if (empty($source)) {
_error_log("convertImageIfNotExists: source image is empty");
return false;
@@ -4251,17 +4415,20 @@ function convertImageIfNotExists($source, $destination, $width, $height, $scaleU
return $destination;
}
-function ogSite() {
+function ogSite()
+{
global $global, $config;
include $global['systemRootPath'] . 'objects/functionogSite.php';
}
-function getOpenGraph($videos_id) {
+function getOpenGraph($videos_id)
+{
global $global, $config, $advancedCustom;
include $global['systemRootPath'] . 'objects/functiongetOpenGraph.php';
}
-function getLdJson($videos_id) {
+function getLdJson($videos_id)
+{
$cache = ObjectYPT::getCacheGlobal("getLdJson{$videos_id}", 0);
if (empty($cache)) {
echo $cache;
@@ -4331,7 +4498,8 @@ function getLdJson($videos_id) {
echo $output;
}
-function getItemprop($videos_id) {
+function getItemprop($videos_id)
+{
$cache = ObjectYPT::getCacheGlobal("getItemprop{$videos_id}", 0);
if (empty($cache)) {
echo $cache;
@@ -4373,7 +4541,8 @@ function getItemprop($videos_id) {
echo $output;
}
-function getOS($user_agent = "") {
+function getOS($user_agent = "")
+{
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
@@ -4418,7 +4587,8 @@ function getOS($user_agent = "") {
return $os_platform;
}
-function get_browser_name($user_agent = "") {
+function get_browser_name($user_agent = "")
+{
if (empty($user_agent)) {
$user_agent = @$_SERVER['HTTP_USER_AGENT'];
}
@@ -4501,10 +4671,10 @@ function get_browser_name($user_agent = "") {
// Check for strings commonly used in bot user agents
elseif (
- strpos($t, 'crawler') || strpos($t, 'api') ||
- strpos($t, 'spider') || strpos($t, 'http') ||
- strpos($t, 'bot') || strpos($t, 'archive') ||
- strpos($t, 'info') || strpos($t, 'data')
+ strpos($t, 'crawler') || strpos($t, 'api') ||
+ strpos($t, 'spider') || strpos($t, 'http') ||
+ strpos($t, 'bot') || strpos($t, 'archive') ||
+ strpos($t, 'info') || strpos($t, 'data')
) {
return '[Bot] Other';
}
@@ -4517,7 +4687,8 @@ function get_browser_name($user_agent = "") {
* we need to detect the chrome browser and load an older version
*
*/
-function isOldChromeVersion() {
+function isOldChromeVersion()
+{
global $global;
if (empty($_SERVER['HTTP_USER_AGENT'])) {
return false;
@@ -4531,7 +4702,8 @@ function isOldChromeVersion() {
return false;
}
-function TimeLogStart($name) {
+function TimeLogStart($name)
+{
global $global;
if (!empty($global['noDebug'])) {
return false;
@@ -4546,7 +4718,8 @@ function TimeLogStart($name) {
return $name;
}
-function TimeLogEnd($name, $line, $TimeLogLimit = 0.7) {
+function TimeLogEnd($name, $line, $TimeLogLimit = 0.7)
+{
global $global;
if (!empty($global['noDebug']) || empty($global['start'][$name])) {
return false;
@@ -4565,17 +4738,18 @@ function TimeLogEnd($name, $line, $TimeLogLimit = 0.7) {
TimeLogStart($name);
}
-class AVideoLog {
+class AVideoLog
+{
public static $DEBUG = 0;
public static $WARNING = 1;
public static $ERROR = 2;
public static $SECURITY = 3;
public static $SOCKET = 4;
-
}
-function _error_log_debug($message, $show_args = false) {
+function _error_log_debug($message, $show_args = false)
+{
$array = debug_backtrace();
$message .= PHP_EOL;
foreach ($array as $value) {
@@ -4587,7 +4761,8 @@ function _error_log_debug($message, $show_args = false) {
_error_log(PHP_EOL . '***' . PHP_EOL . $message . '***');
}
-function _error_log($message, $type = 0, $doNotRepeat = false) {
+function _error_log($message, $type = 0, $doNotRepeat = false)
+{
if (empty($doNotRepeat)) {
// do not log it too many times when you are using HLS format, other wise it will fill the log file with the same error
$doNotRepeat = preg_match("/hls.php$/", $_SERVER['SCRIPT_NAME']);
@@ -4627,7 +4802,8 @@ function _error_log($message, $type = 0, $doNotRepeat = false) {
error_log($str);
}
-function postVariables($url, $array, $httpcodeOnly = true, $timeout = 10) {
+function postVariables($url, $array, $httpcodeOnly = true, $timeout = 10)
+{
if (!$url || !is_string($url) || !preg_match('/^http(s)?:\/\/[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(\/.*)?$/i', $url)) {
return false;
}
@@ -4663,7 +4839,8 @@ function postVariables($url, $array, $httpcodeOnly = true, $timeout = 10) {
}
}
-function _session_start(array $options = []) {
+function _session_start(array $options = [])
+{
try {
if (isset($_GET['PHPSESSID']) && !_empty($_GET['PHPSESSID'])) {
$PHPSESSID = $_GET['PHPSESSID'];
@@ -4698,13 +4875,15 @@ function _session_start(array $options = []) {
}
}
-function _session_regenerate_id() {
+function _session_regenerate_id()
+{
session_regenerate_id(true);
_resetcookie('PHPSESSID', session_id());
_resetcookie(session_name(), session_id());
}
-function debugMemmory($line) {
+function debugMemmory($line)
+{
global $lastDebugMemory, $lastDebugMemoryLine, $global;
if (empty($global['debugMemmory'])) {
return false;
@@ -4726,7 +4905,8 @@ function debugMemmory($line) {
* this is necessary because of the signup from the iframe pages
* @return boolean
*/
-function blackListRegenerateSession() {
+function blackListRegenerateSession()
+{
if (!requestComesFromSafePlace()) {
return false;
}
@@ -4743,7 +4923,8 @@ function blackListRegenerateSession() {
return false;
}
-function _mysql_connect($persistent = false, $try = 0) {
+function _mysql_connect($persistent = false, $try = 0)
+{
global $global, $mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase, $mysqlPort, $mysql_connect_was_closed;
$checkValues = ['mysqlHost', 'mysqlUser', 'mysqlPass', 'mysqlDatabase'];
@@ -4788,7 +4969,8 @@ function _mysql_connect($persistent = false, $try = 0) {
return true;
}
-function _mysql_commit() {
+function _mysql_commit()
+{
global $global;
if (_mysql_is_open()) {
try {
@@ -4799,13 +4981,13 @@ function _mysql_commit() {
*/
@$global['mysqli']->commit();
} catch (Exception $exc) {
-
}
//$global['mysqli'] = false;
}
}
-function _mysql_close() {
+function _mysql_close()
+{
global $global, $mysql_connect_was_closed;
if (_mysql_is_open()) {
//_error_log('MySQL Closed '. json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)));
@@ -4818,13 +5000,13 @@ function _mysql_close() {
*/
@$global['mysqli']->close();
} catch (Exception $exc) {
-
}
//$global['mysqli'] = false;
}
}
-function _mysql_is_open() {
+function _mysql_is_open()
+{
global $global, $mysql_connect_was_closed;
try {
/**
@@ -4842,7 +5024,8 @@ function _mysql_is_open() {
return false;
}
-function remove_utf8_bom($text) {
+function remove_utf8_bom($text)
+{
if (strlen($text) > 1000000) {
return $text;
}
@@ -4852,7 +5035,8 @@ function remove_utf8_bom($text) {
return $text;
}
-function getCacheDir() {
+function getCacheDir()
+{
$p = AVideoPlugin::loadPlugin("Cache");
if (empty($p)) {
return addLastSlash(sys_get_temp_dir());
@@ -4860,7 +5044,8 @@ function getCacheDir() {
return $p->getCacheDir();
}
-function clearCache($firstPageOnly = false) {
+function clearCache($firstPageOnly = false)
+{
global $global;
$lockFile = getVideosDir() . '.clearCache.lock';
if (file_exists($lockFile) && filectime($lockFile) > strtotime('-5 minutes')) {
@@ -4900,15 +5085,18 @@ function clearCache($firstPageOnly = false) {
return true;
}
-function clearAllUsersSessionCache() {
+function clearAllUsersSessionCache()
+{
sendSocketMessageToAll(time(), 'socketClearSessionCache');
}
-function clearFirstPageCache() {
+function clearFirstPageCache()
+{
return clearCache(true);
}
-function getUsageFromFilename($filename, $dir = "") {
+function getUsageFromFilename($filename, $dir = "")
+{
global $global;
if (!empty($global['getUsageFromFilename'])) { // manually add this variable in your configuration.php file to not scan your video usage
@@ -5065,7 +5253,8 @@ function getUsageFromFilename($filename, $dir = "") {
* return The size of the file referenced by $url, or false if the size
* could not be determined.
*/
-function getUsageFromURL($url) {
+function getUsageFromURL($url)
+{
global $global;
if (!empty($global['doNotGetUsageFromURL'])) { // manually add this variable in your configuration.php file to not scan your video usage
@@ -5120,7 +5309,8 @@ function getUsageFromURL($url) {
return (int) $result;
}
-function getDirSize($dir, $forceNew = false) {
+function getDirSize($dir, $forceNew = false)
+{
global $_getDirSize;
if (!isset($_getDirSize)) {
@@ -5163,7 +5353,8 @@ function getDirSize($dir, $forceNew = false) {
}
}
-function foldersize($path) {
+function foldersize($path)
+{
$total_size = 0;
$files = scandir($path);
$cleanPath = rtrim($path, '/') . '/';
@@ -5184,7 +5375,8 @@ function foldersize($path) {
return $total_size;
}
-function getDiskUsage() {
+function getDiskUsage()
+{
global $global;
$dir = getVideosDir() . "";
$obj = new stdClass();
@@ -5206,11 +5398,13 @@ function getDiskUsage() {
return $obj;
}
-function unsetSearch() {
+function unsetSearch()
+{
unset($_GET['searchPhrase'], $_POST['searchPhrase'], $_GET['search'], $_GET['q']);
}
-function encrypt_decrypt($string, $action) {
+function encrypt_decrypt($string, $action)
+{
global $global;
$output = false;
if (empty($string)) {
@@ -5241,32 +5435,37 @@ function encrypt_decrypt($string, $action) {
return $output;
}
-function compressString($string) {
+function compressString($string)
+{
if (function_exists("gzdeflate")) {
$string = gzdeflate($string, 9);
}
return $string;
}
-function decompressString($string) {
+function decompressString($string)
+{
if (function_exists("gzinflate")) {
$string = gzinflate($string);
}
return $string;
}
-function encryptString($string) {
+function encryptString($string)
+{
if (is_object($string) || is_array($string)) {
$string = json_encode($string);
}
return encrypt_decrypt($string, 'encrypt');
}
-function decryptString($string) {
+function decryptString($string)
+{
return encrypt_decrypt($string, 'decrypt');
}
-function getToken($timeout = 0, $salt = "") {
+function getToken($timeout = 0, $salt = "")
+{
global $global;
$obj = new stdClass();
$obj->salt = $global['salt'] . $salt;
@@ -5286,11 +5485,13 @@ function getToken($timeout = 0, $salt = "") {
return encryptString($strObj);
}
-function isTokenValid($token, $salt = "") {
+function isTokenValid($token, $salt = "")
+{
return verifyToken($token, $salt);
}
-function verifyToken($token, $salt = "") {
+function verifyToken($token, $salt = "")
+{
global $global;
$obj = _json_decode(decryptString($token));
if (empty($obj)) {
@@ -5312,7 +5513,8 @@ function verifyToken($token, $salt = "") {
return true;
}
-class YPTvideoObject {
+class YPTvideoObject
+{
public $id;
public $title;
@@ -5321,7 +5523,8 @@ class YPTvideoObject {
public $channelTitle;
public $videoLink;
- public function __construct($id, $title, $description, $thumbnails, $channelTitle, $videoLink) {
+ public function __construct($id, $title, $description, $thumbnails, $channelTitle, $videoLink)
+ {
$this->id = $id;
$this->title = $title;
$this->description = $description;
@@ -5329,10 +5532,10 @@ class YPTvideoObject {
$this->channelTitle = $channelTitle;
$this->videoLink = $videoLink;
}
-
}
-function isToShowDuration($type) {
+function isToShowDuration($type)
+{
$notShowTo = ['pdf', 'article', 'serie', 'zip', 'image', 'live', 'livelinks'];
if (in_array($type, $notShowTo)) {
return false;
@@ -5341,13 +5544,15 @@ function isToShowDuration($type) {
}
}
-function _dieAndLogObject($obj, $prefix = "") {
+function _dieAndLogObject($obj, $prefix = "")
+{
$objString = json_encode($obj);
_error_log($prefix . $objString);
die($objString);
}
-function isAVideoPlayer() {
+function isAVideoPlayer()
+{
global $global;
if (!empty($global['doNotLoadPlayer'])) {
return false;
@@ -5358,12 +5563,14 @@ function isAVideoPlayer() {
return false;
}
-function isFirstPage() {
+function isFirstPage()
+{
global $isFirstPage, $global;
return !empty($isFirstPage) || getSelfURI() === "{$global['webSiteRootURL']}view/";
}
-function isVideo() {
+function isVideo()
+{
global $isModeYouTube, $global;
if (!empty($global['doNotLoadPlayer'])) {
return false;
@@ -5371,12 +5578,14 @@ function isVideo() {
return !empty($isModeYouTube) || isPlayList() || isEmbed() || isLive();
}
-function isOffline() {
+function isOffline()
+{
global $_isOffline;
return !empty($_isOffline);
}
-function isVideoTypeEmbed() {
+function isVideoTypeEmbed()
+{
global $isVideoTypeEmbed;
if (isVideo() && !empty($isVideoTypeEmbed) && $videos_id = getVideos_id()) {
@@ -5386,21 +5595,25 @@ function isVideoTypeEmbed() {
return false;
}
-function isAudio() {
+function isAudio()
+{
global $isAudio;
return !empty($isAudio) || Video::forceAudio();
}
-function isSerie() {
+function isSerie()
+{
return isPlayList();
}
-function isPlayList() {
+function isPlayList()
+{
global $isPlayList, $isSerie;
return !empty($isSerie) || !empty($isPlayList);
}
-function isChannel() {
+function isChannel()
+{
global $isChannel;
if (!empty($isChannel) && !isVideo()) {
$user_id = 0;
@@ -5424,7 +5637,8 @@ function isChannel() {
return false;
}
-function isEmbed() {
+function isEmbed()
+{
global $isEmbed, $global;
if (!empty($global['doNotLoadPlayer'])) {
return false;
@@ -5432,7 +5646,8 @@ function isEmbed() {
return !empty($isEmbed);
}
-function isWebRTC() {
+function isWebRTC()
+{
global $isWebRTC, $global;
if (!empty($global['doNotLoadPlayer'])) {
return false;
@@ -5440,7 +5655,8 @@ function isWebRTC() {
return !empty($isWebRTC);
}
-function isLive() {
+function isLive()
+{
global $isLive, $global;
if (!empty($global['doNotLoadPlayer'])) {
return false;
@@ -5464,7 +5680,8 @@ function isLive() {
}
}
-function isLiveLink() {
+function isLiveLink()
+{
global $isLiveLink;
if (!empty($isLiveLink)) {
return $isLiveLink;
@@ -5473,7 +5690,8 @@ function isLiveLink() {
}
}
-function getLiveKey() {
+function getLiveKey()
+{
global $getLiveKey;
if (empty($getLiveKey)) {
return false;
@@ -5481,7 +5699,8 @@ function getLiveKey() {
return $getLiveKey;
}
-function setLiveKey($key, $live_servers_id, $live_index = '') {
+function setLiveKey($key, $live_servers_id, $live_index = '')
+{
global $getLiveKey;
$parameters = Live::getLiveParametersFromKey($key);
$key = $parameters['key'];
@@ -5502,7 +5721,8 @@ function setLiveKey($key, $live_servers_id, $live_index = '') {
return $getLiveKey;
}
-function isVideoPlayerHasProgressBar() {
+function isVideoPlayerHasProgressBar()
+{
if (isWebRTC()) {
return false;
}
@@ -5517,7 +5737,8 @@ function isVideoPlayerHasProgressBar() {
return false;
}
-function isHLS() {
+function isHLS()
+{
global $video, $global;
if (isLive()) {
return true;
@@ -5527,7 +5748,8 @@ function isHLS() {
return false;
}
-function getRedirectUri($returnThisIfRedirectUriIsNotSet = false) {
+function getRedirectUri($returnThisIfRedirectUriIsNotSet = false)
+{
if (isValidURL(@$_GET['redirectUri'])) {
return $_GET['redirectUri'];
}
@@ -5547,12 +5769,14 @@ function getRedirectUri($returnThisIfRedirectUriIsNotSet = false) {
}
}
-function setRedirectUri($redirectUri) {
+function setRedirectUri($redirectUri)
+{
_session_start();
$_SESSION['redirectUri'] = $redirectUri;
}
-function redirectIfRedirectUriIsSet() {
+function redirectIfRedirectUriIsSet()
+{
$redirectUri = false;
if (!empty($_GET['redirectUri'])) {
if (isSameDomainAsMyAVideo($_GET['redirectUri'])) {
@@ -5573,7 +5797,8 @@ function redirectIfRedirectUriIsSet() {
}
}
-function getRedirectToVideo($videos_id) {
+function getRedirectToVideo($videos_id)
+{
$redirectUri = getRedirectUri();
$isEmbed = 0;
if (stripos($redirectUri, "embed") !== false) {
@@ -5586,14 +5811,16 @@ function getRedirectToVideo($videos_id) {
return Video::getLink($videos_id, $video['clean_title'], $isEmbed);
}
-function getRequestURI() {
+function getRequestURI()
+{
if (empty($_SERVER['REQUEST_URI'])) {
return "";
}
return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
}
-function getSelfURI() {
+function getSelfURI()
+{
if (empty($_SERVER['PHP_SELF']) || empty($_SERVER['HTTP_HOST'])) {
return "";
}
@@ -5612,11 +5839,13 @@ function getSelfURI() {
return fixTestURL($url);
}
-function isSameVideoAsSelfURI($url) {
+function isSameVideoAsSelfURI($url)
+{
return URLsAreSameVideo($url, getSelfURI());
}
-function URLsAreSameVideo($url1, $url2) {
+function URLsAreSameVideo($url1, $url2)
+{
$videos_id1 = getVideoIDFromURL($url1);
$videos_id2 = getVideoIDFromURL($url2);
if (empty($videos_id1) || empty($videos_id2)) {
@@ -5625,7 +5854,8 @@ function URLsAreSameVideo($url1, $url2) {
return $videos_id1 === $videos_id2;
}
-function getVideos_id($returnPlaylistVideosIDIfIsSerie = false) {
+function getVideos_id($returnPlaylistVideosIDIfIsSerie = false)
+{
global $_getVideos_id;
$videos_id = false;
if (isset($_getVideos_id) && is_int($_getVideos_id)) {
@@ -5668,7 +5898,8 @@ function getVideos_id($returnPlaylistVideosIDIfIsSerie = false) {
return $videos_id;
}
-function getPlayListIndex() {
+function getPlayListIndex()
+{
global $__playlistIndex;
if (empty($__playlistIndex) && !empty($_REQUEST['playlist_index'])) {
$__playlistIndex = intval($_REQUEST['playlist_index']);
@@ -5676,7 +5907,8 @@ function getPlayListIndex() {
return intval($__playlistIndex);
}
-function getPlayListData() {
+function getPlayListData()
+{
global $playListData;
if (empty($playListData)) {
$playListData = [];
@@ -5684,7 +5916,8 @@ function getPlayListData() {
return $playListData;
}
-function getPlayListDataVideosId() {
+function getPlayListDataVideosId()
+{
$playListData_videos_id = [];
foreach (getPlayListData() as $value) {
$playListData_videos_id[] = $value->getVideos_id();
@@ -5692,7 +5925,8 @@ function getPlayListDataVideosId() {
return $playListData_videos_id;
}
-function getPlayListCurrentVideo($setVideos_id = true) {
+function getPlayListCurrentVideo($setVideos_id = true)
+{
$videos_id = getPlayListCurrentVideosId($setVideos_id);
if (empty($videos_id)) {
return false;
@@ -5701,7 +5935,8 @@ function getPlayListCurrentVideo($setVideos_id = true) {
return $video;
}
-function getPlayListCurrentVideosId($setVideos_id = true) {
+function getPlayListCurrentVideosId($setVideos_id = true)
+{
$playListData = getPlayListData();
$playlist_index = getPlayListIndex();
if (empty($playListData[$playlist_index])) {
@@ -5715,17 +5950,20 @@ function getPlayListCurrentVideosId($setVideos_id = true) {
return $videos_id;
}
-function setPlayListIndex($index) {
+function setPlayListIndex($index)
+{
global $__playlistIndex;
$__playlistIndex = intval($index);
}
-function setVideos_id($videos_id) {
+function setVideos_id($videos_id)
+{
global $_getVideos_id;
$_getVideos_id = $videos_id;
}
-function getPlaylists_id() {
+function getPlaylists_id()
+{
global $_isPlayList;
if (!isset($_isPlayList)) {
$_isPlayList = false;
@@ -5749,7 +5987,8 @@ function getPlaylists_id() {
return $_isPlayList;
}
-function isVideoOrAudioNotEmbed() {
+function isVideoOrAudioNotEmbed()
+{
if (!isVideo()) {
return false;
}
@@ -5768,7 +6007,8 @@ function isVideoOrAudioNotEmbed() {
return false;
}
-function getVideoIDFromURL($url) {
+function getVideoIDFromURL($url)
+{
if (preg_match("/v=([0-9]+)/", $url, $matches)) {
return intval($matches[1]);
}
@@ -5797,7 +6037,8 @@ function getVideoIDFromURL($url) {
return false;
}
-function getBackURL() {
+function getBackURL()
+{
global $global;
$backURL = getRedirectUri();
if (empty($backURL)) {
@@ -5809,7 +6050,8 @@ function getBackURL() {
return $backURL;
}
-function getHomeURL() {
+function getHomeURL()
+{
global $global, $advancedCustomUser, $advancedCustom;
if (isValidURL($advancedCustomUser->afterLoginGoToURL)) {
return $advancedCustomUser->afterLoginGoToURL;
@@ -5819,7 +6061,8 @@ function getHomeURL() {
return $global['webSiteRootURL'];
}
-function isValidURL($url) {
+function isValidURL($url)
+{
//var_dump(empty($url), !is_string($url), preg_match("/^http.*/", $url), filter_var($url, FILTER_VALIDATE_URL));
if (empty($url) || !is_string($url)) {
return false;
@@ -5830,7 +6073,8 @@ function isValidURL($url) {
return false;
}
-function isValidEmail($email) {
+function isValidEmail($email)
+{
global $_email_hosts_checked;
if (empty($email)) {
return false;
@@ -5852,8 +6096,8 @@ function isValidEmail($email) {
$_email_hosts_checked[$email_host] = true;
// Check if valid IP (v4 or v6). If it is we can't do a DNS lookup
if (!filter_var($email_host, FILTER_VALIDATE_IP, [
- 'flags' => FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE,
- ])) {
+ 'flags' => FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE,
+ ])) {
//Add a dot to the end of the host name to make a fully qualified domain name
// and get last array element because an escaped @ is allowed in the local part (RFC 5322)
// Then convert to ascii (http://us.php.net/manual/en/function.idn-to-ascii.php)
@@ -5868,7 +6112,8 @@ function isValidEmail($email) {
return $_email_hosts_checked[$email_host];
}
-function isValidURLOrPath($str, $insideCacheOrTmpDirOnly = true) {
+function isValidURLOrPath($str, $insideCacheOrTmpDirOnly = true)
+{
global $global;
//var_dump(empty($url), !is_string($url), preg_match("/^http.*/", $url), filter_var($url, FILTER_VALIDATE_URL));
if (empty($str) || !is_string($str)) {
@@ -5895,11 +6140,11 @@ function isValidURLOrPath($str, $insideCacheOrTmpDirOnly = true) {
foreach ($pathsToCheck as $value) {
if (
- str_starts_with($value, $absolutePathTmp) ||
- str_starts_with($value, '/var/www/') ||
- str_starts_with($value, $absolutePathCache) ||
- str_starts_with($value, $global['systemRootPath']) ||
- str_starts_with($value, getVideosDir())
+ str_starts_with($value, $absolutePathTmp) ||
+ str_starts_with($value, '/var/www/') ||
+ str_starts_with($value, $absolutePathCache) ||
+ str_starts_with($value, $global['systemRootPath']) ||
+ str_starts_with($value, getVideosDir())
) {
return true;
}
@@ -5915,21 +6160,25 @@ function isValidURLOrPath($str, $insideCacheOrTmpDirOnly = true) {
return false;
}
-function hasLastSlash($word) {
+function hasLastSlash($word)
+{
$word = trim($word);
return substr($word, -1) === '/';
}
-function addLastSlash($word) {
+function addLastSlash($word)
+{
$word = trim($word);
return $word . (hasLastSlash($word) ? "" : "/");
}
-function URLHasLastSlash() {
+function URLHasLastSlash()
+{
return hasLastSlash($_SERVER["REQUEST_URI"]);
}
-function ucname($str) {
+function ucname($str)
+{
$str = ucwords(mb_strtolower($str));
foreach (['\'', '-'] as $delim) {
@@ -5940,15 +6189,18 @@ function ucname($str) {
return $str;
}
-function sanitize_input($input) {
+function sanitize_input($input)
+{
return htmlentities(strip_tags($input));
}
-function sanitize_array_item(&$item, $key) {
+function sanitize_array_item(&$item, $key)
+{
$item = sanitize_input($item);
}
-function getSEOComplement($parameters = []) {
+function getSEOComplement($parameters = [])
+{
global $config;
$allowedTypes = $parameters["allowedTypes"] ?? null;
@@ -5996,7 +6248,8 @@ function getSEOComplement($parameters = []) {
return $txt;
}
-function doNOTOrganizeHTMLIfIsPagination() {
+function doNOTOrganizeHTMLIfIsPagination()
+{
global $global;
$page = getCurrentPage();
if ($page > 1) {
@@ -6004,7 +6257,8 @@ function doNOTOrganizeHTMLIfIsPagination() {
}
}
-function getCurrentPage() {
+function getCurrentPage()
+{
global $lastCurrent;
$current = 1;
if (!empty($_REQUEST['current'])) {
@@ -6035,7 +6289,8 @@ function getCurrentPage() {
return $current;
}
-function getTrendingLimit() {
+function getTrendingLimit()
+{
global $advancedCustom;
if (empty($advancedCustom)) {
$advancedCustom = AVideoPlugin::getObjectData("CustomizeAdvanced");
@@ -6044,17 +6299,20 @@ function getTrendingLimit() {
return $daysLimit;
}
-function getTrendingLimitDate() {
+function getTrendingLimitDate()
+{
$daysLimit = getTrendingLimit();
$dateDaysLimit = date('Y-m-d H:i:s', strtotime("-{$daysLimit} days"));
return $dateDaysLimit;
}
-function setCurrentPage($current) {
+function setCurrentPage($current)
+{
$_REQUEST['current'] = intval($current);
}
-function getRowCount($default = 1000) {
+function getRowCount($default = 1000)
+{
global $global;
if (!empty($_REQUEST['rowCount'])) {
$defaultN = intval($_REQUEST['rowCount']);
@@ -6074,13 +6332,15 @@ function getRowCount($default = 1000) {
return (!empty($defaultN) && $defaultN > 0) ? $defaultN : $default;
}
-function setRowCount($rowCount) {
+function setRowCount($rowCount)
+{
global $global;
$_REQUEST['rowCount'] = intval($rowCount);
$global['rowCount'] = $_REQUEST['rowCount'];
}
-function getSearchVar() {
+function getSearchVar()
+{
$search = '';
if (!empty($_REQUEST['search'])) {
$search = $_REQUEST['search'];
@@ -6094,13 +6354,15 @@ function getSearchVar() {
return mb_strtolower($search);
}
-function isSearch() {
+function isSearch()
+{
return !empty(getSearchVar());
}
$cleanSearchHistory = '';
-function cleanSearchVar() {
+function cleanSearchVar()
+{
global $cleanSearchHistory;
$search = getSearchVar();
if (!empty($search)) {
@@ -6112,7 +6374,8 @@ function cleanSearchVar() {
}
}
-function reloadSearchVar() {
+function reloadSearchVar()
+{
global $cleanSearchHistory;
$_REQUEST['search'] = $cleanSearchHistory;
if (empty($_GET['search'])) {
@@ -6123,7 +6386,8 @@ function reloadSearchVar() {
}
}
-function wget($url, $filename, $debug = false) {
+function wget($url, $filename, $debug = false)
+{
if (empty($url) || $url == "php://input" || !isValidURL($url)) {
return false;
}
@@ -6170,7 +6434,8 @@ function wget($url, $filename, $debug = false) {
* @param $infile The full URL to the remote file
* @param $outfile The path where to save the file
*/
-function copyfile_chunked($infile, $outfile) {
+function copyfile_chunked($infile, $outfile)
+{
$chunksize = 10 * (1024 * 1024); // 10 Megs
/**
@@ -6251,16 +6516,19 @@ function copyfile_chunked($infile, $outfile) {
return $cnt;
}
-function wgetLockFile($url) {
+function wgetLockFile($url)
+{
return getTmpDir("YPTWget") . md5($url) . ".lock";
}
-function wgetLock($url) {
+function wgetLock($url)
+{
$file = wgetLockFile($url);
return file_put_contents($file, time() . PHP_EOL, FILE_APPEND | LOCK_EX);
}
-function wgetRemoveLock($url) {
+function wgetRemoveLock($url)
+{
$filename = wgetLockFile($url);
if (!file_exists($filename)) {
return false;
@@ -6268,16 +6536,19 @@ function wgetRemoveLock($url) {
return unlink($filename);
}
-function getLockFile($name) {
+function getLockFile($name)
+{
return getTmpDir("YPTLockFile") . md5($name) . ".lock";
}
-function setLock($name) {
+function setLock($name)
+{
$file = getLockFile($name);
return file_put_contents($file, time());
}
-function isLock($name, $timeout = 60) {
+function isLock($name, $timeout = 60)
+{
$file = getLockFile($name);
if (file_exists($file)) {
$time = intval(file_get_contents($file));
@@ -6287,7 +6558,8 @@ function isLock($name, $timeout = 60) {
}
}
-function removeLock($name) {
+function removeLock($name)
+{
$filename = getLockFile($name);
if (!file_exists($filename)) {
return false;
@@ -6295,7 +6567,8 @@ function removeLock($name) {
return unlink($filename);
}
-function wgetIsLocked($url) {
+function wgetIsLocked($url)
+{
$filename = wgetLockFile($url);
if (!file_exists($filename)) {
return false;
@@ -6309,7 +6582,8 @@ function wgetIsLocked($url) {
}
// due the some OS gives a fake is_writable response
-function isWritable($dir) {
+function isWritable($dir)
+{
$dir = rtrim($dir, '/') . '/';
$file = $dir . uniqid();
$result = false;
@@ -6325,7 +6599,8 @@ function isWritable($dir) {
return $result;
}
-function _isWritable($dir) {
+function _isWritable($dir)
+{
if (!isWritable($dir)) {
return false;
}
@@ -6335,7 +6610,8 @@ function _isWritable($dir) {
return !empty($bytes);
}
-function getTmpDir($subdir = "") {
+function getTmpDir($subdir = "")
+{
global $global;
if (empty($_SESSION['getTmpDir'])) {
$_SESSION['getTmpDir'] = [];
@@ -6368,11 +6644,13 @@ function getTmpDir($subdir = "") {
return $tmpDir;
}
-function getTmpFile() {
+function getTmpFile()
+{
return getTmpDir("tmpFiles") . uniqid();
}
-function getMySQLDate() {
+function getMySQLDate()
+{
global $global;
$sql = "SELECT now() as time FROM configurations 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
@@ -6387,7 +6665,8 @@ function getMySQLDate() {
return $row;
}
-function _file_put_contents($filename, $data, $flags = 0, $context = null) {
+function _file_put_contents($filename, $data, $flags = 0, $context = null)
+{
make_path($filename);
if (!is_string($data)) {
$data = _json_encode($data);
@@ -6395,7 +6674,8 @@ function _file_put_contents($filename, $data, $flags = 0, $context = null) {
return file_put_contents($filename, $data, $flags, $context);
}
-function html2plainText($html) {
+function html2plainText($html)
+{
if (!is_string($html)) {
return '';
}
@@ -6404,19 +6684,20 @@ function html2plainText($html) {
return $text;
}
-function getInputPassword($id, $attributes = 'class="form-control"', $placeholder = '') {
+function getInputPassword($id, $attributes = 'class="form-control"', $placeholder = '')
+{
if (empty($placeholder)) {
$placeholder = __("Password");
}
- ?>
+?>
>
-
+
-
+?>
>
-
+
-
+?>
";
}
-function getServerClock() {
+function getServerClock()
+{
$id = uniqid();
$today = getdate();
$html = '00:00:00';
@@ -7478,7 +7809,8 @@ function getServerClock() {
* @param string $filepath
* @return boolean
*/
-function downloadHLS($filepath) {
+function downloadHLS($filepath)
+{
global $global;
if (!CustomizeUser::canDownloadVideos()) {
@@ -7523,7 +7855,8 @@ function downloadHLS($filepath) {
exit;
}
-function playHLSasMP4($filepath) {
+function playHLSasMP4($filepath)
+{
global $global;
if (!CustomizeUser::canDownloadVideos()) {
@@ -7556,33 +7889,34 @@ function playHLSasMP4($filepath) {
exit;
}
-function getSocialModal($videos_id, $url = "", $title = "") {
+function getSocialModal($videos_id, $url = "", $title = "")
+{
global $global;
$video['id'] = $videos_id;
$sharingUid = uniqid();
$filePath = $global['systemRootPath'] . 'objects/functionGetSocialModal.php';
$contents = getIncludeFileContent(
- $filePath,
- [
- 'videos_id' => $videos_id,
- 'url' => $url,
- 'title' => $title,
- 'video' => $video,
- 'sharingUid' => $sharingUid
- ]
+ $filePath,
+ [
+ 'videos_id' => $videos_id,
+ 'url' => $url,
+ 'title' => $title,
+ 'video' => $video,
+ 'sharingUid' => $sharingUid
+ ]
);
return ['html' => $contents, 'id' => $sharingUid];
}
function getCroppie(
- $buttonTitle,
- $callBackJSFunction,
- $resultWidth = 0,
- $resultHeight = 0,
- $viewportWidth = 0,
- $boundary = 25,
- $viewportHeight = 0,
- $enforceBoundary = true
+ $buttonTitle,
+ $callBackJSFunction,
+ $resultWidth = 0,
+ $resultHeight = 0,
+ $viewportWidth = 0,
+ $boundary = 25,
+ $viewportHeight = 0,
+ $enforceBoundary = true
) {
global $global;
@@ -7645,7 +7979,8 @@ function getCroppie(
];
}
-function saveCroppieImage($destination, $postIndex = "imgBase64") {
+function saveCroppieImage($destination, $postIndex = "imgBase64")
+{
if (empty($destination) || empty($_POST[$postIndex])) {
return false;
}
@@ -7670,7 +8005,8 @@ function saveCroppieImage($destination, $postIndex = "imgBase64") {
return $saved;
}
-function get_ffmpeg($ignoreGPU = false) {
+function get_ffmpeg($ignoreGPU = false)
+{
global $global;
$complement = ' -user_agent "' . getSelfUserAgent() . '" ';
//return 'ffmpeg -headers "User-Agent: '.getSelfUserAgent("FFMPEG").'" ';
@@ -7687,14 +8023,16 @@ function get_ffmpeg($ignoreGPU = false) {
return $ffmpeg . $complement;
}
-function removeUserAgentIfNotURL($cmd) {
+function removeUserAgentIfNotURL($cmd)
+{
if (!preg_match('/ -i [\'"]?https?:/', $cmd)) {
$cmd = preg_replace('/-user_agent "[^"]+"/', '', $cmd);
}
return $cmd;
}
-function convertVideoToMP3FileIfNotExists($videos_id) {
+function convertVideoToMP3FileIfNotExists($videos_id)
+{
global $global;
if (!empty($global['disableMP3'])) {
return false;
@@ -7726,7 +8064,8 @@ function convertVideoToMP3FileIfNotExists($videos_id) {
}
}
-function convertVideoFileWithFFMPEG($fromFileLocation, $toFileLocation, $try = 0) {
+function convertVideoFileWithFFMPEG($fromFileLocation, $toFileLocation, $try = 0)
+{
$parts = explode('?', $fromFileLocation);
$localFileLock = getCacheDir() . 'convertVideoFileWithFFMPEG_' . md5($parts[0]) . ".lock";
$ageInSeconds = time() - @filemtime($localFileLock);
@@ -7794,7 +8133,8 @@ function convertVideoFileWithFFMPEG($fromFileLocation, $toFileLocation, $try = 0
return ['return' => $return, 'output' => $output, 'command' => $command, 'fromFileLocation' => $fromFileLocation, 'toFileLocation' => $toFileLocation, 'progressFile' => $progressFile];
}
-function m3u8ToMP4($input) {
+function m3u8ToMP4($input)
+{
$videosDir = getVideosDir();
$outputfilename = str_replace($videosDir, "", $input);
$parts = explode("/", $outputfilename);
@@ -7849,17 +8189,20 @@ function m3u8ToMP4($input) {
return ['error' => $error, 'msg' => $msg, 'path' => $outputpath, 'filename' => $outputfilename];
}
-function getConvertVideoFileWithFFMPEGProgressFilename($toFileLocation) {
+function getConvertVideoFileWithFFMPEGProgressFilename($toFileLocation)
+{
$progressFile = $toFileLocation . '.log';
return $progressFile;
}
-function convertVideoToDownlaodProgress($toFileLocation) {
+function convertVideoToDownlaodProgress($toFileLocation)
+{
$progressFile = getConvertVideoFileWithFFMPEGProgressFilename($toFileLocation);
return parseFFMPEGProgress($progressFile);
}
-function getPHP() {
+function getPHP()
+{
global $global;
if (!empty($global['php'])) {
$php = $global['php'];
@@ -7874,11 +8217,13 @@ function getPHP() {
return get_php();
}
-function get_php() {
+function get_php()
+{
return getPHP();
}
-function isHTMLPage($url) {
+function isHTMLPage($url)
+{
if (preg_match('/https?:\/\/(www\.)?(youtu.be|youtube.com|vimeo.com|bitchute.com)\//i', $url)) {
return true;
} elseif ($type = getHeaderContentTypeFromURL($url)) {
@@ -7889,7 +8234,8 @@ function isHTMLPage($url) {
return false;
}
-function url_exists($url) {
+function url_exists($url)
+{
global $global;
if (preg_match('/^https?:\/\//i', $url)) {
$parts = explode('/videos/', $url);
@@ -7922,14 +8268,16 @@ function url_exists($url) {
}
}
-function getHeaderContentTypeFromURL($url) {
+function getHeaderContentTypeFromURL($url)
+{
if (isValidURL($url) && $type = get_headers($url, 1)["Content-Type"]) {
return $type;
}
return false;
}
-function canFullScreen() {
+function canFullScreen()
+{
global $doNotFullScreen;
if (!empty($doNotFullScreen) || isSerie() || !isVideo()) {
return false;
@@ -7937,13 +8285,15 @@ function canFullScreen() {
return true;
}
-function getTinyMCE($id, $simpleMode = false) {
+function getTinyMCE($id, $simpleMode = false)
+{
global $global;
$contents = getIncludeFileContent($global['systemRootPath'] . 'objects/functionsGetTinyMCE.php', ['id' => $id, 'simpleMode' => $simpleMode]);
return $contents;
}
-function pathToRemoteURL($filename, $forceHTTP = false, $ignoreCDN = false) {
+function pathToRemoteURL($filename, $forceHTTP = false, $ignoreCDN = false)
+{
global $pathToRemoteURL, $global;
if (!isset($pathToRemoteURL)) {
$pathToRemoteURL = [];
@@ -8010,13 +8360,15 @@ function pathToRemoteURL($filename, $forceHTTP = false, $ignoreCDN = false) {
return $url;
}
-function getFilenameFromPath($path) {
+function getFilenameFromPath($path)
+{
global $global;
$fileName = Video::getCleanFilenameFromFile($path);
return $fileName;
}
-function showCloseButton() {
+function showCloseButton()
+{
global $global, $showCloseButtonIncluded;
if (!empty($showCloseButtonIncluded)) {
return '';
@@ -8042,7 +8394,8 @@ function showCloseButton() {
return '';
}
-function getThemes() {
+function getThemes()
+{
global $_getThemes, $global;
if (isset($_getThemes)) {
return $_getThemes;
@@ -8055,7 +8408,8 @@ function getThemes() {
return $_getThemes;
}
-function getCurrentTheme() {
+function getCurrentTheme()
+{
global $config;
if (!empty($_REQUEST['customCSS'])) {
_setcookie('customCSS', $_REQUEST['customCSS']);
@@ -8072,7 +8426,8 @@ function getCurrentTheme() {
* $users_id="-1" means send to no one
*/
-function sendSocketMessage($msg, $callbackJSFunction = "", $users_id = "-1", $send_to_uri_pattern = "", $try = 0) {
+function sendSocketMessage($msg, $callbackJSFunction = "", $users_id = "-1", $send_to_uri_pattern = "", $try = 0)
+{
if (AVideoPlugin::isEnabledByName('YPTSocket')) {
if (!is_string($msg)) {
$msg = json_encode($msg);
@@ -8098,7 +8453,8 @@ function sendSocketMessage($msg, $callbackJSFunction = "", $users_id = "-1", $se
return false;
}
-function sendSocketMessageToUsers_id($msg, $users_id, $callbackJSFunction = "") {
+function sendSocketMessageToUsers_id($msg, $users_id, $callbackJSFunction = "")
+{
if (empty($users_id)) {
return false;
}
@@ -8115,29 +8471,34 @@ function sendSocketMessageToUsers_id($msg, $users_id, $callbackJSFunction = "")
return $resp;
}
-function sendSocketErrorMessageToUsers_id($msg, $users_id, $callbackJSFunction = "avideoResponse") {
+function sendSocketErrorMessageToUsers_id($msg, $users_id, $callbackJSFunction = "avideoResponse")
+{
$newMessage = new stdClass();
$newMessage->error = true;
$newMessage->msg = $msg;
return sendSocketMessageToUsers_id($newMessage, $users_id, $callbackJSFunction);
}
-function sendSocketSuccessMessageToUsers_id($msg, $users_id, $callbackJSFunction = "avideoResponse") {
+function sendSocketSuccessMessageToUsers_id($msg, $users_id, $callbackJSFunction = "avideoResponse")
+{
$newMessage = new stdClass();
$newMessage->error = false;
$newMessage->msg = $msg;
return sendSocketMessageToUsers_id($newMessage, $users_id, $callbackJSFunction);
}
-function sendSocketMessageToAll($msg, $callbackJSFunction = "", $send_to_uri_pattern = "") {
+function sendSocketMessageToAll($msg, $callbackJSFunction = "", $send_to_uri_pattern = "")
+{
return sendSocketMessage($msg, $callbackJSFunction, "", $send_to_uri_pattern);
}
-function sendSocketMessageToNone($msg, $callbackJSFunction = "") {
+function sendSocketMessageToNone($msg, $callbackJSFunction = "")
+{
return sendSocketMessage($msg, $callbackJSFunction, -1);
}
-function execAsync($command) {
+function execAsync($command)
+{
//$command = escapeshellarg($command);
// If windows, else
if (isWindows()) {
@@ -8156,7 +8517,8 @@ function execAsync($command) {
return $pid;
}
-function killProcess($pid) {
+function killProcess($pid)
+{
$pid = intval($pid);
if (empty($pid)) {
return false;
@@ -8169,11 +8531,13 @@ function killProcess($pid) {
return true;
}
-function isWindows() {
+function isWindows()
+{
return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
}
-function getPIDUsingPort($port) {
+function getPIDUsingPort($port)
+{
$port = intval($port);
if (empty($port)) {
return false;
@@ -8208,7 +8572,8 @@ function getPIDUsingPort($port) {
return false;
}
-function isURL200($url, $forceRecheck = false) {
+function isURL200($url, $forceRecheck = false)
+{
global $_isURL200;
$name = "isURL200" . DIRECTORY_SEPARATOR . md5($url);
if (empty($forceRecheck)) {
@@ -8233,9 +8598,9 @@ function isURL200($url, $forceRecheck = false) {
$object->result = false;
foreach ($headers as $value) {
if (
- strpos($value, '200') ||
- strpos($value, '302') ||
- strpos($value, '304')
+ strpos($value, '200') ||
+ strpos($value, '302') ||
+ strpos($value, '304')
) {
$object->result = true;
break;
@@ -8249,20 +8614,23 @@ function isURL200($url, $forceRecheck = false) {
return $object->result;
}
-function isURL200Clear() {
+function isURL200Clear()
+{
$tmpDir = ObjectYPT::getCacheDir();
$cacheDir = $tmpDir . "isURL200" . DIRECTORY_SEPARATOR;
_error_log('isURL200Clear: ' . json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)));
rrmdir($cacheDir);
}
-function deleteStatsNotifications($clearFirstPage = false) {
+function deleteStatsNotifications($clearFirstPage = false)
+{
Live::deleteStatsCache($clearFirstPage);
$cacheName = "getStats" . DIRECTORY_SEPARATOR . "getStatsNotifications";
ObjectYPT::deleteCache($cacheName);
}
-function getLiveVideosFromUsers_id($users_id) {
+function getLiveVideosFromUsers_id($users_id)
+{
$videos = [];
if (!empty($users_id)) {
$stats = getStatsNotifications();
@@ -8280,7 +8648,8 @@ function getLiveVideosFromUsers_id($users_id) {
return $videos;
}
-function getLiveVideosObject($application) {
+function getLiveVideosObject($application)
+{
foreach ($application as $key => $application2) {
if (preg_match('/^html/i', $key)) {
unset($application[$key]);
@@ -8437,7 +8806,8 @@ function getLiveVideosObject($application) {
return $video;
}
-function getLiveVideosFromCategory($categories_id) {
+function getLiveVideosFromCategory($categories_id)
+{
$stats = getStatsNotifications();
$videos = [];
if (!empty($categories_id)) {
@@ -8452,7 +8822,8 @@ function getLiveVideosFromCategory($categories_id) {
return $videos;
}
-function getStatsNotifications($force_recreate = false, $listItIfIsAdminOrOwner = true) {
+function getStatsNotifications($force_recreate = false, $listItIfIsAdminOrOwner = true)
+{
global $__getStatsNotifications__;
$isLiveEnabled = AVideoPlugin::isEnabledByName('Live');
$cacheName = "getStats" . DIRECTORY_SEPARATOR . "getStatsNotifications";
@@ -8564,7 +8935,8 @@ function getStatsNotifications($force_recreate = false, $listItIfIsAdminOrOwner
return $json;
}
-function getSocketConnectionLabel() {
+function getSocketConnectionLabel()
+{
$html = '
@@ -8584,19 +8956,23 @@ function getSocketConnectionLabel() {
return $html;
}
-function getSocketVideoClassName($videos_id) {
+function getSocketVideoClassName($videos_id)
+{
return 'total_on_videos_id_' . $videos_id;
}
-function getSocketLiveClassName($key, $live_servers_id) {
+function getSocketLiveClassName($key, $live_servers_id)
+{
return 'total_on_live_' . $key . '_' . intval($live_servers_id);
}
-function getSocketLiveLinksClassName($live_links_id) {
+function getSocketLiveLinksClassName($live_links_id)
+{
return 'total_on_live_links_id_' . $live_links_id;
}
-function getLiveUsersLabelVideo($videos_id, $totalViews = null, $viewsClass = "label label-default", $counterClass = "label label-primary") {
+function getLiveUsersLabelVideo($videos_id, $totalViews = null, $viewsClass = "label label-default", $counterClass = "label label-primary")
+{
global $global;
$label = '';
if (AVideoPlugin::isEnabledByName('LiveUsers') && method_exists("LiveUsers", "getLabels")) {
@@ -8605,20 +8981,23 @@ function getLiveUsersLabelVideo($videos_id, $totalViews = null, $viewsClass = "l
return $label;
}
-function getLiveUsersLabelLive($key, $live_servers_id, $viewsClass = "label label-default", $counterClass = "label label-primary") {
+function getLiveUsersLabelLive($key, $live_servers_id, $viewsClass = "label label-default", $counterClass = "label label-primary")
+{
if (AVideoPlugin::isEnabledByName('LiveUsers') && method_exists("LiveUsers", "getLabels")) {
$totalViews = LiveUsers::getTotalUsers($key, $live_servers_id);
return LiveUsers::getLabels(getSocketLiveClassName($key, $live_servers_id), $totalViews, $viewsClass, $counterClass, 'live');
}
}
-function getLiveUsersLabelLiveLinks($liveLinks_id, $totalViews = null, $viewsClass = "label label-default", $counterClass = "label label-primary") {
+function getLiveUsersLabelLiveLinks($liveLinks_id, $totalViews = null, $viewsClass = "label label-default", $counterClass = "label label-primary")
+{
if (AVideoPlugin::isEnabledByName('LiveUsers') && method_exists("LiveUsers", "getWatchingNowLabel")) {
return LiveUsers::getWatchingNowLabel(getSocketLiveLinksClassName($liveLinks_id), "label label-primary", '', $viewsClass, 'livelinks');
}
}
-function getLiveUsersLabel($viewsClass = "label label-default", $counterClass = "label label-primary") {
+function getLiveUsersLabel($viewsClass = "label label-default", $counterClass = "label label-primary")
+{
if (empty($_REQUEST['disableLiveUsers']) && AVideoPlugin::isEnabledByName('LiveUsers')) {
$live = isLive();
if (!empty($live)) {
@@ -8639,7 +9018,8 @@ function getLiveUsersLabel($viewsClass = "label label-default", $counterClass =
return "";
}
-function getLiveUsersLabelHTML($viewsClass = "label label-default", $counterClass = "label label-primary") {
+function getLiveUsersLabelHTML($viewsClass = "label label-default", $counterClass = "label label-primary")
+{
global $global, $_getLiveUsersLabelHTML;
if (!empty($_getLiveUsersLabelHTML)) {
return '';
@@ -8653,7 +9033,8 @@ function getLiveUsersLabelHTML($viewsClass = "label label-default", $counterClas
return $htmlMediaTag;
}
-function getHTMLTitle($titleArray) {
+function getHTMLTitle($titleArray)
+{
global $config, $global;
if (!is_array($titleArray)) {
@@ -8666,7 +9047,8 @@ function getHTMLTitle($titleArray) {
return "{$title}";
}
-function getButtonSignInAndUp() {
+function getButtonSignInAndUp()
+{
$signIn = getButtonSignIn();
$signUp = getButtonSignUp();
$html = $signIn . $signUp;
@@ -8677,7 +9059,8 @@ function getButtonSignInAndUp() {
}
}
-function getButtonSignUp() {
+function getButtonSignUp()
+{
global $global;
$obj = AVideoPlugin::getDataObject('CustomizeUser');
if (!empty($obj->disableNativeSignUp)) {
@@ -8691,7 +9074,8 @@ function getButtonSignUp() {
return $html;
}
-function getButtonSignIn() {
+function getButtonSignIn()
+{
global $global;
$obj = AVideoPlugin::getDataObject('CustomizeUser');
if (!empty($obj->disableNativeSignIn)) {
@@ -8705,7 +9089,8 @@ function getButtonSignIn() {
return $html;
}
-function getTitle() {
+function getTitle()
+{
global $global;
if (empty($global['pageTitle'])) {
$url = getSelfURI();
@@ -8722,7 +9107,8 @@ function getTitle() {
return $global['pageTitle'];
}
-function outputAndContinueInBackground($msg = '') {
+function outputAndContinueInBackground($msg = '')
+{
global $outputAndContinueInBackground;
if (!empty($outputAndContinueInBackground)) {
@@ -8745,7 +9131,8 @@ function outputAndContinueInBackground($msg = '') {
flush();
}
-function cleanUpRowFromDatabase($row) {
+function cleanUpRowFromDatabase($row)
+{
if (is_array($row)) {
foreach ($row as $key => $value) {
if (preg_match('/pass/i', $key)) {
@@ -8756,12 +9143,14 @@ function cleanUpRowFromDatabase($row) {
return $row;
}
-function getImageTransparent1pxURL() {
+function getImageTransparent1pxURL()
+{
global $global;
return getCDN() . "view/img/transparent1px.png";
}
-function getDatabaseTime() {
+function getDatabaseTime()
+{
global $global, $_getDatabaseTime;
if (isset($_getDatabaseTime)) {
return $_getDatabaseTime;
@@ -8779,7 +9168,8 @@ function getDatabaseTime() {
return $_getDatabaseTime;
}
-function fixTimezone($timezone) {
+function fixTimezone($timezone)
+{
$known_abbreviations = [
'PDT' => 'America/Los_Angeles',
'PST' => 'America/Los_Angeles',
@@ -8805,7 +9195,8 @@ function fixTimezone($timezone) {
return $timezone;
}
-function getSystemTimezone() {
+function getSystemTimezone()
+{
global $global, $_getSystemTimezoneName;
if (isset($_getSystemTimezoneName)) {
return $_getSystemTimezoneName;
@@ -8824,7 +9215,8 @@ function getSystemTimezone() {
return $_getDatabaseTimezoneName;
}
-function getDatabaseTimezoneName() {
+function getDatabaseTimezoneName()
+{
global $global, $_getDatabaseTimezoneName;
if (isset($_getDatabaseTimezoneName)) {
return $_getDatabaseTimezoneName;
@@ -8844,7 +9236,8 @@ function getDatabaseTimezoneName() {
return $_getDatabaseTimezoneName;
}
-function get_js_availableLangs() {
+function get_js_availableLangs()
+{
global $global;
if (empty($global['js_availableLangs'])) {
include_once $global['systemRootPath'] . 'objects/bcp47.php';
@@ -8852,7 +9245,8 @@ function get_js_availableLangs() {
return $global['js_availableLangs'];
}
-function listAllWordsToTranslate() {
+function listAllWordsToTranslate()
+{
global $global;
$cacheName = 'listAllWordsToTranslate';
$cache = ObjectYPT::getCache($cacheName, 0);
@@ -8861,7 +9255,8 @@ function listAllWordsToTranslate() {
}
ini_set('max_execution_time', 300);
- function listAll($dir) {
+ function listAll($dir)
+ {
$vars = [];
if (preg_match('/vendor.*$/', $dir)) {
return $vars;
@@ -8879,9 +9274,9 @@ function listAllWordsToTranslate() {
$data = file_get_contents($filename);
$regex = '/__\(["\']{1}(.*)["\']{1}\)/U';
preg_match_all(
- $regex,
- $data,
- $matches
+ $regex,
+ $data,
+ $matches
);
foreach ($matches[0] as $key => $value) {
$vars[$matches[1][$key]] = $matches[1][$key];
@@ -8907,7 +9302,8 @@ function listAllWordsToTranslate() {
return $vars;
}
-function secondsInterval($time1, $time2) {
+function secondsInterval($time1, $time2)
+{
if (!isset($time1) || !isset($time2)) {
return 0;
}
@@ -8921,7 +9317,8 @@ function secondsInterval($time1, $time2) {
return $time1 - $time2;
}
-function secondsIntervalHuman($time, $useDatabaseTime = true) {
+function secondsIntervalHuman($time, $useDatabaseTime = true)
+{
$dif = secondsIntervalFromNow($time, $useDatabaseTime);
if ($dif < 0) {
return humanTimingAfterwards($time, 0, $useDatabaseTime);
@@ -8930,7 +9327,8 @@ function secondsIntervalHuman($time, $useDatabaseTime = true) {
}
}
-function isTimeForFuture($time, $useDatabaseTime = true) {
+function isTimeForFuture($time, $useDatabaseTime = true)
+{
$dif = secondsIntervalFromNow($time, $useDatabaseTime);
if ($dif < 0) {
return true;
@@ -8939,7 +9337,8 @@ function isTimeForFuture($time, $useDatabaseTime = true) {
}
}
-function secondsIntervalFromNow($time, $useDatabaseTimeOrTimezoneString = true) {
+function secondsIntervalFromNow($time, $useDatabaseTimeOrTimezoneString = true)
+{
$timeNow = time();
//var_dump($time, $useDatabaseTimeOrTimezoneString);
if (!empty($useDatabaseTimeOrTimezoneString)) {
@@ -8954,18 +9353,21 @@ function secondsIntervalFromNow($time, $useDatabaseTimeOrTimezoneString = true)
return secondsInterval($timeNow, $time);
}
-function getScriptRunMicrotimeInSeconds() {
+function getScriptRunMicrotimeInSeconds()
+{
global $global;
$time_now = microtime(true);
return ($time_now - $global['avideoStartMicrotime']);
}
-function fixSystemPath() {
+function fixSystemPath()
+{
global $global;
$global['systemRootPath'] = fixPath($global['systemRootPath']);
}
-function fixPath($path, $addLastSlash = false) {
+function fixPath($path, $addLastSlash = false)
+{
if (empty($path)) {
return false;
}
@@ -8983,13 +9385,14 @@ function fixPath($path, $addLastSlash = false) {
if (false) {
- function openssl_cipher_key_length() {
+ function openssl_cipher_key_length()
+ {
return 0;
}
-
}
-function getHashMethodsAndInfo() {
+function getHashMethodsAndInfo()
+{
global $global, $_getHashMethod;
if (empty($_getHashMethod)) {
@@ -9025,7 +9428,8 @@ function getHashMethodsAndInfo() {
return $_getHashMethod;
}
-function idToHash($id) {
+function idToHash($id)
+{
global $global, $_idToHash;
if (!isset($_idToHash)) {
@@ -9059,7 +9463,8 @@ function idToHash($id) {
return $hash;
}
-function hashToID($hash) {
+function hashToID($hash)
+{
//return hashToID_old($hash);
global $global;
$hash = str_replace(['_', '-', '.'], ['/', '+', '='], $hash);
@@ -9087,7 +9492,8 @@ function hashToID($hash) {
* @param type $hash
* @return type
*/
-function hashToID_old($hash) {
+function hashToID_old($hash)
+{
global $global;
if (!empty($global['useLongHash'])) {
$base = 2;
@@ -9104,7 +9510,8 @@ function hashToID_old($hash) {
return intval($decrypt);
}
-function videosHashToID($hash_of_videos_id) {
+function videosHashToID($hash_of_videos_id)
+{
if (is_int($hash_of_videos_id)) {
return $hash_of_videos_id;
}
@@ -9130,7 +9537,8 @@ function videosHashToID($hash_of_videos_id) {
* @param string $id the ID of the URL in case the CDN is an array
* @return \type
*/
-function getCDN($type = 'CDN', $id = 0) {
+function getCDN($type = 'CDN', $id = 0)
+{
global $advancedCustom, $global, $_getCDNURL;
$index = $type . $id;
if (!isset($_getCDNURL)) {
@@ -9154,7 +9562,8 @@ function getCDN($type = 'CDN', $id = 0) {
return empty($_getCDNURL[$index]) ? false : $_getCDNURL[$index];
}
-function getURL($relativePath, $ignoreCDN = false) {
+function getURL($relativePath, $ignoreCDN = false)
+{
global $global;
$relativePath = str_replace('\\', '/', $relativePath);
$relativePath = getRelativePath($relativePath);
@@ -9184,7 +9593,8 @@ function getURL($relativePath, $ignoreCDN = false) {
return $url;
}
-function fixTestURL($text) {
+function fixTestURL($text)
+{
if (isAVideoMobileApp() || !empty($_REQUEST['isAVideoMobileApp'])) {
$text = str_replace(array('https://vlu.me', 'https://www.vlu.me', 'vlu.me'), array('http://192.168.0.2', 'http://192.168.0.2', '192.168.0.2'), $text);
}
@@ -9192,7 +9602,8 @@ function fixTestURL($text) {
return $text;
}
-function getCDNOrURL($url, $type = 'CDN', $id = 0) {
+function getCDNOrURL($url, $type = 'CDN', $id = 0)
+{
if (!preg_match('/^http/i', $url)) {
return $url;
}
@@ -9203,7 +9614,8 @@ function getCDNOrURL($url, $type = 'CDN', $id = 0) {
return addLastSlash($url);
}
-function replaceCDNIfNeed($url, $type = 'CDN', $id = 0) {
+function replaceCDNIfNeed($url, $type = 'CDN', $id = 0)
+{
$cdn = getCDN($type, $id);
if (!empty($_GET['debug'])) {
$obj = AVideoPlugin::getDataObject('Blackblaze_B2');
@@ -9231,7 +9643,8 @@ function replaceCDNIfNeed($url, $type = 'CDN', $id = 0) {
return str_replace(parse_url($url, PHP_URL_HOST), parse_url($cdn, PHP_URL_HOST), $url);
}
-function isIPPrivate($ip) {
+function isIPPrivate($ip)
+{
if ($ip == '192.168.0.2') {
return false;
}
@@ -9239,9 +9652,9 @@ function isIPPrivate($ip) {
return false;
}
$result = filter_var(
- $ip,
- FILTER_VALIDATE_IP,
- FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE
+ $ip,
+ FILTER_VALIDATE_IP,
+ FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE
);
if (empty($result)) {
return true;
@@ -9249,13 +9662,15 @@ function isIPPrivate($ip) {
return false;
}
-function countDownPage($toTime, $message, $image, $bgImage, $title) {
+function countDownPage($toTime, $message, $image, $bgImage, $title)
+{
global $global;
include $global['systemRootPath'] . 'objects/functionCountDownPage.php';
exit;
}
-function inputToRequest() {
+function inputToRequest()
+{
$content = file_get_contents("php://input");
if (!empty($content)) {
$json = json_decode($content);
@@ -9270,7 +9685,8 @@ function inputToRequest() {
}
}
-function useVideoHashOrLogin() {
+function useVideoHashOrLogin()
+{
if (!empty($_REQUEST['video_id_hash'])) {
$videos_id = Video::getVideoIdFromHash($_REQUEST['video_id_hash']);
if (!empty($videos_id)) {
@@ -9283,7 +9699,8 @@ function useVideoHashOrLogin() {
return User::loginFromRequest();
}
-function strip_specific_tags($string, $tags_to_strip = ['script', 'style', 'iframe', 'object', 'applet', 'link']) {
+function strip_specific_tags($string, $tags_to_strip = ['script', 'style', 'iframe', 'object', 'applet', 'link'])
+{
if (empty($string)) {
return '';
}
@@ -9293,7 +9710,8 @@ function strip_specific_tags($string, $tags_to_strip = ['script', 'style', 'ifra
return $string;
}
-function strip_render_blocking_resources($string) {
+function strip_render_blocking_resources($string)
+{
$tags_to_strip = ['link', 'style'];
$head = preg_match('/(.*)<\/head>/s', $string, $matches);
if (empty($matches[0])) {
@@ -9308,14 +9726,16 @@ function strip_render_blocking_resources($string) {
return $string;
}
-function optimizeHTMLTags($html) {
+function optimizeHTMLTags($html)
+{
return $html;
//$html = optimizeCSS($html);
//$html = optimizeJS($html);
return $html . '<--! optimized -->';
}
-function optimizeCSS($html) {
+function optimizeCSS($html)
+{
global $global;
$css = '';
$cacheDir = getVideosDir() . 'cache/';
@@ -9357,7 +9777,8 @@ function optimizeCSS($html) {
return str_replace('', '' . PHP_EOL . $HTMLTag . PHP_EOL . '', $html);
}
-function optimizeJS($html) {
+function optimizeJS($html)
+{
global $global;
$js = '';
$cacheDir = getVideosDir() . 'cache/';
@@ -9402,7 +9823,8 @@ function optimizeJS($html) {
return str_replace('', '' . PHP_EOL . $HTMLTag . PHP_EOL . '