1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 09:49:28 +02:00

There is a option now so admin can allow each user to chose if wants to

let other users download or share his videos
This commit is contained in:
daniel 2018-12-15 09:36:45 -03:00
parent 9fcf188e73
commit ac26179b0c
34 changed files with 581 additions and 61 deletions

View file

@ -11,4 +11,4 @@
'onlyVerifiedEmailCanUpload'=>'Users must verify their emails before upload/submit videos', 'onlyVerifiedEmailCanUpload'=>'Users must verify their emails before upload/submit videos',
'sendVerificationMailAutomaic'=>'After sign up we will automatic send a verification email', 'sendVerificationMailAutomaic'=>'After sign up we will automatic send a verification email',
'userMustBeLoggedIn'=>'Hide the website to non logged users'); 'userMustBeLoggedIn'=>'Hide the website to non logged users');
createTable("CustomizeAdvanced", $filter); createTable("CustomizeUser", $filter);

View file

@ -8,7 +8,7 @@
'disableNativeSignUp' => 'The form to signup will not exists', 'disableNativeSignUp' => 'The form to signup will not exists',
'disableNativeSignIn' => 'The regular form to signin will not exist, if you check this will only have social login or LDAP option', 'disableNativeSignIn' => 'The regular form to signin will not exist, if you check this will only have social login or LDAP option',
'userMustBeLoggedIn' => 'The site will display only a login form to un authenticated users'); 'userMustBeLoggedIn' => 'The site will display only a login form to un authenticated users');
createTable("CustomizeAdvanced", $filter); createTable("CustomizeUser", $filter);
?> ?>
</div> </div>
</div> </div>

View file

