1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

fix searches in specific languages

allow searches in the manual
This commit is contained in:
Nuno Lopes
2006-02-28 12:05:29 +00:00
parent 130e7e7237
commit b6d3b9dd18
2 changed files with 12 additions and 10 deletions

View File

@@ -19,10 +19,10 @@ $l = urlencode($l);
$s = (int) $_GET['start'];
$per_page = 15;
$valid_profiles = array('all', 'local', 'news', 'bugs', 'pear', 'pecl', 'talks');
$valid_profiles = array('all', 'local', 'manual', 'news', 'bugs', 'pear', 'pecl', 'talks');
$scope = in_array($_GET['p'], $valid_profiles) ? $_GET['p'] : 'all';
$data = file_get_contents("http://www.php.net/ws.php?profile=$scope&q=$q&results=$per_page&start=$s");
$data = file_get_contents("http://www.php.net/ws.php?profile=$scope&q=$q&lang=$l&results=$per_page&start=$s");
$res = unserialize($data);
// HTTP status line is passed on, signifies an error

18
ws.php
View File

@@ -8,21 +8,23 @@ $q = urlencode($raw);
$r = isset($_REQUEST['results']) ? (int)$_REQUEST['results'] : 10;
$s = isset($_REQUEST['start']) ? (int)$_REQUEST['start'] : 1;
$l = isset($_REQUEST['lang']) ? htmlspecialchars($_REQUEST['lang']) : 'en';
$sites = array( 'all'=>'site=php.net',
'local'=>'site=www.php.net',
'news'=>'site=news.php.net',
'bugs'=>'site=bugs.php.net',
'pear'=>'site=pear.php.net',
'pecl'=>'site=pecl.php.net',
'talks'=>'site=talks.php.net',
$sites = array( 'all'=>'php.net',
'local'=>'www.php.net',
'manual'=>'www.php.net',
'news'=>'news.php.net',
'bugs'=>'bugs.php.net',
'pear'=>'pear.php.net',
'pecl'=>'pecl.php.net',
'talks'=>'talks.php.net',
);
if(isset($sites[$_REQUEST['profile']])) {
$scope = $_REQUEST['profile'];
} else {
$scope = 'all';
}
$request = "{$conf['svc']}?appid={$conf['appid']}&query=$q&start=$s&results=$r&{$sites[$scope]}&language=$l&output=php";
$request = "{$conf['svc']}?appid={$conf['appid']}&query=$q&start=$s&results=$r&site={$sites[$scope]}&language=$l&output=php";
$data = @file_get_contents($request);
list($version,$status_code,$msg) = explode(' ',$http_response_header[0], 3);
if($status_code==200) echo $data;