summaryrefslogtreecommitdiff
path: root/oracles/calc.php
diff options
context:
space:
mode:
authorcynic <admin@cynic.moe>2023-09-14 19:10:13 -0500
committerlolcat <lolcat@no-reply@lolcat.ca>2023-09-14 19:10:13 -0500
commitbe8546bdf55f9c77012217ec510b81d9d5fd58b3 (patch)
treee2a5b0dbde02794355c77d05cbffe9314bba52a9 /oracles/calc.php
parent8762d68466b825382f4708a0eebbd3074e32c5c5 (diff)
make 'oracles' feature backwards compatible with php 7.4 (#13)
adds implementations of `str_contains` and `str_starts_with` that are used if the functions are not already defined. this should enable 4get to work on both php 7.4 and php 8.* my instance is currently on 7.4.33, and you can see the oracles working here: [calc.php](https://4get.silly.computer/web?s=2%2B4*(2^2)) [encoder.php](https://4get.silly.computer/web?s=md5+hamburger) [numerics.php](https://4get.silly.computer/web?s=0xf0f0f) [time.php](https://4get.silly.computer/web?s=what+is+the+time+right+now+tz%253Aest) Reviewed-on: https://git.lolcat.ca/lolcat/4get/pulls/13 Co-authored-by: cynic <admin@cynic.moe> Co-committed-by: cynic <admin@cynic.moe>
Diffstat (limited to 'oracles/calc.php')
-rw-r--r--oracles/calc.php7
1 files changed, 7 insertions, 0 deletions
diff --git a/oracles/calc.php b/oracles/calc.php
index 4888b95..bcc127b 100644
--- a/oracles/calc.php
+++ b/oracles/calc.php
@@ -84,6 +84,13 @@ class calculator extends oracle {
}
}
+ // no implicit multiplication
+ for ($i = 0; $i < count($tokens) - 1; $i++) {
+ if ($tokens[$i][0] == "n" && $tokens[$i+1] == ["g", "("]) {
+ return "";
+ }
+ }
+
//strategy:
// traverse to group open (if there is one)
// - return to start with the internals