1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-03 01:39:24 +02:00

New version 9.6 that add support to encoder Version 3.3

you can now dynamic extract resolutions from MP4 and Webm files on encoder
-- Add Login control
-- Fix some layout issues
-- support for encoder 3.3 and dynamic resolutions for MP4 and webm
This commit is contained in:
DanielnetoDotCom 2020-10-12 23:03:47 -03:00
parent 6303633477
commit 16059b5d84
48 changed files with 1589 additions and 202 deletions

3
.gitignore vendored
View file

@ -64,4 +64,5 @@
/plugin/IPTV/
/.scannerwork/
/vendor/
/plugin/Layout/
/plugin/Layout/
/git.php

View file

@ -51,7 +51,7 @@ Options All -Indexes
# END Expires
# BEGIN Caching
<ifModule mod_headers.c>
<FilesMatch "\.(ts|key|ttf|otf|eot|woff|woff2|mp4|webm|m3u8|mp3|ogg)$">
<FilesMatch "\.(ts|key|ttf|otf|eot|woff|woff2|mp4|webm|m3u8|mp3|ogg|css)$">
Header set Access-Control-Allow-Origin: *
</FilesMatch>
<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf)$">
@ -90,6 +90,7 @@ Options All -Indexes
RewriteRule ^js/(.+)$ view/js/$1 [NC,L]
RewriteRule ^css/(.+)$ view/css/$1 [NC,L]
RewriteRule ^img/(.+)$ view/img/$1 [NC,L]
RewriteRule ^i/(.+)$ view/iframe.php?type=$1 [NC,L]
RewriteRule ^videos/fonts/(.+)$ view/bootstrap/fonts/$1 [NC,L]
RewriteRule ^page/([0-9]+)/?$ view/?page=$1 [QSA]
RewriteRule ^videoOnly/?$ view/?type=video [NC,L]

View file

@ -4,7 +4,7 @@ if (file_exists("../videos/configuration.php")) {
exit;
}
$installationVersion = "9.5";
$installationVersion = "9.6";
error_log("Installation: ".__LINE__." ". json_encode($_POST));
header('Content-Type: application/json');

View file

