diff --git a/objects/login.json.php b/objects/login.json.php index 267eea7b9..f6ecc60a5 100644 --- a/objects/login.json.php +++ b/objects/login.json.php @@ -1,288 +1,284 @@ $value) { $_POST[$key] = $value; } } TimeLogEnd($timeLog, __LINE__); require_once $global['systemRootPath'] . 'videos/configuration.php'; require_once $global['systemRootPath'] . 'objects/user.php'; require_once $global['systemRootPath'] . 'objects/category.php'; Category::clearCacheCount(); TimeLogEnd($timeLog, __LINE__); _error_log("Start Login Request"); _error_log("redirectUri: " . $_POST['redirectUri']); if (!preg_match("|^" . $global['webSiteRootURL'] . "|", $_POST['redirectUri'])) { $_POST['redirectUri'] = $global['webSiteRootURL']; } _error_log("same redirectUri: " . $_POST['redirectUri']); use Hybridauth\Hybridauth; use Hybridauth\HttpClient; TimeLogEnd($timeLog, __LINE__); if (!empty($_GET['type'])) { if (!empty($_GET['redirectUri'])) { if (session_status() == PHP_SESSION_NONE) { session_start(); } $_SESSION['redirectUri'] = $_GET['redirectUri']; } $login = AVideoPlugin::getLogin(); foreach ($login as $value) { $obj = $value['loginObject']->getDataObject(); if ($value['parameters']->type === $_GET['type']) { $id = $obj->id; $key = $obj->key; break; } } if (empty($id)) { die(sprintf(__("%s ERROR: You must set a ID on config"), $_GET['type'])); } if (empty($key)) { die(sprintf(__("%s ERROR: You must set a KEY on config"), $_GET['type'])); } $scope = 'email'; if ($_GET['type'] === "Yahoo") { $scope = 'sdpp-w'; } if ($_GET['type'] === 'LinkedIn') { $scope = ("r_liteprofile r_emailaddress w_member_social"); } $config = [ 'callback' => HttpClient\Util::getCurrentUrl() . "?type={$_GET['type']}", 'providers' => [ $_GET['type'] => [ 'enabled' => true, 'keys' => ['id' => $id, 'secret' => $key, 'key' => $id], "includeEmail" => true, 'scope' => $scope, 'trustForwarded' => false ] ], /* optional : set debug mode 'debug_mode' => true, // Path to file writeable by the web server. Required if 'debug_mode' is not false 'debug_file' => __FILE__ . '.log', */ ]; try { $hybridauth = new Hybridauth($config); $adapter = $hybridauth->authenticate($_GET['type']); $tokens = $adapter->getAccessToken(); $userProfile = $adapter->getUserProfile(); //print_r($tokens); //print_r($userProfile); if (!empty($userProfile->email)) { $user = $userProfile->email; } else { $user = $userProfile->displayName; } $name = $userProfile->displayName; $photoURL = $userProfile->photoURL; $email = $userProfile->email; $pass = rand(); //createUserIfNotExists($user, $pass, $name, $email, $photoURL, $isAdmin = false, $emailVerified = false); User::createUserIfNotExists($user, $pass, $name, $email, $photoURL, false, true); $userObject = new User(0, $user, $pass); $userObject->login(true); $adapter->disconnect(); if (!empty($_SESSION['redirectUri'])) { if (session_status() == PHP_SESSION_NONE) { session_start(); } $location = $_SESSION['redirectUri']; //header("Location: {$_SESSION['redirectUri']}"); $_SESSION['redirectUri'] = ""; unset($_SESSION['redirectUri']); } else { $location = $global['webSiteRootURL']; //header("Location: {$global['webSiteRootURL']}"); } } catch (\Exception $e) { $location = "{$global['webSiteRootURL']}user?error=" . urlencode($e->getMessage()); //header("Location: {$global['webSiteRootURL']}user?error=" . urlencode($e->getMessage())); //echo $e->getMessage(); } header('Content-Type: text/html'); ?> error = __("User and Password can not be blank"); die(json_encode($object)); } $user = new User(0, $_POST['user'], $_POST['pass']); $resp = $user->login(false, @$_POST['encodedPass']); TimeLogEnd($timeLog, __LINE__); $object->isCaptchaNeed = User::isCaptchaNeed(); if ($resp === User::USER_NOT_VERIFIED) { _error_log("login.json.php User not verified"); $object->error = __("Your user is not verified, we sent you a new e-mail"); die(json_encode($object)); } if ($resp === User::CAPTCHA_ERROR) { _error_log("login.json.php invalid captcha"); $object->error = __("Invalid Captcha"); die(json_encode($object)); } if ($resp === User::REQUIRE2FA) { _error_log("login.json.php 2fa login is required"); $object->error = __("2FA login is required"); die(json_encode($object)); } //_error_log("login.json.php setup object"); $object->siteLogo = $global['webSiteRootURL'] . $config->getLogo(); $object->id = User::getId(); $object->user = User::getUserName(); $object->donationLink = User::donationLink(); $object->name = User::getName(); //_error_log("login.json.php get name identification"); $object->nameIdentification = User::getNameIdentification(); $object->pass = User::getUserPass(); $object->email = User::getMail(); //_error_log("login.json.php get channel name"); $object->channelName = User::_getChannelName($object->id); $object->photo = User::getPhoto(); $object->backgroundURL = User::getBackground($object->id); $object->isLogged = User::isLogged(); $object->isAdmin = User::isAdmin(); $object->canUpload = User::canUpload(); $object->canComment = User::canComment(); $object->canStream = User::canStream(); $object->redirectUri = @$_POST['redirectUri']; //_error_log("login.json.php setup object done"); if ((empty($object->redirectUri) || $object->redirectUri === $global['webSiteRootURL'])) { if (!empty($advancedCustomUser->afterLoginGoToMyChannel)) { $object->redirectUri = User::getChannelLink(); } elseif (!empty($advancedCustomUser->afterLoginGoToURL)) { $object->redirectUri = $advancedCustomUser->afterLoginGoToURL; } } if (empty($advancedCustomUser->userCanNotChangeCategory) || User::isAdmin()) { //_error_log("login.json.php get categories"); $object->categories = Category::getAllCategories(true); if (is_array($object->categories)) { array_multisort(array_column($object->categories, 'hierarchyAndName'), SORT_ASC, $object->categories); } } else { $object->categories = array(); } //_error_log("login.json.php get user groups"); -if(!empty($advancedCustomUser->autoSaveUsersOnCategorySelectedGroups)){ - $object->userGroups = array(); -}else{ - TimeLogEnd($timeLog, __LINE__); - $object->userGroups = UserGroups::getAllUsersGroups(); - TimeLogEnd($timeLog, __LINE__); -} +TimeLogEnd($timeLog, __LINE__); +$object->userGroups = UserGroups::getAllUsersGroups(); +TimeLogEnd($timeLog, __LINE__); $object->streamServerURL = ""; $object->streamKey = ""; if ($object->isLogged) { $timeLog2 = __FILE__."::Is Logged "; TimeLogStart($timeLog2); //_error_log("login.json.php get Live"); $p = AVideoPlugin::loadPluginIfEnabled("Live"); if (!empty($p)) { require_once $global['systemRootPath'] . 'plugin/Live/Objects/LiveTransmition.php'; $trasnmition = LiveTransmition::createTransmitionIfNeed(User::getId()); if (!empty($trasnmition)) { $object->streamServerURL = $p->getServer() . "?p=" . User::getUserPass(); $object->streamKey = $trasnmition['key']; } } TimeLogEnd($timeLog2, __LINE__); //_error_log("login.json.php get MobileManager"); $p = AVideoPlugin::loadPluginIfEnabled("MobileManager"); if (!empty($p)) { $object->streamer = json_decode(url_get_contents($global['webSiteRootURL'] . "objects/status.json.php")); $object->plugin = $p->getDataObject(); $object->encoder = $config->getEncoderURL(); } TimeLogEnd($timeLog2, __LINE__); //_error_log("login.json.php get VideoHLS"); $p = AVideoPlugin::loadPluginIfEnabled("VideoHLS"); if (!empty($p)) { $object->videoHLS = true; } TimeLogEnd($timeLog2, __LINE__); //_error_log("login.json.php get Subscriptions"); $p = AVideoPlugin::loadPluginIfEnabled("Subscription"); if (!empty($p)) { $object->Subscription = Subscription::getAllFromUser($object->id); } TimeLogEnd($timeLog2, __LINE__); //_error_log("login.json.php get PayPerView"); $p = AVideoPlugin::loadPluginIfEnabled("PayPerView"); if (!empty($p) && class_exists('PayPerView')) { $object->PayPerView = PayPerView::getAllPPVFromUser($object->id); } TimeLogEnd($timeLog2, __LINE__); } TimeLogEnd($timeLog, __LINE__); //_error_log("login.json.php almost complete"); $json = _json_encode($object); //_error_log("login.json.php complete"); //header("Content-length: " . strlen($json)); echo $json; diff --git a/plugin/CustomizeUser/CustomizeUser.php b/plugin/CustomizeUser/CustomizeUser.php index 10cc799a0..7b5333c7a 100644 --- a/plugin/CustomizeUser/CustomizeUser.php +++ b/plugin/CustomizeUser/CustomizeUser.php @@ -1,478 +1,478 @@ nonAdminCannotDownload = false; $obj->userCanAllowFilesDownload = false; $obj->userCanAllowFilesShare = false; $obj->userCanAllowFilesDownloadSelectPerVideo = false; $obj->userCanAllowFilesShareSelectPerVideo = false; $obj->blockEmbedFromSharedVideos = true; $obj->userCanProtectVideosWithPassword = true; $obj->userCanChangeVideoOwner = false; $obj->usersCanCreateNewCategories = !isset($advancedCustom->usersCanCreateNewCategories) ? false : $advancedCustom->usersCanCreateNewCategories; $obj->userCanNotChangeCategory = !isset($advancedCustom->userCanNotChangeCategory) ? false : $advancedCustom->userCanNotChangeCategory; $obj->userCanNotChangeUserGroup = false; $o = new stdClass(); $o->type = array(0=>__("Default"))+UserGroups::getAllUsersGroupsArray(); $o->value = 0; $obj->userDefaultUserGroup = $o; $obj->userMustBeLoggedIn = !isset($advancedCustom->userMustBeLoggedIn) ? false : $advancedCustom->userMustBeLoggedIn; $obj->userMustBeLoggedInCloseButtonURL = ""; $obj->onlyVerifiedEmailCanUpload = !isset($advancedCustom->onlyVerifiedEmailCanUpload) ? false : $advancedCustom->onlyVerifiedEmailCanUpload; $obj->sendVerificationMailAutomaic = !isset($advancedCustom->sendVerificationMailAutomaic) ? false : $advancedCustom->sendVerificationMailAutomaic; $o = new stdClass(); $o->type = "textarea"; $o->value = "Just a quick note to say a big welcome and an even bigger thank you for registering"; $obj->verificationMailTextLine1 = "Just a quick note to say a big welcome and an even bigger thank you for registering"; $obj->verificationMailTextLine2 = "Cheers, %s Team."; $obj->verificationMailTextLine3 = "You are just one click away from starting your journey with %s!"; $obj->verificationMailTextLine4 = "All you need to do is to verify your e-mail by clicking the link below"; $obj->unverifiedEmailsCanNOTLogin = !isset($advancedCustom->unverifiedEmailsCanNOTLogin) ? false : $advancedCustom->unverifiedEmailsCanNOTLogin; $obj->unverifiedEmailsCanNOTComment = false; $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->showChannelHomeTab = true; $obj->showChannelVideosTab = true; $obj->showChannelProgramsTab = true; $obj->showBigVideoOnChannelVideosTab = true; $obj->encryptPasswordsWithSalt = !isset($advancedCustom->encryptPasswordsWithSalt) ? false : $advancedCustom->encryptPasswordsWithSalt; $obj->requestCaptchaAfterLoginsAttempts = !isset($advancedCustom->requestCaptchaAfterLoginsAttempts) ? 0 : $advancedCustom->requestCaptchaAfterLoginsAttempts; $obj->disableSignOutButton = false; $obj->disableNativeSignUp = !isset($advancedCustom->disableNativeSignUp) ? false : $advancedCustom->disableNativeSignUp; $obj->disableNativeSignIn = !isset($advancedCustom->disableNativeSignIn) ? false : $advancedCustom->disableNativeSignIn; $obj->disablePersonalInfo = !isset($advancedCustom->disablePersonalInfo) ? true : $advancedCustom->disablePersonalInfo; $obj->userCanChangeUsername = true; $obj->signInOnRight = false; $obj->doNotShowRightProfile = false; $obj->doNotShowLeftProfile = false; $obj->forceLoginToBeTheEmail = false; $obj->emailMustBeUnique = false; // added on 2019-02-11 $o = new stdClass(); $o->type = "textarea"; $o->value = ""; $obj->messageToAppearBelowLoginBox = $o; $o = new stdClass(); $o->type = "textarea"; $o->value = ""; $obj->messageToAppearAboveSignUpBox = $o; $obj->keepViewerOnChannel = false; $obj->showLeaveChannelButton = false; $obj->addChannelNameOnLinks = true; $obj->doNotShowTopBannerOnChannel = false; $obj->doNotShowMyChannelNameOnBasicInfo = false; $obj->doNotShowMyAnalyticsCodeOnBasicInfo = false; $obj->doNotShowMyAboutOnBasicInfo = false; $obj->MyChannelLabel = "My Channel"; $obj->afterLoginGoToMyChannel = false; $obj->afterLoginGoToURL = ""; $obj->afterLogoffGoToMyChannel = false; $obj->afterLogoffGoToURL = ""; $obj->allowDonationLink = false; $obj->allowWalletDirectTransferDonation = false; $obj->donationButtonLabel = __('Donation'); $obj->showEmailVerifiedMark = true; $obj->Checkmark1Enabled = true; $obj->Checkmark1HTML = ''; $obj->Checkmark2Enabled = true; $obj->Checkmark2HTML = ''; $obj->Checkmark3Enabled = true; $obj->Checkmark3HTML = ''; $obj->autoSaveUsersOnCategorySelectedGroups = false; - self::addDataObjectHelper('autoSaveUsersOnCategorySelectedGroups', 'Auto save new users on category selected User Groups', 'Edit this plugin to select the user groups per category'); + self::addDataObjectHelper('autoSaveUsersOnCategorySelectedGroups', 'Auto save new videos on category selected User Groups', 'Edit this plugin to select the user groups per category'); $obj->enableExtraInfo = false; self::addDataObjectHelper('enableExtraInfo', 'Enable user extra info', 'You can add custom fields on user“s profile, Edit this plugin to tell what fields should be saved'); return $obj; } public function getUserOptions() { $obj = $this->getDataObject(); $userOptions = array(); if ($obj->Checkmark1Enabled) { $userOptions["Checkmark 1"] = "checkmark1"; } if ($obj->Checkmark2Enabled) { $userOptions["Checkmark 2"] = "checkmark2"; } if ($obj->Checkmark3Enabled) { $userOptions["Checkmark 3"] = "checkmark3"; } return $userOptions; } static function canDownloadVideosFromUser($users_id) { global $config; $obj = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser"); if(!empty($obj->nonAdminCannotDownload) && !User::isAdmin()){ return false; } if (empty($obj) || empty($obj->userCanAllowFilesDownload)) { return self::canDownloadVideos(); } $user = new User($users_id); return !empty($user->getExternalOption('userCanAllowFilesDownload')); } static function canDownloadVideos() { global $config; $obj = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser"); if(!empty($obj->nonAdminCannotDownload) && !User::isAdmin()){ return false; } return !empty($config->getAllow_download()); } static function setCanDownloadVideosFromUser($users_id, $value = true) { $obj = AVideoPlugin::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->disableShareOnly)) { _error_log("CustomizeUser::canShareVideosFromUser disableShareOnly"); return false; } if (!empty($advancedCustom->disableShareAndPlaylist)) { _error_log("CustomizeUser::canShareVideosFromUser disableShareAndPlaylist"); return false; } $obj = AVideoPlugin::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 = AVideoPlugin::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 = AVideoPlugin::getObjectDataIfEnabled("CustomizeUser"); if (!empty($objcu) && !empty($objcu->userCanAllowFilesDownload)) { echo '