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");
die(json_encode($obj));
}
$dir = "{$global['systemRootPath']}locale/";
if(empty($_REQUEST['custom'])){
$dir = "{$global['systemRootPath']}locale/";
}else{
$dir = "{$global['systemRootPath']}videos/locale/";
make_path($dir);
}
if (!is_writable($dir) && !isWindows()) {
$obj->status = 0;
$obj->error = sprintf(__("Your %slocale dir is not writable"), $global['systemRootPath']);

View file

@ -8249,10 +8249,11 @@ function listAllWordsToTranslate() {
if (preg_match('/vendor.*$/', $dir)) {
return $vars;
}
//echo $dir.'<br>';
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry !== '.' && $entry !== '..') {
$filename = $dir . '/' . $entry;
$filename = ($dir) .DIRECTORY_SEPARATOR. $entry;
if (is_dir($filename)) {
$vars = listAll($filename);
} elseif (preg_match("/\.php$/", $entry)) {
@ -8276,7 +8277,12 @@ function listAllWordsToTranslate() {
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);
ObjectYPT::setCache($cacheName, $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'];
$securityFilterInt = ['isAdmin', 'priority', 'totalClips', 'rowCount'];
$securityRemoveSingleQuotes = ['search', 'searchPhrase', 'videoName', 'databaseName', 'sort', 'user', 'pass', 'encodedPass', 'isAdmin', 'videoLink', 'video_password'];
$securityRemoveNonCharsStrict = ['APIName','APIPlugin'];
$securityRemoveNonChars = ['resolution', 'format', 'videoDirectory', 'chunkFile'];
$filterURL = ['videoURL', 'siteURL', 'redirectUri', 'encoderURL'];
@ -50,11 +51,25 @@ foreach ($scanVars as $value) {
foreach ($securityRemoveNonChars as $value) {
if (!empty($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])) {
foreach ($scanThis[$value] as $key => $value2) {
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) {
$eo = unserialize(base64_decode($this->externalOptions));
$eo = User::decodeExternalOption($this->externalOptions);
if (!is_array($eo)) {
$eo = [];
}
@ -200,7 +200,7 @@ if (typeof gtag !== \"function\") {
}
public function removeExternalOptions($id) {
$eo = unserialize(base64_decode($this->externalOptions));
$eo = User::decodeExternalOption($this->externalOptions);
unset($eo[$id]);
$this->setExternalOptions($eo);
return $this->save();
@ -213,7 +213,7 @@ if (typeof gtag !== \"function\") {
}
public function getExternalOption($id) {
$eo = unserialize(base64_decode($this->externalOptions));
$eo = User::decodeExternalOption($this->externalOptions);
if (empty($eo[$id])) {
return null;
}
@ -1173,7 +1173,7 @@ if (typeof gtag !== \"function\") {
public static function externalOptions($id) {
if (!empty($_SESSION['user']['externalOptions'])) {
$externalOptions = unserialize(base64_decode($_SESSION['user']['externalOptions']));
$externalOptions = User::decodeExternalOption($_SESSION['user']['externalOptions']);
if (isset($externalOptions[$id])) {
if ($externalOptions[$id] == "true") {
$externalOptions[$id] = true;
@ -1194,11 +1194,15 @@ if (typeof gtag !== \"function\") {
return self::externalOptionsFromUserID($this->id, $id);
}
public function _getExternalOptions() {
return $this->externalOptions;
}
public static function externalOptionsFromUserID($users_id, $id) {
$user = self::findById($users_id);
if ($user) {
if (!is_null($user['externalOptions'])) {
$externalOptions = unserialize(base64_decode($user['externalOptions']));
$externalOptions = User::decodeExternalOption($user['externalOptions']);
if (is_array($externalOptions) && sizeof($externalOptions) > 0) {
//var_dump($externalOptions);
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['isEmailVerified'] = $user['emailVerified'];
if (!is_null($user['externalOptions'])) {
$externalOptions = unserialize(base64_decode($user['externalOptions']));
$externalOptions = User::decodeExternalOption($user['externalOptions']);
if (is_array($externalOptions) && sizeof($externalOptions) > 0) {
foreach ($externalOptions as $k => $v) {
if ($v == "true") {
@ -1757,6 +1761,13 @@ if (typeof gtag !== \"function\") {
return $user;
}
public static function decodeExternalOption($externalOptions){
if(is_string($externalOptions)){
$externalOptions = unserialize(base64_decode($externalOptions));
}
return $externalOptions;
}
private static function getUserInfoFromRow($row) {
$row['groups'] = UserGroups::getUserGroups($row['id']);
$row['identification'] = self::getNameIdentificationById($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['isEmailVerified'] = $row['emailVerified'];
if (!is_null($row['externalOptions'])) {
$externalOptions = unserialize(base64_decode($row['externalOptions']));
$externalOptions = self::decodeExternalOption($row['externalOptions']);
if (is_array($externalOptions) && sizeof($externalOptions) > 0) {
foreach ($externalOptions as $k => $v) {
if ($v == "true") {

View file

@ -792,7 +792,7 @@ if (!class_exists('Video')) {
}
}
_mysql_connect();
$sql = "SELECT STRAIGHT_JOIN u.*, v.*, "
$sql = "SELECT STRAIGHT_JOIN u.*, u.externalOptions as userExternalOptions, v.*, "
. " nv.title as next_title,"
. " nv.clean_title as next_clean_title,"
. " nv.filename as next_filename,"
@ -1162,7 +1162,7 @@ if (!class_exists('Video')) {
$suggestedOnly = true;
$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 "
//. ", (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 "
@ -1434,6 +1434,9 @@ if (!class_exists('Video')) {
if (empty($obj['externalOptions'])) {
$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);
return $obj;
}
@ -1502,6 +1505,10 @@ if (!class_exists('Video')) {
if (empty($row['externalOptions'])) {
$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']));
TimeLogEnd($timeLogName, __LINE__, $TimeLogLimit);
ObjectYPT::setCache($name, $row);

View file

@ -3,6 +3,7 @@
global $global;
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
class API extends PluginAbstract {
public function getTags() {
@ -41,7 +42,7 @@ class API extends PluginAbstract {
public function getEmptyDataObject() {
global $global;
$obj = new stdClass();
$obj->APISecret = md5($global['systemRootPath']);
$obj->APISecret = md5($global['salt'].$global['systemRootPath'].'API');
return $obj;
}
@ -65,14 +66,22 @@ class API extends PluginAbstract {
$user = new User("", $parameters['user'], $parameters['password']);
$user->login(false, @$parameters['encodedPass']);
}
$APIName = $parameters['APIName'];
if (method_exists($this, "set_api_$APIName")) {
$str = "\$object = \$this->set_api_$APIName(\$parameters);";
eval($str);
} else {
$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;
}
@ -94,10 +103,18 @@ class API extends PluginAbstract {
if (method_exists($this, "get_api_$APIName")) {
$str = "\$object = \$this->get_api_$APIName(\$parameters);";
eval($str);
} else {
$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;
}
@ -1576,7 +1593,7 @@ class API extends PluginAbstract {
exit;
}
private static function isAPISecretValid(){
public static function isAPISecretValid(){
global $global;
if(!empty($_REQUEST['APISecret'])){
$dataObj = AVideoPlugin::getDataObject('API');

View file

@ -4,18 +4,15 @@ if (!isset($global['systemRootPath'])) {
require_once '../../videos/configuration.php';
}
if (!User::isAdmin()) {
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not do this"));
exit;
forbiddenPage('Admin only');
}
require_once $global['systemRootPath'] . 'plugin/API/API.php';
$plugin = AVideoPlugin::loadPluginIfEnabled("API");
if (empty($plugin)) {
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not do this"));
exit;
forbiddenPage('API Plugin disabled');
}
$obj = AVideoPlugin::getObjectData("API");
$reflector = new ReflectionClass('API');
?>
<!DOCTYPE html>
<html lang="<?php echo getLanguage(); ?>">
@ -36,12 +33,30 @@ $reflector = new ReflectionClass('API');
<body class="<?php echo $global['bodyClass']; ?>">
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
$methodsList = array();
$reflector = new ReflectionClass('API');
$class_methods = get_class_methods('API');
foreach ($class_methods as $key => $method_name) {
if (!preg_match("/(get|set)_api_(.*)/", $method_name, $matches)) {
unset($class_methods[$key]);
foreach ($class_methods as $key => $method[0]) {
if (preg_match("/(get|set)_api_(.*)/", $method[0], $matches)) {
$methodsList[] = array($method[0], $reflector, $matches[1], $matches[2], '');
}
}
$plugins = Plugin::getAllEnabled();
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']);
}
}
}
/*
usort($class_methods, function ($a, $b) {
if (!preg_match("/(get|set)_api_(.*)/", $a, $matchesA)) {
return 0;
@ -51,6 +66,8 @@ $reflector = new ReflectionClass('API');
}
return strcasecmp($matchesA[2], $matchesB[2]);
});
*
*/
?>
<div class="container-fluid">
<ul class="list-group">
@ -68,7 +85,7 @@ $reflector = new ReflectionClass('API');
<input name="categories_id" type="hidden" value="1" />
<input name="upl" type="file" accept="video/mp4" /><br>
<input type="submit" value="submit" id="submit"/>
</form>';
</form>';
echo htmlentities($frm);
?>
</pre>
@ -78,24 +95,30 @@ $reflector = new ReflectionClass('API');
</details>
</li>
<?php
foreach ($class_methods as $method_name) {
if (!preg_match("/(get|set)_api_(.*)/", $method_name, $matches)) {
foreach ($methodsList as $method) {
if (!preg_match("/(get|set)_api_(.*)/", $method[0], $matches)) {
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">
<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>
<pre><?php
$comment = $reflector->getMethod($method_name)->getDocComment();
$comment = str_replace(['{webSiteRootURL}', '{getOrSet}', '{APIName}', '{APISecret}'], [$global['webSiteRootURL'], $matches[1], $matches[2], $obj->APISecret], $comment);
$comment = $reflector->getMethod($method[0])->getDocComment();
$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);
//var_dump($match2[0]);
$link = "<a target='_blank' href='{$match2[0][0]}'>" . htmlentities($match2[0][0]) . "</a>";
$comment = str_replace([$match2[0][0], " *"], [$link, "*"], $comment);
echo($comment);
//{webSiteRootURL}plugin/API/{getOrSet}.json.php?name={name}
?>
</pre>
</details>

View file

@ -295,6 +295,7 @@ class AVideoPlugin
if (empty($pluginIsLoaded)) {
$pluginIsLoaded = [];
}
$name = preg_replace('/[^0-9a-z_]/i', '', $name);
$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
if (!isset($pluginIsLoaded[$name]) && empty($forceReload)) {

View file

@ -517,6 +517,7 @@ Allow: .css";
}
public static function saveVideosAddNew($post, $videos_id) {
self::setDoNotShowAdsOnChannel($videos_id, !_empty($post['doNotShowAdsOnThisChannel']));
self::setDoNotShowAds($videos_id, !_empty($post['doNotShowAdsOnThisVideo']));
self::setRedirectVideo($videos_id, @$post['redirectVideoCode'], @$post['redirectVideoURL']);
self::setShortSummaryAndMetaDescriptionVideo($videos_id,@$post['ShortSummary'], @$post['MetaDescription']);
@ -533,12 +534,33 @@ Allow: .css";
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 {
$video = new Video('', '', $videos_id);
$externalOptions = _json_decode($video->getExternalOptions());
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) {
if (!Permissions::canAdminVideos()) {
return false;
@ -574,7 +596,7 @@ Allow: .css";
}
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"),
"doNotShowAdsOnThisChannel": $("#doNotShowAdsOnThisChannel").is(":checked"),
"redirectVideoCode": $("#redirectVideoCode").val(),
"redirectVideoURL": $("#redirectVideoURL").val(),
"MetaDescription": $("#inputMetaDescription").val(),

View file

@ -1,4 +1,5 @@
$("#doNotShowAdsOnThisVideo").prop("checked", false);
$("#doNotShowAdsOnThisChannel").prop("checked", false);
$("#redirectVideoCode").val(0);
$("#redirectVideoURL").val('');
$("#inputMetaDescription").val('');
@ -26,3 +27,12 @@ if (typeof row.externalOptions !== 'undefined' && row.externalOptions) {
}
$("#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>
<div class="clearfix"></div>
<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">
<i class="fas fa-photo-video"></i>
<?php echo __('Do NOT Show Video Ads on this video'); ?>

View file

@ -512,7 +512,7 @@ class CustomizeUser extends PluginAbstract {
$p = AVideoPlugin::loadPlugin("CustomizeUser");
$obj = $p->getDataObject();
$btn = '';
if (!empty($obj->enableExtraInfo)) {
if (!empty(self::showExtraInfo())) {
$btn .= '<li><a data-toggle="tab" href="#tabExtraInfo' . $p->getUUID() . '">' . __('Extra Info') . '</a></li>';
}
if ($obj->allowWalletDirectTransferDonation && $obj->UsersCanCustomizeWalletDirectTransferDonation) {
@ -533,12 +533,32 @@ class CustomizeUser extends PluginAbstract {
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) {
global $global;
$p = AVideoPlugin::loadPlugin("CustomizeUser");
$obj = $p->getDataObject();
$btn = '';
if (!empty($obj->enableExtraInfo)) {
if (!empty(self::showExtraInfo())) {
$tabId = 'tabExtraInfo' . $p->getUUID();
include $global['systemRootPath'] . 'plugin/CustomizeUser/View/tabExtraInfo.php';
}
@ -561,7 +581,7 @@ class CustomizeUser extends PluginAbstract {
$obj = $p->getDataObject();
$btn = '';
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="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();
}
/*
static function getNotifications() {
global $global, $customUser_getNotifications;
$return = array();
@ -622,6 +642,8 @@ class CustomizeUser extends PluginAbstract {
return $return;
}
*
*/
static function getAffiliationNotifications() {
global $global, $customUser_getAffiliationNotifications;

View file

@ -162,20 +162,28 @@ class Users_affiliations extends ObjectYPT {
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;
}
$icon = 'fas fa-user-friends';
$href = "{$global['webSiteRootURL']}user?tab=tabAffiliation";
//var_dump($this);exit;
if (!empty($this->id) && empty($this->company_agree_date) && empty($this->affiliate_agree_date)) {
_error_log('Affiliation: both dates are empty, delete ' . $this->id);
return self::deleteFromID($this->id);
} else if (!empty($this->company_agree_date) && !empty($this->affiliate_agree_date)) {
_error_log('Affiliation: both dates are NOT empty, make it active ' . $this->id);
// $this->users_id_company $this->users_id_affiliate
$this->status = 'a';
$title = __('Affiliation Confirmed');
$type = UserNotifications::type_success;
$msg = __('Affiliation approved');
} else {
_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';
$title = __('Affiliation Updated');
$type = UserNotifications::type_warning;
$msg = __('You have a new affiliation request');
}
if (empty($this->company_agree_date) || $this->company_agree_date == '0000-00-00 00:00:00' ) {
if (empty($this->company_agree_date) || $this->company_agree_date == '0000-00-00 00:00:00') {
$this->company_agree_date = 'NULL';
}
if (empty($this->affiliate_agree_date) || $this->affiliate_agree_date == '0000-00-00 00:00:00') {
@ -189,7 +197,21 @@ class Users_affiliations extends ObjectYPT {
$this->users_id_company = 'NULL';
}
return parent::save();
$id = parent::save();
if (!empty($id)) {
$sendTo = array(array($this->users_id_company, $this->users_id_affiliate), array($this->users_id_affiliate, $this->users_id_company));
foreach ($sendTo as $key => $value) {
$identification = User::getNameIdentificationById($value[0]);
$image = "user/{$value[0]}/foto.png";
$element_id = "affiliation_a{$value[0]}_b{$value[1]}_{$this->modified}";
$to_users_id = $value[1];
$msg .= " <strong>{$identification}</strong> ";
UserNotifications::createNotification($title, $msg, $to_users_id, $image, $href, $type, $element_id, $icon);
}
}
return $id;
}
static public function deleteFromID($id) {

View file

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

View file

@ -324,7 +324,7 @@ class Layout extends PluginAbstract {
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;
$getLangsSelect = 1;
if ($getAll) {
@ -346,19 +346,20 @@ class Layout extends PluginAbstract {
$selectedJsonIcon = '';
}
$html = '<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle navbar-btn" data-toggle="dropdown" aria-expanded="true">
<i class="selectedflagicon ' . $selectedJsonIcon . '"></i> <span class="caret"></span>
$html = '<div class="btn-group" id="div_'.$id.'">
<input type="hidden" name="'.$name.'" value="'.$selected.'" id="'.$id.'"/>
<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>
<ul class="dropdown-menu dropdown-menu-right" role="menu">';
<ul class="dropdown-menu dropdown-menu-right dropdown-menu-arrow" role="menu">';
$selfURI = getSelfURI();
foreach ($flags as $key => $value) {
$info = json_decode($value[0]);
$url = addQueryStringParameter($selfURI, 'lang', $key);
$html .= '<li class="dropdown-submenu">
<a tabindex="-1" href="' . $url . '">
<i class="' . $info->icon . '" aria-hidden="true"></i> ' . $info->text . '</a>
<a tabindex="-1" href="' . $url . '" value="' . $key . '" onclick="$(\'#div_'.$id.' > button > span.flag\').html($(this).find(\'span.flag\').html());$(\'input[name='.$name.']\').val(\''.$key.'\');">
<span class="flag"><i class="' . $info->icon . '" aria-hidden="true"></i></span> ' . $info->text . '</a>
</li>';
}
@ -496,7 +497,7 @@ class Layout extends PluginAbstract {
if (!AVideoPlugin::isEnabledByName('YouPHPFlix2') && !empty($obj->categoriesTopButtons)) {
if (!empty($obj->categoriesTopButtonsShowOnlyOnFirstPage) && !isFirstPage()) {
}else{
} else {
$content = getIncludeFileContent($global['systemRootPath'] . 'plugin/Layout/categoriesTopButtons.php');
}
}
@ -518,11 +519,11 @@ class Layout extends PluginAbstract {
//return $html;
if (!empty($global['doNOTOrganizeHTML'])) {
//var_dump('doNOTOrganizeHTML');exit;
return $html.PHP_EOL.'<!-- Layout::organizeHTML doNOTOrganizeHTML -->';
return $html . PHP_EOL . '<!-- Layout::organizeHTML doNOTOrganizeHTML -->';
}
if (!empty($_REQUEST['debug'])) {
//var_dump('doNOTOrganizeHTML');exit;
return $html.PHP_EOL.'<!-- Layout::organizeHTML debug -->';
return $html . PHP_EOL . '<!-- Layout::organizeHTML debug -->';
}
self::$tags = array();
//return $html;
@ -537,19 +538,19 @@ class Layout extends PluginAbstract {
//var_dump(self::$tags['tagscript']);exit;
if (!empty(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;
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'])) {
self::$tags['tagscript'] = self::removeDuplicated(self::$tags['tagscript']);
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'])) {
$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::removeExtraSpacesFromScript($html);
@ -558,11 +559,11 @@ class Layout extends PluginAbstract {
}
private static function tryToReplace($search, $replace, $subject) {
if(true || self::codeIsValid($subject)){
if (true || self::codeIsValid($subject)) {
$newSubject = str_replace($search, $replace, $subject, $count);
return ['newSubject' => $newSubject, 'success' => $count];
}else{
_error_log('organizeHTML: Invalid code: '.$subject);
} else {
_error_log('organizeHTML: Invalid code: ' . $subject);
return ['newSubject' => $subject, 'success' => false];
}
}
@ -693,7 +694,7 @@ class Layout extends PluginAbstract {
$html = self::organizeHTML($html);
//_ob_clean();
_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) {
@ -701,15 +702,15 @@ class Layout extends PluginAbstract {
$srcList = array();
foreach ($list as $key => $value) {
preg_match('/<script.+src=["\']([^"\']+)["\']/i', $value, $matches);
if(!empty($matches[1])){
if(!in_array($matches[1], $srcList)){
if (!empty($matches[1])) {
if (!in_array($matches[1], $srcList)) {
$cleanList[] = $value;
$srcList[] = $matches[1];
}
}else{
} else {
preg_match('/<link.+href=["\']([^"\']+)["\']/i', $value, $matches);
if(!empty($matches[1])){
if(!in_array($matches[1], $srcList)){
if (!empty($matches[1])) {
if (!in_array($matches[1], $srcList)) {
$cleanList[] = $value;
$srcList[] = $matches[1];
}
@ -718,25 +719,24 @@ class Layout extends PluginAbstract {
}
//var_dump($srcList);exit;
return $cleanList;
}
static function getSuggestedButton($videos_id, $class='btn btn-xs'){
static function getSuggestedButton($videos_id, $class = 'btn btn-xs') {
global $global;
if(empty($videos_id)){
if (empty($videos_id)) {
return '';
}
if(!Permissions::canAdminVideos()){
if (!Permissions::canAdminVideos()) {
return '';
}
$varsArray = array('videos_id'=>$videos_id, 'class'=>$class);
$varsArray = array('videos_id' => $videos_id, 'class' => $class);
$filePath = $global['systemRootPath'] . 'plugin/Layout/suggestedButton.php';
return getIncludeFileContent($filePath, $varsArray);
}
}
function _sortJS($a, $b){
function _sortJS($a, $b) {
// make it first
if (preg_match('/jquery(.min)?.js/i', $a)) {
return -1;
@ -816,7 +816,7 @@ function _sortJS($a, $b){
return 1;
}
// 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)) {
return 1;
}

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>
</a>
</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">
<?php
echo AVideoPlugin::getUserNotificationButton();

View file

@ -169,8 +169,28 @@ class User_notifications extends ObjectYPT {
public function save() {
if (empty($this->element_id)) {
$this->element_id = 'automatic_id_' . uniqid();
}else{
if(self::elementIdExists($this->element_id)){
return false;
}
}
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);
}
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()){
return false;
}

View file

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

View file

@ -951,6 +951,31 @@ li.dropdown-submenu > ul > li > a{
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{
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>
</button>
<?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; ?>
</ul>
</div>

View file

@ -8,7 +8,7 @@
if ((isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && $advancedCustomUser->onlyVerifiedEmailCanUpload && User::isVerified()) || (isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && !$advancedCustomUser->onlyVerifiedEmailCanUpload) || !isset($advancedCustomUser->onlyVerifiedEmailCanUpload)) {
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
include $global['systemRootPath'] . 'view/include/navbarEncoder.php';
if (empty($advancedCustom->doNotShowUploadMP4Button)) {
@ -55,7 +55,7 @@
} else {
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>
<a href="" >
<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)) {
$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) {

View file

@ -47,7 +47,7 @@ $subscribe->save();
</div>
<div class="panel-body">
<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>