aef209f2ebdd82721c25aa999601c9eff229f050
[phorkie.git] / www / search.php
1 <?php
2 namespace phorkie;
3 /**
4  * Search for a search term
5  */
6 require_once 'www-header.php';
7
8 if (!isset($_GET['q']) || $_GET['q'] == '') {
9     header('Location: ' . Tools::fullUrl('/list'));
10     exit();
11 }
12 $query = $_GET['q'];
13
14 $page = 0;
15 if (isset($_GET['page'])) {
16     if (!is_numeric($_GET['page'])) {
17         throw new Exception_Input('List page is not numeric');
18     }
19     $page = (int)$_GET['page'];
20 }
21 $perPage = 10;
22
23 $db     = new Database();
24 $search = $db->getSearch();
25
26 $sres = $search->search($query, $page, $perPage);
27 render(
28     'search',
29     array(
30         'query' => $query,
31         'sres'  => $sres,
32     )
33 );
34 ?>