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
if (AVideoPlugin::exists('Backup')) {
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>
<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'); ?>
@ -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>
</div>
<?php
$filter = array(
'cloneSiteURL' => __('Place here the URL of the site you want to clone'));
$filter = [
'cloneSiteURL' => __('Place here the URL of the site you want to clone'), ];
echo createTable("CloneSite", $filter);
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)) {
$response = Array(
$response = [
"status" => 'error',
"message" => 'No write Access'
);
"message" => 'No write Access',
];
print json_encode($response);
return;
}
$response = array();
$response = [];
if (!empty($_POST['logoImgBase64'])) {
$fileData = base64DataToImage($_POST['logoImgBase64']);
$fileName = 'logo.png';
$photoURL = $imagePath . $fileName;
$bytes = file_put_contents($global['systemRootPath'] . $photoURL, $fileData);
if ($bytes > 10) {
$response = array(
$response = [
"status" => 'success',
"url" => $global['systemRootPath'] . $photoURL
);
"url" => $global['systemRootPath'] . $photoURL,
];
$config->setLogo($photoURL);
} else {
$response = array(
$response = [
"status" => 'error',
"msg" => 'We could not save logo',
"url" => $global['systemRootPath'] . $photoURL
);
"url" => $global['systemRootPath'] . $photoURL,
];
}
}

View file

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

View file

@ -31,13 +31,13 @@ $delay = 0.2;
<div class="panel-heading">
<?php echo ucfirst($fileEx); ?>
<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" : ""; ?>>
<label for="themeSwitch<?php echo ($fileEx); ?>" class="label-primary"></label>
<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>
</div>
</div>
<div class="panel-body" style="padding: 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>
</div>
</div>

View file

@ -12,8 +12,8 @@
<div class="panel-heading">
<?php echo ucfirst($fileEx); ?>
<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" : ""; ?>>
<label for="themeSwitch<?php echo ($fileEx); ?>" class="label-primary"></label>
<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>
</div>
</div>
<div class="panel-body">

View file

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

View file

@ -1,11 +1,11 @@
<?php
$filter = array(
$filter = [
'useEncoderNetworkRecomendation' => __('Let the encoder network (If configured) choose what is the best encoder to use'),
'doNotShowEncoderResolutionLow' => __('Do not allow encode in Low resolution'),
'doNotShowEncoderResolutionSD' => __('Do not allow encode in SD 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'),
'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);

View file

@ -1,10 +1,10 @@
<?php
$filter = array(
'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'),
'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'),
'doNotShowEncoderButton'=>__('Do not show the button to the encoder'),
'doNotShowEmbedButton'=>__('Check this if you will not use embed videos on your site')
);
$filter = [
'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'),
'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'),
'doNotShowEncoderButton' => __('Do not show the button to the encoder'),
'doNotShowEmbedButton' => __('Check this if you will not use embed videos on your site'),
];
createTable("CustomizeAdvanced", $filter);

View file

@ -1,5 +1,5 @@
<?php
$filter = array(
$filter = [
'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'),
'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'),
'onlyVerifiedEmailCanUpload'=>__('Users must verify their emails before upload/submit videos'),
'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);

View file

