fba1bac4 |
1 | <?php |
fba1bac4 |
2 | |
b101f04f |
3 | function smarty_function_get_k_neurons($params,&$smarty) { |
4 | |
5 | global $db,$node; |
6 | if (is_numeric($params['offset'])) $offset=$params['offset']; |
7 | else $offset=0; |
8 | if (is_numeric($params['listing_amount'])) $listing_amount=$params['listing_amount']; |
9 | else $listing_amount=DEFAULT_LISTING_AMOUNT; |
10 | if (!is_numeric($_POST['interval'])) $interval=1; |
11 | else $interval = $_POST['interval']; |
12 | if ($params['vector']) { |
13 | $vector=$params['vector']; |
14 | $interval=365; |
15 | } |
16 | else $vector="00"; |
fba1bac4 |
17 | |
b101f04f |
18 | // XXX move to backend |
fba1bac4 |
19 | |
b101f04f |
20 | /*$q="select nodes.*,parent.node_name as parent_name,users.login as creator |
fba1bac4 |
21 | from nodes left join nodes as parent on nodes.node_parent=parent.node_id |
22 | left join users on users.user_id=nodes.node_creator where nodes.node_created>now()-interval $interval day |
23 | and nodes.node_vector like '$vector%' and nodes.k>0 and nodes.node_system_access!='private' order by nodes.k desc limit $offset,$listing_amount"; |
b101f04f |
24 | */ |
25 | |
26 | $q="select COUNT(I.node_id) as count,length(concat(nodes.node_vector)) as vector_depth,nodes.*,nodes.node_creator as node_owner_id,creator.node_name as owner, node_parent.node_name as node_parent_name from I left join nodes on nodes.node_id=I.node_id left join nodes as creator on creator.node_id=nodes.node_creator left join nodes as node_parent on nodes.node_parent=node_parent.node_id where cas>NOW()-INTERVAL 1 HOUR and nodes.node_system_access='public' and nodes.node_vector like '00%' GROUP BY I.node_id ORDER BY count desc"; |
27 | // $q="select nodes.*,'foter' as parent_name,'niekt0' as creator from nodes where node_id=4738126"; |
28 | |
29 | $set=$db->query($q); |
30 | while ($set->next()) { |
31 | $k_array[]=$set->getRecord(); |
32 | } |
fba1bac4 |
33 | |
b101f04f |
34 | // XXX backend end |
fba1bac4 |
35 | |
b101f04f |
36 | $smarty->assign('get_k_neurons',$k_array); |
37 | } |
fba1bac4 |
38 | ?> |