2 // PukiWiki - Yet another WikiWikiWeb clone.
3 // $Id: search.inc.php,v 1.6 2005/01/16 14:10:46 henoheno Exp $
7 // Allow search via GET method 'index.php?plugin=search&word=keyword'
8 // NOTE: Also allows DoS to your site more easily by SPAMbot or worm or ...
9 define('PLUGIN_SEARCH_DISABLE_GET_ACCESS', 1); // 1, 0
11 define('PLUGIN_SEARCH_MAX_LENGTH', 80);
13 // Show a search box on a page
14 function plugin_search_convert()
18 if (func_get_args()) {
19 return '#search(): No argument<br/>' . "\n";
20 } else if (isset($done)) {
21 return '#search(): You already view a search box<br/>' . "\n";
24 return plugin_search_search_form();
28 function plugin_search_action()
30 global $post, $vars, $_title_result, $_title_search, $_msg_searching;
32 if (PLUGIN_SEARCH_DISABLE_GET_ACCESS) {
33 $s_word = isset($post['word']) ? htmlspecialchars($post['word']) : '';
35 $s_word = isset($vars['word']) ? htmlspecialchars($vars['word']) : '';
37 if (strlen($s_word) > PLUGIN_SEARCH_MAX_LENGTH) {
38 unset($vars['word']); // Stop using $_msg_word at lib/html.php
39 die_message('Search words too long');
42 $type = isset($vars['type']) ? $vars['type'] : '';
46 $msg = str_replace('$1', $s_word, $_title_result);
47 $body = do_search($vars['word'], $type);
50 unset($vars['word']); // Stop using $_msg_word at lib/html.php
51 $msg = $_title_search;
52 $body = '<br />' . "\n" . $_msg_searching . "\n";
56 $body .= plugin_search_search_form($s_word, $type);
58 return array('msg'=>$msg, 'body'=>$body);
61 function plugin_search_search_form($s_word = '', $type = '')
63 global $script, $_btn_and, $_btn_or, $_btn_search;
65 $and_check = $or_check = '';
67 $or_check = ' checked="checked"';
69 $and_check = ' checked="checked"';
73 <form action="$script?cmd=search" method="post">
75 <input type="text" name="word" value="$s_word" size="20" />
76 <input type="radio" name="type" value="AND" $and_check />$_btn_and
77 <input type="radio" name="type" value="OR" $or_check />$_btn_or
78 <input type="submit" value="$_btn_search" />