Added POST messaging and page redirect
This commit is contained in:
parent
f4db62f730
commit
11501e240b
133
pages/run.php
133
pages/run.php
@ -96,6 +96,31 @@
|
|||||||
catch (Exception $x) {}
|
catch (Exception $x) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// $_SERVER Key replacements:
|
||||||
|
preg_match_all(
|
||||||
|
"/\{\{\s*([A-Z_]{1,})\s*\}\}/i",
|
||||||
|
$strFileData,
|
||||||
|
$varServerKeyReplacements);
|
||||||
|
|
||||||
|
//Respond::json($_SERVER);
|
||||||
|
|
||||||
|
for ($i = 0; $i < count($varServerKeyReplacements[0]); $i++)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$strMatch = $varServerKeyReplacements[0][$i];
|
||||||
|
$strMatchSafe = preg_quote($strMatch);
|
||||||
|
$strKey = $varServerKeyReplacements[1][$i];
|
||||||
|
|
||||||
|
if (array_key_exists($strKey, $_SERVER))
|
||||||
|
$strFileData = preg_replace(
|
||||||
|
"/{$strMatchSafe}/i",
|
||||||
|
$_SERVER[$strKey],
|
||||||
|
$strFileData);
|
||||||
|
}
|
||||||
|
catch (Exception $x) {}
|
||||||
|
}
|
||||||
|
|
||||||
// Get the inputs:
|
// Get the inputs:
|
||||||
preg_match_all(
|
preg_match_all(
|
||||||
"/declare\s+\@([A-Za-z0-9]{1,})\s+(.+)\s+=\s+\?;(\s+-- ([A-Za-z0-9]{1,})\:\s(.*))?/i",
|
"/declare\s+\@([A-Za-z0-9]{1,})\s+(.+)\s+=\s+\?;(\s+-- ([A-Za-z0-9]{1,})\:\s(.*))?/i",
|
||||||
@ -148,6 +173,7 @@
|
|||||||
|
|
||||||
$varPosted = Request::getParams();
|
$varPosted = Request::getParams();
|
||||||
$intRun = 0;
|
$intRun = 0;
|
||||||
|
$intIsPOST = 0;
|
||||||
|
|
||||||
// Merge POST with the GET params:
|
// Merge POST with the GET params:
|
||||||
// POSTing implies running the query, too.
|
// POSTing implies running the query, too.
|
||||||
@ -155,6 +181,7 @@
|
|||||||
{
|
{
|
||||||
$varPosted[$k] = $v;
|
$varPosted[$k] = $v;
|
||||||
$intRun = 1;
|
$intRun = 1;
|
||||||
|
$intIsPOST = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$intRun = $varPosted["run"] ?? $intRun;
|
$intRun = $varPosted["run"] ?? $intRun;
|
||||||
@ -213,6 +240,25 @@
|
|||||||
if (array_key_exists("title", $varOptions))
|
if (array_key_exists("title", $varOptions))
|
||||||
$strTitle = $varOptions["title"];
|
$strTitle = $varOptions["title"];
|
||||||
|
|
||||||
|
// Allow returning a message for POST/form-like inputs:
|
||||||
|
$strOutputMessage = null;
|
||||||
|
$strOutputMessageClass = null;
|
||||||
|
$strRedirectURL = null;
|
||||||
|
|
||||||
|
if ($intIsPOST)
|
||||||
|
{
|
||||||
|
if ($varRows !== null && count($varRows) == 1)
|
||||||
|
{
|
||||||
|
$varRow1 = $varRows[0];
|
||||||
|
$strOutputMessage = $varRow1["message"] ?? null;
|
||||||
|
$strOutputMessageClass = $varRow1["message_class"] ?? "";
|
||||||
|
$strRedirectURL = $varRow1["redirect_url"] ?? null;
|
||||||
|
$varRows = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists("redirecturl", $varOptions))
|
||||||
|
$strRedirectURL = $varOptions["redirecturl"];
|
||||||
|
}
|
||||||
|
|
||||||
// Render the visibility immediately to prevent flicker:
|
// Render the visibility immediately to prevent flicker:
|
||||||
$strPageInputClass = "";
|
$strPageInputClass = "";
|
||||||
@ -278,14 +324,33 @@
|
|||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if ($varRows !== null && count($varRows) < 1): ?>
|
<?php if ($strRedirectURL !== null): ?>
|
||||||
|
<meta http-equiv="refresh" content="5;url=<?= $strRedirectURL; ?>" />
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($strOutputMessage !== null): ?>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="alert alert-warning">
|
<div class="<?= $strOutputMessageClass; ?>">
|
||||||
No rows returned.
|
<?= $strOutputMessage; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php $varRows = null; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
|
||||||
|
<?php if ($varRows !== null && count($varRows) < 1): ?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="alert alert-warning">
|
||||||
|
No rows returned.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@ -416,6 +481,45 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php if (array_key_exists("related", $varOptions)): ?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$strRelated = $varOptions["related"];
|
||||||
|
$varRelated = explode(",", $strRelated);
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label>Related</label>
|
||||||
|
<div>
|
||||||
|
<?php foreach ($varRelated as $r): ?>
|
||||||
|
<?php
|
||||||
|
$strLabel = $r;
|
||||||
|
$strValue = $r;
|
||||||
|
|
||||||
|
if (preg_match("/=.+$/i", $r))
|
||||||
|
{
|
||||||
|
preg_match("/(.+)=(.+)$/i", $r, $varTempMatches);
|
||||||
|
$strLabel = $varTempMatches[1];
|
||||||
|
$strValue = $varTempMatches[2];
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php /*
|
||||||
|
<a class="btn btn-outline-secondary me-1" href="<?= $strValue; ?>"><i class="fa fa-fw fa-link me-1"></i> <?= $strLabel; ?></a>
|
||||||
|
*/ ?>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<a class="link-underline link-underline-opacity-0" href="<?= $strValue; ?>"><i class="fa fa-fw fa-link me-1"></i> <?= $strLabel; ?></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<input type="hidden" name="run" value="1" />
|
<input type="hidden" name="run" value="1" />
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
@ -802,7 +906,7 @@
|
|||||||
|
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
|
|
||||||
<?php if (array_key_exists("autorun", $varOptions)): ?>
|
<?php if (array_key_exists("autorun", $varOptions) || Request::getParam("autorun") !== null): ?>
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
$("#page-input form")
|
$("#page-input form")
|
||||||
@ -810,6 +914,26 @@
|
|||||||
.submit();
|
.submit();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<?php else: ?>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(function() {
|
||||||
|
var chosen = 0;
|
||||||
|
$("input[type='text']").each((i, x) => {
|
||||||
|
if (chosen)
|
||||||
|
return;
|
||||||
|
|
||||||
|
x = $(x);
|
||||||
|
|
||||||
|
if (x.val().length < 1)
|
||||||
|
{
|
||||||
|
x.focus();
|
||||||
|
chosen = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
@ -848,3 +972,4 @@
|
|||||||
<?php if (array_key_exists("autorefresh", $varOptions)): ?>
|
<?php if (array_key_exists("autorefresh", $varOptions)): ?>
|
||||||
<meta http-equiv="refresh" content="<?= $varOptions["autorefresh"]; ?>">
|
<meta http-equiv="refresh" content="<?= $varOptions["autorefresh"]; ?>">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user