diff options
| author | ctrlcctrlv <admin@8chan.co> | 2014-04-19 23:02:42 +0200 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2014-04-19 23:03:23 +0200 |
| commit | 465986d06cff9380c5bf6c0dbe4eadde7e1cc4b7 (patch) | |
| tree | 612fb305748f5e97ee35afb161bf7a3acb888f5d | |
| parent | 7eb2bef107e45e5fc33e063ad9ea52c3b2ce4878 (diff) | |
use all boards for search.php if boards are not specified
| -rw-r--r-- | inc/functions.php | 22 | ||||
| -rw-r--r-- | search.php | 6 |
2 files changed, 21 insertions, 7 deletions
diff --git a/inc/functions.php b/inc/functions.php index 1393f580..cb198e6c 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -612,17 +612,27 @@ function hasPermission($action = null, $board = null, $_mod = null) { return true; } -function listBoards() { +function listBoards($just_uri = false) { global $config; - if ($config['cache']['enabled'] && ($boards = cache::get('all_boards'))) - return $boards; + $just_uri ? $cache_name = 'all_boards_uri' : $cache_name = 'all_boards'; - $query = query("SELECT * FROM ``boards`` ORDER BY `uri`") or error(db_error()); - $boards = $query->fetchAll(); + if ($config['cache']['enabled'] && ($boards = cache::get($cache_name))) + return $boards; + if (!$just_uri) { + $query = query("SELECT ``boards``.`uri` uri, ``boards``.`title` title, ``boards``.`subtitle` subtitle, ``board_create``.`time` time FROM ``boards`` LEFT JOIN ``board_create`` ON ``boards``.`uri` = ``board_create``.`uri` ORDER BY ``boards``.`uri`") or error(db_error()); + $boards = $query->fetchAll(); + } else { + $boards = array(); + $query = query("SELECT `uri` FROM ``boards``") or error(db_error()); + while ($board = $query->fetchColumn()) { + $boards[] = $board; + } + } + if ($config['cache']['enabled']) - cache::set('all_boards', $boards); + cache::set($cache_name, $boards); return $boards; } @@ -9,7 +9,11 @@ $queries_per_minutes_all = $config['search']['queries_per_minutes_all']; $search_limit = $config['search']['search_limit']; - $boards = $config['search']['boards']; + if (isset($config['search']['boards'])) { + $boards = $config['search']['boards']; + } else { + $boards = listBoards(TRUE); + } $body = Element('search_form.html', Array('boards' => $boards, 'board' => isset($_GET['board']) ? $_GET['board'] : false, 'search' => isset($_GET['search']) ? str_replace('"', '"', utf8tohtml($_GET['search'])) : false)); |
