1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00

Refactor.

This commit is contained in:
Caleb Mazalevskis 2022-01-06 21:44:07 +08:00
parent 343eb5e2cc
commit 27a7925b98
No known key found for this signature in database
GPG key ID: 082E6BC1046FAB95
316 changed files with 54291 additions and 53534 deletions

View file

@ -6,8 +6,7 @@
<?php <?php
if (AVideoPlugin::exists('Backup')) { if (AVideoPlugin::exists('Backup')) {
include $global['systemRootPath'] . 'plugin/Backup/backupEditor_head.php'; include $global['systemRootPath'] . 'plugin/Backup/backupEditor_head.php';
include $global['systemRootPath'] . 'plugin/Backup/backupEditor_body.php'; include $global['systemRootPath'] . 'plugin/Backup/backupEditor_body.php'; ?>
?>
<hr> <hr>
<div class="alert alert-info"> <div class="alert alert-info">
<i class="fas fa-info-circle"></i> <?php echo __('As a database increases in size full database backups take more time to complete, and require more storage space. Please be patient'); ?> <i class="fas fa-info-circle"></i> <?php echo __('As a database increases in size full database backups take more time to complete, and require more storage space. Please be patient'); ?>
@ -36,8 +35,8 @@
<?php echo __('You May find some help how to use Clone Plugin'); ?> <a target="_blank" href="https://github.com/WWBN/AVideo/wiki/Clone-Site-Plugin" rel="noopener noreferrer"><?php echo __('here'); ?></a> <?php echo __('You May find some help how to use Clone Plugin'); ?> <a target="_blank" href="https://github.com/WWBN/AVideo/wiki/Clone-Site-Plugin" rel="noopener noreferrer"><?php echo __('here'); ?></a>
</div> </div>
<?php <?php
$filter = array( $filter = [
'cloneSiteURL' => __('Place here the URL of the site you want to clone')); 'cloneSiteURL' => __('Place here the URL of the site you want to clone'), ];
echo createTable("CloneSite", $filter); echo createTable("CloneSite", $filter);
include $global['systemRootPath'] . 'plugin/CloneSite/pluginMenu.html'; include $global['systemRootPath'] . 'plugin/CloneSite/pluginMenu.html';
?> ?>

View file

@ -22,31 +22,31 @@ if (!file_exists($global['systemRootPath'] . $imagePath)) {
} }
if (!is_writable($global['systemRootPath'] . $imagePath)) { if (!is_writable($global['systemRootPath'] . $imagePath)) {
$response = Array( $response = [
"status" => 'error', "status" => 'error',
"message" => 'No write Access' "message" => 'No write Access',
); ];
print json_encode($response); print json_encode($response);
return; return;
} }
$response = array(); $response = [];
if (!empty($_POST['logoImgBase64'])) { if (!empty($_POST['logoImgBase64'])) {
$fileData = base64DataToImage($_POST['logoImgBase64']); $fileData = base64DataToImage($_POST['logoImgBase64']);
$fileName = 'logo.png'; $fileName = 'logo.png';
$photoURL = $imagePath . $fileName; $photoURL = $imagePath . $fileName;
$bytes = file_put_contents($global['systemRootPath'] . $photoURL, $fileData); $bytes = file_put_contents($global['systemRootPath'] . $photoURL, $fileData);
if ($bytes > 10) { if ($bytes > 10) {
$response = array( $response = [
"status" => 'success', "status" => 'success',
"url" => $global['systemRootPath'] . $photoURL "url" => $global['systemRootPath'] . $photoURL,
); ];
$config->setLogo($photoURL); $config->setLogo($photoURL);
} else { } else {
$response = array( $response = [
"status" => 'error', "status" => 'error',
"msg" => 'We could not save logo', "msg" => 'We could not save logo',
"url" => $global['systemRootPath'] . $photoURL "url" => $global['systemRootPath'] . $photoURL,
); ];
} }
} }

View file

@ -13,11 +13,9 @@
<?php <?php
return false; return false;
} else { } else {
require_once $global['systemRootPath'] . 'plugin/Customize/Objects/ExtraConfig.php'; require_once $global['systemRootPath'] . 'plugin/Customize/Objects/ExtraConfig.php';
$ec = new ExtraConfig(); $ec = new ExtraConfig(); ?>
?>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<form id="customizeForm"> <form id="customizeForm">

View file

@ -31,13 +31,13 @@ $delay = 0.2;
<div class="panel-heading"> <div class="panel-heading">
<?php echo ucfirst($fileEx); ?> <?php echo ucfirst($fileEx); ?>
<div class="material-switch pull-right"> <div class="material-switch pull-right">
<input class="playerSwitch" data-toggle="toggle" type="checkbox" value="<?php echo ($fileEx); ?>" id="themeSwitch<?php echo ($fileEx); ?>" <?php echo (!empty($obj) && $fileEx == $obj->skin) ? "checked" : ""; ?>> <input class="playerSwitch" data-toggle="toggle" type="checkbox" value="<?php echo($fileEx); ?>" id="themeSwitch<?php echo($fileEx); ?>" <?php echo (!empty($obj) && $fileEx == $obj->skin) ? "checked" : ""; ?>>
<label for="themeSwitch<?php echo ($fileEx); ?>" class="label-primary"></label> <label for="themeSwitch<?php echo($fileEx); ?>" class="label-primary"></label>
</div> </div>
</div> </div>
<div class="panel-body" style="padding: 0;"> <div class="panel-body" style="padding: 0;">
<iframe fameBorder="0" <iframe fameBorder="0"
src="<?php echo $global['webSiteRootURL']; ?>plugin/PlayerSkins/playerSample.php?playerSkin=<?php echo ($fileEx); ?>" src="<?php echo $global['webSiteRootURL']; ?>plugin/PlayerSkins/playerSample.php?playerSkin=<?php echo($fileEx); ?>"
style="width: 100%; height: 300px; border: 0;"></iframe> style="width: 100%; height: 300px; border: 0;"></iframe>
</div> </div>
</div> </div>

View file

@ -12,8 +12,8 @@
<div class="panel-heading"> <div class="panel-heading">
<?php echo ucfirst($fileEx); ?> <?php echo ucfirst($fileEx); ?>
<div class="material-switch pull-right"> <div class="material-switch pull-right">
<input class="themeSwitch" data-toggle="toggle" type="checkbox" value="<?php echo ($fileEx); ?>" id="themeSwitch<?php echo ($fileEx); ?>" <?php echo ($fileEx == $savedTheme) ? "checked" : ""; ?>> <input class="themeSwitch" data-toggle="toggle" type="checkbox" value="<?php echo($fileEx); ?>" id="themeSwitch<?php echo($fileEx); ?>" <?php echo ($fileEx == $savedTheme) ? "checked" : ""; ?>>
<label for="themeSwitch<?php echo ($fileEx); ?>" class="label-primary"></label> <label for="themeSwitch<?php echo($fileEx); ?>" class="label-primary"></label>
</div> </div>
</div> </div>
<div class="panel-body"> <div class="panel-body">

View file

@ -1,5 +1,5 @@
<?php <?php
function createTable($pluginName, $filter = array()) function createTable($pluginName, $filter = [])
{ {
$plugin = AVideoPlugin::getObjectData($pluginName); $plugin = AVideoPlugin::getObjectData($pluginName);
if (empty($filter)) { if (empty($filter)) {
@ -12,7 +12,7 @@ function createTable($pluginName, $filter = array())
echo '<input type="hidden" value="' . $pluginName . '" name="pluginName"/>'; echo '<input type="hidden" value="' . $pluginName . '" name="pluginName"/>';
echo '<input type="hidden" value="' . implode("|", array_keys($filter)) . '" name="pluginsList"/>'; echo '<input type="hidden" value="' . implode("|", array_keys($filter)) . '" name="pluginsList"/>';
echo '<table class="table table-hover">'; echo '<table class="table table-hover">';
$pluginsList = array(); $pluginsList = [];
if (!AVideoPlugin::exists($pluginName)) { if (!AVideoPlugin::exists($pluginName)) {
echo "<tr><td colspan='2'> ".__('Sorry you do not have the plugin')." </td></tr>"; echo "<tr><td colspan='2'> ".__('Sorry you do not have the plugin')." </td></tr>";
} else { } else {
@ -27,27 +27,27 @@ function createTable($pluginName, $filter = array())
echo '</table></form>'; echo '</table></form>';
} }
function jsonToFormElements($json, $filter = array()) function jsonToFormElements($json, $filter = [])
{ {
//var_dump($json, $filter);exit; //var_dump($json, $filter);exit;
$elements = array(); $elements = [];
foreach ($json as $keyJson => $valueJson) { foreach ($json as $keyJson => $valueJson) {
if (!empty($filter) && empty($filter[$keyJson])) { if (!empty($filter) && empty($filter[$keyJson])) {
continue; continue;
} }
$label = "<label>{$keyJson}</label>"; $label = "<label>{$keyJson}</label>";
$help = ""; $help = '';
if (!empty($filter[$keyJson])) { if (!empty($filter[$keyJson])) {
$help = "<small class=\"form-text text-muted\">{$filter[$keyJson]}</small>"; $help = "<small class=\"form-text text-muted\">{$filter[$keyJson]}</small>";
} }
$input = ""; $input = '';
if (is_object($valueJson)) { if (is_object($valueJson)) {
if ($valueJson->type === 'textarea') { if ($valueJson->type === 'textarea') {
$input = "<textarea class='form-control jsonElement' name='{$keyJson}' pluginType='object'>{$valueJson->value}</textarea>"; $input = "<textarea class='form-control jsonElement' name='{$keyJson}' pluginType='object'>{$valueJson->value}</textarea>";
} elseif (is_array($valueJson->type)) { } elseif (is_array($valueJson->type)) {
$input = "<select class='form-control jsonElement' name='{$keyJson}' pluginType='object'>"; $input = "<select class='form-control jsonElement' name='{$keyJson}' pluginType='object'>";
foreach ($valueJson->type as $key => $value) { foreach ($valueJson->type as $key => $value) {
$select = ""; $select = '';
if ($valueJson->value == $key) { if ($valueJson->value == $key) {
$select = "selected"; $select = "selected";
} }
@ -55,7 +55,7 @@ function jsonToFormElements($json, $filter = array())
} }
$input .= "</select>"; $input .= "</select>";
} else { } else {
if(!is_string($valueJson->type) || !is_string($valueJson->value)){ if (!is_string($valueJson->type) || !is_string($valueJson->value)) {
continue; continue;
} }
$input = "<input class='form-control jsonElement' name='{$keyJson}' " $input = "<input class='form-control jsonElement' name='{$keyJson}' "

View file

@ -1,11 +1,11 @@
<?php <?php
$filter = array( $filter = [
'useEncoderNetworkRecomendation' => __('Let the encoder network (If configured) choose what is the best encoder to use'), 'useEncoderNetworkRecomendation' => __('Let the encoder network (If configured) choose what is the best encoder to use'),
'doNotShowEncoderResolutionLow' => __('Do not allow encode in Low resolution'), 'doNotShowEncoderResolutionLow' => __('Do not allow encode in Low resolution'),
'doNotShowEncoderResolutionSD' => __('Do not allow encode in SD resolution'), 'doNotShowEncoderResolutionSD' => __('Do not allow encode in SD resolution'),
'doNotShowEncoderResolutionHD' => __('Do not allow encode in HD resolution'), 'doNotShowEncoderResolutionHD' => __('Do not allow encode in HD resolution'),
'makeVideosInactiveAfterEncode' => __('Maybe you need to approve or check something on your video before make it public'), 'makeVideosInactiveAfterEncode' => __('Maybe you need to approve or check something on your video before make it public'),
'makeVideosUnlistedAfterEncode' => __('Maybe you need to approve or check something on your video before make it public') 'makeVideosUnlistedAfterEncode' => __('Maybe you need to approve or check something on your video before make it public'),
); ];
createTable("CustomizeAdvanced", $filter); createTable("CustomizeAdvanced", $filter);

View file

@ -1,10 +1,10 @@
<?php <?php
$filter = array( $filter = [
'encoderNetwork'=>'The <a target="_blank" href="https://github.com/WWBN/AVideo-Encoder-Network">Encoder Network</a> URL ', 'encoderNetwork' => 'The <a target="_blank" href="https://github.com/WWBN/AVideo-Encoder-Network">Encoder Network</a> URL ',
'useEncoderNetworkRecomendation'=>__('Let the encoder network (if configured) choose what is the best encoder to use'), 'useEncoderNetworkRecomendation' => __('Let the encoder network (if configured) choose what is the best encoder to use'),
'doNotShowUploadMP4Button'=>__('Users will not be able to directly upload, only use the encoder'), 'doNotShowUploadMP4Button' => __('Users will not be able to directly upload, only use the encoder'),
'doNotShowImportMP4Button'=>__('Disable the option to import MP4 videos from your local (Server) storage'), 'doNotShowImportMP4Button' => __('Disable the option to import MP4 videos from your local (Server) storage'),
'doNotShowEncoderButton'=>__('Do not show the button to the encoder'), 'doNotShowEncoderButton' => __('Do not show the button to the encoder'),
'doNotShowEmbedButton'=>__('Check this if you will not use embed videos on your site') 'doNotShowEmbedButton' => __('Check this if you will not use embed videos on your site'),
); ];
createTable("CustomizeAdvanced", $filter); createTable("CustomizeAdvanced", $filter);

View file

@ -1,5 +1,5 @@
<?php <?php
$filter = array( $filter = [
'disableNativeSignUp'=>__('This is useful if you want to use our LDAP plugin or maybe only allow authentication from Social Networks'), 'disableNativeSignUp'=>__('This is useful if you want to use our LDAP plugin or maybe only allow authentication from Social Networks'),
'disableNativeSignIn'=>__('This is useful if you want to use our LDAP plugin or maybe only allow authentication from Social Networks'), 'disableNativeSignIn'=>__('This is useful if you want to use our LDAP plugin or maybe only allow authentication from Social Networks'),
'disablePersonalInfo'=>__('Disable the My Account personal info like: First and Last Name and address'), 'disablePersonalInfo'=>__('Disable the My Account personal info like: First and Last Name and address'),
@ -10,6 +10,6 @@ $filter = array(
'unverifiedEmailsCanNOTLogin'=>__('Users must verify their emails before login'), 'unverifiedEmailsCanNOTLogin'=>__('Users must verify their emails before login'),
'onlyVerifiedEmailCanUpload'=>__('Users must verify their emails before upload/submit videos'), 'onlyVerifiedEmailCanUpload'=>__('Users must verify their emails before upload/submit videos'),
'sendVerificationMailAutomatic'=>__('After sign up we will automatic send a verification email'), 'sendVerificationMailAutomatic'=>__('After sign up we will automatic send a verification email'),
'userMustBeLoggedIn'=>__('Hide the website to non logged users') 'userMustBeLoggedIn'=>__('Hide the website to non logged users'),
); ];
createTable("CustomizeUser", $filter); createTable("CustomizeUser", $filter);

View file

@ -1,37 +1,37 @@
<?php <?php
function _isAPPInstalled($appName)
function _isAPPInstalled($appName) { {
$appName = preg_replace('/[^a-z0-9_-]/i', '', $appName); $appName = preg_replace('/[^a-z0-9_-]/i', '', $appName);
return trim(shell_exec("which {$appName}")); return trim(shell_exec("which {$appName}"));
} }
$phpExtensions = array(); $phpExtensions = [];
$phpExtensions[] = array('pdo_mysql'); $phpExtensions[] = ['pdo_mysql'];
$phpExtensions[] = array('curl'); $phpExtensions[] = ['curl'];
$phpExtensions[] = array('gd', 'Important to generate images'); $phpExtensions[] = ['gd', 'Important to generate images'];
$phpExtensions[] = array('xml', 'Important to get the live stats'); $phpExtensions[] = ['xml', 'Important to get the live stats'];
$phpExtensions[] = array('zip', 'Important handle HLS files'); $phpExtensions[] = ['zip', 'Important handle HLS files'];
// $phpExtensions[] = array('mbstring'); // I could not detect that // $phpExtensions[] = array('mbstring'); // I could not detect that
$apacheModules = array(); $apacheModules = [];
$apacheModules[] = array('mod_php'); $apacheModules[] = ['mod_php'];
$apacheModules[] = array('mod_xsendfile', 'https://github.com/WWBN/AVideo/wiki/Install-Apache-XSendFIle'); $apacheModules[] = ['mod_xsendfile', 'https://github.com/WWBN/AVideo/wiki/Install-Apache-XSendFIle'];
$apacheModules[] = array('mod_rewrite'); $apacheModules[] = ['mod_rewrite'];
$apacheModules[] = array('mod_expires', 'Important for CDN and cache configuration'); $apacheModules[] = ['mod_expires', 'Important for CDN and cache configuration'];
$apacheModules[] = array('mod_headers', 'Important for CDN and cache configuration'); $apacheModules[] = ['mod_headers', 'Important for CDN and cache configuration'];
$linuxApps = array(); $linuxApps = [];
$linuxApps[] = array('mysql'); $linuxApps[] = ['mysql'];
$linuxApps[] = array('ffmpeg'); $linuxApps[] = ['ffmpeg'];
$linuxApps[] = array('git'); $linuxApps[] = ['git'];
$linuxApps[] = array('exiftool'); $linuxApps[] = ['exiftool'];
$linuxApps[] = array('unzip'); $linuxApps[] = ['unzip'];
$linuxApps[] = array('youtube-dl'); $linuxApps[] = ['youtube-dl'];
$linuxApps[] = array('sshpass', 'https://github.com/WWBN/AVideo/wiki/Clone-Site-Plugin#the-process-with-rsync-support-hls'); $linuxApps[] = ['sshpass', 'https://github.com/WWBN/AVideo/wiki/Clone-Site-Plugin#the-process-with-rsync-support-hls'];
$linuxApps[] = array('apache2'); $linuxApps[] = ['apache2'];
$messages = array('Server' => array(), 'PHP' => array(), 'Apache' => array()); $messages = ['Server' => [], 'PHP' => [], 'Apache' => []];
$version = phpversion(); $version = phpversion();
$phpMinVersion = '7.3.0'; $phpMinVersion = '7.3.0';
if (strnatcmp($version, $phpMinVersion) >= 0) { if (strnatcmp($version, $phpMinVersion) >= 0) {
@ -46,7 +46,7 @@ foreach ($phpExtensions as $value) {
if (in_array($value[0], $extensions)) { if (in_array($value[0], $extensions)) {
$messages['PHP'][] = $value[0]; $messages['PHP'][] = $value[0];
} else { } else {
$messages['PHP'][] = array($value[0], 'sudo apt-get install php-' . str_replace('_', '-', $value[0]) . ' -y && sudo /etc/init.d/apache2 restart'); $messages['PHP'][] = [$value[0], 'sudo apt-get install php-' . str_replace('_', '-', $value[0]) . ' -y && sudo /etc/init.d/apache2 restart'];
} }
} }
@ -54,10 +54,10 @@ foreach ($phpExtensions as $value) {
if (isset($_SERVER["HTTPS"])) { if (isset($_SERVER["HTTPS"])) {
$messages['Apache'][] = "HTTPS is enabled"; $messages['Apache'][] = "HTTPS is enabled";
} else { } else {
$messages['Apache'][] = array("HTTPS is not enabled", 'https://github.com/WWBN/AVideo/wiki/Why-use-HTTPS'); $messages['Apache'][] = ["HTTPS is not enabled", 'https://github.com/WWBN/AVideo/wiki/Why-use-HTTPS'];
} }
if(function_exists('apache_get_modules')){ if (function_exists('apache_get_modules')) {
$mods = array_map('strtolower', apache_get_modules()); $mods = array_map('strtolower', apache_get_modules());
//var_dump($mods); //var_dump($mods);
foreach ($apacheModules as $value) { foreach ($apacheModules as $value) {
@ -74,13 +74,13 @@ if(function_exists('apache_get_modules')){
if ($found) { if ($found) {
$messages['Apache'][] = $found; $messages['Apache'][] = $found;
} else { } else {
$messages['Apache'][] = array($value[0], @$value[1]); $messages['Apache'][] = [$value[0], @$value[1]];
} }
} }
} }
}else{ } else {
foreach ($apacheModules as $value) { foreach ($apacheModules as $value) {
$messages['Apache'][] = array($value[0], 'We could not check your installed modules. We recommend you to use apache as a module NOT as a FPM'); $messages['Apache'][] = [$value[0], 'We could not check your installed modules. We recommend you to use apache as a module NOT as a FPM'];
} }
} }
@ -89,27 +89,27 @@ foreach ($linuxApps as $value) {
if (!empty($response)) { if (!empty($response)) {
$messages['Server'][] = "{$value[0]} is installed here {$response}"; $messages['Server'][] = "{$value[0]} is installed here {$response}";
} else { } else {
$messages['Server'][] = array("{$value[0]} is NOT installed", @$value[1]); $messages['Server'][] = ["{$value[0]} is NOT installed", @$value[1]];
} }
} }
$videosDir = getVideosDir(); $videosDir = getVideosDir();
if (is_writable($videosDir)) { if (is_writable($videosDir)) {
$messages['Server'][] = "{$videosDir} is writable"; $messages['Server'][] = "{$videosDir} is writable";
} else { } else {
$messages['Server'][] = array("{$videosDir} is NOT writable", 'sudo chmod -R 777 ' . $videosDir); $messages['Server'][] = ["{$videosDir} is NOT writable", 'sudo chmod -R 777 ' . $videosDir];
} }
if (is_writable($global['logfile'])) { if (is_writable($global['logfile'])) {
$messages['Server'][] = "Log file is writable"; $messages['Server'][] = "Log file is writable";
} else { } else {
$messages['Server'][] = array("{$global['logfile']} is NOT writable", 'sudo chmod -R 777 ' . $global['logfile']); $messages['Server'][] = ["{$global['logfile']} is NOT writable", 'sudo chmod -R 777 ' . $global['logfile']];
} }
$cacheDir = "{$videosDir}cache/"; $cacheDir = "{$videosDir}cache/";
if (is_writable($cacheDir)) { if (is_writable($cacheDir)) {
$messages['Server'][] = "Cache is writable"; $messages['Server'][] = "Cache is writable";
} else { } else {
$messages['Server'][] = array("{$cacheDir} is NOT writable", 'sudo chmod -R 777 ' . $cacheDir); $messages['Server'][] = ["{$cacheDir} is NOT writable", 'sudo chmod -R 777 ' . $cacheDir];
} }
$_50GB = 53687091200; $_50GB = 53687091200;
@ -118,14 +118,14 @@ $df = disk_free_space("/");
if ($df > $_50GB) { if ($df > $_50GB) {
$messages['Server'][] = "You have enough free disk space " . humanFileSize($df); $messages['Server'][] = "You have enough free disk space " . humanFileSize($df);
} else { } else {
$messages['Server'][] = array("Your disk is almost full, you have only " . humanFileSize($df) . ' free'); $messages['Server'][] = ["Your disk is almost full, you have only " . humanFileSize($df) . ' free'];
} }
$dfVideos = disk_free_space($videosDir); $dfVideos = disk_free_space($videosDir);
if ($dfVideos > $_50GB) { if ($dfVideos > $_50GB) {
$messages['Server'][] = "You have enough free disk space for the videos directory " . humanFileSize($dfVideos); $messages['Server'][] = "You have enough free disk space for the videos directory " . humanFileSize($dfVideos);
} else { } else {
$messages['Server'][] = array("Your videos directory is almost full, you have only " . humanFileSize($dfVideos) . ' free'); $messages['Server'][] = ["Your videos directory is almost full, you have only " . humanFileSize($dfVideos) . ' free'];
} }
@ -135,13 +135,13 @@ $verifyURL = addQueryStringParameter($verifyURL, 'screenshot', 1);
$result = url_get_contents($verifyURL, '', 5); $result = url_get_contents($verifyURL, '', 5);
if (empty($result)) { if (empty($result)) {
$messages['Server'][] = array("We could not verify your server from outside {$global['webSiteRootURL']}"); $messages['Server'][] = ["We could not verify your server from outside {$global['webSiteRootURL']}"];
} else { } else {
$verified = json_decode($result); $verified = json_decode($result);
if (!empty($verified->verified)) { if (!empty($verified->verified)) {
$messages['Server'][] = "Server Checked from outside: <br>" . implode('<br>', $verified->msg); $messages['Server'][] = "Server Checked from outside: <br>" . implode('<br>', $verified->msg);
} else { } else {
$messages['Server'][] = array("Something is wrong: ", implode('<br>', $verified->msg)); $messages['Server'][] = ["Something is wrong: ", implode('<br>', $verified->msg)];
} }
/* /*
if(!empty($verified->screenshot)){ if(!empty($verified->screenshot)){
@ -181,18 +181,17 @@ if (empty($result)) {
<div class="alert alert-danger"> <div class="alert alert-danger">
<i class="fas fa-times"></i> <?php <i class="fas fa-times"></i> <?php
echo $value[0]; echo $value[0];
if (!empty($value[1])) { if (!empty($value[1])) {
if (preg_match('/^http/i', $value[1])) { if (preg_match('/^http/i', $value[1])) {
?> ?>
<a href="<?php echo $value[1]; ?>" class="btn btn-danger btn-xs btn-block" target="_blank"><i class="fas fa-hand-holding-medical"></i> </a> <a href="<?php echo $value[1]; ?>" class="btn btn-danger btn-xs btn-block" target="_blank"><i class="fas fa-hand-holding-medical"></i> </a>
<?php <?php
} else { } else {
?> ?>
<br><code><?php echo $value[1]; ?></code> <br><code><?php echo $value[1]; ?></code>
<?php <?php
} }
} } ?>
?>
</div> </div>
</div> </div>
<?php <?php
@ -201,8 +200,7 @@ if (empty($result)) {
<div class="col-lg-4 col-md-6 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>"> <div class="col-lg-4 col-md-6 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>">
<div class="alert alert-success"> <div class="alert alert-success">
<i class="fas fa-check"></i> <?php <i class="fas fa-check"></i> <?php
echo $value; echo $value; ?>
?>
</div> </div>
</div> </div>
<?php <?php
@ -235,18 +233,17 @@ if (empty($result)) {
<div class="alert alert-danger"> <div class="alert alert-danger">
<i class="fas fa-times"></i> <?php <i class="fas fa-times"></i> <?php
echo $value[0]; echo $value[0];
if (!empty($value[1])) { if (!empty($value[1])) {
if (preg_match('/^http/i', $value[1])) { if (preg_match('/^http/i', $value[1])) {
?> ?>
<a href="<?php echo $value[1]; ?>" class="btn btn-danger btn-xs btn-block" target="_blank"><i class="fas fa-hand-holding-medical"></i> </a> <a href="<?php echo $value[1]; ?>" class="btn btn-danger btn-xs btn-block" target="_blank"><i class="fas fa-hand-holding-medical"></i> </a>
<?php <?php
} else { } else {
?> ?>
<br><code><?php echo $value[1]; ?></code> <br><code><?php echo $value[1]; ?></code>
<?php <?php
} }
} } ?>
?>
</div> </div>
</div> </div>
<?php <?php
@ -255,8 +252,7 @@ if (empty($result)) {
<div class="col-sm-12 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>"> <div class="col-sm-12 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>">
<div class="alert alert-success"> <div class="alert alert-success">
<i class="fas fa-check"></i> <?php <i class="fas fa-check"></i> <?php
echo $value; echo $value; ?>
?>
</div> </div>
</div> </div>
<?php <?php
@ -283,18 +279,17 @@ if (empty($result)) {
<div class="alert alert-danger"> <div class="alert alert-danger">
<i class="fas fa-times"></i> <?php <i class="fas fa-times"></i> <?php
echo $value[0]; echo $value[0];
if (!empty($value[1])) { if (!empty($value[1])) {
if (preg_match('/^http/i', $value[1])) { if (preg_match('/^http/i', $value[1])) {
?> ?>
<a href="<?php echo $value[1]; ?>" class="btn btn-danger btn-xs btn-block" target="_blank"><i class="fas fa-hand-holding-medical"></i> </a> <a href="<?php echo $value[1]; ?>" class="btn btn-danger btn-xs btn-block" target="_blank"><i class="fas fa-hand-holding-medical"></i> </a>
<?php <?php
} else { } else {
?> ?>
<br><code><?php echo $value[1]; ?></code> <br><code><?php echo $value[1]; ?></code>
<?php <?php
} }
} } ?>
?>
</div> </div>
</div> </div>
<?php <?php
@ -303,8 +298,7 @@ if (empty($result)) {
<div class="col-sm-12 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>"> <div class="col-sm-12 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>">
<div class="alert alert-success"> <div class="alert alert-success">
<i class="fas fa-check"></i> <?php <i class="fas fa-check"></i> <?php
echo $value; echo $value; ?>
?>
</div> </div>
</div> </div>
<?php <?php

View file

@ -1,5 +1,5 @@
<?php <?php
$vars = array(); $vars = [];
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
require_once './functions.php'; require_once './functions.php';
@ -9,11 +9,19 @@ if (!User::isAdmin()) {
} }
$isAdminPanel = 1; $isAdminPanel = 1;
class MenuAdmin { class MenuAdmin
{
public $title;
public $icon;
public $href;
public $active = false;
public $show = false;
public $itens = [];
public $data_toggle;
public $data_target;
public $title, $icon, $href, $active = false, $show = false, $itens = array(), $data_toggle, $data_target; public function __construct($title, $icon, $href = "", $data_toggle = "", $data_target = "")
{
function __construct($title, $icon, $href = "", $data_toggle = "", $data_target = "") {
$this->title = $title; $this->title = $title;
$this->icon = $icon; $this->icon = $icon;
$this->href = $href; $this->href = $href;
@ -27,16 +35,16 @@ class MenuAdmin {
} }
} }
function addItem(MenuAdmin $menu) { public function addItem(MenuAdmin $menu)
{
$this->itens[] = $menu; $this->itens[] = $menu;
if ($menu->active) { if ($menu->active) {
$this->show = true; $this->show = true;
} }
} }
} }
$itens = array(); $itens = [];
$menu = new MenuAdmin(__("Dashboard"), "fa fa-tachometer-alt", "dashboard"); $menu = new MenuAdmin(__("Dashboard"), "fa fa-tachometer-alt", "dashboard");
$itens[] = $menu; $itens[] = $menu;
@ -94,8 +102,8 @@ $itens[] = $menu;
$_GET['page'] = xss_esc(@$_GET['page']); $_GET['page'] = xss_esc(@$_GET['page']);
$includeHead = ""; $includeHead = '';
$includeBody = ""; $includeBody = '';
switch ($_GET['page']) { switch ($_GET['page']) {
case "backup": case "backup":
$includeBody = $global['systemRootPath'] . 'admin/backup.php'; $includeBody = $global['systemRootPath'] . 'admin/backup.php';
@ -136,7 +144,7 @@ switch ($_GET['page']) {
break; break;
case "monetize_subscription": case "monetize_subscription":
$includeHead = $global['systemRootPath'] . 'plugin/Subscription/page/editor_head.php'; $includeHead = $global['systemRootPath'] . 'plugin/Subscription/page/editor_head.php';
$includeBody = array(); $includeBody = [];
$includeBody[] = $global['systemRootPath'] . 'plugin/Subscription/page/editor_body.php'; $includeBody[] = $global['systemRootPath'] . 'plugin/Subscription/page/editor_body.php';
$includeBody[] = $global['systemRootPath'] . 'admin/monetize_subscription.php'; $includeBody[] = $global['systemRootPath'] . 'admin/monetize_subscription.php';
break; break;
@ -176,7 +184,7 @@ switch ($_GET['page']) {
case "health_check": case "health_check":
$includeBody = $global['systemRootPath'] . 'admin/health_check.php'; $includeBody = $global['systemRootPath'] . 'admin/health_check.php';
break; break;
default : default:
$includeHead = $global['systemRootPath'] . 'view/charts_head.php'; $includeHead = $global['systemRootPath'] . 'view/charts_head.php';
$includeBody = $global['systemRootPath'] . 'view/charts_body.php'; $includeBody = $global['systemRootPath'] . 'view/charts_body.php';
break; break;
@ -236,7 +244,7 @@ switch ($_GET['page']) {
<div class="panel-group" id="accordion"> <div class="panel-group" id="accordion">
<?php <?php
$panel = 'panel-default'; $panel = 'panel-default';
if(empty($_REQUEST['page'])){ if (empty($_REQUEST['page'])) {
$panel = 'panel-primary'; $panel = 'panel-primary';
} }
foreach ($itens as $key => $value) { foreach ($itens as $key => $value) {
@ -253,8 +261,7 @@ switch ($_GET['page']) {
$panel = 'panel-primary'; $panel = 'panel-primary';
} }
} }
} } ?>
?>
<div class="panel <?php echo $panel; ?> adminLeftMenu <?php echo getCSSAnimationClassAndStyle('animate__bounceInLeft', 'menu'); ?>"> <div class="panel <?php echo $panel; ?> adminLeftMenu <?php echo getCSSAnimationClassAndStyle('animate__bounceInLeft', 'menu'); ?>">
<div class="panel-heading"> <div class="panel-heading">
<h4 class="panel-title"> <h4 class="panel-title">
@ -265,7 +272,7 @@ switch ($_GET['page']) {
</div> </div>
<?php <?php
if (!empty($value->itens)) { if (!empty($value->itens)) {
$in = ""; $in = '';
if (!empty($_GET['page'])) { if (!empty($_GET['page'])) {
foreach ($value->itens as $search) { foreach ($value->itens as $search) {
if ($_GET['page'] === $search->href) { if ($_GET['page'] === $search->href) {
@ -273,36 +280,32 @@ switch ($_GET['page']) {
break; break;
} }
} }
} } ?>
?>
<div id="collapse<?php echo $uid; ?>" class="panel-collapse collapse <?php echo $in; ?>"> <div id="collapse<?php echo $uid; ?>" class="panel-collapse collapse <?php echo $in; ?>">
<div class="panel-body"> <div class="panel-body">
<table class="table"> <table class="table">
<?php <?php
$active = ""; $active = '';
if (empty($_GET['page'])) { if (empty($_GET['page'])) {
$active = "active"; $active = "active";
} }
foreach ($value->itens as $key2 => $value2) { foreach ($value->itens as $key2 => $value2) {
if (!empty($_GET['page']) && $_GET['page'] === $value2->href) { if (!empty($_GET['page']) && $_GET['page'] === $value2->href) {
$active = "active"; $active = "active";
} } ?>
?>
<tr> <tr>
<td class="<?php echo $active; ?>"> <td class="<?php echo $active; ?>">
<a href="<?php echo "{$global['webSiteRootURL']}admin/?page=" . $value2->href; ?>"><i class="<?php echo $value2->icon; ?>"></i> <?php echo $value2->title; ?></a> <a href="<?php echo "{$global['webSiteRootURL']}admin/?page=" . $value2->href; ?>"><i class="<?php echo $value2->icon; ?>"></i> <?php echo $value2->title; ?></a>
</td> </td>
</tr> </tr>
<?php <?php
$active = ""; $active = '';
} } ?>
?>
</table> </table>
</div> </div>
</div> </div>
<?php <?php
} } ?>
?>
</div> </div>
<?php <?php
$panel = 'panel-default'; $panel = 'panel-default';

View file

@ -4,7 +4,6 @@
<div class="panel-heading"><?php echo __('Live') ?> <div class="pull-right"><?php echo getPluginSwitch('Live'); ?></div></div> <div class="panel-heading"><?php echo __('Live') ?> <div class="pull-right"><?php echo getPluginSwitch('Live'); ?></div></div>
<div class="panel-body"> <div class="panel-body">
<?php <?php
createTable("Live"); createTable("Live");
?> ?>
@ -16,7 +15,6 @@
<div class="panel-heading"><?php echo __('Chat') ?> <div class="pull-right"><?php echo getPluginSwitch('Chat2'); ?></div></div> <div class="panel-heading"><?php echo __('Chat') ?> <div class="pull-right"><?php echo getPluginSwitch('Chat2'); ?></div></div>
<div class="panel-body"> <div class="panel-body">
<?php <?php
createTable("Chat2"); createTable("Chat2");
?> ?>
@ -28,11 +26,10 @@
<div class="panel-heading"><?php echo __('Live Users') ?> <div class="pull-right"><?php echo getPluginSwitch('LiveUsers'); ?></div></div> <div class="panel-heading"><?php echo __('Live Users') ?> <div class="pull-right"><?php echo getPluginSwitch('LiveUsers'); ?></div></div>
<div class="panel-body"> <div class="panel-body">
<?php <?php
$filter = [
'doNotDisplayCounter' => 'It will collect usage info but will not display the counter on the live video', ];
$filter = array( createTable("LiveUsers", $filter);
'doNotDisplayCounter' => 'It will collect usage info but will not display the counter on the live video');
createTable("LiveUsers",$filter);
?> ?>
</div> </div>
@ -43,7 +40,6 @@
<div class="panel-heading"><?php echo __('Live Links') ?> <div class="pull-right"><?php echo getPluginSwitch('LiveLinks'); ?></div></div> <div class="panel-heading"><?php echo __('Live Links') ?> <div class="pull-right"><?php echo getPluginSwitch('LiveLinks'); ?></div></div>
<div class="panel-body"> <div class="panel-body">
<?php <?php
createTable("LiveLinks"); createTable("LiveLinks");
?> ?>

View file

@ -4,10 +4,10 @@
<div class="panel-heading"><i class="fa fa-cog"></i> Subscription Configuration </div> <div class="panel-heading"><i class="fa fa-cog"></i> Subscription Configuration </div>
<div class="panel-body" style="overflow: hidden;"> <div class="panel-body" style="overflow: hidden;">
<?php <?php
$filter = array( $filter = [
'displayTopBarSubscribeButton' => 'Show a button on the top to subscribe', 'displayTopBarSubscribeButton' => 'Show a button on the top to subscribe',
'displayLeftMenuSubscribeButton' => 'Show a button on the the left menu to subscribe', 'displayLeftMenuSubscribeButton' => 'Show a button on the the left menu to subscribe',
'textSubscribe' => 'The button text label'); 'textSubscribe' => 'The button text label', ];
createTable("Subscription", $filter); createTable("Subscription", $filter);
?> ?>
</div> </div>

View file

@ -4,11 +4,11 @@
<div class="panel-heading"><?php echo __('Monetize User') ?> <div class="pull-right"><?php echo getPluginSwitch('MonetizeUsers'); ?></div></div> <div class="panel-heading"><?php echo __('Monetize User') ?> <div class="pull-right"><?php echo getPluginSwitch('MonetizeUsers'); ?></div></div>
<div class="panel-body"> <div class="panel-body">
<?php <?php
$filter = array( $filter = [
'rewardPerView' => 'How much will your users receive per each video view', 'rewardPerView' => 'How much will your users receive per each video view',
'rewardOnlyLoggedUsersView' => 'Check this to allow only count rewards from logged users'); 'rewardOnlyLoggedUsersView' => 'Check this to allow only count rewards from logged users', ];
createTable("MonetizeUsers",$filter); createTable("MonetizeUsers", $filter);
?> ?>
</div> </div>
@ -19,13 +19,13 @@
<div class="panel-heading"><?php echo __('Wallet') ?> <div class="pull-right"><?php echo getPluginSwitch('YPTWallet'); ?></div></div> <div class="panel-heading"><?php echo __('Wallet') ?> <div class="pull-right"><?php echo getPluginSwitch('YPTWallet'); ?></div></div>
<div class="panel-body"> <div class="panel-body">
<?php <?php
$filter = array( $filter = [
'decimalPrecision' => 'Usually for USD we use 2, for cryptocurrencies we use more the 2', 'decimalPrecision' => 'Usually for USD we use 2, for cryptocurrencies we use more the 2',
'currency' => 'Australian Dollar = AUD, Brazilian Real = BRL, Canadian Dollar = CAD, Euro = EUR, U.S. Dollar = USD, etc', 'currency' => 'Australian Dollar = AUD, Brazilian Real = BRL, Canadian Dollar = CAD, Euro = EUR, U.S. Dollar = USD, etc',
'currency_symbol' => '$, R$, etc, the format will be {currency} {value} {currency_symbol} for example ($ 10.00 USD) or (R$ 10.00 BRL)', 'currency_symbol' => '$, R$, etc, the format will be {currency} {value} {currency_symbol} for example ($ 10.00 USD) or (R$ 10.00 BRL)',
'manualAddFundsTransferFromUserId' => 'When some one buy something on your web site, the wallet balance will be transferred to this user ID', 'manualAddFundsTransferFromUserId' => 'When some one buy something on your web site, the wallet balance will be transferred to this user ID',
'enablePlugin_YPTWalletPayPal' => 'You need to enable it to be able to use PayPal to add funds on your wallet', 'enablePlugin_YPTWalletPayPal' => 'You need to enable it to be able to use PayPal to add funds on your wallet',
'enableManualWithdrawFundsPage' => 'Let users request withdraws from his wallet. the withdraw mus be done manually'); 'enableManualWithdrawFundsPage' => 'Let users request withdraws from his wallet. the withdraw mus be done manually', ];
createTable("YPTWallet", $filter); createTable("YPTWallet", $filter);
?> ?>
</div> </div>

View file

@ -4,13 +4,13 @@
<div class="panel-heading"><i class="fas fa-wallet"></i> <?php echo __('Wallet'); ?> <div class="pull-right"><?php echo getPluginSwitch('YPTWallet'); ?></div></div> <div class="panel-heading"><i class="fas fa-wallet"></i> <?php echo __('Wallet'); ?> <div class="pull-right"><?php echo getPluginSwitch('YPTWallet'); ?></div></div>
<div class="panel-body" style="overflow: hidden;"> <div class="panel-body" style="overflow: hidden;">
<?php <?php
$filter = array( $filter = [
'decimalPrecision' => __('Usually for USD we use 2, for cryptocurrencies we use more the 2'), 'decimalPrecision' => __('Usually for USD we use 2, for cryptocurrencies we use more the 2'),
'currency' => __('Australian Dollar = AUD, Brazilian Real = BRL, Canadian Dollar = CAD, Euro = EUR, U.S. Dollar = USD, etc'), 'currency' => __('Australian Dollar = AUD, Brazilian Real = BRL, Canadian Dollar = CAD, Euro = EUR, U.S. Dollar = USD, etc'),
'currency_symbol' => __('$, R$, etc, the format will be {currency} {value} {currency_symbol} for example ($ 10.00 USD) or (R$ 10.00 BRL)'), 'currency_symbol' => __('$, R$, etc, the format will be {currency} {value} {currency_symbol} for example ($ 10.00 USD) or (R$ 10.00 BRL)'),
'manualAddFundsTransferFromUserId' => __('When some one buy something on your web site, the wallet balance will be transferred to this user ID'), 'manualAddFundsTransferFromUserId' => __('When some one buy something on your web site, the wallet balance will be transferred to this user ID'),
'enablePlugin_YPTWalletPayPal' => __('You need to enable it to be able to use PayPal to add funds on your wallet'), 'enablePlugin_YPTWalletPayPal' => __('You need to enable it to be able to use PayPal to add funds on your wallet'),
'enableManualWithdrawFundsPage' => __('Let users request withdraws from his wallet. the withdraw mus be done manually')); 'enableManualWithdrawFundsPage' => __('Let users request withdraws from his wallet. the withdraw mus be done manually'), ];
createTable("YPTWallet", $filter); createTable("YPTWallet", $filter);
?> ?>
</div> </div>

View file

@ -22,4 +22,4 @@ $p->setObject_data(json_encode($pluginDO));
$obj = new stdClass(); $obj = new stdClass();
$obj->save = $p->save(); $obj->save = $p->save();
echo (json_encode($obj)); echo(json_encode($obj));

View file

@ -18,9 +18,9 @@ if (empty($_POST['pluginsList'])) {
} else { } else {
$pluginsList = explode("|", $_POST['pluginsList']); $pluginsList = explode("|", $_POST['pluginsList']);
$pluginValues = array(); $pluginValues = [];
foreach ($pluginsList as $value) { foreach ($pluginsList as $value) {
$pluginValues[$value] = empty($_POST[$value]) ? false : ($_POST[$value]==1||$_POST[$value]=="true"?true:$_POST[$value]); $pluginValues[$value] = empty($_POST[$value]) ? false : ($_POST[$value]==1||$_POST[$value]=="true" ? true : $_POST[$value]);
} }
} }
@ -30,7 +30,7 @@ $pluginDB = Plugin::getPluginByName($pluginName);
foreach ($pluginDO as $key => $value) { foreach ($pluginDO as $key => $value) {
if (isset($pluginValues[$key])) { if (isset($pluginValues[$key])) {
if (is_bool($pluginDO->$key)) { if (is_bool($pluginDO->$key)) {
$pluginDO->$key = empty($pluginValues[$key])?false:true; $pluginDO->$key = empty($pluginValues[$key]) ? false : true;
} else { } else {
//$pluginDO->$key = str_replace('"', '\\"', $pluginValues[$key]); //$pluginDO->$key = str_replace('"', '\\"', $pluginValues[$key]);
$pluginDO->$key = $pluginValues[$key]; $pluginDO->$key = $pluginValues[$key];
@ -43,6 +43,8 @@ $p->setObject_data(json_encode($pluginDO));
$obj = new stdClass(); $obj = new stdClass();
$obj->save = $p->save(); $obj->save = $p->save();
if ($obj->save === false) _error_log("[ERROR] Error saving plugin $pluginName data. Maybe plugin is not enabled?", AVideoLog::$ERROR); if ($obj->save === false) {
_error_log("[ERROR] Error saving plugin $pluginName data. Maybe plugin is not enabled?", AVideoLog::$ERROR);
}
echo (json_encode($obj)); echo(json_encode($obj));

View file

@ -4,10 +4,10 @@
<div class="panel-heading"><i class="fa fa-cog"></i> <?php echo __('Customize options'); ?> <div class="pull-right"><?php echo getPluginSwitch('CustomizeAdvanced'); ?></div></div> <div class="panel-heading"><i class="fa fa-cog"></i> <?php echo __('Customize options'); ?> <div class="pull-right"><?php echo getPluginSwitch('CustomizeAdvanced'); ?></div></div>
<div class="panel-body" style="overflow: hidden;"> <div class="panel-body" style="overflow: hidden;">
<?php <?php
$filter = array( $filter = [
'disableNativeSignUp' => __('The form to signup will not exists'), 'disableNativeSignUp' => __('The form to signup will not exists'),
'disableNativeSignIn' => __('The regular form to signin will not exist, if you check this will only have social login or LDAP option'), 'disableNativeSignIn' => __('The regular form to signin will not exist, if you check this will only have social login or LDAP option'),
'userMustBeLoggedIn' => __('The site will display only a login form to un authenticated users')); 'userMustBeLoggedIn' => __('The site will display only a login form to un authenticated users'), ];
createTable("CustomizeUser", $filter); createTable("CustomizeUser", $filter);
?> ?>
</div> </div>

View file

@ -13,7 +13,7 @@ $showOnlyLoggedUserVideos = false;
$title = $config->getWebSiteTitle(); $title = $config->getWebSiteTitle();
$link = $global['webSiteRootURL']; $link = $global['webSiteRootURL'];
$logo = getCDN()."videos/userPhoto/logo.png"; $logo = getCDN()."videos/userPhoto/logo.png";
$description = ""; $description = '';
$extraPluginFile = $global['systemRootPath'] . 'plugin/Customize/Objects/ExtraConfig.php'; $extraPluginFile = $global['systemRootPath'] . 'plugin/Customize/Objects/ExtraConfig.php';
if (file_exists($extraPluginFile) && AVideoPlugin::isEnabledByName("Customize")) { if (file_exists($extraPluginFile) && AVideoPlugin::isEnabledByName("Customize")) {
@ -22,7 +22,7 @@ if (file_exists($extraPluginFile) && AVideoPlugin::isEnabledByName("Customize"))
$description = $ec->getDescription(); $description = $ec->getDescription();
} }
if(!empty($_GET['channelName'])){ if (!empty($_GET['channelName'])) {
$user = User::getChannelOwner($_GET['channelName']); $user = User::getChannelOwner($_GET['channelName']);
$showOnlyLoggedUserVideos = $user['id']; $showOnlyLoggedUserVideos = $user['id'];
$title = User::getNameIdentificationById($user['id']); $title = User::getNameIdentificationById($user['id']);
@ -32,23 +32,22 @@ if(!empty($_GET['channelName'])){
$cacheName = "feedCache".json_encode($_GET); $cacheName = "feedCache".json_encode($_GET);
$rows = ObjectYPT::getCache($cacheName, 0); $rows = ObjectYPT::getCache($cacheName, 0);
if(empty($rows)){ if (empty($rows)) {
// send $_GET['catName'] to be able to filter by category // send $_GET['catName'] to be able to filter by category
$rows = Video::getAllVideos("viewable", $showOnlyLoggedUserVideos); $rows = Video::getAllVideos("viewable", $showOnlyLoggedUserVideos);
ObjectYPT::setCache($cacheName, $rows); ObjectYPT::setCache($cacheName, $rows);
}else{ } else {
$rows = object_to_array($rows); $rows = object_to_array($rows);
} }
if(!empty($_REQUEST['roku'])){ if (!empty($_REQUEST['roku'])) {
include $global['systemRootPath'] . 'feed/roku.json.php'; include $global['systemRootPath'] . 'feed/roku.json.php';
}else if(empty($_REQUEST['mrss'])){ } elseif (empty($_REQUEST['mrss'])) {
include $global['systemRootPath'] . 'feed/rss.php'; include $global['systemRootPath'] . 'feed/rss.php';
}else{ } else {
include $global['systemRootPath'] . 'feed/mrss.php'; include $global['systemRootPath'] . 'feed/mrss.php';
} }
function feedText($text){ function feedText($text)
return str_replace(array('&&'), array('&'), str_replace(array('&','<','>'), array('&amp;','&lt;','&gt;'), (strip_tags(br2nl($text))))); {
return str_replace(['&&'], ['&'], str_replace(['&','<','>'], ['&amp;','&lt;','&gt;'], (strip_tags(br2nl($text)))));
} }
?>

View file

@ -7,8 +7,7 @@ $lifetime = 43200;
$feed = ObjectYPT::getCache($cacheFeedName, $lifetime); $feed = ObjectYPT::getCache($cacheFeedName, $lifetime);
if (empty($feed)) { if (empty($feed)) {
ob_start(); ob_start();
echo'<?xml version="1.0" encoding="UTF-8"?>'; echo'<?xml version="1.0" encoding="UTF-8"?>'; ?>
?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" <rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/"
xmlns:georss="http://www.georss.org/georss" xmlns:georss="http://www.georss.org/georss"
xmlns:gml="http://www.opengis.net/gml"> xmlns:gml="http://www.opengis.net/gml">
@ -29,7 +28,7 @@ if (empty($feed)) {
foreach ($rows as $row) { foreach ($rows as $row) {
$video = Video::getVideoFromFileName($row['filename']); $video = Video::getVideoFromFileName($row['filename']);
$files = getVideosURL($row['filename']); $files = getVideosURL($row['filename']);
$enclosure = ""; $enclosure = '';
$videoSource = Video::getSourceFileURL($row['filename']); $videoSource = Video::getSourceFileURL($row['filename']);
if (empty($videoSource)) { if (empty($videoSource)) {
continue; continue;
@ -44,8 +43,7 @@ if (empty($feed)) {
$enclosure = '<enclosure url="' . $value['url'] . '" length="' . $value['size'] . '" type="' . $value['mime'] . '" />'; $enclosure = '<enclosure url="' . $value['url'] . '" length="' . $value['size'] . '" type="' . $value['mime'] . '" />';
break; break;
} }
} } ?>
?>
<item> <item>
<title><?php echo feedText($row['title']); ?></title> <title><?php echo feedText($row['title']); ?></title>
<description><?php echo feedText($row['title']); ?></description> <description><?php echo feedText($row['title']); ?></description>
@ -65,8 +63,7 @@ if (empty($feed)) {
<media:status state="active" /> <media:status state="active" />
</item> </item>
<?php <?php
} } ?>
?>
</channel> </channel>
</rss> </rss>
<?php <?php
@ -74,12 +71,11 @@ if (empty($feed)) {
ob_end_clean(); ob_end_clean();
//var_dump($cacheFeedName, $feed);exit; //var_dump($cacheFeedName, $feed);exit;
ObjectYPT::setCache($cacheFeedName, $feed); ObjectYPT::setCache($cacheFeedName, $feed);
//echo '<!-- NO cache -->'; //echo '<!-- NO cache -->';
}else{ } else {
//echo '<!-- cache -->'; //echo '<!-- cache -->';
} }
if(!is_string($feed)){ if (!is_string($feed)) {
$feed = json_encode($feed); $feed = json_encode($feed);
} }
echo $feed; echo $feed;
?>

View file

@ -1,6 +1,6 @@
<?php <?php
function rokuRating($avideoRating)
function rokuRating($avideoRating){ {
//('', 'g', 'pg', 'pg-13', 'r', 'nc-17', 'ma'); //('', 'g', 'pg', 'pg-13', 'r', 'nc-17', 'ma');
switch (strtolower($avideoRating)) { switch (strtolower($avideoRating)) {
case 'g': case 'g':
@ -36,7 +36,7 @@ if (empty($output)) {
$obj->providerName = $title; $obj->providerName = $title;
$obj->language = "en"; $obj->language = "en";
$obj->lastUpdated = date('c'); $obj->lastUpdated = date('c');
$obj->movies = array(); $obj->movies = [];
$cacheName = "feedCache_ROKU_movies".json_encode($_REQUEST); $cacheName = "feedCache_ROKU_movies".json_encode($_REQUEST);
@ -58,12 +58,12 @@ if (empty($output)) {
$movie->longDescription = "=> " . _substr(strip_tags(br2nl(UTF8encode($row['description']))), 0, 490); $movie->longDescription = "=> " . _substr(strip_tags(br2nl(UTF8encode($row['description']))), 0, 490);
$movie->shortDescription = _substr($movie->longDescription, 0, 200); $movie->shortDescription = _substr($movie->longDescription, 0, 200);
$movie->thumbnail = Video::getRokuImage($row['id']); $movie->thumbnail = Video::getRokuImage($row['id']);
$movie->tags = array(_substr(UTF8encode($row['category']), 0, 20)); $movie->tags = [_substr(UTF8encode($row['category']), 0, 20)];
$movie->genres = array("special"); $movie->genres = ["special"];
$movie->releaseDate = date('c', strtotime($row['created'])); $movie->releaseDate = date('c', strtotime($row['created']));
$movie->categories_id = $row['categories_id']; $movie->categories_id = $row['categories_id'];
$rrating = $row['rrating']; $rrating = $row['rrating'];
if(!empty($rrating)){ if (!empty($rrating)) {
$movie->rating = new stdClass(); $movie->rating = new stdClass();
$movie->rating->rating = rokuRating($rrating); $movie->rating->rating = rokuRating($rrating);
$movie->rating->ratingSource = 'MPAA'; $movie->rating->ratingSource = 'MPAA';
@ -72,21 +72,20 @@ if (empty($output)) {
$content = new stdClass(); $content = new stdClass();
$content->dateAdded = date('c', strtotime($row['created'])); $content->dateAdded = date('c', strtotime($row['created']));
$content->captions = array(); $content->captions = [];
$content->duration = durationToSeconds($row['duration']); $content->duration = durationToSeconds($row['duration']);
$content->language = "en"; $content->language = "en";
$content->adBreaks = array("00:00:00"); $content->adBreaks = ["00:00:00"];
$video = new stdClass(); $video = new stdClass();
$video->url = $videoSource; $video->url = $videoSource;
$video->quality = getResolutionTextRoku($videoResolution); $video->quality = getResolutionTextRoku($videoResolution);
$video->videoType = Video::getVideoTypeText($row['filename']); $video->videoType = Video::getVideoTypeText($row['filename']);
$content->videos = array($video); $content->videos = [$video];
$movie->content = $content; $movie->content = $content;
$obj->movies[] = $movie; $obj->movies[] = $movie;
} }
ObjectYPT::setCache($cacheName, $obj->movies); ObjectYPT::setCache($cacheName, $obj->movies);
} else { } else {
@ -94,26 +93,25 @@ if (empty($output)) {
} }
$itemIds = array(); $itemIds = [];
foreach ($obj->movies as $value) { foreach ($obj->movies as $value) {
$itemIds[] = $value->id; $itemIds[] = $value->id;
} }
$obj->playlists = array(array('name'=>'all', 'itemIds'=>$itemIds)); $obj->playlists = [['name' => 'all', 'itemIds'=>$itemIds]];
$obj->categories = array(array('name'=>'All', 'playlistName'=>'all', 'order'=>'most_recent')); $obj->categories = [['name' => 'All', 'playlistName' => 'all', 'order' => 'most_recent']];
$output = _json_encode($obj, JSON_UNESCAPED_UNICODE); $output = _json_encode($obj, JSON_UNESCAPED_UNICODE);
if (empty($output) && json_last_error()) { if (empty($output) && json_last_error()) {
$output = json_encode(json_last_error_msg()); $output = json_encode(json_last_error_msg());
var_dump($obj); var_dump($obj);
}else{ } else {
ObjectYPT::setCache($cacheFeedName, $output); ObjectYPT::setCache($cacheFeedName, $output);
} }
}else{ } else {
//echo '<!-- cache -->'; //echo '<!-- cache -->';
} }
if(!is_string($output)){ if (!is_string($output)) {
$output = json_encode($output); $output = json_encode($output);
} }
die($output); die($output);
?>

View file

@ -33,7 +33,7 @@ if (empty($feed)) {
<?php <?php
foreach ($rows as $row) { foreach ($rows as $row) {
$files = getVideosURL($row['filename']); $files = getVideosURL($row['filename']);
$enclosure = ""; $enclosure = '';
foreach ($files as $value) { foreach ($files as $value) {
if ($value["type"] === "video" && file_exists($value['path'])) { if ($value["type"] === "video" && file_exists($value['path'])) {
$path_parts = pathinfo($value['path']); $path_parts = pathinfo($value['path']);
@ -44,8 +44,7 @@ if (empty($feed)) {
$enclosure = '<enclosure url="' . $value['url'] . '" length="' . $value['size'] . '" type="' . $value['mime'] . '" />'; $enclosure = '<enclosure url="' . $value['url'] . '" length="' . $value['size'] . '" type="' . $value['mime'] . '" />';
break; break;
} }
} } ?>
?>
<item> <item>
<title><?php echo feedText($row['title']); ?></title> <title><?php echo feedText($row['title']); ?></title>
<description><?php echo feedText($row['description']); ?></description> <description><?php echo feedText($row['description']); ?></description>
@ -55,19 +54,17 @@ if (empty($feed)) {
<guid><?php echo Video::getLinkToVideo($row['id'], $row['clean_title'], false, "permalink"); ?></guid> <guid><?php echo Video::getLinkToVideo($row['id'], $row['clean_title'], false, "permalink"); ?></guid>
</item> </item>
<?php <?php
} } ?>
?>
</channel> </channel>
</rss> </rss>
<?php <?php
$feed = ob_get_contents(); $feed = ob_get_contents();
ob_end_clean(); ob_end_clean();
ObjectYPT::setCache($cacheFeedName, $feed); ObjectYPT::setCache($cacheFeedName, $feed);
}else{ } else {
//echo '<!-- cache -->'; //echo '<!-- cache -->';
} }
if(!is_string($feed)){ if (!is_string($feed)) {
$feed = json_encode($feed); $feed = json_encode($feed);
} }
echo $feed; echo $feed;
?>

View file

@ -7,10 +7,9 @@ $obj = new stdClass();
$obj->output = $output; $obj->output = $output;
foreach ($output as $value){ foreach ($output as $value) {
preg_match("/Date:(.*)/i", $value, $match); preg_match("/Date:(.*)/i", $value, $match);
if(!empty($match[1])){ if (!empty($match[1])) {
$obj->date = strtotime($match[1]); $obj->date = strtotime($match[1]);
$obj->dateString = trim($match[1]); $obj->dateString = trim($match[1]);
$obj->dateMySQL = date("Y-m-d H:i:s", $obj->date); $obj->dateMySQL = date("Y-m-d H:i:s", $obj->date);

View file

@ -110,7 +110,7 @@
</body> </body>
</html> </html>
<?php <?php
function __($text){ function __($text)
{
return $text; return $text;
} }
?>

View file

@ -34,7 +34,7 @@ error_log("Installation: ".__LINE__);
if ($_POST['createTables'] == 2) { if ($_POST['createTables'] == 2) {
$sql = "CREATE DATABASE IF NOT EXISTS {$_POST['databaseName']}"; $sql = "CREATE DATABASE IF NOT EXISTS {$_POST['databaseName']}";
if ($mysqli->query($sql) !== TRUE) { if ($mysqli->query($sql) !== true) {
$obj->error = "Error creating database: " . $mysqli->error; $obj->error = "Error creating database: " . $mysqli->error;
echo json_encode($obj); echo json_encode($obj);
exit; exit;
@ -55,33 +55,34 @@ error_log("Installation: ".__LINE__);
error_log("Installation: ".__LINE__); error_log("Installation: ".__LINE__);
if ($_POST['createTables'] > 0) { if ($_POST['createTables'] > 0) {
error_log("Installation: ".__LINE__); error_log("Installation: ".__LINE__);
// Temporary variable, used to store current query // Temporary variable, used to store current query
$templine = ''; $templine = '';
$installFile = "{$_POST['systemRootPath']}install/database.sql"; $installFile = "{$_POST['systemRootPath']}install/database.sql";
if(!file_exists($installFile)){ if (!file_exists($installFile)) {
$obj->error = "File Not found {$installFile}"; $obj->error = "File Not found {$installFile}";
echo json_encode($obj); echo json_encode($obj);
exit; exit;
} }
error_log("Installation: ".__LINE__); error_log("Installation: ".__LINE__);
// Read in entire file // Read in entire file
$lines = file($installFile); $lines = file($installFile);
if(empty($lines)){ if (empty($lines)) {
$obj->error = "File is empty {$installFile}"; $obj->error = "File is empty {$installFile}";
echo json_encode($obj); echo json_encode($obj);
exit; exit;
} }
error_log("Installation: ".__LINE__); error_log("Installation: ".__LINE__);
// Loop through each line // Loop through each line
$obj->error = ""; $obj->error = '';
foreach ($lines as $line) { foreach ($lines as $line) {
// Skip it if it's a comment // Skip it if it's a comment
if (substr($line, 0, 2) == '--' || $line == '') if (substr($line, 0, 2) == '--' || $line == '') {
continue; continue;
}
// Add this line to the current segment // Add this line to the current segment
$templine .= $line; $templine .= $line;
// If it has a semicolon at the end, it's the end of the query // If it has a semicolon at the end, it's the end of the query
if (substr(trim($line), -1, 1) == ';') { if (substr(trim($line), -1, 1) == ';') {
// Perform the query // Perform the query
//error_log("Installation: ".$templine); //error_log("Installation: ".$templine);
@ -99,7 +100,7 @@ if ($_POST['createTables'] > 0) {
error_log("Installation: ".__LINE__); error_log("Installation: ".__LINE__);
$sql = "DELETE FROM users WHERE id = 1 "; $sql = "DELETE FROM users WHERE id = 1 ";
if ($mysqli->query($sql) !== TRUE) { if ($mysqli->query($sql) !== true) {
$obj->error = "Error deleting user: " . $mysqli->error; $obj->error = "Error deleting user: " . $mysqli->error;
echo json_encode($obj); echo json_encode($obj);
exit; exit;
@ -108,7 +109,7 @@ if ($mysqli->query($sql) !== TRUE) {
error_log("Installation: ".__LINE__); error_log("Installation: ".__LINE__);
$sql = "INSERT INTO users (id, user, email, password, created, modified, isAdmin) VALUES (1, 'admin', '" . $_POST['contactEmail'] . "', '" . md5($_POST['systemAdminPass']) . "', now(), now(), true)"; $sql = "INSERT INTO users (id, user, email, password, created, modified, isAdmin) VALUES (1, 'admin', '" . $_POST['contactEmail'] . "', '" . md5($_POST['systemAdminPass']) . "', now(), now(), true)";
if ($mysqli->query($sql) !== TRUE) { if ($mysqli->query($sql) !== true) {
$obj->error = "Error creating admin user: " . $mysqli->error; $obj->error = "Error creating admin user: " . $mysqli->error;
echo json_encode($obj); echo json_encode($obj);
exit; exit;
@ -116,7 +117,7 @@ if ($mysqli->query($sql) !== TRUE) {
error_log("Installation: ".__LINE__); error_log("Installation: ".__LINE__);
$sql = "DELETE FROM categories WHERE id = 1 "; $sql = "DELETE FROM categories WHERE id = 1 ";
if ($mysqli->query($sql) !== TRUE) { if ($mysqli->query($sql) !== true) {
$obj->error = "Error deleting category: " . $mysqli->error; $obj->error = "Error deleting category: " . $mysqli->error;
echo json_encode($obj); echo json_encode($obj);
exit; exit;
@ -124,7 +125,7 @@ if ($mysqli->query($sql) !== TRUE) {
error_log("Installation: ".__LINE__); error_log("Installation: ".__LINE__);
$sql = "INSERT INTO categories (id, name, clean_name, description, created, modified) VALUES (1, 'Default', 'default','', now(), now())"; $sql = "INSERT INTO categories (id, name, clean_name, description, created, modified) VALUES (1, 'Default', 'default','', now(), now())";
if ($mysqli->query($sql) !== TRUE) { if ($mysqli->query($sql) !== true) {
$obj->error = "Error creating category: " . $mysqli->error; $obj->error = "Error creating category: " . $mysqli->error;
echo json_encode($obj); echo json_encode($obj);
exit; exit;
@ -132,7 +133,7 @@ if ($mysqli->query($sql) !== TRUE) {
error_log("Installation: ".__LINE__); error_log("Installation: ".__LINE__);
$sql = "DELETE FROM configurations WHERE id = 1 "; $sql = "DELETE FROM configurations WHERE id = 1 ";
if ($mysqli->query($sql) !== TRUE) { if ($mysqli->query($sql) !== true) {
$obj->error = "Error deleting configuration: " . $mysqli->error; $obj->error = "Error deleting configuration: " . $mysqli->error;
echo json_encode($obj); echo json_encode($obj);
exit; exit;
@ -141,14 +142,14 @@ if ($mysqli->query($sql) !== TRUE) {
error_log("Installation: ".__LINE__); error_log("Installation: ".__LINE__);
$encoder = 'https://encoder1.avideo.com/'; $encoder = 'https://encoder1.avideo.com/';
if(is_dir("{$_POST['systemRootPath']}Encoder")){ if (is_dir("{$_POST['systemRootPath']}Encoder")) {
$encoder = "{$_POST['webSiteRootURL']}Encoder/"; $encoder = "{$_POST['webSiteRootURL']}Encoder/";
} }
$sql = "INSERT INTO configurations (id, video_resolution, users_id, version, webSiteTitle, language, contactEmail, encoderURL, created, modified) " $sql = "INSERT INTO configurations (id, video_resolution, users_id, version, webSiteTitle, language, contactEmail, encoderURL, created, modified) "
. " VALUES " . " VALUES "
. " (1, '858:480', 1,'{$installationVersion}', '{$_POST['webSiteTitle']}', '{$_POST['mainLanguage']}', '{$_POST['contactEmail']}', '{$encoder}', now(), now())"; . " (1, '858:480', 1,'{$installationVersion}', '{$_POST['webSiteTitle']}', '{$_POST['mainLanguage']}', '{$_POST['contactEmail']}', '{$encoder}', now(), now())";
if ($mysqli->query($sql) !== TRUE) { if ($mysqli->query($sql) !== true) {
$obj->error = "Error creating configuration: " . $mysqli->error; $obj->error = "Error creating configuration: " . $mysqli->error;
echo json_encode($obj); echo json_encode($obj);
exit; exit;
@ -156,7 +157,7 @@ if ($mysqli->query($sql) !== TRUE) {
error_log("Installation: ".__LINE__); error_log("Installation: ".__LINE__);
$sql = "INSERT INTO `plugins` VALUES (NULL, 'a06505bf-3570-4b1f-977a-fd0e5cab205d', 'active', now(), now(), '', 'Gallery', 'Gallery', '1.0');"; $sql = "INSERT INTO `plugins` VALUES (NULL, 'a06505bf-3570-4b1f-977a-fd0e5cab205d', 'active', now(), now(), '', 'Gallery', 'Gallery', '1.0');";
if ($mysqli->query($sql) !== TRUE) { if ($mysqli->query($sql) !== true) {
$obj->error = "Error enabling Gallery Plugin: " . $mysqli->error; $obj->error = "Error enabling Gallery Plugin: " . $mysqli->error;
echo json_encode($obj); echo json_encode($obj);
exit; exit;
@ -166,7 +167,7 @@ if ($mysqli->query($sql) !== TRUE) {
error_log("Installation: ".__LINE__); error_log("Installation: ".__LINE__);
$mysqli->close(); $mysqli->close();
if(empty($_POST['salt'])){ if (empty($_POST['salt'])) {
$_POST['salt'] = uniqid(); $_POST['salt'] = uniqid();
} }
$content = "<?php $content = "<?php

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
@ -7,11 +6,11 @@ if (!isCommandLineInterface()) {
return die('Command Line only'); return die('Command Line only');
} }
$doNotDeleteFilesList = array('configuration.php', 'favicon.ico', 'favicon.png', 'avideo.log', 'PayPal.log', 'socketPID.log', 'logo.png', 'logoOverlay.png'); $doNotDeleteFilesList = ['configuration.php', 'favicon.ico', 'favicon.png', 'avideo.log', 'PayPal.log', 'socketPID.log', 'logo.png', 'logoOverlay.png'];
$lockFilename = '.move_v1.lock'; $lockFilename = '.move_v1.lock';
$path = getVideosDir(); $path = getVideosDir();
$files = array_diff(scandir($path), array('.', '..')); $files = array_diff(scandir($path), ['.', '..']);
echo "*** Total filenames " . count($files) . "\n"; echo "*** Total filenames " . count($files) . "\n";
foreach ($files as $key => $value) { foreach ($files as $key => $value) {
$dir = "{$path}{$value}"; $dir = "{$path}{$value}";
@ -26,7 +25,7 @@ foreach ($files as $key => $value) {
//echo "+++ Video FOUND for filename {$filename} ".PHP_EOL; //echo "+++ Video FOUND for filename {$filename} ".PHP_EOL;
unset($files[$key]); unset($files[$key]);
} else { } else {
$files[$key] = array($value, $dir); $files[$key] = [$value, $dir];
//echo "*** Video NOT found for filename {$filename} ".PHP_EOL; //echo "*** Video NOT found for filename {$filename} ".PHP_EOL;
} }
} }
@ -40,7 +39,7 @@ foreach ($files as $key => $value) {
//echo "+++ Video FOUND for filename {$filename} ".PHP_EOL; //echo "+++ Video FOUND for filename {$filename} ".PHP_EOL;
unset($files[$key]); unset($files[$key]);
} else { } else {
$files[$key] = array($value, $dir); $files[$key] = [$value, $dir];
//echo "*** Video NOT found for filename {$filename} ".PHP_EOL; //echo "*** Video NOT found for filename {$filename} ".PHP_EOL;
} }
} else { } else {
@ -75,8 +74,7 @@ if (!empty($confirm) && strtolower($confirm) === 'y') {
} else { } else {
echo "$value[1] Directory Could Not be Deleted \n"; echo "$value[1] Directory Could Not be Deleted \n";
} }
} else } elseif (unlink($value[1])) {
if (unlink($value[1])) {
echo "$value[1] Deleted \n"; echo "$value[1] Deleted \n";
} else { } else {
echo "$value[1] Could Not be Deleted \n"; echo "$value[1] Could Not be Deleted \n";

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
@ -12,34 +11,33 @@ if (empty($p)) {
return die('YPTStorage plugin disabled'); return die('YPTStorage plugin disabled');
} }
$fileExtensions = array('jpg', 'gif', 'mp4', 'webm', 'tgz'); $fileExtensions = ['jpg', 'gif', 'mp4', 'webm', 'tgz'];
$files = array(); $files = [];
//foreach (glob("../videos/*.{" . implode(",", $fileExtensions) . "}", GLOB_BRACE) as $filename) { //foreach (glob("../videos/*.{" . implode(",", $fileExtensions) . "}", GLOB_BRACE) as $filename) {
foreach (glob("../videos/*", GLOB_BRACE) as $filename) { foreach (glob("../videos/*", GLOB_BRACE) as $filename) {
$base = basename($filename); $base = basename($filename);
if (is_dir($filename)) { if (is_dir($filename)) {
if (strpos($base, "_YPTuniqid_") !== false) { if (strpos($base, "_YPTuniqid_") !== false) {
$files[$base] = array($base, $filename); $files[$base] = [$base, $filename];
} }
} else { } else {
$baseName = explode("_portrait", $base); $baseName = explode("_portrait", $base);
if (!empty($baseName[1])) { if (!empty($baseName[1])) {
$files[$base] = array($baseName[0], $filename); $files[$base] = [$baseName[0], $filename];
} else { } else {
$baseName = explode("_thumbs", $base); $baseName = explode("_thumbs", $base);
if (!empty($baseName[1])) { if (!empty($baseName[1])) {
$files[$base] = array($baseName[0], $filename); $files[$base] = [$baseName[0], $filename];
} else { } else {
$types = array('_HD', '_Low', '_SD'); $types = ['_HD', '_Low', '_SD'];
$notFound = true; $notFound = true;
foreach ($types as $value) { foreach ($types as $value) {
$baseName = explode($value, $base); $baseName = explode($value, $base);
if (!empty($baseName[1])) { if (!empty($baseName[1])) {
$files[$base] = array($baseName[0], $filename); $files[$base] = [$baseName[0], $filename];
$notFound = false; $notFound = false;
} }
} }
@ -51,7 +49,7 @@ foreach (glob("../videos/*", GLOB_BRACE) as $filename) {
$baseName = str_replace("." . $value, "", $base); $baseName = str_replace("." . $value, "", $base);
if (!empty($baseName[1])) { if (!empty($baseName[1])) {
if (!in_array($baseName, $files)) { if (!in_array($baseName, $files)) {
$files[$base] = array($baseName, $filename); $files[$base] = [$baseName, $filename];
} }
} }
} }
@ -64,12 +62,12 @@ echo "*** Total filenames " . count($files) . "\n";
$max = 10; $max = 10;
$count = 0; $count = 0;
$countExecuted = 0; $countExecuted = 0;
$checkedFiles = array(); $checkedFiles = [];
foreach ($files as $key => $value) { foreach ($files as $key => $value) {
if (!empty($checkedFiles[$value[0]])) { if (!empty($checkedFiles[$value[0]])) {
continue; continue;
} }
$checkedFiles[$value[0]] = array(true); $checkedFiles[$value[0]] = [true];
$getUsageFromFilename = YPTStorage::getUsageFromFilename($value[0]); $getUsageFromFilename = YPTStorage::getUsageFromFilename($value[0]);
$checkedFiles[$value[0]][] = $getUsageFromFilename; $checkedFiles[$value[0]][] = $getUsageFromFilename;
@ -95,14 +93,14 @@ foreach ($files as $key => $value) {
} }
YPTStorage::createDummy($video['id']); YPTStorage::createDummy($video['id']);
$tgzFile = $global['systemRootPath'] . "videos/{$video['filename']}.tgz"; $tgzFile = $global['systemRootPath'] . "videos/{$video['filename']}.tgz";
if(file_exists($tgzFile)){ if (file_exists($tgzFile)) {
unlink($tgzFile); unlink($tgzFile);
} }
echo "****** File size is the same videos_id = {$video['id']} {$sites_id} [$source_size!==$destination_size][" . humanFileSize($source_size) . "!==" . humanFileSize($destination_size) . "]\n"; echo "****** File size is the same videos_id = {$video['id']} {$sites_id} [$source_size!==$destination_size][" . humanFileSize($source_size) . "!==" . humanFileSize($destination_size) . "]\n";
//exit; //exit;
} else if($source_sizee > 5000000){ } elseif ($source_sizee > 5000000) {
echo "----- ERROR File size is NOT the same videos_id and it's supposed to be on the storage = {$video['id']} {$sites_id} [$source_size!==$destination_size][" . humanFileSize($source_size) . "!==" . humanFileSize($destination_size) . "]\n"; echo "----- ERROR File size is NOT the same videos_id and it's supposed to be on the storage = {$video['id']} {$sites_id} [$source_size!==$destination_size][" . humanFileSize($source_size) . "!==" . humanFileSize($destination_size) . "]\n";
} else if($source_sizee > 5000000){ } elseif ($source_sizee > 5000000) {
echo "+++++ All seems fine with video {$video['id']} {$sites_id} [$source_size!==$destination_size][" . humanFileSize($source_size) . "!==" . humanFileSize($destination_size) . "]\n"; echo "+++++ All seems fine with video {$video['id']} {$sites_id} [$source_size!==$destination_size][" . humanFileSize($source_size) . "!==" . humanFileSize($destination_size) . "]\n";
} }
} else { } else {

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
ob_end_flush(); ob_end_flush();
@ -9,14 +8,14 @@ if (!isCommandLineInterface()) {
$path = getVideosDir(); $path = getVideosDir();
$files = array_diff(scandir($path), array('.', '..')); $files = array_diff(scandir($path), ['.', '..']);
foreach ($files as $value) { foreach ($files as $value) {
$dir = "{$path}{$value}"; $dir = "{$path}{$value}";
if (is_dir($dir)) { if (is_dir($dir)) {
$files2 = array_diff(scandir($dir), array('.', '..')); $files2 = array_diff(scandir($dir), ['.', '..']);
foreach ($files2 as $value2) { foreach ($files2 as $value2) {
$ext = pathinfo($value2, PATHINFO_EXTENSION); $ext = pathinfo($value2, PATHINFO_EXTENSION);
if($ext=='tgz'){ if ($ext=='tgz') {
$file = "{$dir}/{$value2}"; $file = "{$dir}/{$value2}";
echo $file.' '. humanFileSize(filesize($file)).PHP_EOL; echo $file.' '. humanFileSize(filesize($file)).PHP_EOL;
unlink($file); unlink($file);

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/video.php'; require_once $global['systemRootPath'] . 'objects/video.php';
@ -10,22 +9,22 @@ if (!isCommandLineInterface()) {
ob_end_flush(); ob_end_flush();
$checkIfIsCorrupted = intval(@$argv[1]); $checkIfIsCorrupted = intval(@$argv[1]);
echo "checkIfIsCorrupted = $checkIfIsCorrupted".PHP_EOL; echo "checkIfIsCorrupted = $checkIfIsCorrupted".PHP_EOL;
$users_ids = array(); $users_ids = [];
$sql = "SELECT * FROM videos "; $sql = "SELECT * FROM videos ";
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
$total = count($fullData); $total = count($fullData);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
$count = 0; $count = 0;
foreach ($fullData as $key => $row) { foreach ($fullData as $key => $row) {
$count++; $count++;
$filename = $row['filename']; $filename = $row['filename'];
$totalDeleted = Video::deleteThumbs($filename, true, $checkIfIsCorrupted); $totalDeleted = Video::deleteThumbs($filename, true, $checkIfIsCorrupted);
if($totalDeleted){ if ($totalDeleted) {
echo "{$total}/{$count} Thumbs deleted ($totalDeleted) from {$row['title']}".PHP_EOL; echo "{$total}/{$count} Thumbs deleted ($totalDeleted) from {$row['title']}".PHP_EOL;
}else{ } else {
echo "{$total}/{$count} Thumbs NOT deleted from {$row['title']}".PHP_EOL; echo "{$total}/{$count} Thumbs NOT deleted from {$row['title']}".PHP_EOL;
} }
} }

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/playlist.php'; require_once $global['systemRootPath'] . 'objects/playlist.php';
@ -14,25 +13,25 @@ $sql = "select * FROM users";
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
$count = array('NoPermanent'=>0, 'NoDynamic'=>0, 'Deleted'=>0); $count = ['NoPermanent'=>0, 'NoDynamic'=>0, 'Deleted'=>0];
if ($res != false) { if ($res != false) {
foreach ($fullData as $key => $row) { foreach ($fullData as $key => $row) {
$rowsUser = UserGroups::getUserGroups($row['id']); $rowsUser = UserGroups::getUserGroups($row['id']);
if(empty($rowsUser)){ if (empty($rowsUser)) {
//echo "This user has no permanent usergroups".PHP_EOL; //echo "This user has no permanent usergroups".PHP_EOL;
$count['NoPermanent']++; $count['NoPermanent']++;
}else{ } else {
$user = new User($row['id'], $row['user'], $row['password']); $user = new User($row['id'], $row['user'], $row['password']);
$user->login(true, false, true); $user->login(true, false, true);
$user_groups_id = AVideoPlugin::getDynamicUserGroupsId($row['id']); $user_groups_id = AVideoPlugin::getDynamicUserGroupsId($row['id']);
if(empty($user_groups_id)){ if (empty($user_groups_id)) {
//echo "This user has no dynamic usergroups".PHP_EOL; //echo "This user has no dynamic usergroups".PHP_EOL;
$count['NoDynamic']++; $count['NoDynamic']++;
}else{ } else {
echo "found dynamic usergroups from users_id={$row['id']} user={$row['user']} usergroups=". implode(',', $user_groups_id).PHP_EOL; echo "found dynamic usergroups from users_id={$row['id']} user={$row['user']} usergroups=". implode(',', $user_groups_id).PHP_EOL;
$sqlUG = "DELETE FROM users_has_users_groups WHERE users_id = ? AND users_groups_id IN (". implode(',', $user_groups_id).")"; $sqlUG = "DELETE FROM users_has_users_groups WHERE users_id = ? AND users_groups_id IN (". implode(',', $user_groups_id).")";
sqlDAL::writeSql($sqlUG, "i", array($row['id'])); sqlDAL::writeSql($sqlUG, "i", [$row['id']]);
$count['Deleted']++; $count['Deleted']++;
} }
} }

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
@ -64,8 +63,9 @@ foreach ($videos as $value) {
ob_flush(); ob_flush();
} }
function getFirstVideoURL($videoFileName) { function getFirstVideoURL($videoFileName)
$types = array('', '_Low', '_SD', '_HD'); {
$types = ['', '_Low', '_SD', '_HD'];
$videosList = getVideosURL($videoFileName); $videosList = getVideosURL($videoFileName);
if (!empty($videosList['m3u8']["url"])) { if (!empty($videosList['m3u8']["url"])) {
return $videosList['m3u8']["url"]; return $videosList['m3u8']["url"];
@ -73,15 +73,16 @@ function getFirstVideoURL($videoFileName) {
foreach ($types as $value) { foreach ($types as $value) {
if (!empty($videosList['mp4' . $value]["url"])) { if (!empty($videosList['mp4' . $value]["url"])) {
return $videosList['mp4' . $value]["url"]; return $videosList['mp4' . $value]["url"];
} else if (!empty($videosList['webm' . $value]["url"])) { } elseif (!empty($videosList['webm' . $value]["url"])) {
return $videosList['webm' . $value]["url"]; return $videosList['webm' . $value]["url"];
} }
} }
return false; return false;
} }
function getFirstVideoPath($videoFileName) { function getFirstVideoPath($videoFileName)
$types = array('', '_Low', '_SD', '_HD'); {
$types = ['', '_Low', '_SD', '_HD'];
$videosList = getVideosURL($videoFileName); $videosList = getVideosURL($videoFileName);
if (!empty($videosList['m3u8']["path"])) { if (!empty($videosList['m3u8']["path"])) {
return $videosList['m3u8']["path"]; return $videosList['m3u8']["path"];
@ -89,7 +90,7 @@ function getFirstVideoPath($videoFileName) {
foreach ($types as $value) { foreach ($types as $value) {
if (!empty($videosList['mp4' . $value]["path"])) { if (!empty($videosList['mp4' . $value]["path"])) {
return $videosList['mp4' . $value]["path"]; return $videosList['mp4' . $value]["path"];
} else if (!empty($videosList['webm' . $value]["path"])) { } elseif (!empty($videosList['webm' . $value]["path"])) {
return $videosList['webm' . $value]["path"]; return $videosList['webm' . $value]["path"];
} }
} }

View file

@ -1,9 +1,6 @@
<?php <?php
require_once '../objects/functions.php'; require_once '../objects/functions.php';
require_once '../locale/function.php'; require_once '../locale/function.php';
//var_dump($_SERVER);exit; //var_dump($_SERVER);exit;
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
@ -28,8 +25,7 @@ require_once '../locale/function.php';
<body> <body>
<?php <?php
if (file_exists('../videos/configuration.php')) { if (file_exists('../videos/configuration.php')) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php'; ?>
?>
<div class="container"> <div class="container">
<h3 class="alert alert-success"> <h3 class="alert alert-success">
<span class="glyphicon glyphicon-ok-circle"></span> <span class="glyphicon glyphicon-ok-circle"></span>
@ -63,8 +59,7 @@ require_once '../locale/function.php';
<strong>Your server is <?php echo $_SERVER['SERVER_SOFTWARE']; ?>, you must install Apache</strong> <strong>Your server is <?php echo $_SERVER['SERVER_SOFTWARE']; ?>, you must install Apache</strong>
</div> </div>
<?php <?php
} } ?>
?>
<?php <?php
if (isPHP('7.3')) { if (isPHP('7.3')) {
?> ?>
@ -80,8 +75,7 @@ require_once '../locale/function.php';
<strong>Your PHP version is <?php echo PHP_VERSION; ?>. PHP 7.3 or newer is required.</strong> <strong>Your PHP version is <?php echo PHP_VERSION; ?>. PHP 7.3 or newer is required.</strong>
</div> </div>
<?php <?php
} } ?>
?>
<?php <?php
if (checkVideosDir()) { if (checkVideosDir()) {
@ -99,14 +93,13 @@ require_once '../locale/function.php';
<details> <details>
<?php <?php
$dir = getPathToApplication() . "videos"; $dir = getPathToApplication() . "videos";
if (!file_exists($dir)) { if (!file_exists($dir)) {
?> ?>
The video directory does not exists, AVideo had no permition to create it, you must create it manualy! The video directory does not exists, AVideo had no permition to create it, you must create it manualy!
<br> <br>
<pre><code>sudo mkdir <?php echo $dir; ?></code></pre> <pre><code>sudo mkdir <?php echo $dir; ?></code></pre>
<?php <?php
} } ?>
?>
<br> <br>
Then you can set the permissions (www-data means apache user). Then you can set the permissions (www-data means apache user).
<br> <br>
@ -115,11 +108,10 @@ require_once '../locale/function.php';
</div> </div>
<?php <?php
} }
$pathToPHPini = php_ini_loaded_file(); $pathToPHPini = php_ini_loaded_file();
if (empty($pathToPHPini)) { if (empty($pathToPHPini)) {
$pathToPHPini = "/etc/php/7.0/cli/php.ini"; $pathToPHPini = "/etc/php/7.0/cli/php.ini";
} } ?>
?>
<?php <?php
if (check_post_max_size()) { if (check_post_max_size()) {
@ -142,8 +134,7 @@ require_once '../locale/function.php';
</details> </details>
</div> </div>
<?php <?php
} } ?>
?>
<?php <?php
if (check_upload_max_filesize()) { if (check_upload_max_filesize()) {
@ -166,8 +157,7 @@ require_once '../locale/function.php';
</details> </details>
</div> </div>
<?php <?php
} } ?>
?>
</div> </div>
</div> </div>
</div> </div>
@ -195,25 +185,24 @@ require_once '../locale/function.php';
<select class="selectpicker" id="mainLanguage"> <select class="selectpicker" id="mainLanguage">
<?php <?php
global $global; global $global;
include_once '../objects/bcp47.php'; include_once '../objects/bcp47.php';
$dir = "../locale/"; $dir = "../locale/";
$flags = array(); $flags = [];
if ($handle = opendir($dir)) { if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) { while (false !== ($entry = readdir($handle))) {
if ($entry != '.' && $entry != '..' && $entry != 'index.php' && $entry != 'function.php' && $entry != 'save.php') { if ($entry != '.' && $entry != '..' && $entry != 'index.php' && $entry != 'function.php' && $entry != 'save.php') {
$flags[] = str_replace('.php', '', $entry); $flags[] = str_replace('.php', '', $entry);
} }
} }
closedir($handle); closedir($handle);
} }
sort($flags); sort($flags);
foreach ($flags as $flag) { foreach ($flags as $flag) {
//var_dump($global['bcp47'][$flag]); //var_dump($global['bcp47'][$flag]);
$fileEx = $global['bcp47'][$flag]['flag']; $fileEx = $global['bcp47'][$flag]['flag'];
echo "<option data-content='<span class=\"flagstrap-icon flagstrap-$fileEx\"></span> {$global['bcp47'][$flag]['label']}' value=\"$fileEx\" " . (('us' == $fileEx) ? " selected" : "") . ">{$global['bcp47'][$flag]['label']}</option>"; echo "<option data-content='<span class=\"flagstrap-icon flagstrap-$fileEx\"></span> {$global['bcp47'][$flag]['label']}' value=\"$fileEx\" " . (('us' == $fileEx) ? " selected" : "") . ">{$global['bcp47'][$flag]['label']}</option>";
} } ?>
?>
</select> </select>
</div> </div>
</div> </div>
@ -224,14 +213,12 @@ require_once '../locale/function.php';
<div class="form-group"> <div class="form-group">
<label for="systemAdminPass">System Admin password</label> <label for="systemAdminPass">System Admin password</label>
<?php <?php
getInputPassword("systemAdminPass", 'class="form-control" required="required"', __("Enter System Admin password")); getInputPassword("systemAdminPass", 'class="form-control" required="required"', __("Enter System Admin password")); ?>
?>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="confirmSystemAdminPass">Confirm System Admin password</label> <label for="confirmSystemAdminPass">Confirm System Admin password</label>
<?php <?php
getInputPassword("confirmSystemAdminPass", 'class="form-control" required="required"', __("Confirm System Admin password")); getInputPassword("confirmSystemAdminPass", 'class="form-control" required="required"', __("Confirm System Admin password")); ?>
?>
</div> </div>
</div> </div>
</div> </div>
@ -256,8 +243,7 @@ require_once '../locale/function.php';
<div class="form-group"> <div class="form-group">
<label for="databasePass">Database Password</label> <label for="databasePass">Database Password</label>
<?php <?php
getInputPassword("databasePass", 'class="form-control"', __("Enter Database Password")); getInputPassword("databasePass", 'class="form-control"', __("Enter Database Password")); ?>
?>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="databaseName">Database Name</label> <label for="databaseName">Database Name</label>
@ -281,7 +267,8 @@ require_once '../locale/function.php';
</div> </div>
</div> </div>
<?php } ?> <?php
} ?>
<script src="../view/bootstrap/js/bootstrap.min.js" type="text/javascript"></script> <script src="../view/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="../view/css/flagstrap/js/jquery.flagstrap.min.js" type="text/javascript"></script> <script src="../view/css/flagstrap/js/jquery.flagstrap.min.js" type="text/javascript"></script>
<script src="../view/bootstrap/bootstrapSelectPicker/js/bootstrap-select.min.js" type="text/javascript"></script> <script src="../view/bootstrap/bootstrapSelectPicker/js/bootstrap-select.min.js" type="text/javascript"></script>

View file

@ -1,5 +1,4 @@
<?php <?php
require_once '../objects/functions.php'; require_once '../objects/functions.php';
if (!isCommandLineInterface()) { if (!isCommandLineInterface()) {
die('Command Line only'); die('Command Line only');
@ -17,10 +16,10 @@ if (version_compare(phpversion(), '7.2', '<')) {
$webSiteRootURL = @$argv[1]; $webSiteRootURL = @$argv[1];
$webSiteRootURL = preg_replace("/[^0-9a-z._\/:-]/i", "", trim($webSiteRootURL)); $webSiteRootURL = preg_replace("/[^0-9a-z._\/:-]/i", "", trim($webSiteRootURL));
$databaseUser = empty($argv[2])?$databaseUser:$argv[2]; $databaseUser = empty($argv[2]) ? $databaseUser : $argv[2];
$databasePass = empty($argv[3])?$databasePass:$argv[3]; $databasePass = empty($argv[3]) ? $databasePass : $argv[3];
$systemAdminPass = empty($argv[4])?"123":$argv[4]; $systemAdminPass = empty($argv[4]) ? "123" : $argv[4];
$contactEmail = empty($argv[5])?"undefined@youremail.com":$argv[5]; $contactEmail = empty($argv[5]) ? "undefined@youremail.com" : $argv[5];
if (!filter_var($webSiteRootURL, FILTER_VALIDATE_URL)) { if (!filter_var($webSiteRootURL, FILTER_VALIDATE_URL)) {
if (!empty($webSiteRootURL)) { if (!empty($webSiteRootURL)) {
echo "Invalid Site URL ({$webSiteRootURL})\n"; echo "Invalid Site URL ({$webSiteRootURL})\n";
@ -36,9 +35,9 @@ if (!filter_var($webSiteRootURL, FILTER_VALIDATE_URL)) {
$webSiteRootURL = rtrim($webSiteRootURL, '/') . '/'; $webSiteRootURL = rtrim($webSiteRootURL, '/') . '/';
$_POST['systemRootPath'] = str_replace("install", "", getcwd()); $_POST['systemRootPath'] = str_replace("install", "", getcwd());
if(!is_dir($_POST['systemRootPath'])){ if (!is_dir($_POST['systemRootPath'])) {
$_POST['systemRootPath'] = "/var/www/html/YouPHPTube/"; $_POST['systemRootPath'] = "/var/www/html/YouPHPTube/";
if(!is_dir($_POST['systemRootPath'])){ if (!is_dir($_POST['systemRootPath'])) {
$_POST['systemRootPath'] = "/var/www/html/AVideo/"; $_POST['systemRootPath'] = "/var/www/html/AVideo/";
} }
} }

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
@ -7,19 +6,21 @@ if (!isCommandLineInterface()) {
return die('Command Line only'); return die('Command Line only');
} }
function _rsearch($folder, $pattern) { function _rsearch($folder, $pattern)
{
$dir = new RecursiveDirectoryIterator($folder); $dir = new RecursiveDirectoryIterator($folder);
$ite = new RecursiveIteratorIterator($dir); $ite = new RecursiveIteratorIterator($dir);
$files = new RegexIterator($ite, $pattern, RegexIterator::GET_MATCH); $files = new RegexIterator($ite, $pattern, RegexIterator::GET_MATCH);
$fileList = array(); $fileList = [];
foreach ($files as $file) { foreach ($files as $file) {
foreach ($file as $key => $value) { foreach ($file as $key => $value) {
$file[$key] = "{$folder}{$dir}/{$value}"; $file[$key] = "{$folder}{$dir}/{$value}";
} }
$fileList = array_merge($fileList, $file); $fileList = array_merge($fileList, $file);
} }
usort($fileList, usort(
function($a, $b) { $fileList,
function ($a, $b) {
return preg_match('/SendRecordedToEncoder/', $a) ? 1 : 0; return preg_match('/SendRecordedToEncoder/', $a) ? 1 : 0;
} }
); );
@ -50,12 +51,13 @@ if ($option == 1 || $option == 2) {
$countLines = 0; $countLines = 0;
foreach ($lines as $line) { foreach ($lines as $line) {
$countLines++; $countLines++;
if (substr($line, 0, 2) == '--' || $line == '') if (substr($line, 0, 2) == '--' || $line == '') {
continue; continue;
}
$templine .= $line; $templine .= $line;
if (substr(trim($line), -1, 1) == ';') { if (substr(trim($line), -1, 1) == ';') {
if (!$global['mysqli']->query($templine)) { if (!$global['mysqli']->query($templine)) {
echo ($value . ' Error performing query \'<strong>' . $templine . '\': ' . $global['mysqli']->error . '<br /><br />'); echo($value . ' Error performing query \'<strong>' . $templine . '\': ' . $global['mysqli']->error . '<br /><br />');
die(json_encode($obj)); die(json_encode($obj));
} else { } else {
echo "[{$countFiles}/{$totalFiles}][{$countLines}/{$totalLines}] Success performing query from $value\n"; echo "[{$countFiles}/{$totalFiles}][{$countLines}/{$totalLines}] Success performing query from $value\n";
@ -67,30 +69,30 @@ if ($option == 1 || $option == 2) {
$global['mysqli']->commit(); $global['mysqli']->commit();
} }
if ($option == 1 || $option == 3) { if ($option == 1 || $option == 3) {
$EnablePlugins = array( $EnablePlugins = [
array('1apicbec-91db-4357-bb10-ee08b0913778', 'API', 'API'), ['1apicbec-91db-4357-bb10-ee08b0913778', 'API', 'API'],
array('6daca392-7b14-44fb-aa33-51cba620d92e', 'CookieAlert', 'CookieAlert'), ['6daca392-7b14-44fb-aa33-51cba620d92e', 'CookieAlert', 'CookieAlert'],
array('55a4fa56-8a30-48d4-a0fb-8aa6b3f69033', 'CustomizeAdvanced', 'CustomizeAdvanced'), ['55a4fa56-8a30-48d4-a0fb-8aa6b3f69033', 'CustomizeAdvanced', 'CustomizeAdvanced'],
array('55a4fa56-8a30-48d4-a0fb-8aa6b3fuser3', 'CustomizeUser', 'CustomizeUser'), ['55a4fa56-8a30-48d4-a0fb-8aa6b3fuser3', 'CustomizeUser', 'CustomizeUser'],
array('a06505bf-3570-4b1f-977a-fd0e5cab205d', 'Gallery', 'Gallery'), ['a06505bf-3570-4b1f-977a-fd0e5cab205d', 'Gallery', 'Gallery'],
array('e06b161c-cbd0-4c1d-a484-71018efa2f35', 'Live', 'Live'), ['e06b161c-cbd0-4c1d-a484-71018efa2f35', 'Live', 'Live'],
array('5310b394-b54f-48ab-9049-995df4d95239', 'NextButton', 'NextButton'), ['5310b394-b54f-48ab-9049-995df4d95239', 'NextButton', 'NextButton'],
array('plist12345-370-4b1f-977a-fd0e5cabtube', 'Programs', 'PlayLists'), ['plist12345-370-4b1f-977a-fd0e5cabtube', 'Programs', 'PlayLists'],
array('b5e223db-785b-4436-8f7b-f297860c9be0', 'ReportVideo', 'ReportVideo'), ['b5e223db-785b-4436-8f7b-f297860c9be0', 'ReportVideo', 'ReportVideo'],
array('f7596843-51b1-47a0-8bb1-b4ad91f87d6b', 'TheaterButton', 'TheaterButton'), ['f7596843-51b1-47a0-8bb1-b4ad91f87d6b', 'TheaterButton', 'TheaterButton'],
array('45432a78-d0c6-47f3-8ac4-8fd05f507386', 'User_Location', 'User_Location'), ['45432a78-d0c6-47f3-8ac4-8fd05f507386', 'User_Location', 'User_Location'],
array('4c1f4f76-b336-4ddc-a4de-184efe715c09', 'MobileManager', 'MobileManager'), ['4c1f4f76-b336-4ddc-a4de-184efe715c09', 'MobileManager', 'MobileManager'],
array('52chata2-3f14-49db-958e-15ccb1a07f0e', 'Chat2', 'Chat2'), ['52chata2-3f14-49db-958e-15ccb1a07f0e', 'Chat2', 'Chat2'],
array('cf145581-7d5e-4bb6-8c12-48fc37c0630d', 'LiveUsers', 'LiveUsers'), ['cf145581-7d5e-4bb6-8c12-48fc37c0630d', 'LiveUsers', 'LiveUsers'],
array('996c9afb-b90e-40ca-90cb-934856180bb9', 'MP4ThumbsAndGif', 'MP4ThumbsAndGif'), ['996c9afb-b90e-40ca-90cb-934856180bb9', 'MP4ThumbsAndGif', 'MP4ThumbsAndGif'],
array('eb6e2808-d876-4488-94cb-2448a6b14e0b', 'SendRecordedToEncoder', 'SendRecordedToEncoder'), ['eb6e2808-d876-4488-94cb-2448a6b14e0b', 'SendRecordedToEncoder', 'SendRecordedToEncoder'],
array('f2hls8c6-9359-4cc1-809f-fac32c8a4333', 'VideoHLS', 'VideoHLS'), ['f2hls8c6-9359-4cc1-809f-fac32c8a4333', 'VideoHLS', 'VideoHLS'],
array('4b9142c0-f0c3-42be-8fe5-a4775111239c', 'VideoResolutionSwitcher', 'VideoResolutionSwitcher'), ['4b9142c0-f0c3-42be-8fe5-a4775111239c', 'VideoResolutionSwitcher', 'VideoResolutionSwitcher'],
array('28e74f9a-a2ef-4644-86f0-40234ae7c1b5', 'VideoThumbnails', 'VideoThumbnails'), ['28e74f9a-a2ef-4644-86f0-40234ae7c1b5', 'VideoThumbnails', 'VideoThumbnails'],
array('meet225-3807-4167-ba81-0509dd280e06', 'Meet', 'Meet'), ['meet225-3807-4167-ba81-0509dd280e06', 'Meet', 'Meet'],
array('YPTSocket-5ee8405eaaa16', 'YPTSocket', 'YPTSocket'), ['YPTSocket-5ee8405eaaa16', 'YPTSocket', 'YPTSocket'],
array('Scheduler-5ee8405eaaa16', 'Scheduler', 'Scheduler') ['Scheduler-5ee8405eaaa16', 'Scheduler', 'Scheduler'],
); ];
foreach ($EnablePlugins as $value) { foreach ($EnablePlugins as $value) {
if ($plugin = Plugin::getOrCreatePluginByName($value[2], 'active')) { if ($plugin = Plugin::getOrCreatePluginByName($value[2], 'active')) {
echo "Success enable plugin ($value[2]) " . $plugin['name'] . "\n"; echo "Success enable plugin ($value[2]) " . $plugin['name'] . "\n";
@ -114,13 +116,14 @@ if ($option == 4) {
echo "Checking tables from {$value}" . PHP_EOL; echo "Checking tables from {$value}" . PHP_EOL;
$lines = file($value); $lines = file($value);
foreach ($lines as $line) { foreach ($lines as $line) {
if (substr($line, 0, 2) == '--' || $line == '') if (substr($line, 0, 2) == '--' || $line == '') {
continue; continue;
}
$templine .= $line; $templine .= $line;
if (substr(trim($line), -1, 1) == ';') { if (substr(trim($line), -1, 1) == ';') {
if (!$global['mysqli']->query($templine)) { if (!$global['mysqli']->query($templine)) {
echo ($value . ' Error performing query \'<strong>' . $templine . '\': ' . $global['mysqli']->error . '<br /><br />'); echo($value . ' Error performing query \'<strong>' . $templine . '\': ' . $global['mysqli']->error . '<br /><br />');
//die(json_encode($obj)); //die(json_encode($obj));
} else { } else {
echo "Success performing query from $value\n"; echo "Success performing query from $value\n";
} }

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
@ -18,7 +17,7 @@ sqlDAL::close($res);
if ($res != false) { if ($res != false) {
foreach ($users as $row) { foreach ($users as $row) {
echo "-----------------------------------".PHP_EOL; echo "-----------------------------------".PHP_EOL;
if(!empty($row['public'])){ if (!empty($row['public'])) {
echo "PUBLIC "; echo "PUBLIC ";
} }
echo "{$row['id']} - {$row['user']} ".PHP_EOL; echo "{$row['id']} - {$row['user']} ".PHP_EOL;
@ -28,7 +27,3 @@ if ($res != false) {
} }
} }
die(); die();

View file

@ -2,7 +2,7 @@
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
if(!isCommandLineInterface()){ if (!isCommandLineInterface()) {
return die('Command Line only'); return die('Command Line only');
} }
echo "Enter the username or press enter to skip:"; echo "Enter the username or press enter to skip:";
@ -10,18 +10,18 @@ echo "\n";
ob_flush(); ob_flush();
$userName = trim(readline("")); $userName = trim(readline(""));
if(!empty($userName)){ if (!empty($userName)) {
$user = new User(0, $userName, false); $user = new User(0, $userName, false);
if(!empty($user->getBdId())){ if (!empty($user->getBdId())) {
$sql = "UPDATE users SET isAdmin = 1, status = 'a' where id = ".$user->getBdId(); $sql = "UPDATE users SET isAdmin = 1, status = 'a' where id = ".$user->getBdId();
$insert_row = sqlDAL::writeSql($sql); $insert_row = sqlDAL::writeSql($sql);
if($insert_row){ if ($insert_row) {
echo "Your user {$userName} is admin now"; echo "Your user {$userName} is admin now";
echo "\n"; echo "\n";
die(); die();
} }
}else{ } else {
echo "User ({$userName}) Not found"; echo "User ({$userName}) Not found";
echo "\n"; echo "\n";
die(); die();
@ -30,7 +30,3 @@ if(!empty($userName)){
echo "Bye"; echo "Bye";
echo "\n"; echo "\n";
die(); die();

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
@ -25,7 +24,7 @@ foreach ($videos as $value) {
echo " {$count}/{$total} Searching {$basename} ".PHP_EOL; echo " {$count}/{$total} Searching {$basename} ".PHP_EOL;
$glob = glob("{$basename}*"); $glob = glob("{$basename}*");
$totalItems = count($glob); $totalItems = count($glob);
if($totalItems){ if ($totalItems) {
echo "Creating dir {$basename} " . PHP_EOL; echo "Creating dir {$basename} " . PHP_EOL;
make_path(addLastSlash($basename)); make_path(addLastSlash($basename));
} }
@ -36,11 +35,11 @@ foreach ($videos as $value) {
$countItems++; $countItems++;
echo "[$countItems/$totalItems] Process file {$file} " . PHP_EOL; echo "[$countItems/$totalItems] Process file {$file} " . PHP_EOL;
if (is_dir($file)) { if (is_dir($file)) {
if(!$isStorage && !Video::isNewVideoFilename($move['oldDir'])){ if (!$isStorage && !Video::isNewVideoFilename($move['oldDir'])) {
//echo $file.PHP_EOL; //echo $file.PHP_EOL;
$move = Video::updateDirectoryFilename($file); $move = Video::updateDirectoryFilename($file);
echo "-->".PHP_EOL." {$count}/{$total} move directory {$move['oldDir']} to {$move['newDir']} ".PHP_EOL."<--" . PHP_EOL . PHP_EOL; echo "-->".PHP_EOL." {$count}/{$total} move directory {$move['oldDir']} to {$move['newDir']} ".PHP_EOL."<--" . PHP_EOL . PHP_EOL;
}else{ } else {
echo " We will not rename directory {$file} ".PHP_EOL; echo " We will not rename directory {$file} ".PHP_EOL;
} }
continue; continue;
@ -48,9 +47,9 @@ foreach ($videos as $value) {
$filename = basename($file); $filename = basename($file);
$newname = Video::getPathToFile($filename); $newname = Video::getPathToFile($filename);
$renamed = rename($file, $newname); $renamed = rename($file, $newname);
if($renamed){ if ($renamed) {
echo "{$count}/{$total} moved $filename to $newname" . PHP_EOL; echo "{$count}/{$total} moved $filename to $newname" . PHP_EOL;
}else{ } else {
echo "{$count}/{$total} fail to move $filename to $newname" . PHP_EOL; echo "{$count}/{$total} fail to move $filename to $newname" . PHP_EOL;
} }
} }
@ -63,4 +62,3 @@ exec("chown -R www-data:www-data {$videosDir}");
exec("chmod -R 755 {$videosDir}"); exec("chmod -R 755 {$videosDir}");
echo PHP_EOL." Done! ".PHP_EOL; echo PHP_EOL." Done! ".PHP_EOL;
die(); die();

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
@ -22,7 +21,7 @@ if ($handle) {
while (($line = fgets($handle)) !== false) { while (($line = fgets($handle)) !== false) {
if (preg_match($pattern, $line, $matches)) { if (preg_match($pattern, $line, $matches)) {
//var_dump($matches); //var_dump($matches);
if(!is_dir($matches[2])){ if (!is_dir($matches[2])) {
continue; continue;
} }
$glob = glob("{$matches[1]}*"); $glob = glob("{$matches[1]}*");
@ -30,7 +29,7 @@ if ($handle) {
echo "Found total of {$totalItems} items " . PHP_EOL; echo "Found total of {$totalItems} items " . PHP_EOL;
$countItems = 0; $countItems = 0;
foreach ($glob as $file) { foreach ($glob as $file) {
if(is_dir($file)){ if (is_dir($file)) {
continue; continue;
} }
@ -46,7 +45,6 @@ if ($handle) {
$countItems++; $countItems++;
echo "[$countItems/$totalItems] move file {$file} to {$destinationFile}" . PHP_EOL; echo "[$countItems/$totalItems] move file {$file} to {$destinationFile}" . PHP_EOL;
rename($file, $destinationFile); rename($file, $destinationFile);
} }
} }
// process the line read. // process the line read.

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
@ -7,25 +6,25 @@ if (!isCommandLineInterface()) {
return die('Command Line only'); return die('Command Line only');
} }
$fileExtensions = array('mp4', 'webm', 'm3u8'); $fileExtensions = ['mp4', 'webm', 'm3u8'];
$files = array(); $files = [];
//foreach (glob("../videos/*.{" . implode(",", $fileExtensions) . "}", GLOB_BRACE) as $filename) { //foreach (glob("../videos/*.{" . implode(",", $fileExtensions) . "}", GLOB_BRACE) as $filename) {
foreach (glob("../videos/*", GLOB_BRACE) as $filename) { foreach (glob("../videos/*", GLOB_BRACE) as $filename) {
$base = basename($filename); $base = basename($filename);
if (is_dir($filename)) { if (is_dir($filename)) {
if (strpos($base, "_YPTuniqid_") !== false) { if (strpos($base, "_YPTuniqid_") !== false) {
$files[$base] = array($base, $filename); $files[$base] = [$base, $filename];
} }
} else { } else {
$types = array('_HD', '_Low', '_SD'); $types = ['_HD', '_Low', '_SD'];
$notFound = true; $notFound = true;
foreach ($types as $value) { foreach ($types as $value) {
$baseName = explode($value, $base); $baseName = explode($value, $base);
if (!empty($baseName[1])) { if (!empty($baseName[1])) {
$files[$base] = array($baseName[0], $filename); $files[$base] = [$baseName[0], $filename];
$notFound = false; $notFound = false;
} }
} }
@ -37,7 +36,7 @@ foreach (glob("../videos/*", GLOB_BRACE) as $filename) {
$baseName = str_replace("." . $value, "", $base); $baseName = str_replace("." . $value, "", $base);
if (!empty($baseName[1])) { if (!empty($baseName[1])) {
if (!in_array($baseName, $files)) { if (!in_array($baseName, $files)) {
$files[$base] = array($baseName, $filename); $files[$base] = [$baseName, $filename];
} }
} }
} }
@ -64,9 +63,9 @@ if (!empty($confirm) && strtolower($confirm) === 'y') {
$video = new Video($title, $value[0]); $video = new Video($title, $value[0]);
$video->setStatus(Video::$statusActive); $video->setStatus(Video::$statusActive);
$video->setUsers_id(1); $video->setUsers_id(1);
if($video->save(false, true)){ if ($video->save(false, true)) {
echo "{$count}/{$total} {$title} created\n"; echo "{$count}/{$total} {$title} created\n";
}else{ } else {
echo "{$count}/{$total} ERROR on create video {$title}\n"; echo "{$count}/{$total} ERROR on create video {$title}\n";
} }
} }

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
@ -59,7 +58,3 @@ if (empty($userName) || empty($password)) {
echo "Bye"; echo "Bye";
echo "\n"; echo "\n";
die(); die();

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/playlist.php'; require_once $global['systemRootPath'] . 'objects/playlist.php';

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/playlist.php'; require_once $global['systemRootPath'] . 'objects/playlist.php';
@ -8,12 +7,12 @@ if (!isCommandLineInterface()) {
return die('Command Line only'); return die('Command Line only');
} }
$users_ids = array(); $users_ids = [];
$sql = "SELECT distinct(users_id) as users_id FROM playlists "; $sql = "SELECT distinct(users_id) as users_id FROM playlists ";
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $key => $row) { foreach ($fullData as $key => $row) {
$users_ids[] = $row['users_id']; $users_ids[] = $row['users_id'];
@ -30,14 +29,14 @@ foreach ($users_ids as $user_id) {
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $key => $row) { foreach ($fullData as $key => $row) {
if ($key === 0) { if ($key === 0) {
continue; continue;
} }
if(!empty(PlayList::getVideosIDFromPlaylistLight($row['id']))){ if (!empty(PlayList::getVideosIDFromPlaylistLight($row['id']))) {
continue; continue;
} }
@ -46,7 +45,7 @@ foreach ($users_ids as $user_id) {
echo $sql." = {$row['id']}\n"; echo $sql." = {$row['id']}\n";
ob_flush(); ob_flush();
sqlDAL::writeSql($sql, "i", array($row['id'])); sqlDAL::writeSql($sql, "i", [$row['id']]);
} }
} else { } else {
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
@ -59,7 +58,7 @@ foreach ($users_ids as $user_id) {
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $key => $row) { foreach ($fullData as $key => $row) {
if ($key === 0) { if ($key === 0) {
@ -69,10 +68,9 @@ foreach ($users_ids as $user_id) {
$sql .= " WHERE id = ?"; $sql .= " WHERE id = ?";
echo $sql." = {$row['id']}\n"; echo $sql." = {$row['id']}\n";
ob_flush(); ob_flush();
sqlDAL::writeSql($sql, "i", array($row['id'])); sqlDAL::writeSql($sql, "i", [$row['id']]);
} }
} else { } else {
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
} }
} }

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/playlist.php'; require_once $global['systemRootPath'] . 'objects/playlist.php';
@ -10,12 +9,12 @@ if (!isCommandLineInterface()) {
echo "Start fixing statistics" . PHP_EOL; echo "Start fixing statistics" . PHP_EOL;
$session_id = array(); $session_id = [];
$sql = "SELECT distinct(session_id) as session_id FROM videos_statistics "; $sql = "SELECT distinct(session_id) as session_id FROM videos_statistics ";
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $key => $row) { foreach ($fullData as $key => $row) {
$session_id[] = $row['session_id']; $session_id[] = $row['session_id'];
@ -33,7 +32,7 @@ foreach ($session_id as $id) {
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $row) { foreach ($fullData as $row) {
$sql2 = "SELECT id FROM videos_statistics WHERE videos_id = {$row['videos_id']} AND session_id = '{$id}' ORDER BY `when` DESC LIMIT 1"; $sql2 = "SELECT id FROM videos_statistics WHERE videos_id = {$row['videos_id']} AND session_id = '{$id}' ORDER BY `when` DESC LIMIT 1";

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/playlist.php'; require_once $global['systemRootPath'] . 'objects/playlist.php';
@ -22,18 +21,18 @@ if ($option == 1) {
sqlDAL::writeSql($sql); sqlDAL::writeSql($sql);
echo "* Reset all plugins Parameters DONE\n"; echo "* Reset all plugins Parameters DONE\n";
ob_flush(); ob_flush();
} else if ($option == 2) { } elseif ($option == 2) {
$sql = "UPDATE plugins "; $sql = "UPDATE plugins ";
$sql .= " SET object_data = '' WHERE name = 'CustomizeUser'"; $sql .= " SET object_data = '' WHERE name = 'CustomizeUser'";
sqlDAL::writeSql($sql); sqlDAL::writeSql($sql);
echo "* Reset CustomizeUser Plugin Parameters only DONE\n"; echo "* Reset CustomizeUser Plugin Parameters only DONE\n";
ob_flush(); ob_flush();
} else if ($option == 3) { } elseif ($option == 3) {
$sql = "DELETE FROM plugins "; $sql = "DELETE FROM plugins ";
$sql .= " WHERE id > 0"; $sql .= " WHERE id > 0";
sqlDAL::writeSql($sql); sqlDAL::writeSql($sql);
echo "* Reset all plugins (All plugins inactivated) DONE\n"; echo "* Reset all plugins (All plugins inactivated) DONE\n";
ob_flush(); ob_flush();
}else{ } else {
echo "Bye\n"; echo "Bye\n";
} }

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
@ -18,7 +17,7 @@ $videos = Video::getAllVideosLight("", false, true, false);
echo "Path: {$path}" . PHP_EOL; echo "Path: {$path}" . PHP_EOL;
$sites_id_to_check = array(); $sites_id_to_check = [];
foreach ($videos as $value) { foreach ($videos as $value) {
if ($value['status'] !== Video::$statusBrokenMissingFiles) { if ($value['status'] !== Video::$statusBrokenMissingFiles) {
@ -30,17 +29,17 @@ foreach ($videos as $value) {
$total = count($sites_id_to_check); $total = count($sites_id_to_check);
foreach ($sites_id_to_check as $key => $value) { foreach ($sites_id_to_check as $key => $value) {
if(!empty($index) && $key<$index){ if (!empty($index) && $key<$index) {
continue; continue;
} }
$video = new Video('', '', $value); $video = new Video('', '', $value);
$filename = $video->getFilename(); $filename = $video->getFilename();
echo "{$key}/{$total} Start check {$filename} " . PHP_EOL; echo "{$key}/{$total} Start check {$filename} " . PHP_EOL;
if(Video::isMediaFileMissing($filename)){ if (Video::isMediaFileMissing($filename)) {
$sources = getVideosURL_V2($filename); $sources = getVideosURL_V2($filename);
echo "{$key}/{$total} is missing ". json_encode($sources) . PHP_EOL; echo "{$key}/{$total} is missing ". json_encode($sources) . PHP_EOL;
}else{ } else {
$video->setStatus(Video::$statusActive); $video->setStatus(Video::$statusActive);
echo "{$key}/{$total} is set to active " . PHP_EOL; echo "{$key}/{$total} is set to active " . PHP_EOL;
} }

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
AVideoPlugin::loadPlugin('YPTStorage'); AVideoPlugin::loadPlugin('YPTStorage');

View file

@ -2,22 +2,18 @@
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
if(!isCommandLineInterface()){ if (!isCommandLineInterface()) {
return die('Command Line only'); return die('Command Line only');
} }
$global['rowCount'] = 99999; $global['rowCount'] = 99999;
$total = Video::getTotalVideos("",false, true, true, false, false); $total = Video::getTotalVideos("", false, true, true, false, false);
$videos = Video::getAllVideosLight("", false, true, false); $videos = Video::getAllVideosLight("", false, true, false);
$count = 0; $count = 0;
foreach ($videos as $value){ foreach ($videos as $value) {
$count++; $count++;
$updated = Video::updateFilesize($value['id']); $updated = Video::updateFilesize($value['id']);
echo "{$count}/{$total} (".($updated?"success":"fail").") [{$value['id']}] {$value['title']}".PHP_EOL; echo "{$count}/{$total} (".($updated ? "success" : "fail").") [{$value['id']}] {$value['title']}".PHP_EOL;
ob_flush(); ob_flush();
} }
die(); die();

View file

@ -2,7 +2,7 @@
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
if(!isCommandLineInterface()){ if (!isCommandLineInterface()) {
return die('Command Line only'); return die('Command Line only');
} }
echo "Enter the new Streamer URL or press enter to skip:"; echo "Enter the new Streamer URL or press enter to skip:";
@ -10,9 +10,9 @@ echo "\n";
ob_flush(); ob_flush();
$streamerURL = trim(readline("")); $streamerURL = trim(readline(""));
if(!empty($streamerURL)){ if (!empty($streamerURL)) {
if (substr($streamerURL, -1) !== '/') { if (substr($streamerURL, -1) !== '/') {
$streamerURL.="/"; $streamerURL.="/";
} }
$global['webSiteRootURL'] = $streamerURL; $global['webSiteRootURL'] = $streamerURL;
echo "Rewrite Streamer Config File\n"; echo "Rewrite Streamer Config File\n";
@ -25,7 +25,7 @@ if(!empty($streamerURL)){
$encoderConfigFile = "{$global['systemRootPath']}Encoder/videos/configuration.php"; $encoderConfigFile = "{$global['systemRootPath']}Encoder/videos/configuration.php";
echo "Checking encoder in {$encoderConfigFile}\n"; echo "Checking encoder in {$encoderConfigFile}\n";
if(file_exists($encoderConfigFile)){ if (file_exists($encoderConfigFile)) {
echo "Encoder found in {$encoderConfigFile}\n"; echo "Encoder found in {$encoderConfigFile}\n";
require_once $encoderConfigFile; require_once $encoderConfigFile;
// change the encoder database for admin user // change the encoder database for admin user
@ -35,10 +35,7 @@ if(file_exists($encoderConfigFile)){
echo "Encoder Update streamers set siteURL\n"; echo "Encoder Update streamers set siteURL\n";
$sql = "update streamers set siteURL = '{$streamerURL}';"; $sql = "update streamers set siteURL = '{$streamerURL}';";
$global['mysqli']->query($sql); $global['mysqli']->query($sql);
// change the encoder config file // change the encoder config file
}else{ } else {
echo "Encoder not found in {$encoderConfigFile}\n"; echo "Encoder not found in {$encoderConfigFile}\n";
} }

View file

@ -1,5 +1,4 @@
<?php <?php
//streamer config //streamer config
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
@ -13,7 +12,8 @@ ini_set('display_errors', 1);
ini_set('display_startup_errors', 1); ini_set('display_startup_errors', 1);
error_reporting(E_ALL); error_reporting(E_ALL);
function currentVersionLowerThen($currentversion, $oldversion) { function currentVersionLowerThen($currentversion, $oldversion)
{
return version_compare($currentversion, $oldversion) > 0; return version_compare($currentversion, $oldversion) > 0;
} }
@ -23,19 +23,19 @@ $currentVersion = $config->getVersion();
echo "Searching on ({$updateDir}) for updates greater then {$currentVersion}" . PHP_EOL; echo "Searching on ({$updateDir}) for updates greater then {$currentVersion}" . PHP_EOL;
global $global; global $global;
$files1 = scandir($updateDir); $files1 = scandir($updateDir);
$updateFiles = array(); $updateFiles = [];
foreach ($files1 as $value) { foreach ($files1 as $value) {
preg_match("/updateDb.v([0-9.]*).sql/", $value, $match); preg_match("/updateDb.v([0-9.]*).sql/", $value, $match);
if (!empty($match)) { if (!empty($match)) {
if (currentVersionLowerThen($match[1], $currentVersion)) { if (currentVersionLowerThen($match[1], $currentVersion)) {
$updateFiles[] = array('filename' => $match[0], 'version' => $match[1]); $updateFiles[] = ['filename' => $match[0], 'version' => $match[1]];
} }
} }
} }
if (empty($updateFiles)) { if (empty($updateFiles)) {
echo "No new update files found on ({$updateDir})" . PHP_EOL; echo "No new update files found on ({$updateDir})" . PHP_EOL;
}else{ } else {
echo "Found ".count($updateDir)." updats" . PHP_EOL; echo "Found ".count($updateDir)." updats" . PHP_EOL;
} }
@ -44,12 +44,13 @@ foreach ($updateFiles as $value) {
$lines = file("{$updateDir}{$value['filename']}"); $lines = file("{$updateDir}{$value['filename']}");
foreach ($lines as $line) { foreach ($lines as $line) {
if (substr($line, 0, 2) == '--' || $line == '') if (substr($line, 0, 2) == '--' || $line == '') {
continue; continue;
}
$templine .= $line; $templine .= $line;
if (substr(trim($line), -1, 1) == ';') { if (substr(trim($line), -1, 1) == ';') {
if (!$global['mysqli']->query($templine)) { if (!$global['mysqli']->query($templine)) {
echo ('Error performing query ' . $templine . ': ' . $global['mysqli']->error . PHP_EOL); echo('Error performing query ' . $templine . ': ' . $global['mysqli']->error . PHP_EOL);
//exit; //exit;
} }
$templine = ''; $templine = '';
@ -59,4 +60,3 @@ foreach ($updateFiles as $value) {
echo PHP_EOL . " Done! " . PHP_EOL; echo PHP_EOL . " Done! " . PHP_EOL;
die(); die();

View file

@ -18,12 +18,12 @@ class Channel
if ($activeOnly) { if ($activeOnly) {
$sql .= " AND u.status = 'a' "; $sql .= " AND u.status = 'a' ";
} }
$sql .= BootGrid::getSqlFromPost(array('user', 'about', 'channelName', 'u.name', 'u.email'), "", "", false, $FIND_IN_SET); $sql .= BootGrid::getSqlFromPost(['user', 'about', 'channelName', 'u.name', 'u.email'], "", "", false, $FIND_IN_SET);
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$fullResult = sqlDAL::fetchAllAssoc($res); $fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$subscribe = array(); $subscribe = [];
if ($res != false) { if ($res != false) {
foreach ($fullResult as $row) { foreach ($fullResult as $row) {
$row = cleanUpRowFromDatabase($row); $row = cleanUpRowFromDatabase($row);
@ -46,7 +46,7 @@ class Channel
if ($activeOnly) { if ($activeOnly) {
$sql .= " AND u.status = 'a' "; $sql .= " AND u.status = 'a' ";
} }
$sql .= BootGrid::getSqlFromPost(array('user', 'about')); $sql .= BootGrid::getSqlFromPost(['user', 'about']);
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$data = sqlDAL::fetchAssoc($res); $data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);

View file

@ -221,57 +221,57 @@ class Mobile_Detect
* *
* @deprecated since version 2.6.9 * @deprecated since version 2.6.9
*/ */
const DETECTION_TYPE_MOBILE = 'mobile'; public const DETECTION_TYPE_MOBILE = 'mobile';
/** /**
* Extended detection type. * Extended detection type.
* *
* @deprecated since version 2.6.9 * @deprecated since version 2.6.9
*/ */
const DETECTION_TYPE_EXTENDED = 'extended'; public const DETECTION_TYPE_EXTENDED = 'extended';
/** /**
* A frequently used regular expression to extract version #s. * A frequently used regular expression to extract version #s.
* *
* @deprecated since version 2.6.9 * @deprecated since version 2.6.9
*/ */
const VER = '([\w._\+]+)'; public const VER = '([\w._\+]+)';
/** /**
* Top-level device. * Top-level device.
*/ */
const MOBILE_GRADE_A = 'A'; public const MOBILE_GRADE_A = 'A';
/** /**
* Mid-level device. * Mid-level device.
*/ */
const MOBILE_GRADE_B = 'B'; public const MOBILE_GRADE_B = 'B';
/** /**
* Low-level device. * Low-level device.
*/ */
const MOBILE_GRADE_C = 'C'; public const MOBILE_GRADE_C = 'C';
/** /**
* Stores the version number of the current release. * Stores the version number of the current release.
*/ */
const VERSION = '2.8.37'; public const VERSION = '2.8.37';
/** /**
* A type for the version() method indicating a string return value. * A type for the version() method indicating a string return value.
*/ */
const VERSION_TYPE_STRING = 'text'; public const VERSION_TYPE_STRING = 'text';
/** /**
* A type for the version() method indicating a float return value. * A type for the version() method indicating a float return value.
*/ */
const VERSION_TYPE_FLOAT = 'float'; public const VERSION_TYPE_FLOAT = 'float';
/** /**
* A cache for resolved matches * A cache for resolved matches
* @var array * @var array
*/ */
protected $cache = array(); protected $cache = [];
/** /**
* The User-Agent HTTP header is stored in here. * The User-Agent HTTP header is stored in here.
@ -283,13 +283,13 @@ class Mobile_Detect
* HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE. * HTTP headers in the PHP-flavor. So HTTP_USER_AGENT and SERVER_SOFTWARE.
* @var array * @var array
*/ */
protected $httpHeaders = array(); protected $httpHeaders = [];
/** /**
* CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer. * CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
* @var array * @var array
*/ */
protected $cloudfrontHeaders = array(); protected $cloudfrontHeaders = [];
/** /**
* The matching Regex. * The matching Regex.
@ -321,16 +321,16 @@ class Mobile_Detect
* *
* @var array * @var array
*/ */
protected static $mobileHeaders = array( protected static $mobileHeaders = [
'HTTP_ACCEPT' => array('matches' => array( 'HTTP_ACCEPT' => ['matches' => [
// Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/ // Opera Mini; @reference: http://dev.opera.com/articles/view/opera-binary-markup-language/
'application/x-obml2d', 'application/x-obml2d',
// BlackBerry devices. // BlackBerry devices.
'application/vnd.rim.html', 'application/vnd.rim.html',
'text/vnd.wap.wml', 'text/vnd.wap.wml',
'application/vnd.wap.xhtml+xml' 'application/vnd.wap.xhtml+xml',
)), ]],
'HTTP_X_WAP_PROFILE' => null, 'HTTP_X_WAP_PROFILE' => null,
'HTTP_X_WAP_CLIENTID' => null, 'HTTP_X_WAP_CLIENTID' => null,
'HTTP_WAP_CONNECTION' => null, 'HTTP_WAP_CONNECTION' => null,
@ -348,15 +348,15 @@ class Mobile_Detect
// Seen this on HTC Sensation. SensationXE_Beats_Z715e. // Seen this on HTC Sensation. SensationXE_Beats_Z715e.
'HTTP_X_ATT_DEVICEID' => null, 'HTTP_X_ATT_DEVICEID' => null,
// Seen this on a HTC. // Seen this on a HTC.
'HTTP_UA_CPU' => array('matches' => array('ARM')), 'HTTP_UA_CPU' => ['matches' => ['ARM']],
); ];
/** /**
* List of mobile devices (phones). * List of mobile devices (phones).
* *
* @var array * @var array
*/ */
protected static $phoneDevices = array( protected static $phoneDevices = [
'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes 'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+|\b(BBA100|BBB100|BBD100|BBE100|BBF100|STH100)\b-[0-9]+', 'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+|\b(BBA100|BBB100|BBD100|BBE100|BBF100|STH100)\b-[0-9]+',
'Pixel' => '; \bPixel\b', 'Pixel' => '; \bPixel\b',
@ -400,14 +400,14 @@ class Mobile_Detect
'OnePlus' => 'ONEPLUS', 'OnePlus' => 'ONEPLUS',
// @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039 // @Tapatalk is a mobile app; http://support.tapatalk.com/threads/smf-2-0-2-os-and-browser-detection-plugin-and-tapatalk.15565/#post-79039
'GenericPhone' => 'Tapatalk|PDA;|SAGEM|\bmmp\b|pocket|\bpsp\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\bwap\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser', 'GenericPhone' => 'Tapatalk|PDA;|SAGEM|\bmmp\b|pocket|\bpsp\b|symbian|Smartphone|smartfon|treo|up.browser|up.link|vodafone|\bwap\b|nokia|Series40|Series60|S60|SonyEricsson|N900|MAUI.*WAP.*Browser',
); ];
/** /**
* List of tablet devices. * List of tablet devices.
* *
* @var array * @var array
*/ */
protected static $tabletDevices = array( protected static $tabletDevices = [
// @todo: check for mobile friendly emails topic. // @todo: check for mobile friendly emails topic.
'iPad' => 'iPad|iPad.*Mobile', 'iPad' => 'iPad|iPad.*Mobile',
// Removed |^.*Android.*Nexus(?!(?:Mobile).)*$ // Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
@ -667,15 +667,15 @@ class Mobile_Detect
'Hudl' => 'Hudl HT7S3|Hudl 2', 'Hudl' => 'Hudl HT7S3|Hudl 2',
// http://www.telstra.com.au/home-phone/thub-2/ // http://www.telstra.com.au/home-phone/thub-2/
'TelstraTablet' => 'T-Hub2', 'TelstraTablet' => 'T-Hub2',
'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\bM6pro\b|CT1020W|arc 10HD|\bTP750\b|\bQTAQZ3\b|WVT101|TM1088|KT107' 'GenericTablet' => 'Android.*\b97D\b|Tablet(?!.*PC)|BNTV250A|MID-WCDMA|LogicPD Zoom2|\bA7EB\b|CatNova8|A1_07|CT704|CT1002|\bM721\b|rk30sdk|\bEVOTAB\b|M758A|ET904|ALUMIUM10|Smartfren Tab|Endeavour 1010|Tablet-PC-4|Tagi Tab|\bM6pro\b|CT1020W|arc 10HD|\bTP750\b|\bQTAQZ3\b|WVT101|TM1088|KT107',
); ];
/** /**
* List of mobile Operating Systems. * List of mobile Operating Systems.
* *
* @var array * @var array
*/ */
protected static $operatingSystems = array( protected static $operatingSystems = [
'AndroidOS' => 'Android', 'AndroidOS' => 'Android',
'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os', 'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino', 'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
@ -704,7 +704,7 @@ class Mobile_Detect
'webOS' => 'webOS|hpwOS', 'webOS' => 'webOS|hpwOS',
'badaOS' => '\bBada\b', 'badaOS' => '\bBada\b',
'BREWOS' => 'BREW', 'BREWOS' => 'BREW',
); ];
/** /**
* List of mobile User Agents. * List of mobile User Agents.
@ -716,7 +716,7 @@ class Mobile_Detect
* *
* @var array * @var array
*/ */
protected static $browsers = array( protected static $browsers = [
//'Vivaldi' => 'Vivaldi', //'Vivaldi' => 'Vivaldi',
// @reference: https://developers.google.com/chrome/mobile/docs/user-agent // @reference: https://developers.google.com/chrome/mobile/docs/user-agent
'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?', 'Chrome' => '\bCrMo\b|CriOS|Android.*Chrome/[.0-9]* (Mobile)?',
@ -756,14 +756,14 @@ class Mobile_Detect
'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger', 'GenericBrowser' => 'NokiaBrowser|OviBrowser|OneBrowser|TwonkyBeamBrowser|SEMC.*Browser|FlyFlow|Minimo|NetFront|Novarra-Vision|MQQBrowser|MicroMessenger',
// @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser) // @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon', 'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
); ];
/** /**
* Utilities. * Utilities.
* *
* @var array * @var array
*/ */
protected static $utilities = array( protected static $utilities = [
// Experimental. When a mobile device wants to switch to 'Desktop Mode'. // Experimental. When a mobile device wants to switch to 'Desktop Mode'.
// http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/ // http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
// https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011 // https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
@ -776,7 +776,7 @@ class Mobile_Detect
// @todo: Include JXD consoles. // @todo: Include JXD consoles.
'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|Nintendo Switch|PLAYSTATION|Xbox)\b', 'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|Nintendo Switch|PLAYSTATION|Xbox)\b',
'Watch' => 'SM-V700', 'Watch' => 'SM-V700',
); ];
/** /**
* All possible HTTP headers that represent the * All possible HTTP headers that represent the
@ -784,7 +784,7 @@ class Mobile_Detect
* *
* @var array * @var array
*/ */
protected static $uaHttpHeaders = array( protected static $uaHttpHeaders = [
// The default User-Agent string. // The default User-Agent string.
'HTTP_USER_AGENT', 'HTTP_USER_AGENT',
// Header can occur on devices using Opera Mini. // Header can occur on devices using Opera Mini.
@ -795,8 +795,8 @@ class Mobile_Detect
'HTTP_X_SKYFIRE_PHONE', 'HTTP_X_SKYFIRE_PHONE',
'HTTP_X_BOLT_PHONE_UA', 'HTTP_X_BOLT_PHONE_UA',
'HTTP_DEVICE_STOCK_UA', 'HTTP_DEVICE_STOCK_UA',
'HTTP_X_UCBROWSER_DEVICE_UA' 'HTTP_X_UCBROWSER_DEVICE_UA',
); ];
/** /**
* The individual segments that could exist in a User-Agent string. VER refers to the regular * The individual segments that could exist in a User-Agent string. VER refers to the regular
@ -804,7 +804,7 @@ class Mobile_Detect
* *
* @var array * @var array
*/ */
protected static $properties = array( protected static $properties = [
// Build // Build
'Mobile' => 'Mobile/[VER]', 'Mobile' => 'Mobile/[VER]',
@ -820,23 +820,23 @@ class Mobile_Detect
'Kindle' => 'Kindle/[VER]', 'Kindle' => 'Kindle/[VER]',
// Browser // Browser
'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'), 'Chrome' => ['Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'],
'Coast' => array('Coast/[VER]'), 'Coast' => ['Coast/[VER]'],
'Dolfin' => 'Dolfin/[VER]', 'Dolfin' => 'Dolfin/[VER]',
// @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox // @reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent/Firefox
'Firefox' => array('Firefox/[VER]', 'FxiOS/[VER]'), 'Firefox' => ['Firefox/[VER]', 'FxiOS/[VER]'],
'Fennec' => 'Fennec/[VER]', 'Fennec' => 'Fennec/[VER]',
// http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx // http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
// https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx // https://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
'Edge' => 'Edge/[VER]', 'Edge' => 'Edge/[VER]',
'IE' => array('IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'), 'IE' => ['IEMobile/[VER];', 'IEMobile [VER]', 'MSIE [VER];', 'Trident/[0-9.]+;.*rv:[VER]'],
// http://en.wikipedia.org/wiki/NetFront // http://en.wikipedia.org/wiki/NetFront
'NetFront' => 'NetFront/[VER]', 'NetFront' => 'NetFront/[VER]',
'NokiaBrowser' => 'NokiaBrowser/[VER]', 'NokiaBrowser' => 'NokiaBrowser/[VER]',
'Opera' => array( ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ), 'Opera' => [ ' OPR/[VER]', 'Opera Mini/[VER]', 'Version/[VER]' ],
'Opera Mini' => 'Opera Mini/[VER]', 'Opera Mini' => 'Opera Mini/[VER]',
'Opera Mobi' => 'Version/[VER]', 'Opera Mobi' => 'Version/[VER]',
'UCBrowser' => array( 'UCWEB[VER]', 'UC.*Browser/[VER]' ), 'UCBrowser' => [ 'UCWEB[VER]', 'UC.*Browser/[VER]' ],
'MQQBrowser' => 'MQQBrowser/[VER]', 'MQQBrowser' => 'MQQBrowser/[VER]',
'MicroMessenger' => 'MicroMessenger/[VER]', 'MicroMessenger' => 'MicroMessenger/[VER]',
'baiduboxapp' => 'baiduboxapp/[VER]', 'baiduboxapp' => 'baiduboxapp/[VER]',
@ -845,7 +845,7 @@ class Mobile_Detect
'Iron' => 'Iron/[VER]', 'Iron' => 'Iron/[VER]',
// @note: Safari 7534.48.3 is actually Version 5.1. // @note: Safari 7534.48.3 is actually Version 5.1.
// @note: On BlackBerry the Version is overwriten by the OS. // @note: On BlackBerry the Version is overwriten by the OS.
'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ), 'Safari' => [ 'Version/[VER]', 'Safari/[VER]' ],
'Skyfire' => 'Skyfire/[VER]', 'Skyfire' => 'Skyfire/[VER]',
'Tizen' => 'Tizen/[VER]', 'Tizen' => 'Tizen/[VER]',
'Webkit' => 'webkit[ /][VER]', 'Webkit' => 'webkit[ /][VER]',
@ -862,19 +862,19 @@ class Mobile_Detect
'iOS' => ' \bi?OS\b [VER][ ;]{1}', 'iOS' => ' \bi?OS\b [VER][ ;]{1}',
'Android' => 'Android [VER]', 'Android' => 'Android [VER]',
'Sailfish' => 'Sailfish [VER]', 'Sailfish' => 'Sailfish [VER]',
'BlackBerry' => array('BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'), 'BlackBerry' => ['BlackBerry[\w]+/[VER]', 'BlackBerry.*Version/[VER]', 'Version/[VER]'],
'BREW' => 'BREW [VER]', 'BREW' => 'BREW [VER]',
'Java' => 'Java/[VER]', 'Java' => 'Java/[VER]',
// @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx // @reference: http://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/08/29/introducing-the-ie9-on-windows-phone-mango-user-agent-string.aspx
// @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases // @reference: http://en.wikipedia.org/wiki/Windows_NT#Releases
'Windows Phone OS' => array( 'Windows Phone OS [VER]', 'Windows Phone [VER]'), 'Windows Phone OS' => [ 'Windows Phone OS [VER]', 'Windows Phone [VER]'],
'Windows Phone' => 'Windows Phone [VER]', 'Windows Phone' => 'Windows Phone [VER]',
'Windows CE' => 'Windows CE/[VER]', 'Windows CE' => 'Windows CE/[VER]',
// http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd // http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
'Windows NT' => 'Windows NT [VER]', 'Windows NT' => 'Windows NT [VER]',
'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'), 'Symbian' => ['SymbianOS/[VER]', 'Symbian/[VER]'],
'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'), 'webOS' => ['webOS/[VER]', 'hpwOS/[VER];'],
); ];
/** /**
* Construct an instance of this class. * Construct an instance of this class.
@ -919,7 +919,7 @@ class Mobile_Detect
} }
// clear existing headers // clear existing headers
$this->httpHeaders = array(); $this->httpHeaders = [];
// Only save HTTP headers. In PHP land, that means only _SERVER vars that // Only save HTTP headers. In PHP land, that means only _SERVER vars that
// start with HTTP_. // start with HTTP_.
@ -999,14 +999,15 @@ class Mobile_Detect
* *
* @return boolean If there were CloudFront headers to be set * @return boolean If there were CloudFront headers to be set
*/ */
public function setCfHeaders($cfHeaders = null) { public function setCfHeaders($cfHeaders = null)
{
// use global _SERVER if $cfHeaders aren't defined // use global _SERVER if $cfHeaders aren't defined
if (!is_array($cfHeaders) || !count($cfHeaders)) { if (!is_array($cfHeaders) || !count($cfHeaders)) {
$cfHeaders = $_SERVER; $cfHeaders = $_SERVER;
} }
// clear existing headers // clear existing headers
$this->cloudfrontHeaders = array(); $this->cloudfrontHeaders = [];
// Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that // Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
// start with cloudfront-. // start with cloudfront-.
@ -1035,7 +1036,8 @@ class Mobile_Detect
* @param string $userAgent * @param string $userAgent
* @return string * @return string
*/ */
private function prepareUserAgent($userAgent) { private function prepareUserAgent($userAgent)
{
$userAgent = trim($userAgent); $userAgent = trim($userAgent);
$userAgent = substr($userAgent, 0, 500); $userAgent = substr($userAgent, 0, 500);
return $userAgent; return $userAgent;
@ -1051,7 +1053,7 @@ class Mobile_Detect
public function setUserAgent($userAgent = null) public function setUserAgent($userAgent = null)
{ {
// Invalidate cache due to #375 // Invalidate cache due to #375
$this->cache = array(); $this->cache = [];
if (false === empty($userAgent)) { if (false === empty($userAgent)) {
return $this->userAgent = $this->prepareUserAgent($userAgent); return $this->userAgent = $this->prepareUserAgent($userAgent);
@ -1187,7 +1189,6 @@ class Mobile_Detect
} }
return $rules; return $rules;
} }
/** /**
@ -1253,7 +1254,6 @@ class Mobile_Detect
*/ */
public function checkHttpHeadersForMobile() public function checkHttpHeadersForMobile()
{ {
foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) { foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
if (isset($this->httpHeaders[$mobileHeader])) { if (isset($this->httpHeaders[$mobileHeader])) {
if (isset($matchType['matches']) && is_array($matchType['matches'])) { if (isset($matchType['matches']) && is_array($matchType['matches'])) {
@ -1271,7 +1271,6 @@ class Mobile_Detect
} }
return false; return false;
} }
/** /**
@ -1358,7 +1357,6 @@ class Mobile_Detect
*/ */
public function isMobile($userAgent = null, $httpHeaders = null) public function isMobile($userAgent = null, $httpHeaders = null)
{ {
if ($httpHeaders) { if ($httpHeaders) {
$this->setHttpHeaders($httpHeaders); $this->setHttpHeaders($httpHeaders);
} }
@ -1370,7 +1368,7 @@ class Mobile_Detect
// Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront' // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
if ($this->getUserAgent() === 'Amazon CloudFront') { if ($this->getUserAgent() === 'Amazon CloudFront') {
$cfHeaders = $this->getCfHeaders(); $cfHeaders = $this->getCfHeaders();
if(array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') { if (array_key_exists('HTTP_CLOUDFRONT_IS_MOBILE_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'] === 'true') {
return true; return true;
} }
} }
@ -1382,7 +1380,6 @@ class Mobile_Detect
} else { } else {
return $this->matchDetectionRulesAgainstUA(); return $this->matchDetectionRulesAgainstUA();
} }
} }
/** /**
@ -1398,7 +1395,7 @@ class Mobile_Detect
// Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront' // Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
if ($this->getUserAgent() === 'Amazon CloudFront') { if ($this->getUserAgent() === 'Amazon CloudFront') {
$cfHeaders = $this->getCfHeaders(); $cfHeaders = $this->getCfHeaders();
if(array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') { if (array_key_exists('HTTP_CLOUDFRONT_IS_TABLET_VIEWER', $cfHeaders) && $cfHeaders['HTTP_CLOUDFRONT_IS_TABLET_VIEWER'] === 'true') {
return true; return true;
} }
} }
@ -1488,7 +1485,7 @@ class Mobile_Detect
*/ */
public function prepareVersionNo($ver) public function prepareVersionNo($ver)
{ {
$ver = str_replace(array('_', ' ', '/'), '.', $ver); $ver = str_replace(['_', ' ', '/'], '.', $ver);
$arrVer = explode('.', $ver, 2); $arrVer = explode('.', $ver, 2);
if (isset($arrVer[1])) { if (isset($arrVer[1])) {
@ -1532,7 +1529,6 @@ class Mobile_Detect
$properties[$propertyName] = (array) $properties[$propertyName]; $properties[$propertyName] = (array) $properties[$propertyName];
foreach ($properties[$propertyName] as $propertyMatchString) { foreach ($properties[$propertyName] as $propertyMatchString) {
$propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString); $propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
// Identify and extract the version. // Identify and extract the version.
@ -1543,9 +1539,7 @@ class Mobile_Detect
return $version; return $version;
} }
} }
} }
return false; return false;
@ -1570,7 +1564,7 @@ class Mobile_Detect
// Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM // Android 3.1 (Honeycomb) - Tested on the Samsung Galaxy Tab 10.1 and Motorola XOOM
// Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices // Android 4.0 (ICS) - Tested on a Galaxy Nexus. Note: transition performance can be poor on upgraded devices
// Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7 // Android 4.1 (Jelly Bean) - Tested on a Galaxy Nexus and Galaxy 7
( $this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit') ) || ($this->version('Android', self::VERSION_TYPE_FLOAT)>2.1 && $this->is('Webkit')) ||
// Windows Phone 7.5-8 - Tested on the HTC Surround (7.5), HTC Trophy (7.5), LG-E900 (7.5), Nokia 800 (7.8), HTC Mazaa (7.8), Nokia Lumia 520 (8), Nokia Lumia 920 (8), HTC 8x (8) // Windows Phone 7.5-8 - Tested on the HTC Surround (7.5), HTC Trophy (7.5), LG-E900 (7.5), Nokia 800 (7.8), HTC Mazaa (7.8), Nokia Lumia 520 (8), Nokia Lumia 920 (8), HTC 8x (8)
$this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 || $this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
@ -1581,21 +1575,21 @@ class Mobile_Detect
$this->match('Playbook.*Tablet') || $this->match('Playbook.*Tablet') ||
// Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0) // Palm WebOS (1.4-3.0) - Tested on the Palm Pixi (1.4), Pre (1.4), Pre 2 (2.0), HP TouchPad (3.0)
( $this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi') ) || ($this->version('webOS', self::VERSION_TYPE_FLOAT) >= 1.4 && $this->match('Palm|Pre|Pixi')) ||
// Palm WebOS 3.0 - Tested on HP TouchPad // Palm WebOS 3.0 - Tested on HP TouchPad
$this->match('hp.*TouchPad') || $this->match('hp.*TouchPad') ||
// Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices // Firefox Mobile 18 - Tested on Android 2.3 and 4.1 devices
( $this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18 ) || ($this->is('Firefox') && $this->version('Firefox', self::VERSION_TYPE_FLOAT) >= 18) ||
// Chrome for Android - Tested on Android 4.0, 4.1 device // Chrome for Android - Tested on Android 4.0, 4.1 device
( $this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0 ) || ($this->is('Chrome') && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 4.0) ||
// Skyfire 4.1 - Tested on Android 2.3 device // Skyfire 4.1 - Tested on Android 2.3 device
( $this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) || ($this->is('Skyfire') && $this->version('Skyfire', self::VERSION_TYPE_FLOAT) >= 4.1 && $this->is('AndroidOS') && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3) ||
// Opera Mobile 11.5-12: Tested on Android 2.3 // Opera Mobile 11.5-12: Tested on Android 2.3
( $this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS') ) || ($this->is('Opera') && $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11.5 && $this->is('AndroidOS')) ||
// Meego 1.2 - Tested on Nokia 950 and N9 // Meego 1.2 - Tested on Nokia 950 and N9
$this->is('MeeGoOS') || $this->is('MeeGoOS') ||
@ -1611,11 +1605,11 @@ class Mobile_Detect
$this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 || $this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
// UC Browser - Tested on Android 2.3 device // UC Browser - Tested on Android 2.3 device
( ($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 ) || (($this->is('UC Browser') || $this->is('Dolfin')) && $this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3) ||
// Kindle 3 and Fire - Tested on the built-in WebKit browser for each // Kindle 3 and Fire - Tested on the built-in WebKit browser for each
( $this->match('Kindle Fire') || ($this->match('Kindle Fire') ||
$this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) || $this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0) ||
// Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet // Nook Color 1.4.1 - Tested on original Nook Color, not Nook Tablet
$this->is('AndroidOS') && $this->is('NookTablet') || $this->is('AndroidOS') && $this->is('NookTablet') ||
@ -1634,7 +1628,7 @@ class Mobile_Detect
// Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7 // Opera Desktop 10-12 - Tested on OS X 10.7 and Windows 7
$this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile $this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
){ ) {
return self::MOBILE_GRADE_A; return self::MOBILE_GRADE_A;
} }
@ -1648,14 +1642,14 @@ class Mobile_Detect
//Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3 //Opera Mini (5.0-6.5) - Tested on iOS 3.2/4.3 and Android 2.3
($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 && ($this->version('Opera Mini', self::VERSION_TYPE_FLOAT) >= 5.0 && $this->version('Opera Mini', self::VERSION_TYPE_FLOAT) <= 7.0 &&
($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS')) ) || ($this->version('Android', self::VERSION_TYPE_FLOAT) >= 2.3 || $this->is('iOS'))) ||
// Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1) // Nokia Symbian^3 - Tested on Nokia N8 (Symbian^3), C7 (Symbian^3), also works on N97 (Symbian^1)
$this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') || $this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
// @todo: report this (tested on Nokia N71) // @todo: report this (tested on Nokia N71)
$this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS') $this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
){ ) {
return self::MOBILE_GRADE_B; return self::MOBILE_GRADE_B;
} }
@ -1672,7 +1666,7 @@ class Mobile_Detect
// Internet Explorer 7 and older - Tested on Windows XP // Internet Explorer 7 and older - Tested on Windows XP
$this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile $this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
){ ) {
return self::MOBILE_GRADE_C; return self::MOBILE_GRADE_C;
} }

View file

@ -1,26 +1,27 @@
<?php <?php
interface ObjectInterface
interface ObjectInterface { {
public static function getTableName(); public static function getTableName();
public static function getSearchFieldsNames(); public static function getSearchFieldsNames();
} }
$tableExists = array(); $tableExists = [];
abstract class ObjectYPT implements ObjectInterface { abstract class ObjectYPT implements ObjectInterface
{
protected $fieldsName = [];
protected $fieldsName = array(); public function __construct($id = "")
{
public function __construct($id = "") {
if (!empty($id)) { if (!empty($id)) {
// get data from id // get data from id
$this->load($id); $this->load($id);
} }
} }
protected function load($id) { protected function load($id)
{
$row = self::getFromDb($id); $row = self::getFromDb($id);
if (empty($row)) { if (empty($row)) {
return false; return false;
@ -31,7 +32,8 @@ abstract class ObjectYPT implements ObjectInterface {
return true; return true;
} }
public static function getNowFromDB() { public static function getNowFromDB()
{
global $global; global $global;
$sql = "SELECT NOW() as my_date_field"; $sql = "SELECT NOW() as my_date_field";
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
@ -45,7 +47,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $row; return $row;
} }
public static function setGlobalTimeZone() { public static function setGlobalTimeZone()
{
global $advancedCustom, $timezoneOriginal; global $advancedCustom, $timezoneOriginal;
if (!isset($timezoneOriginal)) { if (!isset($timezoneOriginal)) {
$timezoneOriginal = date_default_timezone_get(); $timezoneOriginal = date_default_timezone_get();
@ -62,12 +65,13 @@ abstract class ObjectYPT implements ObjectInterface {
date_default_timezone_set($timezone); date_default_timezone_set($timezone);
} }
protected static function getFromDb($id) { protected static function getFromDb($id)
{
global $global; global $global;
$id = intval($id); $id = intval($id);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE id = ? LIMIT 1"; $sql = "SELECT * FROM " . static::getTableName() . " WHERE id = ? LIMIT 1";
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about // I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
$res = sqlDAL::readSql($sql, "i", array($id), true); $res = sqlDAL::readSql($sql, "i", [$id], true);
$data = sqlDAL::fetchAssoc($res); $data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if ($res) { if ($res) {
@ -78,7 +82,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $row; return $row;
} }
public static function getAll() { public static function getAll()
{
global $global; global $global;
if (!static::isTableInstalled()) { if (!static::isTableInstalled()) {
return false; return false;
@ -89,7 +94,7 @@ abstract class ObjectYPT implements ObjectInterface {
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $row) { foreach ($fullData as $row) {
$rows[] = $row; $rows[] = $row;
@ -100,7 +105,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $rows; return $rows;
} }
public static function getAllActive() { public static function getAllActive()
{
global $global; global $global;
if (!static::isTableInstalled()) { if (!static::isTableInstalled()) {
return false; return false;
@ -111,7 +117,7 @@ abstract class ObjectYPT implements ObjectInterface {
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $row) { foreach ($fullData as $row) {
$rows[] = $row; $rows[] = $row;
@ -122,7 +128,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $rows; return $rows;
} }
public static function getTotal() { public static function getTotal()
{
//will receive //will receive
//current=1&rowCount=10&sort[sender]=asc&searchPhrase= //current=1&rowCount=10&sort[sender]=asc&searchPhrase=
global $global; global $global;
@ -137,7 +144,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $countRow; return $countRow;
} }
public static function getSqlFromPost($keyPrefix = "") { public static function getSqlFromPost($keyPrefix = "")
{
global $global; global $global;
$sql = self::getSqlSearchFromPost(); $sql = self::getSqlSearchFromPost();
@ -155,7 +163,7 @@ abstract class ObjectYPT implements ObjectInterface {
} }
if (!empty($_POST['sort'])) { if (!empty($_POST['sort'])) {
$orderBy = array(); $orderBy = [];
foreach ($_POST['sort'] as $key => $value) { foreach ($_POST['sort'] as $key => $value) {
$key = $global['mysqli']->real_escape_string($key); $key = $global['mysqli']->real_escape_string($key);
//$value = $global['mysqli']->real_escape_string($value); //$value = $global['mysqli']->real_escape_string($value);
@ -177,9 +185,10 @@ abstract class ObjectYPT implements ObjectInterface {
return $sql; return $sql;
} }
public static function getSqlLimit() { public static function getSqlLimit()
{
global $global; global $global;
$sql = ""; $sql = '';
if (empty($_POST['rowCount']) && !empty($_GET['length'])) { if (empty($_POST['rowCount']) && !empty($_GET['length'])) {
$_POST['rowCount'] = intval($_GET['length']); $_POST['rowCount'] = intval($_GET['length']);
@ -208,30 +217,32 @@ abstract class ObjectYPT implements ObjectInterface {
return $sql; return $sql;
} }
public static function getSqlDateFilter() { public static function getSqlDateFilter()
{
$sql = ''; $sql = '';
$created_year = intval(@$_REQUEST['created_year']); $created_year = intval(@$_REQUEST['created_year']);
$created_month = intval(@$_REQUEST['created_month']); $created_month = intval(@$_REQUEST['created_month']);
$modified_year = intval(@$_REQUEST['modified_year']); $modified_year = intval(@$_REQUEST['modified_year']);
$modified_month = intval(@$_REQUEST['modified_month']); $modified_month = intval(@$_REQUEST['modified_month']);
if(!empty($created_year)){ if (!empty($created_year)) {
$sql .= " AND YEAR(created) = $created_year "; $sql .= " AND YEAR(created) = $created_year ";
} }
if(!empty($created_month)){ if (!empty($created_month)) {
$sql .= " AND MONTH(created) = $created_month "; $sql .= " AND MONTH(created) = $created_month ";
} }
if(!empty($modified_year)){ if (!empty($modified_year)) {
$sql .= " AND YEAR(modified) = $modified_year "; $sql .= " AND YEAR(modified) = $modified_year ";
} }
if(!empty($modified_month)){ if (!empty($modified_month)) {
$sql .= " AND MONTH(modified) = $modified_month "; $sql .= " AND MONTH(modified) = $modified_month ";
} }
return $sql; return $sql;
} }
public static function getSqlSearchFromPost() { public static function getSqlSearchFromPost()
{
$sql = self::getSqlDateFilter(); $sql = self::getSqlDateFilter();
if (!empty($_POST['searchPhrase'])) { if (!empty($_POST['searchPhrase'])) {
$_GET['q'] = $_POST['searchPhrase']; $_GET['q'] = $_POST['searchPhrase'];
@ -242,10 +253,10 @@ abstract class ObjectYPT implements ObjectInterface {
global $global; global $global;
$search = $global['mysqli']->real_escape_string(xss_esc($_GET['q'])); $search = $global['mysqli']->real_escape_string(xss_esc($_GET['q']));
$like = array(); $like = [];
$searchFields = static::getSearchFieldsNames(); $searchFields = static::getSearchFieldsNames();
foreach ($searchFields as $value) { foreach ($searchFields as $value) {
if(!str_contains($value, '.') && !str_contains($value, '`')){ if (!str_contains($value, '.') && !str_contains($value, '`')) {
$value = "`{$value}`"; $value = "`{$value}`";
} }
$like[] = " {$value} LIKE '%{$search}%' "; $like[] = " {$value} LIKE '%{$search}%' ";
@ -262,7 +273,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $sql; return $sql;
} }
public function save() { public function save()
{
if (!$this->tableExists()) { if (!$this->tableExists()) {
_error_log("Save error, table " . static::getTableName() . " does not exists", AVideoLog::$ERROR); _error_log("Save error, table " . static::getTableName() . " does not exists", AVideoLog::$ERROR);
return false; return false;
@ -271,14 +283,14 @@ abstract class ObjectYPT implements ObjectInterface {
$fieldsName = $this->getAllFields(); $fieldsName = $this->getAllFields();
if (!empty($this->id)) { if (!empty($this->id)) {
$sql = "UPDATE " . static::getTableName() . " SET "; $sql = "UPDATE " . static::getTableName() . " SET ";
$fields = array(); $fields = [];
foreach ($fieldsName as $value) { foreach ($fieldsName as $value) {
if (strtolower($value) == 'created') { if (strtolower($value) == 'created') {
// do nothing // do nothing
} elseif (strtolower($value) == 'modified') { } elseif (strtolower($value) == 'modified') {
$fields[] = " {$value} = now() "; $fields[] = " {$value} = now() ";
} elseif (strtolower($value) == 'timezone') { } elseif (strtolower($value) == 'timezone') {
if(empty($this->$value)){ if (empty($this->$value)) {
$this->$value = date_default_timezone_get(); $this->$value = date_default_timezone_get();
} }
$fields[] = " `{$value}` = '{$this->$value}' "; $fields[] = " `{$value}` = '{$this->$value}' ";
@ -295,18 +307,18 @@ abstract class ObjectYPT implements ObjectInterface {
} else { } else {
$sql = "INSERT INTO " . static::getTableName() . " ( "; $sql = "INSERT INTO " . static::getTableName() . " ( ";
$sql .= "`" . implode("`,`", $fieldsName) . "` )"; $sql .= "`" . implode("`,`", $fieldsName) . "` )";
$fields = array(); $fields = [];
foreach ($fieldsName as $value) { foreach ($fieldsName as $value) {
if (is_string($value) && (strtolower($value) == 'created' || strtolower($value) == 'modified')) { if (is_string($value) && (strtolower($value) == 'created' || strtolower($value) == 'modified')) {
$fields[] = " now() "; $fields[] = " now() ";
} elseif (is_string($value) && strtolower($value) == 'timezone') { } elseif (is_string($value) && strtolower($value) == 'timezone') {
if(empty($this->$value)){ if (empty($this->$value)) {
$this->$value = date_default_timezone_get(); $this->$value = date_default_timezone_get();
} }
$fields[] = " '{$this->$value}' "; $fields[] = " '{$this->$value}' ";
} elseif (!isset($this->$value) || (is_string($this->$value) && strtolower($this->$value) == 'null')) { } elseif (!isset($this->$value) || (is_string($this->$value) && strtolower($this->$value) == 'null')) {
$fields[] = " NULL "; $fields[] = " NULL ";
} else if (is_string($this->$value) || is_numeric($this->$value)) { } elseif (is_string($this->$value) || is_numeric($this->$value)) {
$fields[] = " '{$this->$value}' "; $fields[] = " '{$this->$value}' ";
} else { } else {
$fields[] = " NULL "; $fields[] = " NULL ";
@ -330,13 +342,14 @@ abstract class ObjectYPT implements ObjectInterface {
} }
} }
private function getAllFields() { private function getAllFields()
{
global $global, $mysqlDatabase; global $global, $mysqlDatabase;
$sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = '" . static::getTableName() . "'"; $sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = ? AND TABLE_NAME = '" . static::getTableName() . "'";
$res = sqlDAL::readSql($sql, "s", array($mysqlDatabase)); $res = sqlDAL::readSql($sql, "s", [$mysqlDatabase]);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $row) { foreach ($fullData as $row) {
$rows[] = $row["COLUMN_NAME"]; $rows[] = $row["COLUMN_NAME"];
@ -347,53 +360,56 @@ abstract class ObjectYPT implements ObjectInterface {
return $rows; return $rows;
} }
public function delete() { public function delete()
{
global $global; global $global;
if (!empty($this->id)) { if (!empty($this->id)) {
$sql = "DELETE FROM " . static::getTableName() . " "; $sql = "DELETE FROM " . static::getTableName() . " ";
$sql .= " WHERE id = ?"; $sql .= " WHERE id = ?";
$global['lastQuery'] = $sql; $global['lastQuery'] = $sql;
//_error_log("Delete Query: ".$sql); //_error_log("Delete Query: ".$sql);
return sqlDAL::writeSql($sql, "i", array($this->id)); return sqlDAL::writeSql($sql, "i", [$this->id]);
} }
_error_log("Id for table " . static::getTableName() . " not defined for deletion ". json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)), AVideoLog::$ERROR); _error_log("Id for table " . static::getTableName() . " not defined for deletion ". json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)), AVideoLog::$ERROR);
return false; return false;
} }
static function shouldUseDatabase($content){ public static function shouldUseDatabase($content)
{
global $advancedCustom, $global; global $advancedCustom, $global;
if(!empty($global['doNotUseCacheDatabase'])){ if (!empty($global['doNotUseCacheDatabase'])) {
return false; return false;
} }
$maxLen = 60000; $maxLen = 60000;
if(empty($advancedCustom)){ if (empty($advancedCustom)) {
$advancedCustom = AVideoPlugin::getObjectData("CustomizeAdvanced"); $advancedCustom = AVideoPlugin::getObjectData("CustomizeAdvanced");
} }
if(empty($advancedCustom->doNotSaveCacheOnFilesystem) && class_exists('Cache') && self::isTableInstalled('CachesInDB')){ if (empty($advancedCustom->doNotSaveCacheOnFilesystem) && class_exists('Cache') && self::isTableInstalled('CachesInDB')) {
$json = _json_encode($content); $json = _json_encode($content);
$len = strlen($json); $len = strlen($json);
if($len>$maxLen/2){ if ($len>$maxLen/2) {
return false; return false;
} }
if(class_exists('CachesInDB')){ if (class_exists('CachesInDB')) {
$content = CachesInDB::encodeContent($json); $content = CachesInDB::encodeContent($json);
}else{ } else {
$content = base64_encode($json); $content = base64_encode($json);
} }
$len = strlen($content); $len = strlen($content);
if(!empty($len) && $len<$maxLen){ if (!empty($len) && $len<$maxLen) {
return $content; return $content;
}else if(!empty($len)){ } elseif (!empty($len)) {
//_error_log('Object::setCache '.$len); //_error_log('Object::setCache '.$len);
} }
} }
return false; return false;
} }
public static function setCache($name, $value) { public static function setCache($name, $value)
if($content = self::shouldUseDatabase($value)){ {
if ($content = self::shouldUseDatabase($value)) {
return Cache::_setCache($name, $content); return Cache::_setCache($name, $content);
} }
@ -402,7 +418,7 @@ abstract class ObjectYPT implements ObjectInterface {
$content = $value; $content = $value;
} }
if(empty($content)){ if (empty($content)) {
return false; return false;
} }
@ -411,11 +427,12 @@ abstract class ObjectYPT implements ObjectInterface {
$bytes = @file_put_contents($cachefile, $content); $bytes = @file_put_contents($cachefile, $content);
self::setSessionCache($name, $value); self::setSessionCache($name, $value);
return array('bytes' => $bytes, 'cachefile' => $cachefile); return ['bytes' => $bytes, 'cachefile' => $cachefile];
} }
public static function cleanCacheName($name) { public static function cleanCacheName($name)
$name = str_replace(array('/', '\\'), array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), $name); {
$name = str_replace(['/', '\\'], [DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR], $name);
$name = preg_replace('/[!#$&\'()*+,:;=?@[\\]% -]+/', '_', trim(strtolower(cleanString($name)))); $name = preg_replace('/[!#$&\'()*+,:;=?@[\\]% -]+/', '_', trim(strtolower(cleanString($name))));
$name = preg_replace('/\/{2,}/', '/', trim(strtolower(cleanString($name)))); $name = preg_replace('/\/{2,}/', '/', trim(strtolower(cleanString($name))));
if (function_exists('mb_ereg_replace')) { if (function_exists('mb_ereg_replace')) {
@ -432,9 +449,10 @@ abstract class ObjectYPT implements ObjectInterface {
* @param type $lifetime, if is = 0 it is unlimited * @param type $lifetime, if is = 0 it is unlimited
* @return type * @return type
*/ */
public static function getCache($name, $lifetime = 60, $ignoreSessionCache = false) { public static function getCache($name, $lifetime = 60, $ignoreSessionCache = false)
{
global $global; global $global;
if(!empty($global['ignoreAllCache'])){ if (!empty($global['ignoreAllCache'])) {
return null; return null;
} }
self::setLastUsedCacheMode("No cache detected $name, $lifetime, " . intval($ignoreSessionCache)); self::setLastUsedCacheMode("No cache detected $name, $lifetime, " . intval($ignoreSessionCache));
@ -447,11 +465,11 @@ abstract class ObjectYPT implements ObjectInterface {
global $getCachesProcessed, $_getCache; global $getCachesProcessed, $_getCache;
if (empty($_getCache)) { if (empty($_getCache)) {
$_getCache = array(); $_getCache = [];
} }
if (empty($getCachesProcessed)) { if (empty($getCachesProcessed)) {
$getCachesProcessed = array(); $getCachesProcessed = [];
} }
$cachefile = self::getCacheFileName($name, false); $cachefile = self::getCacheFileName($name, false);
//var_dump($cachefile);//exit; //var_dump($cachefile);//exit;
@ -481,9 +499,9 @@ abstract class ObjectYPT implements ObjectInterface {
} }
} }
if(self::shouldUseDatabase('')){ if (self::shouldUseDatabase('')) {
$cache = Cache::getCache($name, $lifetime); $cache = Cache::getCache($name, $lifetime);
if(!empty($cache)){ if (!empty($cache)) {
return $cache; return $cache;
} }
} }
@ -522,22 +540,26 @@ abstract class ObjectYPT implements ObjectInterface {
return null; return null;
} }
private static function setLastUsedCacheMode($mode) { private static function setLastUsedCacheMode($mode)
{
global $_lastCacheMode; global $_lastCacheMode;
$_lastCacheMode = $mode; $_lastCacheMode = $mode;
} }
private static function setLastUsedCacheFile($cachefile) { private static function setLastUsedCacheFile($cachefile)
{
global $_lastCacheFile; global $_lastCacheFile;
$_lastCacheFile = $cachefile; $_lastCacheFile = $cachefile;
} }
public static function getLastUsedCacheInfo() { public static function getLastUsedCacheInfo()
{
global $_lastCacheFile, $_lastCacheMode; global $_lastCacheFile, $_lastCacheMode;
return array('file' => $_lastCacheFile, 'mode' => $_lastCacheMode); return ['file' => $_lastCacheFile, 'mode' => $_lastCacheMode];
} }
public static function deleteCache($name) { public static function deleteCache($name)
{
if (empty($name) || !class_exists('Cache')) { if (empty($name) || !class_exists('Cache')) {
return false; return false;
} }
@ -553,7 +575,8 @@ abstract class ObjectYPT implements ObjectInterface {
ObjectYPT::deleteCacheFromPattern($name); ObjectYPT::deleteCacheFromPattern($name);
} }
static function deleteCachePattern($pattern) { public static function deleteCachePattern($pattern)
{
global $__getAVideoCache; global $__getAVideoCache;
unset($__getAVideoCache); unset($__getAVideoCache);
$tmpDir = self::getCacheDir(); $tmpDir = self::getCacheDir();
@ -573,8 +596,9 @@ abstract class ObjectYPT implements ObjectInterface {
} }
} }
public static function deleteALLCache() { public static function deleteALLCache()
if(class_exists('Cache')){ {
if (class_exists('Cache')) {
Cache::deleteAllCache(); Cache::deleteAllCache();
} }
self::deleteAllSessionCache(); self::deleteAllSessionCache();
@ -596,7 +620,7 @@ abstract class ObjectYPT implements ObjectInterface {
if (is_dir($tmpDir)) { if (is_dir($tmpDir)) {
_error_log('deleteALLCache 1 rmdir ' . $tmpDir); _error_log('deleteALLCache 1 rmdir ' . $tmpDir);
rrmdir($tmpDir); rrmdir($tmpDir);
} else if(preg_match('/videos.cache/', $newtmpDir)){ } elseif (preg_match('/videos.cache/', $newtmpDir)) {
// only delete if it is on the videos dir. otherwise it is on the /tmp dit and the system will delete it // only delete if it is on the videos dir. otherwise it is on the /tmp dit and the system will delete it
_error_log('deleteALLCache 2 rmdir ' . $newtmpDir); _error_log('deleteALLCache 2 rmdir ' . $newtmpDir);
rrmdirCommandLine($newtmpDir, true); rrmdirCommandLine($newtmpDir, true);
@ -608,11 +632,12 @@ abstract class ObjectYPT implements ObjectInterface {
return true; return true;
} }
public static function getCacheDir($filename = '', $createDir=true) { public static function getCacheDir($filename = '', $createDir=true)
{
global $_getCacheDir, $global; global $_getCacheDir, $global;
if (!isset($_getCacheDir)) { if (!isset($_getCacheDir)) {
$_getCacheDir = array(); $_getCacheDir = [];
} }
if (!empty($_getCacheDir[$filename])) { if (!empty($_getCacheDir[$filename])) {
@ -651,7 +676,7 @@ abstract class ObjectYPT implements ObjectInterface {
} }
} }
$tmpDir = fixPath($tmpDir); $tmpDir = fixPath($tmpDir);
if($createDir){ if ($createDir) {
make_path($tmpDir); make_path($tmpDir);
} }
if (!file_exists($tmpDir . "index.html") && is_writable($tmpDir)) {// to avoid search into the directory if (!file_exists($tmpDir . "index.html") && is_writable($tmpDir)) {// to avoid search into the directory
@ -662,14 +687,16 @@ abstract class ObjectYPT implements ObjectInterface {
return $tmpDir; return $tmpDir;
} }
public static function getCacheFileName($name, $createDir=true) { public static function getCacheFileName($name, $createDir=true)
{
global $global; global $global;
$tmpDir = self::getCacheDir($name, $createDir); $tmpDir = self::getCacheDir($name, $createDir);
$uniqueHash = md5($name . $global['salt']); // add salt for security reasons $uniqueHash = md5($name . $global['salt']); // add salt for security reasons
return $tmpDir . $uniqueHash . '.cache'; return $tmpDir . $uniqueHash . '.cache';
} }
public static function deleteCacheFromPattern($name) { public static function deleteCacheFromPattern($name)
{
if (empty($name)) { if (empty($name)) {
return false; return false;
} }
@ -689,7 +716,8 @@ abstract class ObjectYPT implements ObjectInterface {
* @param type $name * @param type $name
* @param type $value * @param type $value
*/ */
public static function setSessionCache($name, $value) { public static function setSessionCache($name, $value)
{
$name = self::cleanCacheName($name); $name = self::cleanCacheName($name);
_session_start(); _session_start();
$_SESSION['user']['sessionCache'][$name]['value'] = json_encode($value); $_SESSION['user']['sessionCache'][$name]['value'] = json_encode($value);
@ -705,7 +733,8 @@ abstract class ObjectYPT implements ObjectInterface {
* @param type $lifetime, if is = 0 it is unlimited * @param type $lifetime, if is = 0 it is unlimited
* @return type * @return type
*/ */
public static function getSessionCache($name, $lifetime = 60) { public static function getSessionCache($name, $lifetime = 60)
{
$name = self::cleanCacheName($name); $name = self::cleanCacheName($name);
if (!empty($_GET['lifetime'])) { if (!empty($_GET['lifetime'])) {
$lifetime = intval($_GET['lifetime']); $lifetime = intval($_GET['lifetime']);
@ -726,24 +755,28 @@ abstract class ObjectYPT implements ObjectInterface {
return null; return null;
} }
public static function clearSessionCache() { public static function clearSessionCache()
{
unset($_SESSION['user']['sessionCache']); unset($_SESSION['user']['sessionCache']);
} }
private static function getLastDeleteALLCacheTimeFile() { private static function getLastDeleteALLCacheTimeFile()
{
$tmpDir = getTmpDir(); $tmpDir = getTmpDir();
$tmpDir = rtrim($tmpDir, DIRECTORY_SEPARATOR) . "/"; $tmpDir = rtrim($tmpDir, DIRECTORY_SEPARATOR) . "/";
$tmpDir .= "lastDeleteALLCacheTime.cache"; $tmpDir .= "lastDeleteALLCacheTime.cache";
return $tmpDir; return $tmpDir;
} }
public static function setLastDeleteALLCacheTime() { public static function setLastDeleteALLCacheTime()
{
$file = self::getLastDeleteALLCacheTimeFile(); $file = self::getLastDeleteALLCacheTimeFile();
//_error_log("ObjectYPT::setLastDeleteALLCacheTime {$file}"); //_error_log("ObjectYPT::setLastDeleteALLCacheTime {$file}");
return file_put_contents($file, time()); return file_put_contents($file, time());
} }
public static function getLastDeleteALLCacheTime() { public static function getLastDeleteALLCacheTime()
{
global $getLastDeleteALLCacheTime; global $getLastDeleteALLCacheTime;
if (empty($getLastDeleteALLCacheTime)) { if (empty($getLastDeleteALLCacheTime)) {
$getLastDeleteALLCacheTime = (int) @file_get_contents(self::getLastDeleteALLCacheTimeFile(), time()); $getLastDeleteALLCacheTime = (int) @file_get_contents(self::getLastDeleteALLCacheTimeFile(), time());
@ -751,7 +784,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $getLastDeleteALLCacheTime; return $getLastDeleteALLCacheTime;
} }
public static function checkSessionCacheBasedOnLastDeleteALLCacheTime() { public static function checkSessionCacheBasedOnLastDeleteALLCacheTime()
{
/* /*
var_dump( var_dump(
$session_var['time'], $session_var['time'],
@ -768,24 +802,28 @@ abstract class ObjectYPT implements ObjectInterface {
return true; return true;
} }
public static function deleteSessionCache($name) { public static function deleteSessionCache($name)
{
$name = self::cleanCacheName($name); $name = self::cleanCacheName($name);
_session_start(); _session_start();
$_SESSION['user']['sessionCache'][$name] = null; $_SESSION['user']['sessionCache'][$name] = null;
unset($_SESSION['user']['sessionCache'][$name]); unset($_SESSION['user']['sessionCache'][$name]);
} }
public static function deleteAllSessionCache() { public static function deleteAllSessionCache()
{
_session_start(); _session_start();
unset($_SESSION['user']['sessionCache']); unset($_SESSION['user']['sessionCache']);
return empty($_SESSION['user']['sessionCache']); return empty($_SESSION['user']['sessionCache']);
} }
public function tableExists() { public function tableExists()
{
return self::isTableInstalled(); return self::isTableInstalled();
} }
public static function isTableInstalled($tableName = "") { public static function isTableInstalled($tableName = "")
{
global $global, $tableExists; global $global, $tableExists;
if (empty($tableName)) { if (empty($tableName)) {
$tableName = static::getTableName(); $tableName = static::getTableName();
@ -804,8 +842,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $tableExists[$tableName]; return $tableExists[$tableName];
} }
static function clientTimezoneToDatabaseTimezone($clientDate) { public static function clientTimezoneToDatabaseTimezone($clientDate)
{
if (!preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/', $clientDate)) { if (!preg_match('/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/', $clientDate)) {
return $clientDate; return $clientDate;
} }
@ -820,7 +858,6 @@ abstract class ObjectYPT implements ObjectInterface {
date_default_timezone_set($currentTimezone); date_default_timezone_set($currentTimezone);
return $dbDate; return $dbDate;
} }
} }
//abstract class Object extends ObjectYPT{}; //abstract class Object extends ObjectYPT{};

View file

@ -19,7 +19,7 @@ if (empty($_POST['format']) || !in_array($_POST['format'], $global['allowedExten
_error_log("aVideoEncoder.json: Extension not allowed File " . __FILE__ . ": " . json_encode($_POST)); _error_log("aVideoEncoder.json: Extension not allowed File " . __FILE__ . ": " . json_encode($_POST));
die(); die();
} }
if(!isset($_REQUEST['encodedPass'])){ if (!isset($_REQUEST['encodedPass'])) {
$_REQUEST['encodedPass'] = 1; $_REQUEST['encodedPass'] = 1;
} }
useVideoHashOrLogin(); useVideoHashOrLogin();
@ -42,7 +42,7 @@ _error_log("aVideoEncoder.json: start to receive: " . json_encode($_POST));
// check if there is en video id if yes update if is not create a new one // check if there is en video id if yes update if is not create a new one
$video = new Video("", "", @$_POST['videos_id']); $video = new Video("", "", @$_POST['videos_id']);
if(!empty($video->getId()) && !empty($_REQUEST['first_request'])){ if (!empty($video->getId()) && !empty($_REQUEST['first_request'])) {
_error_log("aVideoEncoder.json: There is a new video to replace the existing one, we will delete the current files videos_id = ".$video->getId()); _error_log("aVideoEncoder.json: There is a new video to replace the existing one, we will delete the current files videos_id = ".$video->getId());
$video->removeVideoFiles(); $video->removeVideoFiles();
} }
@ -61,9 +61,9 @@ if (empty($description)) {
} }
if(!empty($_REQUEST['duration'])){ if (!empty($_REQUEST['duration'])) {
$duration = $video->getDuration(); $duration = $video->getDuration();
if(empty($duration) || $duration === 'EE:EE:EE'){ if (empty($duration) || $duration === 'EE:EE:EE') {
$video->setDuration($_REQUEST['duration']); $video->setDuration($_REQUEST['duration']);
} }
} }
@ -104,7 +104,7 @@ if (!empty($_FILES)) {
} }
if (!empty($_FILES['video']['error'])) { if (!empty($_FILES['video']['error'])) {
$phpFileUploadErrors = array( $phpFileUploadErrors = [
0 => 'There is no error, the file uploaded with success', 0 => 'There is no error, the file uploaded with success',
1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini', 1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini',
2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', 2 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form',
@ -113,7 +113,7 @@ if (!empty($_FILES['video']['error'])) {
6 => 'Missing a temporary folder', 6 => 'Missing a temporary folder',
7 => 'Failed to write file to disk.', 7 => 'Failed to write file to disk.',
8 => 'A PHP extension stopped the file upload.', 8 => 'A PHP extension stopped the file upload.',
); ];
_error_log("aVideoEncoder.json: ******** Files ERROR " . $phpFileUploadErrors[$_FILES['video']['error']]); _error_log("aVideoEncoder.json: ******** Files ERROR " . $phpFileUploadErrors[$_FILES['video']['error']]);
if (!empty($_POST['downloadURL'])) { if (!empty($_POST['downloadURL'])) {
$_FILES['video']['tmp_name'] = downloadVideoFromDownloadURL($_POST['downloadURL']); $_FILES['video']['tmp_name'] = downloadVideoFromDownloadURL($_POST['downloadURL']);
@ -126,7 +126,7 @@ if (empty($_FILES['video']['tmp_name']) && !empty($_POST['chunkFile'])) {
// get video file from encoder // get video file from encoder
if (!empty($_FILES['video']['tmp_name'])) { if (!empty($_FILES['video']['tmp_name'])) {
$resolution = ""; $resolution = '';
if (!empty($_POST['resolution'])) { if (!empty($_POST['resolution'])) {
$resolution = "_{$_POST['resolution']}"; $resolution = "_{$_POST['resolution']}";
} }
@ -169,7 +169,7 @@ $video->updateHLSDurationIfNeed();
if (!empty($_POST['usergroups_id'])) { if (!empty($_POST['usergroups_id'])) {
if (!is_array($_POST['usergroups_id'])) { if (!is_array($_POST['usergroups_id'])) {
$_POST['usergroups_id'] = array($_POST['usergroups_id']); $_POST['usergroups_id'] = [$_POST['usergroups_id']];
} }
UserGroups::updateVideoGroups($video_id, $_POST['usergroups_id']); UserGroups::updateVideoGroups($video_id, $_POST['usergroups_id']);
} }
@ -181,10 +181,10 @@ $v = new Video('', '', $video_id);
$obj->video_id_hash = $v->getVideoIdHash(); $obj->video_id_hash = $v->getVideoIdHash();
_error_log("aVideoEncoder.json: Files Received for video {$video_id}: " . $video->getTitle()); _error_log("aVideoEncoder.json: Files Received for video {$video_id}: " . $video->getTitle());
if(!empty($destinationFile)){ if (!empty($destinationFile)) {
if(file_exists($destinationFile)){ if (file_exists($destinationFile)) {
_error_log("aVideoEncoder.json: Success $destinationFile "); _error_log("aVideoEncoder.json: Success $destinationFile ");
}else{ } else {
_error_log("aVideoEncoder.json: ERROR $destinationFile "); _error_log("aVideoEncoder.json: ERROR $destinationFile ");
} }
} }
@ -196,7 +196,8 @@ die(json_encode($obj));
var_dump($_POST, $_FILES); var_dump($_POST, $_FILES);
*/ */
function downloadVideoFromDownloadURL($downloadURL){ function downloadVideoFromDownloadURL($downloadURL)
{
global $global; global $global;
_error_log("aVideoEncoder.json: Try to download " . $downloadURL); _error_log("aVideoEncoder.json: Try to download " . $downloadURL);
$file = url_get_contents($_POST['downloadURL']); $file = url_get_contents($_POST['downloadURL']);
@ -212,11 +213,11 @@ function downloadVideoFromDownloadURL($downloadURL){
$temp = Video::getStoragePath()."cache/tmpFile/" . $_FILES['video']['name']; $temp = Video::getStoragePath()."cache/tmpFile/" . $_FILES['video']['name'];
make_path($temp); make_path($temp);
$bytesSaved = file_put_contents($temp, $file); $bytesSaved = file_put_contents($temp, $file);
if($bytesSaved){ if ($bytesSaved) {
_error_log("aVideoEncoder.json: saved " . $temp . ' '. humanFileSize($bytesSaved)); _error_log("aVideoEncoder.json: saved " . $temp . ' '. humanFileSize($bytesSaved));
return $temp; return $temp;
}else{ } else {
_error_log("aVideoEncoder.json: ERROR on save file " . $temp ); _error_log("aVideoEncoder.json: ERROR on save file " . $temp);
} }
} }
return false; return false;

View file

@ -1,5 +1,4 @@
<?php <?php
header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json'); header('Content-Type: application/json');
$obj = new stdClass(); $obj = new stdClass();
@ -10,8 +9,9 @@ $fp = fopen($obj->file, "w");
error_log("aVideoEncoderChunk.json.php: start {$obj->file} "); error_log("aVideoEncoderChunk.json.php: start {$obj->file} ");
while ($data = fread($putdata, 1024 * 1024)) while ($data = fread($putdata, 1024 * 1024)) {
fwrite($fp, $data); fwrite($fp, $data);
}
fclose($fp); fclose($fp);
fclose($putdata); fclose($putdata);

View file

@ -1,12 +1,11 @@
<?php <?php
header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json'); header('Content-Type: application/json');
$obj = new stdClass(); $obj = new stdClass();
$obj->error = true; $obj->error = true;
global $global, $config; global $global, $config;
if(!isset($global['systemRootPath'])){ if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/user.php';
@ -27,7 +26,7 @@ if (!User::canUpload()) {
die(json_encode($obj)); die(json_encode($obj));
} }
if(!Video::canEdit($_POST['videos_id'])){ if (!Video::canEdit($_POST['videos_id'])) {
$obj->msg = __("Permission denied to edit a video: ") . print_r($_POST, true); $obj->msg = __("Permission denied to edit a video: ") . print_r($_POST, true);
_error_log($obj->msg); _error_log($obj->msg);
die(json_encode($obj)); die(json_encode($obj));
@ -44,7 +43,7 @@ $video_id = $video->save();
$video = new Video("", "", $video_id); $video = new Video("", "", $video_id);
if($video->getType() == 'audio' && AVideoPlugin::isEnabledByName('MP4ThumbsAndGif')){ if ($video->getType() == 'audio' && AVideoPlugin::isEnabledByName('MP4ThumbsAndGif')) {
$videoFileName = $video->getFilename(); $videoFileName = $video->getFilename();
MP4ThumbsAndGif::getImage($videoFileName, 'jpg', $video_id); MP4ThumbsAndGif::getImage($videoFileName, 'jpg', $video_id);
Video::deleteThumbs($videoFileName); Video::deleteThumbs($videoFileName);
@ -56,7 +55,7 @@ $obj->video_id = $video_id;
Video::updateFilesize($video_id); Video::updateFilesize($video_id);
// delete original files if any // delete original files if any
$originalFilePath = Video::getStoragePath()."original_" . $video->getFilename(); $originalFilePath = Video::getStoragePath()."original_" . $video->getFilename();
if(file_exists($originalFilePath)){ if (file_exists($originalFilePath)) {
unlink($originalFilePath); unlink($originalFilePath);
} }
_error_log("Video is done notified {$video_id}: " . $video->getTitle()); _error_log("Video is done notified {$video_id}: " . $video->getTitle());

View file

@ -1,5 +1,4 @@
<?php <?php
header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json'); header('Content-Type: application/json');
$obj = new stdClass(); $obj = new stdClass();
@ -45,17 +44,17 @@ $destination_local = "{$paths['path']}{$videoFileName}";
_error_log("ReceiveImage: videoFilename = [$videoFileName] destination_local = {$destination_local} Encoder receiving post " . json_encode($_FILES)); _error_log("ReceiveImage: videoFilename = [$videoFileName] destination_local = {$destination_local} Encoder receiving post " . json_encode($_FILES));
$obj->jpgDest = "{$destination_local}.jpg"; $obj->jpgDest = "{$destination_local}.jpg";
if(!empty($_REQUEST['downloadURL_image']) ){ if (!empty($_REQUEST['downloadURL_image'])) {
$content = url_get_contents($_REQUEST['downloadURL_image']); $content = url_get_contents($_REQUEST['downloadURL_image']);
$obj->jpgDestSize = _file_put_contents($obj->jpgDest, $content); $obj->jpgDestSize = _file_put_contents($obj->jpgDest, $content);
_error_log("ReceiveImage: download {$_REQUEST['downloadURL_image']} to {$obj->jpgDest} ". humanFileSize($obj->jpgDestSize)); _error_log("ReceiveImage: download {$_REQUEST['downloadURL_image']} to {$obj->jpgDest} ". humanFileSize($obj->jpgDestSize));
} else if (!empty($_FILES['image']['tmp_name']) && (!empty($_REQUEST['update_video_id']) || !file_exists($obj->jpgDest) || filesize($obj->jpgDest) === 42342)) { } elseif (!empty($_FILES['image']['tmp_name']) && (!empty($_REQUEST['update_video_id']) || !file_exists($obj->jpgDest) || filesize($obj->jpgDest) === 42342)) {
if (!move_uploaded_file($_FILES['image']['tmp_name'], $obj->jpgDest)) { if (!move_uploaded_file($_FILES['image']['tmp_name'], $obj->jpgDest)) {
if(!rename($_FILES['image']['tmp_name'], $obj->jpgDest)){ if (!rename($_FILES['image']['tmp_name'], $obj->jpgDest)) {
if(!copy($_FILES['image']['tmp_name'], $obj->jpgDest)){ if (!copy($_FILES['image']['tmp_name'], $obj->jpgDest)) {
if(!file_exists($_FILES['image']['tmp_name'])){ if (!file_exists($_FILES['image']['tmp_name'])) {
$obj->msg = print_r(sprintf(__("Could not move image file because it does not exits %s => [%s]"), $_FILES['image']['tmp_name'], $obj->jpgDest), true); $obj->msg = print_r(sprintf(__("Could not move image file because it does not exits %s => [%s]"), $_FILES['image']['tmp_name'], $obj->jpgDest), true);
}else{ } else {
$obj->msg = print_r(sprintf(__("Could not move image file %s => [%s]"), $_FILES['image']['tmp_name'], $obj->jpgDest), true); $obj->msg = print_r(sprintf(__("Could not move image file %s => [%s]"), $_FILES['image']['tmp_name'], $obj->jpgDest), true);
} }
_error_log("ReceiveImage: " . $obj->msg); _error_log("ReceiveImage: " . $obj->msg);
@ -77,11 +76,11 @@ if(!empty($_REQUEST['downloadURL_image']) ){
} }
} }
if(!empty($_REQUEST['downloadURL_spectrumimage']) ){ if (!empty($_REQUEST['downloadURL_spectrumimage'])) {
$content = url_get_contents($_REQUEST['downloadURL_spectrumimage']); $content = url_get_contents($_REQUEST['downloadURL_spectrumimage']);
$obj->jpgSpectrumDestSize = _file_put_contents($obj->jpgSpectrumDest, $content); $obj->jpgSpectrumDestSize = _file_put_contents($obj->jpgSpectrumDest, $content);
_error_log("ReceiveImage: download {$_REQUEST['downloadURL_spectrumimage']} {$obj->jpgDestSize}"); _error_log("ReceiveImage: download {$_REQUEST['downloadURL_spectrumimage']} {$obj->jpgDestSize}");
} else if (!empty($_FILES['spectrumimage']['tmp_name'])) { } elseif (!empty($_FILES['spectrumimage']['tmp_name'])) {
$obj->jpgSpectrumDest = "{$destination_local}_spectrum.jpg"; $obj->jpgSpectrumDest = "{$destination_local}_spectrum.jpg";
if ((!empty($_REQUEST['update_video_id']) || !file_exists($obj->jpgSpectrumDest) || filesize($obj->jpgSpectrumDest) === 42342)) { if ((!empty($_REQUEST['update_video_id']) || !file_exists($obj->jpgSpectrumDest) || filesize($obj->jpgSpectrumDest) === 42342)) {
if (!move_uploaded_file($_FILES['spectrumimage']['tmp_name'], $obj->jpgSpectrumDest)) { if (!move_uploaded_file($_FILES['spectrumimage']['tmp_name'], $obj->jpgSpectrumDest)) {
@ -105,11 +104,11 @@ if(!empty($_REQUEST['downloadURL_spectrumimage']) ){
} }
$obj->gifDest = "{$destination_local}.gif"; $obj->gifDest = "{$destination_local}.gif";
if(!empty($_REQUEST['downloadURL_gifimage']) ){ if (!empty($_REQUEST['downloadURL_gifimage'])) {
$content = url_get_contents($_REQUEST['downloadURL_gifimage']); $content = url_get_contents($_REQUEST['downloadURL_gifimage']);
$obj->gifDestSize = file_put_contents($obj->gifDest, $content); $obj->gifDestSize = file_put_contents($obj->gifDest, $content);
_error_log("ReceiveImage: download {$_REQUEST['downloadURL_gifimage']} {$obj->gifDestSize}"); _error_log("ReceiveImage: download {$_REQUEST['downloadURL_gifimage']} {$obj->gifDestSize}");
} else if (!empty($_FILES['gifimage']['tmp_name']) && (!empty($_REQUEST['update_video_id']) || !file_exists($obj->gifDest) || filesize($obj->gifDest) === 2095341)) { } elseif (!empty($_FILES['gifimage']['tmp_name']) && (!empty($_REQUEST['update_video_id']) || !file_exists($obj->gifDest) || filesize($obj->gifDest) === 2095341)) {
if (!move_uploaded_file($_FILES['gifimage']['tmp_name'], $obj->gifDest)) { if (!move_uploaded_file($_FILES['gifimage']['tmp_name'], $obj->gifDest)) {
$obj->msg = print_r(sprintf(__("Could not move gif image file [%s.gif]"), $destination_local), true); $obj->msg = print_r(sprintf(__("Could not move gif image file [%s.gif]"), $destination_local), true);
_error_log("ReceiveImage: " . $obj->msg); _error_log("ReceiveImage: " . $obj->msg);
@ -129,11 +128,11 @@ if(!empty($_REQUEST['downloadURL_gifimage']) ){
} }
} }
$obj->webpDest = "{$destination_local}.webp"; $obj->webpDest = "{$destination_local}.webp";
if(!empty($_REQUEST['downloadURL_webpimage']) ){ if (!empty($_REQUEST['downloadURL_webpimage'])) {
$content = url_get_contents($_REQUEST['downloadURL_webpimage']); $content = url_get_contents($_REQUEST['downloadURL_webpimage']);
$obj->webpDestSize = file_put_contents($obj->webpDest, $content); $obj->webpDestSize = file_put_contents($obj->webpDest, $content);
_error_log("ReceiveImage: download {$_REQUEST['downloadURL_webpimage']} {$obj->webpDestSize}"); _error_log("ReceiveImage: download {$_REQUEST['downloadURL_webpimage']} {$obj->webpDestSize}");
} else if (!empty($_FILES['webpimage']['tmp_name']) && (!empty($_REQUEST['update_video_id']) || !file_exists($obj->webpDest) || filesize($obj->webpDest) === 2095341)) { } elseif (!empty($_FILES['webpimage']['tmp_name']) && (!empty($_REQUEST['update_video_id']) || !file_exists($obj->webpDest) || filesize($obj->webpDest) === 2095341)) {
if (!move_uploaded_file($_FILES['webpimage']['tmp_name'], $obj->webpDest)) { if (!move_uploaded_file($_FILES['webpimage']['tmp_name'], $obj->webpDest)) {
$obj->msg = print_r(sprintf(__("Could not move webp image file [%s.webp]"), $destination_local), true); $obj->msg = print_r(sprintf(__("Could not move webp image file [%s.webp]"), $destination_local), true);
_error_log("ReceiveImage: " . $obj->msg); _error_log("ReceiveImage: " . $obj->msg);

View file

@ -1,5 +1,4 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
$obj = new stdClass(); $obj = new stdClass();
$obj->error = true; $obj->error = true;
@ -16,10 +15,9 @@ if (!User::canUpload()) {
} }
// A list of permitted file extensions // A list of permitted file extensions
$allowed = array('mp4', 'avi', 'mov', 'mkv', 'flv', 'mp3', 'm4a', 'wav', 'm4v', 'webm', 'wmv'); $allowed = ['mp4', 'avi', 'mov', 'mkv', 'flv', 'mp3', 'm4a', 'wav', 'm4v', 'webm', 'wmv'];
if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) { if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
$updateVideoGroups = false; $updateVideoGroups = false;
//echo "Success: \$_FILES OK\n"; //echo "Success: \$_FILES OK\n";
@ -27,8 +25,7 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
if (!in_array(strtolower($extension), $allowed)) { if (!in_array(strtolower($extension), $allowed)) {
//echo '{"status":"error", "msg":"File extension error [' . $_FILES['upl']['name'] . '], we allow only (' . implode(",", $allowed) . ')"}'; //echo '{"status":"error", "msg":"File extension error [' . $_FILES['upl']['name'] . '], we allow only (' . implode(",", $allowed) . ')"}';
status(["status" => "error" status(["status" => "error", "msg" => "File extension error (" . $_FILES['upl']['name'] . "), we allow only (" . implode(",", $allowed) . ")"]);
, "msg" => "File extension error (" . $_FILES['upl']['name'] . "), we allow only (" . implode(",", $allowed) . ")"]);
exit; exit;
} }
@ -57,7 +54,7 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
. "<br>[Max Duration: {$maxDuration} Seconds]" . "<br>[Max Duration: {$maxDuration} Seconds]"
. "<br>[Current Srotage Usage: {$currentStorageUsage} Seconds]" . "<br>[Current Srotage Usage: {$currentStorageUsage} Seconds]"
. "<br>[This File Duration: {$thisFile} Seconds]" . "<br>[This File Duration: {$thisFile} Seconds]"
. "<br>[Limit after this file: {$limitAfterThisFile} Seconds]", "type" => '$_FILES Limit Error']); . "<br>[Limit after this file: {$limitAfterThisFile} Seconds]", "type" => '$_FILES Limit Error', ]);
if (!empty($_FILES['upl']['videoId'])) { if (!empty($_FILES['upl']['videoId'])) {
$video = new Video("", "", $_FILES['upl']['videoId']); $video = new Video("", "", $_FILES['upl']['videoId']);
$video->delete(); $video->delete();
@ -142,40 +139,39 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
$video = new Video('', '', $id); $video = new Video('', '', $id);
// send to encoder // send to encoder
$queue = array(); $queue = [];
$postFields = array(); $postFields = [];
if ($video->getType() == 'video') { if ($video->getType() == 'video') {
if (AVideoPlugin::isEnabledByName("VideoHLS")) { if (AVideoPlugin::isEnabledByName("VideoHLS")) {
$postFields['inputAutoHLS'] = 1; $postFields['inputAutoHLS'] = 1;
}else{ } else {
$postFields['inputLow'] = 1; $postFields['inputLow'] = 1;
$postFields['inputSD'] = 1; $postFields['inputSD'] = 1;
$postFields['inputHD'] = 1; $postFields['inputHD'] = 1;
if (!empty($_FILES['upl']['webm'])) if (!empty($_FILES['upl']['webm'])) {
$postFields['webm'] = 1; $postFields['webm'] = 1;
}
} }
} else { } else {
$postFields['audioOnly'] = 1; $postFields['audioOnly'] = 1;
$postFields['spectrum'] = 1; $postFields['spectrum'] = 1;
} }
if (!empty($_FILES['upl']['override_status'])) if (!empty($_FILES['upl']['override_status'])) {
$postFields['override_status'] = $_FILES['upl']['override_status']; $postFields['override_status'] = $_FILES['upl']['override_status'];
}
if (!empty($_FILES['upl']['update_video_id'])) if (!empty($_FILES['upl']['update_video_id'])) {
$postFields['update_video_id'] = $_FILES['upl']['update_video_id']; $postFields['update_video_id'] = $_FILES['upl']['update_video_id'];
}
$queue[] = $video->queue($postFields); $queue[] = $video->queue($postFields);
//exec("/usr/bin/php -f videoEncoder.php {$_FILES['upl']['tmp_name']} {$filename} 1> Video::getStoragePath()."{$filename}_progress.txt 2>&1", $output, $return_val); //exec("/usr/bin/php -f videoEncoder.php {$_FILES['upl']['tmp_name']} {$filename} 1> Video::getStoragePath()."{$filename}_progress.txt 2>&1", $output, $return_val);
//var_dump($output, $return_val); //var_dump($output, $return_val);
//echo '{"status":"success", "msg":"Your video (' . $filename . ') is encoding <br> ' . $cmd . '", "filename":"' . $filename . '", "duration":"' . $duration . '"}'; //echo '{"status":"success", "msg":"Your video (' . $filename . ') is encoding <br> ' . $cmd . '", "filename":"' . $filename . '", "duration":"' . $duration . '"}';
status(["status" => "success" status(["status" => "success", "msg" => "Your video ($filename) is queue", "filename" => "$filename", "duration" => "$duration", "queue" => json_encode($queue)]);
, "msg" => "Your video ($filename) is queue" //exit;
, "filename" => "$filename"
, "duration" => "$duration"
, "queue" => json_encode($queue)]);
//exit;
} else { } else {
//echo '{"status":"error", "msg":' . json_encode($_FILES) . ', "type":"$_FILES Error"}'; //echo '{"status":"error", "msg":' . json_encode($_FILES) . ', "type":"$_FILES Error"}';
status(["status" => "error", "msg" => print_r($_FILES, true), "type" => '$_FILES Error']); status(["status" => "error", "msg" => print_r($_FILES, true), "type" => '$_FILES Error']);

View file

@ -1,7 +1,5 @@
<?php <?php
ini_set('error_log', '../videos/avideo.js.log'); ini_set('error_log', '../videos/avideo.js.log');
if(!empty($_GET['error'])){ if (!empty($_GET['error'])) {
error_log("[aEC] ".$_GET['error']); error_log("[aEC] ".$_GET['error']);
} }
?>

View file

@ -1,4 +1,2 @@
<?php <?php
require_once __DIR__ . '/../vendor/autoload.php'; require_once __DIR__ . '/../vendor/autoload.php';

View file

@ -1,457 +1,456 @@
<?php <?php
/** /**
* These are just the language codes, not regions. This means it only lists en, not en-US, en-CA etc. * These are just the language codes, not regions. This means it only lists en, not en-US, en-CA etc.
* @see http://www.iana.org/assignments/language-subtag-registry * @see http://www.iana.org/assignments/language-subtag-registry
*/ */
$global['langs_codes'] = array( $global['langs_codes'] = [
array('value'=>'af_NA','label'=>'Afrikaans (Namibia)', 'flag'=>'na'), ['value' => 'af_NA','label' => 'Afrikaans (Namibia)', 'flag' => 'na'],
array('value'=>'af_ZA','label'=>'Afrikaans (South Africa)', 'flag'=>'za'), ['value' => 'af_ZA','label' => 'Afrikaans (South Africa)', 'flag' => 'za'],
array('value'=>'af','label'=>'Afrikaans', 'flag'=>'af'), ['value' => 'af','label' => 'Afrikaans', 'flag' => 'af'],
array('value'=>'ak_GH','label'=>'Akan (Ghana)', 'flag'=>'gh'), ['value' => 'ak_GH','label' => 'Akan (Ghana)', 'flag' => 'gh'],
array('value'=>'ak','label'=>'Akan', 'flag'=>'ak'), ['value' => 'ak','label' => 'Akan', 'flag' => 'ak'],
array('value'=>'sq_AL','label'=>'Albanian (Albania)', 'flag'=>'al'), ['value' => 'sq_AL','label' => 'Albanian (Albania)', 'flag' => 'al'],
array('value'=>'sq','label'=>'Albanian', 'flag'=>'sq'), ['value' => 'sq','label' => 'Albanian', 'flag' => 'sq'],
array('value'=>'am_ET','label'=>'Amharic (Ethiopia)', 'flag'=>'et'), ['value' => 'am_ET','label' => 'Amharic (Ethiopia)', 'flag' => 'et'],
array('value'=>'am','label'=>'Amharic', 'flag'=>'am'), ['value' => 'am','label' => 'Amharic', 'flag' => 'am'],
array('value'=>'ar_DZ','label'=>'Arabic (Algeria)', 'flag'=>'dz'), ['value' => 'ar_DZ','label' => 'Arabic (Algeria)', 'flag' => 'dz'],
array('value'=>'ar_BH','label'=>'Arabic (Bahrain)', 'flag'=>'bh'), ['value' => 'ar_BH','label' => 'Arabic (Bahrain)', 'flag' => 'bh'],
array('value'=>'ar_EG','label'=>'Arabic (Egypt)', 'flag'=>'eg'), ['value' => 'ar_EG','label' => 'Arabic (Egypt)', 'flag' => 'eg'],
array('value'=>'ar_IQ','label'=>'Arabic (Iraq)', 'flag'=>'iq'), ['value' => 'ar_IQ','label' => 'Arabic (Iraq)', 'flag' => 'iq'],
array('value'=>'ar_JO','label'=>'Arabic (Jordan)', 'flag'=>'jo'), ['value' => 'ar_JO','label' => 'Arabic (Jordan)', 'flag' => 'jo'],
array('value'=>'ar_KW','label'=>'Arabic (Kuwait)', 'flag'=>'kw'), ['value' => 'ar_KW','label' => 'Arabic (Kuwait)', 'flag' => 'kw'],
array('value'=>'ar_LB','label'=>'Arabic (Lebanon)', 'flag'=>'lb'), ['value' => 'ar_LB','label' => 'Arabic (Lebanon)', 'flag' => 'lb'],
array('value'=>'ar_LY','label'=>'Arabic (Libya)', 'flag'=>'ly'), ['value' => 'ar_LY','label' => 'Arabic (Libya)', 'flag' => 'ly'],
array('value'=>'ar_MA','label'=>'Arabic (Morocco)', 'flag'=>'ma'), ['value' => 'ar_MA','label' => 'Arabic (Morocco)', 'flag' => 'ma'],
array('value'=>'ar_OM','label'=>'Arabic (Oman)', 'flag'=>'om'), ['value' => 'ar_OM','label' => 'Arabic (Oman)', 'flag' => 'om'],
array('value'=>'ar_QA','label'=>'Arabic (Qatar)', 'flag'=>'qa'), ['value' => 'ar_QA','label' => 'Arabic (Qatar)', 'flag' => 'qa'],
array('value'=>'ar_SA','label'=>'Arabic (Saudi Arabia)', 'flag'=>'sa'), ['value' => 'ar_SA','label' => 'Arabic (Saudi Arabia)', 'flag' => 'sa'],
array('value'=>'ar_SD','label'=>'Arabic (Sudan)', 'flag'=>'sd'), ['value' => 'ar_SD','label' => 'Arabic (Sudan)', 'flag' => 'sd'],
array('value'=>'ar_SY','label'=>'Arabic (Syria)', 'flag'=>'sy'), ['value' => 'ar_SY','label' => 'Arabic (Syria)', 'flag' => 'sy'],
array('value'=>'ar_TN','label'=>'Arabic (Tunisia)', 'flag'=>'tn'), ['value' => 'ar_TN','label' => 'Arabic (Tunisia)', 'flag' => 'tn'],
array('value'=>'ar_AE','label'=>'Arabic (United Arab Emirates)', 'flag'=>'ae'), ['value' => 'ar_AE','label' => 'Arabic (United Arab Emirates)', 'flag' => 'ae'],
array('value'=>'ar_YE','label'=>'Arabic (Yemen)', 'flag'=>'ye'), ['value' => 'ar_YE','label' => 'Arabic (Yemen)', 'flag' => 'ye'],
array('value'=>'ar','label'=>'Arabic', 'flag'=>'ar'), ['value' => 'ar','label' => 'Arabic', 'flag' => 'ar'],
array('value'=>'hy_AM','label'=>'Armenian (Armenia)', 'flag'=>'am'), ['value' => 'hy_AM','label' => 'Armenian (Armenia)', 'flag' => 'am'],
array('value'=>'hy','label'=>'Armenian', 'flag'=>'hy'), ['value' => 'hy','label' => 'Armenian', 'flag' => 'hy'],
array('value'=>'as_IN','label'=>'Assamese (India)', 'flag'=>'in'), ['value' => 'as_IN','label' => 'Assamese (India)', 'flag' => 'in'],
array('value'=>'as','label'=>'Assamese', 'flag'=>'as'), ['value' => 'as','label' => 'Assamese', 'flag' => 'as'],
array('value'=>'asa_TZ','label'=>'Asu (Tanzania)', 'flag'=>'tz'), ['value' => 'asa_TZ','label' => 'Asu (Tanzania)', 'flag' => 'tz'],
array('value'=>'asa','label'=>'Asu', 'flag'=>'asa'), ['value' => 'asa','label' => 'Asu', 'flag' => 'asa'],
array('value'=>'az_Cyrl','label'=>'Azerbaijani (Cyrillic)', 'flag'=>'cyrl'), ['value' => 'az_Cyrl','label' => 'Azerbaijani (Cyrillic)', 'flag' => 'cyrl'],
array('value'=>'az_Cyrl_AZ','label'=>'Azerbaijani (Cyrillic, Azerbaijan)', 'flag'=>'az'), ['value' => 'az_Cyrl_AZ','label' => 'Azerbaijani (Cyrillic, Azerbaijan)', 'flag' => 'az'],
array('value'=>'az_Latn','label'=>'Azerbaijani (Latin)', 'flag'=>'latn'), ['value' => 'az_Latn','label' => 'Azerbaijani (Latin)', 'flag' => 'latn'],
array('value'=>'az_Latn_AZ','label'=>'Azerbaijani (Latin, Azerbaijan)', 'flag'=>'az'), ['value' => 'az_Latn_AZ','label' => 'Azerbaijani (Latin, Azerbaijan)', 'flag' => 'az'],
array('value'=>'az','label'=>'Azerbaijani', 'flag'=>'az'), ['value' => 'az','label' => 'Azerbaijani', 'flag' => 'az'],
array('value'=>'bm_ML','label'=>'Bambara (Mali)', 'flag'=>'ml'), ['value' => 'bm_ML','label' => 'Bambara (Mali)', 'flag' => 'ml'],
array('value'=>'bm','label'=>'Bambara', 'flag'=>'bm'), ['value' => 'bm','label' => 'Bambara', 'flag' => 'bm'],
array('value'=>'eu_ES','label'=>'Basque (Spain)', 'flag'=>'es'), ['value' => 'eu_ES','label' => 'Basque (Spain)', 'flag' => 'es'],
array('value'=>'eu','label'=>'Basque', 'flag'=>'eu'), ['value' => 'eu','label' => 'Basque', 'flag' => 'eu'],
array('value'=>'be_BY','label'=>'Belarusian (Belarus)', 'flag'=>'by'), ['value' => 'be_BY','label' => 'Belarusian (Belarus)', 'flag' => 'by'],
array('value'=>'be','label'=>'Belarusian', 'flag'=>'be'), ['value' => 'be','label' => 'Belarusian', 'flag' => 'be'],
array('value'=>'bem_ZM','label'=>'Bemba (Zambia)', 'flag'=>'zm'), ['value' => 'bem_ZM','label' => 'Bemba (Zambia)', 'flag' => 'zm'],
array('value'=>'bem','label'=>'Bemba', 'flag'=>'bem'), ['value' => 'bem','label' => 'Bemba', 'flag' => 'bem'],
array('value'=>'bez_TZ','label'=>'Bena (Tanzania)', 'flag'=>'tz'), ['value' => 'bez_TZ','label' => 'Bena (Tanzania)', 'flag' => 'tz'],
array('value'=>'bez','label'=>'Bena', 'flag'=>'bez'), ['value' => 'bez','label' => 'Bena', 'flag' => 'bez'],
array('value'=>'bn_BD','label'=>'Bengali (Bangladesh)', 'flag'=>'bd'), ['value' => 'bn_BD','label' => 'Bengali (Bangladesh)', 'flag' => 'bd'],
array('value'=>'bn_IN','label'=>'Bengali (India)', 'flag'=>'in'), ['value' => 'bn_IN','label' => 'Bengali (India)', 'flag' => 'in'],
array('value'=>'bn','label'=>'Bengali', 'flag'=>'bn'), ['value' => 'bn','label' => 'Bengali', 'flag' => 'bn'],
array('value'=>'bs_BA','label'=>'Bosnian (Bosnia and Herzegovina)', 'flag'=>'ba'), ['value' => 'bs_BA','label' => 'Bosnian (Bosnia and Herzegovina)', 'flag' => 'ba'],
array('value'=>'bs','label'=>'Bosnian', 'flag'=>'bs'), ['value' => 'bs','label' => 'Bosnian', 'flag' => 'bs'],
array('value'=>'bg_BG','label'=>'Bulgarian (Bulgaria)', 'flag'=>'bg'), ['value' => 'bg_BG','label' => 'Bulgarian (Bulgaria)', 'flag' => 'bg'],
array('value'=>'bg','label'=>'Bulgarian', 'flag'=>'bg'), ['value' => 'bg','label' => 'Bulgarian', 'flag' => 'bg'],
array('value'=>'my_MM','label'=>'Burmese (Myanmar [Burma])', 'flag'=>'mm'), ['value' => 'my_MM','label' => 'Burmese (Myanmar [Burma])', 'flag' => 'mm'],
array('value'=>'my','label'=>'Burmese', 'flag'=>'my'), ['value' => 'my','label' => 'Burmese', 'flag' => 'my'],
array('value'=>'yue_Hant_HK','label'=>'Cantonese (Traditional, Hong Kong SAR China)', 'flag'=>'hk'), ['value' => 'yue_Hant_HK','label' => 'Cantonese (Traditional, Hong Kong SAR China)', 'flag' => 'hk'],
array('value'=>'ca_ES','label'=>'Catalan (Spain)', 'flag'=>'es'), ['value' => 'ca_ES','label' => 'Catalan (Spain)', 'flag' => 'es'],
array('value'=>'ca','label'=>'Catalan', 'flag'=>'ca'), ['value' => 'ca','label' => 'Catalan', 'flag' => 'ca'],
array('value'=>'tzm_Latn','label'=>'Central Morocco Tamazight (Latin)', 'flag'=>'latn'), ['value' => 'tzm_Latn','label' => 'Central Morocco Tamazight (Latin)', 'flag' => 'latn'],
array('value'=>'tzm_Latn_MA','label'=>'Central Morocco Tamazight (Latin, Morocco)', 'flag'=>'ma'), ['value' => 'tzm_Latn_MA','label' => 'Central Morocco Tamazight (Latin, Morocco)', 'flag' => 'ma'],
array('value'=>'tzm','label'=>'Central Morocco Tamazight', 'flag'=>'tzm'), ['value' => 'tzm','label' => 'Central Morocco Tamazight', 'flag' => 'tzm'],
array('value'=>'chr_US','label'=>'Cherokee (United States)', 'flag'=>'us'), ['value' => 'chr_US','label' => 'Cherokee (United States)', 'flag' => 'us'],
array('value'=>'chr','label'=>'Cherokee', 'flag'=>'chr'), ['value' => 'chr','label' => 'Cherokee', 'flag' => 'chr'],
array('value'=>'cgg_UG','label'=>'Chiga (Uganda)', 'flag'=>'ug'), ['value' => 'cgg_UG','label' => 'Chiga (Uganda)', 'flag' => 'ug'],
array('value'=>'cgg','label'=>'Chiga', 'flag'=>'cgg'), ['value' => 'cgg','label' => 'Chiga', 'flag' => 'cgg'],
array('value'=>'zh_Hans','label'=>'Chinese (Simplified Han)', 'flag'=>'hans'), ['value' => 'zh_Hans','label' => 'Chinese (Simplified Han)', 'flag' => 'hans'],
array('value'=>'zh_Hans_CN','label'=>'Chinese (Simplified Han, China)', 'flag'=>'cn'), ['value' => 'zh_Hans_CN','label' => 'Chinese (Simplified Han, China)', 'flag' => 'cn'],
array('value'=>'zh_Hans_HK','label'=>'Chinese (Simplified Han, Hong Kong SAR China)', 'flag'=>'hk'), ['value' => 'zh_Hans_HK','label' => 'Chinese (Simplified Han, Hong Kong SAR China)', 'flag' => 'hk'],
array('value'=>'zh_Hans_MO','label'=>'Chinese (Simplified Han, Macau SAR China)', 'flag'=>'mo'), ['value' => 'zh_Hans_MO','label' => 'Chinese (Simplified Han, Macau SAR China)', 'flag' => 'mo'],
array('value'=>'zh_Hans_SG','label'=>'Chinese (Simplified Han, Singapore)', 'flag'=>'sg'), ['value' => 'zh_Hans_SG','label' => 'Chinese (Simplified Han, Singapore)', 'flag' => 'sg'],
array('value'=>'zh_Hant','label'=>'Chinese (Traditional Han)', 'flag'=>'hant'), ['value' => 'zh_Hant','label' => 'Chinese (Traditional Han)', 'flag' => 'hant'],
array('value'=>'zh_Hant_HK','label'=>'Chinese (Traditional Han, Hong Kong SAR China)', 'flag'=>'hk'), ['value' => 'zh_Hant_HK','label' => 'Chinese (Traditional Han, Hong Kong SAR China)', 'flag' => 'hk'],
array('value'=>'zh_Hant_MO','label'=>'Chinese (Traditional Han, Macau SAR China)', 'flag'=>'mo'), ['value' => 'zh_Hant_MO','label' => 'Chinese (Traditional Han, Macau SAR China)', 'flag' => 'mo'],
array('value'=>'zh_Hant_TW','label'=>'Chinese (Traditional Han, Taiwan)', 'flag'=>'tw'), ['value' => 'zh_Hant_TW','label' => 'Chinese (Traditional Han, Taiwan)', 'flag' => 'tw'],
array('value'=>'zh','label'=>'Chinese', 'flag'=>'cn'), ['value' => 'zh','label' => 'Chinese', 'flag' => 'cn'],
array('value'=>'kw_GB','label'=>'Cornish (United Kingdom)', 'flag'=>'gb'), ['value' => 'kw_GB','label' => 'Cornish (United Kingdom)', 'flag' => 'gb'],
array('value'=>'kw','label'=>'Cornish', 'flag'=>'kw'), ['value' => 'kw','label' => 'Cornish', 'flag' => 'kw'],
array('value'=>'hr_HR','label'=>'Croatian (Croatia)', 'flag'=>'hr'), ['value' => 'hr_HR','label' => 'Croatian (Croatia)', 'flag' => 'hr'],
array('value'=>'hr','label'=>'Croatian', 'flag'=>'hr'), ['value' => 'hr','label' => 'Croatian', 'flag' => 'hr'],
array('value'=>'cs_CZ','label'=>'Czech (Czech Republic)', 'flag'=>'cz'), ['value' => 'cs_CZ','label' => 'Czech (Czech Republic)', 'flag' => 'cz'],
array('value'=>'cs','label'=>'Czech', 'flag'=>'cz'), ['value' => 'cs','label' => 'Czech', 'flag' => 'cz'],
array('value'=>'da_DK','label'=>'Danish (Denmark)', 'flag'=>'dk'), ['value' => 'da_DK','label' => 'Danish (Denmark)', 'flag' => 'dk'],
array('value'=>'da','label'=>'Danish', 'flag'=>'da'), ['value' => 'da','label' => 'Danish', 'flag' => 'da'],
array('value'=>'nl_BE','label'=>'Dutch (Belgium)', 'flag'=>'be'), ['value' => 'nl_BE','label' => 'Dutch (Belgium)', 'flag' => 'be'],
array('value'=>'nl_NL','label'=>'Dutch (Netherlands)', 'flag'=>'nl'), ['value' => 'nl_NL','label' => 'Dutch (Netherlands)', 'flag' => 'nl'],
array('value'=>'nl','label'=>'Dutch', 'flag'=>'nl'), ['value' => 'nl','label' => 'Dutch', 'flag' => 'nl'],
array('value'=>'ebu_KE','label'=>'Embu (Kenya)', 'flag'=>'ke'), ['value' => 'ebu_KE','label' => 'Embu (Kenya)', 'flag' => 'ke'],
array('value'=>'ebu','label'=>'Embu', 'flag'=>'ebu'), ['value' => 'ebu','label' => 'Embu', 'flag' => 'ebu'],
array('value'=>'en_US','label'=>'English (United States)', 'flag'=>'us'), ['value' => 'en_US','label' => 'English (United States)', 'flag' => 'us'],
array('value'=>'en_GB','label'=>'English (United Kingdom)', 'flag'=>'gb'), ['value' => 'en_GB','label' => 'English (United Kingdom)', 'flag' => 'gb'],
array('value'=>'en_AS','label'=>'English (American Samoa)', 'flag'=>'as'), ['value' => 'en_AS','label' => 'English (American Samoa)', 'flag' => 'as'],
array('value'=>'en_AU','label'=>'English (Australia)', 'flag'=>'au'), ['value' => 'en_AU','label' => 'English (Australia)', 'flag' => 'au'],
array('value'=>'en_BE','label'=>'English (Belgium)', 'flag'=>'be'), ['value' => 'en_BE','label' => 'English (Belgium)', 'flag' => 'be'],
array('value'=>'en_BZ','label'=>'English (Belize)', 'flag'=>'bz'), ['value' => 'en_BZ','label' => 'English (Belize)', 'flag' => 'bz'],
array('value'=>'en_BW','label'=>'English (Botswana)', 'flag'=>'bw'), ['value' => 'en_BW','label' => 'English (Botswana)', 'flag' => 'bw'],
array('value'=>'en_CA','label'=>'English (Canada)', 'flag'=>'ca'), ['value' => 'en_CA','label' => 'English (Canada)', 'flag' => 'ca'],
array('value'=>'en_GU','label'=>'English (Guam)', 'flag'=>'gu'), ['value' => 'en_GU','label' => 'English (Guam)', 'flag' => 'gu'],
array('value'=>'en_HK','label'=>'English (Hong Kong SAR China)', 'flag'=>'hk'), ['value' => 'en_HK','label' => 'English (Hong Kong SAR China)', 'flag' => 'hk'],
array('value'=>'en_IN','label'=>'English (India)', 'flag'=>'in'), ['value' => 'en_IN','label' => 'English (India)', 'flag' => 'in'],
array('value'=>'en_IE','label'=>'English (Ireland)', 'flag'=>'ie'), ['value' => 'en_IE','label' => 'English (Ireland)', 'flag' => 'ie'],
array('value'=>'en_IL','label'=>'English (Israel)', 'flag'=>'il'), ['value' => 'en_IL','label' => 'English (Israel)', 'flag' => 'il'],
array('value'=>'en_JM','label'=>'English (Jamaica)', 'flag'=>'jm'), ['value' => 'en_JM','label' => 'English (Jamaica)', 'flag' => 'jm'],
array('value'=>'en_MT','label'=>'English (Malta)', 'flag'=>'mt'), ['value' => 'en_MT','label' => 'English (Malta)', 'flag' => 'mt'],
array('value'=>'en_MH','label'=>'English (Marshall Islands)', 'flag'=>'mh'), ['value' => 'en_MH','label' => 'English (Marshall Islands)', 'flag' => 'mh'],
array('value'=>'en_MU','label'=>'English (Mauritius)', 'flag'=>'mu'), ['value' => 'en_MU','label' => 'English (Mauritius)', 'flag' => 'mu'],
array('value'=>'en_NA','label'=>'English (Namibia)', 'flag'=>'na'), ['value' => 'en_NA','label' => 'English (Namibia)', 'flag' => 'na'],
array('value'=>'en_NZ','label'=>'English (New Zealand)', 'flag'=>'nz'), ['value' => 'en_NZ','label' => 'English (New Zealand)', 'flag' => 'nz'],
array('value'=>'en_MP','label'=>'English (Northern Mariana Islands)', 'flag'=>'mp'), ['value' => 'en_MP','label' => 'English (Northern Mariana Islands)', 'flag' => 'mp'],
array('value'=>'en_PK','label'=>'English (Pakistan)', 'flag'=>'pk'), ['value' => 'en_PK','label' => 'English (Pakistan)', 'flag' => 'pk'],
array('value'=>'en_PH','label'=>'English (Philippines)', 'flag'=>'ph'), ['value' => 'en_PH','label' => 'English (Philippines)', 'flag' => 'ph'],
array('value'=>'en_SG','label'=>'English (Singapore)', 'flag'=>'sg'), ['value' => 'en_SG','label' => 'English (Singapore)', 'flag' => 'sg'],
array('value'=>'en_ZA','label'=>'English (South Africa)', 'flag'=>'za'), ['value' => 'en_ZA','label' => 'English (South Africa)', 'flag' => 'za'],
array('value'=>'en_TT','label'=>'English (Trinidad and Tobago)', 'flag'=>'tt'), ['value' => 'en_TT','label' => 'English (Trinidad and Tobago)', 'flag' => 'tt'],
array('value'=>'en_UM','label'=>'English (U.S. Minor Outlying Islands)', 'flag'=>'um'), ['value' => 'en_UM','label' => 'English (U.S. Minor Outlying Islands)', 'flag' => 'um'],
array('value'=>'en_VI','label'=>'English (U.S. Virgin Islands)', 'flag'=>'vi'), ['value' => 'en_VI','label' => 'English (U.S. Virgin Islands)', 'flag' => 'vi'],
array('value'=>'en_ZW','label'=>'English (Zimbabwe)', 'flag'=>'zw'), ['value' => 'en_ZW','label' => 'English (Zimbabwe)', 'flag' => 'zw'],
array('value'=>'en','label'=>'English', 'flag'=>'us'), ['value' => 'en','label' => 'English', 'flag' => 'us'],
array('value'=>'eo','label'=>'Esperanto', 'flag'=>'eo'), ['value' => 'eo','label' => 'Esperanto', 'flag' => 'eo'],
array('value'=>'et_EE','label'=>'Estonian (Estonia)', 'flag'=>'ee'), ['value' => 'et_EE','label' => 'Estonian (Estonia)', 'flag' => 'ee'],
array('value'=>'et','label'=>'Estonian', 'flag'=>'et'), ['value' => 'et','label' => 'Estonian', 'flag' => 'et'],
array('value'=>'ee_GH','label'=>'Ewe (Ghana)', 'flag'=>'gh'), ['value' => 'ee_GH','label' => 'Ewe (Ghana)', 'flag' => 'gh'],
array('value'=>'ee_TG','label'=>'Ewe (Togo)', 'flag'=>'tg'), ['value' => 'ee_TG','label' => 'Ewe (Togo)', 'flag' => 'tg'],
array('value'=>'ee','label'=>'Ewe', 'flag'=>'ee'), ['value' => 'ee','label' => 'Ewe', 'flag' => 'ee'],
array('value'=>'fo_FO','label'=>'Faroese (Faroe Islands)', 'flag'=>'fo'), ['value' => 'fo_FO','label' => 'Faroese (Faroe Islands)', 'flag' => 'fo'],
array('value'=>'fo','label'=>'Faroese', 'flag'=>'fo'), ['value' => 'fo','label' => 'Faroese', 'flag' => 'fo'],
array('value'=>'fil_PH','label'=>'Filipino (Philippines)', 'flag'=>'ph'), ['value' => 'fil_PH','label' => 'Filipino (Philippines)', 'flag' => 'ph'],
array('value'=>'fil','label'=>'Filipino', 'flag'=>'fil'), ['value' => 'fil','label' => 'Filipino', 'flag' => 'fil'],
array('value'=>'fi_FI','label'=>'Finnish (Finland)', 'flag'=>'fi'), ['value' => 'fi_FI','label' => 'Finnish (Finland)', 'flag' => 'fi'],
array('value'=>'fi','label'=>'Finnish', 'flag'=>'fi'), ['value' => 'fi','label' => 'Finnish', 'flag' => 'fi'],
array('value'=>'fr_BE','label'=>'French (Belgium)', 'flag'=>'be'), ['value' => 'fr_BE','label' => 'French (Belgium)', 'flag' => 'be'],
array('value'=>'fr_BJ','label'=>'French (Benin)', 'flag'=>'bj'), ['value' => 'fr_BJ','label' => 'French (Benin)', 'flag' => 'bj'],
array('value'=>'fr_BF','label'=>'French (Burkina Faso)', 'flag'=>'bf'), ['value' => 'fr_BF','label' => 'French (Burkina Faso)', 'flag' => 'bf'],
array('value'=>'fr_BI','label'=>'French (Burundi)', 'flag'=>'bi'), ['value' => 'fr_BI','label' => 'French (Burundi)', 'flag' => 'bi'],
array('value'=>'fr_CM','label'=>'French (Cameroon)', 'flag'=>'cm'), ['value' => 'fr_CM','label' => 'French (Cameroon)', 'flag' => 'cm'],
array('value'=>'fr_CA','label'=>'French (Canada)', 'flag'=>'ca'), ['value' => 'fr_CA','label' => 'French (Canada)', 'flag' => 'ca'],
array('value'=>'fr_CF','label'=>'French (Central African Republic)', 'flag'=>'cf'), ['value' => 'fr_CF','label' => 'French (Central African Republic)', 'flag' => 'cf'],
array('value'=>'fr_TD','label'=>'French (Chad)', 'flag'=>'td'), ['value' => 'fr_TD','label' => 'French (Chad)', 'flag' => 'td'],
array('value'=>'fr_KM','label'=>'French (Comoros)', 'flag'=>'km'), ['value' => 'fr_KM','label' => 'French (Comoros)', 'flag' => 'km'],
array('value'=>'fr_CG','label'=>'French (Congo - Brazzaville)', 'flag'=>'cg'), ['value' => 'fr_CG','label' => 'French (Congo - Brazzaville)', 'flag' => 'cg'],
array('value'=>'fr_CD','label'=>'French (Congo - Kinshasa)', 'flag'=>'cd'), ['value' => 'fr_CD','label' => 'French (Congo - Kinshasa)', 'flag' => 'cd'],
array('value'=>'fr_CI','label'=>'French (Côte dIvoire)', 'flag'=>'ci'), ['value' => 'fr_CI','label' => 'French (Côte dIvoire)', 'flag' => 'ci'],
array('value'=>'fr_DJ','label'=>'French (Djibouti)', 'flag'=>'dj'), ['value' => 'fr_DJ','label' => 'French (Djibouti)', 'flag' => 'dj'],
array('value'=>'fr_GQ','label'=>'French (Equatorial Guinea)', 'flag'=>'gq'), ['value' => 'fr_GQ','label' => 'French (Equatorial Guinea)', 'flag' => 'gq'],
array('value'=>'fr_FR','label'=>'French (France)', 'flag'=>'fr'), ['value' => 'fr_FR','label' => 'French (France)', 'flag' => 'fr'],
array('value'=>'fr_GA','label'=>'French (Gabon)', 'flag'=>'ga'), ['value' => 'fr_GA','label' => 'French (Gabon)', 'flag' => 'ga'],
array('value'=>'fr_GP','label'=>'French (Guadeloupe)', 'flag'=>'gp'), ['value' => 'fr_GP','label' => 'French (Guadeloupe)', 'flag' => 'gp'],
array('value'=>'fr_GN','label'=>'French (Guinea)', 'flag'=>'gn'), ['value' => 'fr_GN','label' => 'French (Guinea)', 'flag' => 'gn'],
array('value'=>'fr_LU','label'=>'French (Luxembourg)', 'flag'=>'lu'), ['value' => 'fr_LU','label' => 'French (Luxembourg)', 'flag' => 'lu'],
array('value'=>'fr_MG','label'=>'French (Madagascar)', 'flag'=>'mg'), ['value' => 'fr_MG','label' => 'French (Madagascar)', 'flag' => 'mg'],
array('value'=>'fr_ML','label'=>'French (Mali)', 'flag'=>'ml'), ['value' => 'fr_ML','label' => 'French (Mali)', 'flag' => 'ml'],
array('value'=>'fr_MQ','label'=>'French (Martinique)', 'flag'=>'mq'), ['value' => 'fr_MQ','label' => 'French (Martinique)', 'flag' => 'mq'],
array('value'=>'fr_MC','label'=>'French (Monaco)', 'flag'=>'mc'), ['value' => 'fr_MC','label' => 'French (Monaco)', 'flag' => 'mc'],
array('value'=>'fr_NE','label'=>'French (Niger)', 'flag'=>'ne'), ['value' => 'fr_NE','label' => 'French (Niger)', 'flag' => 'ne'],
array('value'=>'fr_RW','label'=>'French (Rwanda)', 'flag'=>'rw'), ['value' => 'fr_RW','label' => 'French (Rwanda)', 'flag' => 'rw'],
array('value'=>'fr_RE','label'=>'French (Réunion)', 'flag'=>'re'), ['value' => 'fr_RE','label' => 'French (Réunion)', 'flag' => 're'],
array('value'=>'fr_BL','label'=>'French (Saint Barthélemy)', 'flag'=>'bl'), ['value' => 'fr_BL','label' => 'French (Saint Barthélemy)', 'flag' => 'bl'],
array('value'=>'fr_MF','label'=>'French (Saint Martin)', 'flag'=>'mf'), ['value' => 'fr_MF','label' => 'French (Saint Martin)', 'flag' => 'mf'],
array('value'=>'fr_SN','label'=>'French (Senegal)', 'flag'=>'sn'), ['value' => 'fr_SN','label' => 'French (Senegal)', 'flag' => 'sn'],
array('value'=>'fr_CH','label'=>'French (Switzerland)', 'flag'=>'ch'), ['value' => 'fr_CH','label' => 'French (Switzerland)', 'flag' => 'ch'],
array('value'=>'fr_TG','label'=>'French (Togo)', 'flag'=>'tg'), ['value' => 'fr_TG','label' => 'French (Togo)', 'flag' => 'tg'],
array('value'=>'fr','label'=>'French', 'flag'=>'fr'), ['value' => 'fr','label' => 'French', 'flag' => 'fr'],
array('value'=>'ff_SN','label'=>'Fulah (Senegal)', 'flag'=>'sn'), ['value' => 'ff_SN','label' => 'Fulah (Senegal)', 'flag' => 'sn'],
array('value'=>'ff','label'=>'Fulah', 'flag'=>'ff'), ['value' => 'ff','label' => 'Fulah', 'flag' => 'ff'],
array('value'=>'gl_ES','label'=>'Galician (Spain)', 'flag'=>'es'), ['value' => 'gl_ES','label' => 'Galician (Spain)', 'flag' => 'es'],
array('value'=>'gl','label'=>'Galician', 'flag'=>'gl'), ['value' => 'gl','label' => 'Galician', 'flag' => 'gl'],
array('value'=>'lg_UG','label'=>'Ganda (Uganda)', 'flag'=>'ug'), ['value' => 'lg_UG','label' => 'Ganda (Uganda)', 'flag' => 'ug'],
array('value'=>'lg','label'=>'Ganda', 'flag'=>'lg'), ['value' => 'lg','label' => 'Ganda', 'flag' => 'lg'],
array('value'=>'ka_GE','label'=>'Georgian (Georgia)', 'flag'=>'ge'), ['value' => 'ka_GE','label' => 'Georgian (Georgia)', 'flag' => 'ge'],
array('value'=>'ka','label'=>'Georgian', 'flag'=>'ka'), ['value' => 'ka','label' => 'Georgian', 'flag' => 'ka'],
array('value'=>'de_AT','label'=>'German (Austria)', 'flag'=>'at'), ['value' => 'de_AT','label' => 'German (Austria)', 'flag' => 'at'],
array('value'=>'de_BE','label'=>'German (Belgium)', 'flag'=>'be'), ['value' => 'de_BE','label' => 'German (Belgium)', 'flag' => 'be'],
array('value'=>'de_DE','label'=>'German (Germany)', 'flag'=>'de'), ['value' => 'de_DE','label' => 'German (Germany)', 'flag' => 'de'],
array('value'=>'de_LI','label'=>'German (Liechtenstein)', 'flag'=>'li'), ['value' => 'de_LI','label' => 'German (Liechtenstein)', 'flag' => 'li'],
array('value'=>'de_LU','label'=>'German (Luxembourg)', 'flag'=>'lu'), ['value' => 'de_LU','label' => 'German (Luxembourg)', 'flag' => 'lu'],
array('value'=>'de_CH','label'=>'German (Switzerland)', 'flag'=>'ch'), ['value' => 'de_CH','label' => 'German (Switzerland)', 'flag' => 'ch'],
array('value'=>'de','label'=>'German', 'flag'=>'de'), ['value' => 'de','label' => 'German', 'flag' => 'de'],
array('value'=>'el_CY','label'=>'Greek (Cyprus)', 'flag'=>'cy'), ['value' => 'el_CY','label' => 'Greek (Cyprus)', 'flag' => 'cy'],
array('value'=>'el_GR','label'=>'Greek (Greece)', 'flag'=>'gr'), ['value' => 'el_GR','label' => 'Greek (Greece)', 'flag' => 'gr'],
array('value'=>'el','label'=>'Greek', 'flag'=>'gr'), ['value' => 'el','label' => 'Greek', 'flag' => 'gr'],
array('value'=>'gu_IN','label'=>'Gujarati (India)', 'flag'=>'in'), ['value' => 'gu_IN','label' => 'Gujarati (India)', 'flag' => 'in'],
array('value'=>'gu','label'=>'Gujarati', 'flag'=>'gu'), ['value' => 'gu','label' => 'Gujarati', 'flag' => 'gu'],
array('value'=>'guz_KE','label'=>'Gusii (Kenya)', 'flag'=>'ke'), ['value' => 'guz_KE','label' => 'Gusii (Kenya)', 'flag' => 'ke'],
array('value'=>'guz','label'=>'Gusii', 'flag'=>'guz'), ['value' => 'guz','label' => 'Gusii', 'flag' => 'guz'],
array('value'=>'ha_Latn','label'=>'Hausa (Latin)', 'flag'=>'latn'), ['value' => 'ha_Latn','label' => 'Hausa (Latin)', 'flag' => 'latn'],
array('value'=>'ha_Latn_GH','label'=>'Hausa (Latin, Ghana)', 'flag'=>'gh'), ['value' => 'ha_Latn_GH','label' => 'Hausa (Latin, Ghana)', 'flag' => 'gh'],
array('value'=>'ha_Latn_NE','label'=>'Hausa (Latin, Niger)', 'flag'=>'ne'), ['value' => 'ha_Latn_NE','label' => 'Hausa (Latin, Niger)', 'flag' => 'ne'],
array('value'=>'ha_Latn_NG','label'=>'Hausa (Latin, Nigeria)', 'flag'=>'ng'), ['value' => 'ha_Latn_NG','label' => 'Hausa (Latin, Nigeria)', 'flag' => 'ng'],
array('value'=>'ha','label'=>'Hausa', 'flag'=>'ha'), ['value' => 'ha','label' => 'Hausa', 'flag' => 'ha'],
array('value'=>'haw_US','label'=>'Hawaiian (United States)', 'flag'=>'us'), ['value' => 'haw_US','label' => 'Hawaiian (United States)', 'flag' => 'us'],
array('value'=>'haw','label'=>'Hawaiian', 'flag'=>'haw'), ['value' => 'haw','label' => 'Hawaiian', 'flag' => 'haw'],
array('value'=>'he_IL','label'=>'Hebrew (Israel)', 'flag'=>'il'), ['value' => 'he_IL','label' => 'Hebrew (Israel)', 'flag' => 'il'],
array('value'=>'he','label'=>'Hebrew', 'flag'=>'il'), ['value' => 'he','label' => 'Hebrew', 'flag' => 'il'],
array('value'=>'hi_IN','label'=>'Hindi (India)', 'flag'=>'in'), ['value' => 'hi_IN','label' => 'Hindi (India)', 'flag' => 'in'],
array('value'=>'hi','label'=>'Hindi', 'flag'=>'hi'), ['value' => 'hi','label' => 'Hindi', 'flag' => 'hi'],
array('value'=>'hu_HU','label'=>'Hungarian (Hungary)', 'flag'=>'hu'), ['value' => 'hu_HU','label' => 'Hungarian (Hungary)', 'flag' => 'hu'],
array('value'=>'hu','label'=>'Hungarian', 'flag'=>'hu'), ['value' => 'hu','label' => 'Hungarian', 'flag' => 'hu'],
array('value'=>'is_IS','label'=>'Icelandic (Iceland)', 'flag'=>'is'), ['value' => 'is_IS','label' => 'Icelandic (Iceland)', 'flag' => 'is'],
array('value'=>'is','label'=>'Icelandic', 'flag'=>'is'), ['value' => 'is','label' => 'Icelandic', 'flag' => 'is'],
array('value'=>'ig_NG','label'=>'Igbo (Nigeria)', 'flag'=>'ng'), ['value' => 'ig_NG','label' => 'Igbo (Nigeria)', 'flag' => 'ng'],
array('value'=>'ig','label'=>'Igbo', 'flag'=>'ig'), ['value' => 'ig','label' => 'Igbo', 'flag' => 'ig'],
array('value'=>'id_ID','label'=>'Indonesian (Indonesia)', 'flag'=>'id'), ['value' => 'id_ID','label' => 'Indonesian (Indonesia)', 'flag' => 'id'],
array('value'=>'id','label'=>'Indonesian', 'flag'=>'id'), ['value' => 'id','label' => 'Indonesian', 'flag' => 'id'],
array('value'=>'ga_IE','label'=>'Irish (Ireland)', 'flag'=>'ie'), ['value' => 'ga_IE','label' => 'Irish (Ireland)', 'flag' => 'ie'],
array('value'=>'ga','label'=>'Irish', 'flag'=>'ga'), ['value' => 'ga','label' => 'Irish', 'flag' => 'ga'],
array('value'=>'it_IT','label'=>'Italian (Italy)', 'flag'=>'it'), ['value' => 'it_IT','label' => 'Italian (Italy)', 'flag' => 'it'],
array('value'=>'it_CH','label'=>'Italian (Switzerland)', 'flag'=>'ch'), ['value' => 'it_CH','label' => 'Italian (Switzerland)', 'flag' => 'ch'],
array('value'=>'it','label'=>'Italian', 'flag'=>'it'), ['value' => 'it','label' => 'Italian', 'flag' => 'it'],
array('value'=>'ja_JP','label'=>'Japanese (Japan)', 'flag'=>'jp'), ['value' => 'ja_JP','label' => 'Japanese (Japan)', 'flag' => 'jp'],
array('value'=>'ja','label'=>'Japanese', 'flag'=>'ja'), ['value' => 'ja','label' => 'Japanese', 'flag' => 'ja'],
array('value'=>'kea_CV','label'=>'Kabuverdianu (Cape Verde)', 'flag'=>'cv'), ['value' => 'kea_CV','label' => 'Kabuverdianu (Cape Verde)', 'flag' => 'cv'],
array('value'=>'kea','label'=>'Kabuverdianu', 'flag'=>'kea'), ['value' => 'kea','label' => 'Kabuverdianu', 'flag' => 'kea'],
array('value'=>'kab_DZ','label'=>'Kabyle (Algeria)', 'flag'=>'dz'), ['value' => 'kab_DZ','label' => 'Kabyle (Algeria)', 'flag' => 'dz'],
array('value'=>'kab','label'=>'Kabyle', 'flag'=>'kab'), ['value' => 'kab','label' => 'Kabyle', 'flag' => 'kab'],
array('value'=>'kl_GL','label'=>'Kalaallisut (Greenland)', 'flag'=>'gl'), ['value' => 'kl_GL','label' => 'Kalaallisut (Greenland)', 'flag' => 'gl'],
array('value'=>'kl','label'=>'Kalaallisut', 'flag'=>'kl'), ['value' => 'kl','label' => 'Kalaallisut', 'flag' => 'kl'],
array('value'=>'kln_KE','label'=>'Kalenjin (Kenya)', 'flag'=>'ke'), ['value' => 'kln_KE','label' => 'Kalenjin (Kenya)', 'flag' => 'ke'],
array('value'=>'kln','label'=>'Kalenjin', 'flag'=>'kln'), ['value' => 'kln','label' => 'Kalenjin', 'flag' => 'kln'],
array('value'=>'kam_KE','label'=>'Kamba (Kenya)', 'flag'=>'ke'), ['value' => 'kam_KE','label' => 'Kamba (Kenya)', 'flag' => 'ke'],
array('value'=>'kam','label'=>'Kamba', 'flag'=>'kam'), ['value' => 'kam','label' => 'Kamba', 'flag' => 'kam'],
array('value'=>'kn_IN','label'=>'Kannada (India)', 'flag'=>'in'), ['value' => 'kn_IN','label' => 'Kannada (India)', 'flag' => 'in'],
array('value'=>'kn','label'=>'Kannada', 'flag'=>'kn'), ['value' => 'kn','label' => 'Kannada', 'flag' => 'kn'],
array('value'=>'kk_Cyrl','label'=>'Kazakh (Cyrillic)', 'flag'=>'cyrl'), ['value' => 'kk_Cyrl','label' => 'Kazakh (Cyrillic)', 'flag' => 'cyrl'],
array('value'=>'kk_Cyrl_KZ','label'=>'Kazakh (Cyrillic, Kazakhstan)', 'flag'=>'kz'), ['value' => 'kk_Cyrl_KZ','label' => 'Kazakh (Cyrillic, Kazakhstan)', 'flag' => 'kz'],
array('value'=>'kk','label'=>'Kazakh', 'flag'=>'kk'), ['value' => 'kk','label' => 'Kazakh', 'flag' => 'kk'],
array('value'=>'km_KH','label'=>'Khmer (Cambodia)', 'flag'=>'kh'), ['value' => 'km_KH','label' => 'Khmer (Cambodia)', 'flag' => 'kh'],
array('value'=>'km','label'=>'Khmer', 'flag'=>'km'), ['value' => 'km','label' => 'Khmer', 'flag' => 'km'],
array('value'=>'ki_KE','label'=>'Kikuyu (Kenya)', 'flag'=>'ke'), ['value' => 'ki_KE','label' => 'Kikuyu (Kenya)', 'flag' => 'ke'],
array('value'=>'ki','label'=>'Kikuyu', 'flag'=>'ki'), ['value' => 'ki','label' => 'Kikuyu', 'flag' => 'ki'],
array('value'=>'rw_RW','label'=>'Kinyarwanda (Rwanda)', 'flag'=>'rw'), ['value' => 'rw_RW','label' => 'Kinyarwanda (Rwanda)', 'flag' => 'rw'],
array('value'=>'rw','label'=>'Kinyarwanda', 'flag'=>'rw'), ['value' => 'rw','label' => 'Kinyarwanda', 'flag' => 'rw'],
array('value'=>'kok_IN','label'=>'Konkani (India)', 'flag'=>'in'), ['value' => 'kok_IN','label' => 'Konkani (India)', 'flag' => 'in'],
array('value'=>'kok','label'=>'Konkani', 'flag'=>'kok'), ['value' => 'kok','label' => 'Konkani', 'flag' => 'kok'],
array('value'=>'ko_KR','label'=>'Korean (South Korea)', 'flag'=>'kr'), ['value' => 'ko_KR','label' => 'Korean (South Korea)', 'flag' => 'kr'],
array('value'=>'ko','label'=>'Korean', 'flag'=>'ko'), ['value' => 'ko','label' => 'Korean', 'flag' => 'ko'],
array('value'=>'khq_ML','label'=>'Koyra Chiini (Mali)', 'flag'=>'ml'), ['value' => 'khq_ML','label' => 'Koyra Chiini (Mali)', 'flag' => 'ml'],
array('value'=>'khq','label'=>'Koyra Chiini', 'flag'=>'khq'), ['value' => 'khq','label' => 'Koyra Chiini', 'flag' => 'khq'],
array('value'=>'ses_ML','label'=>'Koyraboro Senni (Mali)', 'flag'=>'ml'), ['value' => 'ses_ML','label' => 'Koyraboro Senni (Mali)', 'flag' => 'ml'],
array('value'=>'ses','label'=>'Koyraboro Senni', 'flag'=>'ses'), ['value' => 'ses','label' => 'Koyraboro Senni', 'flag' => 'ses'],
array('value'=>'lag_TZ','label'=>'Langi (Tanzania)', 'flag'=>'tz'), ['value' => 'lag_TZ','label' => 'Langi (Tanzania)', 'flag' => 'tz'],
array('value'=>'lag','label'=>'Langi', 'flag'=>'lag'), ['value' => 'lag','label' => 'Langi', 'flag' => 'lag'],
array('value'=>'lv_LV','label'=>'Latvian (Latvia)', 'flag'=>'lv'), ['value' => 'lv_LV','label' => 'Latvian (Latvia)', 'flag' => 'lv'],
array('value'=>'lv','label'=>'Latvian', 'flag'=>'lv'), ['value' => 'lv','label' => 'Latvian', 'flag' => 'lv'],
array('value'=>'lt_LT','label'=>'Lithuanian (Lithuania)', 'flag'=>'lt'), ['value' => 'lt_LT','label' => 'Lithuanian (Lithuania)', 'flag' => 'lt'],
array('value'=>'lt','label'=>'Lithuanian', 'flag'=>'lt'), ['value' => 'lt','label' => 'Lithuanian', 'flag' => 'lt'],
array('value'=>'luo_KE','label'=>'Luo (Kenya)', 'flag'=>'ke'), ['value' => 'luo_KE','label' => 'Luo (Kenya)', 'flag' => 'ke'],
array('value'=>'luo','label'=>'Luo', 'flag'=>'luo'), ['value' => 'luo','label' => 'Luo', 'flag' => 'luo'],
array('value'=>'luy_KE','label'=>'Luyia (Kenya)', 'flag'=>'ke'), ['value' => 'luy_KE','label' => 'Luyia (Kenya)', 'flag' => 'ke'],
array('value'=>'luy','label'=>'Luyia', 'flag'=>'luy'), ['value' => 'luy','label' => 'Luyia', 'flag' => 'luy'],
array('value'=>'mk_MK','label'=>'Macedonian (Macedonia)', 'flag'=>'mk'), ['value' => 'mk_MK','label' => 'Macedonian (Macedonia)', 'flag' => 'mk'],
array('value'=>'mk','label'=>'Macedonian', 'flag'=>'mk'), ['value' => 'mk','label' => 'Macedonian', 'flag' => 'mk'],
array('value'=>'jmc_TZ','label'=>'Machame (Tanzania)', 'flag'=>'tz'), ['value' => 'jmc_TZ','label' => 'Machame (Tanzania)', 'flag' => 'tz'],
array('value'=>'jmc','label'=>'Machame', 'flag'=>'jmc'), ['value' => 'jmc','label' => 'Machame', 'flag' => 'jmc'],
array('value'=>'kde_TZ','label'=>'Makonde (Tanzania)', 'flag'=>'tz'), ['value' => 'kde_TZ','label' => 'Makonde (Tanzania)', 'flag' => 'tz'],
array('value'=>'kde','label'=>'Makonde', 'flag'=>'kde'), ['value' => 'kde','label' => 'Makonde', 'flag' => 'kde'],
array('value'=>'mg_MG','label'=>'Malagasy (Madagascar)', 'flag'=>'mg'), ['value' => 'mg_MG','label' => 'Malagasy (Madagascar)', 'flag' => 'mg'],
array('value'=>'mg','label'=>'Malagasy', 'flag'=>'mg'), ['value' => 'mg','label' => 'Malagasy', 'flag' => 'mg'],
array('value'=>'ms_BN','label'=>'Malay (Brunei)', 'flag'=>'bn'), ['value' => 'ms_BN','label' => 'Malay (Brunei)', 'flag' => 'bn'],
array('value'=>'ms_MY','label'=>'Malay (Malaysia)', 'flag'=>'my'), ['value' => 'ms_MY','label' => 'Malay (Malaysia)', 'flag' => 'my'],
array('value'=>'ms','label'=>'Malay', 'flag'=>'ms'), ['value' => 'ms','label' => 'Malay', 'flag' => 'ms'],
array('value'=>'ml_IN','label'=>'Malayalam (India)', 'flag'=>'in'), ['value' => 'ml_IN','label' => 'Malayalam (India)', 'flag' => 'in'],
array('value'=>'ml','label'=>'Malayalam', 'flag'=>'ml'), ['value' => 'ml','label' => 'Malayalam', 'flag' => 'ml'],
array('value'=>'mt_MT','label'=>'Maltese (Malta)', 'flag'=>'mt'), ['value' => 'mt_MT','label' => 'Maltese (Malta)', 'flag' => 'mt'],
array('value'=>'mt','label'=>'Maltese', 'flag'=>'mt'), ['value' => 'mt','label' => 'Maltese', 'flag' => 'mt'],
array('value'=>'gv_GB','label'=>'Manx (United Kingdom)', 'flag'=>'gb'), ['value' => 'gv_GB','label' => 'Manx (United Kingdom)', 'flag' => 'gb'],
array('value'=>'gv','label'=>'Manx', 'flag'=>'gv'), ['value' => 'gv','label' => 'Manx', 'flag' => 'gv'],
array('value'=>'mr_IN','label'=>'Marathi (India)', 'flag'=>'in'), ['value' => 'mr_IN','label' => 'Marathi (India)', 'flag' => 'in'],
array('value'=>'mr','label'=>'Marathi', 'flag'=>'mr'), ['value' => 'mr','label' => 'Marathi', 'flag' => 'mr'],
array('value'=>'mas_KE','label'=>'Masai (Kenya)', 'flag'=>'ke'), ['value' => 'mas_KE','label' => 'Masai (Kenya)', 'flag' => 'ke'],
array('value'=>'mas_TZ','label'=>'Masai (Tanzania)', 'flag'=>'tz'), ['value' => 'mas_TZ','label' => 'Masai (Tanzania)', 'flag' => 'tz'],
array('value'=>'mas','label'=>'Masai', 'flag'=>'mas'), ['value' => 'mas','label' => 'Masai', 'flag' => 'mas'],
array('value'=>'mer_KE','label'=>'Meru (Kenya)', 'flag'=>'ke'), ['value' => 'mer_KE','label' => 'Meru (Kenya)', 'flag' => 'ke'],
array('value'=>'mer','label'=>'Meru', 'flag'=>'mer'), ['value' => 'mer','label' => 'Meru', 'flag' => 'mer'],
array('value'=>'mfe_MU','label'=>'Morisyen (Mauritius)', 'flag'=>'mu'), ['value' => 'mfe_MU','label' => 'Morisyen (Mauritius)', 'flag' => 'mu'],
array('value'=>'mfe','label'=>'Morisyen', 'flag'=>'mfe'), ['value' => 'mfe','label' => 'Morisyen', 'flag' => 'mfe'],
array('value'=>'naq_NA','label'=>'Nama (Namibia)', 'flag'=>'na'), ['value' => 'naq_NA','label' => 'Nama (Namibia)', 'flag' => 'na'],
array('value'=>'naq','label'=>'Nama', 'flag'=>'naq'), ['value' => 'naq','label' => 'Nama', 'flag' => 'naq'],
array('value'=>'ne_IN','label'=>'Nepali (India)', 'flag'=>'in'), ['value' => 'ne_IN','label' => 'Nepali (India)', 'flag' => 'in'],
array('value'=>'ne_NP','label'=>'Nepali (Nepal)', 'flag'=>'np'), ['value' => 'ne_NP','label' => 'Nepali (Nepal)', 'flag' => 'np'],
array('value'=>'ne','label'=>'Nepali', 'flag'=>'ne'), ['value' => 'ne','label' => 'Nepali', 'flag' => 'ne'],
array('value'=>'nd_ZW','label'=>'North Ndebele (Zimbabwe)', 'flag'=>'zw'), ['value' => 'nd_ZW','label' => 'North Ndebele (Zimbabwe)', 'flag' => 'zw'],
array('value'=>'nd','label'=>'North Ndebele', 'flag'=>'nd'), ['value' => 'nd','label' => 'North Ndebele', 'flag' => 'nd'],
array('value'=>'nb_NO','label'=>'Norwegian Bokmål (Norway)', 'flag'=>'no'), ['value' => 'nb_NO','label' => 'Norwegian Bokmål (Norway)', 'flag' => 'no'],
array('value'=>'nb','label'=>'Norwegian Bokmål', 'flag'=>'nb'), ['value' => 'nb','label' => 'Norwegian Bokmål', 'flag' => 'nb'],
array('value'=>'nn_NO','label'=>'Norwegian Nynorsk (Norway)', 'flag'=>'no'), ['value' => 'nn_NO','label' => 'Norwegian Nynorsk (Norway)', 'flag' => 'no'],
array('value'=>'nn','label'=>'Norwegian Nynorsk', 'flag'=>'nn'), ['value' => 'nn','label' => 'Norwegian Nynorsk', 'flag' => 'nn'],
array('value'=>'nyn_UG','label'=>'Nyankole (Uganda)', 'flag'=>'ug'), ['value' => 'nyn_UG','label' => 'Nyankole (Uganda)', 'flag' => 'ug'],
array('value'=>'nyn','label'=>'Nyankole', 'flag'=>'nyn'), ['value' => 'nyn','label' => 'Nyankole', 'flag' => 'nyn'],
array('value'=>'or_IN','label'=>'Oriya (India)', 'flag'=>'in'), ['value' => 'or_IN','label' => 'Oriya (India)', 'flag' => 'in'],
array('value'=>'or','label'=>'Oriya', 'flag'=>'or'), ['value' => 'or','label' => 'Oriya', 'flag' => 'or'],
array('value'=>'om_ET','label'=>'Oromo (Ethiopia)', 'flag'=>'et'), ['value' => 'om_ET','label' => 'Oromo (Ethiopia)', 'flag' => 'et'],
array('value'=>'om_KE','label'=>'Oromo (Kenya)', 'flag'=>'ke'), ['value' => 'om_KE','label' => 'Oromo (Kenya)', 'flag' => 'ke'],
array('value'=>'om','label'=>'Oromo', 'flag'=>'om'), ['value' => 'om','label' => 'Oromo', 'flag' => 'om'],
array('value'=>'ps_AF','label'=>'Pashto (Afghanistan)', 'flag'=>'af'), ['value' => 'ps_AF','label' => 'Pashto (Afghanistan)', 'flag' => 'af'],
array('value'=>'ps','label'=>'Pashto', 'flag'=>'ps'), ['value' => 'ps','label' => 'Pashto', 'flag' => 'ps'],
array('value'=>'fa_AF','label'=>'Persian (Afghanistan)', 'flag'=>'af'), ['value' => 'fa_AF','label' => 'Persian (Afghanistan)', 'flag' => 'af'],
array('value'=>'fa_IR','label'=>'Persian (Iran)', 'flag'=>'ir'), ['value' => 'fa_IR','label' => 'Persian (Iran)', 'flag' => 'ir'],
array('value'=>'fa','label'=>'Persian', 'flag'=>'fa'), ['value' => 'fa','label' => 'Persian', 'flag' => 'fa'],
array('value'=>'pl_PL','label'=>'Polish (Poland)', 'flag'=>'pl'), ['value' => 'pl_PL','label' => 'Polish (Poland)', 'flag' => 'pl'],
array('value'=>'pl','label'=>'Polish', 'flag'=>'pl'), ['value' => 'pl','label' => 'Polish', 'flag' => 'pl'],
array('value'=>'pt_BR','label'=>'Portuguese (Brazil)', 'flag'=>'br'), ['value' => 'pt_BR','label' => 'Portuguese (Brazil)', 'flag' => 'br'],
array('value'=>'pt_GW','label'=>'Portuguese (Guinea-Bissau)', 'flag'=>'gw'), ['value' => 'pt_GW','label' => 'Portuguese (Guinea-Bissau)', 'flag' => 'gw'],
array('value'=>'pt_MZ','label'=>'Portuguese (Mozambique)', 'flag'=>'mz'), ['value' => 'pt_MZ','label' => 'Portuguese (Mozambique)', 'flag' => 'mz'],
array('value'=>'pt_PT','label'=>'Portuguese (Portugal)', 'flag'=>'pt'), ['value' => 'pt_PT','label' => 'Portuguese (Portugal)', 'flag' => 'pt'],
array('value'=>'pt','label'=>'Portuguese', 'flag'=>'pt'), ['value' => 'pt','label' => 'Portuguese', 'flag' => 'pt'],
array('value'=>'pa_Arab','label'=>'Punjabi (Arabic)', 'flag'=>'arab'), ['value' => 'pa_Arab','label' => 'Punjabi (Arabic)', 'flag' => 'arab'],
array('value'=>'pa_Arab_PK','label'=>'Punjabi (Arabic, Pakistan)', 'flag'=>'pk'), ['value' => 'pa_Arab_PK','label' => 'Punjabi (Arabic, Pakistan)', 'flag' => 'pk'],
array('value'=>'pa_Guru','label'=>'Punjabi (Gurmukhi)', 'flag'=>'guru'), ['value' => 'pa_Guru','label' => 'Punjabi (Gurmukhi)', 'flag' => 'guru'],
array('value'=>'pa_Guru_IN','label'=>'Punjabi (Gurmukhi, India)', 'flag'=>'in'), ['value' => 'pa_Guru_IN','label' => 'Punjabi (Gurmukhi, India)', 'flag' => 'in'],
array('value'=>'pa','label'=>'Punjabi', 'flag'=>'pa'), ['value' => 'pa','label' => 'Punjabi', 'flag' => 'pa'],
array('value'=>'ro_MD','label'=>'Romanian (Moldova)', 'flag'=>'md'), ['value' => 'ro_MD','label' => 'Romanian (Moldova)', 'flag' => 'md'],
array('value'=>'ro_RO','label'=>'Romanian (Romania)', 'flag'=>'ro'), ['value' => 'ro_RO','label' => 'Romanian (Romania)', 'flag' => 'ro'],
array('value'=>'ro','label'=>'Romanian', 'flag'=>'ro'), ['value' => 'ro','label' => 'Romanian', 'flag' => 'ro'],
array('value'=>'rm_CH','label'=>'Romansh (Switzerland)', 'flag'=>'ch'), ['value' => 'rm_CH','label' => 'Romansh (Switzerland)', 'flag' => 'ch'],
array('value'=>'rm','label'=>'Romansh', 'flag'=>'rm'), ['value' => 'rm','label' => 'Romansh', 'flag' => 'rm'],
array('value'=>'rof_TZ','label'=>'Rombo (Tanzania)', 'flag'=>'tz'), ['value' => 'rof_TZ','label' => 'Rombo (Tanzania)', 'flag' => 'tz'],
array('value'=>'rof','label'=>'Rombo', 'flag'=>'rof'), ['value' => 'rof','label' => 'Rombo', 'flag' => 'rof'],
array('value'=>'ru_MD','label'=>'Russian (Moldova)', 'flag'=>'md'), ['value' => 'ru_MD','label' => 'Russian (Moldova)', 'flag' => 'md'],
array('value'=>'ru_RU','label'=>'Russian (Russia)', 'flag'=>'ru'), ['value' => 'ru_RU','label' => 'Russian (Russia)', 'flag' => 'ru'],
array('value'=>'ru_UA','label'=>'Russian (Ukraine)', 'flag'=>'ua'), ['value' => 'ru_UA','label' => 'Russian (Ukraine)', 'flag' => 'ua'],
array('value'=>'ru','label'=>'Russian', 'flag'=>'ru'), ['value' => 'ru','label' => 'Russian', 'flag' => 'ru'],
array('value'=>'rwk_TZ','label'=>'Rwa (Tanzania)', 'flag'=>'tz'), ['value' => 'rwk_TZ','label' => 'Rwa (Tanzania)', 'flag' => 'tz'],
array('value'=>'rwk','label'=>'Rwa', 'flag'=>'rwk'), ['value' => 'rwk','label' => 'Rwa', 'flag' => 'rwk'],
array('value'=>'saq_KE','label'=>'Samburu (Kenya)', 'flag'=>'ke'), ['value' => 'saq_KE','label' => 'Samburu (Kenya)', 'flag' => 'ke'],
array('value'=>'saq','label'=>'Samburu', 'flag'=>'saq'), ['value' => 'saq','label' => 'Samburu', 'flag' => 'saq'],
array('value'=>'sg_CF','label'=>'Sango (Central African Republic)', 'flag'=>'cf'), ['value' => 'sg_CF','label' => 'Sango (Central African Republic)', 'flag' => 'cf'],
array('value'=>'sg','label'=>'Sango', 'flag'=>'sg'), ['value' => 'sg','label' => 'Sango', 'flag' => 'sg'],
array('value'=>'seh_MZ','label'=>'Sena (Mozambique)', 'flag'=>'mz'), ['value' => 'seh_MZ','label' => 'Sena (Mozambique)', 'flag' => 'mz'],
array('value'=>'seh','label'=>'Sena', 'flag'=>'seh'), ['value' => 'seh','label' => 'Sena', 'flag' => 'seh'],
array('value'=>'sr_Cyrl','label'=>'Serbian (Cyrillic)', 'flag'=>'cyrl'), ['value' => 'sr_Cyrl','label' => 'Serbian (Cyrillic)', 'flag' => 'cyrl'],
array('value'=>'sr_Cyrl_BA','label'=>'Serbian (Cyrillic, Bosnia and Herzegovina)', 'flag'=>'ba'), ['value' => 'sr_Cyrl_BA','label' => 'Serbian (Cyrillic, Bosnia and Herzegovina)', 'flag' => 'ba'],
array('value'=>'sr_Cyrl_ME','label'=>'Serbian (Cyrillic, Montenegro)', 'flag'=>'me'), ['value' => 'sr_Cyrl_ME','label' => 'Serbian (Cyrillic, Montenegro)', 'flag' => 'me'],
array('value'=>'sr_Cyrl_RS','label'=>'Serbian (Cyrillic, Serbia)', 'flag'=>'rs'), ['value' => 'sr_Cyrl_RS','label' => 'Serbian (Cyrillic, Serbia)', 'flag' => 'rs'],
array('value'=>'sr_Latn','label'=>'Serbian (Latin)', 'flag'=>'latn'), ['value' => 'sr_Latn','label' => 'Serbian (Latin)', 'flag' => 'latn'],
array('value'=>'sr_Latn_BA','label'=>'Serbian (Latin, Bosnia and Herzegovina)', 'flag'=>'ba'), ['value' => 'sr_Latn_BA','label' => 'Serbian (Latin, Bosnia and Herzegovina)', 'flag' => 'ba'],
array('value'=>'sr_Latn_ME','label'=>'Serbian (Latin, Montenegro)', 'flag'=>'me'), ['value' => 'sr_Latn_ME','label' => 'Serbian (Latin, Montenegro)', 'flag' => 'me'],
array('value'=>'sr_Latn_RS','label'=>'Serbian (Latin, Serbia)', 'flag'=>'rs'), ['value' => 'sr_Latn_RS','label' => 'Serbian (Latin, Serbia)', 'flag' => 'rs'],
array('value'=>'sr','label'=>'Serbian', 'flag'=>'sr'), ['value' => 'sr','label' => 'Serbian', 'flag' => 'sr'],
array('value'=>'sn_ZW','label'=>'Shona (Zimbabwe)', 'flag'=>'zw'), ['value' => 'sn_ZW','label' => 'Shona (Zimbabwe)', 'flag' => 'zw'],
array('value'=>'sn','label'=>'Shona', 'flag'=>'sn'), ['value' => 'sn','label' => 'Shona', 'flag' => 'sn'],
array('value'=>'ii_CN','label'=>'Sichuan Yi (China)', 'flag'=>'cn'), ['value' => 'ii_CN','label' => 'Sichuan Yi (China)', 'flag' => 'cn'],
array('value'=>'ii','label'=>'Sichuan Yi', 'flag'=>'ii'), ['value' => 'ii','label' => 'Sichuan Yi', 'flag' => 'ii'],
array('value'=>'si_LK','label'=>'Sinhala (Sri Lanka)', 'flag'=>'lk'), ['value' => 'si_LK','label' => 'Sinhala (Sri Lanka)', 'flag' => 'lk'],
array('value'=>'si','label'=>'Sinhala', 'flag'=>'si'), ['value' => 'si','label' => 'Sinhala', 'flag' => 'si'],
array('value'=>'sk_SK','label'=>'Slovak (Slovakia)', 'flag'=>'sk'), ['value' => 'sk_SK','label' => 'Slovak (Slovakia)', 'flag' => 'sk'],
array('value'=>'sk','label'=>'Slovak', 'flag'=>'sk'), ['value' => 'sk','label' => 'Slovak', 'flag' => 'sk'],
array('value'=>'sl_SI','label'=>'Slovenian (Slovenia)', 'flag'=>'si'), ['value' => 'sl_SI','label' => 'Slovenian (Slovenia)', 'flag' => 'si'],
array('value'=>'sl','label'=>'Slovenian', 'flag'=>'sl'), ['value' => 'sl','label' => 'Slovenian', 'flag' => 'sl'],
array('value'=>'xog_UG','label'=>'Soga (Uganda)', 'flag'=>'ug'), ['value' => 'xog_UG','label' => 'Soga (Uganda)', 'flag' => 'ug'],
array('value'=>'xog','label'=>'Soga', 'flag'=>'xog'), ['value' => 'xog','label' => 'Soga', 'flag' => 'xog'],
array('value'=>'so_DJ','label'=>'Somali (Djibouti)', 'flag'=>'dj'), ['value' => 'so_DJ','label' => 'Somali (Djibouti)', 'flag' => 'dj'],
array('value'=>'so_ET','label'=>'Somali (Ethiopia)', 'flag'=>'et'), ['value' => 'so_ET','label' => 'Somali (Ethiopia)', 'flag' => 'et'],
array('value'=>'so_KE','label'=>'Somali (Kenya)', 'flag'=>'ke'), ['value' => 'so_KE','label' => 'Somali (Kenya)', 'flag' => 'ke'],
array('value'=>'so_SO','label'=>'Somali (Somalia)', 'flag'=>'so'), ['value' => 'so_SO','label' => 'Somali (Somalia)', 'flag' => 'so'],
array('value'=>'so','label'=>'Somali', 'flag'=>'so'), ['value' => 'so','label' => 'Somali', 'flag' => 'so'],
array('value'=>'es_AR','label'=>'Spanish (Argentina)', 'flag'=>'ar'), ['value' => 'es_AR','label' => 'Spanish (Argentina)', 'flag' => 'ar'],
array('value'=>'es_BO','label'=>'Spanish (Bolivia)', 'flag'=>'bo'), ['value' => 'es_BO','label' => 'Spanish (Bolivia)', 'flag' => 'bo'],
array('value'=>'es_CL','label'=>'Spanish (Chile)', 'flag'=>'cl'), ['value' => 'es_CL','label' => 'Spanish (Chile)', 'flag' => 'cl'],
array('value'=>'es_CO','label'=>'Spanish (Colombia)', 'flag'=>'co'), ['value' => 'es_CO','label' => 'Spanish (Colombia)', 'flag' => 'co'],
array('value'=>'es_CR','label'=>'Spanish (Costa Rica)', 'flag'=>'cr'), ['value' => 'es_CR','label' => 'Spanish (Costa Rica)', 'flag' => 'cr'],
array('value'=>'es_DO','label'=>'Spanish (Dominican Republic)', 'flag'=>'do'), ['value' => 'es_DO','label' => 'Spanish (Dominican Republic)', 'flag' => 'do'],
array('value'=>'es_EC','label'=>'Spanish (Ecuador)', 'flag'=>'ec'), ['value' => 'es_EC','label' => 'Spanish (Ecuador)', 'flag' => 'ec'],
array('value'=>'es_SV','label'=>'Spanish (El Salvador)', 'flag'=>'sv'), ['value' => 'es_SV','label' => 'Spanish (El Salvador)', 'flag' => 'sv'],
array('value'=>'es_GQ','label'=>'Spanish (Equatorial Guinea)', 'flag'=>'gq'), ['value' => 'es_GQ','label' => 'Spanish (Equatorial Guinea)', 'flag' => 'gq'],
array('value'=>'es_GT','label'=>'Spanish (Guatemala)', 'flag'=>'gt'), ['value' => 'es_GT','label' => 'Spanish (Guatemala)', 'flag' => 'gt'],
array('value'=>'es_HN','label'=>'Spanish (Honduras)', 'flag'=>'hn'), ['value' => 'es_HN','label' => 'Spanish (Honduras)', 'flag' => 'hn'],
array('value'=>'es_419','label'=>'Spanish (Latin America)', 'flag'=>'419'), ['value' => 'es_419','label' => 'Spanish (Latin America)', 'flag' => '419'],
array('value'=>'es_MX','label'=>'Spanish (Mexico)', 'flag'=>'mx'), ['value' => 'es_MX','label' => 'Spanish (Mexico)', 'flag' => 'mx'],
array('value'=>'es_NI','label'=>'Spanish (Nicaragua)', 'flag'=>'ni'), ['value' => 'es_NI','label' => 'Spanish (Nicaragua)', 'flag' => 'ni'],
array('value'=>'es_PA','label'=>'Spanish (Panama)', 'flag'=>'pa'), ['value' => 'es_PA','label' => 'Spanish (Panama)', 'flag' => 'pa'],
array('value'=>'es_PY','label'=>'Spanish (Paraguay)', 'flag'=>'py'), ['value' => 'es_PY','label' => 'Spanish (Paraguay)', 'flag' => 'py'],
array('value'=>'es_PE','label'=>'Spanish (Peru)', 'flag'=>'pe'), ['value' => 'es_PE','label' => 'Spanish (Peru)', 'flag' => 'pe'],
array('value'=>'es_PR','label'=>'Spanish (Puerto Rico)', 'flag'=>'pr'), ['value' => 'es_PR','label' => 'Spanish (Puerto Rico)', 'flag' => 'pr'],
array('value'=>'es_ES','label'=>'Spanish (Spain)', 'flag'=>'es'), ['value' => 'es_ES','label' => 'Spanish (Spain)', 'flag' => 'es'],
//array('value'=>'es_US','label'=>'Spanish (United States)', 'flag'=>'us'), //array('value' => 'es_US','label' => 'Spanish (United States)', 'flag' => 'us'),
array('value'=>'es_UY','label'=>'Spanish (Uruguay)', 'flag'=>'uy'), ['value' => 'es_UY','label' => 'Spanish (Uruguay)', 'flag' => 'uy'],
array('value'=>'es_VE','label'=>'Spanish (Venezuela)', 'flag'=>'ve'), ['value' => 'es_VE','label' => 'Spanish (Venezuela)', 'flag' => 've'],
array('value'=>'es','label'=>'Spanish', 'flag'=>'es'), ['value' => 'es','label' => 'Spanish', 'flag' => 'es'],
array('value'=>'sw_KE','label'=>'Swahili (Kenya)', 'flag'=>'ke'), ['value' => 'sw_KE','label' => 'Swahili (Kenya)', 'flag' => 'ke'],
array('value'=>'sw_TZ','label'=>'Swahili (Tanzania)', 'flag'=>'tz'), ['value' => 'sw_TZ','label' => 'Swahili (Tanzania)', 'flag' => 'tz'],
array('value'=>'sw','label'=>'Swahili', 'flag'=>'sw'), ['value' => 'sw','label' => 'Swahili', 'flag' => 'sw'],
array('value'=>'sv_FI','label'=>'Swedish (Finland)', 'flag'=>'fi'), ['value' => 'sv_FI','label' => 'Swedish (Finland)', 'flag' => 'fi'],
array('value'=>'sv_SE','label'=>'Swedish (Sweden)', 'flag'=>'se'), ['value' => 'sv_SE','label' => 'Swedish (Sweden)', 'flag' => 'se'],
array('value'=>'sv','label'=>'Swedish', 'flag'=>'sv'), ['value' => 'sv','label' => 'Swedish', 'flag' => 'sv'],
array('value'=>'gsw_CH','label'=>'Swiss German (Switzerland)', 'flag'=>'ch'), ['value' => 'gsw_CH','label' => 'Swiss German (Switzerland)', 'flag' => 'ch'],
array('value'=>'gsw','label'=>'Swiss German', 'flag'=>'gsw'), ['value' => 'gsw','label' => 'Swiss German', 'flag' => 'gsw'],
array('value'=>'shi_Latn','label'=>'Tachelhit (Latin)', 'flag'=>'latn'), ['value' => 'shi_Latn','label' => 'Tachelhit (Latin)', 'flag' => 'latn'],
array('value'=>'shi_Latn_MA','label'=>'Tachelhit (Latin, Morocco)', 'flag'=>'ma'), ['value' => 'shi_Latn_MA','label' => 'Tachelhit (Latin, Morocco)', 'flag' => 'ma'],
array('value'=>'shi_Tfng','label'=>'Tachelhit (Tifinagh)', 'flag'=>'tfng'), ['value' => 'shi_Tfng','label' => 'Tachelhit (Tifinagh)', 'flag' => 'tfng'],
array('value'=>'shi_Tfng_MA','label'=>'Tachelhit (Tifinagh, Morocco)', 'flag'=>'ma'), ['value' => 'shi_Tfng_MA','label' => 'Tachelhit (Tifinagh, Morocco)', 'flag' => 'ma'],
array('value'=>'shi','label'=>'Tachelhit', 'flag'=>'shi'), ['value' => 'shi','label' => 'Tachelhit', 'flag' => 'shi'],
array('value'=>'dav_KE','label'=>'Taita (Kenya)', 'flag'=>'ke'), ['value' => 'dav_KE','label' => 'Taita (Kenya)', 'flag' => 'ke'],
array('value'=>'dav','label'=>'Taita', 'flag'=>'dav'), ['value' => 'dav','label' => 'Taita', 'flag' => 'dav'],
array('value'=>'ta_IN','label'=>'Tamil (India)', 'flag'=>'in'), ['value' => 'ta_IN','label' => 'Tamil (India)', 'flag' => 'in'],
array('value'=>'ta_LK','label'=>'Tamil (Sri Lanka)', 'flag'=>'lk'), ['value' => 'ta_LK','label' => 'Tamil (Sri Lanka)', 'flag' => 'lk'],
array('value'=>'ta','label'=>'Tamil', 'flag'=>'ta'), ['value' => 'ta','label' => 'Tamil', 'flag' => 'ta'],
array('value'=>'te_IN','label'=>'Telugu (India)', 'flag'=>'in'), ['value' => 'te_IN','label' => 'Telugu (India)', 'flag' => 'in'],
array('value'=>'te','label'=>'Telugu', 'flag'=>'te'), ['value' => 'te','label' => 'Telugu', 'flag' => 'te'],
array('value'=>'teo_KE','label'=>'Teso (Kenya)', 'flag'=>'ke'), ['value' => 'teo_KE','label' => 'Teso (Kenya)', 'flag' => 'ke'],
array('value'=>'teo_UG','label'=>'Teso (Uganda)', 'flag'=>'ug'), ['value' => 'teo_UG','label' => 'Teso (Uganda)', 'flag' => 'ug'],
array('value'=>'teo','label'=>'Teso', 'flag'=>'teo'), ['value' => 'teo','label' => 'Teso', 'flag' => 'teo'],
array('value'=>'th_TH','label'=>'Thai (Thailand)', 'flag'=>'th'), ['value' => 'th_TH','label' => 'Thai (Thailand)', 'flag' => 'th'],
array('value'=>'th','label'=>'Thai', 'flag'=>'th'), ['value' => 'th','label' => 'Thai', 'flag' => 'th'],
array('value'=>'bo_CN','label'=>'Tibetan (China)', 'flag'=>'cn'), ['value' => 'bo_CN','label' => 'Tibetan (China)', 'flag' => 'cn'],
array('value'=>'bo_IN','label'=>'Tibetan (India)', 'flag'=>'in'), ['value' => 'bo_IN','label' => 'Tibetan (India)', 'flag' => 'in'],
array('value'=>'bo','label'=>'Tibetan', 'flag'=>'bo'), ['value' => 'bo','label' => 'Tibetan', 'flag' => 'bo'],
array('value'=>'ti_ER','label'=>'Tigrinya (Eritrea)', 'flag'=>'er'), ['value' => 'ti_ER','label' => 'Tigrinya (Eritrea)', 'flag' => 'er'],
array('value'=>'ti_ET','label'=>'Tigrinya (Ethiopia)', 'flag'=>'et'), ['value' => 'ti_ET','label' => 'Tigrinya (Ethiopia)', 'flag' => 'et'],
array('value'=>'ti','label'=>'Tigrinya', 'flag'=>'ti'), ['value' => 'ti','label' => 'Tigrinya', 'flag' => 'ti'],
array('value'=>'to_TO','label'=>'Tonga (Tonga)', 'flag'=>'to'), ['value' => 'to_TO','label' => 'Tonga (Tonga)', 'flag' => 'to'],
array('value'=>'to','label'=>'Tonga', 'flag'=>'to'), ['value' => 'to','label' => 'Tonga', 'flag' => 'to'],
array('value'=>'tr_TR','label'=>'Turkish (Turkey)', 'flag'=>'tr'), ['value' => 'tr_TR','label' => 'Turkish (Turkey)', 'flag' => 'tr'],
array('value'=>'tr','label'=>'Turkish', 'flag'=>'tr'), ['value' => 'tr','label' => 'Turkish', 'flag' => 'tr'],
array('value'=>'uk_UA','label'=>'Ukrainian (Ukraine)', 'flag'=>'ua'), ['value' => 'uk_UA','label' => 'Ukrainian (Ukraine)', 'flag' => 'ua'],
array('value'=>'uk','label'=>'Ukrainian', 'flag'=>'uk'), ['value' => 'uk','label' => 'Ukrainian', 'flag' => 'uk'],
array('value'=>'ur_IN','label'=>'Urdu (India)', 'flag'=>'in'), ['value' => 'ur_IN','label' => 'Urdu (India)', 'flag' => 'in'],
array('value'=>'ur_PK','label'=>'Urdu (Pakistan)', 'flag'=>'pk'), ['value' => 'ur_PK','label' => 'Urdu (Pakistan)', 'flag' => 'pk'],
array('value'=>'ur','label'=>'Urdu', 'flag'=>'ur'), ['value' => 'ur','label' => 'Urdu', 'flag' => 'ur'],
array('value'=>'uz_Arab','label'=>'Uzbek (Arabic)', 'flag'=>'arab'), ['value' => 'uz_Arab','label' => 'Uzbek (Arabic)', 'flag' => 'arab'],
array('value'=>'uz_Arab_AF','label'=>'Uzbek (Arabic, Afghanistan)', 'flag'=>'af'), ['value' => 'uz_Arab_AF','label' => 'Uzbek (Arabic, Afghanistan)', 'flag' => 'af'],
array('value'=>'uz_Cyrl','label'=>'Uzbek (Cyrillic)', 'flag'=>'cyrl'), ['value' => 'uz_Cyrl','label' => 'Uzbek (Cyrillic)', 'flag' => 'cyrl'],
array('value'=>'uz_Cyrl_UZ','label'=>'Uzbek (Cyrillic, Uzbekistan)', 'flag'=>'uz'), ['value' => 'uz_Cyrl_UZ','label' => 'Uzbek (Cyrillic, Uzbekistan)', 'flag' => 'uz'],
array('value'=>'uz_Latn','label'=>'Uzbek (Latin)', 'flag'=>'latn'), ['value' => 'uz_Latn','label' => 'Uzbek (Latin)', 'flag' => 'latn'],
array('value'=>'uz_Latn_UZ','label'=>'Uzbek (Latin, Uzbekistan)', 'flag'=>'uz'), ['value' => 'uz_Latn_UZ','label' => 'Uzbek (Latin, Uzbekistan)', 'flag' => 'uz'],
array('value'=>'uz','label'=>'Uzbek', 'flag'=>'uz'), ['value' => 'uz','label' => 'Uzbek', 'flag' => 'uz'],
array('value'=>'vi_VN','label'=>'Vietnamese (Vietnam)', 'flag'=>'vn'), ['value' => 'vi_VN','label' => 'Vietnamese (Vietnam)', 'flag' => 'vn'],
array('value'=>'vi','label'=>'Vietnamese', 'flag'=>'vi'), ['value' => 'vi','label' => 'Vietnamese', 'flag' => 'vi'],
array('value'=>'vun_TZ','label'=>'Vunjo (Tanzania)', 'flag'=>'tz'), ['value' => 'vun_TZ','label' => 'Vunjo (Tanzania)', 'flag' => 'tz'],
array('value'=>'vun','label'=>'Vunjo', 'flag'=>'vun'), ['value' => 'vun','label' => 'Vunjo', 'flag' => 'vun'],
array('value'=>'cy_GB','label'=>'Welsh (United Kingdom)', 'flag'=>'gb'), ['value' => 'cy_GB','label' => 'Welsh (United Kingdom)', 'flag' => 'gb'],
array('value'=>'cy','label'=>'Welsh', 'flag'=>'cy'), ['value' => 'cy','label' => 'Welsh', 'flag' => 'cy'],
array('value'=>'yo_NG','label'=>'Yoruba (Nigeria)', 'flag'=>'ng'), ['value' => 'yo_NG','label' => 'Yoruba (Nigeria)', 'flag' => 'ng'],
array('value'=>'yo','label'=>'Yoruba', 'flag'=>'yo'), ['value' => 'yo','label' => 'Yoruba', 'flag' => 'yo'],
array('value'=>'zu_ZA','label'=>'Zulu (South Africa)', 'flag'=>'za'), ['value' => 'zu_ZA','label' => 'Zulu (South Africa)', 'flag' => 'za'],
array('value'=>'zu','label'=>'Zulu', 'flag'=>'zu') ['value' => 'zu','label' => 'Zulu', 'flag' => 'zu']
); ];
$global['bcp47'] = array(); $global['bcp47'] = [];
$global['langs_codes_values'] = array(); $global['langs_codes_values'] = [];
$global['langs_codes_values_withdot'] = array(); $global['langs_codes_values_withdot'] = [];
foreach ($global['langs_codes'] as $value) { foreach ($global['langs_codes'] as $value) {
$global['bcp47'][$value['value']] = $value; $global['bcp47'][$value['value']] = $value;
$global['flag2Lang'][$value['flag']] = $value['value']; $global['flag2Lang'][$value['flag']] = $value['value'];
$global['langs_codes_values'][] = $value['value']; $global['langs_codes_values'][] = $value['value'];
$global['langs_codes_values_withdot'][] = '.'.$value['value']; $global['langs_codes_values_withdot'][] = '.' . $value['value'];
} }
$global['flag2Lang']['en'] = 'en_US'; $global['flag2Lang']['en'] = 'en_US';
$global['flag2Lang']['us'] = 'en_US'; $global['flag2Lang']['us'] = 'en_US';

View file

@ -1,31 +1,32 @@
<?php <?php
class BootGrid { class BootGrid
{
static function getSqlFromPost($searchFieldsNames = array(), $keyPrefix = "", $alternativeOrderBy = "", $doNotSearch=false, $FIND_IN_SET = "") { public static function getSqlFromPost($searchFieldsNames = [], $keyPrefix = "", $alternativeOrderBy = "", $doNotSearch=false, $FIND_IN_SET = "")
if(empty($doNotSearch)){ {
if (empty($doNotSearch)) {
$sql = self::getSqlSearchFromPost($searchFieldsNames); $sql = self::getSqlSearchFromPost($searchFieldsNames);
}else{ } else {
$sql = ""; $sql = '';
} }
if(empty($_POST['sort']) && !empty($_GET['order'][0]['dir'])){ if (empty($_POST['sort']) && !empty($_GET['order'][0]['dir'])) {
$index = intval($_GET['order'][0]['column']); $index = intval($_GET['order'][0]['column']);
$_GET['columns'][$index]['data']; $_GET['columns'][$index]['data'];
$_POST['sort'][$_GET['columns'][$index]['data']] = $_GET['order'][0]['dir']; $_POST['sort'][$_GET['columns'][$index]['data']] = $_GET['order'][0]['dir'];
} }
if(!empty($FIND_IN_SET)){ if (!empty($FIND_IN_SET)) {
$sql .= " ORDER BY FIND_IN_SET({$FIND_IN_SET}) DESC "; $sql .= " ORDER BY FIND_IN_SET({$FIND_IN_SET}) DESC ";
}else if (!empty($_POST['sort'])) { } elseif (!empty($_POST['sort'])) {
$orderBy = array(); $orderBy = [];
foreach ($_POST['sort'] as $key => $value) { foreach ($_POST['sort'] as $key => $value) {
$direction = "ASC"; $direction = "ASC";
if(strtoupper($value)==="DESC"){ if (strtoupper($value)==="DESC") {
$direction = "DESC"; $direction = "DESC";
} }
$key = preg_replace("/[^A-Za-z0-9._ ]/", '', $key); $key = preg_replace("/[^A-Za-z0-9._ ]/", '', $key);
if($key=='order'){ if ($key=='order') {
$key = '`order`'; $key = '`order`';
} }
$orderBy[] = " {$keyPrefix}{$key} {$direction} "; $orderBy[] = " {$keyPrefix}{$key} {$direction} ";
@ -39,50 +40,50 @@ class BootGrid {
$current = getCurrentPage(); $current = getCurrentPage();
$currentP = ($current-1)*$rowCount; $currentP = ($current-1)*$rowCount;
if($rowCount>0){ if ($rowCount>0) {
$sql .= " LIMIT $currentP, {$rowCount} "; $sql .= " LIMIT $currentP, {$rowCount} ";
} }
return $sql; return $sql;
} }
static function getSqlSearchFromPost($searchFieldsNames = array(), $connection = "AND") { public static function getSqlSearchFromPost($searchFieldsNames = [], $connection = "AND")
$sql = ""; {
$sql = '';
if (!empty($_GET['searchPhrase'])) { if (!empty($_GET['searchPhrase'])) {
$_POST['searchPhrase'] = $_GET['searchPhrase']; $_POST['searchPhrase'] = $_GET['searchPhrase'];
} else if (!empty($_GET['search']['value'])) { } elseif (!empty($_GET['search']['value'])) {
$_POST['searchPhrase'] = $_GET['search']['value']; $_POST['searchPhrase'] = $_GET['search']['value'];
}else if (!empty($_GET['q'])) { } elseif (!empty($_GET['q'])) {
$_POST['searchPhrase'] = $_GET['q']; $_POST['searchPhrase'] = $_GET['q'];
} }
if(!empty($_POST['searchPhrase'])){ if (!empty($_POST['searchPhrase'])) {
global $global; global $global;
$search = $global['mysqli']->real_escape_string(xss_esc($_POST['searchPhrase'])); $search = $global['mysqli']->real_escape_string(xss_esc($_POST['searchPhrase']));
$search = str_replace('&quot;', '"', $search); $search = str_replace('&quot;', '"', $search);
$like = array(); $like = [];
foreach ($searchFieldsNames as $value) { foreach ($searchFieldsNames as $value) {
if(preg_match('/description/', $value)){ if (preg_match('/description/', $value)) {
//$like[] = " {$value} regexp '\\b{$search}\\b' ";// not sure why was using regexp //$like[] = " {$value} regexp '\\b{$search}\\b' ";// not sure why was using regexp
$like[] = " {$value} LIKE '%{$search}%' "; $like[] = " {$value} LIKE '%{$search}%' ";
}else{ } else {
$like[] = " {$value} LIKE '%{$search}%' "; $like[] = " {$value} LIKE '%{$search}%' ";
} }
// for accent insensitive // for accent insensitive
if(preg_match('/description/', $value)){ if (preg_match('/description/', $value)) {
$like[] = " CONVERT(CAST({$value} as BINARY) USING utf8) regexp '\\b{$search}\\b' "; $like[] = " CONVERT(CAST({$value} as BINARY) USING utf8) regexp '\\b{$search}\\b' ";
//$like[] = " CONVERT(CAST({$value} as BINARY) USING utf8) LIKE '%{$search}%' "; //$like[] = " CONVERT(CAST({$value} as BINARY) USING utf8) LIKE '%{$search}%' ";
}else{ } else {
$like[] = " CONVERT(CAST({$value} as BINARY) USING utf8) LIKE '%{$search}%' "; $like[] = " CONVERT(CAST({$value} as BINARY) USING utf8) LIKE '%{$search}%' ";
} }
} }
if(!empty($like)){ if (!empty($like)) {
$sql .= " {$connection} (". implode(" OR ", $like).")"; $sql .= " {$connection} (". implode(" OR ", $like).")";
}else{ } else {
$sql .= " {$connection} 1=1 "; $sql .= " {$connection} 1=1 ";
} }
} }
return $sql; return $sql;
} }
} }

View file

@ -1,12 +1,17 @@
<?php <?php
global $global, $config; global $global, $config;
if(!isset($global['systemRootPath'])){ if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
class Captcha{ class Captcha
private $largura, $altura, $tamanho_fonte, $quantidade_letras; {
private $largura;
private $altura;
private $tamanho_fonte;
private $quantidade_letras;
function __construct($largura, $altura, $tamanho_fonte, $quantidade_letras) { public function __construct($largura, $altura, $tamanho_fonte, $quantidade_letras)
{
$this->largura = $largura; $this->largura = $largura;
$this->altura = $altura; $this->altura = $altura;
$this->tamanho_fonte = $tamanho_fonte; $this->tamanho_fonte = $tamanho_fonte;
@ -14,10 +19,11 @@ class Captcha{
} }
public function getCaptchaImage() { public function getCaptchaImage()
{
global $global; global $global;
header('Content-type: image/jpeg'); header('Content-type: image/jpeg');
$imagem = imagecreate($this->largura,$this->altura); // define a largura e a altura da imagem $imagem = imagecreate($this->largura, $this->altura); // define a largura e a altura da imagem
$fonte = $global['systemRootPath'] . 'objects/monof55.ttf'; //voce deve ter essa ou outra fonte de sua preferencia em sua pasta $fonte = $global['systemRootPath'] . 'objects/monof55.ttf'; //voce deve ter essa ou outra fonte de sua preferencia em sua pasta
$preto = imagecolorallocate($imagem, 0, 0, 0); // define a cor preta $preto = imagecolorallocate($imagem, 0, 0, 0); // define a cor preta
$branco = imagecolorallocate($imagem, 255, 255, 255); // define a cor branca $branco = imagecolorallocate($imagem, 255, 255, 255); // define a cor branca
@ -26,7 +32,7 @@ class Captcha{
//$letters = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnPpQqRrSsTtUuVvYyXxWwZz23456789'; //$letters = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnPpQqRrSsTtUuVvYyXxWwZz23456789';
$letters = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnPpQqRrSsTtUuVvYyXxWwZz23456789'; $letters = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnPpQqRrSsTtUuVvYyXxWwZz23456789';
$palavra = substr(str_shuffle($letters), 0, ($this->quantidade_letras)); $palavra = substr(str_shuffle($letters), 0, ($this->quantidade_letras));
if(User::isAdmin()){ if (User::isAdmin()) {
$palavra = "admin"; $palavra = "admin";
} }
_session_start(); _session_start();
@ -49,20 +55,20 @@ class Captcha{
//_error_log("getCaptchaImage _SESSION[palavra] = ($_SESSION[palavra]) - session_name ". session_name()." session_id: ". session_id()); //_error_log("getCaptchaImage _SESSION[palavra] = ($_SESSION[palavra]) - session_name ". session_name()." session_id: ". session_id());
} }
static public function validation($word) { public static function validation($word)
if(User::isAdmin()){ {
if (User::isAdmin()) {
return true; return true;
} }
_session_start(); _session_start();
if(empty($_SESSION["palavra"])){ if (empty($_SESSION["palavra"])) {
_error_log("Captcha validation Error: you type ({$word}) and session is empty - session_name ". session_name()." session_id: ". session_id()); _error_log("Captcha validation Error: you type ({$word}) and session is empty - session_name ". session_name()." session_id: ". session_id());
return false; return false;
} }
$validation = (strcasecmp($word, $_SESSION["palavra"]) == 0); $validation = (strcasecmp($word, $_SESSION["palavra"]) == 0);
if(!$validation){ if (!$validation) {
_error_log("Captcha validation Error: you type ({$word}) and session is ({$_SESSION["palavra"]})- session_name ". session_name()." session_id: ". session_id()); _error_log("Captcha validation Error: you type ({$word}) and session is ({$_SESSION["palavra"]})- session_name ". session_name()." session_id: ". session_id());
} }
return $validation; return $validation;
} }
} }

View file

@ -1,5 +1,4 @@
<?php <?php
global $global, $config; global $global, $config;
if (!isset($global['systemRootPath'])) { if (!isset($global['systemRootPath'])) {
require_once dirname(__FILE__) . '/../videos/configuration.php'; require_once dirname(__FILE__) . '/../videos/configuration.php';
@ -9,8 +8,8 @@ require_once $global['systemRootPath'] . 'objects/bootGrid.php';
require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/video.php'; require_once $global['systemRootPath'] . 'objects/video.php';
class Category { class Category
{
private $id; private $id;
private $name; private $name;
private $clean_name; private $clean_name;
@ -25,34 +24,41 @@ class Category {
private $order; private $order;
private $suggested; private $suggested;
function getSuggested() { public function getSuggested()
{
return empty($this->suggested) ? 0 : 1; return empty($this->suggested) ? 0 : 1;
} }
function setSuggested($suggested) { public function setSuggested($suggested)
{
$this->suggested = empty($suggested) ? 0 : 1; $this->suggested = empty($suggested) ? 0 : 1;
} }
function getOrder() { public function getOrder()
{
return intval($this->order); return intval($this->order);
} }
function setOrder($order) { public function setOrder($order)
{
$this->order = intval($order); $this->order = intval($order);
} }
function getUsers_id() { public function getUsers_id()
{
if (empty($this->users_id)) { if (empty($this->users_id)) {
$this->users_id = User::getId(); $this->users_id = User::getId();
} }
return $this->users_id; return $this->users_id;
} }
function getPrivate() { public function getPrivate()
{
return $this->private; return $this->private;
} }
function setUsers_id($users_id) { public function setUsers_id($users_id)
{
// only admin can change owner // only admin can change owner
if (!empty($this->users_id) && !User::isAdmin()) { if (!empty($this->users_id) && !User::isAdmin()) {
return false; return false;
@ -61,32 +67,40 @@ class Category {
$this->users_id = intval($users_id); $this->users_id = intval($users_id);
} }
function setPrivate($private) { public function setPrivate($private)
{
$this->private = empty($private) ? 0 : 1; $this->private = empty($private) ? 0 : 1;
} }
function setName($name) { public function setName($name)
{
$this->name = _substr($name, 0, 45); $this->name = _substr($name, 0, 45);
} }
function setClean_name($clean_name) { public function setClean_name($clean_name)
{
$clean_name = preg_replace('/\W+/', '-', strtolower(cleanString($clean_name))); $clean_name = preg_replace('/\W+/', '-', strtolower(cleanString($clean_name)));
$this->clean_name = _substr($clean_name, 0, 45);; $this->clean_name = _substr($clean_name, 0, 45);
;
} }
function setNextVideoOrder($nextVideoOrder) { public function setNextVideoOrder($nextVideoOrder)
{
$this->nextVideoOrder = $nextVideoOrder; $this->nextVideoOrder = $nextVideoOrder;
} }
function setParentId($parentId) { public function setParentId($parentId)
{
$this->parentId = $parentId; $this->parentId = $parentId;
} }
function setDescription($description) { public function setDescription($description)
{
$this->description = $description; $this->description = $description;
} }
function __construct($id, $name = '') { public function __construct($id, $name = '')
{
if (empty($id)) { if (empty($id)) {
// get the category data from category and pass // get the category data from category and pass
$this->name = $name; $this->name = $name;
@ -97,21 +111,25 @@ class Category {
} }
} }
private function load($id) { private function load($id)
{
$row = self::getCategory($id); $row = self::getCategory($id);
if (empty($row)) if (empty($row)) {
return false; return false;
}
foreach ($row as $key => $value) { foreach ($row as $key => $value) {
$this->$key = $value; $this->$key = $value;
} }
return true; return true;
} }
function loadSelfCategory() { public function loadSelfCategory()
{
$this->load($this->getId()); $this->load($this->getId());
} }
function save($allowOfflineUser = false) { public function save($allowOfflineUser = false)
{
global $global; global $global;
if (!$allowOfflineUser && !self::canCreateCategory()) { if (!$allowOfflineUser && !self::canCreateCategory()) {
@ -148,7 +166,7 @@ class Category {
. "suggested = ?," . "suggested = ?,"
. "`private` = ?, allow_download = ?, `order` = ?, modified = now() WHERE id = ?"; . "`private` = ?, allow_download = ?, `order` = ?, modified = now() WHERE id = ?";
$format = "sssiisiiiiii"; $format = "sssiisiiiiii";
$values = array($this->name, $this->clean_name, $this->description, intval($this->nextVideoOrder), $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getSuggested(), $this->getPrivate(), $this->getAllow_download(), $this->getOrder(), $this->id); $values = [$this->name, $this->clean_name, $this->description, intval($this->nextVideoOrder), $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getSuggested(), $this->getPrivate(), $this->getAllow_download(), $this->getOrder(), $this->id];
} else { } else {
$sql = "INSERT INTO categories ( " $sql = "INSERT INTO categories ( "
. "name," . "name,"
@ -161,7 +179,7 @@ class Category {
. "suggested, " . "suggested, "
. "`private`, allow_download, `order`, created, modified) VALUES (?, ?,?,?,?,?,?,?,?,?,?,now(), now())"; . "`private`, allow_download, `order`, created, modified) VALUES (?, ?,?,?,?,?,?,?,?,?,?,now(), now())";
$format = "sssiisiiiii"; $format = "sssiisiiiii";
$values = array($this->name, $this->clean_name, $this->description, intval($this->nextVideoOrder), $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getSuggested(), $this->getPrivate(), $this->getAllow_download(), $this->getOrder()); $values = [$this->name, $this->clean_name, $this->description, intval($this->nextVideoOrder), $this->parentId, $this->getIconClass(), $this->getUsers_id(), $this->getSuggested(), $this->getPrivate(), $this->getAllow_download(), $this->getOrder()];
} }
$insert_row = sqlDAL::writeSql($sql, $format, $values); $insert_row = sqlDAL::writeSql($sql, $format, $values);
if ($insert_row) { if ($insert_row) {
@ -178,7 +196,8 @@ class Category {
} }
} }
static function fixCleanTitle($clean_title, $count, $id, $original_title = "") { public static function fixCleanTitle($clean_title, $count, $id, $original_title = "")
{
global $global; global $global;
if (empty($original_title)) { if (empty($original_title)) {
@ -190,7 +209,7 @@ class Category {
$sql .= " AND id != {$id} "; $sql .= " AND id != {$id} ";
} }
$sql .= " LIMIT 1"; $sql .= " LIMIT 1";
$res = sqlDAL::readSql($sql, "", array(), true); $res = sqlDAL::readSql($sql, "", [], true);
$cleanTitleExists = sqlDAL::fetchAssoc($res); $cleanTitleExists = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if ($cleanTitleExists != false) { if ($cleanTitleExists != false) {
@ -199,7 +218,8 @@ class Category {
return $clean_title; return $clean_title;
} }
function delete() { public function delete()
{
if (!self::canCreateCategory()) { if (!self::canCreateCategory()) {
return false; return false;
} }
@ -219,7 +239,7 @@ class Category {
$categories_id = self::getSiteCategoryDefaultID(); $categories_id = self::getSiteCategoryDefaultID();
if ($categories_id) { if ($categories_id) {
$sql = "UPDATE videos SET categories_id = ? WHERE categories_id = ?"; $sql = "UPDATE videos SET categories_id = ? WHERE categories_id = ?";
sqlDAL::writeSql($sql, "ii", array($categories_id, $this->id)); sqlDAL::writeSql($sql, "ii", [$categories_id, $this->id]);
} }
$sql = "DELETE FROM categories WHERE id = ?"; $sql = "DELETE FROM categories WHERE id = ?";
} else { } else {
@ -227,10 +247,11 @@ class Category {
} }
self::deleteCategoryCache(); self::deleteCategoryCache();
self::deleteAssets($this->id); self::deleteAssets($this->id);
return sqlDAL::writeSql($sql, "i", array($this->id)); return sqlDAL::writeSql($sql, "i", [$this->id]);
} }
static function deleteAssets($categories_id) { public static function deleteAssets($categories_id)
{
$dirPaths = self::getCategoryDirPath($categories_id); $dirPaths = self::getCategoryDirPath($categories_id);
return rrmdir($dirPaths['path']); return rrmdir($dirPaths['path']);
} }
@ -255,11 +276,12 @@ class Category {
* *
*/ */
static function getCategory($id) { public static function getCategory($id)
{
global $global; global $global;
$id = intval($id); $id = intval($id);
$sql = "SELECT * FROM categories WHERE id = ? LIMIT 1"; $sql = "SELECT * FROM categories WHERE id = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "i", array($id)); $res = sqlDAL::readSql($sql, "i", [$id]);
$result = sqlDAL::fetchAssoc($res); $result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if ($result) { if ($result) {
@ -268,24 +290,28 @@ class Category {
return ($res) ? $result : false; return ($res) ? $result : false;
} }
static function getCategoryLink($id) { public static function getCategoryLink($id)
{
$cat = new Category($id); $cat = new Category($id);
return self::getCategoryLinkFromName($cat->getClean_name()); return self::getCategoryLinkFromName($cat->getClean_name());
} }
static function getCategoryLinkFromName($clean_name) { public static function getCategoryLinkFromName($clean_name)
{
global $global; global $global;
return "{$global['webSiteRootURL']}cat/{$clean_name}"; return "{$global['webSiteRootURL']}cat/{$clean_name}";
} }
function getLink() { public function getLink()
{
return self::getCategoryLinkFromName($this->getClean_name()); return self::getCategoryLinkFromName($this->getClean_name());
} }
static function getCategoryByName($name) { public static function getCategoryByName($name)
{
global $global; global $global;
$sql = "SELECT * FROM categories WHERE clean_name = ? LIMIT 1"; $sql = "SELECT * FROM categories WHERE clean_name = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "s", array($name)); $res = sqlDAL::readSql($sql, "s", [$name]);
$result = sqlDAL::fetchAssoc($res); $result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if ($result) { if ($result) {
@ -295,7 +321,8 @@ class Category {
return ($res) ? $result : false; return ($res) ? $result : false;
} }
static function getOrCreateCategoryByName($name) { public static function getOrCreateCategoryByName($name)
{
$cat = self::getCategoryByName($name); $cat = self::getCategoryByName($name);
if (empty($cat)) { if (empty($cat)) {
$obj = new Category(0); $obj = new Category(0);
@ -312,7 +339,8 @@ class Category {
return $cat; return $cat;
} }
static function getCategoryDefault() { public static function getCategoryDefault()
{
global $global; global $global;
$sql = "SELECT * FROM categories ORDER BY id ASC LIMIT 1"; $sql = "SELECT * FROM categories ORDER BY id ASC LIMIT 1";
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
@ -324,7 +352,8 @@ class Category {
return ($res) ? $result : false; return ($res) ? $result : false;
} }
static function getSiteCategoryDefaultID() { public static function getSiteCategoryDefaultID()
{
$obj = AVideoPlugin::getObjectDataIfEnabled("PredefinedCategory"); $obj = AVideoPlugin::getObjectDataIfEnabled("PredefinedCategory");
$id = false; $id = false;
if ($obj) { if ($obj) {
@ -338,7 +367,8 @@ class Category {
return $id; return $id;
} }
static function deleteCategoryCache() { public static function deleteCategoryCache()
{
_session_start(); _session_start();
ObjectYPT::deleteAllSessionCache(); ObjectYPT::deleteAllSessionCache();
clearFirstPageCache(); clearFirstPageCache();
@ -349,7 +379,8 @@ class Category {
_error_log("deleteCategoryCache: {$cacheDir} = ". json_encode($rrmdir)); _error_log("deleteCategoryCache: {$cacheDir} = ". json_encode($rrmdir));
} }
static function getAllCategories($filterCanAddVideoOnly = false, $onlyWithVideos = false, $onlySuggested = false) { public static function getAllCategories($filterCanAddVideoOnly = false, $onlyWithVideos = false, $onlySuggested = false)
{
global $global, $config; global $global, $config;
if ($config->currentVersionLowerThen('8.4')) { if ($config->currentVersionLowerThen('8.4')) {
return false; return false;
@ -392,7 +423,7 @@ class Category {
$sql .= ")"; $sql .= ")";
} }
$sortWhitelist = array('id', 'name', 'clean_name', 'description', 'iconClass', 'nextVideoOrder', 'parentId', 'type', 'users_id', 'private', 'allow_download', 'order', 'suggested'); $sortWhitelist = ['id', 'name', 'clean_name', 'description', 'iconClass', 'nextVideoOrder', 'parentId', 'type', 'users_id', 'private', 'allow_download', 'order', 'suggested'];
if (!empty($_POST['sort']) && is_array($_POST['sort'])) { if (!empty($_POST['sort']) && is_array($_POST['sort'])) {
foreach ($_POST['sort'] as $key => $value) { foreach ($_POST['sort'] as $key => $value) {
@ -401,12 +432,12 @@ class Category {
} }
} }
} }
$sql .= BootGrid::getSqlFromPost(array('name'), "", " ORDER BY `order`, name ASC "); $sql .= BootGrid::getSqlFromPost(['name'], "", " ORDER BY `order`, name ASC ");
//echo $sql;exit; //echo $sql;exit;
$cacheName = 'category/' . md5($sql); $cacheName = 'category/' . md5($sql);
if (empty($_SESSION['user']['sessionCache']['getAllCategoriesClearCache'])) { if (empty($_SESSION['user']['sessionCache']['getAllCategoriesClearCache'])) {
$category = object_to_array(ObjectYPT::getCache($cacheName, 36000)); $category = object_to_array(ObjectYPT::getCache($cacheName, 36000));
//var_dump($cacheName, ObjectYPT::getLastUsedCacheInfo(), fixPath(ObjectYPT::getCacheDir() . 'category/'));exit; //var_dump($cacheName, ObjectYPT::getLastUsedCacheInfo(), fixPath(ObjectYPT::getCacheDir() . 'category/'));exit;
} else { } else {
_session_start(); _session_start();
unset($_SESSION['user']['sessionCache']['getAllCategoriesClearCache']); unset($_SESSION['user']['sessionCache']['getAllCategoriesClearCache']);
@ -415,10 +446,9 @@ class Category {
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$fullResult = sqlDAL::fetchAllAssoc($res); $fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$category = array(); $category = [];
if ($res) { if ($res) {
foreach ($fullResult as $row) { foreach ($fullResult as $row) {
$totals = self::getTotalFromCategory($row['id']); $totals = self::getTotalFromCategory($row['id']);
$fullTotals = self::getTotalFromCategory($row['id'], false, true, true); $fullTotals = self::getTotalFromCategory($row['id'], false, true, true);
@ -446,12 +476,13 @@ class Category {
return $category; return $category;
} }
static function getHierarchyArray($categories_id, $hierarchyArray = array()) { public static function getHierarchyArray($categories_id, $hierarchyArray = [])
{
if (empty($categories_id)) { if (empty($categories_id)) {
return $hierarchyArray; return $hierarchyArray;
} }
$sql = "SELECT * FROM categories WHERE id=? "; $sql = "SELECT * FROM categories WHERE id=? ";
$res = sqlDAL::readSql($sql, "i", array($categories_id)); $res = sqlDAL::readSql($sql, "i", [$categories_id]);
$result = sqlDAL::fetchAssoc($res); $result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if ($result) { if ($result) {
@ -461,7 +492,8 @@ class Category {
return $hierarchyArray; return $hierarchyArray;
} }
static function getHierarchyString($categories_id) { public static function getHierarchyString($categories_id)
{
if (empty($categories_id)) { if (empty($categories_id)) {
return "/"; return "/";
} }
@ -478,7 +510,8 @@ class Category {
return $str; return $str;
} }
static function userCanAddInCategory($categories_id, $users_id = 0) { public static function userCanAddInCategory($categories_id, $users_id = 0)
{
if (empty($categories_id)) { if (empty($categories_id)) {
return false; return false;
} }
@ -495,7 +528,8 @@ class Category {
return false; return false;
} }
static function userCanEditCategory($categories_id, $users_id = 0) { public static function userCanEditCategory($categories_id, $users_id = 0)
{
if (empty($categories_id)) { if (empty($categories_id)) {
return false; return false;
} }
@ -517,7 +551,8 @@ class Category {
return false; return false;
} }
static function canCreateCategory() { public static function canCreateCategory()
{
global $advancedCustomUser; global $advancedCustomUser;
if (User::isAdmin()) { if (User::isAdmin()) {
return true; return true;
@ -528,7 +563,8 @@ class Category {
return false; return false;
} }
static function getChildCategories($parentId, $filterCanAddVideoOnly = false) { public static function getChildCategories($parentId, $filterCanAddVideoOnly = false)
{
global $global, $config; global $global, $config;
if ($config->currentVersionLowerThen('8.4')) { if ($config->currentVersionLowerThen('8.4')) {
return false; return false;
@ -545,11 +581,11 @@ class Category {
$sql .= " AND (private=0 OR users_id = '{$users_id}') "; $sql .= " AND (private=0 OR users_id = '{$users_id}') ";
} }
} }
$sql .= BootGrid::getSqlFromPost(array('name'), "", " ORDER BY `order`, name ASC "); $sql .= BootGrid::getSqlFromPost(['name'], "", " ORDER BY `order`, name ASC ");
$res = sqlDAL::readSql($sql, "ii", array($parentId, $parentId)); $res = sqlDAL::readSql($sql, "ii", [$parentId, $parentId]);
$fullResult = sqlDAL::fetchAllAssoc($res); $fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$category = array(); $category = [];
if ($res) { if ($res) {
foreach ($fullResult as $row) { foreach ($fullResult as $row) {
$totals = self::getTotalFromCategory($row['id']); $totals = self::getTotalFromCategory($row['id']);
@ -565,42 +601,45 @@ class Category {
return $category; return $category;
} }
static function getChildCategoriesFromTitle($clean_title) { public static function getChildCategoriesFromTitle($clean_title)
{
$row = self::getCategoryByName($clean_title); $row = self::getCategoryByName($clean_title);
return self::getChildCategories($row['id']); return self::getChildCategories($row['id']);
} }
static function getTotalFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false, $renew = false) { public static function getTotalFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false, $renew = false)
{
$videos = self::getTotalVideosFromCategory($categories_id, $showUnlisted, $getAllVideos, $renew); $videos = self::getTotalVideosFromCategory($categories_id, $showUnlisted, $getAllVideos, $renew);
$lives = self::getTotalLivesFromCategory($categories_id, $showUnlisted, $renew); $lives = self::getTotalLivesFromCategory($categories_id, $showUnlisted, $renew);
$livelinkss = self::getTotalLiveLinksFromCategory($categories_id, $showUnlisted, $renew); $livelinkss = self::getTotalLiveLinksFromCategory($categories_id, $showUnlisted, $renew);
$total = $videos + $lives + $livelinkss; $total = $videos + $lives + $livelinkss;
return array('videos' => $videos, 'lives' => $lives, 'livelinks' => $livelinkss, 'total' => $total); return ['videos' => $videos, 'lives' => $lives, 'livelinks' => $livelinkss, 'total' => $total];
} }
static function getTotalFromChildCategory($categories_id, $showUnlisted = false, $getAllVideos = false, $renew = false) { public static function getTotalFromChildCategory($categories_id, $showUnlisted = false, $getAllVideos = false, $renew = false)
{
$categories = self::getChildCategories($categories_id); $categories = self::getChildCategories($categories_id);
$array = array('videos' => 0, 'lives' => 0, 'livelinks' => 0, 'total' => 0); $array = ['videos' => 0, 'lives' => 0, 'livelinks' => 0, 'total' => 0];
foreach ($categories as $value) { foreach ($categories as $value) {
$totals = self::getTotalFromCategory($categories_id, $showUnlisted, $getAllVideos, $renew); $totals = self::getTotalFromCategory($categories_id, $showUnlisted, $getAllVideos, $renew);
$array = array( $array = [
'videos' => $array['videos'] + $totals['videos'], 'videos' => $array['videos'] + $totals['videos'],
'lives' => $array['lives'] + $totals['lives'], 'lives' => $array['lives'] + $totals['lives'],
'livelinks' => $array['livelinks'] + $totals['livelinks'], 'livelinks' => $array['livelinks'] + $totals['livelinks'],
'total' => $array['total'] + $totals['total']); 'total' => $array['total'] + $totals['total'], ];
$totals = self::getTotalFromChildCategory($value['id'], $showUnlisted, $getAllVideos, $renew); $totals = self::getTotalFromChildCategory($value['id'], $showUnlisted, $getAllVideos, $renew);
$array = array( $array = [
'videos' => $array['videos'] + $totals['videos'], 'videos' => $array['videos'] + $totals['videos'],
'lives' => $array['lives'] + $totals['lives'], 'lives' => $array['lives'] + $totals['lives'],
'livelinks' => $array['livelinks'] + $totals['livelinks'], 'livelinks' => $array['livelinks'] + $totals['livelinks'],
'total' => $array['total'] + $totals['total']); 'total' => $array['total'] + $totals['total'], ];
} }
return $array; return $array;
} }
static function getTotalVideosFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false, $renew = false) { public static function getTotalVideosFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false, $renew = false)
{
global $global, $config; global $global, $config;
if ($renew || empty($_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)]['videos'])) { if ($renew || empty($_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)]['videos'])) {
$sql = "SELECT count(id) as total FROM videos v WHERE 1=1 AND categories_id = ? "; $sql = "SELECT count(id) as total FROM videos v WHERE 1=1 AND categories_id = ? ";
@ -614,7 +653,7 @@ class Category {
$sql .= Video::getUserGroupsCanSeeSQL(); $sql .= Video::getUserGroupsCanSeeSQL();
} }
//echo $categories_id, $sql;exit; //echo $categories_id, $sql;exit;
$res = sqlDAL::readSql($sql, "i", array($categories_id)); $res = sqlDAL::readSql($sql, "i", [$categories_id]);
$fullResult = sqlDAL::fetchAllAssoc($res); $fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$total = empty($fullResult[0]['total']) ? 0 : intval($fullResult[0]['total']); $total = empty($fullResult[0]['total']) ? 0 : intval($fullResult[0]['total']);
@ -628,7 +667,8 @@ class Category {
return $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)]['videos']; return $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][intval($getAllVideos)]['videos'];
} }
static function getLatestVideoFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false) { public static function getLatestVideoFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false)
{
global $global, $config; global $global, $config;
$sql = "SELECT * FROM videos v WHERE 1=1 AND (categories_id = ? OR categories_id IN (SELECT id from categories where parentId = ?))"; $sql = "SELECT * FROM videos v WHERE 1=1 AND (categories_id = ? OR categories_id IN (SELECT id from categories where parentId = ?))";
@ -642,15 +682,16 @@ class Category {
} }
$sql .= "ORDER BY created DESC LIMIT 1"; $sql .= "ORDER BY created DESC LIMIT 1";
//var_dump($sql, $categories_id); //var_dump($sql, $categories_id);
$res = sqlDAL::readSql($sql, "ii", array($categories_id, $categories_id)); $res = sqlDAL::readSql($sql, "ii", [$categories_id, $categories_id]);
$result = sqlDAL::fetchAssoc($res); $result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
return $result; return $result;
} }
static function getLatestLiveFromCategory($categories_id) { public static function getLatestLiveFromCategory($categories_id)
{
if (!AVideoPlugin::isEnabledByName("Live")) { if (!AVideoPlugin::isEnabledByName("Live")) {
return array(); return [];
} }
global $global, $config; global $global, $config;
$sql = "SELECT * FROM live_transmitions lt LEFT JOIN live_transmitions_history lth ON lt.users_id = lth.users_id " $sql = "SELECT * FROM live_transmitions lt LEFT JOIN live_transmitions_history lth ON lt.users_id = lth.users_id "
@ -658,28 +699,30 @@ class Category {
$sql .= "ORDER BY lth.created DESC LIMIT 1"; $sql .= "ORDER BY lth.created DESC LIMIT 1";
//var_dump($sql, $categories_id); //var_dump($sql, $categories_id);
$res = sqlDAL::readSql($sql, "ii", array($categories_id, $categories_id)); $res = sqlDAL::readSql($sql, "ii", [$categories_id, $categories_id]);
$result = sqlDAL::fetchAssoc($res); $result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
return $result; return $result;
} }
static function getLatestLiveLinksFromCategory($categories_id) { public static function getLatestLiveLinksFromCategory($categories_id)
{
if (AVideoPlugin::isEnabledByName("LiveLinks")) { if (AVideoPlugin::isEnabledByName("LiveLinks")) {
return array(); return [];
} }
global $global, $config; global $global, $config;
$sql = "SELECT * FROM livelinks WHERE 1=1 AND (categories_id = ? OR categories_id IN (SELECT id from categories where parentId = ?))"; $sql = "SELECT * FROM livelinks WHERE 1=1 AND (categories_id = ? OR categories_id IN (SELECT id from categories where parentId = ?))";
$sql .= "ORDER BY created DESC LIMIT 1"; $sql .= "ORDER BY created DESC LIMIT 1";
//var_dump($sql, $categories_id); //var_dump($sql, $categories_id);
$res = sqlDAL::readSql($sql, "ii", array($categories_id, $categories_id)); $res = sqlDAL::readSql($sql, "ii", [$categories_id, $categories_id]);
$result = sqlDAL::fetchAssoc($res); $result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
return $result; return $result;
} }
static function getTotalLiveLinksFromCategory($categories_id, $showUnlisted = false, $renew = false) { public static function getTotalLiveLinksFromCategory($categories_id, $showUnlisted = false, $renew = false)
{
global $global; global $global;
if (!AVideoPlugin::isEnabledByName("LiveLinks")) { if (!AVideoPlugin::isEnabledByName("LiveLinks")) {
@ -694,7 +737,7 @@ class Category {
} }
//echo $categories_id, $sql;exit; //echo $categories_id, $sql;exit;
$res = sqlDAL::readSql($sql, "i", array($categories_id)); $res = sqlDAL::readSql($sql, "i", [$categories_id]);
$fullResult = sqlDAL::fetchAllAssoc($res); $fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$total = empty($fullResult[0]['total']) ? 0 : intval($fullResult[0]['total']); $total = empty($fullResult[0]['total']) ? 0 : intval($fullResult[0]['total']);
@ -708,9 +751,8 @@ class Category {
return $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['livelinks']; return $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['livelinks'];
} }
static function getTotalLivesFromCategory($categories_id, $showUnlisted = false, $renew = false) { public static function getTotalLivesFromCategory($categories_id, $showUnlisted = false, $renew = false)
{
if (!AVideoPlugin::isEnabledByName("Live")) { if (!AVideoPlugin::isEnabledByName("Live")) {
return 0; return 0;
} }
@ -724,7 +766,7 @@ class Category {
} }
//echo $categories_id, $sql;exit; //echo $categories_id, $sql;exit;
$res = sqlDAL::readSql($sql, "i", array($categories_id)); $res = sqlDAL::readSql($sql, "i", [$categories_id]);
$fullResult = sqlDAL::fetchAllAssoc($res); $fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$total = empty($fullResult[0]['total']) ? 0 : intval($fullResult[0]['total']); $total = empty($fullResult[0]['total']) ? 0 : intval($fullResult[0]['total']);
@ -738,7 +780,8 @@ class Category {
return $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['live']; return $_SESSION['user']['sessionCache']['categoryTotal'][$categories_id][intval($showUnlisted)][0]['live'];
} }
static function clearCacheCount($categories_id = 0) { public static function clearCacheCount($categories_id = 0)
{
// clear category count cache // clear category count cache
_session_start(); _session_start();
if (empty($categories_id)) { if (empty($categories_id)) {
@ -750,7 +793,8 @@ class Category {
//session_write_close(); //session_write_close();
} }
static function getTotalCategories($filterCanAddVideoOnly = false, $onlyWithVideos = false, $onlySuggested = false) { public static function getTotalCategories($filterCanAddVideoOnly = false, $onlyWithVideos = false, $onlySuggested = false)
{
global $global, $config; global $global, $config;
if ($config->currentVersionLowerThen('5.01')) { if ($config->currentVersionLowerThen('5.01')) {
@ -793,7 +837,7 @@ class Category {
} }
$sql .= ")"; $sql .= ")";
} }
$sql .= BootGrid::getSqlSearchFromPost(array('name')); $sql .= BootGrid::getSqlSearchFromPost(['name']);
//echo $sql;exit; //echo $sql;exit;
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$numRows = sqlDal::num_rows($res); $numRows = sqlDal::num_rows($res);
@ -801,38 +845,46 @@ class Category {
return $numRows; return $numRows;
} }
function getIconClass() { public function getIconClass()
{
if (empty($this->iconClass)) { if (empty($this->iconClass)) {
return "fa fa-folder"; return "fa fa-folder";
} }
return $this->iconClass; return $this->iconClass;
} }
function setIconClass($iconClass) { public function setIconClass($iconClass)
{
$this->iconClass = $iconClass; $this->iconClass = $iconClass;
} }
function getName() { public function getName()
{
return $this->name; return $this->name;
} }
function getClean_name() { public function getClean_name()
{
return $this->clean_name; return $this->clean_name;
} }
function getDescription() { public function getDescription()
{
return $this->description; return $this->description;
} }
function getAllow_download() { public function getAllow_download()
{
return $this->allow_download; return $this->allow_download;
} }
function setAllow_download($allow_download) { public function setAllow_download($allow_download)
{
$this->allow_download = intval($allow_download); $this->allow_download = intval($allow_download);
} }
static function getCategoryDirPath($categories_id = "") { public static function getCategoryDirPath($categories_id = "")
{
global $global; global $global;
$dir = "videos/categories/assets/"; $dir = "videos/categories/assets/";
@ -840,7 +892,7 @@ class Category {
$dir .= $categories_id . "/"; $dir .= $categories_id . "/";
} }
$path = array(); $path = [];
$path['dir'] = "{$global['systemRootPath']}{$dir}"; $path['dir'] = "{$global['systemRootPath']}{$dir}";
make_path($path['dir']); make_path($path['dir']);
$path['path'] = "{$global['systemRootPath']}{$dir}"; $path['path'] = "{$global['systemRootPath']}{$dir}";
@ -848,7 +900,8 @@ class Category {
return $path; return $path;
} }
static function isAssetsValids($categories_id) { public static function isAssetsValids($categories_id)
{
$photo = Category::getCategoryPhotoPath($categories_id); $photo = Category::getCategoryPhotoPath($categories_id);
$background = Category::getCategoryBackgroundPath($categories_id); $background = Category::getCategoryBackgroundPath($categories_id);
//var_dump(filesize($background['path']), $background['path'], filesize($photo['path']), $photo['path'] ); //var_dump(filesize($background['path']), $background['path'], filesize($photo['path']), $photo['path'] );
@ -864,10 +917,11 @@ class Category {
return true; return true;
} }
public static function getOGImagePaths($categories_id) { public static function getOGImagePaths($categories_id)
{
$name = "og_200X200.jpg"; $name = "og_200X200.jpg";
$dirPaths = self::getCategoryDirPath($categories_id); $dirPaths = self::getCategoryDirPath($categories_id);
$path = array(); $path = [];
$path['dir'] = $dirPaths['url']; $path['dir'] = $dirPaths['url'];
$path['path'] = "{$dirPaths['path']}{$name}"; $path['path'] = "{$dirPaths['path']}{$name}";
$path['url'] = "{$dirPaths['url']}{$name}"; $path['url'] = "{$dirPaths['url']}{$name}";
@ -879,7 +933,8 @@ class Category {
return $path; return $path;
} }
public static function deleteOGImage($categories_id) { public static function deleteOGImage($categories_id)
{
$ogPaths = self::getOGImagePaths($categories_id); $ogPaths = self::getOGImagePaths($categories_id);
$destination = $ogPaths['path']; $destination = $ogPaths['path'];
if (file_exists($destination)) { if (file_exists($destination)) {
@ -887,7 +942,8 @@ class Category {
} }
} }
public static function getOGImage($categories_id) { public static function getOGImage($categories_id)
{
global $global; global $global;
$isAssetsValids = self::isAssetsValids($categories_id); $isAssetsValids = self::isAssetsValids($categories_id);
if ($isAssetsValids) { if ($isAssetsValids) {
@ -905,17 +961,20 @@ class Category {
} }
} }
static function getCategoryPhotoPath($categories_id) { public static function getCategoryPhotoPath($categories_id)
{
$path = self::getCategoryAssetPath("photo.png", $categories_id); $path = self::getCategoryAssetPath("photo.png", $categories_id);
return $path; return $path;
} }
static function getCategoryBackgroundPath($categories_id) { public static function getCategoryBackgroundPath($categories_id)
{
$path = self::getCategoryAssetPath("background.png", $categories_id); $path = self::getCategoryAssetPath("background.png", $categories_id);
return $path; return $path;
} }
private static function getCategoryAssetPath($name, $categories_id) { private static function getCategoryAssetPath($name, $categories_id)
{
if (empty($categories_id)) { if (empty($categories_id)) {
return false; return false;
} }
@ -927,7 +986,7 @@ class Category {
global $global; global $global;
$path = array(); $path = [];
$path['dir'] = $dirPaths['url']; $path['dir'] = $dirPaths['url'];
$path['path'] = "{$dirPaths['path']}{$name}"; $path['path'] = "{$dirPaths['path']}{$name}";
$path['url'] = "{$dirPaths['url']}{$name}"; $path['url'] = "{$dirPaths['url']}{$name}";
@ -938,5 +997,4 @@ class Category {
} }
return $path; return $path;
} }
} }

View file

@ -2,7 +2,7 @@
error_reporting(0); error_reporting(0);
header('Content-Type: application/json'); header('Content-Type: application/json');
global $global, $config; global $global, $config;
if(!isset($global['systemRootPath'])){ if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/user.php';
@ -15,7 +15,7 @@ $obj->categories_id = 0;
$obj->image1 = 0; $obj->image1 = 0;
$obj->image2 = 0; $obj->image2 = 0;
if(!Category::canCreateCategory()){ if (!Category::canCreateCategory()) {
$obj->msg = __("Permission denied"); $obj->msg = __("Permission denied");
die(json_encode($obj)); die(json_encode($obj));
} }
@ -35,7 +35,7 @@ $objCat->setOrder($_POST['order']);
$obj->categories_id = $objCat->save(); $obj->categories_id = $objCat->save();
//$objCat->setType($_POST['type'],$id); //$objCat->setType($_POST['type'],$id);
if(!empty($obj->categories_id)){ if (!empty($obj->categories_id)) {
$obj->error = false; $obj->error = false;
$path = Category::getCategoryPhotoPath($obj->categories_id); $path = Category::getCategoryPhotoPath($obj->categories_id);
$obj->image1 = saveCroppieImage($path['path'], "image1"); $obj->image1 = saveCroppieImage($path['path'], "image1");

View file

@ -1,12 +1,12 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
global $global, $config; global $global, $config;
if(!isset($global['systemRootPath'])){ if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/category.php'; require_once $global['systemRootPath'] . 'objects/category.php';
if(!Category::canCreateCategory()){ if (!Category::canCreateCategory()) {
die('{"error":"'.__("Permission denied").'"}'); die('{"error":"'.__("Permission denied").'"}');
} }
require_once 'category.php'; require_once 'category.php';

View file

@ -101,12 +101,12 @@ class Comment
} }
$sql = "UPDATE comments SET " $sql = "UPDATE comments SET "
. " comment = ?, modified = now() WHERE id = ?"; . " comment = ?, modified = now() WHERE id = ?";
$resp = sqlDAL::writeSql($sql, "si", array(xss_esc($this->comment),$this->id)); $resp = sqlDAL::writeSql($sql, "si", [xss_esc($this->comment),$this->id]);
} else { } else {
$id = User::getId(); $id = User::getId();
$sql = "INSERT INTO comments ( comment,users_id, videos_id, comments_id_pai, created, modified) VALUES " $sql = "INSERT INTO comments ( comment,users_id, videos_id, comments_id_pai, created, modified) VALUES "
. " (?, ?, ?, {$this->comments_id_pai}, now(), now())"; . " (?, ?, ?, {$this->comments_id_pai}, now(), now())";
$resp = sqlDAL::writeSql($sql, "sii", array(xss_esc($this->comment),$id,$this->videos_id)); $resp = sqlDAL::writeSql($sql, "sii", [xss_esc($this->comment),$id,$this->videos_id]);
} }
if ((empty($resp))&&($global['mysqli']->errno!=0)) { if ((empty($resp))&&($global['mysqli']->errno!=0)) {
die('Error (comment save) : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); die('Error (comment save) : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
@ -138,7 +138,7 @@ class Comment
} else { } else {
return false; return false;
} }
return sqlDAL::writeSql($sql, "i", array($this->id)); return sqlDAL::writeSql($sql, "i", [$this->id]);
} }
private function getComment($id) private function getComment($id)
@ -146,7 +146,7 @@ class Comment
global $global; global $global;
$id = intval($id); $id = intval($id);
$sql = "SELECT * FROM comments WHERE id = ? LIMIT 1"; $sql = "SELECT * FROM comments WHERE id = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "i", array($id)); $res = sqlDAL::readSql($sql, "i", [$id]);
$result = sqlDAL::fetchAssoc($res); $result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
return ($res!=false) ? $result : false; return ($res!=false) ? $result : false;
@ -155,8 +155,8 @@ class Comment
public static function getAllComments($videoId = 0, $comments_id_pai = 'NULL') public static function getAllComments($videoId = 0, $comments_id_pai = 'NULL')
{ {
global $global; global $global;
$format = ""; $format = '';
$values = array(); $values = [];
$sql = "SELECT c.*, u.name as name, u.user as user, " $sql = "SELECT c.*, u.name as name, u.user as user, "
. " (SELECT count(id) FROM comments_likes as l where l.comments_id = c.id AND `like` = 1 ) as likes, " . " (SELECT count(id) FROM comments_likes as l where l.comments_id = c.id AND `like` = 1 ) as likes, "
. " (SELECT count(id) FROM comments_likes as l where l.comments_id = c.id AND `like` = -1 ) as dislikes "; . " (SELECT count(id) FROM comments_likes as l where l.comments_id = c.id AND `like` = -1 ) as dislikes ";
@ -201,11 +201,11 @@ class Comment
$values[]=$comments_id_pai; $values[]=$comments_id_pai;
} }
$sql .= BootGrid::getSqlFromPost(array('name')); $sql .= BootGrid::getSqlFromPost(['name']);
$res = sqlDAL::readSql($sql, $format, $values); $res = sqlDAL::readSql($sql, $format, $values);
$allData = sqlDAL::fetchAllAssoc($res); $allData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$comment = array(); $comment = [];
if ($res!=false) { if ($res!=false) {
foreach ($allData as $row) { foreach ($allData as $row) {
$row = cleanUpRowFromDatabase($row); $row = cleanUpRowFromDatabase($row);
@ -225,8 +225,8 @@ class Comment
public static function getTotalComments($videoId = 0, $comments_id_pai = 'NULL', $video_owner_users_id=0) public static function getTotalComments($videoId = 0, $comments_id_pai = 'NULL', $video_owner_users_id=0)
{ {
global $global; global $global;
$format = ""; $format = '';
$values = array(); $values = [];
$sql = "SELECT c.id FROM comments c LEFT JOIN users as u ON u.id = users_id LEFT JOIN videos as v ON v.id = videos_id WHERE 1=1 "; $sql = "SELECT c.id FROM comments c LEFT JOIN users as u ON u.id = users_id LEFT JOIN videos as v ON v.id = videos_id WHERE 1=1 ";
if (!empty($videoId)) { if (!empty($videoId)) {
@ -265,7 +265,7 @@ class Comment
$values[] = $video_owner_users_id; $values[] = $video_owner_users_id;
} }
$sql .= BootGrid::getSqlSearchFromPost(array('name')); $sql .= BootGrid::getSqlSearchFromPost(['name']);
$res = sqlDAL::readSql($sql, $format, $values); $res = sqlDAL::readSql($sql, $format, $values);
$countRow = sqlDAL::num_rows($res); $countRow = sqlDAL::num_rows($res);
@ -312,14 +312,14 @@ class Comment
{ {
global $global; global $global;
$sql = "SELECT id from comments WHERE users_id = ?"; $sql = "SELECT id from comments WHERE users_id = ?";
$res = sqlDAL::readSql($sql, "i", array($users_id)); $res = sqlDAL::readSql($sql, "i", [$users_id]);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$r = array('thumbsUp'=>0, 'thumbsDown'=>0 ); $r = ['thumbsUp'=>0, 'thumbsDown'=>0 ];
if ($res!=false) { if ($res!=false) {
foreach ($fullData as $row) { foreach ($fullData as $row) {
$format = "i"; $format = "i";
$values = array($row['id']); $values = [$row['id']];
$sql = "SELECT id from comments_likes WHERE comments_id = ? AND `like` = 1 "; $sql = "SELECT id from comments_likes WHERE comments_id = ? AND `like` = 1 ";
if (!empty($startDate)) { if (!empty($startDate)) {
$sql .= " AND `created` >= ? "; $sql .= " AND `created` >= ? ";
@ -336,7 +336,7 @@ class Comment
sqlDAL::close($res); sqlDAL::close($res);
$r['thumbsUp']+=$countRow; $r['thumbsUp']+=$countRow;
$format = "i"; $format = "i";
$values = array($row['id']); $values = [$row['id']];
$sql = "SELECT id from comments_likes WHERE comments_id = ? AND `like` = -1 "; $sql = "SELECT id from comments_likes WHERE comments_id = ? AND `like` = -1 ";
if (!empty($startDate)) { if (!empty($startDate)) {
$sql .= " AND `created` >= ? "; $sql .= " AND `created` >= ? ";

View file

@ -3,7 +3,7 @@ header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Content-Type"); header("Access-Control-Allow-Headers: Content-Type");
header('Content-Type: application/json'); header('Content-Type: application/json');
global $global, $config; global $global, $config;
if(!isset($global['systemRootPath'])){ if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
@ -14,15 +14,15 @@ require_once $global['systemRootPath'] . 'objects/functions.php';
// gettig the mobile submited value // gettig the mobile submited value
$inputJSON = url_get_contents('php://input'); $inputJSON = url_get_contents('php://input');
$input = _json_decode($inputJSON, TRUE); //convert JSON into array $input = _json_decode($inputJSON, true); //convert JSON into array
unset($_REQUEST["redirectUri"]); unset($_REQUEST["redirectUri"]);
if(!empty($input) && empty($_REQUEST)){ if (!empty($input) && empty($_REQUEST)) {
foreach ($input as $key => $value) { foreach ($input as $key => $value) {
$_REQUEST[$key]=$value; $_REQUEST[$key]=$value;
} }
} }
if(!empty($_REQUEST['user']) && !empty($_REQUEST['pass'])){ if (!empty($_REQUEST['user']) && !empty($_REQUEST['pass'])) {
$user = new User(0, $_REQUEST['user'], $_REQUEST['pass']); $user = new User(0, $_REQUEST['user'], $_REQUEST['pass']);
$user->login(false, true); $user->login(false, true);
} }
@ -36,36 +36,37 @@ if (!User::canComment()) {
die(json_encode($obj)); die(json_encode($obj));
} }
function isCommentASpam($comment, $videos_id){ function isCommentASpam($comment, $videos_id)
{
$comment = trim($comment); $comment = trim($comment);
$obj = new stdClass(); $obj = new stdClass();
$obj->error = true; $obj->error = true;
$obj->msg = ''; $obj->msg = '';
$obj->time = time(); $obj->time = time();
if(empty($comment)){ if (empty($comment)) {
$obj->msg = __('Comment is empty'); $obj->msg = __('Comment is empty');
return $obj; return $obj;
} }
if(empty($videos_id)){ if (empty($videos_id)) {
$obj->msg = __('Video is empty'); $obj->msg = __('Video is empty');
return $obj; return $obj;
} }
_session_start(); _session_start();
if(!isset($_SESSION['comments'])){ if (!isset($_SESSION['comments'])) {
$_SESSION['comments'] = array(); $_SESSION['comments'] = [];
} }
// you can only comment each 5 seconds // you can only comment each 5 seconds
$rest = $_SESSION['comments']['_avideo_last_comment'] - ($obj->time-5); $rest = $_SESSION['comments']['_avideo_last_comment'] - ($obj->time-5);
if($rest>0){ if ($rest>0) {
$obj->msg = __('You just comment something, please wait to comment again').', '.$rest.' '.__('Seconds'); $obj->msg = __('You just comment something, please wait to comment again').', '.$rest.' '.__('Seconds');
return $obj; return $obj;
} }
// if you already comment 3 times or more on the same video you must wait 30 seconds // if you already comment 3 times or more on the same video you must wait 30 seconds
if($_SESSION['comments']['_avideo_count_comments_'.$videos_id]>3){ if ($_SESSION['comments']['_avideo_count_comments_'.$videos_id]>3) {
$rest = $_SESSION['comments']['_avideo_last_comment'] - ($obj->time-30); $rest = $_SESSION['comments']['_avideo_last_comment'] - ($obj->time-30);
if($rest>0){ if ($rest>0) {
$obj->msg = __('You just comment something, please wait to comment again').', '.$rest.' '.__('Seconds'); $obj->msg = __('You just comment something, please wait to comment again').', '.$rest.' '.__('Seconds');
return $obj; return $obj;
} }
@ -74,17 +75,17 @@ function isCommentASpam($comment, $videos_id){
$index = preg_replace('/[^0-9a-z]/i', '', $comment); $index = preg_replace('/[^0-9a-z]/i', '', $comment);
$obj->index = $index; $obj->index = $index;
// you can only repeat the comment (equal or similar) each 60 seconds // you can only repeat the comment (equal or similar) each 60 seconds
if(!empty($_SESSION['comments'][$index])){ if (!empty($_SESSION['comments'][$index])) {
$rest = $_SESSION['comments'][$index]->time - ($obj->time-60); $rest = $_SESSION['comments'][$index]->time - ($obj->time-60);
if($rest>0){ if ($rest>0) {
$obj->msg = __('You just comment something similar, please wait to comment again').', '.$rest.' '.__('Seconds'); $obj->msg = __('You just comment something similar, please wait to comment again').', '.$rest.' '.__('Seconds');
return $obj; return $obj;
} }
} }
if(empty($_SESSION['comments']['_avideo_count_comments_'.$videos_id])){ if (empty($_SESSION['comments']['_avideo_count_comments_'.$videos_id])) {
$_SESSION['comments']['_avideo_count_comments_'.$videos_id] = 1; $_SESSION['comments']['_avideo_count_comments_'.$videos_id] = 1;
}else{ } else {
$_SESSION['comments']['_avideo_count_comments_'.$videos_id]++; $_SESSION['comments']['_avideo_count_comments_'.$videos_id]++;
} }
@ -96,33 +97,33 @@ function isCommentASpam($comment, $videos_id){
} }
require_once 'comment.php'; require_once 'comment.php';
if(empty($_REQUEST['video']) && !empty($_REQUEST['comments_id'])){ if (empty($_REQUEST['video']) && !empty($_REQUEST['comments_id'])) {
$c = new Comment('', '', $_REQUEST['comments_id']); $c = new Comment('', '', $_REQUEST['comments_id']);
$_REQUEST['video'] = $c->getVideos_id(); $_REQUEST['video'] = $c->getVideos_id();
} }
$isSpam = isCommentASpam($_REQUEST['comment'], $_REQUEST['video']); $isSpam = isCommentASpam($_REQUEST['comment'], $_REQUEST['video']);
if($isSpam->error){ if ($isSpam->error) {
$obj->msg = $isSpam->msg; $obj->msg = $isSpam->msg;
die(json_encode($obj)); die(json_encode($obj));
} }
if(!empty($_REQUEST['id'])){ if (!empty($_REQUEST['id'])) {
$_REQUEST['id'] = intval($_REQUEST['id']); $_REQUEST['id'] = intval($_REQUEST['id']);
if(Comment::userCanEditComment($_REQUEST['id'])){ if (Comment::userCanEditComment($_REQUEST['id'])) {
$objC = new Comment("", 0, $_REQUEST['id']); $objC = new Comment("", 0, $_REQUEST['id']);
$objC->setComment($_REQUEST['comment']); $objC->setComment($_REQUEST['comment']);
} }
}else{ } else {
$objC = new Comment($_REQUEST['comment'], $_REQUEST['video']); $objC = new Comment($_REQUEST['comment'], $_REQUEST['video']);
$objC->setComments_id_pai($_REQUEST['comments_id']); $objC->setComments_id_pai($_REQUEST['comments_id']);
} }
$obj->comments_id = $objC->save(); $obj->comments_id = $objC->save();
if(!empty($obj->comments_id)){ if (!empty($obj->comments_id)) {
$obj->error = false; $obj->error = false;
$obj->msg = __("Your comment has been saved!"); $obj->msg = __("Your comment has been saved!");
}else{ } else {
$obj->msg = __("Your comment has NOT been saved!"); $obj->msg = __("Your comment has NOT been saved!");
} }
die(json_encode($obj)); die(json_encode($obj));

View file

@ -1,7 +1,7 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
global $global, $config; global $global, $config;
if(!isset($global['systemRootPath'])){ if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/user.php';

View file

@ -11,9 +11,10 @@ header('Content-Type: application/json');
$comments = Comment::getAllComments($_GET['video_id'], @$_POST['comments_id']); $comments = Comment::getAllComments($_GET['video_id'], @$_POST['comments_id']);
$total = Comment::getTotalComments($_GET['video_id'], @$_POST['comments_id']); $total = Comment::getTotalComments($_GET['video_id'], @$_POST['comments_id']);
function fixCommentText($subject){ function fixCommentText($subject)
$search = array('\n'); {
$replace = array("<br/>"); $search = ['\n'];
$replace = ["<br/>"];
return stripslashes(str_replace($search, $replace, $subject)); return stripslashes(str_replace($search, $replace, $subject));
} }

View file

@ -1,6 +1,6 @@
<?php <?php
global $global, $config; global $global, $config;
if(!isset($global['systemRootPath'])){ if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
require_once $global['systemRootPath'] . 'objects/like.php'; require_once $global['systemRootPath'] . 'objects/like.php';
@ -8,11 +8,11 @@ require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/comments_like.php'; require_once $global['systemRootPath'] . 'objects/comments_like.php';
header('Content-Type: application/json'); header('Content-Type: application/json');
if(!empty($_GET['user']) && !empty($_GET['pass'])){ if (!empty($_GET['user']) && !empty($_GET['pass'])) {
$user = new User(0, $_GET['user'], $_GET['pass']); $user = new User(0, $_GET['user'], $_GET['pass']);
$user->login(false, true); $user->login(false, true);
} }
if(empty($_POST['comments_id']) && !empty($_GET['comments_id'])){ if (empty($_POST['comments_id']) && !empty($_GET['comments_id'])) {
$_POST['comments_id'] = $_GET['comments_id']; $_POST['comments_id'] = $_GET['comments_id'];
} }

View file

@ -34,7 +34,7 @@ class CommentsLike
private function setLike($like) private function setLike($like)
{ {
$like = intval($like); $like = intval($like);
if (!in_array($like, array(0,1,-1))) { if (!in_array($like, [0,1,-1])) {
$like = 0; $like = 0;
} }
$this->like = $like; $this->like = $like;
@ -59,7 +59,7 @@ class CommentsLike
die('{"error":"You must have user and videos set to get a like"}'); die('{"error":"You must have user and videos set to get a like"}');
} }
$sql = "SELECT * FROM comments_likes WHERE users_id = ? AND comments_id = ? LIMIT 1"; $sql = "SELECT * FROM comments_likes WHERE users_id = ? AND comments_id = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "ii", array($this->users_id,$this->comments_id)); $res = sqlDAL::readSql($sql, "ii", [$this->users_id,$this->comments_id]);
$result = sqlDAL::fetchAssoc($res); $result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
return ($res) ? $result : false; return ($res) ? $result : false;
@ -72,16 +72,16 @@ class CommentsLike
header('Content-Type: application/json'); header('Content-Type: application/json');
die('{"error":"'.__("Permission denied").'"}'); die('{"error":"'.__("Permission denied").'"}');
} }
$formats = ""; $formats = '';
$values = array(); $values = [];
if (!empty($this->id)) { if (!empty($this->id)) {
$sql = "UPDATE comments_likes SET `like` = ?, modified = now() WHERE id = ?"; $sql = "UPDATE comments_likes SET `like` = ?, modified = now() WHERE id = ?";
$formats = "ii"; $formats = "ii";
$values = array($this->like,$this->id); $values = [$this->like,$this->id];
} else { } else {
$sql = "INSERT INTO comments_likes ( `like`,users_id, comments_id, created, modified) VALUES (?, ?, ?, now(), now())"; $sql = "INSERT INTO comments_likes ( `like`,users_id, comments_id, created, modified) VALUES (?, ?, ?, now(), now())";
$formats = "iii"; $formats = "iii";
$values = array($this->like,$this->users_id,$this->comments_id); $values = [$this->like,$this->users_id,$this->comments_id];
} }
return sqlDAL::writeSql($sql, $formats, $values); return sqlDAL::writeSql($sql, $formats, $values);
} }
@ -97,7 +97,7 @@ class CommentsLike
$obj->myVote = self::getMyVote($comments_id); $obj->myVote = self::getMyVote($comments_id);
$sql = "SELECT count(*) as total FROM comments_likes WHERE comments_id = ? AND `like` = 1 "; // like $sql = "SELECT count(*) as total FROM comments_likes WHERE comments_id = ? AND `like` = 1 "; // like
$res = sqlDAL::readSql($sql, "i", array($comments_id)); $res = sqlDAL::readSql($sql, "i", [$comments_id]);
$result = sqlDAL::fetchAssoc($res); $result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if (!$res) { if (!$res) {
@ -106,7 +106,7 @@ class CommentsLike
$obj->likes = intval($result['total']); $obj->likes = intval($result['total']);
$sql = "SELECT count(*) as total FROM comments_likes WHERE comments_id = ? AND `like` = -1 "; // dislike $sql = "SELECT count(*) as total FROM comments_likes WHERE comments_id = ? AND `like` = -1 "; // dislike
$res = sqlDAL::readSql($sql, "i", array($comments_id)); $res = sqlDAL::readSql($sql, "i", [$comments_id]);
$result = sqlDAL::fetchAssoc($res); $result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if (!$res) { if (!$res) {
@ -152,7 +152,7 @@ class CommentsLike
} }
$id = User::getId(); $id = User::getId();
$sql = "SELECT `like` FROM comments_likes WHERE comments_id = ? AND users_id = ? "; // like $sql = "SELECT `like` FROM comments_likes WHERE comments_id = ? AND users_id = ? "; // like
$res = sqlDAL::readSql($sql, "ii", array($comments_id,$id)); $res = sqlDAL::readSql($sql, "ii", [$comments_id,$id]);
$result = sqlDAL::fetchAssoc($res); $result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if (!empty($result)) { if (!empty($result)) {

View file

@ -1,5 +1,4 @@
<?php <?php
global $global, $config; global $global, $config;
if (!isset($global['systemRootPath'])) { if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
@ -7,8 +6,8 @@ if (!isset($global['systemRootPath'])) {
require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/user.php';
require_once $global['systemRootPath'] . 'objects/functions.php'; require_once $global['systemRootPath'] . 'objects/functions.php';
class Configuration { class Configuration
{
private $id; private $id;
private $video_resolution; private $video_resolution;
private $webSiteTitle; private $webSiteTitle;
@ -43,19 +42,21 @@ class Configuration {
// version 4 // version 4
private $encoderURL; private $encoderURL;
function __construct($video_resolution = "") { public function __construct($video_resolution = "")
{
$this->load(); $this->load();
if (!empty($video_resolution)) { if (!empty($video_resolution)) {
$this->video_resolution = $video_resolution; $this->video_resolution = $video_resolution;
} }
} }
function load() { public function load()
{
global $global; global $global;
$sql = "SELECT * FROM configurations WHERE id = 1 LIMIT 1"; $sql = "SELECT * FROM configurations WHERE id = 1 LIMIT 1";
//echo $sql;exit; //echo $sql;exit;
// add true because I was not getting the SMTP configuration on function setSiteSendMessage(&$mail) // add true because I was not getting the SMTP configuration on function setSiteSendMessage(&$mail)
$res = sqlDAL::readSql($sql, "", array(), true); $res = sqlDAL::readSql($sql, "", [], true);
$result = sqlDAL::fetchAssoc($res); $result = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if ($res && !empty($result)) { if ($res && !empty($result)) {
@ -69,7 +70,8 @@ class Configuration {
} }
} }
function save() { public function save()
{
global $global; global $global;
if (!User::isAdmin()) { if (!User::isAdmin()) {
header('Content-Type: application/json'); header('Content-Type: application/json');
@ -113,98 +115,119 @@ class Configuration {
return sqlDAL::writeSql($sql); return sqlDAL::writeSql($sql);
} }
function getVideo_resolution() { public function getVideo_resolution()
{
return $this->video_resolution; return $this->video_resolution;
} }
function getUsers_id() { public function getUsers_id()
{
return $this->users_id; return $this->users_id;
} }
function getVersion() { public function getVersion()
{
if (empty($this->version)) { if (empty($this->version)) {
return " 0.1"; return " 0.1";
} }
return $this->version; return $this->version;
} }
function getWebSiteTitle() { public function getWebSiteTitle()
{
return $this->webSiteTitle; return $this->webSiteTitle;
} }
function getLanguage() { public function getLanguage()
{
if ($this->language == "en") { if ($this->language == "en") {
return "us"; return "us";
} }
return $this->language; return $this->language;
} }
function getContactEmail() { public function getContactEmail()
{
return $this->contactEmail; return $this->contactEmail;
} }
function setVideo_resolution($video_resolution) { public function setVideo_resolution($video_resolution)
{
$this->video_resolution = $video_resolution; $this->video_resolution = $video_resolution;
} }
function setWebSiteTitle($webSiteTitle) { public function setWebSiteTitle($webSiteTitle)
{
$this->webSiteTitle = $webSiteTitle; $this->webSiteTitle = $webSiteTitle;
} }
function setLanguage($language) { public function setLanguage($language)
{
$this->language = $language; $this->language = $language;
} }
function setContactEmail($contactEmail) { public function setContactEmail($contactEmail)
{
$this->contactEmail = $contactEmail; $this->contactEmail = $contactEmail;
} }
function currentVersionLowerThen($version) { public function currentVersionLowerThen($version)
{
return version_compare($version, $this->getVersion()) > 0; return version_compare($version, $this->getVersion()) > 0;
} }
function currentVersionGreaterThen($version) { public function currentVersionGreaterThen($version)
{
return version_compare($version, $this->getVersion()) < 0; return version_compare($version, $this->getVersion()) < 0;
} }
function currentVersionEqual($version) { public function currentVersionEqual($version)
{
return version_compare($version, $this->getVersion()) == 0; return version_compare($version, $this->getVersion()) == 0;
} }
function getAuthCanUploadVideos() { public function getAuthCanUploadVideos()
{
return $this->authCanUploadVideos; return $this->authCanUploadVideos;
} }
function getAuthCanViewChart() { public function getAuthCanViewChart()
{
return $this->authCanViewChart; return $this->authCanViewChart;
} }
function getAuthCanComment() { public function getAuthCanComment()
{
return $this->authCanComment; return $this->authCanComment;
} }
function setAuthCanUploadVideos($authCanUploadVideos) { public function setAuthCanUploadVideos($authCanUploadVideos)
{
$this->authCanUploadVideos = intval($authCanUploadVideos); $this->authCanUploadVideos = intval($authCanUploadVideos);
} }
function setAuthCanViewChart($authCanViewChart) { public function setAuthCanViewChart($authCanViewChart)
{
$this->authCanViewChart = $authCanViewChart; $this->authCanViewChart = $authCanViewChart;
} }
function setAuthCanComment($authCanComment) { public function setAuthCanComment($authCanComment)
{
$this->authCanComment = $authCanComment; $this->authCanComment = $authCanComment;
} }
function getHead() { public function getHead()
{
return $this->head; return $this->head;
} }
function getLogo($timestamp = false) { public function getLogo($timestamp = false)
{
global $global; global $global;
if (empty($this->logo)) { if (empty($this->logo)) {
return "view/img/logo.png"; return "view/img/logo.png";
} }
$get = ""; $get = '';
$file = str_replace("?", "", $global['systemRootPath'] . $this->logo); $file = str_replace("?", "", $global['systemRootPath'] . $this->logo);
if ($timestamp && file_exists($file)) { if ($timestamp && file_exists($file)) {
$get .= "?" . filemtime($file); $get .= "?" . filemtime($file);
@ -212,7 +235,8 @@ class Configuration {
return $this->logo . $get; return $this->logo . $get;
} }
static function _getFavicon($getPNG = false) { public static function _getFavicon($getPNG = false)
{
global $global; global $global;
$file = false; $file = false;
$url = false; $url = false;
@ -232,10 +256,11 @@ class Configuration {
$url = getCDN()."view/img/favicon.png"; $url = getCDN()."view/img/favicon.png";
} }
} }
return array('file' => $file, 'url' => $url); return ['file' => $file, 'url' => $url];
} }
function getFavicon($getPNG = false, $getTime = true) { public function getFavicon($getPNG = false, $getTime = true)
{
$return = self::_getFavicon($getPNG); $return = self::_getFavicon($getPNG);
if ($getTime) { if ($getTime) {
return $return['url'] . "?" . filemtime($return['file']); return $return['url'] . "?" . filemtime($return['file']);
@ -244,98 +269,118 @@ class Configuration {
} }
} }
static function getOGImage() { public static function getOGImage()
{
global $global; global $global;
$destination = Video::getStoragePath()."cache/og_200X200.jpg"; $destination = Video::getStoragePath()."cache/og_200X200.jpg";
$return = self::_getFavicon(true); $return = self::_getFavicon(true);
if(file_exists($return['file'])){ if (file_exists($return['file'])) {
convertImageToOG($return['file'], $destination); convertImageToOG($return['file'], $destination);
} }
return getCDN() . "videos/cache/og_200X200.jpg"; return getCDN() . "videos/cache/og_200X200.jpg";
} }
function setHead($head) { public function setHead($head)
{
$this->head = $head; $this->head = $head;
} }
function setLogo($logo) { public function setLogo($logo)
{
$this->logo = $logo; $this->logo = $logo;
} }
function getLogo_small() { public function getLogo_small()
{
if (empty($this->logo_small)) { if (empty($this->logo_small)) {
return "view/img/logo32.png"; return "view/img/logo32.png";
} }
return $this->logo_small; return $this->logo_small;
} }
function setLogo_small($logo_small) { public function setLogo_small($logo_small)
{
$this->logo_small = $logo_small; $this->logo_small = $logo_small;
} }
function getAdsense() { public function getAdsense()
{
return $this->adsense; return $this->adsense;
} }
function setAdsense($adsense) { public function setAdsense($adsense)
{
$this->adsense = $adsense; $this->adsense = $adsense;
} }
function getMode() { public function getMode()
{
if (empty($this->mode)) { if (empty($this->mode)) {
return 'Youtube'; return 'Youtube';
} }
return $this->mode; return $this->mode;
} }
function setMode($mode) { public function setMode($mode)
{
$this->mode = $mode; $this->mode = $mode;
} }
// version 2.7 // version 2.7
function getDisable_analytics() { public function getDisable_analytics()
{
return $this->disable_analytics; return $this->disable_analytics;
} }
function getDisable_youtubeupload() { public function getDisable_youtubeupload()
{
return $this->disable_youtubeupload; return $this->disable_youtubeupload;
} }
function getAllow_download() { public function getAllow_download()
{
return $this->allow_download; return $this->allow_download;
} }
function getSession_timeout() { public function getSession_timeout()
{
return $this->session_timeout; return $this->session_timeout;
} }
function setDisable_analytics($disable_analytics) { public function setDisable_analytics($disable_analytics)
{
$this->disable_analytics = ($disable_analytics == 'true' || $disable_analytics == '1') ? 1 : 0; $this->disable_analytics = ($disable_analytics == 'true' || $disable_analytics == '1') ? 1 : 0;
} }
function setDisable_youtubeupload($disable_youtubeupload) { public function setDisable_youtubeupload($disable_youtubeupload)
{
$this->disable_youtubeupload = ($disable_youtubeupload == 'true' || $disable_youtubeupload == '1') ? 1 : 0; $this->disable_youtubeupload = ($disable_youtubeupload == 'true' || $disable_youtubeupload == '1') ? 1 : 0;
} }
function setAllow_download($allow_download) { public function setAllow_download($allow_download)
{
$this->allow_download = ($allow_download == 'true' || $allow_download == '1') ? 1 : 0; $this->allow_download = ($allow_download == 'true' || $allow_download == '1') ? 1 : 0;
} }
function setSession_timeout($session_timeout) { public function setSession_timeout($session_timeout)
{
$this->session_timeout = $session_timeout; $this->session_timeout = $session_timeout;
} }
function getAutoplay() { public function getAutoplay()
{
return intval($this->autoplay); return intval($this->autoplay);
} }
function setAutoplay($autoplay) { public function setAutoplay($autoplay)
{
$this->autoplay = ($autoplay == 'true' || $autoplay == '1') ? 1 : 0; $this->autoplay = ($autoplay == 'true' || $autoplay == '1') ? 1 : 0;
} }
// end version 2.7 // end version 2.7
static function rewriteConfigFile() { public static function rewriteConfigFile()
{
global $global, $mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase; global $global, $mysqlHost, $mysqlUser, $mysqlPass, $mysqlDatabase;
if (empty($global['salt'])) { if (empty($global['salt'])) {
$global['salt'] = uniqid(); $global['salt'] = uniqid();
@ -395,89 +440,107 @@ require_once \$global['systemRootPath'].'objects/include_config.php';
fclose($fp); fclose($fp);
} }
function getTheme() { public function getTheme()
{
if (empty($this->theme)) { if (empty($this->theme)) {
return "default"; return "default";
} }
return $this->theme; return $this->theme;
} }
function setTheme($theme) { public function setTheme($theme)
{
$this->theme = $theme; $this->theme = $theme;
} }
function getSmtp() { public function getSmtp()
{
return intval($this->smtp); return intval($this->smtp);
} }
function getSmtpAuth() { public function getSmtpAuth()
{
return intval($this->smtpAuth); return intval($this->smtpAuth);
} }
function getSmtpSecure() { public function getSmtpSecure()
{
return $this->smtpSecure; return $this->smtpSecure;
} }
function getSmtpHost() { public function getSmtpHost()
{
return $this->smtpHost; return $this->smtpHost;
} }
function getSmtpUsername() { public function getSmtpUsername()
{
return $this->smtpUsername; return $this->smtpUsername;
} }
function getSmtpPassword() { public function getSmtpPassword()
{
return $this->smtpPassword; return $this->smtpPassword;
} }
function setSmtp($smtp) { public function setSmtp($smtp)
{
$this->smtp = ($smtp == 'true' || $smtp == '1') ? 1 : 0; $this->smtp = ($smtp == 'true' || $smtp == '1') ? 1 : 0;
} }
function setSmtpAuth($smtpAuth) { public function setSmtpAuth($smtpAuth)
{
$this->smtpAuth = ($smtpAuth == 'true' || $smtpAuth == '1') ? 1 : 0; $this->smtpAuth = ($smtpAuth == 'true' || $smtpAuth == '1') ? 1 : 0;
} }
function setSmtpSecure($smtpSecure) { public function setSmtpSecure($smtpSecure)
{
$this->smtpSecure = $smtpSecure; $this->smtpSecure = $smtpSecure;
} }
function setSmtpHost($smtpHost) { public function setSmtpHost($smtpHost)
{
$this->smtpHost = $smtpHost; $this->smtpHost = $smtpHost;
} }
function setSmtpUsername($smtpUsername) { public function setSmtpUsername($smtpUsername)
{
$this->smtpUsername = $smtpUsername; $this->smtpUsername = $smtpUsername;
} }
function setSmtpPassword($smtpPassword) { public function setSmtpPassword($smtpPassword)
{
$this->smtpPassword = $smtpPassword; $this->smtpPassword = $smtpPassword;
} }
function getSmtpPort() { public function getSmtpPort()
{
return intval($this->smtpPort); return intval($this->smtpPort);
} }
function setSmtpPort($smtpPort) { public function setSmtpPort($smtpPort)
{
$this->smtpPort = intval($smtpPort); $this->smtpPort = intval($smtpPort);
} }
function _getEncoderURL() { public function _getEncoderURL()
{
if (substr($this->encoderURL, -1) !== '/') { if (substr($this->encoderURL, -1) !== '/') {
$this->encoderURL .= "/"; $this->encoderURL .= "/";
} }
return $this->encoderURL; return $this->encoderURL;
} }
function shouldUseEncodernetwork(){ public function shouldUseEncodernetwork()
{
global $advancedCustom, $global; global $advancedCustom, $global;
if(empty($advancedCustom->useEncoderNetworkRecomendation) || empty($advancedCustom->encoderNetwork)){ if (empty($advancedCustom->useEncoderNetworkRecomendation) || empty($advancedCustom->encoderNetwork)) {
return false; return false;
} }
if($advancedCustom->encoderNetwork === 'https://network.avideo.com/'){ if ($advancedCustom->encoderNetwork === 'https://network.avideo.com/') {
// check if you have your own encoder // check if you have your own encoder
$encoderConfigFile = "{$global['systemRootPath']}Encoder/videos/configuration.php"; $encoderConfigFile = "{$global['systemRootPath']}Encoder/videos/configuration.php";
if(file_exists($encoderConfigFile)){ // you have an encoder do not use the public one if (file_exists($encoderConfigFile)) { // you have an encoder do not use the public one
_error_log("Configuration:shouldUseEncodernetwork 1 You checked the Encoder Network but you have your own encoder, we will ignore this option"); _error_log("Configuration:shouldUseEncodernetwork 1 You checked the Encoder Network but you have your own encoder, we will ignore this option");
return false; return false;
} }
@ -486,9 +549,9 @@ require_once \$global['systemRootPath'].'objects/include_config.php';
$this->encoderURL .= "/"; $this->encoderURL .= "/";
} }
if(!preg_match('/encoder[1-9].avideo.com/i', $this->encoderURL)){ if (!preg_match('/encoder[1-9].avideo.com/i', $this->encoderURL)) {
$creatingImages = "{$this->encoderURL}view/img/creatingImages.jpg"; $creatingImages = "{$this->encoderURL}view/img/creatingImages.jpg";
if(isURL200($creatingImages)){ if (isURL200($creatingImages)) {
_error_log("Configuration:shouldUseEncodernetwork 2 You checked the Encoder Network but you have your own encoder, we will ignore this option"); _error_log("Configuration:shouldUseEncodernetwork 2 You checked the Encoder Network but you have your own encoder, we will ignore this option");
return false; return false;
} }
@ -497,7 +560,8 @@ require_once \$global['systemRootPath'].'objects/include_config.php';
return true; return true;
} }
static function deleteEncoderURLCache(){ public static function deleteEncoderURLCache()
{
_error_log_debug("Configuration::deleteEncoderURLCache"); _error_log_debug("Configuration::deleteEncoderURLCache");
$name = "getEncoderURL" . DIRECTORY_SEPARATOR; $name = "getEncoderURL" . DIRECTORY_SEPARATOR;
$tmpDir = ObjectYPT::getCacheDir(); $tmpDir = ObjectYPT::getCacheDir();
@ -506,9 +570,10 @@ require_once \$global['systemRootPath'].'objects/include_config.php';
rrmdir($cacheDir); rrmdir($cacheDir);
} }
function getEncoderURL() { public function getEncoderURL()
{
global $global, $getEncoderURL, $advancedCustom; global $global, $getEncoderURL, $advancedCustom;
if(!empty($global['forceEncoderURL'])){ if (!empty($global['forceEncoderURL'])) {
return $global['forceEncoderURL']; return $global['forceEncoderURL'];
} }
if (empty($getEncoderURL)) { if (empty($getEncoderURL)) {
@ -524,7 +589,7 @@ require_once \$global['systemRootPath'].'objects/include_config.php';
} else { } else {
error_log("Configuration::getEncoderURL ERROR your network ($advancedCustom->encoderNetwork) is not configured properly This slow down your site a lot, disable the option useEncoderNetworkRecomendation in your CustomizeAdvanced plugin"); error_log("Configuration::getEncoderURL ERROR your network ($advancedCustom->encoderNetwork) is not configured properly This slow down your site a lot, disable the option useEncoderNetworkRecomendation in your CustomizeAdvanced plugin");
} }
}else{ } else {
//error_log("Configuration::getEncoderURL shouldUseEncodernetwork said no"); //error_log("Configuration::getEncoderURL shouldUseEncodernetwork said no");
} }
@ -534,22 +599,23 @@ require_once \$global['systemRootPath'].'objects/include_config.php';
addLastSlash($this->encoderURL); addLastSlash($this->encoderURL);
$getEncoderURL = $this->encoderURL; $getEncoderURL = $this->encoderURL;
ObjectYPT::setCache("getEncoderURL", $getEncoderURL); ObjectYPT::setCache("getEncoderURL", $getEncoderURL);
}else{ } else {
//error_log("Configuration::getEncoderURL got it from cache ". json_encode($getEncoderURL)); //error_log("Configuration::getEncoderURL got it from cache ". json_encode($getEncoderURL));
} }
} }
return $getEncoderURL; return $getEncoderURL;
} }
function setEncoderURL($encoderURL) { public function setEncoderURL($encoderURL)
{
$this->encoderURL = $encoderURL; $this->encoderURL = $encoderURL;
} }
function getPageTitleSeparator() { public function getPageTitleSeparator()
if(!defined('PAGE_TITLE_SEPARATOR')){ {
if (!defined('PAGE_TITLE_SEPARATOR')) {
define("PAGE_TITLE_SEPARATOR", "&middot;"); // This is ready to be configurable, if needed define("PAGE_TITLE_SEPARATOR", "&middot;"); // This is ready to be configurable, if needed
} }
return " " . PAGE_TITLE_SEPARATOR . " "; return " " . PAGE_TITLE_SEPARATOR . " ";
} }
} }

View file

@ -1,13 +1,13 @@
<?php <?php
header('Content-Type: application/json'); header('Content-Type: application/json');
global $global, $config; global $global, $config;
if(!isset($global['systemRootPath'])){ if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
$obj = new stdClass(); $obj = new stdClass();
$obj->error = true; $obj->error = true;
$obj->msg = ""; $obj->msg = '';
$obj->clearCache = false; $obj->clearCache = false;
$obj->deleteALLCache = false; $obj->deleteALLCache = false;
$obj->deleteAllSessionCache = false; $obj->deleteAllSessionCache = false;
@ -15,10 +15,10 @@ $_SESSION['user']['sessionCache']['getAllCategoriesClearCache'] = 1;
if (!Permissions::canClearCache() || !empty($_REQUEST['sessionOnly'])) { if (!Permissions::canClearCache() || !empty($_REQUEST['sessionOnly'])) {
$obj->deleteAllSessionCache = ObjectYPT::deleteAllSessionCache(); $obj->deleteAllSessionCache = ObjectYPT::deleteAllSessionCache();
}else{ } else {
if(!empty($_REQUEST['FirstPage'])){ if (!empty($_REQUEST['FirstPage'])) {
$obj->firstPageCache = clearCache(true); $obj->firstPageCache = clearCache(true);
}else{ } else {
$obj->clearCache = clearCache(); $obj->clearCache = clearCache();
$obj->deleteALLCache = ObjectYPT::deleteALLCache(); $obj->deleteALLCache = ObjectYPT::deleteALLCache();
} }

View file

@ -1,5 +1,4 @@
<?php <?php
//header("Content-type: text/xml"); //header("Content-type: text/xml");
header('Content-Type: application/json'); header('Content-Type: application/json');
global $global, $config; global $global, $config;
@ -11,7 +10,7 @@ require_once $global['systemRootPath'] . 'objects/category.php';
$obj = new stdClass(); $obj = new stdClass();
$obj->error = true; $obj->error = true;
$obj->msg = ""; $obj->msg = '';
if (!Permissions::canGenerateSiteMap()) { if (!Permissions::canGenerateSiteMap()) {
$obj->msg = __("Permission denied"); $obj->msg = __("Permission denied");
@ -19,7 +18,7 @@ if (!Permissions::canGenerateSiteMap()) {
} }
$sitemap = siteMap(); $sitemap = siteMap();
if(empty($sitemap)){ if (empty($sitemap)) {
$obj->msg = "Sitemap content is empty"; $obj->msg = "Sitemap content is empty";
die(json_encode($obj)); die(json_encode($obj));
} }

View file

@ -60,24 +60,24 @@ if (!is_writable($global['systemRootPath'] . $imagePath)) {
} }
* *
*/ */
$response = array(); $response = [];
if (!empty($_POST['logoImgBase64'])) { if (!empty($_POST['logoImgBase64'])) {
$fileData = base64DataToImage($_POST['logoImgBase64']); $fileData = base64DataToImage($_POST['logoImgBase64']);
$fileName = 'logo.png'; $fileName = 'logo.png';
$photoURL = $imagePath . $fileName; $photoURL = $imagePath . $fileName;
$bytes = file_put_contents($global['systemRootPath'] . $photoURL, $fileData); $bytes = file_put_contents($global['systemRootPath'] . $photoURL, $fileData);
if ($bytes > 10) { if ($bytes > 10) {
$response = array( $response = [
"status" => 'success', "status" => 'success',
"url" => $global['systemRootPath'] . $photoURL "url" => $global['systemRootPath'] . $photoURL,
); ];
$config->setLogo($photoURL); $config->setLogo($photoURL);
} else { } else {
$response = array( $response = [
"status" => 'error', "status" => 'error',
"msg" => 'We could not save logo', "msg" => 'We could not save logo',
"url" => $global['systemRootPath'] . $photoURL "url" => $global['systemRootPath'] . $photoURL,
); ];
} }
} }
if (!empty($_POST['faviconBase64'])) { if (!empty($_POST['faviconBase64'])) {
@ -87,27 +87,27 @@ if (!empty($_POST['faviconBase64'])) {
$photoURL = $imagePath . $fileName; $photoURL = $imagePath . $fileName;
$bytes = file_put_contents($global['systemRootPath'] . $photoURL, $fileData); $bytes = file_put_contents($global['systemRootPath'] . $photoURL, $fileData);
if ($bytes > 10) { if ($bytes > 10) {
$response2 = array( $response2 = [
"status" => 'success', "status" => 'success',
"url" => $global['systemRootPath'] . $photoURL "url" => $global['systemRootPath'] . $photoURL,
); ];
$sizes = array( $sizes = [
array(16, 16), [16, 16],
array(24, 24), [24, 24],
array(32, 32), [32, 32],
array(48, 48), [48, 48],
array(144, 144) [144, 144],
); ];
$ico_lib = new PHP_ICO($global['systemRootPath'] . $photoURL, $sizes); $ico_lib = new PHP_ICO($global['systemRootPath'] . $photoURL, $sizes);
$ico_lib->save_ico($global['systemRootPath'] . $imagePath.'favicon.ico'); $ico_lib->save_ico($global['systemRootPath'] . $imagePath.'favicon.ico');
} else { } else {
$response2 = array( $response2 = [
"status" => 'error', "status" => 'error',
"msg" => 'We could not save favicon', "msg" => 'We could not save favicon',
"url" => $global['systemRootPath'] . $photoURL "url" => $global['systemRootPath'] . $photoURL,
); ];
} }
} }

View file

@ -18,13 +18,13 @@ if (empty($_POST['email'])) {
$users = User::getAllUsersFromUsergroup( $users = User::getAllUsersFromUsergroup(
$_REQUEST['users_groups_id'], $_REQUEST['users_groups_id'],
false, false,
array('name', 'email', 'user', 'channelName', 'about'), ['name', 'email', 'user', 'channelName', 'about'],
'a' 'a'
); );
} else { } else {
$users = User::getAllUsers( $users = User::getAllUsers(
false, false,
array('name', 'email', 'user', 'channelName', 'about'), ['name', 'email', 'user', 'channelName', 'about'],
'a' 'a'
); );
} }
@ -36,9 +36,9 @@ $mailsLimit = 100;
$obj = new stdClass(); $obj = new stdClass();
$obj->error = false; $obj->error = false;
$obj->msg = array(); $obj->msg = [];
//Create a new PHPMailer instance //Create a new PHPMailer instance
$mail = new \PHPMailer\PHPMailer\PHPMailer; $mail = new \PHPMailer\PHPMailer\PHPMailer();
setSiteSendMessage($mail); setSiteSendMessage($mail);
//Set who the message is to be sent from //Set who the message is to be sent from
$mail->setFrom($config->getContactEmail()); $mail->setFrom($config->getContactEmail());

View file

@ -1,7 +1,7 @@
<?php <?php
global $advancedCustom; global $advancedCustom;
$global['doNotLoadPlayer'] = 1; $global['doNotLoadPlayer'] = 1;
if(!is_numeric($toTime)){ if (!is_numeric($toTime)) {
$toTime = strtotime($toTime); $toTime = strtotime($toTime);
} }
//$toTime = strtotime('+10 seconds'); //$toTime = strtotime('+10 seconds');

View file

@ -23,7 +23,7 @@ if (($video['type'] !== "audio") && ($video['type'] !== "linkAudio") && !empty($
$data = getimgsize($source['path']); $data = getimgsize($source['path']);
$imgw = $data[0]; $imgw = $data[0];
$imgh = $data[1]; $imgh = $data[1];
} else if ($video['type'] == "audio") { } elseif ($video['type'] == "audio") {
$img = getCDN()."view/img/audio_wave.jpg"; $img = getCDN()."view/img/audio_wave.jpg";
} }
$type = 'video'; $type = 'video';
@ -43,8 +43,8 @@ if (!empty($images->posterPortrait) && basename($images->posterPortrait) !== 'no
$img = $images->poster; $img = $images->poster;
} }
$twitter_site = $advancedCustom->twitter_site; $twitter_site = $advancedCustom->twitter_site;
$title = _substr(html2plainText($video['title']), 0,55); $title = _substr(html2plainText($video['title']), 0, 55);
$description = _substr(html2plainText($video['description']), 0,155); $description = _substr(html2plainText($video['description']), 0, 155);
$ogURL = Video::getLinkToVideo($videos_id); $ogURL = Video::getLinkToVideo($videos_id);
?> ?>
<link rel="image_src" href="<?php echo $img; ?>" /> <link rel="image_src" href="<?php echo $img; ?>" />
@ -63,14 +63,14 @@ $ogURL = Video::getLinkToVideo($videos_id);
<?php <?php
$source = Video::getHigestResolution($video['filename']); $source = Video::getHigestResolution($video['filename']);
if(empty($source['url'])){ if (empty($source['url'])) {
if(CustomizeUser::canDownloadVideos()){ if (CustomizeUser::canDownloadVideos()) {
echo "<!-- you cannot download videos we will not share the video source file -->"; echo "<!-- you cannot download videos we will not share the video source file -->";
} }
if(empty($source['url'])){ if (empty($source['url'])) {
echo "<!-- we could not get the MP4 source file -->"; echo "<!-- we could not get the MP4 source file -->";
} }
}else{ } else {
$source['url'] = str_replace(".m3u8", ".m3u8.mp4", $source['url']); $source['url'] = str_replace(".m3u8", ".m3u8.mp4", $source['url']);
} }
if (!AVideoPlugin::isEnabledByName("SecureVideosDirectory") && !empty($source['url'])) { if (!AVideoPlugin::isEnabledByName("SecureVideosDirectory") && !empty($source['url'])) {
@ -82,18 +82,16 @@ if (!AVideoPlugin::isEnabledByName("SecureVideosDirectory") && !empty($source['u
<meta property="og:video:height" content="<?php echo $imgh; ?>" /> <meta property="og:video:height" content="<?php echo $imgh; ?>" />
<?php <?php
} else { } else {
if(AVideoPlugin::isEnabledByName("SecureVideosDirectory")){ if (AVideoPlugin::isEnabledByName("SecureVideosDirectory")) {
echo "<!-- SecureVideosDirectory plugin is enabled we will not share the video source file -->"; echo "<!-- SecureVideosDirectory plugin is enabled we will not share the video source file -->";
} }
if(empty($source['url'])){ if (empty($source['url'])) {
echo "<!-- we could not get the source file -->"; echo "<!-- we could not get the source file -->";
} } ?>
?>
<meta property="og:video" content="<?php echo Video::getLinkToVideo($videos_id); ?>" /> <meta property="og:video" content="<?php echo Video::getLinkToVideo($videos_id); ?>" />
<meta property="og:video:secure_url" content="<?php echo Video::getLinkToVideo($videos_id); ?>" /> <meta property="og:video:secure_url" content="<?php echo Video::getLinkToVideo($videos_id); ?>" />
<?php <?php
} }
?> ?>
<meta property="video:duration" content="<?php echo Video::getItemDurationSeconds($video['duration']); ?>" /> <meta property="video:duration" content="<?php echo Video::getItemDurationSeconds($video['duration']); ?>" />
<meta property="duration" content="<?php echo Video::getItemDurationSeconds($video['duration']); ?>" /> <meta property="duration" content="<?php echo Video::getItemDurationSeconds($video['duration']); ?>" />
@ -102,7 +100,7 @@ if (!AVideoPlugin::isEnabledByName("SecureVideosDirectory") && !empty($source['u
<?php <?php
if (!empty($advancedCustom->twitter_player)) { if (!empty($advancedCustom->twitter_player)) {
if (!AVideoPlugin::isEnabledByName("SecureVideosDirectory") && !empty($source['url'])) { if (!AVideoPlugin::isEnabledByName("SecureVideosDirectory") && !empty($source['url'])) {
?> ?>
<meta name="twitter:card" content="player" /> <meta name="twitter:card" content="player" />
<meta name="twitter:player" content=<?php echo Video::getLinkToVideo($videos_id, $video['clean_title'], true); ?>" /> <meta name="twitter:player" content=<?php echo Video::getLinkToVideo($videos_id, $video['clean_title'], true); ?>" />
<meta name="twitter:player:width" content="<?php echo $imgw; ?>" /> <meta name="twitter:player:width" content="<?php echo $imgw; ?>" />
@ -110,14 +108,14 @@ if (!empty($advancedCustom->twitter_player)) {
<meta name="twitter:player:stream" content="<?php echo $source['url']; ?>" /> <meta name="twitter:player:stream" content="<?php echo $source['url']; ?>" />
<meta name="twitter:player:stream:content_type" content="video/mp4" /> <meta name="twitter:player:stream:content_type" content="video/mp4" />
<?php <?php
} else { } else {
?> ?>
<meta name="twitter:card" content="player" /> <meta name="twitter:card" content="player" />
<meta name="twitter:player" content="<?php echo Video::getLinkToVideo($videos_id, $video['clean_title'], true); ?>" /> <meta name="twitter:player" content="<?php echo Video::getLinkToVideo($videos_id, $video['clean_title'], true); ?>" />
<meta name="twitter:player:width" content="480" /> <meta name="twitter:player:width" content="480" />
<meta name="twitter:player:height" content="480" /> <meta name="twitter:player:height" content="480" />
<?php <?php
} }
} else { } else {
if (!empty($advancedCustom->twitter_summary_large_image)) { if (!empty($advancedCustom->twitter_summary_large_image)) {
?> ?>

View file

@ -1,7 +1,7 @@
<?php <?php
$objSecure = AVideoPlugin::getObjectDataIfEnabled('SecureVideosDirectory'); $objSecure = AVideoPlugin::getObjectDataIfEnabled('SecureVideosDirectory');
$search = array('{permaLink}','{imgSRC}','{title}', '{embedURL}', '{videoLengthInSeconds}'); $search = ['{permaLink}','{imgSRC}','{title}', '{embedURL}', '{videoLengthInSeconds}'];
$replace = array($permaLink,$img,$title, $embedURL, $videoLengthInSeconds); $replace = [$permaLink,$img,$title, $embedURL, $videoLengthInSeconds];
?> ?>
<div class="<?php echo $class; ?>" id="shareDiv"> <div class="<?php echo $class; ?>" id="shareDiv">
<div class="tabbable-panel"> <div class="tabbable-panel">
@ -86,8 +86,7 @@ $replace = array($permaLink,$img,$title, $embedURL, $videoLengthInSeconds);
</div> </div>
<?php <?php
if (empty($advancedCustom->disableEmailSharing)) { if (empty($advancedCustom->disableEmailSharing)) {
$loaderSequenceName = uniqid(); $loaderSequenceName = uniqid(); ?>
?>
<div class="tab-pane" id="tabEmail"> <div class="tab-pane" id="tabEmail">
<?php if (!User::isLogged()) { ?> <?php if (!User::isLogged()) { ?>
<strong> <strong>
@ -171,26 +170,22 @@ $replace = array($permaLink,$img,$title, $embedURL, $videoLengthInSeconds);
<?php <?php
} }
if (!empty($permaLink) && $permaLink !== $URLFriendly) { if (!empty($permaLink) && $permaLink !== $URLFriendly) {
$loaderSequenceName = uniqid(); $loaderSequenceName = uniqid(); ?>
?>
<div class="tab-pane" id="tabPermaLink"> <div class="tab-pane" id="tabPermaLink">
<div class="form-group <?php echo getCSSAnimationClassAndStyle($type, $loaderSequenceName); ?>"> <div class="form-group <?php echo getCSSAnimationClassAndStyle($type, $loaderSequenceName); ?>">
<label class="control-label"><?php echo __("Permanent Link") ?></label> <label class="control-label"><?php echo __("Permanent Link") ?></label>
<?php <?php
getInputCopyToClipboard('linkPermanent', $permaLink); getInputCopyToClipboard('linkPermanent', $permaLink); ?>
?>
</div> </div>
<div class="form-group <?php echo getCSSAnimationClassAndStyle($type, $loaderSequenceName); ?>"> <div class="form-group <?php echo getCSSAnimationClassAndStyle($type, $loaderSequenceName); ?>">
<label class="control-label"><?php echo __("URL Friendly") ?> (SEO)</label> <label class="control-label"><?php echo __("URL Friendly") ?> (SEO)</label>
<?php <?php
getInputCopyToClipboard('linkFriendly', $URLFriendly); getInputCopyToClipboard('linkFriendly', $URLFriendly); ?>
?>
</div> </div>
<div class="form-group <?php echo getCSSAnimationClassAndStyle($type, $loaderSequenceName); ?>"> <div class="form-group <?php echo getCSSAnimationClassAndStyle($type, $loaderSequenceName); ?>">
<label class="control-label"><?php echo __("Current Time") ?> (SEO)</label> <label class="control-label"><?php echo __("Current Time") ?> (SEO)</label>
<?php <?php
getInputCopyToClipboard('linkCurrentTime', $URLFriendly); getInputCopyToClipboard('linkCurrentTime', $URLFriendly); ?>
?>
</div> </div>
</div> </div>
<?php <?php

View file

@ -7,50 +7,46 @@ if ($users_id = isChannel()) {
$imgh = 200; $imgh = 200;
$img = User::getOGImage($users_id); $img = User::getOGImage($users_id);
$title = User::getNameIdentificationById($users_id); $title = User::getNameIdentificationById($users_id);
$url = User::getChannelLink($users_id); $url = User::getChannelLink($users_id); ?>
?>
<meta property="og:type" content="profile" /> <meta property="og:type" content="profile" />
<meta property="profile:username" content="<?php echo $title; ?>" /> <meta property="profile:username" content="<?php echo $title; ?>" />
<?php <?php
} else if (!empty($_GET['catName'])) { } elseif (!empty($_GET['catName'])) {
$imgw = 200; $imgw = 200;
$imgh = 200; $imgh = 200;
$category = Category::getCategoryByName($_GET['catName']); $category = Category::getCategoryByName($_GET['catName']);
$img = Category::getOGImage($category['id']); $img = Category::getOGImage($category['id']);
$title = html2plainText($category['name']); $title = html2plainText($category['name']);
$url = Category::getCategoryLinkFromName($_GET['catName']); $url = Category::getCategoryLinkFromName($_GET['catName']);
echo PHP_EOL."<!-- OpenGraph not video -->".PHP_EOL; echo PHP_EOL."<!-- OpenGraph not video -->".PHP_EOL; ?>
?>
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="og:site_name" content="<?php echo $title; ?>"> <meta property="og:site_name" content="<?php echo $title; ?>">
<?php <?php
} else if (!isVideo() && empty($videos_id)) { } elseif (!isVideo() && empty($videos_id)) {
$imgw = 200; $imgw = 200;
$imgh = 200; $imgh = 200;
$img = Configuration::getOGImage(); $img = Configuration::getOGImage();
$title = html2plainText($config->getWebSiteTitle()); $title = html2plainText($config->getWebSiteTitle());
$url = $global['webSiteRootURL']; $url = $global['webSiteRootURL'];
echo PHP_EOL."<!-- OpenGraph not video -->".PHP_EOL; echo PHP_EOL."<!-- OpenGraph not video -->".PHP_EOL; ?>
?>
<meta property="og:type" content="website" /> <meta property="og:type" content="website" />
<meta property="og:site_name" content="<?php echo $title; ?>"> <meta property="og:site_name" content="<?php echo $title; ?>">
<?php <?php
} else { } else {
return false; return false;
} }
if(empty($customizePluginDescription)){ if (empty($customizePluginDescription)) {
if(AVideoPlugin::isEnabledByName('Customize')){ if (AVideoPlugin::isEnabledByName('Customize')) {
$ec = new ExtraConfig(); $ec = new ExtraConfig();
$customizePluginDescription = $ec->getDescription(); $customizePluginDescription = $ec->getDescription();
} }
} }
$description = $title; $description = $title;
if(!empty($customizePluginDescription)){ if (!empty($customizePluginDescription)) {
$description = $customizePluginDescription; $description = $customizePluginDescription;
}else } elseif (!empty($metaDescription)) {
if(!empty($metaDescription)){
$description = $metaDescription; $description = $metaDescription;
} }
@ -75,10 +71,10 @@ if (!empty($advancedCustom->twitter_summary_large_image)) {
<meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:card" content="summary_large_image" />
<?php <?php
} else { } else {
?> ?>
<meta name="twitter:card" content="summary" /> <meta name="twitter:card" content="summary" />
<?php <?php
} }
?> ?>
<meta name="twitter:url" content="<?php echo $global['webSiteRootURL']; ?>"/> <meta name="twitter:url" content="<?php echo $global['webSiteRootURL']; ?>"/>
<meta name="twitter:title" content="<?php echo $title; ?>"/> <meta name="twitter:title" content="<?php echo $title; ?>"/>

File diff suppressed because it is too large Load diff

View file

@ -2,13 +2,11 @@
if (empty($advancedCustom->disableHTMLDescription)) { if (empty($advancedCustom->disableHTMLDescription)) {
global $tinyMCELibs; global $tinyMCELibs;
if (empty($tinyMCELibs)) { if (empty($tinyMCELibs)) {
$tinyMCELibs = 1; $tinyMCELibs = 1; ?>
?>
<script type="text/javascript" src="<?php echo getURL('node_modules/tinymce/tinymce.min.js'); ?>"></script> <script type="text/javascript" src="<?php echo getURL('node_modules/tinymce/tinymce.min.js'); ?>"></script>
<style>.tox-statusbar__branding{display:none !important;}</style> <style>.tox-statusbar__branding{display:none !important;}</style>
<?php <?php
} } ?>
?>
<script> <script>
<?php <?php
if ($simpleMode) { if ($simpleMode) {
@ -61,8 +59,7 @@ if (empty($advancedCustom->disableHTMLDescription)) {
var tinyMCEtoolbar = 'fullscreen | formatselect | bold italic strikethrough | link image media pageembed | numlist bullist | removeformat | addcomment'; var tinyMCEtoolbar = 'fullscreen | formatselect | bold italic strikethrough | link image media pageembed | numlist bullist | removeformat | addcomment';
var tinyMCEmenubar = 'edit insert view format table tools help'; var tinyMCEmenubar = 'edit insert view format table tools help';
<?php <?php
} } ?>
?>
tinymce.init({ tinymce.init({
language: "<?php echo ($_SESSION['language'] == 'en_US') ? 'us' : $_SESSION['language']; ?>", language: "<?php echo ($_SESSION['language'] == 'en_US') ? 'us' : $_SESSION['language']; ?>",
language_url: '<?php echo getURL('node_modules/tinymce-langs/langs/' . (($_SESSION['language'] == 'en_US') ? 'us' : $_SESSION['language']) . '.js'); ?>', language_url: '<?php echo getURL('node_modules/tinymce-langs/langs/' . (($_SESSION['language'] == 'en_US') ? 'us' : $_SESSION['language']) . '.js'); ?>',

View file

@ -1,20 +1,19 @@
<?php <?php
global $global, $config; global $global, $config;
if (!isset($global['systemRootPath'])) { if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
if(!User::isAdmin()){ if (!User::isAdmin()) {
die("Admin only"); die("Admin only");
} }
$users = array(); $users = [];
$sql = "SELECT id, user, name, email, status, created, isAdmin FROM users"; $sql = "SELECT id, user, name, email, status, created, isAdmin FROM users";
if ($result = $global['mysqli']->query($sql)) { if ($result = $global['mysqli']->query($sql)) {
while ($p = $result->fetch_assoc()) { while ($p = $result->fetch_assoc()) {
$groups = UserGroups::getUserGroups($p['id']); $groups = UserGroups::getUserGroups($p['id']);
$groupsName = array(); $groupsName = [];
foreach ($groups as $value) { foreach ($groups as $value) {
$groupsName[] = $value['group_name']; $groupsName[] = $value['group_name'];
} }
@ -25,7 +24,7 @@ if ($result = $global['mysqli']->query($sql)) {
$output = fopen("php://output", 'w') or die("Can't open php://output"); $output = fopen("php://output", 'w') or die("Can't open php://output");
header("Content-Type:application/csv"); header("Content-Type:application/csv");
header("Content-Disposition:attachment;filename=email.csv"); header("Content-Disposition:attachment;filename=email.csv");
fputcsv($output, array('id', 'user', 'name', 'email', 'status', 'created', 'isAdmin', 'Groups')); fputcsv($output, ['id', 'user', 'name', 'email', 'status', 'created', 'isAdmin', 'Groups']);
foreach ($users as $user) { foreach ($users as $user) {
fputcsv($output, $user); fputcsv($output, $user);
} }

View file

@ -1,5 +1,4 @@
<?php <?php
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/video.php'; require_once $global['systemRootPath'] . 'objects/video.php';
//getAllVideosAsync($status = "viewable", $showOnlyLoggedUserVideos = false, $ignoreGroup = false, $videosArrayId = array(), $getStatistcs = false, $showUnlisted = false, $activeUsersOnly = true) //getAllVideosAsync($status = "viewable", $showOnlyLoggedUserVideos = false, $ignoreGroup = false, $videosArrayId = array(), $getStatistcs = false, $showUnlisted = false, $activeUsersOnly = true)
@ -15,7 +14,7 @@ $_GET = object_to_array(_json_decode($argv[8]));
$_POST = object_to_array(_json_decode($argv[9])); $_POST = object_to_array(_json_decode($argv[9]));
$cacheFileName = $argv[10]; $cacheFileName = $argv[10];
$lockFile = $cacheFileName.".lock"; $lockFile = $cacheFileName.".lock";
if(file_exists($lockFile) && (time() - filemtime($lockFile) < 300)){ // 5 min limit if (file_exists($lockFile) && (time() - filemtime($lockFile) < 300)) { // 5 min limit
_error_log("getAllVideos: file locked ".$lockFile." filemtime(\$lockFile) = ".filemtime($lockFile)."| (time() - filemtime(\$lockFile))=".(time() - filemtime($lockFile))); _error_log("getAllVideos: file locked ".$lockFile." filemtime(\$lockFile) = ".filemtime($lockFile)."| (time() - filemtime(\$lockFile))=".(time() - filemtime($lockFile)));
return false; return false;
} }

View file

@ -1,5 +1,4 @@
<?php <?php
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/video.php'; require_once $global['systemRootPath'] . 'objects/video.php';
//getTotalVideosInfo($status = "viewable", $showOnlyLoggedUserVideos = false, //getTotalVideosInfo($status = "viewable", $showOnlyLoggedUserVideos = false,

View file

@ -21,7 +21,7 @@ $obj->fileURI = pathinfo($_POST['fileURI']);
//get description //get description
$filename = $obj->fileURI['dirname'] . DIRECTORY_SEPARATOR . $obj->fileURI['filename']; $filename = $obj->fileURI['dirname'] . DIRECTORY_SEPARATOR . $obj->fileURI['filename'];
$extensions = array('txt', 'html', 'htm'); $extensions = ['txt', 'html', 'htm'];
$length = intval($_POST['length']); $length = intval($_POST['length']);
if (empty($length) || $length>100) { if (empty($length) || $length>100) {
@ -29,11 +29,11 @@ if (empty($length) || $length>100) {
} }
foreach ($extensions as $value) { foreach ($extensions as $value) {
$_POST['description'] = ""; $_POST['description'] = '';
$_POST['title'] = ""; $_POST['title'] = '';
if (file_exists("{$filename}.{$value}")) { if (file_exists("{$filename}.{$value}")) {
$html = file_get_contents("{$filename}.{$value}"); $html = file_get_contents("{$filename}.{$value}");
$breaks = array("<br />","<br>","<br/>"); $breaks = ["<br />","<br>","<br/>"];
$html = str_ireplace($breaks, "\r\n", $html); $html = str_ireplace($breaks, "\r\n", $html);
$_POST['description'] = $html; $_POST['description'] = $html;
$cleanHTML = strip_tags($html); $cleanHTML = strip_tags($html);

View file

@ -1,5 +1,4 @@
<?php <?php
if (!empty($doNotIncludeConfig)) { if (!empty($doNotIncludeConfig)) {
error_log('AVideo includeconfig ignored'); error_log('AVideo includeconfig ignored');
return false; return false;
@ -111,8 +110,8 @@ $url1['host'] = '';
$global['HTTP_REFERER'] = ''; $global['HTTP_REFERER'] = '';
if (!empty($_SERVER['HTTP_REFERER'])) { if (!empty($_SERVER['HTTP_REFERER'])) {
if (( if ((
strpos($_SERVER['HTTP_REFERER'], '/video/') !== false || strpos($_SERVER['HTTP_REFERER'], '/v/') !== false strpos($_SERVER['HTTP_REFERER'], '/video/') !== false || strpos($_SERVER['HTTP_REFERER'], '/v/') !== false
) && ) &&
!empty($_SESSION['LAST_HTTP_REFERER'])) { !empty($_SESSION['LAST_HTTP_REFERER'])) {
if (strpos($_SESSION['LAST_HTTP_REFERER'], 'cache/css/') !== false || if (strpos($_SESSION['LAST_HTTP_REFERER'], 'cache/css/') !== false ||
strpos($_SESSION['LAST_HTTP_REFERER'], 'cache/js/') !== false || strpos($_SESSION['LAST_HTTP_REFERER'], 'cache/js/') !== false ||
@ -172,10 +171,10 @@ if (empty($doNotConnectDatabaseIncludeConfig) && $baseName !== 'xsendfile.php' &
if (empty($global['bodyClass'])) { if (empty($global['bodyClass'])) {
$global['bodyClass'] = ''; $global['bodyClass'] = '';
} }
$global['allowedExtension'] = array('gif', 'jpg', 'mp4', 'webm', 'mp3', 'm4a', 'ogg', 'zip', 'm3u8'); $global['allowedExtension'] = ['gif', 'jpg', 'mp4', 'webm', 'mp3', 'm4a', 'ogg', 'zip', 'm3u8'];
if (empty($global['avideo_resolutions'])) { if (empty($global['avideo_resolutions'])) {
$global['avideo_resolutions'] = array(240, 360, 480, 540, 720, 1080, 1440, 2160); $global['avideo_resolutions'] = [240, 360, 480, 540, 720, 1080, 1440, 2160];
} }
sort($global['avideo_resolutions']); sort($global['avideo_resolutions']);

View file

@ -1,4 +1,6 @@
<?php <?php
global $global; global $global;
if(class_exists("Plugin") && empty($global['avideoEndIncluded'])){AVideoPlugin::getEnd();} if (class_exists("Plugin") && empty($global['avideoEndIncluded'])) {
AVideoPlugin::getEnd();
}
$global['avideoEndIncluded'] = 1; $global['avideoEndIncluded'] = 1;

View file

@ -190,7 +190,7 @@ class Minifier
'-' => true, '-' => true,
'+' => true, '+' => true,
'[' => true, '[' => true,
'@' => true]; '@' => true, ];
/** /**
* The primary action occurs here. This function loops through the input string, * The primary action occurs here. This function loops through the input string,

View file

@ -1,17 +1,17 @@
<?php <?php
global $global, $config; global $global, $config;
if(!isset($global['systemRootPath'])){ if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
require_once $global['systemRootPath'] . 'objects/like.php'; require_once $global['systemRootPath'] . 'objects/like.php';
require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/user.php';
header('Content-Type: application/json'); header('Content-Type: application/json');
if(!empty($_GET['user']) && !empty($_GET['pass'])){ if (!empty($_GET['user']) && !empty($_GET['pass'])) {
$user = new User(0, $_GET['user'], $_GET['pass']); $user = new User(0, $_GET['user'], $_GET['pass']);
$user->login(false, true); $user->login(false, true);
} }
if(empty($_POST['videos_id']) && !empty($_GET['videos_id'])){ if (empty($_POST['videos_id']) && !empty($_GET['videos_id'])) {
$_POST['videos_id'] = $_GET['videos_id']; $_POST['videos_id'] = $_GET['videos_id'];
} }

View file

@ -25,23 +25,23 @@ class Like
// if click again in the same vote, remove the vote // if click again in the same vote, remove the vote
if ($this->like == $like) { if ($this->like == $like) {
$like = 0; $like = 0;
if($this->like==1){ if ($this->like==1) {
Video::updateLikesDislikes($videos_id, 'likes', '-1'); Video::updateLikesDislikes($videos_id, 'likes', '-1');
}else if($this->like==-1){ } elseif ($this->like==-1) {
Video::updateLikesDislikes($videos_id, 'dislikes', '-1'); Video::updateLikesDislikes($videos_id, 'dislikes', '-1');
} }
}else{ } else {
if(!empty($this->like)){ if (!empty($this->like)) {
// need to remove some like or dislike // need to remove some like or dislike
if($like==1){ if ($like==1) {
Video::updateLikesDislikes($videos_id, 'dislikes', '-1'); Video::updateLikesDislikes($videos_id, 'dislikes', '-1');
}else if($like==-1){ } elseif ($like==-1) {
Video::updateLikesDislikes($videos_id, 'likes', '-1'); Video::updateLikesDislikes($videos_id, 'likes', '-1');
} }
} }
if($like==1){ if ($like==1) {
Video::updateLikesDislikes($videos_id, 'likes', '+1'); Video::updateLikesDislikes($videos_id, 'likes', '+1');
}else if($like==-1){ } elseif ($like==-1) {
Video::updateLikesDislikes($videos_id, 'dislikes', '+1'); Video::updateLikesDislikes($videos_id, 'dislikes', '+1');
} }
} }
@ -53,7 +53,7 @@ class Like
private function setLike($like) private function setLike($like)
{ {
$like = intval($like); $like = intval($like);
if (!in_array($like, array(0,1,-1))) { if (!in_array($like, [0,1,-1])) {
$like = 0; $like = 0;
} }
$this->like = $like; $this->like = $like;
@ -78,7 +78,7 @@ class Like
die('{"error":"You must have user and videos set to get a like"}'); die('{"error":"You must have user and videos set to get a like"}');
} }
$sql = "SELECT * FROM likes WHERE users_id = ? AND videos_id = ".$this->videos_id." LIMIT 1;"; $sql = "SELECT * FROM likes WHERE users_id = ? AND videos_id = ".$this->videos_id." LIMIT 1;";
$res = sqlDAL::readSql($sql, "i", array($this->users_id)); $res = sqlDAL::readSql($sql, "i", [$this->users_id]);
$dbLike = sqlDAL::fetchAssoc($res); $dbLike = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
return $dbLike; return $dbLike;
@ -93,10 +93,10 @@ class Like
} }
if (!empty($this->id)) { if (!empty($this->id)) {
$sql = "UPDATE likes SET `like` = ?, modified = now() WHERE id = ?;"; $sql = "UPDATE likes SET `like` = ?, modified = now() WHERE id = ?;";
$res = sqlDAL::writeSql($sql, "ii", array($this->like, $this->id)); $res = sqlDAL::writeSql($sql, "ii", [$this->like, $this->id]);
} else { } else {
$sql = "INSERT INTO likes (`like`,users_id, videos_id, created, modified) VALUES (?, ?, ?, now(), now());"; $sql = "INSERT INTO likes (`like`,users_id, videos_id, created, modified) VALUES (?, ?, ?, now(), now());";
$res = sqlDAL::writeSql($sql, "iii", array($this->like, $this->users_id, $this->videos_id)); $res = sqlDAL::writeSql($sql, "iii", [$this->like, $this->users_id, $this->videos_id]);
} }
//echo $sql; //echo $sql;
if ($global['mysqli']->errno!=0) { if ($global['mysqli']->errno!=0) {
@ -105,14 +105,15 @@ class Like
return $res; return $res;
} }
public static function getLikes($videos_id){ public static function getLikes($videos_id)
{
global $global, $_getLikes; global $global, $_getLikes;
if(!isset($_getLikes)){ if (!isset($_getLikes)) {
$_getLikes = array(); $_getLikes = [];
} }
if(!empty($_getLikes[$videos_id])){ if (!empty($_getLikes[$videos_id])) {
return $_getLikes[$videos_id]; return $_getLikes[$videos_id];
} }
@ -123,7 +124,7 @@ class Like
$obj->myVote = self::getMyVote($videos_id); $obj->myVote = self::getMyVote($videos_id);
$sql = "SELECT count(*) as total FROM likes WHERE videos_id = ? AND `like` = 1 "; // like $sql = "SELECT count(*) as total FROM likes WHERE videos_id = ? AND `like` = 1 "; // like
$res = sqlDAL::readSql($sql, "i", array($videos_id)); $res = sqlDAL::readSql($sql, "i", [$videos_id]);
$row = sqlDAL::fetchAssoc($res); $row = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if ($global['mysqli']->errno!=0) { if ($global['mysqli']->errno!=0) {
@ -133,7 +134,7 @@ class Like
$sql = "SELECT count(*) as total FROM likes WHERE videos_id = ? AND `like` = -1 "; // dislike $sql = "SELECT count(*) as total FROM likes WHERE videos_id = ? AND `like` = -1 "; // dislike
$res = sqlDAL::readSql($sql, "i", array($videos_id)); $res = sqlDAL::readSql($sql, "i", [$videos_id]);
$row = sqlDAL::fetchAssoc($res); $row = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if ($global['mysqli']->errno!=0) { if ($global['mysqli']->errno!=0) {
@ -181,7 +182,7 @@ class Like
$id = User::getId(); $id = User::getId();
$sql = "SELECT `like` FROM likes WHERE videos_id = ? AND users_id = ? "; // like $sql = "SELECT `like` FROM likes WHERE videos_id = ? AND users_id = ? "; // like
$res = sqlDAL::readSql($sql, "ii", array($videos_id,$id)); $res = sqlDAL::readSql($sql, "ii", [$videos_id,$id]);
$dbLike = sqlDAL::fetchAssoc($res); $dbLike = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if ($dbLike!=false) { if ($dbLike!=false) {

View file

@ -1,5 +1,4 @@
<?php <?php
global $global, $config; global $global, $config;
if (!isset($global['systemRootPath'])) { if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';

View file

@ -1,6 +1,6 @@
<?php <?php
global $global, $config; global $global, $config;
if(!isset($global['systemRootPath'])){ if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
header('Content-Type: application/json'); header('Content-Type: application/json');
@ -8,8 +8,8 @@ header('Content-Type: application/json');
if (!User::canUpload() || !empty($advancedCustom->doNotShowImportMP4Button)) { if (!User::canUpload() || !empty($advancedCustom->doNotShowImportMP4Button)) {
return false; return false;
} }
$global['allowed'] = array('mp4'); $global['allowed'] = ['mp4'];
$files = array(); $files = [];
if (!empty($_POST['path'])) { if (!empty($_POST['path'])) {
$path = $_POST['path']; $path = $_POST['path'];
if (substr($path, -1) !== '/') { if (substr($path, -1) !== '/') {

View file

@ -58,11 +58,11 @@ if (!empty($_GET['type'])) {
"id" => trim($obj->id), "id" => trim($obj->id),
"team_id" => trim($obj->team_id), "team_id" => trim($obj->team_id),
"key_id" => trim($obj->key_id), "key_id" => trim($obj->key_id),
"key_content" => trim($obj->key_content->value) "key_content" => trim($obj->key_content->value),
], ],
"scope" => "name email", "scope" => "name email",
"verifyTokenSignature" => true "verifyTokenSignature" => true,
] ],
], ],
/* optional : set debug mode /* optional : set debug mode
'debug_mode' => true, 'debug_mode' => true,
@ -102,8 +102,8 @@ if (!empty($_GET['type'])) {
'keys' => ['id' => $id, 'secret' => $key, 'key' => $id], 'keys' => ['id' => $id, 'secret' => $key, 'key' => $id],
"includeEmail" => true, "includeEmail" => true,
'scope' => $scope, 'scope' => $scope,
'trustForwarded' => false 'trustForwarded' => false,
] ],
], ],
/* optional : set debug mode /* optional : set debug mode
'debug_mode' => true, 'debug_mode' => true,
@ -140,7 +140,7 @@ if (!empty($_GET['type'])) {
_session_start(); _session_start();
$location = $_SESSION['redirectUri']; $location = $_SESSION['redirectUri'];
//header("Location: {$_SESSION['redirectUri']}"); //header("Location: {$_SESSION['redirectUri']}");
$_SESSION['redirectUri'] = ""; $_SESSION['redirectUri'] = '';
unset($_SESSION['redirectUri']); unset($_SESSION['redirectUri']);
} else { } else {
$location = $global['webSiteRootURL']; $location = $global['webSiteRootURL'];
@ -151,11 +151,10 @@ if (!empty($_GET['type'])) {
//header("Location: {$global['webSiteRootURL']}user?error=" . urlencode($e->getMessage())); //header("Location: {$global['webSiteRootURL']}user?error=" . urlencode($e->getMessage()));
//echo $e->getMessage(); //echo $e->getMessage();
} }
if(!isSameDomainAsMyAVideo($location)){ if (!isSameDomainAsMyAVideo($location)) {
$location = $global['webSiteRootURL']; $location = $global['webSiteRootURL'];
} }
header('Content-Type: text/html'); header('Content-Type: text/html'); ?>
?>
<script> <script>
window.opener = self; window.opener = self;
if (window.name == 'loginYPT') { if (window.name == 'loginYPT') {
@ -262,14 +261,14 @@ if (empty($advancedCustomUser->userCanNotChangeCategory) || User::isAdmin()) {
array_multisort(array_column($object->categories, 'hierarchyAndName'), SORT_ASC, $object->categories); array_multisort(array_column($object->categories, 'hierarchyAndName'), SORT_ASC, $object->categories);
} }
} else { } else {
$object->categories = array(); $object->categories = [];
} }
//_error_log("login.json.php get user groups"); //_error_log("login.json.php get user groups");
TimeLogEnd($timeLog, __LINE__); TimeLogEnd($timeLog, __LINE__);
$object->userGroups = UserGroups::getAllUsersGroups(); $object->userGroups = UserGroups::getAllUsersGroups();
TimeLogEnd($timeLog, __LINE__); TimeLogEnd($timeLog, __LINE__);
$object->streamServerURL = ""; $object->streamServerURL = '';
$object->streamKey = ""; $object->streamKey = '';
if ($object->isLogged) { if ($object->isLogged) {
$timeLog2 = __FILE__ . "::Is Logged "; $timeLog2 = __FILE__ . "::Is Logged ";
TimeLogStart($timeLog2); TimeLogStart($timeLog2);

View file

@ -1,15 +1,15 @@
<?php <?php
global $global, $config; global $global, $config;
if(!isset($global['systemRootPath'])){ if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php'; require_once '../videos/configuration.php';
} }
require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/user.php';
if (!empty($advancedCustomUser->afterLogoffGoToMyChannel)) { if (!empty($advancedCustomUser->afterLogoffGoToMyChannel)) {
$redirectUri = User::getChannelLink(); $redirectUri = User::getChannelLink();
}else if (!empty($advancedCustomUser->afterLogoffGoToURL)) { } elseif (!empty($advancedCustomUser->afterLogoffGoToURL)) {
$redirectUri = $advancedCustomUser->afterLogoffGoToURL; $redirectUri = $advancedCustomUser->afterLogoffGoToURL;
}else{ } else {
$redirectUri = $global['webSiteRootURL']; $redirectUri = $global['webSiteRootURL'];
} }

View file

@ -1,11 +1,13 @@
<?php <?php
class Main { class Main
/** {
* receive a YYYY-MM-DD /**
* @param type $brDate * receive a YYYY-MM-DD
* @return String dd/mm/yyyy * @param type $brDate
*/ * @return String dd/mm/yyyy
static public function dateMySQLToBrString($mySqlDate) { */
public static function dateMySQLToBrString($mySqlDate)
{
$parts = explode('-', $mySqlDate); $parts = explode('-', $mySqlDate);
//switch month and day //switch month and day
if (empty($parts[2])) { if (empty($parts[2])) {
@ -17,7 +19,7 @@ class Main {
$hour = " " . $parts2[1]; $hour = " " . $parts2[1];
} else { } else {
$day = $parts[2]; $day = $parts[2];
$hour = ""; $hour = '';
} }
return "{$day}/{$parts[1]}/{$parts[0]}{$hour}"; return "{$day}/{$parts[1]}/{$parts[0]}{$hour}";
} }
@ -28,7 +30,8 @@ class Main {
* @param type $mySqlDate * @param type $mySqlDate
* @return String YYYY-mm-dd * @return String YYYY-mm-dd
*/ */
static public function dateBrStringToMySQL($date) { public static function dateBrStringToMySQL($date)
{
$parts = explode("/", $date); $parts = explode("/", $date);
//switch month and day //switch month and day
if (empty($parts[2])) { if (empty($parts[2])) {
@ -40,7 +43,7 @@ class Main {
$hour = " " . $parts2[1]; $hour = " " . $parts2[1];
} else { } else {
$year = $parts[2]; $year = $parts[2];
$hour = ""; $hour = '';
} }
return "{$year}-{$parts[1]}-{$parts[0]}{$hour}"; return "{$year}-{$parts[1]}-{$parts[0]}{$hour}";
} }

View file

@ -1,5 +1,4 @@
<?php <?php
/* /*
tester-execution-code tester-execution-code
$sql = "SELECT * FROM users WHERE id=?;"; $sql = "SELECT * FROM users WHERE id=?;";
@ -19,10 +18,11 @@
* Internal used class * Internal used class
*/ */
class iimysqli_result { class iimysqli_result
{
public $stmt, $nCols, $fields; public $stmt;
public $nCols;
public $fields;
} }
global $disableMysqlNdMethods; global $disableMysqlNdMethods;
@ -34,9 +34,10 @@ $disableMysqlNdMethods = false;
* It wouldn't be possible without Daan on https://stackoverflow.com/questions/31562359/workaround-for-mysqlnd-missing-driver * It wouldn't be possible without Daan on https://stackoverflow.com/questions/31562359/workaround-for-mysqlnd-missing-driver
*/ */
class sqlDAL { class sqlDAL
{
static function executeFile($filename) { public static function executeFile($filename)
{
global $global; global $global;
$templine = ''; $templine = '';
// Read in entire file // Read in entire file
@ -44,8 +45,9 @@ class sqlDAL {
// Loop through each line // Loop through each line
foreach ($lines as $line) { foreach ($lines as $line) {
// Skip it if it's a comment // Skip it if it's a comment
if (substr($line, 0, 2) == '--' || $line == '') if (substr($line, 0, 2) == '--' || $line == '') {
continue; continue;
}
// Add this line to the current segment // Add this line to the current segment
$templine .= $line; $templine .= $line;
@ -69,9 +71,10 @@ class sqlDAL {
* @return boolean true on success, false on fail * @return boolean true on success, false on fail
*/ */
static function writeSql($preparedStatement, $formats = "", $values = array()) { public static function writeSql($preparedStatement, $formats = "", $values = [])
{
global $global, $disableMysqlNdMethods; global $global, $disableMysqlNdMethods;
if(empty($preparedStatement)){ if (empty($preparedStatement)) {
return false; return false;
} }
// make sure it does not store autid transactions // make sure it does not store autid transactions
@ -87,7 +90,7 @@ class sqlDAL {
} }
} }
if(!is_object($global['mysqli'])){ if (!is_object($global['mysqli'])) {
_mysql_connect(); _mysql_connect();
} }
@ -109,9 +112,9 @@ class sqlDAL {
//$global['mysqli']->affected_rows = $stmt->affected_rows; //$global['mysqli']->affected_rows = $stmt->affected_rows;
//$stmt->commit(); //$stmt->commit();
$stmt->close(); $stmt->close();
if(!empty($iid)){ if (!empty($iid)) {
return $iid; return $iid;
}else{ } else {
return true; return true;
} }
} }
@ -124,14 +127,15 @@ class sqlDAL {
* @return Object Depend if mysqlnd is active or not, a object, but always false on fail * @return Object Depend if mysqlnd is active or not, a object, but always false on fail
*/ */
static function readSql($preparedStatement, $formats = "", $values = array(), $refreshCache = false) { public static function readSql($preparedStatement, $formats = "", $values = [], $refreshCache = false)
{
// $refreshCache = true; // $refreshCache = true;
global $global, $disableMysqlNdMethods, $readSqlCached, $crc; global $global, $disableMysqlNdMethods, $readSqlCached, $crc;
// need to add dechex because some times it return an negative value and make it fails on javascript playlists // need to add dechex because some times it return an negative value and make it fails on javascript playlists
$crc = (md5($preparedStatement . implode($values))); $crc = (md5($preparedStatement . implode($values)));
if (!isset($readSqlCached)) { if (!isset($readSqlCached)) {
$readSqlCached = array(); $readSqlCached = [];
} }
if ((function_exists('mysqli_fetch_all')) && ($disableMysqlNdMethods == false)) { if ((function_exists('mysqli_fetch_all')) && ($disableMysqlNdMethods == false)) {
@ -152,7 +156,7 @@ class sqlDAL {
if (!($stmt = $global['mysqli']->prepare($preparedStatement))) { if (!($stmt = $global['mysqli']->prepare($preparedStatement))) {
log_error("[sqlDAL::readSql] (mysqlnd) Prepare failed again return false"); log_error("[sqlDAL::readSql] (mysqlnd) Prepare failed again return false");
return false; return false;
}else{ } else {
log_error("[sqlDAL::readSql] SUCCESS close and reconnect works!"); log_error("[sqlDAL::readSql] SUCCESS close and reconnect works!");
} }
} }
@ -175,7 +179,7 @@ class sqlDAL {
} }
TimeLogEnd($TimeLog, "mysql_dal", 0.5); TimeLogEnd($TimeLog, "mysql_dal", 0.5);
$stmt->close(); $stmt->close();
} else if (is_object($readSqlCached[$crc])) { } elseif (is_object($readSqlCached[$crc])) {
// When cached // When cached
// reset the stmt for fetch. this solves objects/video.php line 550 // reset the stmt for fetch. this solves objects/video.php line 550
@ -237,10 +241,11 @@ class sqlDAL {
* @param Object $result A object from sqlDAL::readSql * @param Object $result A object from sqlDAL::readSql
*/ */
static function close($result) { public static function close($result)
{
global $disableMysqlNdMethods, $global; global $disableMysqlNdMethods, $global;
if ((!function_exists('mysqli_fetch_all')) || ($disableMysqlNdMethods != false)) { if ((!function_exists('mysqli_fetch_all')) || ($disableMysqlNdMethods != false)) {
if(!empty($result->stmt)){ if (!empty($result->stmt)) {
$result->stmt->close(); $result->stmt->close();
} }
} }
@ -252,10 +257,11 @@ class sqlDAL {
* @return int The nr of rows * @return int The nr of rows
*/ */
static function num_rows($res) { public static function num_rows($res)
{
global $global, $disableMysqlNdMethods, $crc, $num_row_cache; global $global, $disableMysqlNdMethods, $crc, $num_row_cache;
if (!isset($num_row_cache)) { if (!isset($num_row_cache)) {
$num_row_cache = array(); $num_row_cache = [];
} }
// cache is working - but disable for proper test-results // cache is working - but disable for proper test-results
if (!isset($num_row_cache[$crc])) { if (!isset($num_row_cache[$crc])) {
@ -275,7 +281,8 @@ class sqlDAL {
} }
// unused // unused
static function cached_num_rows($data) { public static function cached_num_rows($data)
{
return sizeof($data); return sizeof($data);
} }
@ -285,13 +292,14 @@ class sqlDAL {
* @return array A array filled with all rows as a assoc array * @return array A array filled with all rows as a assoc array
*/ */
static function fetchAllAssoc($result) { public static function fetchAllAssoc($result)
{
global $crc, $fetchAllAssoc_cache; global $crc, $fetchAllAssoc_cache;
if (!isset($fetchAllAssoc_cache)) { if (!isset($fetchAllAssoc_cache)) {
$fetchAllAssoc_cache = array(); $fetchAllAssoc_cache = [];
} }
if (!isset($fetchAllAssoc_cache[$crc])) { if (!isset($fetchAllAssoc_cache[$crc])) {
$ret = array(); $ret = [];
while ($row = self::fetchAssoc($result)) { while ($row = self::fetchAssoc($result)) {
$ret[] = $row; $ret[] = $row;
} }
@ -306,7 +314,8 @@ class sqlDAL {
* @return int A single row in a assoc array * @return int A single row in a assoc array
*/ */
static function fetchAssoc($result) { public static function fetchAssoc($result)
{
global $global, $disableMysqlNdMethods; global $global, $disableMysqlNdMethods;
ini_set('memory_limit', '-1'); ini_set('memory_limit', '-1');
// here, a cache is more/too difficult, because fetch gives always a next. with this kind of cache, we would give always the same. // here, a cache is more/too difficult, because fetch gives always a next. with this kind of cache, we would give always the same.
@ -326,14 +335,15 @@ class sqlDAL {
* @return array A array filled with all rows * @return array A array filled with all rows
*/ */
static function fetchAllArray($result) { public static function fetchAllArray($result)
{
global $crc, $fetchAllArray_cache; global $crc, $fetchAllArray_cache;
if (!isset($fetchAllArray_cache)) { if (!isset($fetchAllArray_cache)) {
$fetchAllArray_cache = array(); $fetchAllArray_cache = [];
} }
// cache is working - but disable for proper test-results // cache is working - but disable for proper test-results
if (!isset($fetchAllArray_cache[$crc])) { if (!isset($fetchAllArray_cache[$crc])) {
$ret = array(); $ret = [];
while ($row = self::fetchArray($result)) { while ($row = self::fetchArray($result)) {
$ret[] = $row; $ret[] = $row;
} }
@ -350,7 +360,8 @@ class sqlDAL {
* @return int A single row in a array * @return int A single row in a array
*/ */
static function fetchArray($result) { public static function fetchArray($result)
{
global $global, $disableMysqlNdMethods; global $global, $disableMysqlNdMethods;
if ((function_exists('mysqli_fetch_all')) && ($disableMysqlNdMethods == false)) { if ((function_exists('mysqli_fetch_all')) && ($disableMysqlNdMethods == false)) {
return $result->fetch_array(); return $result->fetch_array();
@ -360,7 +371,8 @@ class sqlDAL {
return false; return false;
} }
private static function eval_mysql_bind($stmt, $formats, $values) { private static function eval_mysql_bind($stmt, $formats, $values)
{
if (($stmt->param_count != sizeof($values)) || ($stmt->param_count != strlen($formats))) { if (($stmt->param_count != sizeof($values)) || ($stmt->param_count != strlen($formats))) {
return false; return false;
} }
@ -378,11 +390,12 @@ class sqlDAL {
return true; return true;
} }
private static function iimysqli_stmt_get_result($stmt) { private static function iimysqli_stmt_get_result($stmt)
{
global $global; global $global;
$metadata = mysqli_stmt_result_metadata($stmt); $metadata = mysqli_stmt_result_metadata($stmt);
$ret = new iimysqli_result; $ret = new iimysqli_result();
$field_array = array(); $field_array = [];
if (!$metadata) { if (!$metadata) {
die("Execute query error, because: {$stmt->error}"); die("Execute query error, because: {$stmt->error}");
} }
@ -393,8 +406,9 @@ class sqlDAL {
$i++; $i++;
} }
$ret->fields = $field_array; $ret->fields = $field_array;
if (!$ret) if (!$ret) {
return NULL; return null;
}
$ret->nCols = mysqli_num_fields($metadata); $ret->nCols = mysqli_num_fields($metadata);
@ -404,12 +418,13 @@ class sqlDAL {
return $ret; return $ret;
} }
private static function iimysqli_result_fetch_assoc(&$result) { private static function iimysqli_result_fetch_assoc(&$result)
{
global $global; global $global;
$ret = array(); $ret = [];
$code = "return mysqli_stmt_bind_result(\$result->stmt "; $code = "return mysqli_stmt_bind_result(\$result->stmt ";
for ($i = 0; $i < $result->nCols; $i++) { for ($i = 0; $i < $result->nCols; $i++) {
$ret[$result->fields[$i]] = NULL; $ret[$result->fields[$i]] = null;
$code .= ", \$ret['" . $result->fields[$i] . "']"; $code .= ", \$ret['" . $result->fields[$i] . "']";
}; };
@ -423,12 +438,13 @@ class sqlDAL {
return $ret; return $ret;
} }
private static function iimysqli_result_fetch_array(&$result) { private static function iimysqli_result_fetch_array(&$result)
$ret = array(); {
$ret = [];
$code = "return mysqli_stmt_bind_result(\$result->stmt "; $code = "return mysqli_stmt_bind_result(\$result->stmt ";
for ($i = 0; $i < $result->nCols; $i++) { for ($i = 0; $i < $result->nCols; $i++) {
$ret[$i] = NULL; $ret[$i] = null;
$code .= ", \$ret['" . $i . "']"; $code .= ", \$ret['" . $i . "']";
}; };
$code .= ");"; $code .= ");";
@ -440,15 +456,13 @@ class sqlDAL {
}; };
return $ret; return $ret;
} }
} }
function log_error($err) { function log_error($err)
{
if (!empty($global['debug'])) { if (!empty($global['debug'])) {
echo $err; echo $err;
} }
_error_log("MySQL ERROR: ".json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)), AVideoLog::$ERROR); _error_log("MySQL ERROR: ".json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)), AVideoLog::$ERROR);
_error_log($err, AVideoLog::$ERROR); _error_log($err, AVideoLog::$ERROR);
} }
?>

View file

@ -14,7 +14,7 @@ if (!User::canUpload()) {
$user_id = User::getId(); $user_id = User::getId();
// if admin bring all subscribers // if admin bring all subscribers
if (User::isAdmin()) { if (User::isAdmin()) {
$user_id = ""; $user_id = '';
} }
require_once 'subscribe.php'; require_once 'subscribe.php';
@ -23,7 +23,7 @@ $Subscribes = Subscribe::getAllSubscribes($user_id);
$obj = new stdClass(); $obj = new stdClass();
//Create a new PHPMailer instance //Create a new PHPMailer instance
$mail = new \PHPMailer\PHPMailer\PHPMailer; $mail = new \PHPMailer\PHPMailer\PHPMailer();
setSiteSendMessage($mail); setSiteSendMessage($mail);
//Set who the message is to be sent from //Set who the message is to be sent from
$mail->setFrom($config->getContactEmail()); $mail->setFrom($config->getContactEmail());

View file

@ -1,5 +1,4 @@
<?php <?php
global $global, $config, $refreshCacheFromPlaylist; global $global, $config, $refreshCacheFromPlaylist;
$refreshCacheFromPlaylist = false; // this is because it was creating playlists multiple times $refreshCacheFromPlaylist = false; // this is because it was creating playlists multiple times
@ -8,27 +7,30 @@ if (!isset($global['systemRootPath'])) {
} }
require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/user.php';
class PlayList extends ObjectYPT { class PlayList extends ObjectYPT
{
protected $id; protected $id;
protected $name; protected $name;
protected $users_id; protected $users_id;
protected $status; protected $status;
protected $showOnTV; protected $showOnTV;
public static $validStatus = array('public', 'private', 'unlisted', 'favorite', 'watch_later'); public static $validStatus = ['public', 'private', 'unlisted', 'favorite', 'watch_later'];
public static function getSearchFieldsNames() { public static function getSearchFieldsNames()
return array('pl.name'); {
return ['pl.name'];
} }
public static function getTableName() { public static function getTableName()
{
return 'playlists'; return 'playlists';
} }
protected static function getFromDbFromName($name) { protected static function getFromDbFromName($name)
{
global $global; global $global;
$sql = "SELECT * FROM " . static::getTableName() . " WHERE name = ? users_id = " . User::getId() . " LIMIT 1"; $sql = "SELECT * FROM " . static::getTableName() . " WHERE name = ? users_id = " . User::getId() . " LIMIT 1";
$res = sqlDAL::readSql($sql, "s", array($name)); $res = sqlDAL::readSql($sql, "s", [$name]);
$data = sqlDAL::fetchAssoc($res); $data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if ($res) { if ($res) {
@ -39,7 +41,8 @@ class PlayList extends ObjectYPT {
return $row; return $row;
} }
public function loadFromName($name) { public function loadFromName($name)
{
if (!User::isLogged()) { if (!User::isLogged()) {
return false; return false;
} }
@ -54,7 +57,8 @@ class PlayList extends ObjectYPT {
return true; return true;
} }
public static function getAllFromPlaylistsID($playlists_id) { public static function getAllFromPlaylistsID($playlists_id)
{
if (empty($playlists_id)) { if (empty($playlists_id)) {
return false; return false;
} }
@ -80,11 +84,12 @@ class PlayList extends ObjectYPT {
* @param type $isVideoIdPresent pass the ID of the video checking * @param type $isVideoIdPresent pass the ID of the video checking
* @return boolean * @return boolean
*/ */
public static function getAllFromUser($userId, $publicOnly = true, $status = false, $playlists_id = 0, $try = 0) { public static function getAllFromUser($userId, $publicOnly = true, $status = false, $playlists_id = 0, $try = 0)
{
global $global, $config, $refreshCacheFromPlaylist; global $global, $config, $refreshCacheFromPlaylist;
$playlists_id = intval($playlists_id); $playlists_id = intval($playlists_id);
$formats = ""; $formats = '';
$values = array(); $values = [];
$sql = "SELECT u.*, pl.* FROM " . static::getTableName() . " pl " $sql = "SELECT u.*, pl.* FROM " . static::getTableName() . " pl "
. " LEFT JOIN users u ON u.id = users_id WHERE 1=1 "; . " LEFT JOIN users u ON u.id = users_id WHERE 1=1 ";
if (!empty($playlists_id)) { if (!empty($playlists_id)) {
@ -106,9 +111,9 @@ class PlayList extends ObjectYPT {
$res = sqlDAL::readSql($sql, $formats, $values, $refreshCacheFromPlaylist); $res = sqlDAL::readSql($sql, $formats, $values, $refreshCacheFromPlaylist);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
$favorite = array(); $favorite = [];
$watch_later = array(); $watch_later = [];
$favoriteCount = 0; $favoriteCount = 0;
$watch_laterCount = 0; $watch_laterCount = 0;
if ($res != false) { if ($res != false) {
@ -185,11 +190,12 @@ class PlayList extends ObjectYPT {
* @param type $isVideoIdPresent pass the ID of the video checking * @param type $isVideoIdPresent pass the ID of the video checking
* @return boolean * @return boolean
*/ */
public static function getAllFromUserLight($userId, $publicOnly = true, $status = false, $playlists_id = 0, $onlyWithVideos = false) { public static function getAllFromUserLight($userId, $publicOnly = true, $status = false, $playlists_id = 0, $onlyWithVideos = false)
{
global $global, $config, $refreshCacheFromPlaylist; global $global, $config, $refreshCacheFromPlaylist;
$playlists_id = intval($playlists_id); $playlists_id = intval($playlists_id);
$formats = ""; $formats = '';
$values = array(); $values = [];
$sql = "SELECT u.*, pl.* FROM " . static::getTableName() . " pl " $sql = "SELECT u.*, pl.* FROM " . static::getTableName() . " pl "
. " LEFT JOIN users u ON u.id = users_id WHERE 1=1 "; . " LEFT JOIN users u ON u.id = users_id WHERE 1=1 ";
if (!empty($playlists_id)) { if (!empty($playlists_id)) {
@ -213,7 +219,7 @@ class PlayList extends ObjectYPT {
$res = sqlDAL::readSql($sql, $formats, $values, $refreshCacheFromPlaylist); $res = sqlDAL::readSql($sql, $formats, $values, $refreshCacheFromPlaylist);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $row) { foreach ($fullData as $row) {
$row = cleanUpRowFromDatabase($row); $row = cleanUpRowFromDatabase($row);
@ -231,16 +237,17 @@ class PlayList extends ObjectYPT {
return $rows; return $rows;
} }
public static function fixDuplicatePlayList($user_id) { public static function fixDuplicatePlayList($user_id)
{
if (empty($user_id)) { if (empty($user_id)) {
return false; return false;
} }
_error_log("PlayList::fixDuplicatePlayList Process user_id = {$user_id} favorite"); _error_log("PlayList::fixDuplicatePlayList Process user_id = {$user_id} favorite");
$sql = "SELECT * FROM playlists WHERE users_id = ? AND status = 'favorite' ORDER BY created "; $sql = "SELECT * FROM playlists WHERE users_id = ? AND status = 'favorite' ORDER BY created ";
$res = sqlDAL::readSql($sql, "i", array($user_id), true); $res = sqlDAL::readSql($sql, "i", [$user_id], true);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $key => $row) { foreach ($fullData as $key => $row) {
if ($key === 0) { if ($key === 0) {
@ -256,16 +263,16 @@ class PlayList extends ObjectYPT {
$sql .= " WHERE id = ?"; $sql .= " WHERE id = ?";
_error_log("PlayList::fixDuplicatePlayList favorite {$row['id']}"); _error_log("PlayList::fixDuplicatePlayList favorite {$row['id']}");
sqlDAL::writeSql($sql, "i", array($row['id'])); sqlDAL::writeSql($sql, "i", [$row['id']]);
} }
} }
_error_log("PlayList::fixDuplicatePlayList Process user_id = {$user_id} watch_later"); _error_log("PlayList::fixDuplicatePlayList Process user_id = {$user_id} watch_later");
$sql = "SELECT * FROM playlists WHERE users_id = ? AND status = 'watch_later' ORDER BY created "; $sql = "SELECT * FROM playlists WHERE users_id = ? AND status = 'watch_later' ORDER BY created ";
$res = sqlDAL::readSql($sql, "i", array($user_id), true); $res = sqlDAL::readSql($sql, "i", [$user_id], true);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $key => $row) { foreach ($fullData as $key => $row) {
if ($key === 0) { if ($key === 0) {
@ -279,12 +286,13 @@ class PlayList extends ObjectYPT {
$sql .= " WHERE id = ?"; $sql .= " WHERE id = ?";
_error_log("PlayList::fixDuplicatePlayList watch_later {$row['id']}"); _error_log("PlayList::fixDuplicatePlayList watch_later {$row['id']}");
ob_flush(); ob_flush();
sqlDAL::writeSql($sql, "i", array($row['id'])); sqlDAL::writeSql($sql, "i", [$row['id']]);
} }
} }
} }
public static function getAllFromUserVideo($userId, $videos_id, $publicOnly = true, $status = false) { public static function getAllFromUserVideo($userId, $videos_id, $publicOnly = true, $status = false)
{
if (empty($_SESSION['user']['sessionCache']['getAllFromUserVideo'][$videos_id][$userId][intval($publicOnly)][intval($status)])) { if (empty($_SESSION['user']['sessionCache']['getAllFromUserVideo'][$videos_id][$userId][intval($publicOnly)][intval($status)])) {
$rows = self::getAllFromUser($userId, $publicOnly, $status); $rows = self::getAllFromUser($userId, $publicOnly, $status);
foreach ($rows as $key => $value) { foreach ($rows as $key => $value) {
@ -301,17 +309,19 @@ class PlayList extends ObjectYPT {
return $rows; return $rows;
} }
private static function removeCache($videos_id) { private static function removeCache($videos_id)
{
$close = false; $close = false;
_session_start(); _session_start();
unset($_SESSION['user']['sessionCache']['getAllFromUserVideo'][$videos_id]); unset($_SESSION['user']['sessionCache']['getAllFromUserVideo'][$videos_id]);
} }
public static function getVideosIDFromPlaylistLight($playlists_id) { public static function getVideosIDFromPlaylistLight($playlists_id)
{
global $global, $getVideosIDFromPlaylistLight; global $global, $getVideosIDFromPlaylistLight;
if (!isset($getVideosIDFromPlaylistLight)) { if (!isset($getVideosIDFromPlaylistLight)) {
$getVideosIDFromPlaylistLight = array(); $getVideosIDFromPlaylistLight = [];
} }
if (isset($getVideosIDFromPlaylistLight[$playlists_id])) { if (isset($getVideosIDFromPlaylistLight[$playlists_id])) {
@ -328,10 +338,10 @@ class PlayList extends ObjectYPT {
reloadSearchVar(); reloadSearchVar();
* *
*/ */
$res = sqlDAL::readSql($sql, "i", array($playlists_id)); $res = sqlDAL::readSql($sql, "i", [$playlists_id]);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $row) { foreach ($fullData as $row) {
$rows[] = $row; $rows[] = $row;
@ -343,7 +353,8 @@ class PlayList extends ObjectYPT {
return $rows; return $rows;
} }
public static function getVideosFromPlaylist($playlists_id) { public static function getVideosFromPlaylist($playlists_id)
{
$sql = "SELECT *,v.created as cre, p.`order` as video_order, v.externalOptions as externalOptions " $sql = "SELECT *,v.created as cre, p.`order` as video_order, v.externalOptions as externalOptions "
//. ", (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = 1 ) as likes " //. ", (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = 1 ) as likes "
. " FROM playlists_has_videos p " . " FROM playlists_has_videos p "
@ -352,7 +363,7 @@ class PlayList extends ObjectYPT {
. " WHERE playlists_id = ? AND v.status != 'i' "; . " WHERE playlists_id = ? AND v.status != 'i' ";
cleanSearchVar(); cleanSearchVar();
$sort = @$_POST['sort']; $sort = @$_POST['sort'];
$_POST['sort'] = array(); $_POST['sort'] = [];
$_POST['sort']['p.`order`'] = 'ASC'; $_POST['sort']['p.`order`'] = 'ASC';
$sql .= self::getSqlFromPost(); $sql .= self::getSqlFromPost();
reloadSearchVar(); reloadSearchVar();
@ -362,10 +373,10 @@ class PlayList extends ObjectYPT {
if (empty($rows)) { if (empty($rows)) {
global $global; global $global;
$res = sqlDAL::readSql($sql, "i", array($playlists_id)); $res = sqlDAL::readSql($sql, "i", [$playlists_id]);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
$SubtitleSwitcher = AVideoPlugin::loadPluginIfEnabled("SubtitleSwitcher"); $SubtitleSwitcher = AVideoPlugin::loadPluginIfEnabled("SubtitleSwitcher");
if ($res != false) { if ($res != false) {
foreach ($fullData as $row) { foreach ($fullData as $row) {
@ -395,8 +406,8 @@ class PlayList extends ObjectYPT {
$row['subtitlesSRT'][] = convertSRTTrack($value); $row['subtitlesSRT'][] = convertSRTTrack($value);
} }
} }
if(empty($row['externalOptions'])){ if (empty($row['externalOptions'])) {
$row['externalOptions'] = json_encode(array('videoStartSeconds'=>'00:00:00')); $row['externalOptions'] = json_encode(['videoStartSeconds' => '00:00:00']);
} }
$rows[] = $row; $rows[] = $row;
} }
@ -411,14 +422,15 @@ class PlayList extends ObjectYPT {
return $rows; return $rows;
} }
public static function getRandomImageFromPlayList($playlists_id) { public static function getRandomImageFromPlayList($playlists_id)
{
global $global; global $global;
$sql = "SELECT v.* " $sql = "SELECT v.* "
. " FROM playlists_has_videos p " . " FROM playlists_has_videos p "
. " LEFT JOIN videos as v ON videos_id = v.id " . " LEFT JOIN videos as v ON videos_id = v.id "
. " WHERE playlists_id = ? AND v.status != 'i' ORDER BY RAND() . " WHERE playlists_id = ? AND v.status != 'i' ORDER BY RAND()
LIMIT 1"; LIMIT 1";
$res = sqlDAL::readSql($sql, "i", array($playlists_id)); $res = sqlDAL::readSql($sql, "i", [$playlists_id]);
$data = sqlDAL::fetchAssoc($res); $data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if ($res) { if ($res) {
@ -433,23 +445,24 @@ class PlayList extends ObjectYPT {
return false; return false;
} }
public static function isAGroupOfPlayLists($playlists_id) { public static function isAGroupOfPlayLists($playlists_id)
{
$rows = self::getAllSubPlayLists($playlists_id); $rows = self::getAllSubPlayLists($playlists_id);
return count($rows); return count($rows);
} }
public static function getAllSubPlayLists($playlists_id, $NOTSubPlaylists = 0) { public static function getAllSubPlayLists($playlists_id, $NOTSubPlaylists = 0)
{
global $getAllSubPlayLists; global $getAllSubPlayLists;
if (empty($playlists_id)) { if (empty($playlists_id)) {
return false; return false;
} }
if (!isset($getAllSubPlayLists)) { if (!isset($getAllSubPlayLists)) {
$getAllSubPlayLists = array(); $getAllSubPlayLists = [];
} }
if (!isset($getAllSubPlayLists[$playlists_id])) { if (!isset($getAllSubPlayLists[$playlists_id])) {
$getAllSubPlayLists[$playlists_id] = array(); $getAllSubPlayLists[$playlists_id] = [];
} }
if (isset($getAllSubPlayLists[$playlists_id][$NOTSubPlaylists])) { if (isset($getAllSubPlayLists[$playlists_id][$NOTSubPlaylists])) {
return $getAllSubPlayLists[$playlists_id][$NOTSubPlaylists]; return $getAllSubPlayLists[$playlists_id][$NOTSubPlaylists];
@ -465,10 +478,10 @@ class PlayList extends ObjectYPT {
$sql .= ' AND serie_playlists_id IS NOT NULL '; $sql .= ' AND serie_playlists_id IS NOT NULL ';
} }
$res = sqlDAL::readSql($sql, "i", array($playlists_id)); $res = sqlDAL::readSql($sql, "i", [$playlists_id]);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $row) { foreach ($fullData as $row) {
$rows[] = $row; $rows[] = $row;
@ -478,19 +491,23 @@ class PlayList extends ObjectYPT {
return $rows; return $rows;
} }
public static function getAllNOTSubPlayLists($playlists_id) { public static function getAllNOTSubPlayLists($playlists_id)
{
return self::getAllSubPlayLists($playlists_id, 1); return self::getAllSubPlayLists($playlists_id, 1);
} }
public static function isVideoOnFavorite($videos_id, $users_id) { public static function isVideoOnFavorite($videos_id, $users_id)
{
return self::isVideoOn($videos_id, $users_id, 'favorite'); return self::isVideoOn($videos_id, $users_id, 'favorite');
} }
public static function isVideoOnWatchLater($videos_id, $users_id) { public static function isVideoOnWatchLater($videos_id, $users_id)
{
return self::isVideoOn($videos_id, $users_id, 'watch_later'); return self::isVideoOn($videos_id, $users_id, 'watch_later');
} }
private static function isVideoOn($videos_id, $users_id, $status) { private static function isVideoOn($videos_id, $users_id, $status)
{
global $global; global $global;
$status = str_replace("'", "", $status); $status = str_replace("'", "", $status);
@ -500,7 +517,7 @@ class PlayList extends ObjectYPT {
. " LEFT JOIN videos as v ON videos_id = v.id " . " LEFT JOIN videos as v ON videos_id = v.id "
. " WHERE videos_id = ? AND pl.users_id = ? AND pl.status = '{$status}' LIMIT 1 "; . " WHERE videos_id = ? AND pl.users_id = ? AND pl.status = '{$status}' LIMIT 1 ";
//echo $videos_id," - " ,$users_id, $sql; //echo $videos_id," - " ,$users_id, $sql;
$res = sqlDAL::readSql($sql, "ii", array($videos_id, $users_id)); $res = sqlDAL::readSql($sql, "ii", [$videos_id, $users_id]);
$data = sqlDAL::fetchAssoc($res); $data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if ($res) { if ($res) {
@ -512,7 +529,8 @@ class PlayList extends ObjectYPT {
return $row; return $row;
} }
public static function getFavoriteIdFromUser($users_id) { public static function getFavoriteIdFromUser($users_id)
{
global $refreshCacheFromPlaylist; global $refreshCacheFromPlaylist;
$favorite = self::getIdFromUser($users_id, "favorite"); $favorite = self::getIdFromUser($users_id, "favorite");
if (empty($favorite)) { if (empty($favorite)) {
@ -527,7 +545,8 @@ class PlayList extends ObjectYPT {
return $favorite; return $favorite;
} }
public static function getWatchLaterIdFromUser($users_id) { public static function getWatchLaterIdFromUser($users_id)
{
global $refreshCacheFromPlaylist; global $refreshCacheFromPlaylist;
$watch_later = self::getIdFromUser($users_id, "watch_later"); $watch_later = self::getIdFromUser($users_id, "watch_later");
@ -543,13 +562,14 @@ class PlayList extends ObjectYPT {
return $watch_later; return $watch_later;
} }
private static function getIdFromUser($users_id, $status) { private static function getIdFromUser($users_id, $status)
{
global $global; global $global;
$status = str_replace("'", "", $status); $status = str_replace("'", "", $status);
$sql = "SELECT * FROM " . static::getTableName() . " pl WHERE" $sql = "SELECT * FROM " . static::getTableName() . " pl WHERE"
. " users_id = ? AND pl.status = '{$status}' LIMIT 1 "; . " users_id = ? AND pl.status = '{$status}' LIMIT 1 ";
$res = sqlDAL::readSql($sql, "i", array($users_id)); $res = sqlDAL::readSql($sql, "i", [$users_id]);
$data = sqlDAL::fetchAssoc($res); $data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
if ($res && !empty($data)) { if ($res && !empty($data)) {
@ -560,15 +580,16 @@ class PlayList extends ObjectYPT {
return $row; return $row;
} }
public static function getVideosIdFromPlaylist($playlists_id) { public static function getVideosIdFromPlaylist($playlists_id)
{
global $getVideosIdFromPlaylist; global $getVideosIdFromPlaylist;
if (empty($getVideosIdFromPlaylist)) { if (empty($getVideosIdFromPlaylist)) {
$getVideosIdFromPlaylist = array(); $getVideosIdFromPlaylist = [];
} }
if (isset($getVideosIdFromPlaylist[$playlists_id])) { if (isset($getVideosIdFromPlaylist[$playlists_id])) {
return $getVideosIdFromPlaylist[$playlists_id]; return $getVideosIdFromPlaylist[$playlists_id];
} }
$videosId = array(); $videosId = [];
$rows = static::getVideosIDFromPlaylistLight($playlists_id); $rows = static::getVideosIDFromPlaylistLight($playlists_id);
foreach ($rows as $value) { foreach ($rows as $value) {
$videosId[] = $value['videos_id']; $videosId[] = $value['videos_id'];
@ -578,8 +599,9 @@ class PlayList extends ObjectYPT {
return $videosId; return $videosId;
} }
public static function sortVideos($videosList, $listIdOrder) { public static function sortVideos($videosList, $listIdOrder)
$list = array(); {
$list = [];
foreach ($listIdOrder as $value) { foreach ($listIdOrder as $value) {
$found = false; $found = false;
foreach ($videosList as $key => $value2) { foreach ($videosList as $key => $value2) {
@ -594,13 +616,14 @@ class PlayList extends ObjectYPT {
if (empty($v->getFilename())) { if (empty($v->getFilename())) {
continue; continue;
} }
$list[] = array('id' => $value); $list[] = ['id' => $value];
} }
} }
return $list; return $list;
} }
public function save() { public function save()
{
if (!User::isLogged()) { if (!User::isLogged()) {
return false; return false;
} }
@ -619,16 +642,18 @@ class PlayList extends ObjectYPT {
* This is just to fix errors from the update 6.4 to 6.5, where empty playlists were created before the update * This is just to fix errors from the update 6.4 to 6.5, where empty playlists were created before the update
* @return type * @return type
*/ */
private function clearEmptyLists() { private function clearEmptyLists()
{
$sql = "DELETE FROM " . static::getTableName() . " WHERE status = ''"; $sql = "DELETE FROM " . static::getTableName() . " WHERE status = ''";
return sqlDAL::writeSql($sql); return sqlDAL::writeSql($sql);
} }
public function addVideo($videos_id, $add, $order = 0) { public function addVideo($videos_id, $add, $order = 0)
{
global $global; global $global;
$formats = ""; $formats = '';
$values = array(); $values = [];
if (empty($add) || $add === "false") { if (empty($add) || $add === "false") {
$sql = "DELETE FROM playlists_has_videos WHERE playlists_id = ? AND videos_id = ? "; $sql = "DELETE FROM playlists_has_videos WHERE playlists_id = ? AND videos_id = ? ";
$formats = "ii"; $formats = "ii";
@ -648,54 +673,63 @@ class PlayList extends ObjectYPT {
return $result; return $result;
} }
private static function deleteCacheDir($playlists_id){ private static function deleteCacheDir($playlists_id)
{
$tmpDir = ObjectYPT::getCacheDir(); $tmpDir = ObjectYPT::getCacheDir();
$name = "getvideosfromplaylist{$playlists_id}"; $name = "getvideosfromplaylist{$playlists_id}";
$cacheDir = $tmpDir . $name . DIRECTORY_SEPARATOR; $cacheDir = $tmpDir . $name . DIRECTORY_SEPARATOR;
rrmdir($cacheDir); rrmdir($cacheDir);
if(class_exists('CachesInDB')){ if (class_exists('CachesInDB')) {
CachesInDB::_deleteCacheStartingWith($name); CachesInDB::_deleteCacheStartingWith($name);
} }
} }
public function delete() { public function delete()
{
if (empty($this->id)) { if (empty($this->id)) {
return false; return false;
} }
global $global; global $global;
$sql = "DELETE FROM playlists WHERE id = ? "; $sql = "DELETE FROM playlists WHERE id = ? ";
//echo $sql; //echo $sql;
$result = sqlDAL::writeSql($sql, "i", array($this->id)); $result = sqlDAL::writeSql($sql, "i", [$this->id]);
self::deleteCacheDir($this->id); self::deleteCacheDir($this->id);
return $result; return $result;
} }
public function getId() { public function getId()
{
return $this->id; return $this->id;
} }
public function getName() { public function getName()
{
return $this->name; return $this->name;
} }
public function getModified() { public function getModified()
{
return $this->modified; return $this->modified;
} }
public function getUsers_id() { public function getUsers_id()
{
return $this->users_id; return $this->users_id;
} }
public function getStatus() { public function getStatus()
{
return $this->status; return $this->status;
} }
public function setId($id) { public function setId($id)
{
$this->id = $id; $this->id = $id;
} }
public function setName($name) { public function setName($name)
{
if (strlen($name) > 45) { if (strlen($name) > 45) {
$name = substr($name, 0, 42) . '...'; $name = substr($name, 0, 42) . '...';
} }
@ -703,18 +737,21 @@ class PlayList extends ObjectYPT {
//var_dump($name,$this->name);exit; //var_dump($name,$this->name);exit;
} }
public function setUsers_id($users_id) { public function setUsers_id($users_id)
{
$this->users_id = $users_id; $this->users_id = $users_id;
} }
public function setStatus($status) { public function setStatus($status)
{
if (!in_array($status, self::$validStatus)) { if (!in_array($status, self::$validStatus)) {
$status = 'public'; $status = 'public';
} }
$this->status = $status; $this->status = $status;
} }
public static function canSee($playlist_id, $users_id) { public static function canSee($playlist_id, $users_id)
{
$obj = new PlayList($playlist_id); $obj = new PlayList($playlist_id);
$status = $obj->getStatus(); $status = $obj->getStatus();
if ($status !== 'public' && $status !== 'unlisted' && $users_id != $obj->getUsers_id()) { if ($status !== 'public' && $status !== 'unlisted' && $users_id != $obj->getUsers_id()) {
@ -723,7 +760,8 @@ class PlayList extends ObjectYPT {
return true; return true;
} }
public static function getEPG() { public static function getEPG()
{
global $config, $global; global $config, $global;
$encoder = $config->_getEncoderURL(); $encoder = $config->_getEncoderURL();
$url = "{$encoder}view/videosListEPG.php?date_default_timezone=" . urlencode(date_default_timezone_get()); $url = "{$encoder}view/videosListEPG.php?date_default_timezone=" . urlencode(date_default_timezone_get());
@ -732,11 +770,13 @@ class PlayList extends ObjectYPT {
return _json_decode($content); return _json_decode($content);
} }
public function getShowOnTV() { public function getShowOnTV()
{
return intval($this->showOnTV); return intval($this->showOnTV);
} }
public function setShowOnTV($showOnTV) { public function setShowOnTV($showOnTV)
{
if (strtolower($showOnTV) === "false") { if (strtolower($showOnTV) === "false") {
$showOnTV = 0; $showOnTV = 0;
} elseif (strtolower($showOnTV) === "true") { } elseif (strtolower($showOnTV) === "true") {
@ -745,7 +785,8 @@ class PlayList extends ObjectYPT {
$this->showOnTV = intval($showOnTV); $this->showOnTV = intval($showOnTV);
} }
public static function getAllToShowOnTV() { public static function getAllToShowOnTV()
{
global $global; global $global;
if (!static::isTableInstalled()) { if (!static::isTableInstalled()) {
return false; return false;
@ -759,7 +800,7 @@ class PlayList extends ObjectYPT {
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = array(); $rows = [];
if ($res != false) { if ($res != false) {
foreach ($fullData as $row) { foreach ($fullData as $row) {
$row = cleanUpRowFromDatabase($row); $row = cleanUpRowFromDatabase($row);
@ -771,9 +812,10 @@ class PlayList extends ObjectYPT {
return $rows; return $rows;
} }
public static function showPlayListSelector($playListArray) { public static function showPlayListSelector($playListArray)
$collections = array(); {
$videos = array(); $collections = [];
$videos = [];
foreach ($playListArray as $value) { foreach ($playListArray as $value) {
if ($value['type'] === 'serie' && !empty($value['serie_playlists_id'])) { if ($value['type'] === 'serie' && !empty($value['serie_playlists_id'])) {
$collections[] = $value; $collections[] = $value;
@ -791,5 +833,4 @@ class PlayList extends ObjectYPT {
} }
return false; return false;
} }
} }

Some files were not shown because too many files have changed in this diff Show more