@ -320,13 +320,13 @@ abstract class ObjectYPT implements ObjectInterface {
static function getCacheDir() {
$tmpDir = getTmpDir();
$tmpDir = rtrim($tmpDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
$tmpDir .= "YPTObjectCache" . DIRECTORY_SEPARATOR;
$tmpDir = rtrim($tmpDir, DIRECTORY_SEPARATOR) . "/";
$tmpDir .= "YPTObjectCache" . "/";
if(class_exists("User_Location")){
$loc = User_Location::getThisUserLocation();
if(!empty($loc)){
$tmpDir .= $loc['country_code'] . DIRECTORY_SEPARATOR;
$tmpDir .= $loc['country_code'] . "/";
}
}

View file

@ -39,6 +39,8 @@ if (!empty($_POST['videos_id']) && !Video::canEdit($_POST['videos_id'])) {
die(json_encode($obj));
}
_error_log("aVideoEncoder.json: start to receive: " . json_encode($_POST));
// check if there is en video id if yes update if is not create a new one
$video = new Video("", "", @$_POST['videos_id']);
$obj->video_id = @$_POST['videos_id'];

View file

@ -15,6 +15,7 @@ while ($data = fread($putdata, 1024 * 1024))
fclose($fp);
fclose($putdata);
sleep(1);
$obj->filesize = filesize($obj->file);
$json = json_encode($obj);

View file

@ -22,58 +22,70 @@ if (empty($_POST)) {
$user = new User("", @$_POST['user'], @$_POST['password']);
$user->login(false, true);
if (!User::canUpload()) {
$obj->msg = __("Permission denied to receive a file: " . print_r($_POST, true));
$obj->msg = __("Permission denied to receive a file: " . json_encode($_POST));
_error_log("ReceiveImage: ".$obj->msg);
die(json_encode($obj));
}
if(!Video::canEdit($_POST['videos_id'])){
$obj->msg = __("Permission denied to edit a video: " . print_r($_POST, true));
$obj->msg = __("Permission denied to edit a video: " . json_encode($_POST));
_error_log("ReceiveImage: ".$obj->msg);
die(json_encode($obj));
}
_error_log("ReceiveImage: "."Start receiving image");
_error_log("ReceiveImage: "."Start receiving image ". json_encode($_FILES)."". json_encode($_POST));
// check if there is en video id if yes update if is not create a new one
$video = new Video("", "", $_POST['videos_id']);
$obj->video_id = $_POST['videos_id'];
_error_log("ReceiveImage: "."Encoder receiving post ". print_r($_FILES, true));
//_error_log("ReceiveImage: ".print_r($_POST, true));
_error_log("ReceiveImage: "."Encoder receiving post ". json_encode($_FILES));
//_error_log("ReceiveImage: ".json_encode($_POST));
$videoFileName = $video->getFilename();
$destination_local = "{$global['systemRootPath']}videos/{$videoFileName}";
if (!empty($_FILES['image']['tmp_name']) && !file_exists("{$destination_local}.jpg")) {
if (!move_uploaded_file($_FILES['image']['tmp_name'], "{$destination_local}.jpg")) {
$obj->jpgDest = "{$destination_local}.jpg";
if (!empty($_FILES['image']['tmp_name']) && (!file_exists($obj->jpgDest) || filesize($obj->jpgDest)===42342)) {
if (!move_uploaded_file($_FILES['image']['tmp_name'], $obj->jpgDest)) {
$obj->msg = print_r(sprintf(__("Could not move image file [%s.jpg]"), $destination_local), true);
_error_log("ReceiveImage: ".$obj->msg);
die(json_encode($obj));
}
} else{
$obj->jpgDestSize = humanFileSize(filesize($obj->jpgDest));
}
}
if (!empty($_FILES['gifimage']['tmp_name']) && !file_exists("{$destination_local}.gif")) {
if (!move_uploaded_file($_FILES['gifimage']['tmp_name'], "{$destination_local}.gif")) {
$obj->gifDest = "{$destination_local}.gif";
if (!empty($_FILES['gifimage']['tmp_name']) && (!file_exists($obj->gifDest) || filesize($obj->gifDest)===2095341)) {
if (!move_uploaded_file($_FILES['gifimage']['tmp_name'], $obj->gifDest)) {
$obj->msg = print_r(sprintf(__("Could not move gif image file [%s.gif]"), $destination_local), true);
_error_log("ReceiveImage: ".$obj->msg);
die(json_encode($obj));
}
} else{
$obj->gifDestSize = humanFileSize(filesize($obj->gifDest));
}
}
if (!empty($_FILES['webpimage']['tmp_name']) && !file_exists("{$destination_local}.webp")) {
if (!move_uploaded_file($_FILES['webpimage']['tmp_name'], "{$destination_local}.webp")) {
$obj->webpDest = "{$destination_local}.webp";
if (!empty($_FILES['webpimage']['tmp_name']) && (!file_exists($obj->webpDest) || filesize($obj->webpDest)===2095341)) {
if (!move_uploaded_file($_FILES['webpimage']['tmp_name'], $obj->webpDest)) {
$obj->msg = print_r(sprintf(__("Could not move webp image file [%s.webp]"), $destination_local), true);
_error_log("ReceiveImage: ".$obj->msg);
die(json_encode($obj));
}
} else{
$obj->webpDestSize = humanFileSize(filesize($obj->webpDest));
}
}
$video_id = $video->save();
Video::updateFilesize($video_id);
$obj->error = false;
$obj->video_id = $video_id;
_error_log("ReceiveImage: "."Files Received for video {$video_id}: " . $video->getTitle());
die(json_encode($obj));
$json = json_encode($obj);
_error_log("ReceiveImage: "."Files Received for video {$video_id}: " . $video->getTitle()." {$json}");
die($json);
/*
_error_log(print_r($_POST, true));
_error_log(print_r($_FILES, true));
_error_log(json_encode($_POST));
_error_log(json_encode($_FILES));
var_dump($_POST, $_FILES);
*/

View file

@ -535,6 +535,10 @@ function sendSiteEmail($to, $subject, $message) {
$to = array($to);
}
if(empty($advancedCustom)){
$advancedCustom = AVideoPlugin::loadPlugin("CustomizeAdvanced");
}
$subject = UTF8encode($subject);
$message = UTF8encode($message);
@ -563,7 +567,7 @@ function sendSiteEmail($to, $subject, $message) {
_error_log("sendSiteEmail Success Info: $subject " . json_encode($to));
}
} else {
$size = intval($advancedCustom->splitBulkEmailSend);
$size = intval(@$advancedCustom->splitBulkEmailSend);
if (empty($size)) {
$size = 90;
}
@ -1083,7 +1087,7 @@ function getVideosURLAudio($fileName) {
function getVideosURL($fileName, $cache = true) {
//return getVideosURL_V2($fileName); // disable this function soon
return getVideosURL_V2($fileName); // disable this function soon
global $global;
if (empty($fileName)) {
@ -1376,16 +1380,7 @@ function getSources($fileName, $returnArray = false) {
if ($path_parts['extension'] == "webm" || $path_parts['extension'] == "mp4" || $path_parts['extension'] == "m3u8" || $path_parts['extension'] == "mp3" || $path_parts['extension'] == "ogg") {
$obj = new stdClass();
$obj->type = mime_content_type_per_filename($value['path']);
if ($path_parts['extension'] == "webm" || $path_parts['extension'] == "mp4" || $path_parts['extension'] == "m3u8") {
$getVars = "";
if($path_parts['extension'] == "m3u8"){
$getVars = "?". uniqid();
}
$sources .= "<source src=\"{$value['url']}{$getVars}\" type=\"{$obj->type}\">";
} else {
$sources .= "<source src=\"{$value['url']}\" type=\"{$obj->type}\">";
}
$sources .= "<source src=\"{$value['url']}\" type=\"{$obj->type}\">";
$obj->src = $value['url'];
$sourcesArray[] = $obj;
}
@ -4689,21 +4684,65 @@ function ogSite() {
function gotToLoginAndComeBackHere($msg) {
global $global;
header("Location: {$global['webSiteRootURL']}/user?redirectUri=" . urlencode(getSelfURI()) . "&msg=" . urlencode($msg));
header("Location: {$global['webSiteRootURL']}user?redirectUri=" . urlencode(getSelfURI()) . "&msg=" . urlencode($msg));
exit;
}
function setAlertMessage($msg, $type = "msg") {
_session_start();
$_SESSION['YPTalertMessage'] = array($msg, $type);
$_SESSION['YPTalertMessage'][] = array($msg, $type);
}
function setToastMessage($msg) {
setAlertMessage($msg, "toast");
}
function showAlertMessage() {
if (!empty($_SESSION['YPTalertMessage'])) {
$_GET[$_SESSION['YPTalertMessage'][1]] = $_SESSION['YPTalertMessage'][0];
foreach ($_SESSION['YPTalertMessage'] as $value) {
if(!empty($value[0])){
if(empty($_GET[$value[1]])){
$_GET[$value[1]] = array();
}
$_GET[$value[1]][] = $value[0];
}
}
_session_start();
unset($_SESSION['YPTalertMessage']);
}
$joinString = array('error', 'msg', 'success');
foreach ($joinString as $value) {
if(!empty($_GET[$value]) && is_array($_GET[$value])){
$_GET[$value] = array_unique($_GET[$value]);
$newStr = array();
foreach ($_GET[$value] as $value2) {
if(!empty($value2)){
$newStr[] = $value2;
}
}
$_GET[$value] = implode("<br>", $newStr);
}
}
$check = array('error', 'msg', 'success', 'toast');
foreach ($check as $value) {
if(!empty($_GET[$value])){
if(is_array($_GET[$value])){
$newStr = array();
foreach ($_GET[$value] as $key => $value2) {
$value2 = str_replace('"', "''", $value2);
if(!empty($value2)){
$newStr[] = $value2;
}
}
$_GET[$value] = $newStr;
}else{
$_GET[$value] = str_replace('"', "''", $_GET[$value]);
}
}
}
echo "/** showAlertMessage **/", PHP_EOL;
if (!empty($_GET['error'])) {
echo 'avideoAlertError("' . $_GET['error'] . '");';
echo 'window.history.pushState({}, document.title, "' . getSelfURI() . '");';
@ -4716,5 +4755,29 @@ function ogSite() {
echo 'avideoAlertSuccess("' . $_GET['success'] . '");';
echo 'window.history.pushState({}, document.title, "' . getSelfURI() . '");';
}
if (!empty($_GET['toast'])) {
if(!is_array($_GET['toast'])){
$_GET['toast'] = array($_GET['toast']);
}else{
$_GET['toast'] = array_unique($_GET['toast']);
}
foreach ($_GET['toast'] as $key => $value) {
$hideAfter = strlen(strip_tags($value))*150;
if($hideAfter<3000){
$hideAfter = 3000;
}
if($hideAfter>15000){
$hideAfter = 15000;
}
echo '$.toast({
text: "' . $value . '",
hideAfter: '.$hideAfter.' // in milli seconds
});console.log("Toast Hide after '.$hideAfter.'");';
}
echo 'window.history.pushState({}, document.title, "' . getSelfURI() . '");';
}
echo PHP_EOL, "/** showAlertMessage END **/";
}

View file

@ -121,7 +121,7 @@ if ($baseName !== 'xsendfile.php' && class_exists("Plugin")) {
if (empty($global['bodyClass'])) {
$global['bodyClass'] = "";
}
$global['allowedExtension'] = array('gif', 'jpg', 'mp4', 'webm', 'mp3','m4a', 'ogg', 'zip');
$global['allowedExtension'] = array('gif', 'jpg', 'mp4', 'webm', 'mp3','m4a', 'ogg', 'zip', 'm3u8');
$advancedCustom = AVideoPlugin::getObjectData("CustomizeAdvanced");
$advancedCustomUser = AVideoPlugin::getObjectData("CustomizeUser");
$customizePlugin = AVideoPlugin::getObjectData("Customize");

View file

@ -179,6 +179,12 @@ if ($resp === User::CAPTCHA_ERROR) {
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();
@ -232,8 +238,10 @@ if ($object->isLogged) {
if (!empty($p)) {
require_once $global['systemRootPath'] . 'plugin/Live/Objects/LiveTransmition.php';
$trasnmition = LiveTransmition::createTransmitionIfNeed(User::getId());
$object->streamServerURL = $p->getServer() . "?p=" . User::getUserPass();
$object->streamKey = $trasnmition['key'];
if(!empty($trasnmition)){
$object->streamServerURL = $p->getServer() . "?p=" . User::getUserPass();
$object->streamKey = $trasnmition['key'];
}
}
TimeLogEnd($timeLog2, __LINE__);
//_error_log("login.json.php get MobileManager");

View file

@ -53,7 +53,7 @@ class sqlDAL {
if (substr(trim($line), -1, 1) == ';') {
// Perform the query
if (!$global['mysqli']->query($templine)) {
_error_log('sqlDAL::executeFile '.$filename.' Error performing query \'<strong>' . $templine . '\': ' . $global['mysqli']->error . '<br /><br />', AVideoLog::$ERROR);
_error_log('sqlDAL::executeFile ' . $filename . ' Error performing query \'<strong>' . $templine . '\': ' . $global['mysqli']->error . '<br /><br />', AVideoLog::$ERROR);
}
// Reset temp variable to empty
$templine = '';
@ -81,7 +81,7 @@ class sqlDAL {
$audit->exec(@$debug[1]['function'], @$debug[1]['class'], $preparedStatement, $formats, json_encode($values), User::getId());
} catch (Exception $exc) {
echo log_error($exc->getTraceAsString());
}
}
}
}
@ -144,7 +144,7 @@ class sqlDAL {
log_error("[sqlDAL::readSql] (mysqlnd) eval_mysql_bind failed: values and params in stmt don't match <br>\r\n{$preparedStatement} with formats {$formats}");
return false;
}
$TimeLog = "[$preparedStatement], $formats, ". json_encode($values).", $refreshCache";
$TimeLog = "[$preparedStatement], $formats, " . json_encode($values) . ", $refreshCache";
TimeLogStart($TimeLog);
$stmt->execute();
$readSqlCached[$crc] = $stmt->get_result();
@ -167,7 +167,7 @@ class sqlDAL {
//log_error("set dataseek to 0");
// increase a counter for the saved queries.
if (isset($_SESSION['savedQuerys'])) {
$_SESSION['savedQuerys'] ++;
$_SESSION['savedQuerys']++;
}
} else {
$readSqlCached[$crc] = "false";
@ -365,6 +365,9 @@ class sqlDAL {
$metadata = mysqli_stmt_result_metadata($stmt);
$ret = new iimysqli_result;
$field_array = array();
if (!$metadata) {
die("Execute query error, because: {$stmt->error}");
}
$tmpFields = $metadata->fetch_fields();
$i = 0;
foreach ($tmpFields as $f) {

View file

@ -7,6 +7,7 @@ require_once $global['systemRootPath'] . 'objects/captcha.php';
$config = new Configuration();
$valid = Captcha::validation(@$_POST['captcha']);
$obj = new stdClass();
$obj->error = "";
if ($valid) {
$msg = "<b>Name:</b> {$_POST['first_name']}<br> <b>Email:</b> {$_POST['email']}<br><b>Website:</b> {$_POST['website']}<br><br>{$_POST['comment']}";

View file

@ -758,6 +758,7 @@ if (typeof gtag !== \"function\") {
const USER_NOT_VERIFIED = 1;
const USER_NOT_FOUND = 2;
const CAPTCHA_ERROR = 3;
const REQUIRE2FA = 4;
function login($noPass = false, $encodedPass = false) {
global $global, $advancedCustom, $advancedCustomUser, $config;
@ -807,7 +808,7 @@ if (typeof gtag !== \"function\") {
return self::USER_NOT_FOUND;
}
}
static function isCaptchaNeed() {
global $advancedCustomUser;
// check for multiple logins attempts to prevent hacking
@ -881,9 +882,8 @@ if (typeof gtag !== \"function\") {
static function logoff() {
global $global;
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
_session_start();
ObjectYPT::deleteAllSessionCache();
_unsetcookie('rememberme');
_unsetcookie('user');
_unsetcookie('pass');
@ -996,7 +996,7 @@ if (typeof gtag !== \"function\") {
if (!empty($result)) {
if ($pass !== false) {
if (!encryptPasswordVerify($pass, $result['password'], $encodedPass)) {
if ($advancedCustom->enableOldPassHashCheck) {
if (!empty($advancedCustom) && $advancedCustom->enableOldPassHashCheck) {
_error_log("Password check new hash pass does not match, trying MD5");
return $this->find_Old($user, $pass, $mustBeactive, $encodedPass);
} else {

View file

@ -852,6 +852,7 @@ if (!class_exists('Video')) {
if (!empty($parts[0])) {
$fileName = $parts[0];
}
$fileName = self::getCleanFilenameFromFile($fileName);
$sql = "SELECT id FROM videos WHERE filename = ? LIMIT 1";
$res = sqlDAL::readSql($sql, "s", array($fileName));
@ -2574,7 +2575,14 @@ if (!class_exists('Video')) {
* @return type .jpg .gif .webp _thumbs.jpg _Low.mp4 _SD.mp4 _HD.mp4
*/
static function getSourceFile($filename, $type = ".jpg", $includeS3 = false) {
global $global, $advancedCustom, $videosPaths;
global $global, $advancedCustom, $videosPaths, $VideoGetSourceFile;
$cacheName = md5($filename.$type.$includeS3);
if(isset($VideoGetSourceFile[$cacheName])){
return $VideoGetSourceFile[$cacheName];
}
// check if there is a webp image
if ($type === '.gif' && (empty($_SERVER['HTTP_USER_AGENT']) || get_browser_name($_SERVER['HTTP_USER_AGENT']) !== 'Safari')) {
@ -2617,7 +2625,13 @@ if (!class_exists('Video')) {
if ($type == ".m3u8") {
$source['path'] = "{$global['systemRootPath']}videos/{$filename}/index{$type}";
}
$video = Video::getVideoFromFileNameLight(str_replace(array('_Low', '_SD', '_HD'), array('', '', ''), $filename));
$cleanFileName = self::getCleanFilenameFromFile($filename);
$video = Video::getVideoFromFileNameLight($cleanFileName);
if(empty($video)){
_error_log("Video::getSourceFile($filename, $type, $includeS3) ERROR video not found ($cleanFileName)");
$VideoGetSourceFile[$cacheName] = false;
return false;
}
$canUseCDN = canUseCDN($video['id']);
if (!empty($video['sites_id']) && (preg_match("/.*\\.mp3$/", $type) || preg_match("/.*\\.mp4$/", $type) || preg_match("/.*\\.webm$/", $type) || $type == ".m3u8" || $type == ".pdf" || $type == ".zip") && @filesize($source['path']) < 20) {
@ -2653,7 +2667,8 @@ if (!class_exists('Video')) {
}
if (!file_exists($source['path']) || ($type !== ".m3u8" && !is_dir($source['path']) && (filesize($source['path']) < 1000 && filesize($source['path']) != 10 ))) {
if ($type != "_thumbsV2.jpg" && $type != "_thumbsSmallV2.jpg" && $type != "_portrait_thumbsV2.jpg" && $type != "_portrait_thumbsSmallV2.jpg") {
return array('path' => false, 'url' => false);
$VideoGetSourceFile[$cacheName] = array('path' => false, 'url' => false);
return $VideoGetSourceFile[$cacheName];
}
}
@ -2671,7 +2686,21 @@ if (!class_exists('Video')) {
$source['url'] .= "?{$x}";
}
//ObjectYPT::setCache($name, $source);
return $source;
$VideoGetSourceFile[$cacheName] = $source;
return $VideoGetSourceFile[$cacheName];
}
static function getCleanFilenameFromFile($filename) {
$cleanName = str_replace(
array('_Low', '_SD', '_HD', '_thumbsV2','_thumbsSmallV2',
'_2160', '_1440', '_1080', '_720', '_480', '_360', '_240'),
array('', '', '', '', '', '', '', '', '', '', '', ''), $filename);
$path_parts = pathinfo($cleanName);
if(strlen($path_parts['extension'])>4){
return $cleanName;
}else{
return $path_parts['filename'];
}
}
static function getHigestResolutionVideoMP4Source($filename, $includeS3 = false) {
@ -2723,7 +2752,7 @@ if (!class_exists('Video')) {
}
static function getVideosPaths($filename, $includeS3 = false) {
$types = array('', '_Low', '_SD', '_HD');
$types = array('', '_Low', '_SD', '_HD','_2160', '_1440', '_1080', '_720', '_480', '_360', '_240');
$videos = array();
$plugin = AVideoPlugin::loadPluginIfEnabled("VideoHLS");
@ -3226,6 +3255,7 @@ if (!class_exists('Video')) {
ObjectYPT::deleteCache("otherInfo{$videos_id}");
ObjectYPT::deleteCache($filename);
ObjectYPT::deleteCache("getVideosURL_V2$filename");
ObjectYPT::deleteCache($filename . "article");
ObjectYPT::deleteCache($filename . "pdf");
ObjectYPT::deleteCache($filename . "video");
@ -3295,7 +3325,7 @@ if (!class_exists('Video')) {
static function getVideoType($filename) {
$obj = new stdClass();
$paths = self::getVideosPaths($filename);
$obj->mp4 = !empty($paths['mp4']) ? true : false;
$obj->webm = !empty($paths['webm']) ? true : false;
$obj->m3u8 = !empty($paths['m3u8']) ? true : false;

View file

@ -41,6 +41,9 @@ class Live extends PluginAbstract {
global $global;
$buttonTitle = $this->getButtonTitle();
$obj = $this->getDataObject();
if(!empty($obj->hideTopButton )){
return '';
}
include $global['systemRootPath'] . 'plugin/Live/view/menuRight.php';
}
@ -131,6 +134,7 @@ class Live extends PluginAbstract {
$obj->disableDVR = false;
$obj->disableGifThumbs = false;
$obj->disableLiveThumbs = false;
$obj->hideTopButton = true;
$obj->useAadaptiveMode = false;
$obj->protectLive = false;
$obj->experimentalWebcam = false;
@ -1040,5 +1044,15 @@ class Live extends PluginAbstract {
return true;
}
public function getUploadMenuButton() {
global $global;
$obj = $this->getDataObject();
if (!empty($obj->doNotShowGoLiveButton) || !User::canStream()) {
return '';
}
$buttonTitle = $this->getButtonTitle();
include $global['systemRootPath'] . 'plugin/Live/getUploadMenuButton.php';
}
}

View file

@ -0,0 +1,5 @@
<li>
<a href="<?php echo $global['webSiteRootURL']; ?>plugin/Live" data-toggle="tooltip" title="<?php echo __("Broadcast a Live Stream"); ?>" data-placement="left" >
<span class="fa fa-circle"></span> <?php echo $buttonTitle; ?>
</a>
</li>

View file

@ -36,6 +36,7 @@ class LiveLinks extends PluginAbstract {
$obj->disableGifThumbs = false;
$obj->disableLiveThumbs = false;
$obj->doNotShowLiveLinksLabel = false;
$obj->hideTopButton = true;
return $obj;
}
@ -61,6 +62,9 @@ class LiveLinks extends PluginAbstract {
public function getHTMLMenuRight() {
global $global;
$obj = $this->getDataObject();
if(!empty($obj->hideTopButton )){
return '';
}
if (!$this->canAddLinks()) {
return '';
}
@ -208,5 +212,16 @@ class LiveLinks extends PluginAbstract {
return $file;
}
public function getUploadMenuButton() {
global $global;
if (!$this->canAddLinks()) {
return '';
}
$obj = $this->getDataObject();
$buttonTitle = $obj->buttonTitle;
include $global['systemRootPath'] . 'plugin/LiveLinks/getUploadMenuButton.php';
}
}

View file

@ -0,0 +1,5 @@
<li>
<a href="<?php echo $global['webSiteRootURL']; ?>plugin/LiveLinks" data-toggle="tooltip" title="<?php echo __("Add an External a Live Streaming"); ?>" data-placement="left" >
<i class="fas fa-link"></i> <span class="hidden-md hidden-sm hidden-mdx"><?php echo $buttonTitle; ?></span>
</a>
</li>

View file

@ -0,0 +1,404 @@
<?php
global $global;
require_once $global['systemRootPath'] . 'plugin/Plugin.abstract.php';
require_once $global['systemRootPath'] . 'plugin/LoginControl/Objects/Users_login_history.php';
class LoginControl extends PluginAbstract {
public function getTags() {
return array(
PluginTags::$FREE,
PluginTags::$SECURITY,
PluginTags::$LOGIN,
);
}
public function getDescription() {
$desc = "LoginControl Plugin";
$desc .= "<br><strong>Protect your account with 2-Factor Authentication</strong>: With 2-Factor Authentication, you add an extra layer of security to your account in case your password is stolen. After you set up 2-Step Verification, you'll sign in to your account in two steps using:
<br> - Something you know, like your password
<br> - Something you have,access to your email";
$desc .= "<br><strong>Single Device Login Limitation</strong>: If you are logged in on one device and then go to log in on another, your first session will expire and you will be logged out automatically. Only admins users are ignored on this rule";
//$desc .= $this->isReadyLabel(array('YPTWallet'));
return $desc;
}
public function getName() {
return "LoginControl";
}
public function getUUID() {
return "LoginControl-5ee8405eaaa16";
}
public function getPluginVersion() {
return "1.0";
}
public function updateScript() {
global $global;
/*
if (AVideoPlugin::compareVersion($this->getName(), "2.0") < 0) {
sqlDal::executeFile($global['systemRootPath'] . 'plugin/PayPerView/install/updateV2.0.sql');
}
*
*/
return true;
}
public function getEmptyDataObject() {
$obj = new stdClass();
$obj->singleDeviceLogin = false; // will disconnect other devices
$obj->enable2FA = false;
$o = new stdClass();
$obj->textFor2FASubject = "Confirm {siteName} log in from a new browser";
$o->type = "textarea";
$o->value = "Dear {user},
If you recently tried to log into your {siteName} account from {userIP} using the device {userAgent}, please complete your login by clicking {confirmationLink}.
If the login attempt was NOT done by you, secure your account by changing your {siteName} password immediately.
Best regards,
{siteName}";
$obj->textFor2FABody = $o;
/*
$obj->textSample = "text";
$obj->checkboxSample = true;
$obj->numberSample = 5;
$o = new stdClass();
$o->type = array(0=>__("Default"))+array(1,2,3);
$o->value = 0;
$obj->selectBoxSample = $o;
*/
return $obj;
}
public function getPluginMenu() {
global $global;
return '<a href="plugin/LoginControl/View/editor.php" class="btn btn-primary btn-sm btn-xs btn-block"><i class="fa fa-edit"></i> Edit</a>';
}
public function onUserSignIn($users_id) {
if (empty($_REQUEST['confirmation'])) {
// create the log
self::createLog($users_id);
}
// check if the user confirmed this device before
if (self::is2FAEnabled($users_id) && !self::is2FAConfirmed($users_id)) {
header('Content-Type: application/json');
_error_log("Login_control::onUserSignIn 2FA is required for user {$users_id}");
if (self::send2FAEmail($users_id)) {
User::logoff();
$object = new stdClass();
$u = new User($users_id);
$to = $u->getEmail();
$hiddenemail = self::getHiddenEmail($to);
$object->error = __("Please check your email for 2FA confirmation ") ."<br>($hiddenemail)";
die(json_encode($object));
} else {
_error_log("Login_control::onUserSignIn 2FA your email could not be sent ({$users_id})", AVideoLog::$ERROR);
setToastMessage(__("2FA email not sent"));
}
}else{
$row = self::getPreviewsLogin(User::getId());
if(!empty($row)){
setToastMessage(__("Last login was on ")." ".$row['ago']." (".$row['device'].")");
}
}
}
private static function getHiddenEmail($email){
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
return false;
}
$parts = explode("@", $email);
$hiddenemail = "";
$part0Len = strlen($parts[0]);
$hiddenemail = substr($parts[0], 0, 2);
for($i=2;$i<$part0Len;$i++){
$hiddenemail.="*";
}
$hiddenemail.="@";
$part1Len = strlen($parts[1]);
for($i=0;$i<$part1Len-4;$i++){
$hiddenemail.="*";
}
$hiddenemail .= substr($parts[1], $part1Len-4);
return $hiddenemail;
}
static function createLog($users_id) {
global $loginControlCreateLog;
if (empty($users_id)) {
return false;
}
if (empty($loginControlCreateLog)) {
$ulh = new Users_login_history(0);
$ulh->setIp(getRealIpAddr());
$ulh->setStatus(self::is2FAConfirmed($users_id) ? Users_login_history_status::$CONFIRMED : Users_login_history_status::$WAITING_CONFIRMATION);
$ulh->setUniqidV4(getDeviceID());
$ulh->setUser_agent(@$_SERVER['HTTP_USER_AGENT']);
$ulh->setUsers_id($users_id);
$ulh->setConfirmation_code(self::getConfirmationCode($users_id, getDeviceID()));
$loginControlCreateLog = $ulh->save();
}
return $loginControlCreateLog;
}
static function getConfirmationCode($users_id, $uniqidV4) {
$row = Users_login_history::getLastLoginAttempt($users_id, $uniqidV4);
if (!empty($row) && ($row['status'] === Users_login_history_status::$CONFIRMED || strtotime($row['modified']) > strtotime("-2 hours"))) {
return $row['confirmation_code'];
}else if(empty($row)){
_error_log("LoginControl::getConfirmationCode first login attempt $users_id, $uniqidV4");
}else{
_error_log("LoginControl::getConfirmationCode confirmation code is expired $users_id, $uniqidV4");
}
return uniqid();
}
static function is2FAEnabled($users_id) {
$obj = AVideoPlugin::getObjectDataIfEnabled("LoginControl");
//check for 2fa
if ($obj->enable2FA) {
// check if the user confirmed this device before
return self::isUser2FAEnabled($users_id);
}
return false;
}
static function is2FAConfirmed($users_id) {
return !empty(Users_login_history::is2FAConfirmed($users_id, getDeviceID()));
}
static function getLastLoginOnDevice($users_id) {
$row = Users_login_history::getLastLoginAttempt($users_id, getDeviceID());
if (empty($row)) {
_error_log("LoginControl::getLastLoginOnDevice Not found $users_id, " . getDeviceID());
}
return $row;
}
static function send2FAEmail($users_id) {
global $config, $global;
$obj = AVideoPlugin::getObjectDataIfEnabled("LoginControl");
$u = new User($users_id);
$to = $u->getEmail();
if (empty($to)) {
_error_log("LoginControl::send2FAEmail the user {$users_id} does not have and email");
return false;
}
if (!filter_var($to, FILTER_VALIDATE_EMAIL)) {
_error_log("LoginControl::send2FAEmail the email {$to} for user {$users_id} is invalid");
setToastMessage(__("Your email is invalid"));
return false;
}
$user = $u->getNameIdentificationBd();
$siteName = $config->getWebSiteTitle();
$userIP = getRealIpAddr();
$userAgent = get_browser_name();
$confirmation = self::getConfirmationCodeHash($users_id);
if(empty($confirmation)){
_error_log("LoginControl::send2FAEmail error on generate confirmation code hash {$users_id}");
return false;
}
$confirmationLink = self::getConfirmationLink($confirmation);
$confirmationLinkATag = '< href="'.$confirmationLink.'">'.__("Here").'</a>';
$search = array('{user}', '{siteName}', '{userIP}', '{userAgent}', '{confirmationLink}');
$replace = array($user, $siteName, $userIP, $userAgent, $confirmationLinkATag);
$subject = str_replace($search, $replace, $obj->textFor2FASubject);
$message = str_replace($search, $replace, $obj->textFor2FABody->value);
$message = nl2br($message);
_error_log("LoginControl::send2FAEmail $subject - $message");
return true;
return sendSiteEmail($to, $subject, $message);
}
static private function getConfirmationCodeHash($users_id){
if(empty($users_id)){
return false;
}
$lastLogin = self::getLastLoginOnDevice($users_id);
if (empty($lastLogin)) {
if (self::createLog($users_id)) {
$lastLogin = self::getLastLoginOnDevice($users_id);
if (empty($lastLogin)) {
_error_log("LoginControl::getConfirmationCodeHash we could not find the last login for the user {$users_id}");
return false;
}
} else {
_error_log("LoginControl::getConfirmationCodeHash we could not create the login log for the user {$users_id}");
return false;
}
}
$confirmationCode = $lastLogin['confirmation_code'];
return encryptString(json_encode(array('confirmation_code' => $confirmationCode, 'users_id' => $users_id)));
}
static function validateConfirmationCodeHash($code){
if(empty($code)){
return false;
}
$decryptedCode = decryptString($code);
if(empty($decryptedCode)){
_error_log("LoginControl::validateConfirmationCodeHash we could not decrypt code {$code}");
return false;
}
$json = json_decode($decryptedCode);
if(empty($json)){
_error_log("LoginControl::validateConfirmationCodeHash we could not decrypt json {$json}");
return false;
}
return self::confirmCode($json->users_id, $json->confirmation_code);
}
public function getStart() {
$obj = $this->getDataObject();
if ($obj->singleDeviceLogin) {
// check if the user is logged somewhere else and log him off
if (!User::isAdmin() && !self::isLoggedFromSameDevice()) {
_error_log("LoginControl::getStart the user logged somewhere else");
$row = self::getLastConfirmedLogin(User::getId());
User::logoff();
if (!empty($row)) {
AVideoPlugin::loadPlugin('User_Location');
$location = IP2Location::getLocation($row['ip']);
$loc = "";
if (!empty($location)) {
$loc = "$location[country_name], $location[region_name], $location[city_name]";
}
if(!empty($row['created'])){
$msg = "You were disconected by ({$row['device']}) <br>IP: {$row['ip']} <br>{$loc} <br>{$row['ago']}";
setAlertMessage($msg);
}
}
}
}
}
static function getLastLogin($users_id) {
return Users_login_history::getLastLogin($users_id);
}
static function getPreviewsLogin($users_id) {
if(self::isUser2FAEnabled($users_id)){
return Users_login_history::getPreviewsConfirmedLogin($users_id);
}else{
return Users_login_history::getPreviewsLogin($users_id);
}
}
static function getLastConfirmedLogin($users_id) {
return Users_login_history::getLastConfirmedLogin($users_id);
}
static function isLoggedFromSameDevice() {
if (!User::isLogged()) {
return true;
}
return self::isSameDeviceAsLastLogin(User::getId(), getDeviceID());
}
static function isSameDeviceAsLastLogin($users_id, $uniqidV4) {
if(self::isUser2FAEnabled($users_id)){
$row = self::getLastConfirmedLogin($users_id);
}else{
$row = self::getLastLogin($users_id);
}
if (!empty($row) && $row['uniqidV4'] === $uniqidV4) {
return true;
}else if(empty($row)){
_error_log("LoginControl::isSameDeviceAsLastLogin that is the user first login at all {$users_id} ");
return true;
}
return false;
}
static function confirmCode($users_id, $code) {
$lastLogin = self::getLastLoginOnDevice($users_id);
if (empty($lastLogin)) {
return false;
}
$confirmationCode = $lastLogin['confirmation_code'];
if ($confirmationCode === $code) {
$ulh = new Users_login_history($lastLogin['id']);
$ulh->setStatus(Users_login_history_status::$CONFIRMED);
return $ulh->save();
} else {
_error_log("LoginControl::confirmCode the code does not match $users_id, sent: $code, expected: {$confirmationCode}");
return false;
}
}
public function getMyAccount($users_id) {
global $global;
$obj = AVideoPlugin::getObjectDataIfEnabled("LoginControl");
if (!empty($obj) && !empty($obj->enable2FA)) {
echo '<div class="form-group">
<label class="col-md-4 control-label">' . __("Enable 2FA Login") . '</label>
<div class="col-md-8 inputGroupContainer">';
include $global['systemRootPath'] . 'plugin/LoginControl/switchUser2FA.php';
echo '</div></div>';
}
}
static function isUser2FAEnabled($users_id) {
global $config;
$obj = AVideoPlugin::getObjectDataIfEnabled("LoginControl");
if (!empty($obj) && !empty($obj->enable2FA)) {
$user = new User($users_id);
return !empty($user->getExternalOption('2FAEnabled'));
}
return false;
}
static function setUser2FA($users_id, $value = true) {
$obj = AVideoPlugin::getObjectDataIfEnabled("LoginControl");
if (!empty($obj) && !empty($obj->enable2FA)) {
$user = new User($users_id);
return $user->addExternalOptions('2FAEnabled', $value);
}
return false;
}
static function getConfirmationLink($confirmation) {
global $global;
return "{$global['webSiteRootURL']}plugin/LoginControl/confirm.php?confirmation={$confirmation}";
}
public static function profileTabName($users_id) {
global $global;
include $global['systemRootPath'] . 'plugin/LoginControl/profileTabName.php';
}
public static function profileTabContent($users_id) {
global $global;
include $global['systemRootPath'] . 'plugin/LoginControl/profileTabContent.php';
}
}

View file

@ -0,0 +1,248 @@
<?php
require_once dirname(__FILE__) . '/../../../videos/configuration.php';
class Users_login_history extends ObjectYPT {
protected $id,$users_id,$uniqidV4,$ip,$user_agent,$confirmation_code,$status;
static function getSearchFieldsNames() {
return array('uniqidV4','ip','user_agent','confirmation_code');
}
static function getTableName() {
return 'users_login_history';
}
static function getAllUsers() {
global $global;
$table = "users";
$sql = "SELECT * FROM {$table} WHERE 1=1 ";
$sql .= self::getSqlFromPost();
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$rows = array();
if ($res != false) {
foreach ($fullData as $row) {
$rows[] = $row;
}
} else {
_error_log($sql . ' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
}
return $rows;
}
function setId($id) {
$this->id = intval($id);
}
function setUsers_id($users_id) {
$this->users_id = intval($users_id);
}
function setUniqidV4($uniqidV4) {
$this->uniqidV4 = $uniqidV4;
}
function setIp($ip) {
$this->ip = $ip;
}
function setUser_agent($user_agent) {
$this->user_agent = $user_agent;
}
function setConfirmation_code($confirmation_code) {
$this->confirmation_code = $confirmation_code;
}
function setStatus($status) {
$this->status = $status;
}
function getId() {
return intval($this->id);
}
function getUsers_id() {
return intval($this->users_id);
}
function getUniqidV4() {
return $this->uniqidV4;
}
function getIp() {
return $this->ip;
}
function getUser_agent() {
return $this->user_agent;
}
function getConfirmation_code() {
return $this->confirmation_code;
}
function getStatus() {
return $this->status;
}
static function getLastLogins($users_id, $limit=50){
global $global;
$table = "users";
$users_id = intval($users_id);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = {$users_id} ORDER BY modified DESC LIMIT {$limit} ";
$res = sqlDAL::readSql($sql);
$fullData = sqlDAL::fetchAllAssoc($res);
sqlDAL::close($res);
$rows = array();
if ($res != false) {
foreach ($fullData as $row) {
$row['device'] = self::getDeviceName($row['user_agent']);
$row['ago'] = humanTimingAgo($row['created']);
$row['time_ago'] = "{$row['created']} ({$row['ago']})";
$row['type'] = ($row['status']!==Users_login_history_status::$CONFIRMED)?__("Failed login attempt"):__("Successfully logged in");
$rows[] = $row;
}
} else {
_error_log($sql . ' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error);
}
return $rows;
}
static function getDeviceName($user_agent){
$device = get_browser_name($user_agent);
$device .= " - " . getOS($user_agent);
return $device;
}
static function getLastLogin($users_id){
global $global;
$users_id = intval($users_id);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = ? ORDER BY modified DESC LIMIT 1";
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
$res = sqlDAL::readSql($sql, "i", array($users_id), true);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
$row = $data;
$row['device'] = self::getDeviceName($row['user_agent']);
$row['ago'] = humanTimingAgo($row['created']);
$row['time_ago'] = "{$row['created']} ({$row['ago']})";
$row['type'] = ($row['status']!==Users_login_history_status::$CONFIRMED)?__("Failed login attempt"):__("Successfully logged in");
} else {
$row = false;
}
return $row;
}
static function getPreviewsLogin($users_id){
global $global;
$users_id = intval($users_id);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = ? ORDER BY modified DESC LIMIT 1, 1";
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
$res = sqlDAL::readSql($sql, "i", array($users_id), true);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
$row = $data;
if(!empty($row)){
$row['device'] = self::getDeviceName($row['user_agent']);
$row['ago'] = humanTimingAgo($row['created']);
$row['time_ago'] = "{$row['created']} ({$row['ago']})";
$row['type'] = ($row['status']!==Users_login_history_status::$CONFIRMED)?__("Failed login attempt"):__("Successfully logged in");
}
} else {
$row = false;
}
return $row;
}
static function getPreviewsConfirmedLogin($users_id){
global $global;
$users_id = intval($users_id);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = ? AND status = '".Users_login_history_status::$CONFIRMED."' ORDER BY modified DESC LIMIT 1, 1";
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
$res = sqlDAL::readSql($sql, "i", array($users_id), true);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
$row = $data;
if(!empty($row)){
$row['device'] = self::getDeviceName($row['user_agent']);
$row['ago'] = humanTimingAgo($row['created']);
$row['time_ago'] = "{$row['created']} ({$row['ago']})";
$row['type'] = ($row['status']!==Users_login_history_status::$CONFIRMED)?__("Failed login attempt"):__("Successfully logged in");
}
} else {
$row = false;
}
return $row;
}
static function getLastConfirmedLogin($users_id){
global $global;
$users_id = intval($users_id);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = ? AND status = '".Users_login_history_status::$CONFIRMED."' ORDER BY modified DESC LIMIT 1";
// I had to add this because the about from customize plugin was not loading on the about page http://127.0.0.1/AVideo/about
$res = sqlDAL::readSql($sql, "i", array($users_id), true);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
$row = $data;
if(!empty($row)){
$row['device'] = self::getDeviceName($row['user_agent']);
$row['ago'] = humanTimingAgo($row['created']);
$row['time_ago'] = "{$row['created']} ({$row['ago']})";
$row['type'] = ($row['status']!==Users_login_history_status::$CONFIRMED)?__("Failed login attempt"):__("Successfully logged in");
}
} else {
$row = false;
}
return $row;
}
static function is2FAConfirmed($users_id, $uniqidV4){
global $global;
$users_id = intval($users_id);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = ? AND uniqidV4 = ? AND status = '".Users_login_history_status::$CONFIRMED."' ORDER BY modified DESC 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, "is", array($users_id, $uniqidV4), true);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
$row = $data;
} else {
$row = false;
}
return $row;
}
static function getLastLoginAttempt($users_id, $uniqidV4){
global $global;
$users_id = intval($users_id);
$sql = "SELECT * FROM " . static::getTableName() . " WHERE users_id = ? AND uniqidV4 = ? ORDER BY modified DESC 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, "is", array($users_id, $uniqidV4), true);
$data = sqlDAL::fetchAssoc($res);
sqlDAL::close($res);
if ($res) {
$row = $data;
} else {
$row = false;
}
return $row;
}
}
class Users_login_history_status{
static $WAITING_CONFIRMATION = 'w';
static $CONFIRMED = 'c';
}

View file

@ -0,0 +1,29 @@
<?php
header('Content-Type: application/json');
require_once '../../../../videos/configuration.php';
require_once $global['systemRootPath'] . 'plugin/LoginControl/Objects/Users_login_history.php';
$obj = new stdClass();
$obj->error = true;
$obj->msg = "";
$plugin = AVideoPlugin::loadPluginIfEnabled('LoginControl');
if(!User::isAdmin()){
$obj->msg = "You cant do this";
die(json_encode($obj));
}
$o = new Users_login_history(@$_POST['id']);
$o->setUsers_id($_POST['users_id']);
$o->setUniqidV4($_POST['uniqidV4']);
$o->setIp($_POST['ip']);
$o->setUser_agent($_POST['user_agent']);
$o->setConfirmation_code($_POST['confirmation_code']);
$o->setStatus($_POST['status']);
if($id = $o->save()){
$obj->error = false;
}
echo json_encode($obj);

View file

@ -0,0 +1,20 @@
<?php
require_once '../../../../videos/configuration.php';
require_once $global['systemRootPath'] . 'plugin/LoginControl/Objects/Users_login_history.php';
header('Content-Type: application/json');
$obj = new stdClass();
$obj->error = true;
$plugin = AVideoPlugin::loadPluginIfEnabled('LoginControl');
if(!User::isAdmin()){
$obj->msg = "You cant do this";
die(json_encode($obj));
}
$id = intval($_POST['id']);
$row = new Users_login_history($id);
$obj->error = !$row->delete();
die(json_encode($obj));
?>

View file

@ -0,0 +1,29 @@
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../../videos/configuration.php';
}
if (!User::isAdmin()) {
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not do this"));
exit;
}
?>
<!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>">
<head>
<title><?php echo $config->getWebSiteTitle(); ?> :: LoginControl</title>
<?php
include $global['systemRootPath'] . 'view/include/head.php';
include $global['systemRootPath'] . 'plugin/LoginControl/View/{$classname}/index_head.php';
?>
</head>
<body class="<?php echo $global['bodyClass']; ?>">
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
include $global['systemRootPath'] . 'plugin/LoginControl/View/{$classname}/index_body.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,231 @@
<?php
global $global, $config;
if (!isset($global['systemRootPath'])) {
require_once '../../videos/configuration.php';
}
if (!User::isAdmin()) {
header("Location: {$global['webSiteRootURL']}?error=" . __("You can not do this"));
exit;
}
?>
<div class="panel panel-default">
<div class="panel-heading">
<i class="fas fa-cog"></i> <?php echo __("Configurations"); ?>
</div>
<div class="panel-body">
<div class="row">
<div class="col-sm-4">
<div class="panel panel-default ">
<div class="panel-heading"><i class="far fa-plus-square"></i> <?php echo __("Create"); ?></div>
<div class="panel-body">
<form id="panelUsers_login_historyForm">
<div class="row">
<input type="hidden" name="id" id="Users_login_historyid" value="" >
<div class="form-group col-sm-12">
<label for="Users_login_historyusers_id"><?php echo __("Users Id"); ?>:</label>
<select class="form-control input-sm" name="users_id" id="Users_login_historyusers_id">
<?php
$options = Users_login_history::getAllUsers();
foreach ($options as $value) {
echo '<option value="' . $value['id'] . '">' . $value['id'] . '</option>';
}
?>
</select>
</div>
<div class="form-group col-sm-12">
<label for="Users_login_historyuniqidV4"><?php echo __("UniqidV4"); ?>:</label>
<input type="text" id="Users_login_historyuniqidV4" name="uniqidV4" class="form-control input-sm" placeholder="<?php echo __("UniqidV4"); ?>" required="true">
</div>
<div class="form-group col-sm-12">
<label for="Users_login_historyip"><?php echo __("Ip"); ?>:</label>
<input type="text" id="Users_login_historyip" name="ip" class="form-control input-sm" placeholder="<?php echo __("Ip"); ?>" required="true">
</div>
<div class="form-group col-sm-12">
<label for="Users_login_historyuser_agent"><?php echo __("User Agent"); ?>:</label>
<input type="text" id="Users_login_historyuser_agent" name="user_agent" class="form-control input-sm" placeholder="<?php echo __("User Agent"); ?>" required="true">
</div>
<div class="form-group col-sm-12">
<label for="Users_login_historyconfirmation_code"><?php echo __("Confirmation Code"); ?>:</label>
<input type="text" id="Users_login_historyconfirmation_code" name="confirmation_code" class="form-control input-sm" placeholder="<?php echo __("Confirmation Code"); ?>" required="true">
</div>
<div class="form-group col-sm-12">
<label for="status"><?php echo __("Status"); ?>:</label>
<select class="form-control input-sm" name="status" id="Users_login_historystatus">
<option value="a"><?php echo __("Active"); ?></option>
<option value="i"><?php echo __("Inactive"); ?></option>
</select>
</div>
<div class="form-group col-sm-12">
<div class="btn-group pull-right">
<span class="btn btn-success" id="newUsers_login_historyLink" onclick="clearUsers_login_historyForm()"><i class="fas fa-plus"></i> <?php echo __("New"); ?></span>
<button class="btn btn-primary" type="submit"><i class="fas fa-save"></i> <?php echo __("Save"); ?></button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="col-sm-8">
<div class="panel panel-default ">
<div class="panel-heading"><i class="fas fa-edit"></i> <?php echo __("Edit"); ?></div>
<div class="panel-body">
<table id="Users_login_historyTable" class="display table table-bordered table-responsive table-striped table-hover table-condensed" width="100%" cellspacing="0">
<thead>
<tr>
<th>#</th>
<th><?php echo __("UniqidV4"); ?></th>
<th><?php echo __("Ip"); ?></th>
<th><?php echo __("User Agent"); ?></th>
<th><?php echo __("Confirmation Code"); ?></th>
<th><?php echo __("Status"); ?></th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th>#</th>
<th><?php echo __("UniqidV4"); ?></th>
<th><?php echo __("Ip"); ?></th>
<th><?php echo __("User Agent"); ?></th>
<th><?php echo __("Confirmation Code"); ?></th>
<th><?php echo __("Status"); ?></th>
<th></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="Users_login_historybtnModelLinks" style="display: none;">
<div class="btn-group pull-right">
<button href="" class="edit_Users_login_history btn btn-default btn-xs">
<i class="fa fa-edit"></i>
</button>
<button href="" class="delete_Users_login_history btn btn-danger btn-xs">
<i class="fa fa-trash"></i>
</button>
</div>
</div>
<script type="text/javascript">
function clearUsers_login_historyForm() {
$('#Users_login_historyid').val('');
$('#Users_login_historyusers_id').val('');
$('#Users_login_historyuniqidV4').val('');
$('#Users_login_historyip').val('');
$('#Users_login_historyuser_agent').val('');
$('#Users_login_historyconfirmation_code').val('');
$('#Users_login_historystatus').val('');
}
$(document).ready(function () {
$('#addUsers_login_historyBtn').click(function () {
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/LoginControl/View/addUsers_login_historyVideo.php',
data: $('#panelUsers_login_historyForm').serialize(),
type: 'post',
success: function (response) {
if (response.error) {
swal("<?php echo __("Sorry!"); ?>", response.msg, "error");
} else {
swal("<?php echo __("Congratulations!"); ?>", "<?php echo __("Your register has been saved!"); ?>", "success");
$("#panelUsers_login_historyForm").trigger("reset");
}
clearUsers_login_historyForm();
tableVideos.ajax.reload();
modal.hidePleaseWait();
}
});
});
var Users_login_historytableVar = $('#Users_login_historyTable').DataTable({
"ajax": "<?php echo $global['webSiteRootURL']; ?>plugin/LoginControl/View/Users_login_history/list.json.php",
"columns": [
{"data": "id"},
{"data": "uniqidV4"},
{"data": "ip"},
{"data": "user_agent"},
{"data": "confirmation_code"},
{"data": "status"},
{
sortable: false,
data: null,
defaultContent: $('#Users_login_historybtnModelLinks').html()
}
],
select: true,
});
$('#newUsers_login_history').on('click', function (e) {
e.preventDefault();
$('#panelUsers_login_historyForm').trigger("reset");
$('#Users_login_historyid').val('');
});
$('#panelUsers_login_historyForm').on('submit', function (e) {
e.preventDefault();
modal.showPleaseWait();
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/LoginControl/View/Users_login_history/add.json.php',
data: $('#panelUsers_login_historyForm').serialize(),
type: 'post',
success: function (response) {
if (response.error) {
swal("<?php echo __("Sorry!"); ?>", response.msg, "error");
} else {
swal("<?php echo __("Congratulations!"); ?>", "<?php echo __("Your register has been saved!"); ?>", "success");
$("#panelUsers_login_historyForm").trigger("reset");
}
Users_login_historytableVar.ajax.reload();
$('#Users_login_historyid').val('');
modal.hidePleaseWait();
}
});
});
$('#Users_login_historyTable').on('click', 'button.delete_Users_login_history', function (e) {
e.preventDefault();
var tr = $(this).closest('tr')[0];
var data = Users_login_historytableVar.row(tr).data();
swal({
title: "<?php echo __("Are you sure?"); ?>",
text: "<?php echo __("You will not be able to recover this action!"); ?>",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
modal.showPleaseWait();
$.ajax({
type: "POST",
url: "<?php echo $global['webSiteRootURL']; ?>plugin/LoginControl/View/Users_login_history/delete.json.php",
data: data
}).done(function (resposta) {
if (resposta.error) {
swal("<?php echo __("Sorry!"); ?>", resposta.msg, "error");
}
Users_login_historytableVar.ajax.reload();
modal.hidePleaseWait();
});
} else {
}
});
});
$('#Users_login_historyTable').on('click', 'button.edit_Users_login_history', function (e) {
e.preventDefault();
var tr = $(this).closest('tr')[0];
var data = Users_login_historytableVar.row(tr).data();
$('#Users_login_historyid').val(data.id);
$('#Users_login_historyusers_id').val(data.users_id);
$('#Users_login_historyuniqidV4').val(data.uniqidV4);
$('#Users_login_historyip').val(data.ip);
$('#Users_login_historyuser_agent').val(data.user_agent);
$('#Users_login_historyconfirmation_code').val(data.confirmation_code);
$('#Users_login_historystatus').val(data.status);
});
});
</script>

View file

@ -0,0 +1,5 @@
<?php
$plugin = AVideoPlugin::loadPluginIfEnabled('LoginControl');
?>
<link rel="stylesheet" type="text/css" href="<?php echo $global['webSiteRootURL']; ?>view/css/DataTables/datatables.min.css"/>
<link href="<?php echo $global['webSiteRootURL']; ?>view/js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css"/>

View file

@ -0,0 +1,10 @@
<?php
require_once '../../../../videos/configuration.php';
require_once $global['systemRootPath'] . 'plugin/LoginControl/Objects/Users_login_history.php';
header('Content-Type: application/json');
if(!User::isAdmin()){
die('{"data": []}');
}
$rows = Users_login_history::getAll();
?>
{"data": <?php echo json_encode($rows); ?>}

View file

@ -0,0 +1,46 @@
<?php
require_once '../../../videos/configuration.php';
AVideoPlugin::loadPlugin("LoginControl");
?>
<!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>">
<head>
<title><?php echo $config->getWebSiteTitle(); ?> :: LoginControl</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"/>
<link href="<?php echo $global['webSiteRootURL']; ?>view/js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css"/>
</head>
<body class="<?php echo $global['bodyClass']; ?>">
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
?>
<div class="container-fluid">
<div class="panel panel-default">
<div class="panel-heading"><?php echo __('LoginControl') ?>
<div class="pull-right">
<?php echo AVideoPlugin::getSwitchButton("LoginControl"); ?>
</div>
</div>
<div class="panel-body">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Users_login_history"><?php echo __("Users Login History"); ?></a></li>
</ul>
<div class="tab-content">
<div id="Users_login_history" class="tab-pane fade in active" style="padding: 10px;">
<?php
include $global['systemRootPath'] . 'plugin/LoginControl/View/Users_login_history/index_body.php';
?>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="<?php echo $global['webSiteRootURL']; ?>view/css/DataTables/datatables.min.js"></script>
<script src="<?php echo $global['webSiteRootURL']; ?>js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js" type="text/javascript"></script>
<?php
include $global['systemRootPath'] . 'view/include/footer.php';
?>
</body>
</html>

View file

@ -0,0 +1,30 @@
<?php
require_once '../../videos/configuration.php';
$obj = AVideoPlugin::getDataObjectIfEnabled("LoginControl");
if (empty($obj)) {
forbiddenPage("Plugin disabled");
}
if(!empty($_REQUEST['confirmation'])){
if(LoginControl::validateConfirmationCodeHash($_REQUEST['confirmation'])){
header("Location: {$global['webSiteRootURL']}user?msg=". urlencode(__("Your device is confirmed")));
exit;
}
}
if(empty($users_id)){
if(!User::isLogged()){
gotToLoginAndComeBackHere("");
}else{
$users_id = User::getId();
}
}
if(empty($_REQUEST['confirmation_code'])){
forbiddenPage("Confirmation code not found");
}
if(LoginControl::confirmCode($users_id, $_REQUEST['confirmation_code'])){
header("Location: {$global['webSiteRootURL']}user?msg=". urlencode(__("Your device is confirmed")));
}

View file

@ -0,0 +1,20 @@
CREATE TABLE IF NOT EXISTS `users_login_history` (
`id` INT NOT NULL AUTO_INCREMENT,
`users_id` INT NOT NULL,
`uniqidV4` VARCHAR(45) NOT NULL,
`ip` VARCHAR(45) NULL,
`user_agent` VARCHAR(255) NULL,
`confirmation_code` VARCHAR(45) NULL,
`status` CHAR(1) NULL,
`created` DATETIME NULL,
`modified` DATETIME NULL,
PRIMARY KEY (`id`),
INDEX `fk_login_history_users_idx` (`users_id` ASC),
INDEX `uniqueidv4_index` USING BTREE (`uniqidV4`),
INDEX `sort_created_index` (`created` ASC),
CONSTRAINT `fk_login_history_users`
FOREIGN KEY (`users_id`)
REFERENCES `users` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;

View file

@ -0,0 +1,16 @@
<?php
require_once '../../videos/configuration.php';
require_once $global['systemRootPath'] . 'plugin/LoginControl/Objects/Users_login_history.php';
header('Content-Type: application/json');
if(!User::isAdmin() || empty($_REQUEST['users_id'])){
$_REQUEST['users_id'] = User::getId();
}else if(!empty ($_REQUEST['users_id'])){
$_REQUEST['users_id'] = intval($_REQUEST['users_id']);
}
if(empty($_REQUEST['users_id'])){
die('{"data": []}');
}
$rows = Users_login_history::getLastLogins($_REQUEST['users_id'], 100);
?>
{"data": <?php echo json_encode($rows); ?>}

Binary file not shown.

Binary file not shown.

View file

@ -4,36 +4,47 @@ $obj = AVideoPlugin::getObjectDataIfEnabled('AD_Overlay');
$ad = new AD_Overlay_Code(0);
$ad->loadFromUser(User::getId());
?>
<div id="adOverlay" class="tab-pane fade" style="padding: 10px 0;">
<link rel="stylesheet" type="text/css" href="<?php echo $global['webSiteRootURL']; ?>view/css/DataTables/datatables.min.css"/>
<div id="loginHistory" class="tab-pane fade" style="padding: 10px 0;">
<div class="panel panel-default">
<div class="panel-heading">
AD Code
<?php echo __("Login History"); ?>
</div>
<div class="panel-body">
<textarea class="form-control" rows="10" id="addOverlayCode"><?php echo $ad->getCode(); ?></textarea>
<button class="btn btn-success btn-block" type="button" onclick="saveCode()"><?php echo __("Save Ad Code") ?></button>
<table id="Users_login_historyTable" class="display table table-bordered table-responsive table-striped table-hover table-condensed" width="100%" cellspacing="0">
<thead>
<tr>
<th><?php echo __("When"); ?></th>
<th><?php echo __("IP"); ?></th>
<th><?php echo __("Device"); ?></th>
<th><?php echo __("Type"); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th><?php echo __("When"); ?></th>
<th><?php echo __("IP"); ?></th>
<th><?php echo __("Device"); ?></th>
<th><?php echo __("Type"); ?></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<script type="text/javascript" src="<?php echo $global['webSiteRootURL']; ?>view/css/DataTables/datatables.min.js"></script>
<script>
function saveCode() {
$.ajax({
url: '<?php echo $global['webSiteRootURL']; ?>plugin/AD_Overlay/saveCode.json.php',
data: {
"addOverlayCode": $('#addOverlayCode').val()
},
type: 'post',
success: function (response) {
if (response.error) {
avideoAlert("<?php echo __("Sorry!"); ?>", response.error, "error");
} else {
avideoAlert("<?php echo __("Congratulations!"); ?>", "<?php echo __("Your code has been saved!"); ?>", "success");
}
modal.hidePleaseWait();
}
});
}
$(document).ready(function () {
var Users_login_historytableVar = $('#Users_login_historyTable').DataTable({
"ajax": "<?php echo $global['webSiteRootURL']; ?>plugin/LoginControl/listLastLogins.json.php",
"columns": [
{"data": "time_ago"},
{"data": "ip"},
{"data": "device"},
{"data": "type"},
],
"order": [],
select: true,
});
});
</script>

View file

@ -1,22 +1,5 @@
<?php
$obj = AVideoPlugin::getObjectDataIfEnabled('AD_Overlay');
$ad = new AD_Overlay_Code(0);
$ad->loadFromUser(User::getId());
?>
<li>
<a data-toggle="tab" href="#adOverlay" id="aPersonalInfo">
<?php echo __("Ad Overlay") ?>
<?php
if (!empty($ad->getStatus()) && $ad->getStatus() == 'a') {
?>
<span class="label label-success adsStatus">Ads Active</span>
<?php
} else {
?>
<span class="label label-danger adsStatus">Ads Inacitive</span>
<?php
}
?>
<a data-toggle="tab" href="#loginHistory" id="aloginControl">
<?php echo __("Login History") ?>
</a>
</li>

View file

@ -18,7 +18,7 @@ if(!isset($_POST['value'])){
die(json_encode($obj));
}
$cu = AVideoPlugin::loadPluginIfEnabled('CustomizeUser');
$cu = AVideoPlugin::loadPluginIfEnabled('LoginControl');
if(empty($cu)){
$obj->msg = "Plugin not enabled";
@ -27,11 +27,8 @@ if(empty($cu)){
$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);
case 'set2FA':
LoginControl::setUser2FA(User::getId(), $_POST['value']=="true"?true:false);
break;
}

View file

@ -2,7 +2,7 @@
$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" : ""; ?>>
<input class="playerSwitchDefault" data-toggle="toggle" type="checkbox" value="" id="switch<?php echo $uid; ?>" <?php echo (LoginControl::is2FAEnabled($users_id)) ? "checked" : ""; ?>>
<label for="switch<?php echo $uid; ?>" class="label-primary"></label>
</div>
<script>
@ -10,8 +10,8 @@ $uid = uniqid();
$('#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")},
url: '<?php echo $global['webSiteRootURL']; ?>plugin/LoginControl/set.json.php',
data: {"type": "set2FA", "value": $('#switch<?php echo $uid; ?>').is(":checked")},
type: 'post',
success: function (response) {
modal.hidePleaseWait();

View file

@ -7,6 +7,7 @@ class LoginFacebook extends PluginAbstract {
public function getTags() {
return array(
PluginTags::$FREE,
PluginTags::$LOGIN,
);
}
public function getDescription() {

View file

@ -164,6 +164,9 @@ abstract class PluginAbstract {
public function setDataObject($object) {
$pluginRow = Plugin::getPluginByUUID($this->getUUID());
if(empty($pluginRow)){
return false;
}
$obj = new Plugin($pluginRow['id']);
$obj->setObject_data(addcslashes(json_encode($object), '\\'));
return $obj->save();

View file

@ -24,7 +24,7 @@ class SeekButton extends PluginAbstract {
}
public function getPluginVersion() {
return "1.0";
return "1.1";
}
public function getEmptyDataObject() {

View file

@ -1,3 +1,5 @@
-- Add Meet Support
UPDATE configurations SET version = '9.5', modified = now() WHERE id = 1;
-- Add Login control
-- Fix some layout issues
-- support for encoder 3.3 and dynamic resolutions for MP4 and webm
UPDATE configurations SET version = '9.6', modified = now() WHERE id = 1;

View file

@ -795,9 +795,32 @@ img.blur{
}
.btn-group.justified {
display: flex;
display: flex;
}
.justified .btn {
flex: 1
flex: 1
}
.addWidthOnMenuOpen {
transition: width 0.3s;
}
@media (min-width: 1200px){
body.youtube .lessMarginLeftOnMenuOpen{
margin-left: -200px;
}
body.youtube .col-lg-4.addWidthOnMenuOpen {
margin-left: -150px;
width: calc(33.3333333333% + 300px);
}
body.youtube .col-lg-10.addWidthOnMenuOpen {
width: 100%;
}
body.youtube .col-lg-offset-1.addWidthOnMenuOpen {
margin-left: 0px;
}
}

77
view/iframe.php Normal file
View file

@ -0,0 +1,77 @@
<?php
global $global, $config;
if(!isset($global['systemRootPath'])){
require_once '../videos/configuration.php';
}
if(empty($_GET['type'])){
forbiddenPage("Wrong Type");
}
if(!User::isLogged()){
gotToLoginAndComeBackHere(__("Please login first"));
}
$iframeURL = "";
switch ($_GET['type']){
case "upload":
if ((isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && $advancedCustomUser->onlyVerifiedEmailCanUpload && User::isVerified()) || (isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && !$advancedCustomUser->onlyVerifiedEmailCanUpload) || !isset($advancedCustomUser->onlyVerifiedEmailCanUpload)) {
if (!empty($config->getEncoderURL())) {
$iframeURL = $config->getEncoderURL()."?noNavbar=1&".getCredentialsURL();
}else{
if(empty($iframeURL)){
forbiddenPage("Your encoder is empty");
}
}
}else{
if(empty($iframeURL)){
forbiddenPage("You cannot upload 1");
}
}
break;
case "network":
if ((isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && $advancedCustomUser->onlyVerifiedEmailCanUpload && User::isVerified()) || (isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && !$advancedCustomUser->onlyVerifiedEmailCanUpload) || !isset($advancedCustomUser->onlyVerifiedEmailCanUpload)) {
if (!empty($advancedCustom->encoderNetwork) && empty($advancedCustom->doNotShowEncoderNetwork)) {
$iframeURL = $advancedCustom->encoderNetwork."?".getCredentialsURL();
}else{
if(empty($iframeURL)){
forbiddenPage("Network is disabled");
}
}
}else{
if(empty($iframeURL)){
forbiddenPage("You cannot upload 1");
}
}
break;
}
if(empty($iframeURL)){
forbiddenPage("Invalid Type {$_GET['type']}");
}
?>
<!DOCTYPE html>
<html lang="<?php echo $config->getLanguage(); ?>">
<head>
<title><?php echo $config->getWebSiteTitle(); ?></title>
<?php
include $global['systemRootPath'] . 'view/include/head.php';
?>
</head>
<body class="<?php echo $global['bodyClass']; ?>">
<?php
include $global['systemRootPath'] . 'view/include/navbar.php';
?>
<iframe src="<?php echo $iframeURL; ?>" style="width: 100%; height: calc( 100vh - 50px );">
</iframe>
<?php
include $global['systemRootPath'] . 'view/include/footer.php';
?>
</body>
</html>

View file

@ -27,28 +27,7 @@
<script>
$(function () {
<?php
if (!empty($_GET['error'])) {
?>
avideoAlert("<?php echo __("Sorry!"); ?>", "<?php echo $_GET['error']; ?>", "error");
window.history.pushState({}, document.title, '<?php echo getSelfURI(); ?>');
<?php
}
?>
<?php
if (!empty($_GET['msg'])) {
?>
avideoAlert("<?php echo __("Ops!"); ?>", "<?php echo $_GET['msg']; ?>", "info");
window.history.pushState({}, document.title, '<?php echo getSelfURI(); ?>');
<?php
}
?>
<?php
if (!empty($_GET['success']) && strlen($_GET['success']) > 4) {
?>
avideoAlert("<?php echo __("Congratulations!"); ?>", "<?php echo $_GET['success']; ?>", "info");
window.history.pushState({}, document.title, '<?php echo getSelfURI(); ?>');
<?php
}
showAlertMessage();
?>
});
</script>

View file

@ -17,7 +17,7 @@ if (isIframe() && !empty($_SESSION['noNavbar'])) {
$_SESSION['noNavbarClose'] = 0;
}
}
if(empty($_SESSION['noNavbarClose'])){
if (empty($_SESSION['noNavbarClose'])) {
//$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$actual_link = basename($_SERVER['PHP_SELF']);
$params = $_GET;
@ -27,7 +27,7 @@ if (isIframe() && !empty($_SESSION['noNavbar'])) {
?>
<a href="<?php echo $actual_link, "?", $new_query_string; ?>" class="btn btn-default" style="position: absolute; right: 10px; top: 5px;"><i class="fas fa-bars"></i></a>
<?php
}else{
} else {
echo '<style>body{padding-top:0;}</style>';
}
echo '<nav class="hidden" id="mainNavBar" style="display:none;"></nav>';
@ -402,53 +402,15 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
<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>
<?php
if ((isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && $advancedCustomUser->onlyVerifiedEmailCanUpload && User::isVerified()) || (isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && !$advancedCustomUser->onlyVerifiedEmailCanUpload) || !isset($advancedCustomUser->onlyVerifiedEmailCanUpload)
) {
if ((isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && $advancedCustomUser->onlyVerifiedEmailCanUpload && User::isVerified()) || (isset($advancedCustomUser->onlyVerifiedEmailCanUpload) && !$advancedCustomUser->onlyVerifiedEmailCanUpload) || !isset($advancedCustomUser->onlyVerifiedEmailCanUpload)) {
?>
<ul class="dropdown-menu dropdown-menu-right" role="menu" style="">
<?php
if (!empty($advancedCustom->encoderNetwork) && empty($advancedCustom->doNotShowEncoderNetwork)) {
?>
<li>
<form id="formEncoderN" method="post" action="<?php echo $advancedCustom->encoderNetwork; ?>" target="encoder" autocomplete="off">
<input type="hidden" name="webSiteRootURL" value="<?php echo $global['webSiteRootURL']; ?>" autocomplete="off" />
<input type="hidden" name="user" value="<?php echo User::getUserName(); ?>" autocomplete="off" />
<input type="hidden" name="pass" value="<?php echo User::getUserPass(); ?>" autocomplete="off" />
</form>
<a href="#" onclick="$('#formEncoderN').submit();
return false;">
<span class="fa fa-cogs"></span> <?php echo empty($advancedCustom->encoderNetworkLabel) ? __("Encoder Network") : $advancedCustom->encoderNetworkLabel; ?>
</a>
</li>
<?php
}
if (empty($advancedCustom->doNotShowEncoderButton)) {
if (!empty($config->getEncoderURL())) {
?>
<li>
<form id="formEncoder" method="post" action="<?php echo $config->getEncoderURL(); ?>" target="encoder" autocomplete="off" >
<input type="hidden" name="webSiteRootURL" value="<?php echo $global['webSiteRootURL']; ?>" autocomplete="off" />
<input type="hidden" name="user" value="<?php echo User::getUserName(); ?>" autocomplete="off" />
<input type="hidden" name="pass" value="<?php echo User::getUserPass(); ?>" autocomplete="off" />
</form>
<a href="#" onclick="$('#formEncoder').submit();
return false;">
<span class="fa fa-cog"></span> <?php echo empty($advancedCustom->encoderButtonLabel) ? __("Encode video and audio") : $advancedCustom->encoderButtonLabel; ?>
</a>
</li>
<?php
} else {
?>
<li>
<a href="<?php echo $global['webSiteRootURL']; ?>siteConfigurations" ><span class="fa fa-cogs"></span> <?php echo __("Configure an Encoder URL"); ?></a>
</li>
<?php
}
}
include $global['systemRootPath'] . 'view/include/navbarEncoder.php';
if (empty($advancedCustom->doNotShowUploadMP4Button)) {
?>
<li>
<a href="<?php echo $global['webSiteRootURL']; ?>mvideos?upload=1" >
<a href="<?php echo $global['webSiteRootURL']; ?>mvideos?upload=1" data-toggle="tooltip" title="<?php echo __("Upload files without encode"); ?>" data-placement="left" >
<span class="fa fa-upload"></span> <?php echo empty($advancedCustom->uploadMP4ButtonLabel) ? __("Direct upload") : $advancedCustom->uploadMP4ButtonLabel; ?>
</a>
</li>
@ -457,7 +419,7 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
if (empty($advancedCustom->doNotShowImportMP4Button)) {
?>
<li>
<a href="<?php echo $global['webSiteRootURL']; ?>view/import.php" >
<a href="<?php echo $global['webSiteRootURL']; ?>view/import.php" data-toggle="tooltip" title="<?php echo __("Search for videos in your local disk"); ?>" data-placement="left" >
<span class="fas fa-hdd"></span> <?php echo empty($advancedCustom->importMP4ButtonLabel) ? __("Direct Import Local Videos") : $advancedCustom->importMP4ButtonLabel; ?>
</a>
</li>
@ -466,7 +428,7 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
if (empty($advancedCustom->doNotShowEmbedButton)) {
?>
<li>
<a href="<?php echo $global['webSiteRootURL']; ?>mvideos?link=1" >
<a href="<?php echo $global['webSiteRootURL']; ?>mvideos?link=1" data-toggle="tooltip" title="<?php echo __("Embed videos/files in your site"); ?>" data-placement="left" >
<span class="fa fa-link"></span> <?php echo empty($advancedCustom->embedButtonLabel) ? __("Embed a video link") : $advancedCustom->embedButtonLabel; ?>
</a>
</li>
@ -475,7 +437,7 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
if (AVideoPlugin::isEnabledByName("Articles")) {
?>
<li>
<a href="<?php echo $global['webSiteRootURL']; ?>mvideos?article=1" >
<a href="<?php echo $global['webSiteRootURL']; ?>mvideos?article=1" data-toggle="tooltip" title="<?php echo __("Write an article"); ?>" data-placement="left" >
<i class="far fa-newspaper"></i> <?php echo __("Add Article"); ?>
</a>
</li>
@ -483,7 +445,7 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
}
echo AVideoPlugin::getUploadMenuButton();
?>
</ul>
</ul>
<?php
} else {
?>
@ -493,6 +455,9 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
<span class="fa fa-exclamation"></span> <?php echo __("Only verified users can upload"); ?>
</a>
</li>
<?php
echo AVideoPlugin::getUploadMenuButton();
?>
</ul>
<?php
@ -502,6 +467,28 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
</li>
<?php
} else {
$output = ob_get_clean();
echo AVideoPlugin::getUploadMenuButton();
$getUploadMenuButton = ob_get_clean();
if (!empty($getUploadMenuButton)) {
?>
<li>
<div class="btn-group" data-toggle="tooltip" title="<?php echo __("Submit your videos"); ?>" data-placement="left" >
<button type="button" class="btn btn-default dropdown-toggle navbar-btn pull-left" data-toggle="dropdown">
<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>
<ul class="dropdown-menu dropdown-menu-right" role="menu" style="">
<?php
echo $getUploadMenuButton;
?>
</ul>
</div>
</li>
<?php
}
ob_start();
echo $output;
}
?>
<li>
@ -592,8 +579,8 @@ if (!User::isLogged() && !empty($advancedCustomUser->userMustBeLoggedIn) && !emp
$tooltip = "";
if (User::isLogged()) {
$tooltip = 'data-toggle="tooltip" data-html="true" title="' . User::getName() . ":: " . User::getMail() . '" data-placement="left"';
}else{
$tooltip = 'data-toggle="tooltip" data-html="true" title="' .__("Login") . '" data-placement="left"';
} else {
$tooltip = 'data-toggle="tooltip" data-html="true" title="' . __("Login") . '" data-placement="left"';
}
?>
<li class="rightProfile" <?php echo $tooltip; ?> >

View file

@ -0,0 +1,70 @@
<?php
if (empty($advancedCustom->openEncoderInIFrame)) {
if (!empty($advancedCustom->encoderNetwork) && empty($advancedCustom->doNotShowEncoderNetwork)) {
?>
<li>
<form id="formEncoderN" method="post" action="<?php echo $advancedCustom->encoderNetwork; ?>" target="encoder" autocomplete="off">
<input type="hidden" name="webSiteRootURL" value="<?php echo $global['webSiteRootURL']; ?>" autocomplete="off" />
<input type="hidden" name="user" value="<?php echo User::getUserName(); ?>" autocomplete="off" />
<input type="hidden" name="pass" value="<?php echo User::getUserPass(); ?>" autocomplete="off" />
</form>
<a href="#" onclick="$('#formEncoderN').submit();
return false;" data-toggle="tooltip" title="<?php echo __("Choose one of our encoders to upload a file or download it from the Internet"); ?>" data-placement="left" >
<span class="fa fa-cogs"></span> <?php echo empty($advancedCustom->encoderNetworkLabel) ? __("Encoder Network") : $advancedCustom->encoderNetworkLabel; ?>
</a>
</li>
<?php
}
if (empty($advancedCustom->doNotShowEncoderButton)) {
if (!empty($config->getEncoderURL())) {
?>
<li>
<form id="formEncoder" method="post" action="<?php echo $config->getEncoderURL(); ?>" target="encoder" autocomplete="off" >
<input type="hidden" name="webSiteRootURL" value="<?php echo $global['webSiteRootURL']; ?>" autocomplete="off" />
<input type="hidden" name="user" value="<?php echo User::getUserName(); ?>" autocomplete="off" />
<input type="hidden" name="pass" value="<?php echo User::getUserPass(); ?>" autocomplete="off" />
</form>
<a href="#" onclick="$('#formEncoder').submit();
return false;" data-toggle="tooltip" title="<?php echo __("Upload a file or download it from the Internet"); ?>" data-placement="left" >
<span class="fa fa-cog"></span> <?php echo empty($advancedCustom->encoderButtonLabel) ? __("Encode video and audio") : $advancedCustom->encoderButtonLabel; ?>
</a>
</li>
<?php
} else {
?>
<li>
<a href="<?php echo $global['webSiteRootURL']; ?>siteConfigurations" ><span class="fa fa-cogs"></span> <?php echo __("Configure an Encoder URL"); ?></a>
</li>
<?php
}
}
}else{
if (!empty($advancedCustom->encoderNetwork) && empty($advancedCustom->doNotShowEncoderNetwork)) {
?>
<li>
<a href="<?php echo $global['webSiteRootURL']; ?>i/network" data-toggle="tooltip" title="<?php echo __("Choose one of our encoders to upload a file or download it from the Internet"); ?>" data-placement="left" >
<span class="fa fa-cogs"></span> <?php echo empty($advancedCustom->encoderNetworkLabel) ? __("Encoder Network") : $advancedCustom->encoderNetworkLabel; ?>
</a>
</li>
<?php
}
if (empty($advancedCustom->doNotShowEncoderButton)) {
if (!empty($config->getEncoderURL())) {
?>
<li>
<a href="<?php echo $global['webSiteRootURL']; ?>i/upload" data-toggle="tooltip" title="<?php echo __("Upload a file or download it from the Internet"); ?>" data-placement="left" >
<span class="fa fa-cog"></span> <?php echo empty($advancedCustom->encoderButtonLabel) ? __("Encode video and audio") : $advancedCustom->encoderButtonLabel; ?>
</a>
</li>
<?php
} else {
?>
<li>
<a href="<?php echo $global['webSiteRootURL']; ?>siteConfigurations"><span class="fa fa-cogs"></span> <?php echo __("Configure an Encoder URL"); ?></a>
</li>
<?php
}
}
}
?>

View file

@ -70,7 +70,7 @@ if (!empty($videoSerie)) {
<?php
if ($value['type'] !== 'pdf' && $value['type'] !== 'article' && $value['type'] !== 'serie') {
?>
<span class="duration"><?php echo Video::getCleanDuration($value['duration']); ?></span>
<time class="duration"><?php echo Video::getCleanDuration($value['duration']); ?></time>
<div class="progress" style="height: 3px; margin-bottom: 2px;">
<div class="progress-bar progress-bar-danger" role="progressbar" style="width: <?php echo $value['progress']['percent'] ?>%;" aria-valuenow="<?php echo $value['progress']['percent'] ?>" aria-valuemin="0" aria-valuemax="100"></div>
</div>

View file

@ -711,6 +711,7 @@ if (empty($advancedCustom->disableHTMLDescription)) {
var videoUploaded = false;
var videos_id = <?php echo intval(@$_GET['video_id']); ?>;
var isArticle = 0;
var checkProgressTimeout = [];
function saveVideoOnPlaylist(videos_id, add, playlists_id) {
modal.showPleaseWait();
$.ajax({
@ -795,9 +796,9 @@ if (empty($advancedCustomUser->userCanNotChangeUserGroup) || User::isAdmin()) {
<?php
}
?>
function checkProgress() {
function checkProgress(encoderURL) {
$.ajax({
url: '<?php echo $config->getEncoderURL(); ?>status',
url: encoderURL+'status',
success: function (response) {
if (response.queue_list.length) {
for (i = 0; i < response.queue_list.length; i++) {
@ -831,6 +832,7 @@ if (empty($advancedCustomUser->userCanNotChangeUserGroup) || User::isAdmin()) {
if (response.encoding_status.progress >= 100) {
$("#encodingProgress" + id).find('.progress-bar').css({'width': '100%'});
clearTimeout(timeOut);
$.toast("Encode Complete");
timeOut = setTimeout(function () {
$("#grid").bootgrid('reload');
}, 5000);
@ -839,20 +841,20 @@ if (empty($advancedCustomUser->userCanNotChangeUserGroup) || User::isAdmin()) {
}
setTimeout(function () {
checkProgress();
}, 3000);
checkProgress(encoderURL);
}, 10000);
} else if (encodingNowId !== "") {
$("#encodeProgress" + encodingNowId).slideUp("normal", function () {
$(this).remove();
});
encodingNowId = "";
setTimeout(function () {
checkProgress();
}, 10000);
checkProgress(encoderURL);
}, 20000);
} else {
setTimeout(function () {
checkProgress();
}, 10000);
checkProgress(encoderURL);
}, 20000);
}
}
@ -1340,10 +1342,10 @@ echo AVideoPlugin::getManagerVideosReset();
if ($('#encodeProgress' + id).children().length) {
return false;
}
var item = '<div class="progress progress-striped active " id="encodingProgress' + queueItem.id + '" style="margin: 0;">';
item += '<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0;"><span >0% Complete</span></div>';
var item = '<div class="progress progress-striped active " id="encodingProgress' + queueItem.id + '" style="margin: 0;border-bottom-right-radius: 0; border-bottom-left-radius: 0;">';
item += '<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0; animation-duration: 15s;animation: 15s;transition-duration: 15s; "><span >0% Complete</span></div>';
item += '<span class="progress-type"><span class="badge "><?php echo __("Queue Position"); ?> ' + position + '</span></span><span class="progress-completed">' + queueItem.name + '</span>';
item += '</div><div class="progress progress-striped active " id="downloadProgress' + queueItem.id + '" style="height: 10px;"><div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0;"></div></div> ';
item += '</div><div class="progress progress-striped active " id="downloadProgress' + queueItem.id + '" style="height: 10px; border-top-right-radius: 0; border-top-left-radius: 0;"><div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0;"></div></div> ';
$('#encodeProgress' + id).html(item);
}
@ -1789,7 +1791,13 @@ if (User::isAdmin()) {
tags += "<span class='label label-primary fix-width'><?php echo __("Format") . ":"; ?> </span>" + row.typeLabels;
if (row.encoderURL) {
tags += "<br><span class='label label-primary fix-width'><?php echo __("Encoder") . ":"; ?> </span><span class=\"label label-default fix-width\">" + row.encoderURL + "</span><br>";
clearTimeout(checkProgressTimeout[row.encoderURL]);
checkProgressTimeout[row.encoderURL] = setTimeout(function(){
checkProgress(row.encoderURL);
},1000);
}
return tags;
},
"filesize": function (column, row) {
@ -1824,7 +1832,7 @@ if (User::isAdmin()) {
} else if (row.status == 'd') {
tags += '<div class="progress progress-striped active" style="margin:5px;"><div id="downloadProgress' + row.id + '" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0px"></div></div>';
tags += '<div class="progress progress-striped active" style="margin:5px;"><div id="downloadProgress' + row.id + '" class="progress-bar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0px;"></div></div>';
}
var type, img, is_portrait;
if (row.type === "audio") {
@ -1864,7 +1872,7 @@ if (AVideoPlugin::isEnabledByName('PlayLists')) {
?>
var pluginsButtons = '<br><?php echo AVideoPlugin::getVideosManagerListButtonTitle(); ?>';
return img + '<a href="<?php echo $global['webSiteRootURL']; ?>video/' + row.id + '/' + row.clean_title + '" class="btn btn-default btn-xs">' + type + row.title + "</a>" + tags + "" + yt + pluginsButtons + playList;
return img + '<div class="clearfix hidden-md hidden-lg"></div><a href="<?php echo $global['webSiteRootURL']; ?>video/' + row.id + '/' + row.clean_title + '" class="btn btn-default btn-xs">' + type + row.title + "</a>" + tags + "" + yt + pluginsButtons + playList;
}
@ -2051,9 +2059,6 @@ if (User::isAdmin()) {
<?php
}
?>
setTimeout(function () {
checkProgress()
}, 500);
});
$('#inputCleanTitle').keyup(function (evt) {
$('#inputCleanTitle').val(clean_name($('#inputCleanTitle').val()));

View file

@ -46,7 +46,7 @@ if (empty($_COOKIE) && get_browser_name()!=='Other (Unknown)') {
?>
<div class="row">
<div class="hidden-xs col-sm-2 col-md-3 col-lg-4"></div>
<div class="col-xs-12 col-sm-8 col-md-6 col-lg-4 list-group-item ">
<div class="col-xs-12 col-sm-8 col-md-6 col-lg-4 list-group-item addWidthOnMenuOpen">
<fieldset>
<legend class=" hidden-xs">
<?php