LibreY- privacy respecting meta search engine |
git clone git://git.acid.vegas/LibreY.git |
Log | Files | Refs | Archive | README | LICENSE |
special.php (2811B)
1 <?php 2 3 function check_for_special_search($query) { 4 if (isset($_COOKIE["disable_special"])) 5 return 0; 6 7 $query_lower = strtolower($query); 8 $split_query = explode(" ", $query); 9 10 if (strpos($query_lower, "to") && count($split_query) >= 4) // currency 11 { 12 $amount_to_convert = floatval($split_query[0]); 13 if ($amount_to_convert != 0) 14 return 1; 15 } 16 else if ((strpos($query_lower, "mean") || str_starts_with($query_lower, "define")) && count($split_query) >= 2) // definition 17 { 18 return 2; 19 } 20 else if (strpos($query_lower, "my") !== false) 21 { 22 if (strpos($query_lower, "ip")) 23 { 24 return 3; 25 } 26 else if (strpos($query_lower, "user agent") || strpos($query_lower, "ua")) 27 { 28 return 4; 29 } 30 } 31 else if (strpos($query_lower, "weather") !== false) 32 { 33 return 5; 34 } 35 else if ($query_lower == "tor") 36 { 37 return 6; 38 } 39 else if (3 > count(explode(" ", $query))) // wikipedia 40 { 41 return 7; 42 } 43 44 return 0; 45 } 46 47 function get_special_search_request($opts, $mh) { 48 if ($opts->page != 0) 49 return null; 50 51 $special_search = check_for_special_search($opts->query); 52 $special_request = null; 53 $url = null; 54 55 if ($special_search == 0) 56 return null; 57 58 switch ($special_search) { 59 case 1: 60 require "engines/special/currency.php"; 61 $special_request = new CurrencyRequest($opts, $mh); 62 break; 63 case 2: 64 require "engines/special/definition.php"; 65 $special_request = new DefinitionRequest($opts, $mh); 66 break; 67 case 3: 68 require "engines/special/ip.php"; 69 $special_request = new IPRequest($opts, $mh); 70 break; 71 case 4: 72 require "engines/special/user_agent.php"; 73 $special_request = new UserAgentRequest($opts, $mh); 74 break; 75 case 5: 76 require "engines/special/weather.php"; 77 $special_request = new WeatherRequest($opts, $mh); 78 break; 79 case 6: 80 require "engines/special/tor.php"; 81 $special_request = new TorRequest($opts, $mh); 82 break; 83 case 7: 84 require "engines/special/wikipedia.php"; 85 $special_request = new WikipediaRequest($opts, $mh); 86 break; 87 } 88 89 return $special_request; 90 } 91 ?>