1 | <?php |
---|
2 | # ***** BEGIN LICENSE BLOCK ***** |
---|
3 | # |
---|
4 | # This file is part of External Search, a plugin for Dotclear 2 |
---|
5 | # Copyright (C) 2009 Moe (http://gniark.net/) |
---|
6 | # |
---|
7 | # External Search is free software; you can redistribute it and/or |
---|
8 | # modify it under the terms of the GNU General Public License v2.0 |
---|
9 | # as published by the Free Software Foundation. |
---|
10 | # |
---|
11 | # External Search is distributed in the hope that it will be useful, |
---|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | # GNU General Public License for more details. |
---|
15 | # |
---|
16 | # You should have received a copy of the GNU General Public License |
---|
17 | # along with this program; if not, write to the Free Software Foundation, |
---|
18 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
19 | # |
---|
20 | # ***** END LICENSE BLOCK ***** |
---|
21 | |
---|
22 | if (!defined('DC_RC_PATH')) {return;} |
---|
23 | |
---|
24 | /** |
---|
25 | @ingroup External Search |
---|
26 | @brief Document |
---|
27 | */ |
---|
28 | class externalSearchDocument extends dcUrlHandlers |
---|
29 | { |
---|
30 | /** |
---|
31 | serve the document |
---|
32 | @param args <b>string</b> Arguments |
---|
33 | */ |
---|
34 | public static function page($args) |
---|
35 | { |
---|
36 | $url = preg_replace('/^(http([s]*)\:\/\/)/i','', |
---|
37 | $GLOBALS['core']->blog->url); |
---|
38 | |
---|
39 | $q = !empty($_POST['q']) ? $_POST['q'] : ''; |
---|
40 | $q = urlencode($q); |
---|
41 | |
---|
42 | switch($_POST['engine']) |
---|
43 | { |
---|
44 | case 'bing' : |
---|
45 | $url = 'http://www.bing.com/search?q=site:'.$url.' '.$q; |
---|
46 | break; |
---|
47 | default : |
---|
48 | throw new Exception(__('invalid search engine')); |
---|
49 | break; |
---|
50 | } |
---|
51 | |
---|
52 | http::redirect($url); |
---|
53 | } |
---|
54 | } |
---|