@ -1,37 +1,37 @@
<?php
function _isAPPInstalled($appName) {
function _isAPPInstalled($appName)
{
$appName = preg_replace('/[^a-z0-9_-]/i', '', $appName);
return trim(shell_exec("which {$appName}"));
}
$phpExtensions = array();
$phpExtensions[] = array('pdo_mysql');
$phpExtensions[] = array('curl');
$phpExtensions[] = array('gd', 'Important to generate images');
$phpExtensions[] = array('xml', 'Important to get the live stats');
$phpExtensions[] = array('zip', 'Important handle HLS files');
$phpExtensions = [];
$phpExtensions[] = ['pdo_mysql'];
$phpExtensions[] = ['curl'];
$phpExtensions[] = ['gd', 'Important to generate images'];
$phpExtensions[] = ['xml', 'Important to get the live stats'];
$phpExtensions[] = ['zip', 'Important handle HLS files'];
// $phpExtensions[] = array('mbstring'); // I could not detect that
$apacheModules = array();
$apacheModules[] = array('mod_php');
$apacheModules[] = array('mod_xsendfile', 'https://github.com/WWBN/AVideo/wiki/Install-Apache-XSendFIle');
$apacheModules[] = array('mod_rewrite');
$apacheModules[] = array('mod_expires', 'Important for CDN and cache configuration');
$apacheModules[] = array('mod_headers', 'Important for CDN and cache configuration');
$apacheModules = [];
$apacheModules[] = ['mod_php'];
$apacheModules[] = ['mod_xsendfile', 'https://github.com/WWBN/AVideo/wiki/Install-Apache-XSendFIle'];
$apacheModules[] = ['mod_rewrite'];
$apacheModules[] = ['mod_expires', 'Important for CDN and cache configuration'];
$apacheModules[] = ['mod_headers', 'Important for CDN and cache configuration'];
$linuxApps = array();
$linuxApps[] = array('mysql');
$linuxApps[] = array('ffmpeg');
$linuxApps[] = array('git');
$linuxApps[] = array('exiftool');
$linuxApps[] = array('unzip');
$linuxApps[] = array('youtube-dl');
$linuxApps[] = array('sshpass', 'https://github.com/WWBN/AVideo/wiki/Clone-Site-Plugin#the-process-with-rsync-support-hls');
$linuxApps[] = array('apache2');
$linuxApps = [];
$linuxApps[] = ['mysql'];
$linuxApps[] = ['ffmpeg'];
$linuxApps[] = ['git'];
$linuxApps[] = ['exiftool'];
$linuxApps[] = ['unzip'];
$linuxApps[] = ['youtube-dl'];
$linuxApps[] = ['sshpass', 'https://github.com/WWBN/AVideo/wiki/Clone-Site-Plugin#the-process-with-rsync-support-hls'];
$linuxApps[] = ['apache2'];
$messages = array('Server' => array(), 'PHP' => array(), 'Apache' => array());
$messages = ['Server' => [], 'PHP' => [], 'Apache' => []];
$version = phpversion();
$phpMinVersion = '7.3.0';
if (strnatcmp($version, $phpMinVersion) >= 0) {
@ -46,7 +46,7 @@ foreach ($phpExtensions as $value) {
if (in_array($value[0], $extensions)) {
$messages['PHP'][] = $value[0];
} 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"])) {
$messages['Apache'][] = "HTTPS is enabled";
} 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());
//var_dump($mods);
foreach ($apacheModules as $value) {
@ -74,13 +74,13 @@ if(function_exists('apache_get_modules')){
if ($found) {
$messages['Apache'][] = $found;
} else {
$messages['Apache'][] = array($value[0], @$value[1]);
$messages['Apache'][] = [$value[0], @$value[1]];
}
}
}
}else{
} else {
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)) {
$messages['Server'][] = "{$value[0]} is installed here {$response}";
} else {
$messages['Server'][] = array("{$value[0]} is NOT installed", @$value[1]);
$messages['Server'][] = ["{$value[0]} is NOT installed", @$value[1]];
}
}
$videosDir = getVideosDir();
if (is_writable($videosDir)) {
$messages['Server'][] = "{$videosDir} is writable";
} 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'])) {
$messages['Server'][] = "Log file is writable";
} 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/";
if (is_writable($cacheDir)) {
$messages['Server'][] = "Cache is writable";
} 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;
@ -118,14 +118,14 @@ $df = disk_free_space("/");
if ($df > $_50GB) {
$messages['Server'][] = "You have enough free disk space " . humanFileSize($df);
} 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);
if ($dfVideos > $_50GB) {
$messages['Server'][] = "You have enough free disk space for the videos directory " . humanFileSize($dfVideos);
} 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);
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 {
$verified = json_decode($result);
if (!empty($verified->verified)) {
$messages['Server'][] = "Server Checked from outside: <br>" . implode('<br>', $verified->msg);
} else {
$messages['Server'][] = array("Something is wrong: ", implode('<br>', $verified->msg));
$messages['Server'][] = ["Something is wrong: ", implode('<br>', $verified->msg)];
}
/*
if(!empty($verified->screenshot)){
@ -181,18 +181,17 @@ if (empty($result)) {
<div class="alert alert-danger">
<i class="fas fa-times"></i> <?php
echo $value[0];
if (!empty($value[1])) {
if (preg_match('/^http/i', $value[1])) {
?>
if (!empty($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>
<?php
} else {
?>
} else {
?>
<br><code><?php echo $value[1]; ?></code>
<?php
}
}
?>
}
} ?>
</div>
</div>
<?php
@ -201,8 +200,7 @@ if (empty($result)) {
<div class="col-lg-4 col-md-6 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>">
<div class="alert alert-success">
<i class="fas fa-check"></i> <?php
echo $value;
?>
echo $value; ?>
</div>
</div>
<?php
@ -235,18 +233,17 @@ if (empty($result)) {
<div class="alert alert-danger">
<i class="fas fa-times"></i> <?php
echo $value[0];
if (!empty($value[1])) {
if (preg_match('/^http/i', $value[1])) {
?>
if (!empty($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>
<?php
} else {
?>
} else {
?>
<br><code><?php echo $value[1]; ?></code>
<?php
}
}
?>
}
} ?>
</div>
</div>
<?php
@ -255,8 +252,7 @@ if (empty($result)) {
<div class="col-sm-12 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>">
<div class="alert alert-success">
<i class="fas fa-check"></i> <?php
echo $value;
?>
echo $value; ?>
</div>
</div>
<?php
@ -283,18 +279,17 @@ if (empty($result)) {
<div class="alert alert-danger">
<i class="fas fa-times"></i> <?php
echo $value[0];
if (!empty($value[1])) {
if (preg_match('/^http/i', $value[1])) {
?>
if (!empty($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>
<?php
} else {
?>
} else {
?>
<br><code><?php echo $value[1]; ?></code>
<?php
}
}
?>
}
} ?>
</div>
</div>
<?php
@ -303,8 +298,7 @@ if (empty($result)) {
<div class="col-sm-12 <?php echo getCSSAnimationClassAndStyle('animate__flipInX'); ?>">
<div class="alert alert-success">
<i class="fas fa-check"></i> <?php
echo $value;
?>
echo $value; ?>
</div>
</div>
<?php

View file

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

View file

@ -4,10 +4,10 @@
<div class="panel-heading"><i class="fa fa-cog"></i> Subscription Configuration </div>
<div class="panel-body" style="overflow: hidden;">
<?php
$filter = array(
$filter = [
'displayTopBarSubscribeButton' => 'Show a button on the top 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);
?>
</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-body">
<?php
$filter = array(
$filter = [
'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>
@ -19,13 +19,13 @@
<div class="panel-heading"><?php echo __('Wallet') ?> <div class="pull-right"><?php echo getPluginSwitch('YPTWallet'); ?></div></div>
<div class="panel-body">
<?php
$filter = array(
$filter = [
'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_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',
'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);
?>
</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-body" style="overflow: hidden;">
<?php
$filter = array(
$filter = [
'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_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'),
'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);
?>
</div>

View file

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

View file

@ -18,9 +18,9 @@ if (empty($_POST['pluginsList'])) {
} else {
$pluginsList = explode("|", $_POST['pluginsList']);
$pluginValues = array();
$pluginValues = [];
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) {
if (isset($pluginValues[$key])) {
if (is_bool($pluginDO->$key)) {
$pluginDO->$key = empty($pluginValues[$key])?false:true;
$pluginDO->$key = empty($pluginValues[$key]) ? false : true;
} else {
//$pluginDO->$key = str_replace('"', '\\"', $pluginValues[$key]);
$pluginDO->$key = $pluginValues[$key];
@ -43,6 +43,8 @@ $p->setObject_data(json_encode($pluginDO));
$obj = new stdClass();
$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-body" style="overflow: hidden;">
<?php
$filter = array(
$filter = [
'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'),
'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);
?>
</div>

View file

@ -13,7 +13,7 @@ $showOnlyLoggedUserVideos = false;
$title = $config->getWebSiteTitle();
$link = $global['webSiteRootURL'];
$logo = getCDN()."videos/userPhoto/logo.png";
$description = "";
$description = '';
$extraPluginFile = $global['systemRootPath'] . 'plugin/Customize/Objects/ExtraConfig.php';
if (file_exists($extraPluginFile) && AVideoPlugin::isEnabledByName("Customize")) {
@ -22,7 +22,7 @@ if (file_exists($extraPluginFile) && AVideoPlugin::isEnabledByName("Customize"))
$description = $ec->getDescription();
}
if(!empty($_GET['channelName'])){
if (!empty($_GET['channelName'])) {
$user = User::getChannelOwner($_GET['channelName']);
$showOnlyLoggedUserVideos = $user['id'];
$title = User::getNameIdentificationById($user['id']);
@ -32,23 +32,22 @@ if(!empty($_GET['channelName'])){
$cacheName = "feedCache".json_encode($_GET);
$rows = ObjectYPT::getCache($cacheName, 0);
if(empty($rows)){
if (empty($rows)) {
// send $_GET['catName'] to be able to filter by category
$rows = Video::getAllVideos("viewable", $showOnlyLoggedUserVideos);
ObjectYPT::setCache($cacheName, $rows);
}else{
} else {
$rows = object_to_array($rows);
}
if(!empty($_REQUEST['roku'])){
if (!empty($_REQUEST['roku'])) {
include $global['systemRootPath'] . 'feed/roku.json.php';
}else if(empty($_REQUEST['mrss'])){
} elseif (empty($_REQUEST['mrss'])) {
include $global['systemRootPath'] . 'feed/rss.php';
}else{
} else {
include $global['systemRootPath'] . 'feed/mrss.php';
}
function feedText($text){
return str_replace(array('&&'), array('&'), str_replace(array('&','<','>'), array('&amp;','&lt;','&gt;'), (strip_tags(br2nl($text)))));
function feedText($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);
if (empty($feed)) {
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/"
xmlns:georss="http://www.georss.org/georss"
xmlns:gml="http://www.opengis.net/gml">
@ -29,7 +28,7 @@ if (empty($feed)) {
foreach ($rows as $row) {
$video = Video::getVideoFromFileName($row['filename']);
$files = getVideosURL($row['filename']);
$enclosure = "";
$enclosure = '';
$videoSource = Video::getSourceFileURL($row['filename']);
if (empty($videoSource)) {
continue;
@ -44,8 +43,7 @@ if (empty($feed)) {
$enclosure = '<enclosure url="' . $value['url'] . '" length="' . $value['size'] . '" type="' . $value['mime'] . '" />';
break;
}
}
?>
} ?>
<item>
<title><?php echo feedText($row['title']); ?></title>
<description><?php echo feedText($row['title']); ?></description>
@ -65,8 +63,7 @@ if (empty($feed)) {
<media:status state="active" />
</item>
<?php
}
?>
} ?>
</channel>
</rss>
<?php
@ -74,12 +71,11 @@ if (empty($feed)) {
ob_end_clean();
//var_dump($cacheFeedName, $feed);exit;
ObjectYPT::setCache($cacheFeedName, $feed);
//echo '<!-- NO cache -->';
}else{
//echo '<!-- NO cache -->';
} else {
//echo '<!-- cache -->';
}
if(!is_string($feed)){
if (!is_string($feed)) {
$feed = json_encode($feed);
}
echo $feed;
?>

View file

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

View file

@ -33,7 +33,7 @@ if (empty($feed)) {
<?php
foreach ($rows as $row) {
$files = getVideosURL($row['filename']);
$enclosure = "";
$enclosure = '';
foreach ($files as $value) {
if ($value["type"] === "video" && file_exists($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'] . '" />';
break;
}
}
?>
} ?>
<item>
<title><?php echo feedText($row['title']); ?></title>
<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>
</item>
<?php
}
?>
} ?>
</channel>
</rss>
<?php
$feed = ob_get_contents();
ob_end_clean();
ObjectYPT::setCache($cacheFeedName, $feed);
}else{
} else {
//echo '<!-- cache -->';
}
if(!is_string($feed)){
if (!is_string($feed)) {
$feed = json_encode($feed);
}
echo $feed;
?>

View file

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

View file

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

View file

@ -34,7 +34,7 @@ error_log("Installation: ".__LINE__);
if ($_POST['createTables'] == 2) {
$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;
echo json_encode($obj);
exit;
@ -55,33 +55,34 @@ error_log("Installation: ".__LINE__);
error_log("Installation: ".__LINE__);
if ($_POST['createTables'] > 0) {
error_log("Installation: ".__LINE__);
// Temporary variable, used to store current query
// Temporary variable, used to store current query
$templine = '';
$installFile = "{$_POST['systemRootPath']}install/database.sql";
if(!file_exists($installFile)){
if (!file_exists($installFile)) {
$obj->error = "File Not found {$installFile}";
echo json_encode($obj);
exit;
}
error_log("Installation: ".__LINE__);
// Read in entire file
// Read in entire file
$lines = file($installFile);
if(empty($lines)){
if (empty($lines)) {
$obj->error = "File is empty {$installFile}";
echo json_encode($obj);
exit;
}
error_log("Installation: ".__LINE__);
// Loop through each line
$obj->error = "";
// Loop through each line
$obj->error = '';
foreach ($lines as $line) {
// Skip it if it's a comment
if (substr($line, 0, 2) == '--' || $line == '')
// Skip it if it's a comment
if (substr($line, 0, 2) == '--' || $line == '') {
continue;
}
// Add this line to the current segment
// Add this line to the current segment
$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) == ';') {
// Perform the query
//error_log("Installation: ".$templine);
@ -99,7 +100,7 @@ if ($_POST['createTables'] > 0) {
error_log("Installation: ".__LINE__);
$sql = "DELETE FROM users WHERE id = 1 ";
if ($mysqli->query($sql) !== TRUE) {
if ($mysqli->query($sql) !== true) {
$obj->error = "Error deleting user: " . $mysqli->error;
echo json_encode($obj);
exit;
@ -108,7 +109,7 @@ if ($mysqli->query($sql) !== TRUE) {
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)";
if ($mysqli->query($sql) !== TRUE) {
if ($mysqli->query($sql) !== true) {
$obj->error = "Error creating admin user: " . $mysqli->error;
echo json_encode($obj);
exit;
@ -116,7 +117,7 @@ if ($mysqli->query($sql) !== TRUE) {
error_log("Installation: ".__LINE__);
$sql = "DELETE FROM categories WHERE id = 1 ";
if ($mysqli->query($sql) !== TRUE) {
if ($mysqli->query($sql) !== true) {
$obj->error = "Error deleting category: " . $mysqli->error;
echo json_encode($obj);
exit;
@ -124,7 +125,7 @@ if ($mysqli->query($sql) !== TRUE) {
error_log("Installation: ".__LINE__);
$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;
echo json_encode($obj);
exit;
@ -132,7 +133,7 @@ if ($mysqli->query($sql) !== TRUE) {
error_log("Installation: ".__LINE__);
$sql = "DELETE FROM configurations WHERE id = 1 ";
if ($mysqli->query($sql) !== TRUE) {
if ($mysqli->query($sql) !== true) {
$obj->error = "Error deleting configuration: " . $mysqli->error;
echo json_encode($obj);
exit;
@ -141,14 +142,14 @@ if ($mysqli->query($sql) !== TRUE) {
error_log("Installation: ".__LINE__);
$encoder = 'https://encoder1.avideo.com/';
if(is_dir("{$_POST['systemRootPath']}Encoder")){
if (is_dir("{$_POST['systemRootPath']}Encoder")) {
$encoder = "{$_POST['webSiteRootURL']}Encoder/";
}
$sql = "INSERT INTO configurations (id, video_resolution, users_id, version, webSiteTitle, language, contactEmail, encoderURL, created, modified) "
. " VALUES "
. " (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;
echo json_encode($obj);
exit;
@ -156,7 +157,7 @@ if ($mysqli->query($sql) !== TRUE) {
error_log("Installation: ".__LINE__);
$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;
echo json_encode($obj);
exit;
@ -166,7 +167,7 @@ if ($mysqli->query($sql) !== TRUE) {
error_log("Installation: ".__LINE__);
$mysqli->close();
if(empty($_POST['salt'])){
if (empty($_POST['salt'])) {
$_POST['salt'] = uniqid();
}
$content = "<?php

View file

@ -1,5 +1,4 @@
<?php
//streamer config
require_once '../videos/configuration.php';
@ -7,11 +6,11 @@ if (!isCommandLineInterface()) {
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';
$path = getVideosDir();
$files = array_diff(scandir($path), array('.', '..'));
$files = array_diff(scandir($path), ['.', '..']);
echo "*** Total filenames " . count($files) . "\n";
foreach ($files as $key => $value) {
$dir = "{$path}{$value}";
@ -26,7 +25,7 @@ foreach ($files as $key => $value) {
//echo "+++ Video FOUND for filename {$filename} ".PHP_EOL;
unset($files[$key]);
} else {
$files[$key] = array($value, $dir);
$files[$key] = [$value, $dir];
//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;
unset($files[$key]);
} else {
$files[$key] = array($value, $dir);
$files[$key] = [$value, $dir];
//echo "*** Video NOT found for filename {$filename} ".PHP_EOL;
}
} else {
@ -75,8 +74,7 @@ if (!empty($confirm) && strtolower($confirm) === 'y') {
} else {
echo "$value[1] Directory Could Not be Deleted \n";
}
} else
if (unlink($value[1])) {
} elseif (unlink($value[1])) {
echo "$value[1] Deleted \n";
} else {
echo "$value[1] Could Not be Deleted \n";

View file

@ -1,5 +1,4 @@
<?php
//streamer config
require_once '../videos/configuration.php';
@ -12,34 +11,33 @@ if (empty($p)) {
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/*", GLOB_BRACE) as $filename) {
$base = basename($filename);
if (is_dir($filename)) {
if (strpos($base, "_YPTuniqid_") !== false) {
$files[$base] = array($base, $filename);
$files[$base] = [$base, $filename];
}
} else {
$baseName = explode("_portrait", $base);
if (!empty($baseName[1])) {
$files[$base] = array($baseName[0], $filename);
$files[$base] = [$baseName[0], $filename];
} else {
$baseName = explode("_thumbs", $base);
if (!empty($baseName[1])) {
$files[$base] = array($baseName[0], $filename);
$files[$base] = [$baseName[0], $filename];
} else {
$types = array('_HD', '_Low', '_SD');
$types = ['_HD', '_Low', '_SD'];
$notFound = true;
foreach ($types as $value) {
$baseName = explode($value, $base);
if (!empty($baseName[1])) {
$files[$base] = array($baseName[0], $filename);
$files[$base] = [$baseName[0], $filename];
$notFound = false;
}
}
@ -51,7 +49,7 @@ foreach (glob("../videos/*", GLOB_BRACE) as $filename) {
$baseName = str_replace("." . $value, "", $base);
if (!empty($baseName[1])) {
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;
$count = 0;
$countExecuted = 0;
$checkedFiles = array();
$checkedFiles = [];
foreach ($files as $key => $value) {
if (!empty($checkedFiles[$value[0]])) {
continue;
}
$checkedFiles[$value[0]] = array(true);
$checkedFiles[$value[0]] = [true];
$getUsageFromFilename = YPTStorage::getUsageFromFilename($value[0]);
$checkedFiles[$value[0]][] = $getUsageFromFilename;
@ -95,14 +93,14 @@ foreach ($files as $key => $value) {
}
YPTStorage::createDummy($video['id']);
$tgzFile = $global['systemRootPath'] . "videos/{$video['filename']}.tgz";
if(file_exists($tgzFile)){
if (file_exists($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";
//exit;
} else if($source_sizee > 5000000){
//exit;
} 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";
} 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";
}
} else {

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,6 @@
<?php
require_once '../objects/functions.php';
require_once '../locale/function.php';
//var_dump($_SERVER);exit;
?>
<!DOCTYPE html>
@ -28,8 +25,7 @@ require_once '../locale/function.php';
<body>
<?php
if (file_exists('../videos/configuration.php')) {
require_once '../videos/configuration.php';
?>
require_once '../videos/configuration.php'; ?>
<div class="container">
<h3 class="alert alert-success">
<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>
</div>
<?php
}
?>
} ?>
<?php
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>
</div>
<?php
}
?>
} ?>
<?php
if (checkVideosDir()) {
@ -99,14 +93,13 @@ require_once '../locale/function.php';
<details>
<?php
$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!
<br>
<pre><code>sudo mkdir <?php echo $dir; ?></code></pre>
<?php
}
?>
} ?>
<br>
Then you can set the permissions (www-data means apache user).
<br>
@ -115,11 +108,10 @@ require_once '../locale/function.php';
</div>
<?php
}
$pathToPHPini = php_ini_loaded_file();
if (empty($pathToPHPini)) {
$pathToPHPini = "/etc/php/7.0/cli/php.ini";
}
?>
$pathToPHPini = php_ini_loaded_file();
if (empty($pathToPHPini)) {
$pathToPHPini = "/etc/php/7.0/cli/php.ini";
} ?>
<?php
if (check_post_max_size()) {
@ -142,8 +134,7 @@ require_once '../locale/function.php';
</details>
</div>
<?php
}
?>
} ?>
<?php
if (check_upload_max_filesize()) {
@ -166,8 +157,7 @@ require_once '../locale/function.php';
</details>
</div>
<?php
}
?>
} ?>
</div>
</div>
</div>
@ -195,25 +185,24 @@ require_once '../locale/function.php';
<select class="selectpicker" id="mainLanguage">
<?php
global $global;
include_once '../objects/bcp47.php';
$dir = "../locale/";
$flags = array();
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != '.' && $entry != '..' && $entry != 'index.php' && $entry != 'function.php' && $entry != 'save.php') {
$flags[] = str_replace('.php', '', $entry);
}
}
closedir($handle);
}
sort($flags);
include_once '../objects/bcp47.php';
$dir = "../locale/";
$flags = [];
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != '.' && $entry != '..' && $entry != 'index.php' && $entry != 'function.php' && $entry != 'save.php') {
$flags[] = str_replace('.php', '', $entry);
}
}
closedir($handle);
}
sort($flags);
foreach ($flags as $flag) {
//var_dump($global['bcp47'][$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>";
}
?>
foreach ($flags as $flag) {
//var_dump($global['bcp47'][$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>";
} ?>
</select>
</div>
</div>
@ -224,14 +213,12 @@ require_once '../locale/function.php';
<div class="form-group">
<label for="systemAdminPass">System Admin password</label>
<?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 class="form-group">
<label for="confirmSystemAdminPass">Confirm System Admin password</label>
<?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>
@ -256,8 +243,7 @@ require_once '../locale/function.php';
<div class="form-group">
<label for="databasePass">Database Password</label>
<?php
getInputPassword("databasePass", 'class="form-control"', __("Enter Database Password"));
?>
getInputPassword("databasePass", 'class="form-control"', __("Enter Database Password")); ?>
</div>
<div class="form-group">
<label for="databaseName">Database Name</label>
@ -281,7 +267,8 @@ require_once '../locale/function.php';
</div>
</div>
<?php } ?>
<?php
} ?>
<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/bootstrap/bootstrapSelectPicker/js/bootstrap-select.min.js" type="text/javascript"></script>

View file

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

View file

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

View file

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

View file

@ -2,7 +2,7 @@
//streamer config
require_once '../videos/configuration.php';
if(!isCommandLineInterface()){
if (!isCommandLineInterface()) {
return die('Command Line only');
}
echo "Enter the username or press enter to skip:";
@ -10,18 +10,18 @@ echo "\n";
ob_flush();
$userName = trim(readline(""));
if(!empty($userName)){
if (!empty($userName)) {
$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();
$insert_row = sqlDAL::writeSql($sql);
if($insert_row){
if ($insert_row) {
echo "Your user {$userName} is admin now";
echo "\n";
die();
}
}else{
} else {
echo "User ({$userName}) Not found";
echo "\n";
die();
@ -30,7 +30,3 @@ if(!empty($userName)){
echo "Bye";
echo "\n";
die();

View file

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

View file

@ -1,5 +1,4 @@
<?php
//streamer config
require_once '../videos/configuration.php';
@ -25,7 +24,7 @@ foreach ($videos as $value) {
echo " {$count}/{$total} Searching {$basename} ".PHP_EOL;
$glob = glob("{$basename}*");
$totalItems = count($glob);
if($totalItems){
if ($totalItems) {
echo "Creating dir {$basename} " . PHP_EOL;
make_path(addLastSlash($basename));
}
@ -36,11 +35,11 @@ foreach ($videos as $value) {
$countItems++;
echo "[$countItems/$totalItems] Process file {$file} " . PHP_EOL;
if (is_dir($file)) {
if(!$isStorage && !Video::isNewVideoFilename($move['oldDir'])){
if (!$isStorage && !Video::isNewVideoFilename($move['oldDir'])) {
//echo $file.PHP_EOL;
$move = Video::updateDirectoryFilename($file);
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;
}
continue;
@ -48,9 +47,9 @@ foreach ($videos as $value) {
$filename = basename($file);
$newname = Video::getPathToFile($filename);
$renamed = rename($file, $newname);
if($renamed){
if ($renamed) {
echo "{$count}/{$total} moved $filename to $newname" . PHP_EOL;
}else{
} else {
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}");
echo PHP_EOL." Done! ".PHP_EOL;
die();

View file

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

View file

@ -1,5 +1,4 @@
<?php
//streamer config
require_once '../videos/configuration.php';
@ -7,25 +6,25 @@ if (!isCommandLineInterface()) {
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/*", GLOB_BRACE) as $filename) {
$base = basename($filename);
if (is_dir($filename)) {
if (strpos($base, "_YPTuniqid_") !== false) {
$files[$base] = array($base, $filename);
$files[$base] = [$base, $filename];
}
} else {
$types = array('_HD', '_Low', '_SD');
$types = ['_HD', '_Low', '_SD'];
$notFound = true;
foreach ($types as $value) {
$baseName = explode($value, $base);
if (!empty($baseName[1])) {
$files[$base] = array($baseName[0], $filename);
$files[$base] = [$baseName[0], $filename];
$notFound = false;
}
}
@ -37,7 +36,7 @@ foreach (glob("../videos/*", GLOB_BRACE) as $filename) {
$baseName = str_replace("." . $value, "", $base);
if (!empty($baseName[1])) {
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->setStatus(Video::$statusActive);
$video->setUsers_id(1);
if($video->save(false, true)){
if ($video->save(false, true)) {
echo "{$count}/{$total} {$title} created\n";
}else{
} else {
echo "{$count}/{$total} ERROR on create video {$title}\n";
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,22 +2,18 @@
//streamer config
require_once '../videos/configuration.php';
if(!isCommandLineInterface()){
if (!isCommandLineInterface()) {
return die('Command Line only');
}
$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);
$count = 0;
foreach ($videos as $value){
foreach ($videos as $value) {
$count++;
$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();
}
die();

View file

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

View file

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

View file

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

View file

@ -221,57 +221,57 @@ class Mobile_Detect
*
* @deprecated since version 2.6.9
*/
const DETECTION_TYPE_MOBILE = 'mobile';
public const DETECTION_TYPE_MOBILE = 'mobile';
/**
* Extended detection type.
*
* @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.
*
* @deprecated since version 2.6.9
*/
const VER = '([\w._\+]+)';
public const VER = '([\w._\+]+)';
/**
* Top-level device.
*/
const MOBILE_GRADE_A = 'A';
public const MOBILE_GRADE_A = 'A';
/**
* Mid-level device.
*/
const MOBILE_GRADE_B = 'B';
public const MOBILE_GRADE_B = 'B';
/**
* Low-level device.
*/
const MOBILE_GRADE_C = 'C';
public const MOBILE_GRADE_C = 'C';
/**
* 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.
*/
const VERSION_TYPE_STRING = 'text';
public const VERSION_TYPE_STRING = 'text';
/**
* 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
* @var array
*/
protected $cache = array();
protected $cache = [];
/**
* 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.
* @var array
*/
protected $httpHeaders = array();
protected $httpHeaders = [];
/**
* CloudFront headers. E.g. CloudFront-Is-Desktop-Viewer, CloudFront-Is-Mobile-Viewer & CloudFront-Is-Tablet-Viewer.
* @var array
*/
protected $cloudfrontHeaders = array();
protected $cloudfrontHeaders = [];
/**
* The matching Regex.
@ -321,16 +321,16 @@ class Mobile_Detect
*
* @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/
'application/x-obml2d',
// BlackBerry devices.
'application/vnd.rim.html',
'text/vnd.wap.wml',
'application/vnd.wap.xhtml+xml'
)),
'application/vnd.wap.xhtml+xml',
]],
'HTTP_X_WAP_PROFILE' => null,
'HTTP_X_WAP_CLIENTID' => null,
'HTTP_WAP_CONNECTION' => null,
@ -348,15 +348,15 @@ class Mobile_Detect
// Seen this on HTC Sensation. SensationXE_Beats_Z715e.
'HTTP_X_ATT_DEVICEID' => null,
// Seen this on a HTC.
'HTTP_UA_CPU' => array('matches' => array('ARM')),
);
'HTTP_UA_CPU' => ['matches' => ['ARM']],
];
/**
* List of mobile devices (phones).
*
* @var array
*/
protected static $phoneDevices = array(
protected static $phoneDevices = [
'iPhone' => '\biPhone\b|\biPod\b', // |\biTunes
'BlackBerry' => 'BlackBerry|\bBB10\b|rim[0-9]+|\b(BBA100|BBB100|BBD100|BBE100|BBF100|STH100)\b-[0-9]+',
'Pixel' => '; \bPixel\b',
@ -400,14 +400,14 @@ class Mobile_Detect
'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
'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.
*
* @var array
*/
protected static $tabletDevices = array(
protected static $tabletDevices = [
// @todo: check for mobile friendly emails topic.
'iPad' => 'iPad|iPad.*Mobile',
// Removed |^.*Android.*Nexus(?!(?:Mobile).)*$
@ -667,15 +667,15 @@ class Mobile_Detect
'Hudl' => 'Hudl HT7S3|Hudl 2',
// http://www.telstra.com.au/home-phone/thub-2/
'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.
*
* @var array
*/
protected static $operatingSystems = array(
protected static $operatingSystems = [
'AndroidOS' => 'Android',
'BlackBerryOS' => 'blackberry|\bBB10\b|rim tablet os',
'PalmOS' => 'PalmOS|avantgo|blazer|elaine|hiptop|palm|plucker|xiino',
@ -704,7 +704,7 @@ class Mobile_Detect
'webOS' => 'webOS|hpwOS',
'badaOS' => '\bBada\b',
'BREWOS' => 'BREW',
);
];
/**
* List of mobile User Agents.
@ -716,7 +716,7 @@ class Mobile_Detect
*
* @var array
*/
protected static $browsers = array(
protected static $browsers = [
//'Vivaldi' => 'Vivaldi',
// @reference: https://developers.google.com/chrome/mobile/docs/user-agent
'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',
// @reference: https://en.wikipedia.org/wiki/Pale_Moon_(web_browser)
'PaleMoon' => 'Android.*PaleMoon|Mobile.*PaleMoon',
);
];
/**
* Utilities.
*
* @var array
*/
protected static $utilities = array(
protected static $utilities = [
// Experimental. When a mobile device wants to switch to 'Desktop Mode'.
// http://scottcate.com/technology/windows-phone-8-ie10-desktop-or-mobile/
// https://github.com/serbanghita/Mobile-Detect/issues/57#issuecomment-15024011
@ -776,7 +776,7 @@ class Mobile_Detect
// @todo: Include JXD consoles.
'Console' => '\b(Nintendo|Nintendo WiiU|Nintendo 3DS|Nintendo Switch|PLAYSTATION|Xbox)\b',
'Watch' => 'SM-V700',
);
];
/**
* All possible HTTP headers that represent the
@ -784,7 +784,7 @@ class Mobile_Detect
*
* @var array
*/
protected static $uaHttpHeaders = array(
protected static $uaHttpHeaders = [
// The default User-Agent string.
'HTTP_USER_AGENT',
// Header can occur on devices using Opera Mini.
@ -795,8 +795,8 @@ class Mobile_Detect
'HTTP_X_SKYFIRE_PHONE',
'HTTP_X_BOLT_PHONE_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
@ -804,7 +804,7 @@ class Mobile_Detect
*
* @var array
*/
protected static $properties = array(
protected static $properties = [
// Build
'Mobile' => 'Mobile/[VER]',
@ -820,23 +820,23 @@ class Mobile_Detect
'Kindle' => 'Kindle/[VER]',
// Browser
'Chrome' => array('Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'),
'Coast' => array('Coast/[VER]'),
'Chrome' => ['Chrome/[VER]', 'CriOS/[VER]', 'CrMo/[VER]'],
'Coast' => ['Coast/[VER]'],
'Dolfin' => 'Dolfin/[VER]',
// @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]',
// 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
'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
'NetFront' => 'NetFront/[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 Mobi' => 'Version/[VER]',
'UCBrowser' => array( 'UCWEB[VER]', 'UC.*Browser/[VER]' ),
'UCBrowser' => [ 'UCWEB[VER]', 'UC.*Browser/[VER]' ],
'MQQBrowser' => 'MQQBrowser/[VER]',
'MicroMessenger' => 'MicroMessenger/[VER]',
'baiduboxapp' => 'baiduboxapp/[VER]',
@ -845,7 +845,7 @@ class Mobile_Detect
'Iron' => 'Iron/[VER]',
// @note: Safari 7534.48.3 is actually Version 5.1.
// @note: On BlackBerry the Version is overwriten by the OS.
'Safari' => array( 'Version/[VER]', 'Safari/[VER]' ),
'Safari' => [ 'Version/[VER]', 'Safari/[VER]' ],
'Skyfire' => 'Skyfire/[VER]',
'Tizen' => 'Tizen/[VER]',
'Webkit' => 'webkit[ /][VER]',
@ -862,19 +862,19 @@ class Mobile_Detect
'iOS' => ' \bi?OS\b [VER][ ;]{1}',
'Android' => 'Android [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]',
'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://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 CE' => 'Windows CE/[VER]',
// http://social.msdn.microsoft.com/Forums/en-US/windowsdeveloperpreviewgeneral/thread/6be392da-4d2f-41b4-8354-8dcee20c85cd
'Windows NT' => 'Windows NT [VER]',
'Symbian' => array('SymbianOS/[VER]', 'Symbian/[VER]'),
'webOS' => array('webOS/[VER]', 'hpwOS/[VER];'),
);
'Symbian' => ['SymbianOS/[VER]', 'Symbian/[VER]'],
'webOS' => ['webOS/[VER]', 'hpwOS/[VER];'],
];
/**
* Construct an instance of this class.
@ -919,7 +919,7 @@ class Mobile_Detect
}
// clear existing headers
$this->httpHeaders = array();
$this->httpHeaders = [];
// Only save HTTP headers. In PHP land, that means only _SERVER vars that
// start with HTTP_.
@ -999,14 +999,15 @@ class Mobile_Detect
*
* @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
if (!is_array($cfHeaders) || !count($cfHeaders)) {
$cfHeaders = $_SERVER;
}
// clear existing headers
$this->cloudfrontHeaders = array();
$this->cloudfrontHeaders = [];
// Only save CLOUDFRONT headers. In PHP land, that means only _SERVER vars that
// start with cloudfront-.
@ -1035,7 +1036,8 @@ class Mobile_Detect
* @param string $userAgent
* @return string
*/
private function prepareUserAgent($userAgent) {
private function prepareUserAgent($userAgent)
{
$userAgent = trim($userAgent);
$userAgent = substr($userAgent, 0, 500);
return $userAgent;
@ -1051,7 +1053,7 @@ class Mobile_Detect
public function setUserAgent($userAgent = null)
{
// Invalidate cache due to #375
$this->cache = array();
$this->cache = [];
if (false === empty($userAgent)) {
return $this->userAgent = $this->prepareUserAgent($userAgent);
@ -1187,7 +1189,6 @@ class Mobile_Detect
}
return $rules;
}
/**
@ -1253,7 +1254,6 @@ class Mobile_Detect
*/
public function checkHttpHeadersForMobile()
{
foreach ($this->getMobileHeaders() as $mobileHeader => $matchType) {
if (isset($this->httpHeaders[$mobileHeader])) {
if (isset($matchType['matches']) && is_array($matchType['matches'])) {
@ -1271,7 +1271,6 @@ class Mobile_Detect
}
return false;
}
/**
@ -1358,7 +1357,6 @@ class Mobile_Detect
*/
public function isMobile($userAgent = null, $httpHeaders = null)
{
if ($httpHeaders) {
$this->setHttpHeaders($httpHeaders);
}
@ -1370,7 +1368,7 @@ class Mobile_Detect
// Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
if ($this->getUserAgent() === 'Amazon CloudFront') {
$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;
}
}
@ -1382,7 +1380,6 @@ class Mobile_Detect
} else {
return $this->matchDetectionRulesAgainstUA();
}
}
/**
@ -1398,7 +1395,7 @@ class Mobile_Detect
// Check specifically for cloudfront headers if the useragent === 'Amazon CloudFront'
if ($this->getUserAgent() === 'Amazon CloudFront') {
$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;
}
}
@ -1488,7 +1485,7 @@ class Mobile_Detect
*/
public function prepareVersionNo($ver)
{
$ver = str_replace(array('_', ' ', '/'), '.', $ver);
$ver = str_replace(['_', ' ', '/'], '.', $ver);
$arrVer = explode('.', $ver, 2);
if (isset($arrVer[1])) {
@ -1532,7 +1529,6 @@ class Mobile_Detect
$properties[$propertyName] = (array) $properties[$propertyName];
foreach ($properties[$propertyName] as $propertyMatchString) {
$propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);
// Identify and extract the version.
@ -1543,9 +1539,7 @@ class Mobile_Detect
return $version;
}
}
}
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 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
( $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)
$this->version('Windows Phone OS', self::VERSION_TYPE_FLOAT) >= 7.5 ||
@ -1581,21 +1575,21 @@ class Mobile_Detect
$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)
( $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
$this->match('hp.*TouchPad') ||
// 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
( $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
( $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
( $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
$this->is('MeeGoOS') ||
@ -1611,11 +1605,11 @@ class Mobile_Detect
$this->is('Dolfin') && $this->version('Bada', self::VERSION_TYPE_FLOAT) >= 2.0 ||
// 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
( $this->match('Kindle Fire') ||
$this->is('Kindle') && $this->version('Kindle', self::VERSION_TYPE_FLOAT) >= 3.0 ) ||
($this->match('Kindle Fire') ||
$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
$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
$this->version('Opera', self::VERSION_TYPE_FLOAT) >= 10 && !$isMobile
){
) {
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
($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)
$this->match('NokiaN8|NokiaC7|N97.*Series60|Symbian/3') ||
// @todo: report this (tested on Nokia N71)
$this->version('Opera Mobi', self::VERSION_TYPE_FLOAT) >= 11 && $this->is('SymbianOS')
){
) {
return self::MOBILE_GRADE_B;
}
@ -1672,7 +1666,7 @@ class Mobile_Detect
// Internet Explorer 7 and older - Tested on Windows XP
$this->version('IE', self::VERSION_TYPE_FLOAT) <= 7.0 && !$isMobile
){
) {
return self::MOBILE_GRADE_C;
}

View file

@ -1,26 +1,27 @@
<?php
interface ObjectInterface {
interface ObjectInterface
{
public static function getTableName();
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)) {
// get data from id
$this->load($id);
}
}
protected function load($id) {
protected function load($id)
{
$row = self::getFromDb($id);
if (empty($row)) {
return false;
@ -31,7 +32,8 @@ abstract class ObjectYPT implements ObjectInterface {
return true;
}
public static function getNowFromDB() {
public static function getNowFromDB()
{
global $global;
$sql = "SELECT NOW() as my_date_field";
$res = sqlDAL::readSql($sql);
@ -45,7 +47,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $row;
}
public static function setGlobalTimeZone() {
public static function setGlobalTimeZone()
{
global $advancedCustom, $timezoneOriginal;
if (!isset($timezoneOriginal)) {
$timezoneOriginal = date_default_timezone_get();
@ -62,12 +65,13 @@ abstract class ObjectYPT implements ObjectInterface {
date_default_timezone_set($timezone);
}
protected static function getFromDb($id) {
protected static function getFromDb($id)
{
global $global;
$id = intval($id);
$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
$res = sqlDAL::readSql($sql, "i", array($id), true);
$res = sqlDAL::readSql($sql, "i", [$id], true);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
@ -78,7 +82,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $row;
}
public static function getAll() {
public static function getAll()
{
global $global;
if (!static::isTableInstalled()) {
return false;
@ -89,7 +94,7 @@ abstract class ObjectYPT implements ObjectInterface {
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$rows = array();
$rows = [];
if ($res != false) {
foreach ($fullData as $row) {
$rows[] = $row;
@ -100,7 +105,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $rows;
}
public static function getAllActive() {
public static function getAllActive()
{
global $global;
if (!static::isTableInstalled()) {
return false;
@ -111,7 +117,7 @@ abstract class ObjectYPT implements ObjectInterface {
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$rows = array();
$rows = [];
if ($res != false) {
foreach ($fullData as $row) {
$rows[] = $row;
@ -122,7 +128,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $rows;
}
public static function getTotal() {
public static function getTotal()
{
//will receive
//current=1&rowCount=10&sort[sender]=asc&searchPhrase=
global $global;
@ -137,7 +144,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $countRow;
}
public static function getSqlFromPost($keyPrefix = "") {
public static function getSqlFromPost($keyPrefix = "")
{
global $global;
$sql = self::getSqlSearchFromPost();
@ -155,7 +163,7 @@ abstract class ObjectYPT implements ObjectInterface {
}
if (!empty($_POST['sort'])) {
$orderBy = array();
$orderBy = [];
foreach ($_POST['sort'] as $key => $value) {
$key = $global['mysqli']->real_escape_string($key);
//$value = $global['mysqli']->real_escape_string($value);
@ -177,9 +185,10 @@ abstract class ObjectYPT implements ObjectInterface {
return $sql;
}
public static function getSqlLimit() {
public static function getSqlLimit()
{
global $global;
$sql = "";
$sql = '';
if (empty($_POST['rowCount']) && !empty($_GET['length'])) {
$_POST['rowCount'] = intval($_GET['length']);
@ -208,30 +217,32 @@ abstract class ObjectYPT implements ObjectInterface {
return $sql;
}
public static function getSqlDateFilter() {
public static function getSqlDateFilter()
{
$sql = '';
$created_year = intval(@$_REQUEST['created_year']);
$created_month = intval(@$_REQUEST['created_month']);
$modified_year = intval(@$_REQUEST['modified_year']);
$modified_month = intval(@$_REQUEST['modified_month']);
if(!empty($created_year)){
if (!empty($created_year)) {
$sql .= " AND YEAR(created) = $created_year ";
}
if(!empty($created_month)){
if (!empty($created_month)) {
$sql .= " AND MONTH(created) = $created_month ";
}
if(!empty($modified_year)){
if (!empty($modified_year)) {
$sql .= " AND YEAR(modified) = $modified_year ";
}
if(!empty($modified_month)){
if (!empty($modified_month)) {
$sql .= " AND MONTH(modified) = $modified_month ";
}
return $sql;
}
public static function getSqlSearchFromPost() {
public static function getSqlSearchFromPost()
{
$sql = self::getSqlDateFilter();
if (!empty($_POST['searchPhrase'])) {
$_GET['q'] = $_POST['searchPhrase'];
@ -242,10 +253,10 @@ abstract class ObjectYPT implements ObjectInterface {
global $global;
$search = $global['mysqli']->real_escape_string(xss_esc($_GET['q']));
$like = array();
$like = [];
$searchFields = static::getSearchFieldsNames();
foreach ($searchFields as $value) {
if(!str_contains($value, '.') && !str_contains($value, '`')){
if (!str_contains($value, '.') && !str_contains($value, '`')) {
$value = "`{$value}`";
}
$like[] = " {$value} LIKE '%{$search}%' ";
@ -262,7 +273,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $sql;
}
public function save() {
public function save()
{
if (!$this->tableExists()) {
_error_log("Save error, table " . static::getTableName() . " does not exists", AVideoLog::$ERROR);
return false;
@ -271,14 +283,14 @@ abstract class ObjectYPT implements ObjectInterface {
$fieldsName = $this->getAllFields();
if (!empty($this->id)) {
$sql = "UPDATE " . static::getTableName() . " SET ";
$fields = array();
$fields = [];
foreach ($fieldsName as $value) {
if (strtolower($value) == 'created') {
// do nothing
} elseif (strtolower($value) == 'modified') {
$fields[] = " {$value} = now() ";
} elseif (strtolower($value) == 'timezone') {
if(empty($this->$value)){
if (empty($this->$value)) {
$this->$value = date_default_timezone_get();
}
$fields[] = " `{$value}` = '{$this->$value}' ";
@ -295,18 +307,18 @@ abstract class ObjectYPT implements ObjectInterface {
} else {
$sql = "INSERT INTO " . static::getTableName() . " ( ";
$sql .= "`" . implode("`,`", $fieldsName) . "` )";
$fields = array();
$fields = [];
foreach ($fieldsName as $value) {
if (is_string($value) && (strtolower($value) == 'created' || strtolower($value) == 'modified')) {
$fields[] = " now() ";
} elseif (is_string($value) && strtolower($value) == 'timezone') {
if(empty($this->$value)){
} elseif (is_string($value) && strtolower($value) == 'timezone') {
if (empty($this->$value)) {
$this->$value = date_default_timezone_get();
}
$fields[] = " '{$this->$value}' ";
} elseif (!isset($this->$value) || (is_string($this->$value) && strtolower($this->$value) == '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}' ";
} else {
$fields[] = " NULL ";
@ -330,13 +342,14 @@ abstract class ObjectYPT implements ObjectInterface {
}
}
private function getAllFields() {
private function getAllFields()
{
global $global, $mysqlDatabase;
$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);
sqlDAL::close($res);
$rows = array();
$rows = [];
if ($res != false) {
foreach ($fullData as $row) {
$rows[] = $row["COLUMN_NAME"];
@ -347,53 +360,56 @@ abstract class ObjectYPT implements ObjectInterface {
return $rows;
}
public function delete() {
public function delete()
{
global $global;
if (!empty($this->id)) {
$sql = "DELETE FROM " . static::getTableName() . " ";
$sql .= " WHERE id = ?";
$global['lastQuery'] = $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);
return false;
}
static function shouldUseDatabase($content){
public static function shouldUseDatabase($content)
{
global $advancedCustom, $global;
if(!empty($global['doNotUseCacheDatabase'])){
if (!empty($global['doNotUseCacheDatabase'])) {
return false;
}
$maxLen = 60000;
if(empty($advancedCustom)){
if (empty($advancedCustom)) {
$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);
$len = strlen($json);
if($len>$maxLen/2){
if ($len>$maxLen/2) {
return false;
}
if(class_exists('CachesInDB')){
if (class_exists('CachesInDB')) {
$content = CachesInDB::encodeContent($json);
}else{
} else {
$content = base64_encode($json);
}
$len = strlen($content);
if(!empty($len) && $len<$maxLen){
if (!empty($len) && $len<$maxLen) {
return $content;
}else if(!empty($len)){
} elseif (!empty($len)) {
//_error_log('Object::setCache '.$len);
}
}
return false;
}
public static function setCache($name, $value) {
if($content = self::shouldUseDatabase($value)){
public static function setCache($name, $value)
{
if ($content = self::shouldUseDatabase($value)) {
return Cache::_setCache($name, $content);
}
@ -402,7 +418,7 @@ abstract class ObjectYPT implements ObjectInterface {
$content = $value;
}
if(empty($content)){
if (empty($content)) {
return false;
}
@ -411,11 +427,12 @@ abstract class ObjectYPT implements ObjectInterface {
$bytes = @file_put_contents($cachefile, $content);
self::setSessionCache($name, $value);
return array('bytes' => $bytes, 'cachefile' => $cachefile);
return ['bytes' => $bytes, 'cachefile' => $cachefile];
}
public static function cleanCacheName($name) {
$name = str_replace(array('/', '\\'), array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), $name);
public static function cleanCacheName($name)
{
$name = str_replace(['/', '\\'], [DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR], $name);
$name = preg_replace('/[!#$&\'()*+,:;=?@[\\]% -]+/', '_', trim(strtolower(cleanString($name))));
$name = preg_replace('/\/{2,}/', '/', trim(strtolower(cleanString($name))));
if (function_exists('mb_ereg_replace')) {
@ -432,9 +449,10 @@ abstract class ObjectYPT implements ObjectInterface {
* @param type $lifetime, if is = 0 it is unlimited
* @return type
*/
public static function getCache($name, $lifetime = 60, $ignoreSessionCache = false) {
public static function getCache($name, $lifetime = 60, $ignoreSessionCache = false)
{
global $global;
if(!empty($global['ignoreAllCache'])){
if (!empty($global['ignoreAllCache'])) {
return null;
}
self::setLastUsedCacheMode("No cache detected $name, $lifetime, " . intval($ignoreSessionCache));
@ -447,11 +465,11 @@ abstract class ObjectYPT implements ObjectInterface {
global $getCachesProcessed, $_getCache;
if (empty($_getCache)) {
$_getCache = array();
$_getCache = [];
}
if (empty($getCachesProcessed)) {
$getCachesProcessed = array();
$getCachesProcessed = [];
}
$cachefile = self::getCacheFileName($name, false);
//var_dump($cachefile);//exit;
@ -481,9 +499,9 @@ abstract class ObjectYPT implements ObjectInterface {
}
}
if(self::shouldUseDatabase('')){
if (self::shouldUseDatabase('')) {
$cache = Cache::getCache($name, $lifetime);
if(!empty($cache)){
if (!empty($cache)) {
return $cache;
}
}
@ -522,22 +540,26 @@ abstract class ObjectYPT implements ObjectInterface {
return null;
}
private static function setLastUsedCacheMode($mode) {
private static function setLastUsedCacheMode($mode)
{
global $_lastCacheMode;
$_lastCacheMode = $mode;
}
private static function setLastUsedCacheFile($cachefile) {
private static function setLastUsedCacheFile($cachefile)
{
global $_lastCacheFile;
$_lastCacheFile = $cachefile;
}
public static function getLastUsedCacheInfo() {
public static function getLastUsedCacheInfo()
{
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')) {
return false;
}
@ -553,7 +575,8 @@ abstract class ObjectYPT implements ObjectInterface {
ObjectYPT::deleteCacheFromPattern($name);
}
static function deleteCachePattern($pattern) {
public static function deleteCachePattern($pattern)
{
global $__getAVideoCache;
unset($__getAVideoCache);
$tmpDir = self::getCacheDir();
@ -573,8 +596,9 @@ abstract class ObjectYPT implements ObjectInterface {
}
}
public static function deleteALLCache() {
if(class_exists('Cache')){
public static function deleteALLCache()
{
if (class_exists('Cache')) {
Cache::deleteAllCache();
}
self::deleteAllSessionCache();
@ -596,7 +620,7 @@ abstract class ObjectYPT implements ObjectInterface {
if (is_dir($tmpDir)) {
_error_log('deleteALLCache 1 rmdir ' . $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
_error_log('deleteALLCache 2 rmdir ' . $newtmpDir);
rrmdirCommandLine($newtmpDir, true);
@ -608,11 +632,12 @@ abstract class ObjectYPT implements ObjectInterface {
return true;
}
public static function getCacheDir($filename = '', $createDir=true) {
public static function getCacheDir($filename = '', $createDir=true)
{
global $_getCacheDir, $global;
if (!isset($_getCacheDir)) {
$_getCacheDir = array();
$_getCacheDir = [];
}
if (!empty($_getCacheDir[$filename])) {
@ -651,7 +676,7 @@ abstract class ObjectYPT implements ObjectInterface {
}
}
$tmpDir = fixPath($tmpDir);
if($createDir){
if ($createDir) {
make_path($tmpDir);
}
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;
}
public static function getCacheFileName($name, $createDir=true) {
public static function getCacheFileName($name, $createDir=true)
{
global $global;
$tmpDir = self::getCacheDir($name, $createDir);
$uniqueHash = md5($name . $global['salt']); // add salt for security reasons
return $tmpDir . $uniqueHash . '.cache';
}
public static function deleteCacheFromPattern($name) {
public static function deleteCacheFromPattern($name)
{
if (empty($name)) {
return false;
}
@ -689,7 +716,8 @@ abstract class ObjectYPT implements ObjectInterface {
* @param type $name
* @param type $value
*/
public static function setSessionCache($name, $value) {
public static function setSessionCache($name, $value)
{
$name = self::cleanCacheName($name);
_session_start();
$_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
* @return type
*/
public static function getSessionCache($name, $lifetime = 60) {
public static function getSessionCache($name, $lifetime = 60)
{
$name = self::cleanCacheName($name);
if (!empty($_GET['lifetime'])) {
$lifetime = intval($_GET['lifetime']);
@ -726,24 +755,28 @@ abstract class ObjectYPT implements ObjectInterface {
return null;
}
public static function clearSessionCache() {
public static function clearSessionCache()
{
unset($_SESSION['user']['sessionCache']);
}
private static function getLastDeleteALLCacheTimeFile() {
private static function getLastDeleteALLCacheTimeFile()
{
$tmpDir = getTmpDir();
$tmpDir = rtrim($tmpDir, DIRECTORY_SEPARATOR) . "/";
$tmpDir .= "lastDeleteALLCacheTime.cache";
return $tmpDir;
}
public static function setLastDeleteALLCacheTime() {
public static function setLastDeleteALLCacheTime()
{
$file = self::getLastDeleteALLCacheTimeFile();
//_error_log("ObjectYPT::setLastDeleteALLCacheTime {$file}");
return file_put_contents($file, time());
}
public static function getLastDeleteALLCacheTime() {
public static function getLastDeleteALLCacheTime()
{
global $getLastDeleteALLCacheTime;
if (empty($getLastDeleteALLCacheTime)) {
$getLastDeleteALLCacheTime = (int) @file_get_contents(self::getLastDeleteALLCacheTimeFile(), time());
@ -751,7 +784,8 @@ abstract class ObjectYPT implements ObjectInterface {
return $getLastDeleteALLCacheTime;
}
public static function checkSessionCacheBasedOnLastDeleteALLCacheTime() {
public static function checkSessionCacheBasedOnLastDeleteALLCacheTime()
{
/*
var_dump(
$session_var['time'],
@ -768,24 +802,28 @@ abstract class ObjectYPT implements ObjectInterface {
return true;
}
public static function deleteSessionCache($name) {
public static function deleteSessionCache($name)
{
$name = self::cleanCacheName($name);
_session_start();
$_SESSION['user']['sessionCache'][$name] = null;
unset($_SESSION['user']['sessionCache'][$name]);
}
public static function deleteAllSessionCache() {
public static function deleteAllSessionCache()
{
_session_start();
unset($_SESSION['user']['sessionCache']);
return empty($_SESSION['user']['sessionCache']);
}
public function tableExists() {
public function tableExists()
{
return self::isTableInstalled();
}
public static function isTableInstalled($tableName = "") {
public static function isTableInstalled($tableName = "")
{
global $global, $tableExists;
if (empty($tableName)) {
$tableName = static::getTableName();
@ -804,8 +842,8 @@ abstract class ObjectYPT implements ObjectInterface {
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)) {
return $clientDate;
}
@ -820,7 +858,6 @@ abstract class ObjectYPT implements ObjectInterface {
date_default_timezone_set($currentTimezone);
return $dbDate;
}
}
//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));
die();
}
if(!isset($_REQUEST['encodedPass'])){
if (!isset($_REQUEST['encodedPass'])) {
$_REQUEST['encodedPass'] = 1;
}
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
$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());
$video->removeVideoFiles();
}
@ -61,9 +61,9 @@ if (empty($description)) {
}
if(!empty($_REQUEST['duration'])){
if (!empty($_REQUEST['duration'])) {
$duration = $video->getDuration();
if(empty($duration) || $duration === 'EE:EE:EE'){
if (empty($duration) || $duration === 'EE:EE:EE') {
$video->setDuration($_REQUEST['duration']);
}
}
@ -104,7 +104,7 @@ if (!empty($_FILES)) {
}
if (!empty($_FILES['video']['error'])) {
$phpFileUploadErrors = array(
$phpFileUploadErrors = [
0 => 'There is no error, the file uploaded with success',
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',
@ -113,7 +113,7 @@ if (!empty($_FILES['video']['error'])) {
6 => 'Missing a temporary folder',
7 => 'Failed to write file to disk.',
8 => 'A PHP extension stopped the file upload.',
);
];
_error_log("aVideoEncoder.json: ******** Files ERROR " . $phpFileUploadErrors[$_FILES['video']['error']]);
if (!empty($_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
if (!empty($_FILES['video']['tmp_name'])) {
$resolution = "";
$resolution = '';
if (!empty($_POST['resolution'])) {
$resolution = "_{$_POST['resolution']}";
}
@ -169,7 +169,7 @@ $video->updateHLSDurationIfNeed();
if (!empty($_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']);
}
@ -181,10 +181,10 @@ $v = new Video('', '', $video_id);
$obj->video_id_hash = $v->getVideoIdHash();
_error_log("aVideoEncoder.json: Files Received for video {$video_id}: " . $video->getTitle());
if(!empty($destinationFile)){
if(file_exists($destinationFile)){
if (!empty($destinationFile)) {
if (file_exists($destinationFile)) {
_error_log("aVideoEncoder.json: Success $destinationFile ");
}else{
} else {
_error_log("aVideoEncoder.json: ERROR $destinationFile ");
}
}
@ -196,7 +196,8 @@ die(json_encode($obj));
var_dump($_POST, $_FILES);
*/
function downloadVideoFromDownloadURL($downloadURL){
function downloadVideoFromDownloadURL($downloadURL)
{
global $global;
_error_log("aVideoEncoder.json: Try to download " . $downloadURL);
$file = url_get_contents($_POST['downloadURL']);
@ -212,11 +213,11 @@ function downloadVideoFromDownloadURL($downloadURL){
$temp = Video::getStoragePath()."cache/tmpFile/" . $_FILES['video']['name'];
make_path($temp);
$bytesSaved = file_put_contents($temp, $file);
if($bytesSaved){
if ($bytesSaved) {
_error_log("aVideoEncoder.json: saved " . $temp . ' '. humanFileSize($bytesSaved));
return $temp;
}else{
_error_log("aVideoEncoder.json: ERROR on save file " . $temp );
} else {
_error_log("aVideoEncoder.json: ERROR on save file " . $temp);
}
}
return false;

View file

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

View file

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

View file

@ -1,5 +1,4 @@
<?php
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
$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));
$obj->jpgDest = "{$destination_local}.jpg";
if(!empty($_REQUEST['downloadURL_image']) ){
if (!empty($_REQUEST['downloadURL_image'])) {
$content = url_get_contents($_REQUEST['downloadURL_image']);
$obj->jpgDestSize = _file_put_contents($obj->jpgDest, $content);
_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(!rename($_FILES['image']['tmp_name'], $obj->jpgDest)){
if(!copy($_FILES['image']['tmp_name'], $obj->jpgDest)){
if(!file_exists($_FILES['image']['tmp_name'])){
if (!rename($_FILES['image']['tmp_name'], $obj->jpgDest)) {
if (!copy($_FILES['image']['tmp_name'], $obj->jpgDest)) {
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);
}else{
} else {
$obj->msg = print_r(sprintf(__("Could not move image file %s => [%s]"), $_FILES['image']['tmp_name'], $obj->jpgDest), true);
}
_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']);
$obj->jpgSpectrumDestSize = _file_put_contents($obj->jpgSpectrumDest, $content);
_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";
if ((!empty($_REQUEST['update_video_id']) || !file_exists($obj->jpgSpectrumDest) || filesize($obj->jpgSpectrumDest) === 42342)) {
if (!move_uploaded_file($_FILES['spectrumimage']['tmp_name'], $obj->jpgSpectrumDest)) {
@ -105,11 +104,11 @@ if(!empty($_REQUEST['downloadURL_spectrumimage']) ){
}
$obj->gifDest = "{$destination_local}.gif";
if(!empty($_REQUEST['downloadURL_gifimage']) ){
if (!empty($_REQUEST['downloadURL_gifimage'])) {
$content = url_get_contents($_REQUEST['downloadURL_gifimage']);
$obj->gifDestSize = file_put_contents($obj->gifDest, $content);
_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)) {
$obj->msg = print_r(sprintf(__("Could not move gif image file [%s.gif]"), $destination_local), true);
_error_log("ReceiveImage: " . $obj->msg);
@ -129,11 +128,11 @@ if(!empty($_REQUEST['downloadURL_gifimage']) ){
}
}
$obj->webpDest = "{$destination_local}.webp";
if(!empty($_REQUEST['downloadURL_webpimage']) ){
if (!empty($_REQUEST['downloadURL_webpimage'])) {
$content = url_get_contents($_REQUEST['downloadURL_webpimage']);
$obj->webpDestSize = file_put_contents($obj->webpDest, $content);
_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)) {
$obj->msg = print_r(sprintf(__("Could not move webp image file [%s.webp]"), $destination_local), true);
_error_log("ReceiveImage: " . $obj->msg);

View file

@ -1,5 +1,4 @@
<?php
header('Content-Type: application/json');
$obj = new stdClass();
$obj->error = true;
@ -16,10 +15,9 @@ if (!User::canUpload()) {
}
// 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) {
$updateVideoGroups = false;
//echo "Success: \$_FILES OK\n";
@ -27,8 +25,7 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
if (!in_array(strtolower($extension), $allowed)) {
//echo '{"status":"error", "msg":"File extension error [' . $_FILES['upl']['name'] . '], we allow only (' . implode(",", $allowed) . ')"}';
status(["status" => "error"
, "msg" => "File extension error (" . $_FILES['upl']['name'] . "), we allow only (" . implode(",", $allowed) . ")"]);
status(["status" => "error", "msg" => "File extension error (" . $_FILES['upl']['name'] . "), we allow only (" . implode(",", $allowed) . ")"]);
exit;
}
@ -57,7 +54,7 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
. "<br>[Max Duration: {$maxDuration} Seconds]"
. "<br>[Current Srotage Usage: {$currentStorageUsage} 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'])) {
$video = new Video("", "", $_FILES['upl']['videoId']);
$video->delete();
@ -142,40 +139,39 @@ if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) {
$video = new Video('', '', $id);
// send to encoder
$queue = array();
$postFields = array();
$queue = [];
$postFields = [];
if ($video->getType() == 'video') {
if (AVideoPlugin::isEnabledByName("VideoHLS")) {
$postFields['inputAutoHLS'] = 1;
}else{
} else {
$postFields['inputLow'] = 1;
$postFields['inputSD'] = 1;
$postFields['inputHD'] = 1;
if (!empty($_FILES['upl']['webm']))
if (!empty($_FILES['upl']['webm'])) {
$postFields['webm'] = 1;
}
}
} else {
$postFields['audioOnly'] = 1;
$postFields['spectrum'] = 1;
}
if (!empty($_FILES['upl']['override_status']))
if (!empty($_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'];
}
$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);
//var_dump($output, $return_val);
//echo '{"status":"success", "msg":"Your video (' . $filename . ') is encoding <br> ' . $cmd . '", "filename":"' . $filename . '", "duration":"' . $duration . '"}';
status(["status" => "success"
, "msg" => "Your video ($filename) is queue"
, "filename" => "$filename"
, "duration" => "$duration"
, "queue" => json_encode($queue)]);
//exit;
status(["status" => "success", "msg" => "Your video ($filename) is queue", "filename" => "$filename", "duration" => "$duration", "queue" => json_encode($queue)]);
//exit;
} else {
//echo '{"status":"error", "msg":' . json_encode($_FILES) . ', "type":"$_FILES Error"}';
status(["status" => "error", "msg" => print_r($_FILES, true), "type" => '$_FILES Error']);

View file

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

View file

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

View file

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

View file

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

View file

@ -1,12 +1,17 @@
<?php
global $global, $config;
if(!isset($global['systemRootPath'])){
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
class Captcha{
private $largura, $altura, $tamanho_fonte, $quantidade_letras;
class Captcha
{
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->altura = $altura;
$this->tamanho_fonte = $tamanho_fonte;
@ -14,10 +19,11 @@ class Captcha{
}
public function getCaptchaImage() {
public function getCaptchaImage()
{
global $global;
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
$preto = imagecolorallocate($imagem, 0, 0, 0); // define a cor preta
$branco = imagecolorallocate($imagem, 255, 255, 255); // define a cor branca
@ -26,7 +32,7 @@ class Captcha{
//$letters = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnPpQqRrSsTtUuVvYyXxWwZz23456789';
$letters = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnPpQqRrSsTtUuVvYyXxWwZz23456789';
$palavra = substr(str_shuffle($letters), 0, ($this->quantidade_letras));
if(User::isAdmin()){
if (User::isAdmin()) {
$palavra = "admin";
}
_session_start();
@ -49,20 +55,20 @@ class Captcha{
//_error_log("getCaptchaImage _SESSION[palavra] = ($_SESSION[palavra]) - session_name ". session_name()." session_id: ". session_id());
}
static public function validation($word) {
if(User::isAdmin()){
public static function validation($word)
{
if (User::isAdmin()) {
return true;
}
_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());
return false;
}
$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());
}
return $validation;
}
}

View file

@ -1,5 +1,4 @@
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
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/video.php';
class Category {
class Category
{
private $id;
private $name;
private $clean_name;
@ -25,34 +24,41 @@ class Category {
private $order;
private $suggested;
function getSuggested() {
public function getSuggested()
{
return empty($this->suggested) ? 0 : 1;
}
function setSuggested($suggested) {
public function setSuggested($suggested)
{
$this->suggested = empty($suggested) ? 0 : 1;
}
function getOrder() {
public function getOrder()
{
return intval($this->order);
}
function setOrder($order) {
public function setOrder($order)
{
$this->order = intval($order);
}
function getUsers_id() {
public function getUsers_id()
{
if (empty($this->users_id)) {
$this->users_id = User::getId();
}
return $this->users_id;
}
function getPrivate() {
public function getPrivate()
{
return $this->private;
}
function setUsers_id($users_id) {
public function setUsers_id($users_id)
{
// only admin can change owner
if (!empty($this->users_id) && !User::isAdmin()) {
return false;
@ -61,32 +67,40 @@ class Category {
$this->users_id = intval($users_id);
}
function setPrivate($private) {
public function setPrivate($private)
{
$this->private = empty($private) ? 0 : 1;
}
function setName($name) {
public function setName($name)
{
$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)));
$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;
}
function setParentId($parentId) {
public function setParentId($parentId)
{
$this->parentId = $parentId;
}
function setDescription($description) {
public function setDescription($description)
{
$this->description = $description;
}
function __construct($id, $name = '') {
public function __construct($id, $name = '')
{
if (empty($id)) {
// get the category data from category and pass
$this->name = $name;
@ -97,21 +111,25 @@ class Category {
}
}
private function load($id) {
private function load($id)
{
$row = self::getCategory($id);
if (empty($row))
if (empty($row)) {
return false;
}
foreach ($row as $key => $value) {
$this->$key = $value;
}
return true;
}
function loadSelfCategory() {
public function loadSelfCategory()
{
$this->load($this->getId());
}
function save($allowOfflineUser = false) {
public function save($allowOfflineUser = false)
{
global $global;
if (!$allowOfflineUser && !self::canCreateCategory()) {
@ -148,7 +166,7 @@ class Category {
. "suggested = ?,"
. "`private` = ?, allow_download = ?, `order` = ?, modified = now() WHERE id = ?";
$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 {
$sql = "INSERT INTO categories ( "
. "name,"
@ -161,7 +179,7 @@ class Category {
. "suggested, "
. "`private`, allow_download, `order`, created, modified) VALUES (?, ?,?,?,?,?,?,?,?,?,?,now(), now())";
$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);
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;
if (empty($original_title)) {
@ -190,7 +209,7 @@ class Category {
$sql .= " AND id != {$id} ";
}
$sql .= " LIMIT 1";
$res = sqlDAL::readSql($sql, "", array(), true);
$res = sqlDAL::readSql($sql, "", [], true);
$cleanTitleExists = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($cleanTitleExists != false) {
@ -199,7 +218,8 @@ class Category {
return $clean_title;
}
function delete() {
public function delete()
{
if (!self::canCreateCategory()) {
return false;
}
@ -219,7 +239,7 @@ class Category {
$categories_id = self::getSiteCategoryDefaultID();
if ($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 = ?";
} else {
@ -227,10 +247,11 @@ class Category {
}
self::deleteCategoryCache();
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);
return rrmdir($dirPaths['path']);
}
@ -255,11 +276,12 @@ class Category {
*
*/
static function getCategory($id) {
public static function getCategory($id)
{
global $global;
$id = intval($id);
$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);
sqlDAL::close($res);
if ($result) {
@ -268,24 +290,28 @@ class Category {
return ($res) ? $result : false;
}
static function getCategoryLink($id) {
public static function getCategoryLink($id)
{
$cat = new Category($id);
return self::getCategoryLinkFromName($cat->getClean_name());
}
static function getCategoryLinkFromName($clean_name) {
public static function getCategoryLinkFromName($clean_name)
{
global $global;
return "{$global['webSiteRootURL']}cat/{$clean_name}";
}
function getLink() {
public function getLink()
{
return self::getCategoryLinkFromName($this->getClean_name());
}
static function getCategoryByName($name) {
public static function getCategoryByName($name)
{
global $global;
$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);
sqlDAL::close($res);
if ($result) {
@ -295,7 +321,8 @@ class Category {
return ($res) ? $result : false;
}
static function getOrCreateCategoryByName($name) {
public static function getOrCreateCategoryByName($name)
{
$cat = self::getCategoryByName($name);
if (empty($cat)) {
$obj = new Category(0);
@ -312,7 +339,8 @@ class Category {
return $cat;
}
static function getCategoryDefault() {
public static function getCategoryDefault()
{
global $global;
$sql = "SELECT * FROM categories ORDER BY id ASC LIMIT 1";
$res = sqlDAL::readSql($sql);
@ -324,7 +352,8 @@ class Category {
return ($res) ? $result : false;
}
static function getSiteCategoryDefaultID() {
public static function getSiteCategoryDefaultID()
{
$obj = AVideoPlugin::getObjectDataIfEnabled("PredefinedCategory");
$id = false;
if ($obj) {
@ -338,7 +367,8 @@ class Category {
return $id;
}
static function deleteCategoryCache() {
public static function deleteCategoryCache()
{
_session_start();
ObjectYPT::deleteAllSessionCache();
clearFirstPageCache();
@ -349,7 +379,8 @@ class Category {
_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;
if ($config->currentVersionLowerThen('8.4')) {
return false;
@ -392,7 +423,7 @@ class Category {
$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'])) {
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;
$cacheName = 'category/' . md5($sql);
if (empty($_SESSION['user']['sessionCache']['getAllCategoriesClearCache'])) {
$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 {
_session_start();
unset($_SESSION['user']['sessionCache']['getAllCategoriesClearCache']);
@ -415,10 +446,9 @@ class Category {
$res = sqlDAL::readSql($sql);
$fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$category = array();
$category = [];
if ($res) {
foreach ($fullResult as $row) {
$totals = self::getTotalFromCategory($row['id']);
$fullTotals = self::getTotalFromCategory($row['id'], false, true, true);
@ -446,12 +476,13 @@ class Category {
return $category;
}
static function getHierarchyArray($categories_id, $hierarchyArray = array()) {
public static function getHierarchyArray($categories_id, $hierarchyArray = [])
{
if (empty($categories_id)) {
return $hierarchyArray;
}
$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);
sqlDAL::close($res);
if ($result) {
@ -461,7 +492,8 @@ class Category {
return $hierarchyArray;
}
static function getHierarchyString($categories_id) {
public static function getHierarchyString($categories_id)
{
if (empty($categories_id)) {
return "/";
}
@ -478,7 +510,8 @@ class Category {
return $str;
}
static function userCanAddInCategory($categories_id, $users_id = 0) {
public static function userCanAddInCategory($categories_id, $users_id = 0)
{
if (empty($categories_id)) {
return false;
}
@ -495,7 +528,8 @@ class Category {
return false;
}
static function userCanEditCategory($categories_id, $users_id = 0) {
public static function userCanEditCategory($categories_id, $users_id = 0)
{
if (empty($categories_id)) {
return false;
}
@ -517,7 +551,8 @@ class Category {
return false;
}
static function canCreateCategory() {
public static function canCreateCategory()
{
global $advancedCustomUser;
if (User::isAdmin()) {
return true;
@ -528,7 +563,8 @@ class Category {
return false;
}
static function getChildCategories($parentId, $filterCanAddVideoOnly = false) {
public static function getChildCategories($parentId, $filterCanAddVideoOnly = false)
{
global $global, $config;
if ($config->currentVersionLowerThen('8.4')) {
return false;
@ -545,11 +581,11 @@ class Category {
$sql .= " AND (private=0 OR users_id = '{$users_id}') ";
}
}
$sql .= BootGrid::getSqlFromPost(array('name'), "", " ORDER BY `order`, name ASC ");
$res = sqlDAL::readSql($sql, "ii", array($parentId, $parentId));
$sql .= BootGrid::getSqlFromPost(['name'], "", " ORDER BY `order`, name ASC ");
$res = sqlDAL::readSql($sql, "ii", [$parentId, $parentId]);
$fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$category = array();
$category = [];
if ($res) {
foreach ($fullResult as $row) {
$totals = self::getTotalFromCategory($row['id']);
@ -565,42 +601,45 @@ class Category {
return $category;
}
static function getChildCategoriesFromTitle($clean_title) {
public static function getChildCategoriesFromTitle($clean_title)
{
$row = self::getCategoryByName($clean_title);
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);
$lives = self::getTotalLivesFromCategory($categories_id, $showUnlisted, $renew);
$livelinkss = self::getTotalLiveLinksFromCategory($categories_id, $showUnlisted, $renew);
$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);
$array = array('videos' => 0, 'lives' => 0, 'livelinks' => 0, 'total' => 0);
$array = ['videos' => 0, 'lives' => 0, 'livelinks' => 0, 'total' => 0];
foreach ($categories as $value) {
$totals = self::getTotalFromCategory($categories_id, $showUnlisted, $getAllVideos, $renew);
$array = array(
$array = [
'videos' => $array['videos'] + $totals['videos'],
'lives' => $array['lives'] + $totals['lives'],
'livelinks' => $array['livelinks'] + $totals['livelinks'],
'total' => $array['total'] + $totals['total']);
'total' => $array['total'] + $totals['total'], ];
$totals = self::getTotalFromChildCategory($value['id'], $showUnlisted, $getAllVideos, $renew);
$array = array(
$array = [
'videos' => $array['videos'] + $totals['videos'],
'lives' => $array['lives'] + $totals['lives'],
'livelinks' => $array['livelinks'] + $totals['livelinks'],
'total' => $array['total'] + $totals['total']);
'total' => $array['total'] + $totals['total'], ];
}
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;
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 = ? ";
@ -614,7 +653,7 @@ class Category {
$sql .= Video::getUserGroupsCanSeeSQL();
}
//echo $categories_id, $sql;exit;
$res = sqlDAL::readSql($sql, "i", array($categories_id));
$res = sqlDAL::readSql($sql, "i", [$categories_id]);
$fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$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'];
}
static function getLatestVideoFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false) {
public static function getLatestVideoFromCategory($categories_id, $showUnlisted = false, $getAllVideos = false)
{
global $global, $config;
$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";
//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);
sqlDAL::close($res);
return $result;
}
static function getLatestLiveFromCategory($categories_id) {
public static function getLatestLiveFromCategory($categories_id)
{
if (!AVideoPlugin::isEnabledByName("Live")) {
return array();
return [];
}
global $global, $config;
$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";
//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);
sqlDAL::close($res);
return $result;
}
static function getLatestLiveLinksFromCategory($categories_id) {
public static function getLatestLiveLinksFromCategory($categories_id)
{
if (AVideoPlugin::isEnabledByName("LiveLinks")) {
return array();
return [];
}
global $global, $config;
$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";
//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);
sqlDAL::close($res);
return $result;
}
static function getTotalLiveLinksFromCategory($categories_id, $showUnlisted = false, $renew = false) {
public static function getTotalLiveLinksFromCategory($categories_id, $showUnlisted = false, $renew = false)
{
global $global;
if (!AVideoPlugin::isEnabledByName("LiveLinks")) {
@ -694,7 +737,7 @@ class Category {
}
//echo $categories_id, $sql;exit;
$res = sqlDAL::readSql($sql, "i", array($categories_id));
$res = sqlDAL::readSql($sql, "i", [$categories_id]);
$fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$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'];
}
static function getTotalLivesFromCategory($categories_id, $showUnlisted = false, $renew = false) {
public static function getTotalLivesFromCategory($categories_id, $showUnlisted = false, $renew = false)
{
if (!AVideoPlugin::isEnabledByName("Live")) {
return 0;
}
@ -724,7 +766,7 @@ class Category {
}
//echo $categories_id, $sql;exit;
$res = sqlDAL::readSql($sql, "i", array($categories_id));
$res = sqlDAL::readSql($sql, "i", [$categories_id]);
$fullResult = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$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'];
}
static function clearCacheCount($categories_id = 0) {
public static function clearCacheCount($categories_id = 0)
{
// clear category count cache
_session_start();
if (empty($categories_id)) {
@ -750,7 +793,8 @@ class Category {
//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;
if ($config->currentVersionLowerThen('5.01')) {
@ -793,7 +837,7 @@ class Category {
}
$sql .= ")";
}
$sql .= BootGrid::getSqlSearchFromPost(array('name'));
$sql .= BootGrid::getSqlSearchFromPost(['name']);
//echo $sql;exit;
$res = sqlDAL::readSql($sql);
$numRows = sqlDal::num_rows($res);
@ -801,38 +845,46 @@ class Category {
return $numRows;
}
function getIconClass() {
public function getIconClass()
{
if (empty($this->iconClass)) {
return "fa fa-folder";
}
return $this->iconClass;
}
function setIconClass($iconClass) {
public function setIconClass($iconClass)
{
$this->iconClass = $iconClass;
}
function getName() {
public function getName()
{
return $this->name;
}
function getClean_name() {
public function getClean_name()
{
return $this->clean_name;
}
function getDescription() {
public function getDescription()
{
return $this->description;
}
function getAllow_download() {
public function getAllow_download()
{
return $this->allow_download;
}
function setAllow_download($allow_download) {
public function setAllow_download($allow_download)
{
$this->allow_download = intval($allow_download);
}
static function getCategoryDirPath($categories_id = "") {
public static function getCategoryDirPath($categories_id = "")
{
global $global;
$dir = "videos/categories/assets/";
@ -840,7 +892,7 @@ class Category {
$dir .= $categories_id . "/";
}
$path = array();
$path = [];
$path['dir'] = "{$global['systemRootPath']}{$dir}";
make_path($path['dir']);
$path['path'] = "{$global['systemRootPath']}{$dir}";
@ -848,7 +900,8 @@ class Category {
return $path;
}
static function isAssetsValids($categories_id) {
public static function isAssetsValids($categories_id)
{
$photo = Category::getCategoryPhotoPath($categories_id);
$background = Category::getCategoryBackgroundPath($categories_id);
//var_dump(filesize($background['path']), $background['path'], filesize($photo['path']), $photo['path'] );
@ -864,10 +917,11 @@ class Category {
return true;
}
public static function getOGImagePaths($categories_id) {
public static function getOGImagePaths($categories_id)
{
$name = "og_200X200.jpg";
$dirPaths = self::getCategoryDirPath($categories_id);
$path = array();
$path = [];
$path['dir'] = $dirPaths['url'];
$path['path'] = "{$dirPaths['path']}{$name}";
$path['url'] = "{$dirPaths['url']}{$name}";
@ -879,7 +933,8 @@ class Category {
return $path;
}
public static function deleteOGImage($categories_id) {
public static function deleteOGImage($categories_id)
{
$ogPaths = self::getOGImagePaths($categories_id);
$destination = $ogPaths['path'];
if (file_exists($destination)) {
@ -887,7 +942,8 @@ class Category {
}
}
public static function getOGImage($categories_id) {
public static function getOGImage($categories_id)
{
global $global;
$isAssetsValids = self::isAssetsValids($categories_id);
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);
return $path;
}
static function getCategoryBackgroundPath($categories_id) {
public static function getCategoryBackgroundPath($categories_id)
{
$path = self::getCategoryAssetPath("background.png", $categories_id);
return $path;
}
private static function getCategoryAssetPath($name, $categories_id) {
private static function getCategoryAssetPath($name, $categories_id)
{
if (empty($categories_id)) {
return false;
}
@ -927,7 +986,7 @@ class Category {
global $global;
$path = array();
$path = [];
$path['dir'] = $dirPaths['url'];
$path['path'] = "{$dirPaths['path']}{$name}";
$path['url'] = "{$dirPaths['url']}{$name}";
@ -938,5 +997,4 @@ class Category {
}
return $path;
}
}

View file

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

View file

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

View file

@ -101,12 +101,12 @@ class Comment
}
$sql = "UPDATE comments SET "
. " 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 {
$id = User::getId();
$sql = "INSERT INTO comments ( comment,users_id, videos_id, comments_id_pai, created, modified) VALUES "
. " (?, ?, ?, {$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)) {
die('Error (comment save) : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
@ -138,7 +138,7 @@ class Comment
} else {
return false;
}
return sqlDAL::writeSql($sql, "i", array($this->id));
return sqlDAL::writeSql($sql, "i", [$this->id]);
}
private function getComment($id)
@ -146,7 +146,7 @@ class Comment
global $global;
$id = intval($id);
$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);
sqlDAL::close($res);
return ($res!=false) ? $result : false;
@ -155,8 +155,8 @@ class Comment
public static function getAllComments($videoId = 0, $comments_id_pai = 'NULL')
{
global $global;
$format = "";
$values = array();
$format = '';
$values = [];
$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 dislikes ";
@ -201,11 +201,11 @@ class Comment
$values[]=$comments_id_pai;
}
$sql .= BootGrid::getSqlFromPost(array('name'));
$sql .= BootGrid::getSqlFromPost(['name']);
$res = sqlDAL::readSql($sql, $format, $values);
$allData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$comment = array();
$comment = [];
if ($res!=false) {
foreach ($allData as $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)
{
global $global;
$format = "";
$values = array();
$format = '';
$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 ";
if (!empty($videoId)) {
@ -265,7 +265,7 @@ class Comment
$values[] = $video_owner_users_id;
}
$sql .= BootGrid::getSqlSearchFromPost(array('name'));
$sql .= BootGrid::getSqlSearchFromPost(['name']);
$res = sqlDAL::readSql($sql, $format, $values);
$countRow = sqlDAL::num_rows($res);
@ -312,14 +312,14 @@ class Comment
{
global $global;
$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);
sqlDAL::close($res);
$r = array('thumbsUp'=>0, 'thumbsDown'=>0 );
$r = ['thumbsUp'=>0, 'thumbsDown'=>0 ];
if ($res!=false) {
foreach ($fullData as $row) {
$format = "i";
$values = array($row['id']);
$values = [$row['id']];
$sql = "SELECT id from comments_likes WHERE comments_id = ? AND `like` = 1 ";
if (!empty($startDate)) {
$sql .= " AND `created` >= ? ";
@ -336,7 +336,7 @@ class Comment
sqlDAL::close($res);
$r['thumbsUp']+=$countRow;
$format = "i";
$values = array($row['id']);
$values = [$row['id']];
$sql = "SELECT id from comments_likes WHERE comments_id = ? AND `like` = -1 ";
if (!empty($startDate)) {
$sql .= " AND `created` >= ? ";

View file

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

View file

@ -1,7 +1,7 @@
<?php
header('Content-Type: application/json');
global $global, $config;
if(!isset($global['systemRootPath'])){
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.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']);
$total = Comment::getTotalComments($_GET['video_id'], @$_POST['comments_id']);
function fixCommentText($subject){
$search = array('\n');
$replace = array("<br/>");
function fixCommentText($subject)
{
$search = ['\n'];
$replace = ["<br/>"];
return stripslashes(str_replace($search, $replace, $subject));
}

View file

@ -1,6 +1,6 @@
<?php
global $global, $config;
if(!isset($global['systemRootPath'])){
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.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';
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->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'];
}

View file

@ -34,7 +34,7 @@ class CommentsLike
private function setLike($like)
{
$like = intval($like);
if (!in_array($like, array(0,1,-1))) {
if (!in_array($like, [0,1,-1])) {
$like = 0;
}
$this->like = $like;
@ -59,7 +59,7 @@ class CommentsLike
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";
$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);
sqlDAL::close($res);
return ($res) ? $result : false;
@ -72,16 +72,16 @@ class CommentsLike
header('Content-Type: application/json');
die('{"error":"'.__("Permission denied").'"}');
}
$formats = "";
$values = array();
$formats = '';
$values = [];
if (!empty($this->id)) {
$sql = "UPDATE comments_likes SET `like` = ?, modified = now() WHERE id = ?";
$formats = "ii";
$values = array($this->like,$this->id);
$values = [$this->like,$this->id];
} else {
$sql = "INSERT INTO comments_likes ( `like`,users_id, comments_id, created, modified) VALUES (?, ?, ?, now(), now())";
$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);
}
@ -97,7 +97,7 @@ class CommentsLike
$obj->myVote = self::getMyVote($comments_id);
$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);
sqlDAL::close($res);
if (!$res) {
@ -106,7 +106,7 @@ class CommentsLike
$obj->likes = intval($result['total']);
$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);
sqlDAL::close($res);
if (!$res) {
@ -152,7 +152,7 @@ class CommentsLike
}
$id = User::getId();
$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);
sqlDAL::close($res);
if (!empty($result)) {

View file

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

View file

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

View file

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

View file

@ -60,24 +60,24 @@ if (!is_writable($global['systemRootPath'] . $imagePath)) {
}
*
*/
$response = array();
$response = [];
if (!empty($_POST['logoImgBase64'])) {
$fileData = base64DataToImage($_POST['logoImgBase64']);
$fileName = 'logo.png';
$photoURL = $imagePath . $fileName;
$bytes = file_put_contents($global['systemRootPath'] . $photoURL, $fileData);
if ($bytes > 10) {
$response = array(
$response = [
"status" => 'success',
"url" => $global['systemRootPath'] . $photoURL
);
"url" => $global['systemRootPath'] . $photoURL,
];
$config->setLogo($photoURL);
} else {
$response = array(
$response = [
"status" => 'error',
"msg" => 'We could not save logo',
"url" => $global['systemRootPath'] . $photoURL
);
"url" => $global['systemRootPath'] . $photoURL,
];
}
}
if (!empty($_POST['faviconBase64'])) {
@ -87,27 +87,27 @@ if (!empty($_POST['faviconBase64'])) {
$photoURL = $imagePath . $fileName;
$bytes = file_put_contents($global['systemRootPath'] . $photoURL, $fileData);
if ($bytes > 10) {
$response2 = array(
$response2 = [
"status" => 'success',
"url" => $global['systemRootPath'] . $photoURL
);
"url" => $global['systemRootPath'] . $photoURL,
];
$sizes = array(
array(16, 16),
array(24, 24),
array(32, 32),
array(48, 48),
array(144, 144)
);
$sizes = [
[16, 16],
[24, 24],
[32, 32],
[48, 48],
[144, 144],
];
$ico_lib = new PHP_ICO($global['systemRootPath'] . $photoURL, $sizes);
$ico_lib->save_ico($global['systemRootPath'] . $imagePath.'favicon.ico');
} else {
$response2 = array(
$response2 = [
"status" => 'error',
"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(
$_REQUEST['users_groups_id'],
false,
array('name', 'email', 'user', 'channelName', 'about'),
['name', 'email', 'user', 'channelName', 'about'],
'a'
);
} else {
$users = User::getAllUsers(
false,
array('name', 'email', 'user', 'channelName', 'about'),
['name', 'email', 'user', 'channelName', 'about'],
'a'
);
}
@ -36,9 +36,9 @@ $mailsLimit = 100;
$obj = new stdClass();
$obj->error = false;
$obj->msg = array();
$obj->msg = [];
//Create a new PHPMailer instance
$mail = new \PHPMailer\PHPMailer\PHPMailer;
$mail = new \PHPMailer\PHPMailer\PHPMailer();
setSiteSendMessage($mail);
//Set who the message is to be sent from
$mail->setFrom($config->getContactEmail());

View file

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

View file

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

View file

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

View file

@ -7,50 +7,46 @@ if ($users_id = isChannel()) {
$imgh = 200;
$img = User::getOGImage($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="profile:username" content="<?php echo $title; ?>" />
<?php
} else if (!empty($_GET['catName'])) {
$imgw = 200;
$imgh = 200;
$category = Category::getCategoryByName($_GET['catName']);
$img = Category::getOGImage($category['id']);
$title = html2plainText($category['name']);
$url = Category::getCategoryLinkFromName($_GET['catName']);
echo PHP_EOL."<!-- OpenGraph not video -->".PHP_EOL;
?>
} elseif (!empty($_GET['catName'])) {
$imgw = 200;
$imgh = 200;
$category = Category::getCategoryByName($_GET['catName']);
$img = Category::getOGImage($category['id']);
$title = html2plainText($category['name']);
$url = Category::getCategoryLinkFromName($_GET['catName']);
echo PHP_EOL."<!-- OpenGraph not video -->".PHP_EOL; ?>
<meta property="og:type" content="website" />
<meta property="og:site_name" content="<?php echo $title; ?>">
<?php
} else if (!isVideo() && empty($videos_id)) {
$imgw = 200;
$imgh = 200;
$img = Configuration::getOGImage();
$title = html2plainText($config->getWebSiteTitle());
$url = $global['webSiteRootURL'];
echo PHP_EOL."<!-- OpenGraph not video -->".PHP_EOL;
?>
} elseif (!isVideo() && empty($videos_id)) {
$imgw = 200;
$imgh = 200;
$img = Configuration::getOGImage();
$title = html2plainText($config->getWebSiteTitle());
$url = $global['webSiteRootURL'];
echo PHP_EOL."<!-- OpenGraph not video -->".PHP_EOL; ?>
<meta property="og:type" content="website" />
<meta property="og:site_name" content="<?php echo $title; ?>">
<?php
} else {
return false;
}
} else {
return false;
}
if(empty($customizePluginDescription)){
if(AVideoPlugin::isEnabledByName('Customize')){
if (empty($customizePluginDescription)) {
if (AVideoPlugin::isEnabledByName('Customize')) {
$ec = new ExtraConfig();
$customizePluginDescription = $ec->getDescription();
}
}
$description = $title;
if(!empty($customizePluginDescription)){
if (!empty($customizePluginDescription)) {
$description = $customizePluginDescription;
}else
if(!empty($metaDescription)){
} elseif (!empty($metaDescription)) {
$description = $metaDescription;
}
@ -75,10 +71,10 @@ if (!empty($advancedCustom->twitter_summary_large_image)) {
<meta name="twitter:card" content="summary_large_image" />
<?php
} else {
?>
?>
<meta name="twitter:card" content="summary" />
<?php
}
}
?>
<meta name="twitter:url" content="<?php echo $global['webSiteRootURL']; ?>"/>
<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)) {
global $tinyMCELibs;
if (empty($tinyMCELibs)) {
$tinyMCELibs = 1;
?>
$tinyMCELibs = 1; ?>
<script type="text/javascript" src="<?php echo getURL('node_modules/tinymce/tinymce.min.js'); ?>"></script>
<style>.tox-statusbar__branding{display:none !important;}</style>
<?php
}
?>
} ?>
<script>
<?php
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 tinyMCEmenubar = 'edit insert view format table tools help';
<?php
}
?>
} ?>
tinymce.init({
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'); ?>',

View file

@ -1,20 +1,19 @@
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
if(!User::isAdmin()){
if (!User::isAdmin()) {
die("Admin only");
}
$users = array();
$users = [];
$sql = "SELECT id, user, name, email, status, created, isAdmin FROM users";
if ($result = $global['mysqli']->query($sql)) {
while ($p = $result->fetch_assoc()) {
$groups = UserGroups::getUserGroups($p['id']);
$groupsName = array();
$groupsName = [];
foreach ($groups as $value) {
$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");
header("Content-Type:application/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) {
fputcsv($output, $user);
}

View file

@ -1,5 +1,4 @@
<?php
require_once '../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/video.php';
//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]));
$cacheFileName = $argv[10];
$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)));
return false;
}

View file

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

View file

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

View file

@ -1,5 +1,4 @@
<?php
if (!empty($doNotIncludeConfig)) {
error_log('AVideo includeconfig ignored');
return false;
@ -111,8 +110,8 @@ $url1['host'] = '';
$global['HTTP_REFERER'] = '';
if (!empty($_SERVER['HTTP_REFERER'])) {
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'])) {
if (strpos($_SESSION['LAST_HTTP_REFERER'], 'cache/css/') !== false ||
strpos($_SESSION['LAST_HTTP_REFERER'], 'cache/js/') !== false ||
@ -172,10 +171,10 @@ if (empty($doNotConnectDatabaseIncludeConfig) && $baseName !== 'xsendfile.php' &
if (empty($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'])) {
$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']);

View file

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

View file

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

View file

@ -1,17 +1,17 @@
<?php
global $global, $config;
if(!isset($global['systemRootPath'])){
if (!isset($global['systemRootPath'])) {
require_once '../videos/configuration.php';
}
require_once $global['systemRootPath'] . 'objects/like.php';
require_once $global['systemRootPath'] . 'objects/user.php';
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->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'];
}

View file

@ -25,23 +25,23 @@ class Like
// if click again in the same vote, remove the vote
if ($this->like == $like) {
$like = 0;
if($this->like==1){
if ($this->like==1) {
Video::updateLikesDislikes($videos_id, 'likes', '-1');
}else if($this->like==-1){
} elseif ($this->like==-1) {
Video::updateLikesDislikes($videos_id, 'dislikes', '-1');
}
}else{
if(!empty($this->like)){
} else {
if (!empty($this->like)) {
// need to remove some like or dislike
if($like==1){
if ($like==1) {
Video::updateLikesDislikes($videos_id, 'dislikes', '-1');
}else if($like==-1){
} elseif ($like==-1) {
Video::updateLikesDislikes($videos_id, 'likes', '-1');
}
}
if($like==1){
if ($like==1) {
Video::updateLikesDislikes($videos_id, 'likes', '+1');
}else if($like==-1){
} elseif ($like==-1) {
Video::updateLikesDislikes($videos_id, 'dislikes', '+1');
}
}
@ -53,7 +53,7 @@ class Like
private function setLike($like)
{
$like = intval($like);
if (!in_array($like, array(0,1,-1))) {
if (!in_array($like, [0,1,-1])) {
$like = 0;
}
$this->like = $like;
@ -78,7 +78,7 @@ class 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;";
$res = sqlDAL::readSql($sql, "i", array($this->users_id));
$res = sqlDAL::readSql($sql, "i", [$this->users_id]);
$dbLike = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
return $dbLike;
@ -93,10 +93,10 @@ class Like
}
if (!empty($this->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 {
$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;
if ($global['mysqli']->errno!=0) {
@ -105,14 +105,15 @@ class Like
return $res;
}
public static function getLikes($videos_id){
public static function getLikes($videos_id)
{
global $global, $_getLikes;
if(!isset($_getLikes)){
$_getLikes = array();
if (!isset($_getLikes)) {
$_getLikes = [];
}
if(!empty($_getLikes[$videos_id])){
if (!empty($_getLikes[$videos_id])) {
return $_getLikes[$videos_id];
}
@ -123,7 +124,7 @@ class Like
$obj->myVote = self::getMyVote($videos_id);
$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);
sqlDAL::close($res);
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
$res = sqlDAL::readSql($sql, "i", array($videos_id));
$res = sqlDAL::readSql($sql, "i", [$videos_id]);
$row = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($global['mysqli']->errno!=0) {
@ -181,7 +182,7 @@ class Like
$id = User::getId();
$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);
sqlDAL::close($res);
if ($dbLike!=false) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,4 @@
<?php
/*
tester-execution-code
$sql = "SELECT * FROM users WHERE id=?;";
@ -19,10 +18,11 @@
* Internal used class
*/
class iimysqli_result {
public $stmt, $nCols, $fields;
class iimysqli_result
{
public $stmt;
public $nCols;
public $fields;
}
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
*/
class sqlDAL {
static function executeFile($filename) {
class sqlDAL
{
public static function executeFile($filename)
{
global $global;
$templine = '';
// Read in entire file
@ -44,8 +45,9 @@ class sqlDAL {
// Loop through each line
foreach ($lines as $line) {
// Skip it if it's a comment
if (substr($line, 0, 2) == '--' || $line == '')
if (substr($line, 0, 2) == '--' || $line == '') {
continue;
}
// Add this line to the current segment
$templine .= $line;
@ -69,9 +71,10 @@ class sqlDAL {
* @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;
if(empty($preparedStatement)){
if (empty($preparedStatement)) {
return false;
}
// 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();
}
@ -109,9 +112,9 @@ class sqlDAL {
//$global['mysqli']->affected_rows = $stmt->affected_rows;
//$stmt->commit();
$stmt->close();
if(!empty($iid)){
if (!empty($iid)) {
return $iid;
}else{
} else {
return true;
}
}
@ -124,14 +127,15 @@ class sqlDAL {
* @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;
global $global, $disableMysqlNdMethods, $readSqlCached, $crc;
// need to add dechex because some times it return an negative value and make it fails on javascript playlists
$crc = (md5($preparedStatement . implode($values)));
if (!isset($readSqlCached)) {
$readSqlCached = array();
$readSqlCached = [];
}
if ((function_exists('mysqli_fetch_all')) && ($disableMysqlNdMethods == false)) {
@ -152,7 +156,7 @@ class sqlDAL {
if (!($stmt = $global['mysqli']->prepare($preparedStatement))) {
log_error("[sqlDAL::readSql] (mysqlnd) Prepare failed again return false");
return false;
}else{
} else {
log_error("[sqlDAL::readSql] SUCCESS close and reconnect works!");
}
}
@ -175,7 +179,7 @@ class sqlDAL {
}
TimeLogEnd($TimeLog, "mysql_dal", 0.5);
$stmt->close();
} else if (is_object($readSqlCached[$crc])) {
} elseif (is_object($readSqlCached[$crc])) {
// When cached
// 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
*/
static function close($result) {
public static function close($result)
{
global $disableMysqlNdMethods, $global;
if ((!function_exists('mysqli_fetch_all')) || ($disableMysqlNdMethods != false)) {
if(!empty($result->stmt)){
if (!empty($result->stmt)) {
$result->stmt->close();
}
}
@ -252,10 +257,11 @@ class sqlDAL {
* @return int The nr of rows
*/
static function num_rows($res) {
public static function num_rows($res)
{
global $global, $disableMysqlNdMethods, $crc, $num_row_cache;
if (!isset($num_row_cache)) {
$num_row_cache = array();
$num_row_cache = [];
}
// cache is working - but disable for proper test-results
if (!isset($num_row_cache[$crc])) {
@ -275,7 +281,8 @@ class sqlDAL {
}
// unused
static function cached_num_rows($data) {
public static function cached_num_rows($data)
{
return sizeof($data);
}
@ -285,13 +292,14 @@ class sqlDAL {
* @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;
if (!isset($fetchAllAssoc_cache)) {
$fetchAllAssoc_cache = array();
$fetchAllAssoc_cache = [];
}
if (!isset($fetchAllAssoc_cache[$crc])) {
$ret = array();
$ret = [];
while ($row = self::fetchAssoc($result)) {
$ret[] = $row;
}
@ -306,7 +314,8 @@ class sqlDAL {
* @return int A single row in a assoc array
*/
static function fetchAssoc($result) {
public static function fetchAssoc($result)
{
global $global, $disableMysqlNdMethods;
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.
@ -326,14 +335,15 @@ class sqlDAL {
* @return array A array filled with all rows
*/
static function fetchAllArray($result) {
public static function fetchAllArray($result)
{
global $crc, $fetchAllArray_cache;
if (!isset($fetchAllArray_cache)) {
$fetchAllArray_cache = array();
$fetchAllArray_cache = [];
}
// cache is working - but disable for proper test-results
if (!isset($fetchAllArray_cache[$crc])) {
$ret = array();
$ret = [];
while ($row = self::fetchArray($result)) {
$ret[] = $row;
}
@ -350,7 +360,8 @@ class sqlDAL {
* @return int A single row in a array
*/
static function fetchArray($result) {
public static function fetchArray($result)
{
global $global, $disableMysqlNdMethods;
if ((function_exists('mysqli_fetch_all')) && ($disableMysqlNdMethods == false)) {
return $result->fetch_array();
@ -360,7 +371,8 @@ class sqlDAL {
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))) {
return false;
}
@ -378,11 +390,12 @@ class sqlDAL {
return true;
}
private static function iimysqli_stmt_get_result($stmt) {
private static function iimysqli_stmt_get_result($stmt)
{
global $global;
$metadata = mysqli_stmt_result_metadata($stmt);
$ret = new iimysqli_result;
$field_array = array();
$ret = new iimysqli_result();
$field_array = [];
if (!$metadata) {
die("Execute query error, because: {$stmt->error}");
}
@ -393,8 +406,9 @@ class sqlDAL {
$i++;
}
$ret->fields = $field_array;
if (!$ret)
return NULL;
if (!$ret) {
return null;
}
$ret->nCols = mysqli_num_fields($metadata);
@ -404,12 +418,13 @@ class sqlDAL {
return $ret;
}
private static function iimysqli_result_fetch_assoc(&$result) {
private static function iimysqli_result_fetch_assoc(&$result)
{
global $global;
$ret = array();
$ret = [];
$code = "return mysqli_stmt_bind_result(\$result->stmt ";
for ($i = 0; $i < $result->nCols; $i++) {
$ret[$result->fields[$i]] = NULL;
$ret[$result->fields[$i]] = null;
$code .= ", \$ret['" . $result->fields[$i] . "']";
};
@ -423,12 +438,13 @@ class sqlDAL {
return $ret;
}
private static function iimysqli_result_fetch_array(&$result) {
$ret = array();
private static function iimysqli_result_fetch_array(&$result)
{
$ret = [];
$code = "return mysqli_stmt_bind_result(\$result->stmt ";
for ($i = 0; $i < $result->nCols; $i++) {
$ret[$i] = NULL;
$ret[$i] = null;
$code .= ", \$ret['" . $i . "']";
};
$code .= ");";
@ -440,15 +456,13 @@ class sqlDAL {
};
return $ret;
}
}
function log_error($err) {
function log_error($err)
{
if (!empty($global['debug'])) {
echo $err;
}
_error_log("MySQL ERROR: ".json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)), AVideoLog::$ERROR);
_error_log($err, AVideoLog::$ERROR);
}
?>

View file

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

View file

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

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