| 1 |
<?php |
<?php |
| 2 |
// $Id$ |
// $Id: serapi.module,v 1.1 2008/11/05 00:03:40 yaph Exp $ |
| 3 |
error_reporting(E_ALL); |
error_reporting(E_ALL); |
| 4 |
serapi_test(); |
serapi_test(); |
| 5 |
|
|
| 11 |
if (!$referer) { |
if (!$referer) { |
| 12 |
$referer = $_SERVER['HTTP_REFERER']; |
$referer = $_SERVER['HTTP_REFERER']; |
| 13 |
} |
} |
| 14 |
|
|
| 15 |
|
if (!valid_url($referer)) { |
| 16 |
|
return false; |
| 17 |
|
} |
| 18 |
|
|
| 19 |
$engines = array( |
$engines = array( |
| 20 |
'google' => array( |
'google' => array( |
| 21 |
'host_pattern' => 'www.google', |
'host_pattern' => 'www.google.', |
| 22 |
'query_param' => 'q' |
'query_param' => 'q' |
| 23 |
), |
), |
| 24 |
'yahoo' => array( |
'yahoo' => array( |
| 45 |
$param = $prop['query_param']; |
$param = $prop['query_param']; |
| 46 |
// check that the query contains the search parameter |
// check that the query contains the search parameter |
| 47 |
if (false !== strpos($query, $param)) { |
if (false !== strpos($query, $param)) { |
| 48 |
|
#@todo use http://php.net/parse_str |
| 49 |
if (preg_match("%" . $param . "=([^&]+)%", $query, $match)) { |
if (preg_match("%" . $param . "=([^&]+)%", $query, $match)) { |
| 50 |
$search = array(); |
$search = array(); |
| 51 |
$search_string = $match[1]; |
$search_string = $match[1]; |