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