|
-
Information Architect
My Web Command Line
I was so frustrated today that YubNub had a lot of cryptic commands for the services I'm using and the short ones are all taken, so what do you do? Yes, you create your own web command line. 
http://www.mindshareprojects.com/webcommandline.php
Here's the php code for everyone that wants to do the same:
PHP Code:
<?php
$search = trim($_GET['c']);
$splitat = strpos($search,' ');
$command = substr($search,0,$splitat);
$parameter = substr($search,$splitat+1);
if ($command == 'leo' || $command == 'l'){
header("Location: http://dict.leo.org/?search=".urlencode($parameter));
exit(0);
}
if ($command == 'digg' || $command == 'd'){
header("Location: http://www.digg.com/search?section=news&s=".urlencode($parameter));
exit(0);
}
if ($command == 'reddit' || $command == 'r'){
header("Location: http://reddit.com/search?q=".urlencode($parameter));
exit(0);
}
if ($command == 'imdb' || $command == 'i'){
header("Location: http://www.imdb.com/find?s=all&q=".urlencode($parameter));
exit(0);
}
if ($command == 'wiki' || $command == 'w'){
header("Location: http://en.wikipedia.org/wiki/".urlencode($parameter));
exit(0);
}
if ($command == 'gmail' || $command == 'g'){
header("Location: https://gmail.google.com/gmail?search=query&q=".urlencode($parameter)."&view=tl&fs=1");
exit(0);
}
if ($command == 'php' || $command == 'p'){
header("Location: http://www.php.net/".urlencode($parameter));
exit(0);
}
if ($command == 'fk' || $command == 'f'){
header("Location: http://board.flashkit.com/board/search.php?do=process&query=".urlencode($parameter));
exit(0);
}
if ($command == 'whois' || $command == 'wi'){
header("Location: http://whois.sc/".urlencode($parameter));
exit(0);
}
if ($command == 'slang' || $command == 's'){
header("Location: http://www.urbandictionary.com/define.php?term=".urlencode($parameter)."&r=f");
exit(0);
}
if ($command == 'css' || $command == 'c'){
header("Location: http://cssdocs.org/".urlencode($parameter));
exit(0);
}
if ($command == 'lorem' || $command == 'li'){
header("Location: http://www.lipsum.com/feed/html?amount=".urlencode($parameter));
exit(0);
}
if ($command == 'validate' || $command == 'v'){
header("Location: http://validator.w3.org/check?uri=".urlencode($parameter));
exit(0);
}
if ($command == 'product' || $command == 'ps'){
header("Location: http://www.google.com/products?q=".urlencode($parameter));
exit(0);
}
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">'."\n";
echo '<html>'."\n";
echo '<head>'."\n";
echo ' <title>Web Command Line | Mind Share Projects | Fredi Bach</title>'."\n";
echo ' <style type="text/css">'."\n";
echo ' body { font-family: Verdana, Helvetica, Geneva, Arial, sans-serif; font-size: 12px; line-height: 14pt; color: #333; background-color: #f2f2f2; margin: 0px; }'."\n";
echo ' 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; }'."\n";
echo ' 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; }'."\n";
echo ' #commandform { margin-left: 60px; }'."\n";
echo ' #commandtable { margin-left: 25px; width: 700px; }'."\n";
echo ' #tabledesc { font-size: 14px; font-weight: bold; background-color: #ddd; }'."\n";
echo ' td { margin: 2px; padding: 2px; padding-left: 6px; background-color: #fff; }'."\n";
echo ' #footer { margin-left: 25px; margin-top: 20px; margin-bottom: 20px; }'."\n";
echo ' </style>'."\n";
echo '</head>'."\n";
echo '<body>'."\n";
echo '<h1>Web Command Line</h1>'."\n";
echo '<div id="commandform"><form action="redirect.php" method="get" name="input_box">'."\n";
echo '<input type="text" name="c" size="55" value=""/>'."\n";
echo '<input type="submit" value="Enter" />'."\n";
echo '</form></div>'."\n";
echo '<h2>Installation Help (Firefox)</h2>'."\n";
echo '<ul><li>Right-click the input box above</li>'."\n";
echo '<li>Click "Add a Keyword for this Search"</li>'."\n";
echo '<li>For the Name, enter "Web Command Line" and for the Keyword, enter "c" for command</li>'."\n";
echo '<li>Press OK</li>'."\n";
echo '<li>Now you can enter "c yourcommand" into the address bar to use this web command line</li></ul>'."\n";
echo '<h2>Commands</h2>'."\n";
echo '<table id="commandtable"><tr><td id="tabledesc">Command</td><td id="tabledesc">Short</td><td id="tabledesc">Parameter</td><td id="tabledesc">Explanation</td></tr>'."\n";
echo '<tr><td><b>leo</b></td><td>l</td><td>word</td><td>Translate from German to English or from English to German</td></tr>'."\n";
echo '<tr><td><b>digg</b></td><td>d</td><td>searchstring</td><td>Search Digg News</td></tr>'."\n";
echo '<tr><td><b>reddit</b></td><td>r</td><td>searchstring</td><td>Search Reddit</td></tr>'."\n";
echo '<tr><td><b>imdb</b></td><td>i</td><td>searchstring</td><td>Search the International Movie Database</td></tr>'."\n";
echo '<tr><td><b>wiki</b></td><td>w</td><td>page</td><td>Search a Wikipedia page</td></tr>'."\n";
echo '<tr><td><b>gmail</b></td><td>g</td><td>searchstring</td><td>Search your own Gmail account (if logged in)</td></tr>'."\n";
echo '<tr><td><b>php</b></td><td>p</td><td>searchstring</td><td>Search the php site</td></tr>'."\n";
echo '<tr><td><b>fk</b></td><td>f</td><td>searchstring</td><td>Search the Flashkit Forums</td></tr>'."\n";
echo '<tr><td><b>whois</b></td><td>wi</td><td>domain</td><td>Look up the whois informations for a domain</td></tr>'."\n";
echo '<tr><td><b>slang</b></td><td>s</td><td>word</td><td>Check the urban dictionary what this slang means</td></tr>'."\n";
echo '<tr><td><b>css</b></td><td>c</td><td>searchstring</td><td>Search the W3C CSS documentation</td></tr>'."\n";
echo '<tr><td><b>lorem</b></td><td>li</td><td>paragraphs</td><td>Get a specific number of lorem ipsum paragraphs</td></tr>'."\n";
echo '<tr><td><b>validate</b></td><td>v</td><td>url</td><td>W3C validate a given url</td></tr>'."\n";
echo '<tr><td><b>product</b></td><td>ps</td><td>name</td><td>Do a Google product search</td></tr>'."\n";
echo '</table>'."\n";
echo '<div id="footer">(c) 2007 by Fredi Bach / Mind Share Projects</div>'."\n";
echo '</body>';
?>
Enjoy. 
Fredi
Last edited by Subway; 06-10-2007 at 01:48 PM.
-
Script kiddie
Does it only work through installation into Firefox? Because I tried typing "f raycasting" to test it in Safari, and it just redirected me to your website. :s
-
Information Architect
That's an error ... working on it. 
Edit: Fixed. I changed the url of the script and forget to change it in the form as well. I simple have'nt tested the form after the url change. Of course the form url has to be the same as the script name, in this case "webcommandline.php".
Fredi
Last edited by Subway; 06-10-2007 at 04:17 PM.
-
Senior Member
Save some processing power and cut down the php file size. 
Code:
function returnsite($url)
{ global $parameter;
header("Location: http://".$url.urlencode($parameter));
exit(0);
}
switch($command)
{
case 'leo': case 'l':
returnsite("dict.leo.org/?search=");
case 'digg': case'd':
returnsite("www.digg.com/search?section=news&s=");
case 'reddit': case'r':
returnsite("reddit.com/search?q=");
case 'imdb': case 'i':
returnsite("www.imdb.com/find?s=all&q=");
case 'wiki' : case 'w':
returnsite("en.wikipedia.org/wiki/");
case 'gmail' : case 'g':
returnsite("gmail.google.com/gmail?search=query&view=tl&fs=1&q=");
case 'php' : case 'p':
returnsite("www.php.net/");
case 'fk' : case 'f':
returnsite("board.flashkit.com/board/search.php?do=process&query=");
case 'whois' : case 'wi':
returnsite("whois.sc/");
case 'slang' : case 's':
returnsite("www.urbandictionary.com/define.php?r=f&term");
case 'css' : case 'c':
returnsite("cssdocs.org/");
case 'lorem' : case 'li':
returnsite("www.lipsum.com/feed/html?amount=");
case 'validate' : case 'v':
returnsite("validator.w3.org/check?uri=");
case 'product' : case 'ps':
returnsite("www.google.com/products?q=");
}
Last edited by Genesis F5; 06-10-2007 at 05:23 PM.
-
Script kiddie
Sweet!
Any way of incorporating this as a Safari plugin? Hell, I reckon a simple Flash app could do the same job with a getURL() code.
-
Information Architect
Have a look: http://slashdot.org/comments.pl?sid=153340&cid=12866050
You should be able to do the same with this script.
 Originally Posted by Genesis F5
