forked from php/web-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
66 lines (51 loc) · 1.83 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php // vim: et
$_SERVER['BASE_PAGE'] = 'search.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc';
// ---------------------------------------------------------------------------
$_FORM = &$_GET;
// ---------------------------------------------------------------------------
// If PHP added some slashes to quotes, get rid of them
if ($MQ) {
foreach ($_FORM as $name => $value) {
$_FORM[$name] = stripslashes($value);
}
}
// We received something to search for
if (!empty($_FORM['pattern'])) {
if (empty($_FORM['show'])) {
$_FORM['show'] = 'all';
}
// Never allow a comma in the show string, that would confuse our JS
$_FORM['show'] = str_replace(",", "", $_FORM['show']);
$ucp = urlencode($_FORM['pattern']);
// Do redirections for external search engines
switch ($_FORM['show']) {
case "quickref" :
case "404quickref" :
$langparam = (isset($EXPL_LANG) ? "&lang=$EXPL_LANG" : "");
mirror_redirect("/manual-lookup.php?pattern={$ucp}{$langparam}&scope={$_FORM['show']}");
break;
case "manual":
case "404manual":
mirror_redirect($MYSITE . "results.php?q={$ucp}&p={$_FORM['show']}&l=$LANG");
break;
// Covers the rest
default:
$p = urlencode($_FORM['show']);
mirror_redirect($MYSITE . "results.php?q={$ucp}&l=$LANG&p=$p");
break;
}
}
// No pattern provided, print search page
else {
// Print out common header
$link = array(
"rel" => "search",
"type" => "application/opensearchdescription+xml",
"href" => $MYSITE . "phpnetimprovedsearch.src",
"title" => "Add PHP.net search"
);
site_header("Search", array("link" => array($link), "current" => "help"));
google_cse();
site_footer();
}