Last active
December 24, 2018 14:10
-
-
Save mspreij/931b24a69810ce1293951544c8c78fc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$q = $_GET['q']; | |
$googStump = "https://www.google.com/search?q="; | |
$gooogle = $googStump.rawurlencode($q); | |
// custom keys | |
$keys = [ | |
'hn' => 'https://news.ycombinator.com/', | |
]; | |
if (isset($keys[$q])) { | |
$url = $keys[$q]; | |
// custom key | |
}elseif (substr($q, 0, 2)==='g ') { | |
// force google (in case you're googling for something which is also a custom key) | |
$url = $googStump.rawurlencode(substr($q, 2)); | |
}else{ | |
// default to google | |
$url = $gooogle; | |
} | |
header("Location: $url"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment