| 1 |
<?php |
<?php |
| 2 |
// $Id: serapi.module,v 1.4 2008/11/05 10:38:04 yaph Exp $ |
// $Id: serapi.module,v 1.5 2008/11/05 11:32:55 yaph Exp $ |
| 3 |
error_reporting(E_ALL); |
error_reporting(E_ALL); |
| 4 |
|
|
| 5 |
/** |
/** |
| 107 |
'info' => t('Search Engine Referer Information'), |
'info' => t('Search Engine Referer Information'), |
| 108 |
'weight' => 0 |
'weight' => 0 |
| 109 |
); |
); |
|
// @todo move to a test script |
|
|
$blocks[1] = array( |
|
|
'info' => t('Search Engine Referer Test - Do not show this to your visitors!'), |
|
|
'weight' => 0 |
|
|
); |
|
| 110 |
return $blocks; |
return $blocks; |
| 111 |
} |
} |
| 112 |
elseif ('view' == $op) { |
elseif ('view' == $op) { |
| 115 |
$block['content'] = serapi_block_search_engine_information(); |
$block['content'] = serapi_block_search_engine_information(); |
| 116 |
$block['subject'] = t('Search Engine Referer Information'); |
$block['subject'] = t('Search Engine Referer Information'); |
| 117 |
break; |
break; |
|
case 1: |
|
|
$block['content'] = serapi_block_search_engine_test(); |
|
|
$block['subject'] = t('Search Engine Referer Test'); |
|
|
break; |
|
| 118 |
} |
} |
| 119 |
return $block; |
return $block; |
| 120 |
} |
} |
| 132 |
); |
); |
| 133 |
} |
} |
| 134 |
return false; |
return false; |
|
} |
|
|
|
|
|
/** |
|
|
* Calls serapi_get_search() for all test URLs and returns |
|
|
* a parsable string representation of the returned array |
|
|
* |
|
|
* @return String |
|
|
* A parsable string representation of the serapi_get_search() |
|
|
* test result |
|
|
*/ |
|
|
function serapi_block_search_engine_test() { |
|
|
$search_info = array_map('serapi_get_search', serapi_get_test_urls()); |
|
|
if (false !== $search_info) { |
|
|
return var_export($search_info, true); |
|
|
} |
|
|
} |
|
|
|
|
|
/** |
|
|
* Returns an array of possible referer URLs for testing purposes |
|
|
* |
|
|
* @return Array |
|
|
* An array of search engine result page URLs |
|
|
*/ |
|
|
function serapi_get_test_urls() { |
|
|
return array( |
|
|
// google |
|
|
'http://www.google.de/search?hl=de&q=drupal&btnG=Google-Suche&meta=', |
|
|
'http://www.google.com/search?q=drupal', |
|
|
'http://www.google.com/search?q=drupal+cms&ie=utf-8&oe=utf-8', |
|
|
// yahoo |
|
|
'http://search.yahoo.com/search?p=drupal&vc=&fr=yfp-t-501&toggle=1&cop=mss&ei=UTF-8', |
|
|
'http://de.search.yahoo.com/search?p=drupal&fr=yfp-t-501&ei=UTF-8&rd=r1', |
|
|
'http://de.search.yahoo.com/search?p=drupal+cms&ei=UTF-8&fr=moz2', |
|
|
// ask |
|
|
'http://de.ask.com/web?q=drupal&qsrc=0&o=0&l=dir&s=&part=&dm=lang', |
|
|
'http://www.ask.com/web?q=drupal&search=search&qsrc=0&o=312&l=dir', |
|
|
'http://de.ask.com/web?q=is+drupal+a+framework&qsrc=1&o=312&l=dir&s=&part=&dm=all', |
|
|
// live |
|
|
'http://search.live.com/results.aspx?q=drupal', |
|
|
'http://search.live.com/results.aspx?q=drupal+cms&go=&form=QBLH', |
|
|
'http://search.live.com/results.aspx?q=live+search+sucks&go=&form=QBLH', |
|
|
// aol actually sucks bad |
|
|
'http://search.aol.com/aol/search?s_it=searchbox.webhome&query=drupal+cms', |
|
|
'http://suche.aol.de/aol/search?q=drupal+cms&langRestrict=2', |
|
|
'http://busqueda.aol.es/aol/search?invocationType=topsearchbox&query=drupal&rp=', |
|
|
// altavista |
|
|
'http://www.altavista.com/web/results?itag=ody&q=drupal&kgs=1&kls=0', |
|
|
'http://de.altavista.com/web/results?itag=ody&q=drupal&kgs=1&kls=0', |
|
|
'http://es.altavista.com/web/results?itag=ody&q=drupal+content+management+framework&kgs=1&kls=0', |
|
|
// alltheweb |
|
|
'http://www.alltheweb.com/search?q=drupal+framework', |
|
|
'http://www.alltheweb.com/search?cat=web&cs=iso88591&q=drupal+cms&rys=0&itag=crv&_sb_lang=pref', |
|
|
'http://www.alltheweb.com/search?cat=web&cs=iso88591&q=drupal&rys=0&itag=crv&_sb_lang=pref' |
|
|
); |
|
| 135 |
} |
} |