mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 10:49:36 +02:00
Update
This commit is contained in:
parent
51cb12d2ee
commit
f38a9536da
3 changed files with 151 additions and 123 deletions
|
@ -525,6 +525,25 @@ function getFFMPEGRemoteLog($keyword)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function stopFFMPEGRemote($keyword)
|
||||||
|
{
|
||||||
|
$obj = AVideoPlugin::getDataObjectIfEnabled('API');
|
||||||
|
if(!empty($obj) && !empty($obj->standAloneFFMPEG)){
|
||||||
|
$url = "{$obj->standAloneFFMPEG}";
|
||||||
|
|
||||||
|
$codeToExec = array('stop'=>1, 'keyword'=>$keyword, 'time'=>time());
|
||||||
|
|
||||||
|
$codeToExecEncrypted = encryptString(json_encode($codeToExec));
|
||||||
|
|
||||||
|
$url = addQueryStringParameter($url, 'APISecret', $obj->APISecret);
|
||||||
|
$url = addQueryStringParameter($url, 'codeToExecEncrypted', $codeToExecEncrypted);
|
||||||
|
_error_log("execFFMPEGAsyncOrRemote: URL $url");
|
||||||
|
return json_decode(url_get_contents($url));
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Function to find the process by keyword using the pid file
|
// Function to find the process by keyword using the pid file
|
||||||
function findProcess($keyword)
|
function findProcess($keyword)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FFMPEG Command Execution Script with API Secret Validation
|
* FFMPEG Command Execution Script with API Secret Validation
|
||||||
* -----------------------------------------------------------
|
* -----------------------------------------------------------
|
||||||
|
@ -123,7 +124,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to safely get inputs from either command line or request
|
// Function to safely get inputs from either command line or request
|
||||||
function getInput($key, $default = '') {
|
function getInput($key, $default = '')
|
||||||
|
{
|
||||||
global $argv;
|
global $argv;
|
||||||
|
|
||||||
// Check if running from command line or HTTP request
|
// Check if running from command line or HTTP request
|
||||||
|
@ -141,7 +143,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate and sanitize the ffmpegCommand
|
// Validate and sanitize the ffmpegCommand
|
||||||
function sanitizeFFmpegCommand($command) {
|
function sanitizeFFmpegCommand($command)
|
||||||
|
{
|
||||||
$allowedPrefixes = ['ffmpeg', '/usr/bin/ffmpeg', '/bin/ffmpeg'];
|
$allowedPrefixes = ['ffmpeg', '/usr/bin/ffmpeg', '/bin/ffmpeg'];
|
||||||
|
|
||||||
// Remove dangerous characters
|
// Remove dangerous characters
|
||||||
|
@ -191,12 +194,11 @@ $tempDir = rtrim($tempDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
|
||||||
// Create a unique log file path
|
// Create a unique log file path
|
||||||
$logFile = "{$tempDir}ffmpeg_{$keyword}.log";
|
$logFile = "{$tempDir}ffmpeg_{$keyword}.log";
|
||||||
|
|
||||||
|
if (!empty($codeToExec->log)) {
|
||||||
$time = time();
|
$time = time();
|
||||||
$modified = @filemtime($logFile);
|
$modified = @filemtime($logFile);
|
||||||
$secondsAgo = $time - $obj->modified;
|
$secondsAgo = $time - $obj->modified;
|
||||||
$isActive = $secondsAgo < 10;
|
$isActive = $secondsAgo < 10;
|
||||||
|
|
||||||
if (!empty($codeToExec->log)) {
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'error' => !file_exists($logFile),
|
'error' => !file_exists($logFile),
|
||||||
'msg' => '',
|
'msg' => '',
|
||||||
|
@ -207,6 +209,17 @@ $isActive = $secondsAgo < 10;
|
||||||
'isActive' => $isActive,
|
'isActive' => $isActive,
|
||||||
]);
|
]);
|
||||||
exit;
|
exit;
|
||||||
|
} else if (!empty($codeToExec->stop) && !empty($keyword)) {
|
||||||
|
$cmd = "pkill -f 'ffmpeg.*$keyword'";
|
||||||
|
echo json_encode([
|
||||||
|
'error' => !file_exists($logFile),
|
||||||
|
'msg' => '',
|
||||||
|
'logFile' => $logFile,
|
||||||
|
'kill' => exec("pkill -f 'ffmpeg.*$keyword'"),
|
||||||
|
'keyword' => $keyword,
|
||||||
|
'unlink' => unlink($logFile),
|
||||||
|
]);
|
||||||
|
exit;
|
||||||
} else
|
} else
|
||||||
// Validate that ffmpegCommand is not empty after sanitization
|
// Validate that ffmpegCommand is not empty after sanitization
|
||||||
if (empty($ffmpegCommand)) {
|
if (empty($ffmpegCommand)) {
|
||||||
|
@ -243,4 +256,3 @@ $isActive = $secondsAgo < 10;
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
exit;
|
exit;
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
includeConfigLog(__LINE__, basename(__FILE__));
|
|
||||||
require_once $global['systemRootPath'] . 'locale/function.php';
|
require_once $global['systemRootPath'] . 'locale/function.php';
|
||||||
includeConfigLog(__LINE__, basename(__FILE__));
|
|
||||||
require_once $global['systemRootPath'] . 'objects/plugin.php';
|
require_once $global['systemRootPath'] . 'objects/plugin.php';
|
||||||
includeConfigLog(__LINE__, basename(__FILE__));
|
|
||||||
|
|
||||||
abstract class PluginAbstract {
|
abstract class PluginAbstract {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue