1<?php 2 3$_SERVER['BASE_PAGE'] = 'search.php'; 4include_once __DIR__ . '/include/prepend.inc'; 5 6// --------------------------------------------------------------------------- 7 8$_FORM = &$_GET; 9 10// --------------------------------------------------------------------------- 11 12// We received something to search for 13if (!empty($_FORM['pattern'])) { 14 15 if (empty($_FORM['show'])) { 16 $_FORM['show'] = 'all'; 17 } 18 19 // Never allow a comma in the show string, that would confuse our JS 20 $_FORM['show'] = str_replace(",", "", $_FORM['show']); 21 22 $ucp = urlencode($_FORM['pattern']); 23 24 // Do redirections for external search engines 25 switch ($_FORM['show']) { 26 case "quickref" : 27 case "404quickref" : 28 $langparam = (isset($EXPL_LANG) ? "&lang=$EXPL_LANG" : ""); 29 mirror_redirect("/manual-lookup.php?pattern={$ucp}{$langparam}&scope={$_FORM['show']}"); 30 break; 31 32 case "manual": 33 case "404manual": 34 mirror_redirect($MYSITE . "results.php?q={$ucp}&p={$_FORM['show']}&l=$LANG"); 35 break; 36 37 // Covers the rest 38 default: 39 $p = urlencode($_FORM['show']); 40 mirror_redirect($MYSITE . "results.php?q={$ucp}&l=$LANG&p=$p"); 41 break; 42 } 43} 44 45// No pattern provided, print search page 46else { 47 48 // Print out common header 49 $link = [ 50 "rel" => "search", 51 "type" => "application/opensearchdescription+xml", 52 "href" => $MYSITE . "phpnetimprovedsearch.src", 53 "title" => "Add PHP.net search", 54 ]; 55 site_header("Search", ["link" => [$link], "current" => "help"]); 56 57 google_cse(); 58 site_footer(); 59} 60