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

Improving Sockets

This commit is contained in:
DanielnetoDotCom 2021-01-23 00:56:34 -03:00
parent a16246f93d
commit b12e5c300e
17 changed files with 107 additions and 40 deletions

View file

@ -173,7 +173,9 @@ switch ($_GET['page']) {
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?php echo $config->getLanguage(); ?>"> <html lang="<?php echo $config->getLanguage(); ?>">
<head> <head>
<title><?php echo __("Administration") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title> <?php
echo getHTMLTitle(__("Administration"));
?>
<?php <?php
include $global['systemRootPath'] . 'view/include/head.php'; include $global['systemRootPath'] . 'view/include/head.php';
if (!empty($includeHead) && file_exists($includeHead)) { if (!empty($includeHead) && file_exists($includeHead)) {

View file

@ -48,7 +48,9 @@ sort($vars);
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?php echo $config->getLanguage(); ?>"> <html lang="<?php echo $config->getLanguage(); ?>">
<head> <head>
<title><?php __("Translate AVideo") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title> <?php
echo getHTMLTitle(__("Translate AVideo"));
?>
<?php <?php
include $global['systemRootPath'] . 'view/include/head.php'; include $global['systemRootPath'] . 'view/include/head.php';

View file

@ -5667,3 +5667,33 @@ function getLiveUsersLabel($viewsClass = "label label-default", $counterClass =
} }
return ""; return "";
} }
function getHTMLTitle($titleArray){
global $config, $global;
if(!is_array($titleArray)){
$titleArray = array();
}
$titleArray[] = $config->getWebSiteTitle();
$title = implode($config->getPageTitleSeparator(), $titleArray);
$global['pageTitle'] = $title;
return "<title>{$title}</title>";
}
function getTitle(){
global $global;
if(empty($global['pageTitle'])){
$url = getSelfURI();
$global['pageTitle'] = str_replace($global['webSiteRootURL'], '', $url);
if(preg_match('/\/plugin\/([^\/])/i', $url, $matches)){
$global['pageTitle'] = __('Plugin').' '.__($matches[1]);
}
$title = $global['pageTitle'];
}
return $global['pageTitle'];
}

View file

