Here's the latest version. Fixed some bugs with the short commands:
FrediPHP Code:<?php
$commands = array();
// dict.leo.org
$commands['leo']['']->url = 'dict.leo.org/?search=';
$commands['leo']['']->value = 'word';
$commands['leo']['']->desc = 'Translate from German to English or from English to German';
$commands['l']['']->usecommand = 'leo';
// digg.com
$commands['digg']['']->url = 'www.digg.com/search?section=news&s=';
$commands['digg']['']->value = 'searchstring';
$commands['digg']['']->desc = 'Search Digg News';
$commands['digg']['f']->url = 'www.digg.com/search?section=news&type=both&area=promoted&sort=new&s=';
$commands['digg']['f']->desc = 'Frontpage Stories';
$commands['digg']['u']->url = 'www.digg.com/search?section=news&type=both&area=dig&sort=new&s=';
$commands['digg']['u']->desc = 'Upcoming Stories';
$commands['d']['']->usecommand = 'digg';
// reddit.com
$commands['reddit']['']->url = 'reddit.com/search?q=';
$commands['reddit']['']->value = 'searchstring';
$commands['reddit']['']->desc = 'Search Reddit';
$commands['reddit']['r']->url = 'reddit.com/search?s=rank&q=';
$commands['reddit']['r']->desc = 'Sort by rank';
$commands['r']['']->usecommand = 'reddit';
// imdb.com
$commands['imdb']['']->url = 'www.imdb.com/find?s=all&q=';
$commands['imdb']['']->value = 'searchstring';
$commands['imdb']['']->desc = 'Search the International Movie Database';
$commands['i']['']->usecommand = 'imdb';
// wikipedia.org
$commands['wiki']['']->url = 'en.wikipedia.org/wiki/';
$commands['wiki']['']->value = 'page';
$commands['wiki']['']->desc = 'Search an English Wikipedia page';
$commands['wiki']['d']->url = 'de.wikipedia.org/wiki/';
$commands['wiki']['d']->desc = 'German Wikipedia';
$commands['w']['']->usecommand = 'wiki';
// gmail.google.com
$commands['gmail']['']->url = 'gmail.google.com/gmail?search=query&view=tl&fs=1&q=';
$commands['gmail']['']->value = 'searchstring';
$commands['gmail']['']->desc = 'Search your own Gmail account (if logged in)';
$commands['g']['']->usecommand = 'gmail';
// php.net
$commands['php']['']->url = 'www.php.net/';
$commands['php']['']->value = 'searchstring';
$commands['php']['']->desc = 'Search the php site';
$commands['p']['']->usecommand = 'php';
// flashkit.com
$commands['fk']['']->url = 'board.flashkit.com/board/search.php?do=process&query=';
$commands['fk']['']->value = 'searchstring';
$commands['fk']['']->desc = 'Search the Flashkit Forums';
$commands['f']['']->usecommand = 'fk';
// whois.sc
$commands['whois']['']->url = 'whois.sc/';
$commands['whois']['']->value = 'domain';
$commands['whois']['']->desc = 'Look up the whois informations for a domain';
$commands['wi']['']->usecommand = 'whois';
// urbandictionary.com
$commands['slang']['']->url = 'www.urbandictionary.com/define.php?r=f&term=';
$commands['slang']['']->value = 'word';
$commands['slang']['']->desc = 'Check the urban dictionary what this slang means';
$commands['s']['']->usecommand = 'slang';
// cssdocs.org
$commands['css']['']->url = 'cssdocs.org/';
$commands['css']['']->value = 'searchstring';
$commands['css']['']->desc = 'Search the W3C CSS documentation';
$commands['c']['']->usecommand = 'css';
// lipsum.com
$commands['lorem']['']->url = 'www.lipsum.com/feed/html?amount=';
$commands['lorem']['']->value = 'paragraphs';
$commands['lorem']['']->desc = 'Get a specific number of lorem ipsum paragraphs';
$commands['li']['']->usecommand = 'lorem';
// validator.w3.org
$commands['validate']['']->url = 'validator.w3.org/check?uri=';
$commands['validate']['']->value = 'url';
$commands['validate']['']->desc = 'W3C validate a given url';
$commands['v']['']->usecommand = 'validate';
// google.com/products
$commands['product']['']->short = 'ps';
$commands['product']['']->url = 'www.google.com/products?q=';
$commands['product']['']->value = 'name';
$commands['product']['']->desc = 'Do a Google product search';
$commands['ps']['']->usecommand = 'product';
$search = trim($_GET['c']);
$splitat = strpos($search,' ');
$command = substr($search,0,$splitat);
$value = substr($search,$splitat+1);
if (isset($commands[$command]['']->usecommand)){
$command = $commands[$command][$parameter]->usecommand;
}
$parameter = '';
if ($value{0} == '-'){
if (isset($commands[$command][$value{1}])){
$parameter = $value{1};
$value = substr($value,strpos($value,' ')+1);
}
}
if (isset($commands[$command][$parameter])){
header("Location: http://".$commands[$command][$parameter]->url.urlencode($value));
exit(0);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Web Command Line | Mind Share Projects | Fredi Bach</title>
<style type="text/css">
body { font-family: Verdana, Helvetica, Geneva, Arial, sans-serif; font-size: 12px; line-height: 14pt; color: #333; background-color: #f2f2f2; margin: 0px; }
h1 { font-family: Georgia, "Times New Roman", Times, serif; background-color: #fff; padding: 8px; padding-left: 16px; padding-top: 50px; border-bottom: 2px #ccc solid; margin-top: 0px; }
h2 { font-family: Georgia, "Times New Roman", Times, serif; background-color: #fff; padding: 4px; padding-left: 16px; border-bottom: 2px #ccc solid; border-top: 2px #ccc solid; }
#commandform { margin-left: 60px; }
#commandtable { margin-left: 25px; width: 700px; }
#tabledesc { font-size: 14px; font-weight: bold; color: #eee; background-color: #666; }
td { margin: 2px; padding: 2px; padding-left: 6px; background-color: #fff; }
.maintd { background-color: #dddddd; }
#footer { margin-left: 25px; margin-top: 20px; margin-bottom: 20px; }
</style>
</head>
<body>
<h1>Web Command Line</h1>
<div id="commandform"><form action="webcommandline.php" method="get" name="input_box">
<input type="text" name="c" size="55" value=""/>
<input type="submit" value="Enter" />
</form></div>
<h2>Installation Help (Firefox)</h2>
<ul><li>Right-click the input box above</li>
<li>Click "Add a Keyword for this Search"</li>
<li>For the Name, enter "Web Command Line" and for the Keyword, enter "c" for command</li>
<li>Press OK</li>
<li>Now you can enter "c yourcommand" into the address bar to use this web command line</li></ul>
<h2>Commands</h2>
<table id="commandtable"><tr><td id="tabledesc">Command</td><td id="tabledesc">Parameter</td><td id="tabledesc">Value</td><td id="tabledesc">Explanation</td></tr>
<?php
foreach($commands as $k1 => $v1) {
foreach ($v1 as $k2 => $v2) {
if ($commands[$k1][$k2]->value != ''){
$tdstyle = ' class="maintd"';
} else {
$tdstyle = '';
}
if (isset($commands[$k1][$k2]->usecommand)){
echo '<tr><td'.$tdstyle.'>'.$k1.'</td>';
} else {
echo '<tr><td'.$tdstyle.'><b>'.$k1.'</b></td>';
}
if ($k2 != ''){
echo '<td'.$tdstyle.'>-'.$k2.'</td>';
} else {
echo '<td'.$tdstyle.'> </td>';
}
if ($commands[$k1][$k2]->value != ''){
echo '<td'.$tdstyle.'>'.$commands[$k1][$k2]->value.'</td>';
} else {
echo '<td'.$tdstyle.'>"</td>';
}
if (isset($commands[$k1][$k2]->usecommand)){
echo '<td'.$tdstyle.'>Short command for "'.$commands[$k1][$k2]->usecommand.'"</td></tr>'."\n";
} else {
echo '<td'.$tdstyle.'>'.$commands[$k1][$k2]->desc.'</td></tr>'."\n";
}
}
}
?>
</table>
<div id="footer">(c) 2007 by Fredi Bach / Mind Share Projects</div>
</body>