Save some processing power and cut down the php file size. 
As if anyone would notice those one or two milliseconds. 
Thx anyway. 
Fredi
Last edited by Subway; 06-10-2007 at 04:56 PM.
-
Senior Member
I know, but I couldn't resist. Redundancy is my kryptonite.
-
supervillain
Sorta reminds me of Ranchero Huevos...
-
Information Architect
 Originally Posted by Genesis F5
I know, but I couldn't resist.  Redundancy is my kryptonite.
Btw, your script does'nt work with Gmail and probably the urban dictionary. You've missed to add the url parameters that came after the search parameter.
Here's the fixed version:
PHP Code:
<?php
$search = trim($_GET['c']);
$splitat = strpos($search,' ');
$command = substr($search,0,$splitat);
$parameter = substr($search,$splitat+1);
function returnsite($url){
global $parameter;
header("Location: ".$url.urlencode($parameter));
exit(0);
}
switch($command){
case 'leo': case 'l':
returnsite("http://dict.leo.org/?search=");
case 'digg': case'd':
returnsite("http://www.digg.com/search?section=news&s=");
case 'reddit': case'r':
returnsite("http://reddit.com/search?q=");
case 'imdb': case 'i':
returnsite("http://www.imdb.com/find?s=all&q=");
case 'wiki' : case 'w':
returnsite("http://en.wikipedia.org/wiki/");
case 'gmail' : case 'g':
returnsite("https://gmail.google.com/gmail?search=query&view=tl&fs=1&q=");
case 'php' : case 'p':
returnsite("http://www.php.net/");
case 'fk' : case 'f':
returnsite("http://board.flashkit.com/board/search.php?do=process&query=");
case 'whois' : case 'wi':
returnsite("http://whois.sc/");
case 'slang' : case 's':
returnsite("http://www.urbandictionary.com/define.php?r=f&term=");
case 'css' : case 'c':
returnsite("http://cssdocs.org/");
case 'lorem' : case 'li':
returnsite("http://www.lipsum.com/feed/html?amount=");
case 'validate' : case 'v':
returnsite("http://validator.w3.org/check?uri=");
case 'product' : case 'ps':
returnsite("http://www.google.com/products?q=");
}
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">'."\n";
echo '<html>'."\n";
echo '<head>'."\n";
echo ' <title>Web Command Line | Mind Share Projects | Fredi Bach</title>'."\n";
echo ' <style type="text/css">'."\n";
echo ' body { font-family: Verdana, Helvetica, Geneva, Arial, sans-serif; font-size: 12px; line-height: 14pt; color: #333; background-color: #f2f2f2; margin: 0px; }'."\n";
echo ' 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; }'."\n";
echo ' 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; }'."\n";
echo ' #commandform { margin-left: 60px; }'."\n";
echo ' #commandtable { margin-left: 25px; width: 700px; }'."\n";
echo ' #tabledesc { font-size: 14px; font-weight: bold; background-color: #ddd; }'."\n";
echo ' td { margin: 2px; padding: 2px; padding-left: 6px; background-color: #fff; }'."\n";
echo ' #footer { margin-left: 25px; margin-top: 20px; margin-bottom: 20px; }'."\n";
echo ' </style>'."\n";
echo '</head>'."\n";
echo '<body>'."\n";
echo '<h1>Web Command Line</h1>'."\n";
echo '<div id="commandform"><form action="webcommandline.php" method="get" name="input_box">'."\n";
echo '<input type="text" name="c" size="55" value=""/>'."\n";
echo '<input type="submit" value="Enter" />'."\n";
echo '</form></div>'."\n";
echo '<h2>Installation Help (Firefox)</h2>'."\n";
echo '<ul><li>Right-click the input box above</li>'."\n";
echo '<li>Click "Add a Keyword for this Search"</li>'."\n";
echo '<li>For the Name, enter "Web Command Line" and for the Keyword, enter "c" for command</li>'."\n";
echo '<li>Press OK</li>'."\n";
echo '<li>Now you can enter "c yourcommand" into the address bar to use this web command line</li></ul>'."\n";
echo '<h2>Commands</h2>'."\n";
echo '<table id="commandtable"><tr><td id="tabledesc">Command</td><td id="tabledesc">Short</td><td id="tabledesc">Parameter</td><td id="tabledesc">Explanation</td></tr>'."\n";
echo '<tr><td><b>leo</b></td><td>l</td><td>word</td><td>Translate from German to English or from English to German</td></tr>'."\n";
echo '<tr><td><b>digg</b></td><td>d</td><td>searchstring</td><td>Search Digg News</td></tr>'."\n";
echo '<tr><td><b>reddit</b></td><td>r</td><td>searchstring</td><td>Search Reddit</td></tr>'."\n";
echo '<tr><td><b>imdb</b></td><td>i</td><td>searchstring</td><td>Search the International Movie Database</td></tr>'."\n";
echo '<tr><td><b>wiki</b></td><td>w</td><td>page</td><td>Search a Wikipedia page</td></tr>'."\n";
echo '<tr><td><b>gmail</b></td><td>g</td><td>searchstring</td><td>Search your own Gmail account (if logged in)</td></tr>'."\n";
echo '<tr><td><b>php</b></td><td>p</td><td>searchstring</td><td>Search the php site</td></tr>'."\n";
echo '<tr><td><b>fk</b></td><td>f</td><td>searchstring</td><td>Search the Flashkit Forums</td></tr>'."\n";
echo '<tr><td><b>whois</b></td><td>wi</td><td>domain</td><td>Look up the whois informations for a domain</td></tr>'."\n";
echo '<tr><td><b>slang</b></td><td>s</td><td>word</td><td>Check the urban dictionary what this slang means</td></tr>'."\n";
echo '<tr><td><b>css</b></td><td>c</td><td>searchstring</td><td>Search the W3C CSS documentation</td></tr>'."\n";
echo '<tr><td><b>lorem</b></td><td>li</td><td>paragraphs</td><td>Get a specific number of lorem ipsum paragraphs</td></tr>'."\n";
echo '<tr><td><b>validate</b></td><td>v</td><td>url</td><td>W3C validate a given url</td></tr>'."\n";
echo '<tr><td><b>product</b></td><td>p</td><td>name</td><td>Do a Google product search</td></tr>'."\n";
echo '</table>'."\n";
echo '<div id="footer">(c) 2007 by Fredi Bach / Mind Share Projects</div>'."\n";
echo '</body>';
?>
Oh and I think we can get rid of the switch breaks as we already use the exit function ... one moment ... yes, we can (script changed).
Fredi
Last edited by Subway; 06-10-2007 at 05:07 PM.
-
Senior Member
Ah, thank you very much. Updated.
Edit: Good call on the breaks. See, you're getting the hang of it. At 1000 visitors a day and an average of 3 seconds saved, you've saved the world a whopping 18 hours a year!
Last edited by Genesis F5; 06-10-2007 at 05:17 PM.
-
Information Architect
I made it even smaller and easier to edit, we really don't need to echo all those html tags:
PHP Code:
<?php
$search = trim($_GET['c']);
$splitat = strpos($search,' ');
$command = substr($search,0,$splitat);
$parameter = substr($search,$splitat+1);
function returnsite($url){
global $parameter;
header("Location: ".$url.urlencode($parameter));
exit(0);
}
switch($command){
case 'leo': case 'l':
returnsite("http://dict.leo.org/?search=");
case 'digg': case'd':
returnsite("http://www.digg.com/search?section=news&s=");
case 'reddit': case'r':
returnsite("http://reddit.com/search?q=");
case 'imdb': case 'i':
returnsite("http://www.imdb.com/find?s=all&q=");
case 'wiki' : case 'w':
returnsite("http://en.wikipedia.org/wiki/");
case 'gmail' : case 'g':
returnsite("https://gmail.google.com/gmail?search=query&view=tl&fs=1&q=");
case 'php' : case 'p':
returnsite("http://www.php.net/");
case 'fk' : case 'f':
returnsite("http://board.flashkit.com/board/search.php?do=process&query=");
case 'whois' : case 'wi':
returnsite("http://whois.sc/");
case 'slang' : case 's':
returnsite("http://www.urbandictionary.com/define.php?r=f&term=");
case 'css' : case 'c':
returnsite("http://cssdocs.org/");
case 'lorem' : case 'li':
returnsite("http://www.lipsum.com/feed/html?amount=");
case 'validate' : case 'v':
returnsite("http://validator.w3.org/check?uri=");
case 'product' : case 'ps':
returnsite("http://www.google.com/products?q=");
}
?>
<!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; background-color: #ddd; }
td { margin: 2px; padding: 2px; padding-left: 6px; background-color: #fff; }
#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">Short</td><td id="tabledesc">Parameter</td><td id="tabledesc">Explanation</td></tr>
<tr><td><b>leo</b></td><td>l</td><td>word</td><td>Translate from German to English or from English to German</td></tr>
<tr><td><b>digg</b></td><td>d</td><td>searchstring</td><td>Search Digg News</td></tr>
<tr><td><b>reddit</b></td><td>r</td><td>searchstring</td><td>Search Reddit</td></tr>
<tr><td><b>imdb</b></td><td>i</td><td>searchstring</td><td>Search the International Movie Database</td></tr>
<tr><td><b>wiki</b></td><td>w</td><td>page</td><td>Search a Wikipedia page</td></tr>
<tr><td><b>gmail</b></td><td>g</td><td>searchstring</td><td>Search your own Gmail account (if logged in)</td></tr>
<tr><td><b>php</b></td><td>p</td><td>searchstring</td><td>Search the php site</td></tr>
<tr><td><b>fk</b></td><td>f</td><td>searchstring</td><td>Search the Flashkit Forums</td></tr>
<tr><td><b>whois</b></td><td>wi</td><td>domain</td><td>Look up the whois informations for a domain</td></tr>
<tr><td><b>slang</b></td><td>s</td><td>word</td><td>Check the urban dictionary what this slang means</td></tr>
<tr><td><b>css</b></td><td>c</td><td>searchstring</td><td>Search the W3C CSS documentation</td></tr>
<tr><td><b>lorem</b></td><td>li</td><td>paragraphs</td><td>Get a specific number of lorem ipsum paragraphs</td></tr>
<tr><td><b>validate</b></td><td>v</td><td>url</td><td>W3C validate a given url</td></tr>
<tr><td><b>product</b></td><td>p</td><td>name</td><td>Do a Google product search</td></tr>
</table>
<div id="footer">(c) 2007 by Fredi Bach / Mind Share Projects</div>
</body>
Fredi
-
Senior Member
If it wasn't for Google using that darn https protocol it could be even smaller if we set the protocol in the function. I guess we could put the http part in there, but readability would be poor.
Edit: Nope! It works. Updated again. How small is this going to get!?
Last edited by Genesis F5; 06-10-2007 at 05:23 PM.
-
Information Architect
A better exercise would be to add a basic useraccount (db) where people can add their own personal commands. Getting closer to what YubNub does, but with commands that are directly linked to individual users and not to everyone. 
Fredi
-
Flashkit historian
-
poet and narcisist
what about something extra? add params to the commands
like for digg: digg -t type -a searchstring
-t type
-a: all, -u: upcoming
-
Information Architect
Good idea. But first I have to finish jMe or Gerbick bans me from this board. 
Fredi
-
supervillain
-
Information Architect
Ok, I just could'nt resist, here's a new version that supports control parameters:
PHP 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';
$commands['l']['']->useparameter = '';
// 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 = 'Search Digg News - Frontpage Stories';
$commands['digg']['u']->url = 'www.digg.com/search?section=news&type=both&area=dig&sort=new&s=';
$commands['digg']['u']->desc = 'Search Digg News - Upcoming Stories';
$commands['d']['']->usecommand = 'digg';
$commands['d']['']->useparameter = '';
// reddit.com
$commands['reddit']['']->url = 'reddit.com/search?q=';
$commands['reddit']['']->value = 'searchstring';
$commands['reddit']['']->desc = 'Search Reddit';
$commands['r']['']->usecommand = 'reddit';
$commands['r']['']->useparameter = '';
// 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';
$commands['i']['']->useparameter = '';
// wikipedia.org
$commands['wiki']['']->url = 'en.wikipedia.org/wiki/';
$commands['wiki']['']->value = 'page';
$commands['wiki']['']->desc = 'Search an English Wikipedia page';
$commands['w']['']->usecommand = 'wiki';
$commands['w']['']->useparameter = '';
// 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';
$commands['g']['']->useparameter = '';
// php.net
$commands['php']['']->url = 'www.php.net/';
$commands['php']['']->value = 'searchstring';
$commands['php']['']->desc = 'Search the php site';
$commands['p']['']->usecommand = 'php';
$commands['p']['']->useparameter = '';
// 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';
$commands['f']['']->useparameter = '';
// 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';
$commands['wi']['']->useparameter = '';
// 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';
$commands['s']['']->useparameter = '';
// cssdocs.org
$commands['css']['']->url = 'cssdocs.org/';
$commands['css']['']->value = 'searchstring';
$commands['css']['']->desc = 'Search the W3C CSS documentation';
$commands['c']['']->usecommand = 'css';
$commands['c']['']->useparameter = '';
// 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';
$commands['li']['']->useparameter = '';
// 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';
$commands['v']['']->useparameter = '';
// 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';
$commands['ps']['']->useparameter = '';
$search = trim($_GET['c']);
$splitat = strpos($search,' ');
$command = substr($search,0,$splitat);
$value = substr($search,$splitat+1);
$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; background-color: #ddd; }
td { margin: 2px; padding: 2px; padding-left: 6px; background-color: #fff; }
#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 (isset($commands[$k1][$k2]->usecommand)){
echo '<tr><td>'.$k1.'</td>';
} else {
echo '<tr><td><b>'.$k1.'</b></td>';
}
if ($k2 != ''){
echo '<td>-'.$k2.'</td>';
} else {
echo '<td> </td>';
}
if ($commands[$k1][$k2]->value != ''){
echo '<td>'.$commands[$k1][$k2]->value.'</td>';
} else {
echo '<td>"</td>';
}
if (isset($commands[$k1][$k2]->usecommand)){
echo '<td>Short Command for "'.$commands[$k1][$k2]->usecommand.'"</td></tr>'."\n";
} else {
echo '<td>'.$commands[$k1][$k2]->desc.'</td></tr>'."\n";
}
}
}
?>
</table>
<div id="footer">(c) 2007 by Fredi Bach / Mind Share Projects</div>
</body>
For example if you want to search only the frontpage stories at digg for iphone news, use it like this: digg -f iphone
The description table is a bit hard to read, working on that one.
Edit: Ok, better. Now I just have to add some more controle parameters. 
Fredi
Last edited by Subway; 06-11-2007 at 11:16 AM.
-
Retired SCORM Guru
Subs, what about packaging this as a XUL app that works like Launchy/Quicksilver in the browser, with a keystroke, that automatically indexes your bookmarks / history?
"What really bugs me is that my mom had the audacity to call Flash Kit a bunch of 'inept jack-asses'." - sk8Krog
...and now I have tape all over my face.
-
Information Architect
I'm not fluent in XUL ... maybe Ihoss steps in at some time. 
Fredi
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|