I’m currently in the process of rewriting my 404 (This is missing!) page, and I thought I’d share some of the search functions for popular search engines. I’ve written the strings below in such a way that if one is to append whatever terminology they’re searching for to the end of the string, that full URL will be rewritten for the chosen search engine.
function searchString($findString, $searchEngine) { $searchengine = array ( ‘altavista’ => ‘http://www.altavista.com/cgi-bin/query?pg=q&what=web&fmt=&q=’, ‘dictionary’ => ‘http://dictionary.reference.com/search?q=’, ‘everything2’ => ‘http://www.everything2.com/index.pl?node=’, ‘excite’ => ‘http://msxml.excite.com/info.xcite/search/web/’, ‘freshmeat’ => ‘http://freshmeat.net/search/?q=’, ‘google’ => ‘http://www.google.com/search?q=’, ‘hotbot’ => ‘http://hotbot.lycos.com/?SW=web&SM=MC&DC=10&DE=2&RG=NA&_v=2&MT=’, ‘imdb’ => ‘http://www.imdb.com/Find/?’, ‘lycos’ => ‘http://search.lycos.com/?npl=&query=’, ‘webcrawler’ => ‘http://dpxml.webcrawler.com/info.wbcrwl/search/web/’, ‘yahoo’ => ‘http://search.yahoo.com/bin/search?p=’ ); return $searchengine[$searchEngine] . $findString; }It’s pretty simple. Keep in mind that it’s up to the writer of any submodule to escape the data given. For instance, a search for “castle” at Yahoo would look like http://search.yahoo.com/bin/search?p=castle, whereas an excite search would look like http://msxml.excite.com/info.xcite/search/web/castle. I’ll probably eventually roll the existing “missing.php” into a dropdown search list, rather than it’s current layout, with the four which are hard-coded, and kind of ugly.
A sample of use would be:
$searchURL=searchString(htmlentities($SERVER[“REDIRECT_URL”]), ‘excite’); echo “Search Excite for: ”. htmlentities($SERVER[“REDIRECT_URL”] . “”;Happy searching, and have a great new year!
[Edit: I’ve rewritten it into an array, as it should have been in the first place.]