Skip to content

Commit

Permalink
Run scripts in popup vs new tab. Allow plugins to run their scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpinkham committed Nov 9, 2023
1 parent f243e44 commit e04452d
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 9 deletions.
31 changes: 26 additions & 5 deletions www/runEventScript.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
<?php
if (!isset($_GET['nohtml'])) {
?>
<!DOCTYPE html>
<html>
<?php
}

$skipJSsettings = 1;
require_once("common.php");

DisableOutputBuffering();

if (!isset($_GET['nohtml'])) {
?>

<head>
Expand All @@ -18,6 +23,12 @@
<h2>FPP Event Script</h2>

<?php
}

if (isset($_GET['plugin'])) {
$plugin = sanitizeFilename($_GET['plugin']);
$scriptDirectory = "/home/fpp/media/plugins/$plugin/scripts";
}

if ((isset($_GET['scriptName'])) && strlen($_GET['scriptName']) > 0 &&
(file_exists($scriptDirectory . "/" . $_GET['scriptName'])))
Expand All @@ -28,19 +39,29 @@
if (isset($_GET['args']))
$args = escapeshellcmd($_GET['args']);

echo "Running $script $args<br><hr>\n";
echo "<pre>\n";
system($SUDO . " $fppDir/scripts/eventScript $scriptDirectory/$script $args");
echo "</pre>\n";
if (isset($_GET['nohtml'])) {
echo "Running $script $args\n--------------------------------------------------------------------------------\n";
system($SUDO . " $fppDir/scripts/eventScript $scriptDirectory/$script $args");
} else {
echo "Running $script $args<br><hr>\n";
echo "<pre>\n";
system($SUDO . " $fppDir/scripts/eventScript $scriptDirectory/$script $args");
echo "</pre>\n";
}
}
else
{
?>
ERROR: Unknown script:
<?
<?php
echo htmlspecialchars($_GET['scriptName']);
}

if (!isset($_GET['nohtml'])) {
?>
<br>
</body>
</html>
<?php
}
?>
34 changes: 30 additions & 4 deletions www/uploadfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,36 @@ function GetAllFiles() {
GetFiles('Crashes');
}

function RunScript(scriptName)
{
window.open("runEventScript.php?scriptName=" + scriptName);
}
function RunScriptDone() {
$('#runScriptCloseButton').prop('disabled', false);
EnableModalDialogCloseButton('runScriptDialog');
}

function RunScript(scriptName)
{
var options = {
id: 'runScriptDialog',
title: 'Run Script',
body: "<textarea style='width: 99%; height: 500px;' disabled id='runScriptText'></textarea>",
noClose: true,
keyboard: false,
backdrop: 'static',
footer: '',
buttons: {
'Close': {
id: 'runScriptCloseButton',
click: function() { CloseModalDialog('runScriptDialog'); },
disabled: true,
class: 'btn-success'
}
}
};

$('#runScriptCloseButton').prop('disabled', true);
DoModalDialog(options);

StreamURL('runEventScript.php?scriptName=' + scriptName + '&nohtml=1', 'runScriptText', 'RunScriptDone');
}

function EditScript(scriptName)
{
Expand Down

0 comments on commit e04452d

Please sign in to comment.