mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-03 09:49:28 +02:00
Update
This commit is contained in:
parent
c5087d9abe
commit
54a698ffda
8 changed files with 103 additions and 11 deletions
|
@ -10,6 +10,10 @@ if (!empty($_GET['lang'])) {
|
||||||
includeLangFile();
|
includeLangFile();
|
||||||
|
|
||||||
function includeLangFile() {
|
function includeLangFile() {
|
||||||
|
global $isStandAlone;
|
||||||
|
if(!empty($isStandAlone)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
global $t, $global;
|
global $t, $global;
|
||||||
if(empty($_SESSION) && function_exists('_session_start')){
|
if(empty($_SESSION) && function_exists('_session_start')){
|
||||||
_session_start();
|
_session_start();
|
||||||
|
|
|
@ -127,7 +127,7 @@ function _mysql_connect($persistent = false, $try = 0)
|
||||||
|
|
||||||
foreach ($checkValues as $value) {
|
foreach ($checkValues as $value) {
|
||||||
if (!isset($$value)) {
|
if (!isset($$value)) {
|
||||||
_error_log("_mysql_connect Variable NOT set $value");
|
_error_log("_mysql_connect Variable NOT set $value ".json_encode(debug_backtrace()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -414,6 +414,10 @@ function isForbidden()
|
||||||
}
|
}
|
||||||
|
|
||||||
function includeSecurityChecks() {
|
function includeSecurityChecks() {
|
||||||
|
global $isStandAlone;
|
||||||
|
if(!empty($isStandAlone)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$directory = __DIR__.'/../plugin/';
|
$directory = __DIR__.'/../plugin/';
|
||||||
// Ensure the directory exists
|
// Ensure the directory exists
|
||||||
if (!is_dir($directory)) {
|
if (!is_dir($directory)) {
|
||||||
|
|
64
objects/functionsStandAlone.php
Normal file
64
objects/functionsStandAlone.php
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
// Function to load standalone configuration
|
||||||
|
function loadStandaloneConfiguration()
|
||||||
|
{
|
||||||
|
global $global, $doNotIncludeConfig, $streamerURL;
|
||||||
|
|
||||||
|
// Define the global system root path
|
||||||
|
$global['systemRootPath'] = realpath(__DIR__ . '/../') . '/';
|
||||||
|
$global['systemRootPath'] = str_replace('\\', '/', $global['systemRootPath']);
|
||||||
|
$configFileStandAlone = "{$global['systemRootPath']}videos/standalone.configuration.php";
|
||||||
|
|
||||||
|
// Load configuration if the file exists
|
||||||
|
if (file_exists($configFileStandAlone)) {
|
||||||
|
$doNotIncludeConfig = 1;
|
||||||
|
require_once $configFileStandAlone;
|
||||||
|
// Set global variables for logging
|
||||||
|
if ($global['webSiteRootURL'] === _getCurrentUrl()) {
|
||||||
|
$configFile = "{$global['systemRootPath']}videos/configuration.php";
|
||||||
|
|
||||||
|
// Check if configuration.php exists; if not, create it
|
||||||
|
if (!file_exists($configFile)) {
|
||||||
|
$content = "<?php" . PHP_EOL;
|
||||||
|
$content .= "global \$global, \$doNotIncludeConfig, \$doNotConnectDatabaseIncludeConfig, \$doNotStartSessionIncludeConfig, \$isStandAlone;" . PHP_EOL;
|
||||||
|
$content .= "\$isStandAlone = 1;" . PHP_EOL;
|
||||||
|
$content .= "\$doNotIncludeConfig = 1;" . PHP_EOL;
|
||||||
|
$content .= "\$doNotConnectDatabaseIncludeConfig = 1;" . PHP_EOL;
|
||||||
|
$content .= "\$doNotStartSessionIncludeConfig = 1;" . PHP_EOL;
|
||||||
|
$content .= "\$global['salt'] = '" . uniqid() . "';" . PHP_EOL;
|
||||||
|
$content .= "\$global['webSiteRootURL'] = '{$global['webSiteRootURL']}';" . PHP_EOL;
|
||||||
|
$content .= "\$global['systemRootPath'] = '{$global['systemRootPath']}';" . PHP_EOL;
|
||||||
|
$content .= "\$global['logfile'] = \$global['systemRootPath'] . 'videos/avideo.log';" . PHP_EOL . PHP_EOL;
|
||||||
|
$content .= "require_once \$global['systemRootPath'] . 'objects/include_config.php';" . PHP_EOL;
|
||||||
|
|
||||||
|
if (file_put_contents($configFile, $content) === false) {
|
||||||
|
die("Failed to create the configuration file at $configFile");
|
||||||
|
}
|
||||||
|
error_log("configuration.php created at $configFile");
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once $configFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function _getCurrentUrl()
|
||||||
|
{
|
||||||
|
// Determine the protocol (http or https)
|
||||||
|
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://";
|
||||||
|
|
||||||
|
// Get the host
|
||||||
|
$host = $_SERVER['HTTP_HOST'];
|
||||||
|
|
||||||
|
// Get the request URI
|
||||||
|
$uri = $_SERVER['REQUEST_URI'];
|
||||||
|
|
||||||
|
// Combine all parts to form the full URL
|
||||||
|
$url = $protocol . $host . $uri;
|
||||||
|
|
||||||
|
return str_replace('plugin/Live/standAloneFiles/restreamer.json.php', '', $url);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the function to load configuration
|
||||||
|
loadStandaloneConfiguration();
|
|
@ -3,9 +3,9 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||||
|
|
||||||
if (empty($global['systemRootPath'])) {
|
if (empty($global['systemRootPath'])) {
|
||||||
$global['systemRootPath'] = '../';
|
$global['systemRootPath'] = '../';
|
||||||
|
require_once $global['systemRootPath'] . 'videos/configuration.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once $global['systemRootPath'] . 'videos/configuration.php';
|
|
||||||
|
|
||||||
require_once $global['systemRootPath'] . 'objects/bootGrid.php';
|
require_once $global['systemRootPath'] . 'objects/bootGrid.php';
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
if (empty($global['systemRootPath'])) {
|
if (empty($global['systemRootPath'])) {
|
||||||
$global['systemRootPath'] = '../';
|
$global['systemRootPath'] = '../';
|
||||||
|
require_once $global['systemRootPath'] . 'videos/configuration.php';
|
||||||
}
|
}
|
||||||
require_once $global['systemRootPath'] . 'videos/configuration.php';
|
|
||||||
require_once $global['systemRootPath'] . 'objects/bootGrid.php';
|
require_once $global['systemRootPath'] . 'objects/bootGrid.php';
|
||||||
require_once $global['systemRootPath'] . 'objects/user.php';
|
require_once $global['systemRootPath'] . 'objects/user.php';
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,8 @@ if ($isCached) {
|
||||||
require_once dirname(__FILE__) . '/../../videos/configuration.php';
|
require_once dirname(__FILE__) . '/../../videos/configuration.php';
|
||||||
$obj = AVideoPlugin::getDataObjectIfEnabled('VideoHLS');
|
$obj = AVideoPlugin::getDataObjectIfEnabled('VideoHLS');
|
||||||
if (class_exists('VideoHLS')) {
|
if (class_exists('VideoHLS')) {
|
||||||
if (empty($_SERVER['HTTP_REFERER']) || !isSameDomain($_SERVER['HTTP_REFERER'], $global['webSiteRootURL'])) {
|
if (empty($_SERVER['HTTP_REFERER']) || !isSameDomain($_SERVER['HTTP_REFERER'], $global['webSiteRootURL'])) {
|
||||||
|
error_log('HTTP_REFERER '.@$_SERVER['HTTP_REFERER']);
|
||||||
$authorized = false;
|
$authorized = false;
|
||||||
}else if ($_SERVER['HTTP_USER_AGENT'] === 'AVideoRestreamer' || empty($obj->downloadProtection) || VideoHLS::verifyToken($token)) {
|
}else if ($_SERVER['HTTP_USER_AGENT'] === 'AVideoRestreamer' || empty($obj->downloadProtection) || VideoHLS::verifyToken($token)) {
|
||||||
$authorized = true;
|
$authorized = true;
|
||||||
|
|
|
@ -18,7 +18,6 @@ require_once __DIR__ . '/functions.php';
|
||||||
* make
|
* make
|
||||||
* make install
|
* make install
|
||||||
*/
|
*/
|
||||||
$streamerURL = "https://demo.avideo.com/"; // change it to your streamer URL
|
|
||||||
// optional you can change the log file location here
|
// optional you can change the log file location here
|
||||||
$logFileLocation = '/var/www/tmp/';
|
$logFileLocation = '/var/www/tmp/';
|
||||||
|
|
||||||
|
@ -66,7 +65,14 @@ if (file_exists($configFile)) {
|
||||||
include_once $configFile;
|
include_once $configFile;
|
||||||
$streamerURL = $global['webSiteRootURL'];
|
$streamerURL = $global['webSiteRootURL'];
|
||||||
error_log("Restreamer.json.php is using local configuration");
|
error_log("Restreamer.json.php is using local configuration");
|
||||||
|
} else {
|
||||||
|
require_once __DIR__ . "/../../../objects/functionsStandAlone.php";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (empty($streamerURL)) {
|
||||||
|
die('streamerURL not defined');
|
||||||
|
}
|
||||||
|
|
||||||
require_once __DIR__ . "/../../../vendor/autoload.php";
|
require_once __DIR__ . "/../../../vendor/autoload.php";
|
||||||
|
|
||||||
if (!empty($_REQUEST['tokenForAction'])) {
|
if (!empty($_REQUEST['tokenForAction'])) {
|
||||||
|
@ -190,8 +196,10 @@ if (!$isCommandLine) { // not command line
|
||||||
if (empty($robj)) {
|
if (empty($robj)) {
|
||||||
$request = file_get_contents("php://input");
|
$request = file_get_contents("php://input");
|
||||||
error_log("Restreamer.json.php php://input {$request}");
|
error_log("Restreamer.json.php php://input {$request}");
|
||||||
$robj = json_decode($request);
|
if (!empty($request)) {
|
||||||
$robj->type = 'decoded from request';
|
$robj = json_decode($request);
|
||||||
|
$robj->type = 'decoded from request';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!empty($robj)) {
|
if (!empty($robj)) {
|
||||||
if (!empty($robj->test)) {
|
if (!empty($robj->test)) {
|
||||||
|
@ -262,10 +270,21 @@ if (empty($robj)) {
|
||||||
$robj = new stdClass();
|
$robj = new stdClass();
|
||||||
$robj->type = 'empty';
|
$robj->type = 'empty';
|
||||||
$robj->token = '';
|
$robj->token = '';
|
||||||
$robj->m3u8 = $argv[1];
|
|
||||||
$robj->restreamsDestinations = [$argv[2]];
|
// Check if running from the command line
|
||||||
$robj->users_id = 'commandline';
|
if (php_sapi_name() === 'cli') {
|
||||||
$robj->logFile = @$argv[3];
|
$robj->m3u8 = @$argv[1];
|
||||||
|
$robj->restreamsDestinations = [@$argv[2]];
|
||||||
|
$robj->users_id = 'commandline';
|
||||||
|
$robj->logFile = @$argv[3];
|
||||||
|
} else {
|
||||||
|
// Fallback to URL parameters
|
||||||
|
$robj->m3u8 = isset($_REQUEST['m3u8']) ? $_REQUEST['m3u8'] : '';
|
||||||
|
$robj->restreamsDestinations = isset($_REQUEST['destinations']) ? explode(',', $_REQUEST['destinations']) : [];
|
||||||
|
$robj->users_id = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : 'web';
|
||||||
|
$robj->logFile = isset($_REQUEST['logFile']) ? $_REQUEST['logFile'] : '';
|
||||||
|
}
|
||||||
|
|
||||||
$robj->responseToken = '';
|
$robj->responseToken = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue