Compare commits
No commits in common. "d1a7d5743e08fd1e214b256da348b34c7ab5eca6" and "8a68af7e0611b9f4a3662cc6c8dab1c9319bf62c" have entirely different histories.
d1a7d5743e
...
8a68af7e06
@ -1,3 +0,0 @@
|
||||
<?php
|
||||
Respond::redirect("/run");
|
||||
?>
|
103
pages/run.php
103
pages/run.php
@ -43,52 +43,17 @@
|
||||
catch (Exception $x) {}
|
||||
}
|
||||
|
||||
// WARNING: Can be abused.
|
||||
// Translate occurrences of {{ SQL: select 'test' }} into the string value of the first cell of the first row:
|
||||
// Can be used in string literals or default values in comments!
|
||||
preg_match_all(
|
||||
"/\{\{\s*SQL\:\s*(.*)\s+?\}\}/i",
|
||||
$strFileData,
|
||||
$varSQLReplacements);
|
||||
|
||||
for ($i = 0; $i < count($varSQLReplacements[0]); $i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
$strMatch = $varSQLReplacements[0][$i];
|
||||
$strMatchSafe = preg_quote($strMatch);
|
||||
$strSQLString = $varSQLReplacements[1][$i];
|
||||
$varTempRows = $c->query($strSQLString);
|
||||
|
||||
//Respond::json($varTempRows);
|
||||
|
||||
$strFirstCell = "";
|
||||
if (count($varTempRows) > 0)
|
||||
foreach ($varTempRows[0] as $k => $v)
|
||||
{
|
||||
$strFirstCell = $varTempRows[0][$k];
|
||||
break;
|
||||
}
|
||||
|
||||
$strFileData = preg_replace(
|
||||
"/{$strMatchSafe}/i",
|
||||
$strFirstCell,
|
||||
$strFileData);
|
||||
}
|
||||
catch (Exception $x) {}
|
||||
}
|
||||
|
||||
//Respond::json($strFileData);
|
||||
|
||||
//foreach ($varReplacements as $k => $v)
|
||||
// $strFileData = preg_replace("/\{\{{$k}\}\}/i", $v, $strFileData);
|
||||
|
||||
// Get the inputs:
|
||||
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+-- Default\:\s(.*))?/i",
|
||||
$strFileData,
|
||||
$varInputs);
|
||||
|
||||
//Respond::json($varInputs);
|
||||
|
||||
// Get the options defined in comments:
|
||||
preg_match_all(
|
||||
"/--\s+([A-Za-z0-9]{1,})\:\s+(.+)/i",
|
||||
@ -131,27 +96,18 @@
|
||||
}
|
||||
|
||||
$intRun = Request::getParam("run");
|
||||
$strFormat = Request::getParam("format");
|
||||
|
||||
//if (Request::posts("run_query"))
|
||||
if ($intRun !== null && $intRun == 1 && $intAllowed == 1)
|
||||
{
|
||||
$varPosted = Request::getParams();
|
||||
|
||||
// Remove these keys from submitted fields:
|
||||
foreach (["run", "format"] as $k)
|
||||
if (array_key_exists($k, $varPosted))
|
||||
unset($varPosted[$k]);
|
||||
unset($varPosted["run"]);
|
||||
|
||||
try
|
||||
{
|
||||
$varRows = $c->query("{$strQueryDir}/{$strSelection}", $varPosted);
|
||||
$strView = "files/views/{$strSelection}.php";
|
||||
|
||||
// Allow returning the data as JSON for APIs, maybe:
|
||||
if (strtolower($strFormat) == "json")
|
||||
Respond::json($varRows);
|
||||
|
||||
// Load a custom view if there is one:
|
||||
if (file_exists($strView))
|
||||
{
|
||||
@ -293,16 +249,8 @@
|
||||
$strInputTypeHTML = "date";
|
||||
|
||||
$strInputDefaultValue = "";
|
||||
if (strtolower($varInputs[4][$i]) == "default")
|
||||
if (strlen($varInputs[5][$i]) > 0)
|
||||
$strInputDefaultValue = $varInputs[5][$i];
|
||||
|
||||
$varOptions = [];
|
||||
if (strtolower($varInputs[4][$i]) == "options")
|
||||
{
|
||||
$strOptionsList = $varInputs[5][$i];
|
||||
$varOptions = explode(",", $strOptionsList);
|
||||
}
|
||||
if (strlen($varInputs[4][$i]) > 0)
|
||||
$strInputDefaultValue = $varInputs[4][$i];
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
@ -310,37 +258,10 @@
|
||||
<div class="mb-3">
|
||||
<label><?= $strInputName; ?> <code><?= $strInputType; ?></code></label>
|
||||
|
||||
<?php if (count($varOptions) > 0): ?>
|
||||
|
||||
<select class="form-select" name="<?= $strInputName; ?>">
|
||||
<?php foreach ($varOptions as $o): ?>
|
||||
<?php
|
||||
$strLabel = $o;
|
||||
$strValue = $o;
|
||||
|
||||
if (preg_match("/=.+$/i", $o))
|
||||
{
|
||||
preg_match("/(.+)=(.+)$/i", $o, $varTempMatches);
|
||||
$strLabel = $varTempMatches[1];
|
||||
$strValue = $varTempMatches[2];
|
||||
}
|
||||
?>
|
||||
|
||||
<option
|
||||
value="<?= $strValue; ?>"
|
||||
<?= Request::getParam($strInputName) == $strValue? "selected": ""; ?>
|
||||
><?= $strLabel; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
<?php else: ?>
|
||||
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-at"></i></span>
|
||||
<input type="<?= $strInputTypeHTML; ?>" class="form-control" name="<?= $strInputName; ?>" value="<?= Request::getParam($strInputName) ?? $strInputDefaultValue; ?>" />
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -527,15 +448,3 @@
|
||||
|
||||
<?php DataTable::js("#table"); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<?php $intAutorun = Request::getParam("autorun"); ?>
|
||||
<?php if ($intAutorun !== null && $intAutorun == 1): ?>
|
||||
<script>
|
||||
$(function() {
|
||||
$("#page-input form")
|
||||
.first()
|
||||
.submit();
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
Loading…
Reference in New Issue
Block a user