1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 10:49:36 +02:00
DanieL 2022-10-03 10:46:59 -03:00
parent 5ac8883fb5
commit b2cc0a89a2
25 changed files with 584 additions and 369 deletions

View file

@ -12,8 +12,12 @@ if (!User::isAdmin() || !empty($global['disableAdvancedConfigurations'])) {
$obj->error = __("Permission denied"); $obj->error = __("Permission denied");
die(json_encode($obj)); die(json_encode($obj));
} }
if(empty($_REQUEST['custom'])){
$dir = "{$global['systemRootPath']}locale/"; $dir = "{$global['systemRootPath']}locale/";
}else{
$dir = "{$global['systemRootPath']}videos/locale/";
make_path($dir);
}
if (!is_writable($dir) && !isWindows()) { if (!is_writable($dir) && !isWindows()) {
$obj->status = 0; $obj->status = 0;
$obj->error = sprintf(__("Your %slocale dir is not writable"), $global['systemRootPath']); $obj->error = sprintf(__("Your %slocale dir is not writable"), $global['systemRootPath']);

View file

@ -8249,10 +8249,11 @@ function listAllWordsToTranslate() {
if (preg_match('/vendor.*$/', $dir)) { if (preg_match('/vendor.*$/', $dir)) {
return $vars; return $vars;
} }
//echo $dir.'<br>';
if ($handle = opendir($dir)) { if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) { while (false !== ($entry = readdir($handle))) {
if ($entry !== '.' && $entry !== '..') { if ($entry !== '.' && $entry !== '..') {
$filename = $dir . '/' . $entry; $filename = ($dir) .DIRECTORY_SEPARATOR. $entry;
if (is_dir($filename)) { if (is_dir($filename)) {
$vars = listAll($filename); $vars = listAll($filename);
} elseif (preg_match("/\.php$/", $entry)) { } elseif (preg_match("/\.php$/", $entry)) {
@ -8276,7 +8277,12 @@ function listAllWordsToTranslate() {
return $vars; return $vars;
} }
$vars = listAll($global['systemRootPath']); $vars1 = listAll($global['systemRootPath'].'plugins');
$vars2 = listAll($global['systemRootPath'].'view');
$vars3 = listAll($global['systemRootPath'].'objects');
$vars = array_merge($vars1, $vars2, $vars3);
sort($vars); sort($vars);
ObjectYPT::setCache($cacheName, $vars); ObjectYPT::setCache($cacheName, $vars);
return $vars; return $vars;

View file

@ -4,6 +4,7 @@ require_once $global['systemRootPath'] . 'objects/functions.php';
$securityFilter = ['jump','videoDownloadedLink','duration','error', 'msg', 'info', 'warning', 'success','toast', 'catName', 'type', 'channelName', 'captcha', 'showOnly', 'key', 'link', 'email', 'country', 'region', 'videoName']; $securityFilter = ['jump','videoDownloadedLink','duration','error', 'msg', 'info', 'warning', 'success','toast', 'catName', 'type', 'channelName', 'captcha', 'showOnly', 'key', 'link', 'email', 'country', 'region', 'videoName'];
$securityFilterInt = ['isAdmin', 'priority', 'totalClips', 'rowCount']; $securityFilterInt = ['isAdmin', 'priority', 'totalClips', 'rowCount'];
$securityRemoveSingleQuotes = ['search', 'searchPhrase', 'videoName', 'databaseName', 'sort', 'user', 'pass', 'encodedPass', 'isAdmin', 'videoLink', 'video_password']; $securityRemoveSingleQuotes = ['search', 'searchPhrase', 'videoName', 'databaseName', 'sort', 'user', 'pass', 'encodedPass', 'isAdmin', 'videoLink', 'video_password'];
$securityRemoveNonCharsStrict = ['APIName','APIPlugin'];
$securityRemoveNonChars = ['resolution', 'format', 'videoDirectory', 'chunkFile']; $securityRemoveNonChars = ['resolution', 'format', 'videoDirectory', 'chunkFile'];
$filterURL = ['videoURL', 'siteURL', 'redirectUri', 'encoderURL']; $filterURL = ['videoURL', 'siteURL', 'redirectUri', 'encoderURL'];
@ -50,11 +51,25 @@ foreach ($scanVars as $value) {
foreach ($securityRemoveNonChars as $value) { foreach ($securityRemoveNonChars as $value) {
if (!empty($scanThis[$value])) { if (!empty($scanThis[$value])) {
if (is_string($scanThis[$value])) { if (is_string($scanThis[$value])) {
$scanThis[$value] = str_replace('/[^a-z0-9./_-]/i', '', trim($scanThis[$value])); $scanThis[$value] = preg_replace('/[^a-z0-9./_-]/i', '', trim($scanThis[$value]));
} elseif (is_array($scanThis[$value])) { } elseif (is_array($scanThis[$value])) {
foreach ($scanThis[$value] as $key => $value2) { foreach ($scanThis[$value] as $key => $value2) {
if (is_string($scanThis[$value][$key])) { if (is_string($scanThis[$value][$key])) {
$scanThis[$value][$key] = str_replace('/[^a-z0-9./_-]/i', '', trim($scanThis[$value][$key])); $scanThis[$value][$key] = preg_replace('/[^a-z0-9./_-]/i', '', trim($scanThis[$value][$key]));
}
}
}
}
}
foreach ($securityRemoveNonCharsStrict as $value) {
if (!empty($scanThis[$value])) {
if (is_string($scanThis[$value])) {
$scanThis[$value] = preg_replace('/[^a-z0-9_]/i', '', trim($scanThis[$value]));
} elseif (is_array($scanThis[$value])) {
foreach ($scanThis[$value] as $key => $value2) {
if (is_string($scanThis[$value][$key])) {
$scanThis[$value][$key] = preg_replace('/[^a-z0-9_]/i', '', trim($scanThis[$value][$key]));
} }
} }
} }

View file

@ -190,7 +190,7 @@ if (typeof gtag !== \"function\") {
} }
public function addExternalOptions($id, $value) { public function addExternalOptions($id, $value) {
$eo = unserialize(base64_decode($this->externalOptions)); $eo = User::decodeExternalOption($this->externalOptions);
if (!is_array($eo)) { if (!is_array($eo)) {
$eo = []; $eo = [];
} }
@ -200,7 +200,7 @@ if (typeof gtag !== \"function\") {
} }
public function removeExternalOptions($id) { public function removeExternalOptions($id) {
$eo = unserialize(base64_decode($this->externalOptions)); $eo = User::decodeExternalOption($this->externalOptions);
unset($eo[$id]); unset($eo[$id]);
$this->setExternalOptions($eo); $this->setExternalOptions($eo);
return $this->save(); return $this->save();
@ -213,7 +213,7 @@ if (typeof gtag !== \"function\") {
} }
public function getExternalOption($id) { public function getExternalOption($id) {
$eo = unserialize(base64_decode($this->externalOptions)); $eo = User::decodeExternalOption($this->externalOptions);
if (empty($eo[$id])) { if (empty($eo[$id])) {
return null; return null;
} }
@ -1173,7 +1173,7 @@ if (typeof gtag !== \"function\") {
public static function externalOptions($id) { public static function externalOptions($id) {
if (!empty($_SESSION['user']['externalOptions'])) { if (!empty($_SESSION['user']['externalOptions'])) {
$externalOptions = unserialize(base64_decode($_SESSION['user']['externalOptions'])); $externalOptions = User::decodeExternalOption($_SESSION['user']['externalOptions']);
if (isset($externalOptions[$id])) { if (isset($externalOptions[$id])) {
if ($externalOptions[$id] == "true") { if ($externalOptions[$id] == "true") {
$externalOptions[$id] = true; $externalOptions[$id] = true;
@ -1193,12 +1193,16 @@ if (typeof gtag !== \"function\") {
} }
return self::externalOptionsFromUserID($this->id, $id); return self::externalOptionsFromUserID($this->id, $id);
} }
public function _getExternalOptions() {
return $this->externalOptions;
}
public static function externalOptionsFromUserID($users_id, $id) { public static function externalOptionsFromUserID($users_id, $id) {
$user = self::findById($users_id); $user = self::findById($users_id);
if ($user) { if ($user) {
if (!is_null($user['externalOptions'])) { if (!is_null($user['externalOptions'])) {
$externalOptions = unserialize(base64_decode($user['externalOptions'])); $externalOptions = User::decodeExternalOption($user['externalOptions']);
if (is_array($externalOptions) && sizeof($externalOptions) > 0) { if (is_array($externalOptions) && sizeof($externalOptions) > 0) {
//var_dump($externalOptions); //var_dump($externalOptions);
foreach ($externalOptions as $k => $v) { foreach ($externalOptions as $k => $v) {
@ -1466,7 +1470,7 @@ if (typeof gtag !== \"function\") {
$user['name'] = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/u', '', $user['name']); $user['name'] = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/u', '', $user['name']);
$user['isEmailVerified'] = $user['emailVerified']; $user['isEmailVerified'] = $user['emailVerified'];
if (!is_null($user['externalOptions'])) { if (!is_null($user['externalOptions'])) {
$externalOptions = unserialize(base64_decode($user['externalOptions'])); $externalOptions = User::decodeExternalOption($user['externalOptions']);
if (is_array($externalOptions) && sizeof($externalOptions) > 0) { if (is_array($externalOptions) && sizeof($externalOptions) > 0) {
foreach ($externalOptions as $k => $v) { foreach ($externalOptions as $k => $v) {
if ($v == "true") { if ($v == "true") {
@ -1756,6 +1760,13 @@ if (typeof gtag !== \"function\") {
return $user; return $user;
} }
public static function decodeExternalOption($externalOptions){
if(is_string($externalOptions)){
$externalOptions = unserialize(base64_decode($externalOptions));
}
return $externalOptions;
}
private static function getUserInfoFromRow($row) { private static function getUserInfoFromRow($row) {
$row['groups'] = UserGroups::getUserGroups($row['id']); $row['groups'] = UserGroups::getUserGroups($row['id']);
@ -1766,7 +1777,7 @@ if (typeof gtag !== \"function\") {
$row['name'] = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/u', '', $row['name']); $row['name'] = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/u', '', $row['name']);
$row['isEmailVerified'] = $row['emailVerified']; $row['isEmailVerified'] = $row['emailVerified'];
if (!is_null($row['externalOptions'])) { if (!is_null($row['externalOptions'])) {
$externalOptions = unserialize(base64_decode($row['externalOptions'])); $externalOptions = self::decodeExternalOption($row['externalOptions']);
if (is_array($externalOptions) && sizeof($externalOptions) > 0) { if (is_array($externalOptions) && sizeof($externalOptions) > 0) {
foreach ($externalOptions as $k => $v) { foreach ($externalOptions as $k => $v) {
if ($v == "true") { if ($v == "true") {

View file

@ -792,7 +792,7 @@ if (!class_exists('Video')) {
} }
} }
_mysql_connect(); _mysql_connect();
$sql = "SELECT STRAIGHT_JOIN u.*, v.*, " $sql = "SELECT STRAIGHT_JOIN u.*, u.externalOptions as userExternalOptions, v.*, "
. " nv.title as next_title," . " nv.title as next_title,"
. " nv.clean_title as next_clean_title," . " nv.clean_title as next_clean_title,"
. " nv.filename as next_filename," . " nv.filename as next_filename,"
@ -1162,7 +1162,7 @@ if (!class_exists('Video')) {
$suggestedOnly = true; $suggestedOnly = true;
$status = ''; $status = '';
} }
$sql = "SELECT STRAIGHT_JOIN u.*, v.*, c.iconClass, c.name as category, c.clean_name as clean_category,c.description as category_description," $sql = "SELECT STRAIGHT_JOIN u.*, u.externalOptions as userExternalOptions, v.*, c.iconClass, c.name as category, c.clean_name as clean_category,c.description as category_description,"
. " v.created as videoCreation, v.modified as videoModified " . " v.created as videoCreation, v.modified as videoModified "
//. ", (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = 1 ) as likes " //. ", (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = 1 ) as likes "
//. ", (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = -1 ) as dislikes " //. ", (SELECT count(id) FROM likes as l where l.videos_id = v.id AND `like` = -1 ) as dislikes "
@ -1433,6 +1433,9 @@ if (!class_exists('Video')) {
} }
if (empty($obj['externalOptions'])) { if (empty($obj['externalOptions'])) {
$obj['externalOptions'] = json_encode(['videoStartSeconds' => '00:00:00']); $obj['externalOptions'] = json_encode(['videoStartSeconds' => '00:00:00']);
}
if (!empty($obj['userExternalOptions']) && is_string($obj['userExternalOptions'])) {
$obj['userExternalOptions'] = User::decodeExternalOption($obj['userExternalOptions']);
} }
$obj = cleanUpRowFromDatabase($obj); $obj = cleanUpRowFromDatabase($obj);
return $obj; return $obj;
@ -1502,6 +1505,10 @@ if (!class_exists('Video')) {
if (empty($row['externalOptions'])) { if (empty($row['externalOptions'])) {
$row['externalOptions'] = json_encode(['videoStartSeconds' => '00:00:00']); $row['externalOptions'] = json_encode(['videoStartSeconds' => '00:00:00']);
} }
if (!empty($row['userExternalOptions']) && is_string($row['userExternalOptions'])) {
$row['userExternalOptions'] = User::decodeExternalOption($row['userExternalOptions']);
}
//var_dump($row['userExternalOptions']);exit;
$row = array_merge($row, AVideoPlugin::getAllVideosArray($row['id'])); $row = array_merge($row, AVideoPlugin::getAllVideosArray($row['id']));
TimeLogEnd($timeLogName, __LINE__, $TimeLogLimit); TimeLogEnd($timeLogName, __LINE__, $TimeLogLimit);
ObjectYPT::setCache($name, $row); ObjectYPT::setCache($name, $row);

View file

@ -3,6 +3,7 @@
global $global; global $global;
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php'; require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
class API extends PluginAbstract { class API extends PluginAbstract {
public function getTags() { public function getTags() {
@ -41,7 +42,7 @@ class API extends PluginAbstract {
public function getEmptyDataObject() { public function getEmptyDataObject() {
global $global; global $global;
$obj = new stdClass(); $obj = new stdClass();
$obj->APISecret = md5($global['systemRootPath']); $obj->APISecret = md5($global['salt'].$global['systemRootPath'].'API');
return $obj; return $obj;
} }
@ -65,12 +66,20 @@ class API extends PluginAbstract {
$user = new User("", $parameters['user'], $parameters['password']); $user = new User("", $parameters['user'], $parameters['password']);
$user->login(false, @$parameters['encodedPass']); $user->login(false, @$parameters['encodedPass']);
} }
$APIName = $parameters['APIName'];
if (method_exists($this, "set_api_$APIName")) { if (method_exists($this, "set_api_$APIName")) {
$str = "\$object = \$this->set_api_$APIName(\$parameters);"; $str = "\$object = \$this->set_api_$APIName(\$parameters);";
eval($str); eval($str);
} else { } else {
$object = new ApiObject(); $method = "API_set_{$parameters['APIName']}";
if (!empty($parameters['APIPlugin']) &&
AVideoPlugin::isEnabledByName($parameters['APIPlugin']) &&
method_exists($parameters['APIPlugin'], $method)) {
$str = "\$object = {$parameters['APIPlugin']}::{$method}(\$parameters);";
eval($str);
} else {
$object = new ApiObject();
}
} }
} }
return $object; return $object;
@ -95,7 +104,15 @@ class API extends PluginAbstract {
$str = "\$object = \$this->get_api_$APIName(\$parameters);"; $str = "\$object = \$this->get_api_$APIName(\$parameters);";
eval($str); eval($str);
} else { } else {
$object = new ApiObject(); $method = "API_get_{$parameters['APIName']}";
if (!empty($parameters['APIPlugin']) &&
AVideoPlugin::isEnabledByName($parameters['APIPlugin']) &&
method_exists($parameters['APIPlugin'], $method)) {
$str = "\$object = {$parameters['APIPlugin']}::{$method}(\$parameters);";
eval($str);
} else {
$object = new ApiObject();
}
} }
} }
return $object; return $object;
@ -1576,7 +1593,7 @@ class API extends PluginAbstract {
exit; exit;
} }
private static function isAPISecretValid(){ public static function isAPISecretValid(){
global $global; global $global;
if(!empty($_REQUEST['APISecret'])){ if(!empty($_REQUEST['APISecret'])){
$dataObj = AVideoPlugin::getDataObject('API'); $dataObj = AVideoPlugin::getDataObject('API');

View file

@ -4,18 +4,15 @@ if (!isset($global['systemRootPath'])) {
require_once '../../videos/configuration.php'; require_once '../../videos/configuration.php';
} }
if (!User::isAdmin()) { if (!User::isAdmin()) {
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not do this")); forbiddenPage('Admin only');
exit;
} }
require_once $global['systemRootPath'] . 'plugin/API/API.php'; require_once $global['systemRootPath'] . 'plugin/API/API.php';
$plugin = AVideoPlugin::loadPluginIfEnabled("API"); $plugin = AVideoPlugin::loadPluginIfEnabled("API");
if (empty($plugin)) { if (empty($plugin)) {
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not do this")); forbiddenPage('API Plugin disabled');
exit;
} }
$obj = AVideoPlugin::getObjectData("API"); $obj = AVideoPlugin::getObjectData("API");
$reflector = new ReflectionClass('API');
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?php echo getLanguage(); ?>"> <html lang="<?php echo getLanguage(); ?>">
@ -36,21 +33,41 @@ $reflector = new ReflectionClass('API');
<body class="<?php echo $global['bodyClass']; ?>"> <body class="<?php echo $global['bodyClass']; ?>">
<?php <?php
include $global['systemRootPath'] . 'view/include/navbar.php'; include $global['systemRootPath'] . 'view/include/navbar.php';
$methodsList = array();
$reflector = new ReflectionClass('API');
$class_methods = get_class_methods('API'); $class_methods = get_class_methods('API');
foreach ($class_methods as $key => $method_name) { foreach ($class_methods as $key => $method[0]) {
if (!preg_match("/(get|set)_api_(.*)/", $method_name, $matches)) { if (preg_match("/(get|set)_api_(.*)/", $method[0], $matches)) {
unset($class_methods[$key]); $methodsList[] = array($method[0], $reflector, $matches[1], $matches[2], '');
} }
} }
usort($class_methods, function ($a, $b) {
if (!preg_match("/(get|set)_api_(.*)/", $a, $matchesA)) { $plugins = Plugin::getAllEnabled();
return 0; foreach ($plugins as $value) {
$p = AVideoPlugin::loadPlugin($value['dirName']);
$class_methods = get_class_methods($value['dirName']);
$reflector = new ReflectionClass($value['dirName']);
foreach ($class_methods as $key => $method[0]) {
if (preg_match("/API_(get|set)_(.*)/", $method[0], $matches)) {
$methodsList[] = array($method[0], $reflector, $matches[1], $matches[2], $value['dirName']);
}
} }
if (!preg_match("/(get|set)_api_(.*)/", $b, $matchesB)) { }
return 0;
} /*
return strcasecmp($matchesA[2], $matchesB[2]); usort($class_methods, function ($a, $b) {
}); if (!preg_match("/(get|set)_api_(.*)/", $a, $matchesA)) {
return 0;
}
if (!preg_match("/(get|set)_api_(.*)/", $b, $matchesB)) {
return 0;
}
return strcasecmp($matchesA[2], $matchesB[2]);
});
*
*/
?> ?>
<div class="container-fluid"> <div class="container-fluid">
<ul class="list-group"> <ul class="list-group">
@ -63,12 +80,12 @@ $reflector = new ReflectionClass('API');
Your HTML Form should looks like this. The user and the pass values on the action URL will be the video owner Your HTML Form should looks like this. The user and the pass values on the action URL will be the video owner
<pre><?php <pre><?php
$frm = '<form enctype="multipart/form-data" method="post" action="' . $global['webSiteRootURL'] . 'plugin/MobileManager/upload.php?user=' . urlencode(User::getUserName()) . '&pass=' . User::getUserPass() . '"> $frm = '<form enctype="multipart/form-data" method="post" action="' . $global['webSiteRootURL'] . 'plugin/MobileManager/upload.php?user=' . urlencode(User::getUserName()) . '&pass=' . User::getUserPass() . '">
<input name="title" type="text" /><br> <input name="title" type="text" /><br>
<textarea name="description"></textarea><br> <textarea name="description"></textarea><br>
<input name="categories_id" type="hidden" value="1" /> <input name="categories_id" type="hidden" value="1" />
<input name="upl" type="file" accept="video/mp4" /><br> <input name="upl" type="file" accept="video/mp4" /><br>
<input type="submit" value="submit" id="submit"/> <input type="submit" value="submit" id="submit"/>
</form>'; </form>';
echo htmlentities($frm); echo htmlentities($frm);
?> ?>
</pre> </pre>
@ -78,24 +95,30 @@ $reflector = new ReflectionClass('API');
</details> </details>
</li> </li>
<?php <?php
foreach ($class_methods as $method_name) { foreach ($methodsList as $method) {
if (!preg_match("/(get|set)_api_(.*)/", $method_name, $matches)) { if (!preg_match("/(get|set)_api_(.*)/", $method[0], $matches)) {
continue; if (!preg_match("/API_(get|set)_(.*)/", $method[0], $matches)) {
} ?> continue;
}
}
$reflector = $method[1];
$icon = 'fas fa-sign-out-alt';
if($method[2] === "GET"){
$icon = 'fas fa-sign-in-alt';
}
?>
<li class="list-group-item"> <li class="list-group-item">
<details> <details>
<summary style="cursor: pointer;"><i class="fas fa-sign-<?php echo strtoupper($matches[1]) === "GET" ? "out" : "in" ?>-alt"></i> <?php echo strtoupper($matches[1]) ?> <?php echo $matches[2] ?></summary> <summary style="cursor: pointer;"><i class="<?php echo $icon; ?>"></i> <?php echo strtoupper($method[2]) ?> <?php echo $method[3] ?></summary>
<br> <br>
<pre><?php <pre><?php
$comment = $reflector->getMethod($method_name)->getDocComment(); $comment = $reflector->getMethod($method[0])->getDocComment();
$comment = str_replace(['{webSiteRootURL}', '{getOrSet}', '{APIName}', '{APISecret}'], [$global['webSiteRootURL'], $matches[1], $matches[2], $obj->APISecret], $comment); $comment = str_replace(['{webSiteRootURL}', '{getOrSet}', '{APIPlugin}', '{APIName}', '{APISecret}'], [$global['webSiteRootURL'], $method[2], $method[4], $method[3], $obj->APISecret], $comment);
preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $comment, $match2); preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $comment, $match2);
//var_dump($match2[0]); //var_dump($match2[0]);
$link = "<a target='_blank' href='{$match2[0][0]}'>" . htmlentities($match2[0][0]) . "</a>"; $link = "<a target='_blank' href='{$match2[0][0]}'>" . htmlentities($match2[0][0]) . "</a>";
$comment = str_replace([$match2[0][0], " *"], [$link, "*"], $comment); $comment = str_replace([$match2[0][0], " *"], [$link, "*"], $comment);
echo($comment);
echo($comment);
//{webSiteRootURL}plugin/API/{getOrSet}.json.php?name={name}
?> ?>
</pre> </pre>
</details> </details>

View file

@ -295,6 +295,7 @@ class AVideoPlugin
if (empty($pluginIsLoaded)) { if (empty($pluginIsLoaded)) {
$pluginIsLoaded = []; $pluginIsLoaded = [];
} }
$name = preg_replace('/[^0-9a-z_]/i', '', $name);
$loadPluginFile = "{$global['systemRootPath']}plugin/{$name}/{$name}.php"; $loadPluginFile = "{$global['systemRootPath']}plugin/{$name}/{$name}.php";
// need to add dechex because some times it return an negative value and make it fails on javascript playlists // need to add dechex because some times it return an negative value and make it fails on javascript playlists
if (!isset($pluginIsLoaded[$name]) && empty($forceReload)) { if (!isset($pluginIsLoaded[$name]) && empty($forceReload)) {

View file

@ -517,6 +517,7 @@ Allow: .css";
} }
public static function saveVideosAddNew($post, $videos_id) { public static function saveVideosAddNew($post, $videos_id) {
self::setDoNotShowAdsOnChannel($videos_id, !_empty($post['doNotShowAdsOnThisChannel']));
self::setDoNotShowAds($videos_id, !_empty($post['doNotShowAdsOnThisVideo'])); self::setDoNotShowAds($videos_id, !_empty($post['doNotShowAdsOnThisVideo']));
self::setRedirectVideo($videos_id, @$post['redirectVideoCode'], @$post['redirectVideoURL']); self::setRedirectVideo($videos_id, @$post['redirectVideoCode'], @$post['redirectVideoURL']);
self::setShortSummaryAndMetaDescriptionVideo($videos_id,@$post['ShortSummary'], @$post['MetaDescription']); self::setShortSummaryAndMetaDescriptionVideo($videos_id,@$post['ShortSummary'], @$post['MetaDescription']);
@ -532,6 +533,19 @@ Allow: .css";
$video->setExternalOptions(json_encode($externalOptions)); $video->setExternalOptions(json_encode($externalOptions));
return $video->save(); return $video->save();
} }
public static function setDoNotShowAdsOnChannel($videos_id, $doNotShowAdsOnThisChannel) {
if (!Permissions::canAdminVideos()) {
return false;
}
$video = new Video('', '', $videos_id);
$users_id = $video->getUsers_id();
$user = new User($users_id);
$externalOptions = object_to_array(_json_decode(User::decodeExternalOption($user->_getExternalOptions())));
$externalOptions['doNotShowAdsOnThisChannel'] = $doNotShowAdsOnThisChannel;
$user->setExternalOptions(json_encode($externalOptions));
return $user->save();
}
public static function getDoNotShowAds($videos_id): bool { public static function getDoNotShowAds($videos_id): bool {
$video = new Video('', '', $videos_id); $video = new Video('', '', $videos_id);
@ -539,6 +553,14 @@ Allow: .css";
return !empty($externalOptions->doNotShowAdsOnThisVideo); return !empty($externalOptions->doNotShowAdsOnThisVideo);
} }
public static function getDoNotShowAdsChannel($videos_id): bool {
$video = new Video('', '', $videos_id);
$users_id = $video->getUsers_id();
$user = new User($users_id);
$externalOptions = object_to_array(_json_decode(User::decodeExternalOption($user->_getExternalOptions())));
return !empty($externalOptions['doNotShowAdsOnThisChannel']);
}
public static function setRedirectVideo($videos_id, $code, $url) { public static function setRedirectVideo($videos_id, $code, $url) {
if (!Permissions::canAdminVideos()) { if (!Permissions::canAdminVideos()) {
return false; return false;
@ -574,7 +596,7 @@ Allow: .css";
} }
public function showAds($videos_id): bool { public function showAds($videos_id): bool {
return !self::getDoNotShowAds($videos_id); return !self::getDoNotShowAdsChannel($videos_id) && !self::getDoNotShowAds($videos_id);
} }
} }

View file

@ -1,4 +1,5 @@
"doNotShowAdsOnThisVideo": $("#doNotShowAdsOnThisVideo").is(":checked"), "doNotShowAdsOnThisVideo": $("#doNotShowAdsOnThisVideo").is(":checked"),
"doNotShowAdsOnThisChannel": $("#doNotShowAdsOnThisChannel").is(":checked"),
"redirectVideoCode": $("#redirectVideoCode").val(), "redirectVideoCode": $("#redirectVideoCode").val(),
"redirectVideoURL": $("#redirectVideoURL").val(), "redirectVideoURL": $("#redirectVideoURL").val(),
"MetaDescription": $("#inputMetaDescription").val(), "MetaDescription": $("#inputMetaDescription").val(),

View file

@ -1,4 +1,5 @@
$("#doNotShowAdsOnThisVideo").prop("checked", false); $("#doNotShowAdsOnThisVideo").prop("checked", false);
$("#doNotShowAdsOnThisChannel").prop("checked", false);
$("#redirectVideoCode").val(0); $("#redirectVideoCode").val(0);
$("#redirectVideoURL").val(''); $("#redirectVideoURL").val('');
$("#inputMetaDescription").val(''); $("#inputMetaDescription").val('');
@ -25,4 +26,13 @@ if (typeof row.externalOptions !== 'undefined' && row.externalOptions) {
$("#inputShortSummary").val(''); $("#inputShortSummary").val('');
} }
$("#inputMetaDescription, #inputShortSummary").trigger('keyup'); $("#inputMetaDescription, #inputShortSummary").trigger('keyup');
}
if (typeof row.userExternalOptions !== 'undefined' && row.userExternalOptions) {
var json = JSON.parse(row.userExternalOptions);
if(json.doNotShowAdsOnThisChannel){
$("#doNotShowAdsOnThisChannel").prop("checked", true);
}
} }

View file

@ -4,6 +4,14 @@ if (Permissions::canAdminVideos()) {
<br> <br>
<div class="clearfix"></div> <div class="clearfix"></div>
<ul class="list-group"> <ul class="list-group">
<li class="list-group-item">
<i class="fas fa-photo-video"></i>
<?php echo __('Do NOT Show Video Ads on this channel'); ?>
<div class="material-switch pull-right">
<input id="doNotShowAdsOnThisChannel" type="checkbox" value="">
<label for="doNotShowAdsOnThisChannel" class="label-danger"></label>
</div>
</li>
<li class="list-group-item"> <li class="list-group-item">
<i class="fas fa-photo-video"></i> <i class="fas fa-photo-video"></i>
<?php echo __('Do NOT Show Video Ads on this video'); ?> <?php echo __('Do NOT Show Video Ads on this video'); ?>

View file

@ -512,7 +512,7 @@ class CustomizeUser extends PluginAbstract {
$p = AVideoPlugin::loadPlugin("CustomizeUser"); $p = AVideoPlugin::loadPlugin("CustomizeUser");
$obj = $p->getDataObject(); $obj = $p->getDataObject();
$btn = ''; $btn = '';
if (!empty($obj->enableExtraInfo)) { if (!empty(self::showExtraInfo())) {
$btn .= '<li><a data-toggle="tab" href="#tabExtraInfo' . $p->getUUID() . '">' . __('Extra Info') . '</a></li>'; $btn .= '<li><a data-toggle="tab" href="#tabExtraInfo' . $p->getUUID() . '">' . __('Extra Info') . '</a></li>';
} }
if ($obj->allowWalletDirectTransferDonation && $obj->UsersCanCustomizeWalletDirectTransferDonation) { if ($obj->allowWalletDirectTransferDonation && $obj->UsersCanCustomizeWalletDirectTransferDonation) {
@ -532,13 +532,33 @@ class CustomizeUser extends PluginAbstract {
} }
return $btn; return $btn;
} }
public static function showExtraInfo(){
global $_showExtraInfo;
if(!isset($_showExtraInfo)){
$p = AVideoPlugin::loadPlugin("CustomizeUser");
$obj = $p->getDataObject();
$_showExtraInfo = false;
if($obj->enableExtraInfo){
$_showExtraInfo = true;
}
if(!$_showExtraInfo && !$obj->disableCompanySignUp){
$rows = Users_extra_info::getAll();
$_showExtraInfo = !empty($rows);
}
if(!$_showExtraInfo && $obj->enableAffiliation){
$_showExtraInfo = true;
}
}
return $_showExtraInfo;
}
public static function profileTabContent($users_id) { public static function profileTabContent($users_id) {
global $global; global $global;
$p = AVideoPlugin::loadPlugin("CustomizeUser"); $p = AVideoPlugin::loadPlugin("CustomizeUser");
$obj = $p->getDataObject(); $obj = $p->getDataObject();
$btn = ''; $btn = '';
if (!empty($obj->enableExtraInfo)) { if (!empty(self::showExtraInfo())) {
$tabId = 'tabExtraInfo' . $p->getUUID(); $tabId = 'tabExtraInfo' . $p->getUUID();
include $global['systemRootPath'] . 'plugin/CustomizeUser/View/tabExtraInfo.php'; include $global['systemRootPath'] . 'plugin/CustomizeUser/View/tabExtraInfo.php';
} }
@ -561,7 +581,7 @@ class CustomizeUser extends PluginAbstract {
$obj = $p->getDataObject(); $obj = $p->getDataObject();
$btn = ''; $btn = '';
if (Permissions::canAdminUsers()) { if (Permissions::canAdminUsers()) {
if (empty(!$obj->enableExtraInfo)) { if (self::showExtraInfo()) {
$btn .= '<button type="button" class="btn btn-default btn-light btn-sm btn-xs btn-block" onclick="avideoAlertAJAXHTML(webSiteRootURL+\\\'plugin/CustomizeUser/View/extraInfo.php?users_id=\'+ row.id + \'\\\');" data-row-id="right" data-toggle="tooltip" data-placement="left" title="' . __('Show Extra Info') . '"><i class="fas fa-info"></i> ' . __('Extra Info') . '</button>'; $btn .= '<button type="button" class="btn btn-default btn-light btn-sm btn-xs btn-block" onclick="avideoAlertAJAXHTML(webSiteRootURL+\\\'plugin/CustomizeUser/View/extraInfo.php?users_id=\'+ row.id + \'\\\');" data-row-id="right" data-toggle="tooltip" data-placement="left" title="' . __('Show Extra Info') . '"><i class="fas fa-info"></i> ' . __('Extra Info') . '</button>';
} }
$btn .= '<button type="button" class="btn btn-default btn-light btn-sm btn-xs btn-block" onclick="avideoModalIframeSmall(webSiteRootURL+\\\'plugin/CustomizeUser/setSubscribers.php?users_id=\'+ row.id + \'\\\');" data-row-id="right" data-toggle="tooltip" data-placement="left" title="' . __('This will add a fake number of subscribers on the user subscribe button') . '"><i class="fas fa-plus"></i> ' . __('Subscribers') . '</button>'; $btn .= '<button type="button" class="btn btn-default btn-light btn-sm btn-xs btn-block" onclick="avideoModalIframeSmall(webSiteRootURL+\\\'plugin/CustomizeUser/setSubscribers.php?users_id=\'+ row.id + \'\\\');" data-row-id="right" data-toggle="tooltip" data-placement="left" title="' . __('This will add a fake number of subscribers on the user subscribe button') . '"><i class="fas fa-plus"></i> ' . __('Subscribers') . '</button>';
@ -612,7 +632,7 @@ class CustomizeUser extends PluginAbstract {
} }
return array(); return array();
} }
/*
static function getNotifications() { static function getNotifications() {
global $global, $customUser_getNotifications; global $global, $customUser_getNotifications;
$return = array(); $return = array();
@ -622,6 +642,8 @@ class CustomizeUser extends PluginAbstract {
return $return; return $return;
} }
*
*/
static function getAffiliationNotifications() { static function getAffiliationNotifications() {
global $global, $customUser_getAffiliationNotifications; global $global, $customUser_getAffiliationNotifications;

View file

@ -1,256 +1,278 @@
<?php <?php
require_once dirname(__FILE__) . '/../../../videos/configuration.php'; require_once dirname(__FILE__) . '/../../../videos/configuration.php';
class Users_affiliations extends ObjectYPT { class Users_affiliations extends ObjectYPT {
protected $id, $users_id_company, $users_id_affiliate, $status, $company_agree_date, $affiliate_agree_date; protected $id, $users_id_company, $users_id_affiliate, $status, $company_agree_date, $affiliate_agree_date;
static function getSearchFieldsNames() { static function getSearchFieldsNames() {
return array(); return array();
} }
static function getTableName() { static function getTableName() {
return 'users_affiliations'; return 'users_affiliations';
} }
static function getAllUsers($companyOnly = false) { static function getAllUsers($companyOnly = false) {
if ($companyOnly) { if ($companyOnly) {
$isCompany = User::$is_company_status_ISACOMPANY; $isCompany = User::$is_company_status_ISACOMPANY;
} else { } else {
$isCompany = User::$is_company_status_NOTCOMPANY; $isCompany = User::$is_company_status_NOTCOMPANY;
} }
$rows = User::getAllUsers(false, ['name', 'email', 'user', 'channelName', 'about'], 'a', null, $isCompany); $rows = User::getAllUsers(false, ['name', 'email', 'user', 'channelName', 'about'], 'a', null, $isCompany);
return $rows; return $rows;
} }
function setId($id) { function setId($id) {
$this->id = intval($id); $this->id = intval($id);
} }
function setUsers_id_company($users_id_company) { function setUsers_id_company($users_id_company) {
$this->users_id_company = intval($users_id_company); $this->users_id_company = intval($users_id_company);
} }
function setUsers_id_affiliate($users_id_affiliate) { function setUsers_id_affiliate($users_id_affiliate) {
$this->users_id_affiliate = intval($users_id_affiliate); $this->users_id_affiliate = intval($users_id_affiliate);
} }
function setStatus($status) { function setStatus($status) {
$this->status = $status; $this->status = $status;
} }
function setCompany_agree_date($company_agree_date) { function setCompany_agree_date($company_agree_date) {
$this->company_agree_date = $company_agree_date; $this->company_agree_date = $company_agree_date;
} }
function setAffiliate_agree_date($affiliate_agree_date) { function setAffiliate_agree_date($affiliate_agree_date) {
$this->affiliate_agree_date = $affiliate_agree_date; $this->affiliate_agree_date = $affiliate_agree_date;
} }
function getId() { function getId() {
return intval($this->id); return intval($this->id);
} }
function getUsers_id_company() { function getUsers_id_company() {
return intval($this->users_id_company); return intval($this->users_id_company);
} }
function getUsers_id_affiliate() { function getUsers_id_affiliate() {
return intval($this->users_id_affiliate); return intval($this->users_id_affiliate);
} }
function getStatus() { function getStatus() {
return $this->status; return $this->status;
} }
function getCompany_agree_date() { function getCompany_agree_date() {
return $this->company_agree_date; return $this->company_agree_date;
} }
function getAffiliate_agree_date() { function getAffiliate_agree_date() {
return $this->affiliate_agree_date; return $this->affiliate_agree_date;
} }
public static function getAll($users_id_company = 0, $users_id_affiliate = 0, $activeOnly = false) { public static function getAll($users_id_company = 0, $users_id_affiliate = 0, $activeOnly = false) {
global $global; global $global;
if (!static::isTableInstalled()) { if (!static::isTableInstalled()) {
return false; return false;
} }
$users_id_company = intval($users_id_company); $users_id_company = intval($users_id_company);
$users_id_affiliate = intval($users_id_affiliate); $users_id_affiliate = intval($users_id_affiliate);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE 1=1 "; $sql = "SELECT * FROM " . static::getTableName() . " WHERE 1=1 ";
if (!empty($users_id_company)) { if (!empty($users_id_company)) {
$sql .= "AND users_id_company = $users_id_company "; $sql .= "AND users_id_company = $users_id_company ";
} }
if (!empty($users_id_affiliate)) { if (!empty($users_id_affiliate)) {
$sql .= "AND users_id_affiliate = $users_id_affiliate "; $sql .= "AND users_id_affiliate = $users_id_affiliate ";
} }
if (!empty($activeOnly)) { if (!empty($activeOnly)) {
$sql .= "AND status = 'a' "; $sql .= "AND status = 'a' ";
} }
//$sql .= self::getSqlFromPost(); //$sql .= self::getSqlFromPost();
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res); $fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res); sqlDAL::close($res);
$rows = []; $rows = [];
if ($res !== false) { if ($res !== false) {
foreach ($fullData as $row) { foreach ($fullData as $row) {
if ($row['company_agree_date'] === '0000-00-00 00:00:00') { if ($row['company_agree_date'] === '0000-00-00 00:00:00') {
$row['company_agree_date'] = null; $row['company_agree_date'] = null;
} }
if ($row['affiliate_agree_date'] === '0000-00-00 00:00:00') { if ($row['affiliate_agree_date'] === '0000-00-00 00:00:00') {
$row['affiliate_agree_date'] = null; $row['affiliate_agree_date'] = null;
} }
$row['company'] = User::getNameIdentificationById($row['users_id_company']); $row['company'] = User::getNameIdentificationById($row['users_id_company']);
$row['affiliate'] = User::getNameIdentificationById($row['users_id_affiliate']); $row['affiliate'] = User::getNameIdentificationById($row['users_id_affiliate']);
$rows[] = $row; $rows[] = $row;
} }
} else { } else {
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
} }
return $rows; return $rows;
} }
public static function getTotal($users_id_company = 0, $users_id_affiliate = 0, $activeOnly = false) { public static function getTotal($users_id_company = 0, $users_id_affiliate = 0, $activeOnly = false) {
//will receive //will receive
//current=1&rowCount=10&sort[sender]=asc&searchPhrase= //current=1&rowCount=10&sort[sender]=asc&searchPhrase=
global $global; global $global;
if (!static::isTableInstalled()) { if (!static::isTableInstalled()) {
return 0; return 0;
} }
$sql = "SELECT id FROM " . static::getTableName() . " WHERE 1=1 "; $sql = "SELECT id FROM " . static::getTableName() . " WHERE 1=1 ";
if (!empty($users_id_company)) { if (!empty($users_id_company)) {
$sql .= "AND users_id_company = $users_id_company "; $sql .= "AND users_id_company = $users_id_company ";
} }
if (!empty($users_id_affiliate)) { if (!empty($users_id_affiliate)) {
$sql .= "AND users_id_affiliate = $users_id_affiliate "; $sql .= "AND users_id_affiliate = $users_id_affiliate ";
} }
if (!empty($activeOnly)) { if (!empty($activeOnly)) {
$sql .= "AND status = 'a' "; $sql .= "AND status = 'a' ";
} }
//$sql .= self::getSqlSearchFromPost(); //$sql .= self::getSqlSearchFromPost();
$res = sqlDAL::readSql($sql); $res = sqlDAL::readSql($sql);
$countRow = sqlDAL::num_rows($res); $countRow = sqlDAL::num_rows($res);
sqlDAL::close($res); sqlDAL::close($res);
return $countRow; return $countRow;
} }
public function save() { public function save() {
if (empty($this->id) && !empty($this->users_id_company) && !empty($this->users_id_affiliate)) { if (empty($this->id) && !empty($this->users_id_company) && !empty($this->users_id_affiliate)) {
$row = self::getAll($this->users_id_company, $this->users_id_affiliate); $row = self::getAll($this->users_id_company, $this->users_id_affiliate);
//var_dump($row); //var_dump($row);
if (!empty($row)) { if (!empty($row)) {
foreach ($row as $value) { foreach ($row as $value) {
if (!empty($value['id'])) { if (!empty($value['id'])) {
$this->id = $value['id']; $this->id = $value['id'];
break; break;
} }
} }
} }
} }
if (empty($this->company_agree_date) || $this->company_agree_date == '0000-00-00 00:00:00' || $this->company_agree_date == 'NULL') { if (empty($this->company_agree_date) || $this->company_agree_date == '0000-00-00 00:00:00' || $this->company_agree_date == 'NULL') {
$this->company_agree_date = null; $this->company_agree_date = null;
} }
if (empty($this->affiliate_agree_date) || $this->affiliate_agree_date == '0000-00-00 00:00:00' || $this->affiliate_agree_date == 'NULL') { if (empty($this->affiliate_agree_date) || $this->affiliate_agree_date == '0000-00-00 00:00:00' || $this->affiliate_agree_date == 'NULL') {
$this->affiliate_agree_date = null; $this->affiliate_agree_date = null;
} }
$icon = 'fas fa-user-friends';
//var_dump($this);exit; $href = "{$global['webSiteRootURL']}user?tab=tabAffiliation";
if (!empty($this->id) && empty($this->company_agree_date) && empty($this->affiliate_agree_date)) { //var_dump($this);exit;
_error_log('Affiliation: both dates are empty, delete ' . $this->id); if (!empty($this->id) && empty($this->company_agree_date) && empty($this->affiliate_agree_date)) {
return self::deleteFromID($this->id); _error_log('Affiliation: both dates are empty, delete ' . $this->id);
} else if (!empty($this->company_agree_date) && !empty($this->affiliate_agree_date)) { return self::deleteFromID($this->id);
_error_log('Affiliation: both dates are NOT empty, make it active ' . $this->id); } else if (!empty($this->company_agree_date) && !empty($this->affiliate_agree_date)) {
$this->status = 'a'; _error_log('Affiliation: both dates are NOT empty, make it active ' . $this->id);
} else { // $this->users_id_company $this->users_id_affiliate
_error_log('Affiliation: one date is empty ' . $this->id . " company_agree_date={$this->company_agree_date} affiliate_agree_date={$this->affiliate_agree_date}"); $this->status = 'a';
$this->status = 'i'; $title = __('Affiliation Confirmed');
} $type = UserNotifications::type_success;
$msg = __('Affiliation approved');
if (empty($this->company_agree_date) || $this->company_agree_date == '0000-00-00 00:00:00' ) { } else {
$this->company_agree_date = 'NULL'; _error_log('Affiliation: one date is empty ' . $this->id . " company_agree_date={$this->company_agree_date} affiliate_agree_date={$this->affiliate_agree_date}");
} $this->status = 'i';
if (empty($this->affiliate_agree_date) || $this->affiliate_agree_date == '0000-00-00 00:00:00') { $title = __('Affiliation Updated');
$this->affiliate_agree_date = 'NULL'; $type = UserNotifications::type_warning;
} $msg = __('You have a new affiliation request');
}
if (empty($this->users_id_affiliate)) {
$this->users_id_affiliate = 'NULL'; if (empty($this->company_agree_date) || $this->company_agree_date == '0000-00-00 00:00:00') {
} $this->company_agree_date = 'NULL';
if (empty($this->users_id_company)) { }
$this->users_id_company = 'NULL'; if (empty($this->affiliate_agree_date) || $this->affiliate_agree_date == '0000-00-00 00:00:00') {
} $this->affiliate_agree_date = 'NULL';
}
return parent::save();
} if (empty($this->users_id_affiliate)) {
$this->users_id_affiliate = 'NULL';
static public function deleteFromID($id) { }
$id = intval($id); if (empty($this->users_id_company)) {
global $global; $this->users_id_company = 'NULL';
if (!empty($id)) { }
$sql = "DELETE FROM users_affiliations ";
$sql .= " WHERE id = ?"; $id = parent::save();
$global['lastQuery'] = $sql; if (!empty($id)) {
_error_log("Delete Query: " . $sql);
return sqlDAL::writeSql($sql, "i", [$id]); $sendTo = array(array($this->users_id_company, $this->users_id_affiliate), array($this->users_id_affiliate, $this->users_id_company));
}
_error_log("Id for table " . static::getTableName() . " not defined for deletion " . json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)), AVideoLog::$ERROR); foreach ($sendTo as $key => $value) {
return false; $identification = User::getNameIdentificationById($value[0]);
} $image = "user/{$value[0]}/foto.png";
$element_id = "affiliation_a{$value[0]}_b{$value[1]}_{$this->modified}";
static function canEditAffiliation($Users_affiliations_id) { $to_users_id = $value[1];
$Users_affiliations_id = intval($Users_affiliations_id); $msg .= " <strong>{$identification}</strong> ";
if (empty($Users_affiliations_id)) { UserNotifications::createNotification($title, $msg, $to_users_id, $image, $href, $type, $element_id, $icon);
return false; }
} }
return $id;
if (User::isAdmin()) { }
return true;
} static public function deleteFromID($id) {
if (!User::isLogged()) { $id = intval($id);
return false; global $global;
} if (!empty($id)) {
$sql = "DELETE FROM users_affiliations ";
$o = new Users_affiliations($Users_affiliations_id); $sql .= " WHERE id = ?";
$global['lastQuery'] = $sql;
if (empty($o->getStatus())) { _error_log("Delete Query: " . $sql);
return false; return sqlDAL::writeSql($sql, "i", [$id]);
} }
_error_log("Id for table " . static::getTableName() . " not defined for deletion " . json_encode(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)), AVideoLog::$ERROR);
if ($o->getUsers_id_affiliate() != User::getId() && $o->getUsers_id_company() != User::getId()) { return false;
return false; }
}
static function canEditAffiliation($Users_affiliations_id) {
return true; $Users_affiliations_id = intval($Users_affiliations_id);
} if (empty($Users_affiliations_id)) {
return false;
static function isUserAffiliateOrCompanyToEachOther($users_id1, $users_id2) { }
$row = self::getAll($users_id1, $users_id2, true);
if (!empty($row)) { if (User::isAdmin()) {
foreach ($row as $value) { return true;
if (!empty($value['id'])) { }
return $value; if (!User::isLogged()) {
} return false;
} }
}
$row = self::getAll($users_id2, $users_id1, true); $o = new Users_affiliations($Users_affiliations_id);
//var_dump($row);
if (!empty($row)) { if (empty($o->getStatus())) {
foreach ($row as $value) { return false;
if (!empty($value['id'])) { }
return $value;
} if ($o->getUsers_id_affiliate() != User::getId() && $o->getUsers_id_company() != User::getId()) {
} return false;
} }
return false;
} return true;
}
}
static function isUserAffiliateOrCompanyToEachOther($users_id1, $users_id2) {
$row = self::getAll($users_id1, $users_id2, true);
if (!empty($row)) {
foreach ($row as $value) {
if (!empty($value['id'])) {
return $value;
}
}
}
$row = self::getAll($users_id2, $users_id1, true);
//var_dump($row);
if (!empty($row)) {
foreach ($row as $value) {
if (!empty($value['id'])) {
return $value;
}
}
}
return false;
}
}

View file

@ -1,5 +1,6 @@
<?php <?php
$notifications = CustomizeUser::getNotifications(); $notifications = array();
//$notifications = CustomizeUser::getNotifications();
?> ?>
<!-- CustomizeUser Footer --> <!-- CustomizeUser Footer -->
<script> <script>

View file

@ -324,7 +324,7 @@ class Layout extends PluginAbstract {
return $flags; return $flags;
} }
static function getLangsSelect($name, $selected = "", $id = "", $class = "", $flagsOnly = false, $getAll = false) { static function getLangsSelect($name, $selected = "", $id = "", $class = "navbar-btn", $flagsOnly = false, $getAll = false) {
global $getLangsSelect; global $getLangsSelect;
$getLangsSelect = 1; $getLangsSelect = 1;
if ($getAll) { if ($getAll) {
@ -346,19 +346,20 @@ class Layout extends PluginAbstract {
$selectedJsonIcon = ''; $selectedJsonIcon = '';
} }
$html = '<div class="btn-group"> $html = '<div class="btn-group" id="div_'.$id.'">
<button type="button" class="btn btn-default dropdown-toggle navbar-btn" data-toggle="dropdown" aria-expanded="true"> <input type="hidden" name="'.$name.'" value="'.$selected.'" id="'.$id.'"/>
<i class="selectedflagicon ' . $selectedJsonIcon . '"></i> <span class="caret"></span> <button type="button" class="btn btn-default dropdown-toggle ' . $class . '" data-toggle="dropdown" aria-expanded="true">
<span class="flag"><i class="selectedflagicon ' . $selectedJsonIcon . '"></i></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu dropdown-menu-right" role="menu">'; <ul class="dropdown-menu dropdown-menu-right dropdown-menu-arrow" role="menu">';
$selfURI = getSelfURI(); $selfURI = getSelfURI();
foreach ($flags as $key => $value) { foreach ($flags as $key => $value) {
$info = json_decode($value[0]); $info = json_decode($value[0]);
$url = addQueryStringParameter($selfURI, 'lang', $key); $url = addQueryStringParameter($selfURI, 'lang', $key);
$html .= '<li class="dropdown-submenu"> $html .= '<li class="dropdown-submenu">
<a tabindex="-1" href="' . $url . '"> <a tabindex="-1" href="' . $url . '" value="' . $key . '" onclick="$(\'#div_'.$id.' > button > span.flag\').html($(this).find(\'span.flag\').html());$(\'input[name='.$name.']\').val(\''.$key.'\');">
<i class="' . $info->icon . '" aria-hidden="true"></i> ' . $info->text . '</a> <span class="flag"><i class="' . $info->icon . '" aria-hidden="true"></i></span> ' . $info->text . '</a>
</li>'; </li>';
} }
@ -496,7 +497,7 @@ class Layout extends PluginAbstract {
if (!AVideoPlugin::isEnabledByName('YouPHPFlix2') && !empty($obj->categoriesTopButtons)) { if (!AVideoPlugin::isEnabledByName('YouPHPFlix2') && !empty($obj->categoriesTopButtons)) {
if (!empty($obj->categoriesTopButtonsShowOnlyOnFirstPage) && !isFirstPage()) { if (!empty($obj->categoriesTopButtonsShowOnlyOnFirstPage) && !isFirstPage()) {
}else{ } else {
$content = getIncludeFileContent($global['systemRootPath'] . 'plugin/Layout/categoriesTopButtons.php'); $content = getIncludeFileContent($global['systemRootPath'] . 'plugin/Layout/categoriesTopButtons.php');
} }
} }
@ -518,11 +519,11 @@ class Layout extends PluginAbstract {
//return $html; //return $html;
if (!empty($global['doNOTOrganizeHTML'])) { if (!empty($global['doNOTOrganizeHTML'])) {
//var_dump('doNOTOrganizeHTML');exit; //var_dump('doNOTOrganizeHTML');exit;
return $html.PHP_EOL.'<!-- Layout::organizeHTML doNOTOrganizeHTML -->'; return $html . PHP_EOL . '<!-- Layout::organizeHTML doNOTOrganizeHTML -->';
} }
if (!empty($_REQUEST['debug'])) { if (!empty($_REQUEST['debug'])) {
//var_dump('doNOTOrganizeHTML');exit; //var_dump('doNOTOrganizeHTML');exit;
return $html.PHP_EOL.'<!-- Layout::organizeHTML debug -->'; return $html . PHP_EOL . '<!-- Layout::organizeHTML debug -->';
} }
self::$tags = array(); self::$tags = array();
//return $html; //return $html;
@ -537,19 +538,19 @@ class Layout extends PluginAbstract {
//var_dump(self::$tags['tagscript']);exit; //var_dump(self::$tags['tagscript']);exit;
if (!empty(self::$tags['tagcss'])) { if (!empty(self::$tags['tagcss'])) {
self::$tags['tagcss'] = self::removeDuplicated(self::$tags['tagcss']); self::$tags['tagcss'] = self::removeDuplicated(self::$tags['tagcss']);
$html = str_replace('</head>', PHP_EOL.implode(PHP_EOL, array_unique(self::$tags['tagcss'])) . '</head>', $html); $html = str_replace('</head>', PHP_EOL . implode(PHP_EOL, array_unique(self::$tags['tagcss'])) . '</head>', $html);
} }
//return $html; //return $html;
if (!empty(self::$tags['style'])) { if (!empty(self::$tags['style'])) {
$html = str_replace('</head>', '<style>' . PHP_EOL.implode(PHP_EOL, array_unique(self::$tags['style'])) . '</style></head>', $html); $html = str_replace('</head>', '<style>' . PHP_EOL . implode(PHP_EOL, array_unique(self::$tags['style'])) . '</style></head>', $html);
} }
if (!empty(self::$tags['tagscript'])) { if (!empty(self::$tags['tagscript'])) {
self::$tags['tagscript'] = self::removeDuplicated(self::$tags['tagscript']); self::$tags['tagscript'] = self::removeDuplicated(self::$tags['tagscript']);
usort(self::$tags['tagscript'], "_sortJS"); usort(self::$tags['tagscript'], "_sortJS");
$html = str_replace('</body>', PHP_EOL.implode(PHP_EOL, array_unique(self::$tags['tagscript'])) . '</body>', $html); $html = str_replace('</body>', PHP_EOL . implode(PHP_EOL, array_unique(self::$tags['tagscript'])) . '</body>', $html);
} }
if (!empty(self::$tags['script'])) { if (!empty(self::$tags['script'])) {
$html = str_replace('</body>', '<script>' . PHP_EOL.implode(PHP_EOL, array_unique(self::$tags['script'])) . '</script></body>', $html); $html = str_replace('</body>', '<script>' . PHP_EOL . implode(PHP_EOL, array_unique(self::$tags['script'])) . '</script></body>', $html);
} }
$html = self::removeExtraSpacesFromHead($html); $html = self::removeExtraSpacesFromHead($html);
$html = self::removeExtraSpacesFromScript($html); $html = self::removeExtraSpacesFromScript($html);
@ -558,11 +559,11 @@ class Layout extends PluginAbstract {
} }
private static function tryToReplace($search, $replace, $subject) { private static function tryToReplace($search, $replace, $subject) {
if(true || self::codeIsValid($subject)){ if (true || self::codeIsValid($subject)) {
$newSubject = str_replace($search, $replace, $subject, $count); $newSubject = str_replace($search, $replace, $subject, $count);
return ['newSubject' => $newSubject, 'success' => $count]; return ['newSubject' => $newSubject, 'success' => $count];
}else{ } else {
_error_log('organizeHTML: Invalid code: '.$subject); _error_log('organizeHTML: Invalid code: ' . $subject);
return ['newSubject' => $subject, 'success' => false]; return ['newSubject' => $subject, 'success' => false];
} }
} }
@ -663,13 +664,13 @@ class Layout extends PluginAbstract {
} }
return $html; return $html;
} }
static function shouldIgnoreJS($tag) { static function shouldIgnoreJS($tag) {
if ( if (
preg_match('/application.+json/i', $tag) || preg_match('/application.+json/i', $tag) ||
preg_match('/function gtag\(/i', $tag) || preg_match('/function gtag\(/i', $tag) ||
preg_match('/<script async/i', $tag) || preg_match('/<script async/i', $tag) ||
preg_match('/doNotSepareteTag/', $tag) || preg_match('/doNotSepareteTag/', $tag) ||
preg_match('/document\.write/', $tag)) { preg_match('/document\.write/', $tag)) {
return true; return true;
} }
@ -693,7 +694,7 @@ class Layout extends PluginAbstract {
$html = self::organizeHTML($html); $html = self::organizeHTML($html);
//_ob_clean(); //_ob_clean();
_ob_start(); _ob_start();
echo '<!-- Layout organizeHTML start -->'.PHP_EOL.$html.PHP_EOL.'<!-- Layout organizeHTML END -->'; echo '<!-- Layout organizeHTML start -->' . PHP_EOL . $html . PHP_EOL . '<!-- Layout organizeHTML END -->';
} }
static private function removeDuplicated($list) { static private function removeDuplicated($list) {
@ -701,15 +702,15 @@ class Layout extends PluginAbstract {
$srcList = array(); $srcList = array();
foreach ($list as $key => $value) { foreach ($list as $key => $value) {
preg_match('/<script.+src=["\']([^"\']+)["\']/i', $value, $matches); preg_match('/<script.+src=["\']([^"\']+)["\']/i', $value, $matches);
if(!empty($matches[1])){ if (!empty($matches[1])) {
if(!in_array($matches[1], $srcList)){ if (!in_array($matches[1], $srcList)) {
$cleanList[] = $value; $cleanList[] = $value;
$srcList[] = $matches[1]; $srcList[] = $matches[1];
} }
}else{ } else {
preg_match('/<link.+href=["\']([^"\']+)["\']/i', $value, $matches); preg_match('/<link.+href=["\']([^"\']+)["\']/i', $value, $matches);
if(!empty($matches[1])){ if (!empty($matches[1])) {
if(!in_array($matches[1], $srcList)){ if (!in_array($matches[1], $srcList)) {
$cleanList[] = $value; $cleanList[] = $value;
$srcList[] = $matches[1]; $srcList[] = $matches[1];
} }
@ -718,25 +719,24 @@ class Layout extends PluginAbstract {
} }
//var_dump($srcList);exit; //var_dump($srcList);exit;
return $cleanList; return $cleanList;
} }
static function getSuggestedButton($videos_id, $class='btn btn-xs'){ static function getSuggestedButton($videos_id, $class = 'btn btn-xs') {
global $global; global $global;
if(empty($videos_id)){ if (empty($videos_id)) {
return ''; return '';
} }
if(!Permissions::canAdminVideos()){ if (!Permissions::canAdminVideos()) {
return ''; return '';
} }
$varsArray = array('videos_id'=>$videos_id, 'class'=>$class); $varsArray = array('videos_id' => $videos_id, 'class' => $class);
$filePath = $global['systemRootPath'] . 'plugin/Layout/suggestedButton.php'; $filePath = $global['systemRootPath'] . 'plugin/Layout/suggestedButton.php';
return getIncludeFileContent($filePath, $varsArray); return getIncludeFileContent($filePath, $varsArray);
} }
} }
function _sortJS($a, $b){ function _sortJS($a, $b) {
// make it first // make it first
if (preg_match('/jquery(.min)?.js/i', $a)) { if (preg_match('/jquery(.min)?.js/i', $a)) {
return -1; return -1;
@ -762,11 +762,11 @@ function _sortJS($a, $b){
if (preg_match('/js.cookie.js/i', $b)) { if (preg_match('/js.cookie.js/i', $b)) {
return 1; return 1;
} }
// videojs // videojs
if (preg_match('/video\.?js/i', $a) || preg_match('/video\.?js/i', $b)) { if (preg_match('/video\.?js/i', $a) || preg_match('/video\.?js/i', $b)) {
if (preg_match('/node_modules.video.js.dist.video/i', $a)) { if (preg_match('/node_modules.video.js.dist.video/i', $a)) {
return -1; return -1;
} }
if (preg_match('/node_modules.video.js.dist.video/i', $b)) { if (preg_match('/node_modules.video.js.dist.video/i', $b)) {
return 1; return 1;
@ -786,8 +786,8 @@ function _sortJS($a, $b){
} }
return 1; return 1;
} }
// make it last // make it last
if (preg_match('/js.script.js/i', $a)) { if (preg_match('/js.script.js/i', $a)) {
return 1; return 1;
@ -801,7 +801,7 @@ function _sortJS($a, $b){
if (preg_match('/\/plugin\//', $b)) { if (preg_match('/\/plugin\//', $b)) {
return -1; return -1;
} }
// moment timezone must be after moment // moment timezone must be after moment
if (preg_match('/\/moment-timezone\//', $a) && preg_match('/\/moment\//', $b)) { if (preg_match('/\/moment-timezone\//', $a) && preg_match('/\/moment\//', $b)) {
return 1; return 1;
@ -816,7 +816,7 @@ function _sortJS($a, $b){
return 1; return 1;
} }
// lazy plugin must be after lazy // lazy plugin must be after lazy
if(preg_match('/jquery\.lazy/', $a) || preg_match('/\/jquery\.lazy/', $b)){ if (preg_match('/jquery\.lazy/', $a) || preg_match('/\/jquery\.lazy/', $b)) {
if (preg_match('/\/jquery\.lazy\.plugins\.min\.js/', $a) || preg_match('/\/jquery\.lazy\.min\.js/', $b)) { if (preg_match('/\/jquery\.lazy\.plugins\.min\.js/', $a) || preg_match('/\/jquery\.lazy\.min\.js/', $b)) {
return 1; return 1;
} }
@ -824,6 +824,6 @@ function _sortJS($a, $b){
return -1; return -1;
} }
} }
return 0; return 0;
} }

View file

@ -9,7 +9,7 @@
<i class="fas fa-bell-slash text-muted" data-toggle="tooltip" title="<?php echo __('There are no notifications'); ?>" data-placement="bottom" ></i> <i class="fas fa-bell-slash text-muted" data-toggle="tooltip" title="<?php echo __('There are no notifications'); ?>" data-placement="bottom" ></i>
</a> </a>
</div> </div>
<ul class="dropdown-menu dropdown-menu-right hideWhenHasNothingToShow"> <ul class="dropdown-menu dropdown-menu-right dropdown-menu-arrow hideWhenHasNothingToShow">
<div class="btn-group btn-group-justified"> <div class="btn-group btn-group-justified">
<?php <?php
echo AVideoPlugin::getUserNotificationButton(); echo AVideoPlugin::getUserNotificationButton();

View file

@ -169,8 +169,28 @@ class User_notifications extends ObjectYPT {
public function save() { public function save() {
if (empty($this->element_id)) { if (empty($this->element_id)) {
$this->element_id = 'automatic_id_' . uniqid(); $this->element_id = 'automatic_id_' . uniqid();
}else{
if(self::elementIdExists($this->element_id)){
return false;
}
} }
return parent::save(); return parent::save();
} }
static function elementIdExists($element_id){
global $global;
$sql = "SELECT * FROM " . static::getTableName() . " WHERE element_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, "s", [$element_id], true);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
$row = $data;
} else {
$row = false;
}
return $row;
}
} }

View file

@ -209,7 +209,7 @@ class UserNotifications extends PluginAbstract {
return self::createNotification($title, $msg, $users_id, $image, $href, $type, $element_id, $icon); return self::createNotification($title, $msg, $users_id, $image, $href, $type, $element_id, $icon);
} }
public function createNotification($title, $msg = '', $to_users_id = 0, $image = '', $href = '', $type = '', $element_id = '', $icon = '', $element_class = '', $onclick = '', $priority = '') { public static function createNotification($title, $msg = '', $to_users_id = 0, $image = '', $href = '', $type = '', $element_id = '', $icon = '', $element_class = '', $onclick = '', $priority = '') {
if($to_users_id == User::getId()){ if($to_users_id == User::getId()){
return false; return false;
} }

View file

@ -23,7 +23,7 @@ $balance = $plugin->getBalance(User::getId());
<?php <?php
} }
?> ?>
<ul class="dropdown-menu dropdown-menu-right" role="menu"> <ul class="dropdown-menu dropdown-menu-right dropdown-menu-arrow" role="menu">
<?php <?php
if ($obj->enableAutomaticAddFundsPage) { if ($obj->enableAutomaticAddFundsPage) {
?> ?>

View file

@ -951,6 +951,31 @@ li.dropdown-submenu > ul > li > a{
width: 100%; width: 100%;
} }
.dropdown-menu.dropdown-menu-arrow:before {
position: absolute;
top: -7px;
right: 20px;
display: inline-block;
border-right: 7px solid transparent;
border-bottom: 7px solid #ccc;
border-left: 7px solid transparent;
border-bottom-color: rgba(0, 0, 0, 0.2);
content: '';
}
.dropdown-menu.dropdown-menu-arrow:after {
position: absolute;
top: -6px;
right: 20px;
display: inline-block;
border-right: 6px solid transparent;
border-bottom: 6px solid #ffffff;
border-left: 6px solid transparent;
content: '';
}
#topMenuUserNotifications > ul > div.list-group{
overflow-x: hidden;
}
.socket_not_loading{ .socket_not_loading{
display: none; display: none;

View file

@ -12,7 +12,7 @@ if (!empty($getUploadMenuButton)) {
<i class="<?php echo $advancedCustom->uploadButtonDropdownIcon ?? "fas fa-video"; ?>"></i> <?php echo!empty($advancedCustom->uploadButtonDropdownText) ? __($advancedCustom->uploadButtonDropdownText) : ""; ?> <span class="caret"></span> <i class="<?php echo $advancedCustom->uploadButtonDropdownIcon ?? "fas fa-video"; ?>"></i> <?php echo!empty($advancedCustom->uploadButtonDropdownText) ? __($advancedCustom->uploadButtonDropdownText) : ""; ?> <span class="caret"></span>
</button> </button>
<?php echo '<!-- navbar line ' . __LINE__ . '-->'; ?> <?php echo '<!-- navbar line ' . __LINE__ . '-->'; ?>
<ul class="dropdown-menu dropdown-menu-right" role="menu" id="uploadMenu"> <ul class="dropdown-menu dropdown-menu-right dropdown-menu-arrow " role="menu" id="uploadMenu">
<?php echo $getUploadMenuButton; ?> <?php echo $getUploadMenuButton; ?>
</ul> </ul>
</div> </div>

View file

@ -8,7 +8,7 @@
if ((isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && $advancedCustomUser->onlyVerifiedEmailCanUpload && User::isVerified()) || (isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && !$advancedCustomUser->onlyVerifiedEmailCanUpload) || !isset($advancedCustomUser->onlyVerifiedEmailCanUpload)) { if ((isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && $advancedCustomUser->onlyVerifiedEmailCanUpload && User::isVerified()) || (isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && !$advancedCustomUser->onlyVerifiedEmailCanUpload) || !isset($advancedCustomUser->onlyVerifiedEmailCanUpload)) {
echo '<!-- navbar line ' . __LINE__ . '-->'; echo '<!-- navbar line ' . __LINE__ . '-->';
?> ?>
<ul class="dropdown-menu dropdown-menu-right" role="menu" id="uploadMenu"> <ul class="dropdown-menu dropdown-menu-right dropdown-menu-arrow " role="menu" id="uploadMenu">
<?php <?php
include $global['systemRootPath'] . 'view/include/navbarEncoder.php'; include $global['systemRootPath'] . 'view/include/navbarEncoder.php';
if (empty($advancedCustom->doNotShowUploadMP4Button)) { if (empty($advancedCustom->doNotShowUploadMP4Button)) {
@ -55,7 +55,7 @@
} else { } else {
echo '<!-- navbar line ' . __LINE__ . '-->'; echo '<!-- navbar line ' . __LINE__ . '-->';
?> ?>
<ul class="dropdown-menu dropdown-menu-right" role="menu" id="uploadMenu"> <ul class="dropdown-menu dropdown-menu-right dropdown-menu-arrow " role="menu" id="uploadMenu">
<li> <li>
<a href="" > <a href="" >
<span class="fa fa-exclamation faa-flash animated"></span> <?php echo __("Only verified users can upload"); ?> <span class="fa fa-exclamation faa-flash animated"></span> <?php echo __("Only verified users can upload"); ?>

View file

@ -7,7 +7,7 @@ $users_tabs[] = array('selector' => 'gridAdmin', 'queryString' => '?isAdmin=1',
if (empty($advancedCustomUser->disableCompanySignUp)) { if (empty($advancedCustomUser->disableCompanySignUp)) {
$users_tabs[] = array('selector' => 'companyAdmin', 'queryString' => '?isCompany=1', 'icon' => 'fas fa-building', 'title' => 'Company Users', 'active' => '', 'userGroupID' => 0); $users_tabs[] = array('selector' => 'companyAdmin', 'queryString' => '?isCompany=1', 'icon' => 'fas fa-building', 'title' => 'Company Users', 'active' => '', 'userGroupID' => 0);
$users_tabs[] = array('selector' => 'companyApAdmin', 'queryString' => '?isCompany=0', 'icon' => 'fas fa-building', 'title' => 'Company Waiting Approval', 'active' => '', 'userGroupID' => 0); $users_tabs[] = array('selector' => 'companyApAdmin', 'queryString' => '?isCompany=2', 'icon' => 'fas fa-building', 'title' => 'Company Waiting Approval', 'active' => '', 'userGroupID' => 0);
} }
foreach ($userGroups as $value) { foreach ($userGroups as $value) {

View file

@ -47,7 +47,7 @@ $subscribe->save();
</div> </div>
<div class="panel-body"> <div class="panel-body">
<h1><?php echo __("You've unsubscribed"); ?></h1> <h1><?php echo __("You've unsubscribed"); ?></h1>
<?php echo __(" You'll no longer receive emails from us"); ?> <?php echo __("You'll no longer receive emails from us"); ?>
</div> </div>
</div> </div>