| 1 | <?php |
| 2 | function smarty_function_get_search($params,&$smarty) { |
| 3 | /* |
| 4 | $string=escapeshellarg($params['query']); |
| 5 | $output=`/usr/local/bin/swish-e -d ::: -p node_name node_id node_type node_content k node_views -s node_views -f |
| 6 | /storage/data/index.swish-e -w node_name=($string) or node_content=($string)`; |
| 7 | //$output2=`/usr/local/bin/swish-e -d ::: -p node_name node_id node_type node_content k node_views -s node_views -f |
| 8 | /storage/data/index.swish-e -w '$string'`; |
| 9 | //echo "/usr/local/bin/swish-e -d ::: -p node_name node_id node_type node_content k node_views -s node_views -f |
| 10 | /storage/data/index.swish-e -w $string"; |
| 11 | //$output=$output1.$output2; |
| 12 | $output=str_replace($params['query'],"<span |
| 13 | class='most_important'>".$params['query']."</span>",$output); |
| 14 | preg_match_all("/:::(.*?):::(.*?):::(.*?):::(.*?):::(.*?):::(.*?):::(.*?):::(.*?):::(.*?)n/i",$output,$matches); |
| 15 | foreach($matches[0] as $key => $value) { |
| 16 | preg_match("/(.*?).xml/i",$matches[2][$key],$ids); |
| 17 | $id=$ids[1]; |
| 18 | echo "<a href='/id/".$id."'>".$matches[4][$key]."</a> |
| 19 | (".$matches[6][$key].")<br>"; |
| 20 | echo $matches[7][$key]."<br><br>"; |
| 21 | //echo $matches[5][$key]."<br><br>"; |
| 22 | } |
| 23 | |
| 24 | |
| 25 | global $db, $node; |
| 26 | |
| 27 | $q = "SELECT * FROM nodes WHERE node_system_access!='private' AND template_id=3 AND node_name LIKE |
| 28 | '%". |
| 29 | str_replace(array("%", "_"), array('%', '_'), |
| 30 | addslashes($params['query']))."%'"; |
| 31 | $set=$db->query($q); |
| 32 | while($set->next()) { |
| 33 | $rec = $set->getRecord(); |
| 34 | echo "<a href='/id/{$rec[node_id]}'>{$rec[node_name]}</a><br>"; |
| 35 | } |
| 36 | */ |
| 37 | global $db, $node; |
| 38 | if (is_numeric($params['offset'])) $offset = $params['offset']; |
| 39 | else $offset = 0; |
| 40 | |
| 41 | if (is_numeric($params['listing_amount'])) $listing_amount = $params['listing_amount']; |
| 42 | else $listing_amount = 32; |
| 43 | $query = addslashes($params['query']); |
| 44 | $q = "select users.login, nodes.* from nodes left join users on |
| 45 | users.user_id = nodes.node_creator where node_name like '$query%'"; |
| 46 | $set = $db->query($q); |
| 47 | while ($set->next()) { |
| 48 | $array[] = $set->getRecord(); |
| 49 | } |
| 50 | $smarty->assign('get_search_short',$array); |
| 51 | |
| 52 | if ($_POST['orderby'] != ("k" || "node_created" || "probability" || |
| 53 | "node_views")) $orderby = "k"; |
| 54 | else $orderby=$_POST['orderby']; |
| 55 | |
| 56 | $q = "select users.login as login, users.*, nodes.*, nodes.node_creator, |
| 57 | nodes.node_content, match (node_content.node_content) against ('$query') as |
| 58 | probability from node_content left join users on node_content.node_id = users.user_id |
| 59 | left join nodes on node_content.node_id = nodes.node_id where |
| 60 | node_system_access!='private' and match (node_content.node_content) |
| 61 | against ('$query') order by $orderby desc limit $offset,$listing_amount"; |
| 62 | |
| 63 | $set = $db->query($q); |
| 64 | while ($set->next()) { |
| 65 | $search[] = $set->getRecord(); |
| 66 | } |
| 67 | |
| 68 | $smarty->assign('get_search',$search); |
| 69 | } |
| 70 | ?> |