aboutsummaryrefslogtreecommitdiff
path: root/search.php
diff options
context:
space:
mode:
Diffstat (limited to 'search.php')
-rw-r--r--search.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/search.php b/search.php
new file mode 100644
index 0000000..dc09366
--- /dev/null
+++ b/search.php
@@ -0,0 +1,43 @@
+<?php
+echo "+--------------------------------+\n";
+echo "| Search Results |\n";
+echo "+--------------------------------+\n\n";
+
+$env=getenv();
+$string=$env["SEARCHREQUEST"];
+$string=htmlentities($string);
+
+if (!empty($string) || !ctype_space($string)) {
+ $string = strtolower($string);
+ echo "Search terms: " . $string . "\n\n";
+ $dir = new RecursiveDirectoryIterator("/srv/gopher/phlog");
+ $dir->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);
+ $iter = new RecursiveIteratorIterator($dir);
+
+ $i=0;
+
+ echo "+".str_repeat("-", 65)."+\n\n";
+ foreach ($iter as $phlogdir) {
+ $path=$phlogdir->getPathname();
+ if (str_contains($path, "/gophermap") ||
+ ($path=="/srv/gopher/phlog/rss.xml") ||
+ ($path=="/srv/gopher/phlog/search.php"))
+ continue;
+ $content = strtolower(file_get_contents($path));
+ $path=str_replace("/srv/gopher", "", $path);
+ if (strpos($content, $string) !== false) {
+ $i++;
+ $title = preg_split('#\r?\n#', $content, 2)[0];
+ $dt=substr($path, 12, 10);
+ echo "0".$dt." ".ucfirst($title)."\t".$path."\t"."spike.nagatha.fr\t70\n";
+ }
+ }
+
+ if ($i == 0) echo "No match";
+}else{
+ echo "Empty search string\n\n";
+ echo "1Return to Phlo\t/phlog\tspike.nagatha.fr\t70\n";
+}
+
+?>
+