diff --git a/pages/run.php b/pages/run.php index b028046..84202db 100644 --- a/pages/run.php +++ b/pages/run.php @@ -96,6 +96,31 @@ 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: preg_match_all( "/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(); $intRun = 0; + $intIsPOST = 0; // Merge POST with the GET params: // POSTing implies running the query, too. @@ -155,6 +181,7 @@ { $varPosted[$k] = $v; $intRun = 1; + $intIsPOST = 1; } $intRun = $varPosted["run"] ?? $intRun; @@ -213,6 +240,25 @@ if (array_key_exists("title", $varOptions)) $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: $strPageInputClass = ""; @@ -278,14 +324,33 @@ - + + + + + +
-
- No rows returned. +
+
+ + + + + +
+
+
+ No rows returned. +
+
+
+ +
@@ -416,6 +481,45 @@
+ + + + +
+ +
+ + + + "> + */ ?> + +
+ +
+ + +
+
+ + + @@ -802,7 +906,7 @@ - + + + + + @@ -848,3 +972,4 @@ "> +