diff options
author | lolcat <will@lolcat.ca> | 2025-08-11 01:55:15 +0000 |
---|---|---|
committer | lolcat <will@lolcat.ca> | 2025-08-11 01:55:15 +0000 |
commit | cdf958d29333d448f4521f4d2faa2592b58e9b27 (patch) | |
tree | 528f2a0ffa789a6f4279d9f54a4a2aaf391f390f /oracles/base.php | |
download | shittyweb-search-cdf958d29333d448f4521f4d2faa2592b58e9b27.tar.gz shittyweb-search-cdf958d29333d448f4521f4d2faa2592b58e9b27.tar.bz2 shittyweb-search-cdf958d29333d448f4521f4d2faa2592b58e9b27.zip |
fix wikipedia crashgrafted
Diffstat (limited to 'oracles/base.php')
-rw-r--r-- | oracles/base.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/oracles/base.php b/oracles/base.php new file mode 100644 index 0000000..84299fd --- /dev/null +++ b/oracles/base.php @@ -0,0 +1,36 @@ +<?php +abstract class oracle { + // some info to spit out alongside the result, so the user knows + // what exactly is giving out the answer. prevents confusion + // about what oracle is answering them for ambiguous queries. + public $info = [ + "name" => "some oracle" + ]; + // this function should take in a query string search from $_GET, + // and return a bool determining whether or not it is a question + // intended for the oracle. + public function check_query($q) { + return false; + } + // produce the correct answer for the query using the oracle. + // note: if it becomes apparent /during generation/ that the + // query is not in fact for the oracle, returning an empty + // string will kill the oracle pane. + // answer format: ["ans1 title" => "ans1", ...] + public function generate_response($q) { + return ""; + } +} +// backwards compatibility +if (!function_exists('str_starts_with')) { + function str_starts_with($haystack, $needle) { + return strncmp($haystack, $needle, strlen($needle)) === 0;; + } +} +if (!function_exists('str_contains')) { + function str_contains($haystack, $needle) { + return strpos((string)$haystack, (string)$needle) !== false; + } +} + +?>
\ No newline at end of file |