@ -55,14 +55,14 @@ if (!(!empty($_GET['user']) && !empty($_GET['recoverpass']))) {
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>"> <html lang="<?php echo $_SESSION['language']; ?>">
<head> <head>
<title><?php echo __("Recover Password") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title>
<?php <?php
include $global['systemRootPath'] . 'view/include/head.php'; ?> echo getHTMLTitle(__("Recover Password"));
?>
<?php include $global['systemRootPath'] . 'view/include/head.php'; ?>
</head> </head>
<body class="<?php echo $global['bodyClass']; ?>"> <body class="<?php echo $global['bodyClass']; ?>">
<?php <?php include $global['systemRootPath'] . 'view/include/navbar.php'; ?>
include $global['systemRootPath'] . 'view/include/navbar.php'; ?>
<div class="container"> <div class="container">
<?php <?php
@ -100,16 +100,14 @@ if (!(!empty($_GET['user']) && !empty($_GET['recoverpass']))) {
<div class="form-group"> <div class="form-group">
<label class="col-md-4 control-label"><?php echo __("New Password"); ?></label> <label class="col-md-4 control-label"><?php echo __("New Password"); ?></label>
<div class="col-md-8 inputGroupContainer"> <div class="col-md-8 inputGroupContainer">
<?php <?php getInputPassword("newPassword", 'class="form-control" required="required" autocomplete="off"', __("New Password")); ?>
getInputPassword("newPassword", 'class="form-control" required="required" autocomplete="off"', __("New Password")); ?>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-md-4 control-label"><?php echo __("Confirm New Password"); ?></label> <label class="col-md-4 control-label"><?php echo __("Confirm New Password"); ?></label>
<div class="col-md-8 inputGroupContainer"> <div class="col-md-8 inputGroupContainer">
<?php <?php getInputPassword("newPasswordConfirm", 'class="form-control" required="required" autocomplete="off"', __("Confirm New Password")); ?>
getInputPassword("newPasswordConfirm", 'class="form-control" required="required" autocomplete="off"', __("Confirm New Password")); ?>
</div> </div>
</div> </div>
@ -124,14 +122,13 @@ if (!(!empty($_GET['user']) && !empty($_GET['recoverpass']))) {
</fieldset> </fieldset>
</form> </form>
<?php <?php }
} ?> ?>
</div> </div>
</div><!--/.container--> </div><!--/.container-->
<?php <?php include $global['systemRootPath'] . 'view/include/footer.php'; ?>
include $global['systemRootPath'] . 'view/include/footer.php'; ?>
<script> <script>
$(document).ready(function () { $(document).ready(function () {

View file

@ -12,7 +12,9 @@ if (!User::isAdmin()) {
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>"> <html lang="<?php echo $_SESSION['language']; ?>">
<head> <head>
<title><?php echo __("VAST") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title> <?php
echo getHTMLTitle( __("VAST"));
?>
<?php <?php
include $global['systemRootPath'] . 'view/include/head.php'; include $global['systemRootPath'] . 'view/include/head.php';
include $global['systemRootPath'] . 'plugin/AD_Server/index_head.php'; include $global['systemRootPath'] . 'plugin/AD_Server/index_head.php';

View file

@ -20,7 +20,9 @@ $reflector = new ReflectionClass('API');
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>"> <html lang="<?php echo $_SESSION['language']; ?>">
<head> <head>
<title><?php echo __("API") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title> <?php
echo getHTMLTitle(__("API"));
?>
<?php <?php
include $global['systemRootPath'] . 'view/include/head.php'; include $global['systemRootPath'] . 'view/include/head.php';
?> ?>
@ -91,7 +93,7 @@ $reflector = new ReflectionClass('API');
preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $comment, $match2); preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $comment, $match2);
//var_dump($match2[0]); //var_dump($match2[0]);
$link = "<a target='_blank' href='{$match2[0][0]}'>" . htmlentities($match2[0][0]) . "</a>"; $link = "<a target='_blank' href='{$match2[0][0]}'>" . htmlentities($match2[0][0]) . "</a>";
$comment = str_replace(array($match2[0][0]," *"), array($link,"*"), $comment); $comment = str_replace(array($match2[0][0], " *"), array($link, "*"), $comment);
echo ($comment); echo ($comment);
//{webSiteRootURL}plugin/API/{getOrSet}.json.php?name={name} //{webSiteRootURL}plugin/API/{getOrSet}.json.php?name={name}

View file

@ -9,7 +9,9 @@ if (!User::isAdmin()) {
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>"> <html lang="<?php echo $_SESSION['language']; ?>">
<head> <head>
<title><?php echo __("Audit") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title> <?php
echo getHTMLTitle( __("Audit"));
?>
<?php <?php
include $global['systemRootPath'] . 'view/include/head.php'; include $global['systemRootPath'] . 'view/include/head.php';
?> ?>

View file

@ -14,7 +14,9 @@ $order = new BlockonomicsOrder($order_id);
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>"> <html lang="<?php echo $_SESSION['language']; ?>">
<head> <head>
<title><?php echo __("Invoice") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title> <?php
echo getHTMLTitle( __("Invoice"));
?>
<?php <?php
include $global['systemRootPath'] . 'view/include/head.php'; include $global['systemRootPath'] . 'view/include/head.php';
?> ?>

View file

@ -9,7 +9,9 @@ $obj = AVideoPlugin::getObjectData("BulkEmbed");
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>"> <html lang="<?php echo $_SESSION['language']; ?>">
<head> <head>
<title><?php echo __("Bulk Embed") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title> <?php
echo getHTMLTitle( __("Search"));
?>
<?php <?php
include $global['systemRootPath'] . 'view/include/head.php'; include $global['systemRootPath'] . 'view/include/head.php';
?> ?>

View file

@ -14,7 +14,9 @@ if (!User::isAdmin()) {
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>"> <html lang="<?php echo $_SESSION['language']; ?>">
<head> <head>
<title><?php echo __("Clone Site") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title> <?php
echo getHTMLTitle( __("Clone Site"));
?>
<?php <?php
include $global['systemRootPath'] . 'view/include/head.php'; include $global['systemRootPath'] . 'view/include/head.php';
?> ?>

View file

@ -12,7 +12,9 @@ require_once $global['systemRootPath'] . 'plugin/CombineSites/Objects/CombineSit
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>"> <html lang="<?php echo $_SESSION['language']; ?>">
<head> <head>
<title><?php echo __("Combine Sites") . $config->getPageTitleSeparator() . $config->getWebSiteTitle(); ?></title> <?php
echo getHTMLTitle( __("Combine Sites"));
?>
<?php <?php
include $global['systemRootPath'] . 'view/include/head.php'; include $global['systemRootPath'] . 'view/include/head.php';
?> ?>

View file

@ -9,9 +9,9 @@ $count = 1;
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?php echo $_SESSION['language']; ?>"> <html lang="<?php echo $_SESSION['language']; ?>">
<head> <head>
<title><?php <?php
echo $siteTitle; echo getHTMLTitle( $siteTitle);
?></title> ?>
<?php include $global['systemRootPath'] . 'view/include/head.php'; ?> <?php include $global['systemRootPath'] . 'view/include/head.php'; ?>
<script src="<?php echo $global['webSiteRootURL']; ?>view/js/infinite-scroll.pkgd.min.js" type="text/javascript"></script> <script src="<?php echo $global['webSiteRootURL']; ?>view/js/infinite-scroll.pkgd.min.js" type="text/javascript"></script>
</head> </head>

View file

@ -22,12 +22,12 @@ class Message implements MessageComponentInterface {
global $onMessageSentTo; global $onMessageSentTo;
$onMessageSentTo = array(); $onMessageSentTo = array();
$query = $conn->httpRequest->getUri()->getQuery(); $query = $conn->httpRequest->getUri()->getQuery();
parse_str($query, $wsocketToken); parse_str($query, $wsocketGetVars);
if (empty($wsocketToken['webSocketToken'])) { if (empty($wsocketGetVars['webSocketToken'])) {
_log_message("Empty websocket token "); _log_message("Empty websocket token ");
return false; return false;
} }
$json = getDecryptedInfo($wsocketToken['webSocketToken']); $json = getDecryptedInfo($wsocketGetVars['webSocketToken']);
if (empty($json)) { if (empty($json)) {
_log_message("Invalid websocket token "); _log_message("Invalid websocket token ");
return false; return false;
@ -43,7 +43,8 @@ class Message implements MessageComponentInterface {
$client['browser'] = $json->browser; $client['browser'] = $json->browser;
$client['yptDeviceId'] = $json->yptDeviceId; $client['yptDeviceId'] = $json->yptDeviceId;
$client['selfURI'] = $json->selfURI; $client['selfURI'] = $json->selfURI;
$client['isCommandLine'] = $wsocketToken['isCommandLine']; $client['isCommandLine'] = $wsocketGetVars['isCommandLine'];
$client['page_title'] = utf8_encode($wsocketGetVars['page_title']);
$client['videos_id'] = $json->videos_id; $client['videos_id'] = $json->videos_id;
$client['live_key'] = object_to_array(@$json->live_key); $client['live_key'] = object_to_array(@$json->live_key);
$client['autoEvalCodeOnHTML'] = $json->autoEvalCodeOnHTML; $client['autoEvalCodeOnHTML'] = $json->autoEvalCodeOnHTML;

View file

@ -37,7 +37,7 @@ class Socket extends PluginAbstract {
} }
public static function getServerVersion() { public static function getServerVersion() {
return "2.0"; return "2.1";
} }
public function updateScript() { public function updateScript() {

View file

@ -5,13 +5,15 @@ function socketConnect() {
return false; return false;
} }
socketConnectRequested = 1; socketConnectRequested = 1;
console.log('Trying to reconnect on socket...'); var url = addGetParam(webSocketURL, 'page_title', $(document).find("title").text());
conn = new WebSocket(webSocketURL); console.log('Trying to reconnect on socket... ' + url);
conn = new WebSocket(url);
conn.onopen = function (e) { conn.onopen = function (e) {
console.log("Socket onopen"); console.log("Socket onopen");
return false; return false;
}; };
conn.onmessage = function (e) { conn.onmessage = function (e) {
console.log(e.data);
var json = JSON.parse(e.data); var json = JSON.parse(e.data);
parseSocketResponse(json); parseSocketResponse(json);
if (json.type == webSocketTypes.ON_VIDEO_MSG) { if (json.type == webSocketTypes.ON_VIDEO_MSG) {
@ -90,7 +92,7 @@ function defaultCallback(json) {
function parseSocketResponse(json) { function parseSocketResponse(json) {
console.log("parseSocketResponse", json); console.log("parseSocketResponse", json);
if(json.isAdmin && webSocketServerVersion!==json.webSocketServerVersion){ if(json.isAdmin && webSocketServerVersion!==json.webSocketServerVersion){
avideoToast("Please restart your socket server. You are running (v"+json.webSocketServerVersion+") and your client is expecting (v"+webSocketServerVersion+")"); avideoToastWarning("Please restart your socket server. You are running (v"+json.webSocketServerVersion+") and your client is expecting (v"+webSocketServerVersion+")");
} }
if (json && typeof json.autoUpdateOnHTML !== 'undefined') { if (json && typeof json.autoUpdateOnHTML !== 'undefined') {
$('.total_on').text(0); $('.total_on').text(0);
@ -128,7 +130,7 @@ function parseSocketResponse(json) {
if (json.users_uri[prop][prop2][prop3] === false || typeof json.users_uri[prop][prop2][prop3] !== 'object') { if (json.users_uri[prop][prop2][prop3] === false || typeof json.users_uri[prop][prop2][prop3] !== 'object') {
continue; continue;
} }
var html = '<div><a href="' + json.users_uri[prop][prop2][prop3].selfURI + '" target="_blank"><img src="' + webSiteRootURL + 'user/' + json.users_uri[prop][prop2][prop3].users_id + '/foto.png" class="img img-circle img-responsive">IP: ' + json.users_uri[prop][prop2][prop3].ip + ' (' + json.users_uri[prop][prop2][prop3].user_name + ') </a></div>' var html = '<div><a href="' + json.users_uri[prop][prop2][prop3].selfURI + '" target="_blank"><img src="' + webSiteRootURL + 'user/' + json.users_uri[prop][prop2][prop3].users_id + '/foto.png" class="img img-circle img-responsive">(' + json.users_uri[prop][prop2][prop3].page_title + ') ' + json.users_uri[prop][prop2][prop3].user_name + ' IP: ' + json.users_uri[prop][prop2][prop3].ip + ' </a></div>'
//console.log(json.users_uri[prop]); //console.log(json.users_uri[prop]);
$('#socketUsersURI').append(html); $('#socketUsersURI').append(html);
} }

View file

@ -24,7 +24,7 @@ _error_log("Starting Socket server at port {$SocketDataObj->port}");
killProcessOnPort(); killProcessOnPort();
$scheme = parse_url($global['webSiteRootURL'], PHP_URL_SCHEME); $scheme = parse_url($global['webSiteRootURL'], PHP_URL_SCHEME);
echo "Starting server on port {$SocketDataObj->port}".PHP_EOL; echo "Starting AVideo Socket server version {$SocketDataObj->serverVersion} on port {$SocketDataObj->port}".PHP_EOL;
if(strtolower($scheme)!=='https'){ if(strtolower($scheme)!=='https'){
echo "Your socket server does NOT use a secure connection".PHP_EOL; echo "Your socket server does NOT use a secure connection".PHP_EOL;

View file

@ -677,7 +677,7 @@ function playNext(url) {
}); });
} }
} else if (isPlayerLoop()) { } else if (isPlayerLoop()) {
$.toast("Looping video"); avideoToast("Looping video");
userIsControling = false; userIsControling = false;
playerPlayTimeout = setTimeout(function () { playerPlayTimeout = setTimeout(function () {
playerPlay(currentTime); playerPlay(currentTime);
@ -861,8 +861,27 @@ function avideoAlert(title, msg, type) {
} }
} }
function _avideoToast(msg, icon) {
var options = {text:msg, hideAfter:7000};
if(icon){
options.icon = icon;
}
$.toast(options);
}
function avideoToast(msg) { function avideoToast(msg) {
$.toast({text:msg, hideAfter:7000}); _avideoToast(msg, null);
}
function avideoToastInfo(msg) {
_avideoToast(msg, 'info');
}
function avideoToastError(msg) {
_avideoToast(msg, 'error');
}
function avideoToastSuccess(msg) {
_avideoToast(msg, 'success');
}
function avideoToastWarning(msg) {
_avideoToast(msg, 'warning');
} }
function avideoAlertAJAXHTML(url) { function avideoAlertAJAXHTML(url) {