Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Really umlaut-safe now;)' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Really umlaut-safe now;)
Authored by: kmue on May 23, '03 05:02:06AM

Some search engines are accepting UTF encoded chars but others are expecting ISO encoded chars.
So give them what they want...

Here is my version. All searches are working with I18 chars:

<?
/*
Add Mozilla-like keyword functionality to Safari's search bar.
http://www.macosxhints.com/article.php?story=20030519070642235

Author: sapporo@land.ru (inspired by a hint from nimatoad at
http://www.macosxhints.com/article.php?story=20030514035516436)

Umlaut hint by Baumi. Changes by kmue to make it work with I18 chars.
*/

// add your own keywords here
$keywords = array(
"vt" => "http://versiontracker.com/mp/new_search.m?productDB=mac&mode=Quick&OS_Filter=MacOSX&search=%query%&x=0&y=0",
"hints" => "http://www.macosxhints.com/search.php?query=%isoquery%&type=stories&mode=search&keyType=all",
"atw" => "http://www.alltheweb.com/search?q=%isoquery%&cs=iso-8859-1",
"t" => "http://s.teoma.com/search?q=%isoquery%",
"img" => "http://images.google.com/images?q=%query%&ie=UTF-8&oe=UTF-8"
);

// the original search term
$q = urldecode($_GET['q']);

// show help screen
if (preg_match("/^\s*(help|\?)/i", $q)) {
echo "<html><body><center><h2>Search help:</h2><table>";
echo "<tr><td><b>key</b></td><td><b>location</b></td></tr>\n";
while (list ($key, $location) = each ($keywords)) {
echo "<tr><td>$key:</td><td>$location</td></tr>\n";
}
echo "</table></body></html>";
exit;
}

// search for matching keyword and redirect on success
while (list ($key, $location) = each ($keywords)) {
if (preg_match("/^\s*$key\s+(.*)/i", $q, $matches)) {
if (preg_match("/%isoquery%/", $location)) {
$val = str_replace("%isoquery%", urlencode(utf8_decode($matches[1])), $location);
} else {
$val = str_replace("%query%", urlencode($matches[1]), $location);
}
header("Location: $val");
exit;
}
}

// default to google.com
header("Location: http://www.google.com/search?q=".urlencode($_GET['q'])."&ie=UTF-8&oe=UTF-8");
?>



[ Reply to This | # ]
Really umlaut-safe now;)
Authored by: tnagpal on May 23, '03 04:16:35PM

I'm really having problems with this script, when I try a search I get a 500 Internal Server Error.

If I type in tail /var/log/httpd/error_log, I get the following:

[Fri May 23 15:08:46 2003] [error] (8)Exec format error: exec of /Library/WebServer/CGI-Executables/search.php failed

[Fri May 23 15:08:46 2003] [error] [client 127.0.0.1] Premature end of script headers: /Library/WebServer/CGI-Executables/search.php

I chmodded the file to 755 and still get this error, anyone able to help?



[ Reply to This | # ]