diff options
| author | Philip Wittamore <philip@wittamore.com> | 2025-11-08 17:52:58 +0100 |
|---|---|---|
| committer | Philip Wittamore <philip@wittamore.com> | 2025-11-08 17:52:58 +0100 |
| commit | 5637b6bc9e9ca99779fd6483318f33a6fe38152d (patch) | |
| tree | e7c7f5556be89e8f11ded44ca167a473032bcdfe /search.php | |
| parent | 301c765535e2dc4e51a3b756e2b830dbe51293aa (diff) | |
| download | scripts-5637b6bc9e9ca99779fd6483318f33a6fe38152d.tar.gz scripts-5637b6bc9e9ca99779fd6483318f33a6fe38152d.tar.bz2 scripts-5637b6bc9e9ca99779fd6483318f33a6fe38152d.zip | |
Diffstat (limited to 'search.php')
| -rw-r--r-- | search.php | 43 |
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"; +} + +?> + |
