| 1 | <?php |
| 2 | function smarty_function_get_search($params,&$smarty) { |
| 3 | |
| 4 | global $db, $node; |
| 5 | if (is_numeric($params['offset'])) $offset = $params['offset']; |
| 6 | else $offset = 0; |
| 7 | |
| 8 | if (is_numeric($params['listing_amount'])) $listing_amount = $params['listing_amount']; |
| 9 | else $listing_amount = 32; |
| 10 | $query = addslashes($params['query']); |
| 11 | $q = "select users.login, nodes.* from nodes left join users on |
| 12 | users.user_id = nodes.node_creator where node_name like '$query%'"; |
| 13 | $set = $db->query($q); |
| 14 | while ($set->next()) { |
| 15 | $array[] = $set->getRecord(); |
| 16 | } |
| 17 | $smarty->assign('get_search_short',$array); |
| 18 | |
| 19 | if ($_POST['orderby'] != ("k" || "node_created" || "probability" || |
| 20 | "node_views")) $orderby = "k"; |
| 21 | else $orderby=$_POST['orderby']; |
| 22 | |
| 23 | $q = "select users.login as login, users.*, nodes.*, nodes.node_creator, |
| 24 | nodes.node_content, match (node_content.node_content) against ('$query') as |
| 25 | probability from node_content left join users on node_content.node_id = users.user_id |
| 26 | left join nodes on node_content.node_id = nodes.node_id where |
| 27 | node_system_access!='private' and match (node_content.node_content) |
| 28 | against ('$query') order by $orderby desc limit $offset,$listing_amount"; |
| 29 | |
| 30 | $set = $db->query($q); |
| 31 | while ($set->next()) { |
| 32 | $search[] = $set->getRecord(); |
| 33 | } |
| 34 | |
| 35 | $smarty->assign('get_search',$search); |
| 36 | } |
| 37 | ?> |