@ -360,11 +360,11 @@ class Category {
} }
static function canCreateCategory() { static function canCreateCategory() {
global $advancedCustom; global $advancedCustomUser;
if (User::isAdmin()) { if (User::isAdmin()) {
return true; return true;
} }
if ($advancedCustom->usersCanCreateNewCategories && User::canUpload()) { if ($advancedCustomUser->usersCanCreateNewCategories && User::canUpload()) {
return true; return true;
} }
return false; return false;

View file

@ -1235,8 +1235,8 @@ function tail($filepath, $lines = 1, $adaptive = true, $returnArray = false)
function encryptPassword($password, $noSalt = false) function encryptPassword($password, $noSalt = false)
{ {
global $advancedCustom, $global; global $advancedCustom, $global, $advancedCustomUser;
if (!empty($advancedCustom->encryptPasswordsWithSalt) && !empty($global['salt']) && empty($noSalt)) { if (!empty($advancedCustomUser->encryptPasswordsWithSalt) && !empty($global['salt']) && empty($noSalt)) {
$password .= $global['salt']; $password .= $global['salt'];
} }

View file

@ -54,4 +54,5 @@ if(class_exists("Plugin")){YouPHPTubePlugin::getStart();}
else{error_log("Class Plugin Not found: {$_SERVER['REQUEST_URI']}");} else{error_log("Class Plugin Not found: {$_SERVER['REQUEST_URI']}");}
$global['allowedExtension'] = array('gif', 'jpg', 'mp4', 'webm', 'mp3', 'ogg'); $global['allowedExtension'] = array('gif', 'jpg', 'mp4', 'webm', 'mp3', 'ogg');
$advancedCustom = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeAdvanced"); $advancedCustom = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeAdvanced");
$advancedCustomUser = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
$sitemapFile = "{$global['systemRootPath']}sitemap.xml"; $sitemapFile = "{$global['systemRootPath']}sitemap.xml";

View file

@ -138,7 +138,7 @@ $object->isLogged = User::isLogged();
$object->isAdmin = User::isAdmin(); $object->isAdmin = User::isAdmin();
$object->canUpload = User::canUpload(); $object->canUpload = User::canUpload();
$object->canComment = User::canComment(); $object->canComment = User::canComment();
if (empty($advancedCustom->userCanNotChangeCategory) || User::isAdmin()) { if (empty($advancedCustomUser->userCanNotChangeCategory) || User::isAdmin()) {
$object->categories = Category::getAllCategories(true); $object->categories = Category::getAllCategories(true);
}else{ }else{
$object->categories = array(); $object->categories = array();

View file

@ -134,12 +134,14 @@ if (typeof gtag !== \"function\") {
$eo = unserialize(base64_decode($this->externalOptions)); $eo = unserialize(base64_decode($this->externalOptions));
$eo[$id] = $value; $eo[$id] = $value;
$this->setExternalOptions($eo); $this->setExternalOptions($eo);
return $this->save();
} }
function removeExternalOptions($id) { function removeExternalOptions($id) {
$eo = unserialize(base64_decode($this->externalOptions)); $eo = unserialize(base64_decode($this->externalOptions));
unset($eo[$id]); unset($eo[$id]);
$this->setExternalOptions($eo); $this->setExternalOptions($eo);
return $this->save();
} }
function setExternalOptions($options) { function setExternalOptions($options) {
@ -149,6 +151,9 @@ if (typeof gtag !== \"function\") {
function getExternalOption($id) { function getExternalOption($id) {
$eo = unserialize(base64_decode($this->externalOptions)); $eo = unserialize(base64_decode($this->externalOptions));
if(empty($eo[$id])){
return NULL;
}
return $eo[$id]; return $eo[$id];
} }
@ -242,13 +247,13 @@ if (typeof gtag !== \"function\") {
static function getNameIdentification() { static function getNameIdentification() {
global $advancedCustom; global $advancedCustom;
if (self::isLogged()) { if (self::isLogged()) {
if (!empty(self::getName()) && empty($advancedCustom->doNotIndentifyByName)) { if (!empty(self::getName()) && empty($advancedCustomUser->doNotIndentifyByName)) {
return self::getName(); return self::getName();
} }
if (!empty(self::getMail()) && empty($advancedCustom->doNotIndentifyByEmail)) { if (!empty(self::getMail()) && empty($advancedCustomUser->doNotIndentifyByEmail)) {
return self::getMail(); return self::getMail();
} }
if (!empty(self::getUserName()) && empty($advancedCustom->doNotIndentifyByUserName)) { if (!empty(self::getUserName()) && empty($advancedCustomUser->doNotIndentifyByUserName)) {
return self::getUserName(); return self::getUserName();
} }
} }
@ -366,7 +371,7 @@ if (typeof gtag !== \"function\") {
} }
if (empty($this->canStream)) { if (empty($this->canStream)) {
if (empty($this->id)) { // it is a new user if (empty($this->id)) { // it is a new user
if (empty($advancedCustom->newUsersCanStream)) { if (empty($advancedCustomUser->newUsersCanStream)) {
$this->canStream = "0"; $this->canStream = "0";
} else { } else {
$this->canStream = "1"; $this->canStream = "1";
@ -451,7 +456,7 @@ if (typeof gtag !== \"function\") {
if ($insert_row) { if ($insert_row) {
if (empty($this->id)) { if (empty($this->id)) {
$id = $global['mysqli']->insert_id; $id = $global['mysqli']->insert_id;
if (!empty($advancedCustom->unverifiedEmailsCanNOTLogin)) { if (!empty($advancedCustomUser->unverifiedEmailsCanNOTLogin)) {
self::sendVerificationLink($id); self::sendVerificationLink($id);
} }
} else { } else {
@ -538,7 +543,7 @@ if (typeof gtag !== \"function\") {
const CAPTCHA_ERROR = 3; const CAPTCHA_ERROR = 3;
function login($noPass = false, $encodedPass = false) { function login($noPass = false, $encodedPass = false) {
global $global,$advancedCustom; global $global,$advancedCustom, $advancedCustomUser;
if ($noPass) { if ($noPass) {
$user = $this->find($this->user, false, true); $user = $this->find($this->user, false, true);
} else { } else {
@ -551,9 +556,9 @@ if (typeof gtag !== \"function\") {
if(empty($_SESSION['loginAttempts'])){ if(empty($_SESSION['loginAttempts'])){
$_SESSION['loginAttempts'] = 0; $_SESSION['loginAttempts'] = 0;
} }
if(!empty($advancedCustom->requestCaptchaAfterLoginsAttempts)){ if(!empty($advancedCustomUser->requestCaptchaAfterLoginsAttempts)){
$_SESSION['loginAttempts']++; $_SESSION['loginAttempts']++;
if($_SESSION['loginAttempts']>$advancedCustom->requestCaptchaAfterLoginsAttempts){ if($_SESSION['loginAttempts']>$advancedCustomUser->requestCaptchaAfterLoginsAttempts){
if(empty($_POST['captcha'])){ if(empty($_POST['captcha'])){
return self::CAPTCHA_ERROR; return self::CAPTCHA_ERROR;
} }
@ -565,7 +570,7 @@ if (typeof gtag !== \"function\") {
} }
// check for multiple logins attempts to prevent hacking end // check for multiple logins attempts to prevent hacking end
// if user is not verified // if user is not verified
if (!empty($user) && empty($user['isAdmin']) && empty($user['emailVerified']) && !empty($advancedCustom->unverifiedEmailsCanNOTLogin)) { if (!empty($user) && empty($user['isAdmin']) && empty($user['emailVerified']) && !empty($advancedCustomUser->unverifiedEmailsCanNOTLogin)) {
unset($_SESSION['user']); unset($_SESSION['user']);
self::sendVerificationLink($user['id']); self::sendVerificationLink($user['id']);
return self::USER_NOT_VERIFIED; return self::USER_NOT_VERIFIED;
@ -590,10 +595,10 @@ if (typeof gtag !== \"function\") {
} }
static function isCaptchaNeed(){ static function isCaptchaNeed(){
global $advancedCustom; global $advancedCustomUser;
// check for multiple logins attempts to prevent hacking // check for multiple logins attempts to prevent hacking
if(!empty($_SESSION['loginAttempts']) && !empty($advancedCustom->requestCaptchaAfterLoginsAttempts)){ if(!empty($_SESSION['loginAttempts']) && !empty($advancedCustomUser->requestCaptchaAfterLoginsAttempts)){
if($_SESSION['loginAttempts']>$advancedCustom->requestCaptchaAfterLoginsAttempts){ if($_SESSION['loginAttempts']>$advancedCustomUser->requestCaptchaAfterLoginsAttempts){
return true; return true;
} }
} }

View file

@ -41,7 +41,7 @@ $status=$user->save();
$json_file = url_get_contents("{$global['webSiteRootURL']}plugin/CustomizeAdvanced/advancedCustom.json.php"); $json_file = url_get_contents("{$global['webSiteRootURL']}plugin/CustomizeAdvanced/advancedCustom.json.php");
$advancedCustom = json_decode($json_file); $advancedCustom = json_decode($json_file);
if($advancedCustom->sendVerificationMailAutomaic && $status!=0) if($advancedCustomUser->sendVerificationMailAutomaic && $status!=0)
{ {
url_get_contents("{$global['webSiteRootURL']}objects/userVerifyEmail.php?users_id=$status"); url_get_contents("{$global['webSiteRootURL']}objects/userVerifyEmail.php?users_id=$status");
} }

View file

@ -0,0 +1,82 @@
<?php
global $global;
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
require_once $global['systemRootPath'] . 'plugin/CreateUserManager/Objects/UserManager.php';
class CreateUserManager extends PluginAbstract {
public function getDescription() {
return "Select some users to be able to add and remove other users from user groups";
}
public function getName() {
return "CreateUserManager";
}
public function getUUID() {
return "cc570956-dc62-46e3-ace9-86c6e8f9c81b";
}
public function getPluginVersion() {
return "1.0";
}
public function getPluginMenu(){
global $global;
$filename = $global['systemRootPath'] . 'plugin/CreateUserManager/pluginMenu.html';
return file_get_contents($filename);
}
public function getHTMLMenuRight() {
global $global;
include $global['systemRootPath'] . 'plugin/CreateUserManager/menuRight.php';
}
static function deleteGroupsFromUser($users_id){
if (!self::isManager()) {
return false;
}
global $global;
if (!empty($users_id)) {
$sql = "DELETE FROM users_has_users_groups WHERE users_id = ?";
} else {
return false;
}
return sqlDAL::writeSql($sql,"i",array($users_id));
}
static function updateUserGroups($users_id, $array_groups_id){
if (!self::isManager()) {
return false;
}
if (!is_array($array_groups_id)) {
return false;
}
self::deleteGroupsFromUser($users_id);
global $global;
$sql = "INSERT INTO users_has_users_groups ( users_id, users_groups_id) VALUES (?,?)";
foreach ($array_groups_id as $value) {
$value = intval($value);
sqlDAL::writeSql($sql,"ii",array($users_id,$value));
}
return true;
}
static function isManager(){
if (!User::isLogged()) {
return false;
}
if (User::isAdmin()) {
return true;
}
if(UserManager::getFromUsersId(User::getId())){
return true;
}
return false;
}
}

View file

@ -0,0 +1,120 @@
<?php
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
require_once dirname(__FILE__) . '/../../../objects/bootGrid.php';
require_once dirname(__FILE__) . '/../../../objects/user.php';
class UserManager extends ObjectYPT {
protected $id, $users_id, $status;
static function getSearchFieldsNames() {
return array('name', 'user', 'email');
}
static function getTableName() {
return 'userManagers';
}
static function getTotalUsers() {
//will receive
//current=1&rowCount=10&sort[sender]=asc&searchPhrase=
global $global;
$sql = "SELECT a.id FROM users u LEFT JOIN " . static::getTableName() . " a ON u.id = users_id WHERE u.status = 'a' ";
$sql .= self::getSqlSearchFromPost();
//echo $sql;
$res = sqlDAL::readSql($sql);
$countRow = sqlDAL::num_rows($res);
sqlDAL::close($res);
return $countRow;
}
static function getAllUsers() {
global $global;
$sql = "SELECT u.*, u.id as real_users_id, a.* FROM users u LEFT JOIN " . static::getTableName() . " a ON u.id = users_id WHERE u.status = 'a' ";
$sql .= self::getSqlFromPost("u.");
//echo $sql;
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$rows = array();
if ($res!=false) {
foreach ($fullData as $row) {
$row['groups'] = UserGroups::getUserGroups($row['real_users_id']);
$row['switch'] = '
<div class="material-switch pull-right">
<input onchange="switchManager('.$row['real_users_id'].');" data-toggle="toggle" type="checkbox" value="'.$row['real_users_id'].'" id="themeSwitch'.$row['real_users_id'].'" '.(($row['status']==='a')?"checked":"").'>
<label for="themeSwitch'.$row['real_users_id'].'" class="label-primary"></label>
</div>';
$rows[] = $row;
}
} else {
die($sql . '\nError : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
}
return $rows;
}
static function getFromUsersId($users_id) {
global $global;
$users_id = intval($users_id);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_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/YouPHPTube/about
$res = sqlDAL::readSql($sql,"i",array($users_id));
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
$row = $data;
} else {
$row = false;
}
return $row;
}
function loadFromUsersId($users_id) {
$row = self::getFromUsersId($users_id);
if (empty($row))
return false;
foreach ($row as $key => $value) {
$this->$key = $value;
}
return true;
}
function switchUsers($users_id) {
$loaded = $this->loadFromUsersId($users_id);
$status = 'a';
if(empty($loaded)){
$this->setUsers_id($users_id);
}else{
if($this->getStatus()==='a'){
$status = 'i';
$this->setStatus('i');
}else{
$this->setStatus('a');
}
}
$obj = new stdClass();
$obj->id = $this->save();
$obj->status = $status;
return $obj;
}
function getUsers_id() {
return $this->users_id;
}
function getStatus() {
return $this->status;
}
function setUsers_id($users_id) {
$this->users_id = $users_id;
}
function setStatus($status) {
$this->status = $status;
}
}

Binary file not shown.

View file

@ -0,0 +1,14 @@
CREATE TABLE IF NOT EXISTS `userManagers` (
`id` INT NOT NULL AUTO_INCREMENT,
`created` DATETIME NULL,
`modified` DATETIME NULL,
`users_id` INT NOT NULL,
`status` CHAR(1) NULL DEFAULT 'a',
PRIMARY KEY (`id`),
INDEX `fk_userManagers_users_idx` (`users_id` ASC),
CONSTRAINT `fk_userManagers_users`
FOREIGN KEY (`users_id`)
REFERENCES `users` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;

View file

@ -0,0 +1,60 @@
<?php
require_once '../../../videos/configuration.php';
require_once $global['systemRootPath'] . 'objects/user.php';
if (!CreateUserManager::isManager()) {
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not manager"));
exit;
}
?>
<!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>">
<head>
<title><?php echo $config->getWebSiteTitle(); ?> :: Managers</title>
<?php
include $global['systemRootPath'] . 'view/include/head.php';
?>
<link rel="stylesheet" type="text/css" href="<?php echo $global['webSiteRootURL']; ?>view/css/DataTables/datatables.min.css"/>
<style>
</style>
</head>
<body>
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
?>
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#ug">Users Groups</a></li>
<?php
if(User::isAdmin()){
?>
<li><a data-toggle="tab" href="#mn">Managers</a></li>
<?php
}
?>
</ul>
<div class="tab-content">
<div id="ug" class="tab-pane fade in active">
<?php
include_once './editorGroups.php';
?>
</div>
<?php
if(User::isAdmin()){
?>
<div id="mn" class="tab-pane fade">
<?php
include_once './editorManagers.php';
?>
</div>
<?php
}
?>
</div>
</div>
<?php
include $global['systemRootPath'] . 'view/include/footer.php';
?>
<script type="text/javascript" src="<?php echo $global['webSiteRootURL']; ?>view/css/DataTables/datatables.min.js"></script>
</body>
</html>

View file

@ -0,0 +1,18 @@
<?php
require_once '../../../videos/configuration.php';
if (!CreateUserManager::isManager()) {
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not manager"));
exit;
}
header('Content-Type: application/json');
require_once $global['systemRootPath'] . 'plugin/CreateUserManager/Objects/UserManager.php';
$rows = UserManager::getAllUsers();
$rowsTotal = UserManager::getTotalUsers();
?>
{
"draw": <?php echo $_GET['draw']; ?>,
"recordsTotal": <?php echo $rowsTotal; ?>,
"recordsFiltered": <?php echo $rowsTotal; ?>,
"data": <?php echo json_encode($rows); ?>
}

View file

@ -0,0 +1 @@
<a href="plugin/CreateUserManager/page/editor.php" class="btn btn-primary btn-sm btn-xs"><i class="fa fa-edit"></i> Create Managers</a>

View file

@ -38,21 +38,13 @@ class CustomizeAdvanced extends PluginAbstract {
$obj->doNotShowEncoderResolutionSD = false; $obj->doNotShowEncoderResolutionSD = false;
$obj->doNotShowEncoderResolutionHD = false; $obj->doNotShowEncoderResolutionHD = false;
$obj->doNotShowLeftMenuAudioAndVideoButtons = false; $obj->doNotShowLeftMenuAudioAndVideoButtons = false;
$obj->disableNativeSignUp = false;
$obj->disableNativeSignIn = false;
$obj->disablePersonalInfo = true;
$obj->doNotShowWebsiteOnContactForm = false; $obj->doNotShowWebsiteOnContactForm = false;
$obj->newUsersCanStream = false;
$obj->doNotIndentifyByEmail = false;
$obj->doNotIndentifyByName = false;
$obj->doNotIndentifyByUserName = false;
$obj->doNotUseXsendFile = false; $obj->doNotUseXsendFile = false;
$obj->makeVideosInactiveAfterEncode = false; $obj->makeVideosInactiveAfterEncode = false;
$obj->usePermalinks = false; $obj->usePermalinks = false;
$obj->showAdsenseBannerOnTop = false; $obj->showAdsenseBannerOnTop = false;
$obj->showAdsenseBannerOnLeft = true; $obj->showAdsenseBannerOnLeft = true;
$obj->disableAnimatedGif = false; $obj->disableAnimatedGif = false;
$obj->unverifiedEmailsCanNOTLogin = false;
$obj->removeBrowserChannelLinkFromMenu = false; $obj->removeBrowserChannelLinkFromMenu = false;
$obj->uploadButtonDropdownIcon = "fas fa-video"; $obj->uploadButtonDropdownIcon = "fas fa-video";
$obj->uploadButtonDropdownText = ""; $obj->uploadButtonDropdownText = "";
@ -64,9 +56,6 @@ class CustomizeAdvanced extends PluginAbstract {
$obj->utf8Encode = false; $obj->utf8Encode = false;
$obj->utf8Decode = false; $obj->utf8Decode = false;
$obj->embedBackgroundColor = "white"; $obj->embedBackgroundColor = "white";
$obj->userMustBeLoggedIn = false;
$obj->onlyVerifiedEmailCanUpload= false;
$obj->sendVerificationMailAutomaic=false;
$o = new stdClass(); $o = new stdClass();
$o->type = "textarea"; $o->type = "textarea";
$o->value = ""; $o->value = "";
@ -92,18 +81,11 @@ class CustomizeAdvanced extends PluginAbstract {
} }
} }
} }
$obj->disableHelpLeftMenu= false; $obj->disableHelpLeftMenu= false;
$obj->disableAboutLeftMenu= false; $obj->disableAboutLeftMenu= false;
$obj->disableContactLeftMenu= false; $obj->disableContactLeftMenu= false;
$obj->disableNavbar= false; $obj->disableNavbar= false;
$obj->userCanNotChangeCategory = false;
$obj->hideRemoveChannelFromModeYoutube = false;
$obj->showChannelBannerOnModeYoutube = false;
$obj->usersCanCreateNewCategories = false;
$obj->encryptPasswordsWithSalt = false;
$obj->requestCaptchaAfterLoginsAttempts = 0;
$obj->videosCDN = ""; $obj->videosCDN = "";
$obj->useFFMPEGToGenerateThumbs = false; $obj->useFFMPEGToGenerateThumbs = false;

View file

@ -0,0 +1,130 @@
<?php
global $global;
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
class CustomizeUser extends PluginAbstract {
public function getDescription() {
$txt = "Fine Tuning User Profile";
return $txt;
}
public function getName() {
return "CustomizeUser";
}
public function getUUID() {
return "55a4fa56-8a30-48d4-a0fb-8aa6b3fuser3";
}
public function getPluginVersion() {
return "1.0";
}
public function getEmptyDataObject() {
global $advancedCustom;
$obj = new stdClass();
$obj->userCanAllowFilesDownload = false;
$obj->userCanAllowFilesShare = false;
$obj->usersCanCreateNewCategories = !isset($advancedCustom->usersCanCreateNewCategories) ? false : $advancedCustom->usersCanCreateNewCategories;
$obj->userCanNotChangeCategory = !isset($advancedCustom->userCanNotChangeCategory) ? false : $advancedCustom->userCanNotChangeCategory;
$obj->userMustBeLoggedIn = !isset($advancedCustom->userMustBeLoggedIn) ? false : $advancedCustom->userMustBeLoggedIn;
$obj->onlyVerifiedEmailCanUpload = !isset($advancedCustom->onlyVerifiedEmailCanUpload) ? false : $advancedCustom->onlyVerifiedEmailCanUpload;
$obj->sendVerificationMailAutomaic = !isset($advancedCustom->sendVerificationMailAutomaic) ? false : $advancedCustom->sendVerificationMailAutomaic;
$obj->unverifiedEmailsCanNOTLogin = !isset($advancedCustom->unverifiedEmailsCanNOTLogin) ? false : $advancedCustom->unverifiedEmailsCanNOTLogin;
$obj->newUsersCanStream = !isset($advancedCustom->newUsersCanStream) ? false : $advancedCustom->newUsersCanStream;
$obj->doNotIndentifyByEmail = !isset($advancedCustom->doNotIndentifyByEmail) ? false : $advancedCustom->doNotIndentifyByEmail;
$obj->doNotIndentifyByName = !isset($advancedCustom->doNotIndentifyByName) ? false : $advancedCustom->doNotIndentifyByName;
$obj->doNotIndentifyByUserName = !isset($advancedCustom->doNotIndentifyByUserName) ? false : $advancedCustom->doNotIndentifyByUserName;
$obj->hideRemoveChannelFromModeYoutube = !isset($advancedCustom->hideRemoveChannelFromModeYoutube) ? false : $advancedCustom->hideRemoveChannelFromModeYoutube;
$obj->showChannelBannerOnModeYoutube = !isset($advancedCustom->showChannelBannerOnModeYoutube) ? false : $advancedCustom->showChannelBannerOnModeYoutube;
$obj->encryptPasswordsWithSalt = !isset($advancedCustom->encryptPasswordsWithSalt) ? false : $advancedCustom->encryptPasswordsWithSalt;
$obj->requestCaptchaAfterLoginsAttempts = !isset($advancedCustom->requestCaptchaAfterLoginsAttempts) ? 0 : $advancedCustom->requestCaptchaAfterLoginsAttempts;
$obj->disableNativeSignUp = !isset($advancedCustom->disableNativeSignUp) ? false : $advancedCustom->disableNativeSignUp;
$obj->disableNativeSignIn = !isset($advancedCustom->disableNativeSignIn) ? false : $advancedCustom->disableNativeSignIn;
$obj->disablePersonalInfo = !isset($advancedCustom->disablePersonalInfo) ? true : $advancedCustom->disablePersonalInfo;
return $obj;
}
static function canDownloadVideosFromUser($users_id) {
global $config;
$obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (empty($obj) || empty($obj->userCanAllowFilesDownload)) {
return $config->getAllow_download();
}
$user = new User($users_id);
return !empty($user->getExternalOption('userCanAllowFilesDownload'));
}
static function setCanDownloadVideosFromUser($users_id, $value = true) {
$obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (empty($obj) || empty($obj->userCanAllowFilesDownload)) {
return false;
}
$user = new User($users_id);
return $user->addExternalOptions('userCanAllowFilesDownload', $value);
}
static function canShareVideosFromUser($users_id) {
global $advancedCustom;
if(!empty($advancedCustom->disableShareAndPlaylist)){
return false;
}
$obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (empty($obj) || empty($obj->userCanAllowFilesShare)) {
return true;
}
$user = new User($users_id);
return !empty($user->getExternalOption('userCanAllowFilesShare'));
}
static function setCanShareVideosFromUser($users_id, $value = true) {
$obj = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (empty($obj) || empty($obj->userCanAllowFilesShare)) {
return false;
}
$user = new User($users_id);
return $user->addExternalOptions('userCanAllowFilesShare', $value);
}
static function getSwitchUserCanAllowFilesDownload($users_id) {
global $global;
include $global['systemRootPath'] . 'plugin/CustomizeUser/switchUserCanAllowFilesDownload.php';
}
static function getSwitchUserCanAllowFilesShare($users_id) {
global $global;
include $global['systemRootPath'] . 'plugin/CustomizeUser/switchUserCanAllowFilesShare.php';
}
public function getMyAccount($users_id) {
$objcu = YouPHPTubePlugin::getObjectDataIfEnabled("CustomizeUser");
if (!empty($objcu) && !empty($objcu->userCanAllowFilesDownload)) {
echo '<div class="form-group">
<label class="col-md-4 control-label">' . __("Allow Download My Videos") . '</label>
<div class="col-md-8 inputGroupContainer">';
self::getSwitchUserCanAllowFilesDownload($users_id);
echo '</div></div>';
}
if (!empty($objcu) && !empty($objcu->userCanAllowFilesShare)) {
echo '<div class="form-group">
<label class="col-md-4 control-label">' . __("Allow Share My Videos") . '</label>
<div class="col-md-8 inputGroupContainer">';
self::getSwitchUserCanAllowFilesShare($users_id);
echo '</div></div>';
}
}
public function getTags() {
return array('free', 'customization', 'users');
}
}

View file

@ -0,0 +1,38 @@
<?php
require_once '../../videos/configuration.php';
session_write_close();
header('Content-Type: application/json');
$obj = new stdClass();
$obj->error = true;
$obj->msg = "";
if(!User::isLogged()){
$obj->msg = "Not logged";
die(json_encode($obj));
}
if(empty($_POST['type'])){
$obj->msg = "Type is empty";
die(json_encode($obj));
}
if(!isset($_POST['value'])){
$obj->msg = "value is empty";
die(json_encode($obj));
}
$cu = YouPHPTubePlugin::loadPluginIfEnabled('CustomizeUser');
if(empty($cu)){
$obj->msg = "Plugin not enabled";
die(json_encode($obj));
}
$obj->error = false;
switch ($_POST['type']) {
case 'userCanAllowFilesDownload':
CustomizeUser::setCanDownloadVideosFromUser(User::getId(), $_POST['value']=="true"?true:false);
break;
case 'userCanAllowFilesShare':
CustomizeUser::setCanShareVideosFromUser(User::getId(), $_POST['value']=="true"?true:false);
break;
}
die(json_encode($obj));

View file

@ -0,0 +1,22 @@
<?php
$uid = uniqid();
?>
<div class="material-switch">
<input class="playerSwitchDefault" data-toggle="toggle" type="checkbox" value="" id="switch<?php echo $uid; ?>" <?php echo (CustomizeUser::canDownloadVideosFromUser($users_id)) ? "checked" : ""; ?>>
<label for="switch<?php echo $uid; ?>" class="label-primary"></label>
</div>
<script>
$(document).ready(function () {
$('#switch<?php echo $uid; ?>').change(function (e) {
modal.showPleaseWait();
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/CustomizeUser/set.json.php',
data: {"type": "userCanAllowFilesDownload", "value": $('#switch<?php echo $uid; ?>').is(":checked")},
type: 'post',
success: function (response) {
modal.hidePleaseWait();
}
});
});
});
</script>

View file

@ -0,0 +1,22 @@
<?php
$uid = uniqid();
?>
<div class="material-switch">
<input class="playerSwitchDefault" data-toggle="toggle" type="checkbox" value="" id="switch<?php echo $uid; ?>" <?php echo (CustomizeUser::canShareVideosFromUser($users_id)) ? "checked" : ""; ?>>
<label for="switch<?php echo $uid; ?>" class="label-primary"></label>
</div>
<script>
$(document).ready(function () {
$('#switch<?php echo $uid; ?>').change(function (e) {
modal.showPleaseWait();
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/CustomizeUser/set.json.php',
data: {"type": "userCanAllowFilesShare", "value": $('#switch<?php echo $uid; ?>').is(":checked")},
type: 'post',
success: function (response) {
modal.hidePleaseWait();
}
});
});
});
</script>

View file

@ -278,7 +278,7 @@ function createGallerySection($videos, $crc = "", $get = array()) {
</div> </div>
</div> </div>
<?php <?php
if ($config->getAllow_download()) { if (CustomizeUser::canDownloadVideosFromUser($value['users_id'])) {
?> ?>
<div style="position: relative; overflow: visible; z-index: 3;" class="dropup"> <div style="position: relative; overflow: visible; z-index: 3;" class="dropup">

View file

@ -222,7 +222,7 @@ if ($obj->BigVideo && empty($_GET['showOnly'])) {
</div> </div>
<?php <?php
if ($config->getAllow_download()) { if (CustomizeUser::canDownloadVideosFromUser($video['users_id'])) {
?> ?>
<div style="position: relative; overflow: visible;"> <div style="position: relative; overflow: visible;">
<button type="button" class="btn btn-default btn-sm btn-xs" data-toggle="dropdown"> <button type="button" class="btn btn-default btn-sm btn-xs" data-toggle="dropdown">

View file

@ -209,6 +209,10 @@ abstract class PluginAbstract {
public function getPlayListButtons($playlist_id) { public function getPlayListButtons($playlist_id) {
return ""; return "";
} }
public function getMyAccount($users_id) {
return "";
}
/** /**
* *
* @return type array(array("key"=>'live key', "users"=>false, "name"=>$userName, "user"=>$user, "photo"=>$photo, "UserPhoto"=>$UserPhoto, "title"=>'')); * @return type array(array("key"=>'live key', "users"=>false, "name"=>$userName, "user"=>$user, "photo"=>$photo, "UserPhoto"=>$UserPhoto, "title"=>''));

View file

@ -479,6 +479,20 @@ class YouPHPTubePlugin {
} }
return $str; return $str;
} }
public static function getMyAccount($users_id = "") {
if (empty($users_id))
return "";
$plugins = Plugin::getAllEnabled();
$str = "";
foreach ($plugins as $value) {
$p = static::loadPlugin($value['dirName']);
if (is_object($p)) {
$str .= $p->getMyAccount($users_id);
}
}
return $str;
}
public static function getPluginUserOptions() { public static function getPluginUserOptions() {
$plugins = Plugin::getAllEnabled(); $plugins = Plugin::getAllEnabled();

View file

@ -78,7 +78,7 @@
<script> <script>
var player; var player;
var mediaId = <?php echo $video['id']; ?>; var mediaId = <?php echo $video['id']; ?>;
<?php if (!$config->getAllow_download()) { ?> <?php if (!CustomizeUser::canDownloadVideosFromUser($video['users_id'])) { ?>
// Prevent HTML5 video from being downloaded (right-click saved)? // Prevent HTML5 video from being downloaded (right-click saved)?
$('#mainVideo').bind('contextmenu', function () { $('#mainVideo').bind('contextmenu', function () {
return false; return false;

View file

@ -86,7 +86,7 @@ $json_file = url_get_contents("{$global['webSiteRootURL']}plugin/CustomizeAdvanc
// convert the string to a json object // convert the string to a json object
$advancedCustom = json_decode($json_file); $advancedCustom = json_decode($json_file);
$thisScriptFile = pathinfo($_SERVER["SCRIPT_FILENAME"]); $thisScriptFile = pathinfo($_SERVER["SCRIPT_FILENAME"]);
if (((empty($advancedCustom->userMustBeLoggedIn) && empty($advancedCustom->disableNavbar)) || $thisScriptFile["basename"] === "signUp.php") || User::isLogged()) { if (((empty($advancedCustomUser->userMustBeLoggedIn) && empty($advancedCustom->disableNavbar)) || $thisScriptFile["basename"] === "signUp.php") || User::isLogged()) {
$updateFiles = getUpdatesFilesArray(); $updateFiles = getUpdatesFilesArray();
?> ?>
<nav class="navbar navbar-default navbar-fixed-top "> <nav class="navbar navbar-default navbar-fixed-top ">
@ -197,7 +197,7 @@ if (((empty($advancedCustom->userMustBeLoggedIn) && empty($advancedCustom->disab
<i class="<?php echo isset($advancedCustom->uploadButtonDropdownIcon) ? $advancedCustom->uploadButtonDropdownIcon : "fas fa-video"; ?>"></i> <?php echo!empty($advancedCustom->uploadButtonDropdownText) ? $advancedCustom->uploadButtonDropdownText : ""; ?> <span class="caret"></span> <i class="<?php echo isset($advancedCustom->uploadButtonDropdownIcon) ? $advancedCustom->uploadButtonDropdownIcon : "fas fa-video"; ?>"></i> <?php echo!empty($advancedCustom->uploadButtonDropdownText) ? $advancedCustom->uploadButtonDropdownText : ""; ?> <span class="caret"></span>
</button> </button>
<?php <?php
if ((isset($advancedCustom->onlyVerifiedEmailCanUpload) && $advancedCustom->onlyVerifiedEmailCanUpload && User::isVerified()) || (isset($advancedCustom->onlyVerifiedEmailCanUpload) && !$advancedCustom->onlyVerifiedEmailCanUpload) || !isset($advancedCustom->onlyVerifiedEmailCanUpload) if ((isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && $advancedCustomUser->onlyVerifiedEmailCanUpload && User::isVerified()) || (isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && !$advancedCustomUser->onlyVerifiedEmailCanUpload) || !isset($advancedCustomUser->onlyVerifiedEmailCanUpload)
) { ) {
?> ?>
<ul class="dropdown-menu dropdown-menu-right" role="menu" style=""> <ul class="dropdown-menu dropdown-menu-right" role="menu" style="">

View file

@ -96,7 +96,7 @@ if ($playNowVideo['type'] == "linkVideo") {
copyToClipboard($('#textAreaEmbed').val()); copyToClipboard($('#textAreaEmbed').val());
}, iconClass: 'fas fa-code' }, iconClass: 'fas fa-code'
} }
<?php if ($config->getAllow_download()) { ?> <?php if (CustomizeUser::canDownloadVideosFromUser($playNowVideo['users_id'])) { ?>
<?php <?php
if ($playNowVideo['type'] == "video") { if ($playNowVideo['type'] == "video") {
$files = getVideosURL($playNowVideo['filename']); $files = getVideosURL($playNowVideo['filename']);

View file

@ -210,7 +210,7 @@ YouPHPTubePlugin::getModeYouTube($v['id']);
<body> <body>
<?php include $global['systemRootPath'] . 'view/include/navbar.php'; ?> <?php include $global['systemRootPath'] . 'view/include/navbar.php'; ?>
<?php <?php
if (!empty($advancedCustom->showChannelBannerOnModeYoutube)) { if (!empty($advancedCustomUser->showChannelBannerOnModeYoutube)) {
?> ?>
<div class="container" style="margin-bottom: 10px;"> <div class="container" style="margin-bottom: 10px;">
<img src="<?php echo User::getBackground($video['users_id']); ?>" class="img img-responsive" /> <img src="<?php echo User::getBackground($video['users_id']); ?>" class="img img-responsive" />
@ -299,7 +299,7 @@ YouPHPTubePlugin::getModeYouTube($v['id']);
<div class="row"> <div class="row">
<div class="col-md-12 watch8-action-buttons text-muted"> <div class="col-md-12 watch8-action-buttons text-muted">
<?php if ((($advancedCustom != false) && ($advancedCustom->disableShareAndPlaylist == false)) || ($advancedCustom == false)) { ?> <?php if (empty($advancedCustom->disableShareAndPlaylist)) { ?>
<button class="btn btn-default no-outline" id="addBtn" data-placement="bottom"> <button class="btn btn-default no-outline" id="addBtn" data-placement="bottom">
<span class="fa fa-plus"></span> <?php echo __("Add to"); ?> <span class="fa fa-plus"></span> <?php echo __("Add to"); ?>
</button> </button>
@ -418,9 +418,11 @@ YouPHPTubePlugin::getModeYouTube($v['id']);
}); });
</script> </script>
<?php if (CustomizeUser::canShareVideosFromUser($video['users_id'])) { ?>
<a href="#" class="btn btn-default no-outline" id="shareBtn"> <a href="#" class="btn btn-default no-outline" id="shareBtn">
<span class="fa fa-share"></span> <?php echo __("Share"); ?> <span class="fa fa-share"></span> <?php echo __("Share"); ?>
</a> </a>
<?php } ?>
<?php } echo YouPHPTubePlugin::getWatchActionButton(); ?> <?php } echo YouPHPTubePlugin::getWatchActionButton(); ?>
<a href="#" class="btn btn-default no-outline pull-right <?php echo ($video['myVote'] == - 1) ? "myVote" : "" ?>" id="dislikeBtn" <?php if (!User::isLogged()) { ?> data-toggle="tooltip" title="<?php echo __("Don´t like this video? Sign in to make your opinion count."); ?>" <?php } ?>> <a href="#" class="btn btn-default no-outline pull-right <?php echo ($video['myVote'] == - 1) ? "myVote" : "" ?>" id="dislikeBtn" <?php if (!User::isLogged()) { ?> data-toggle="tooltip" title="<?php echo __("Don´t like this video? Sign in to make your opinion count."); ?>" <?php } ?>>
<span class="fa fa-thumbs-down"></span> <small><?php echo $video['dislikes']; ?></small> <span class="fa fa-thumbs-down"></span> <small><?php echo $video['dislikes']; ?></small>
@ -461,7 +463,7 @@ YouPHPTubePlugin::getModeYouTube($v['id']);
</div> </div>
</div> </div>
</div> </div>
<?php if ((($advancedCustom != false) && ($advancedCustom->disableShareAndPlaylist == false)) || ($advancedCustom == false)) { ?> <?php if (CustomizeUser::canShareVideosFromUser($video['users_id'])) { ?>
<div class="row bgWhite list-group-item" id="shareDiv"> <div class="row bgWhite list-group-item" id="shareDiv">
<div class="tabbable-panel"> <div class="tabbable-panel">
<div class="tabbable-line text-muted"> <div class="tabbable-line text-muted">

View file

@ -5,10 +5,10 @@ if(!isset($global['systemRootPath'])){
} }
require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/user.php';
$json_file = url_get_contents("{$global['webSiteRootURL']}plugin/CustomizeAdvanced/advancedCustom.json.php"); //$json_file = url_get_contents("{$global['webSiteRootURL']}plugin/CustomizeAdvanced/advancedCustom.json.php");
// convert the string to a json object // convert the string to a json object
$advancedCustom = json_decode($json_file); //$advancedCustom = json_decode($json_file);
if(!empty($advancedCustom->disableNativeSignUp)){ if(!empty($advancedCustomUser->disableNativeSignUp)){
die(__("Sign Up Disabled")); die(__("Sign Up Disabled"));
} }

View file

@ -10,9 +10,9 @@ $tagsStr = "";
foreach ($tags as $value) { foreach ($tags as $value) {
$tagsStr .= "<span class=\"label label-{$value->type} fix-width\">{$value->text}</span>"; $tagsStr .= "<span class=\"label label-{$value->type} fix-width\">{$value->text}</span>";
} }
$json_file = url_get_contents("{$global['webSiteRootURL']}plugin/CustomizeAdvanced/advancedCustom.json.php"); //$json_file = url_get_contents("{$global['webSiteRootURL']}plugin/CustomizeAdvanced/advancedCustom.json.php");
// convert the string to a json object // convert the string to a json object
$advancedCustom = json_decode($json_file); //$advancedCustom = json_decode($json_file);
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>"> <html lang="<?php echo $_SESSION['language']; ?>">
@ -46,7 +46,7 @@ $advancedCustom = json_decode($json_file);
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#basicInfo" id="aBasicInfo"><?php echo __("Basic Info") ?></a></li> <li class="active"><a data-toggle="tab" href="#basicInfo" id="aBasicInfo"><?php echo __("Basic Info") ?></a></li>
<?php if (empty($advancedCustom->disablePersonalInfo)) { ?> <?php if (empty($advancedCustomUser->disablePersonalInfo)) { ?>
<li><a data-toggle="tab" href="#personalInfo" id="aPersonalInfo"><?php echo __("Personal Info") ?></a></li> <li><a data-toggle="tab" href="#personalInfo" id="aPersonalInfo"><?php echo __("Personal Info") ?></a></li>
<?php } ?> <?php } ?>
</ul> </ul>
@ -58,7 +58,7 @@ $advancedCustom = json_decode($json_file);
?> ?>
</div> </div>
<?php if (empty($advancedCustom->disablePersonalInfo)) { ?> <?php if (empty($advancedCustomUser->disablePersonalInfo)) { ?>
<div id="personalInfo" class="tab-pane fade" style="padding: 10px 0;"> <div id="personalInfo" class="tab-pane fade" style="padding: 10px 0;">
<?php <?php
include $global['systemRootPath'] . './view/userPersonalInfo.php'; include $global['systemRootPath'] . './view/userPersonalInfo.php';

View file

@ -110,6 +110,11 @@
<textarea id="textAbout" placeholder="<?php echo __("About"); ?>" class="form-control" ><?php echo $user->getAbout(); ?></textarea> <textarea id="textAbout" placeholder="<?php echo __("About"); ?>" class="form-control" ><?php echo $user->getAbout(); ?></textarea>
</div> </div>
</div> </div>
<?php
YouPHPTubePlugin::getMyAccount(User::getId());
?>
<div class="form-group"> <div class="form-group">
<div class="col-md-12 "> <div class="col-md-12 ">
<div id="croppie"></div> <div id="croppie"></div>
@ -199,7 +204,7 @@
}, success: function (response) { }, success: function (response) {
console.log("SavePersonal"); console.log("SavePersonal");
modal.hidePleaseWait(); modal.hidePleaseWait();
<?php if(empty($advancedCustom->disablePersonalInfo)){ ?> <?php if(empty($advancedCustomUser->disablePersonalInfo)){ ?>
savePersonalInfo(); savePersonalInfo();
<?php } ?> <?php } ?>
} }

View file

@ -6,7 +6,7 @@
<?php <?php
if (empty($advancedCustom->disableNativeSignIn)) { if (empty($advancedCustomUser->disableNativeSignIn)) {
?> ?>
<form class="form-compact well form-horizontal" id="loginForm"> <form class="form-compact well form-horizontal" id="loginForm">
@ -50,7 +50,7 @@
<label class="col-md-4 control-label"></label> <label class="col-md-4 control-label"></label>
<div class="col-md-8 inputGroupContainer"> <div class="col-md-8 inputGroupContainer">
<?php <?php
if (empty($advancedCustom->disableNativeSignUp)) { if (empty($advancedCustomUser->disableNativeSignUp)) {
?> ?>
<small><a href="#" class="btn" id="forgotPassword"><?php echo __("I forgot my password"); ?></a></small> <small><a href="#" class="btn" id="forgotPassword"><?php echo __("I forgot my password"); ?></a></small>
<?php <?php
@ -67,7 +67,7 @@
</form> </form>
<?php <?php
if (empty($advancedCustom->disableNativeSignUp)) { if (empty($advancedCustomUser->disableNativeSignUp)) {
?> ?>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">

View file

@ -1,5 +1,5 @@
<?php <?php
if(!empty($advancedCustom->disablePersonalInfo)){ if(!empty($advancedCustomUser->disablePersonalInfo)){
return false; return false;
} }
require_once $global['systemRootPath'] . 'plugin/User_Location/Objects/IP2Location.php'; require_once $global['systemRootPath'] . 'plugin/User_Location/Objects/IP2Location.php';

View file

@ -56,7 +56,7 @@ if (!empty($video['clean_title'])) {
$get = array(); $get = array();
$get = array('channelName' => @$_GET['channelName'], 'catName' => @$_GET['catName']); $get = array('channelName' => @$_GET['channelName'], 'catName' => @$_GET['catName']);
if (!empty($_GET['channelName']) && empty($advancedCustom->hideRemoveChannelFromModeYoutube)) { if (!empty($_GET['channelName']) && empty($advancedCustomUser->hideRemoveChannelFromModeYoutube)) {
$user = User::getChannelOwner($_GET['channelName']); $user = User::getChannelOwner($_GET['channelName']);
//var_dump($user);exit; //var_dump($user);exit;
?> ?>