51ff3226 |
1 | <?php |
2 | function smarty_function_get_userlist($params,&$smarty) { |
3 | global $db,$node; |
08172b71 |
4 | if ((isset($params['node_id'])) && (is_numeric($params['node_id']))) |
5 | { $node_id=$params['node_id']; |
51ff3226 |
6 | |
08172b71 |
7 | } else $node_id=$node['node_id']; |
8 | if ((isset($params['vector'])) && ($params['vector'])) { |
51ff3226 |
9 | $vector=AddSlashes($params['vector']); |
10 | } |
08172b71 |
11 | if ((isset($_SESSION['cube_vector'])) && ($_SESSION['cube_vector'])) { |
51ff3226 |
12 | $vector=$_SESSION['cube_vector']; |
13 | } |
14 | |
15 | $q="select user_action,user_action_id,(UNIX_TIMESTAMP()-UNIX_TIMESTAMP(last_action)) as idle,login,user_id from users where "; |
08172b71 |
16 | if (isset($vector) && $vector) $q.=" user_location_vector like '$vector%' and "; |
51ff3226 |
17 | $q.=" invisible != 'yes' and user_action_id IS NOT NULL order by login"; |
18 | |
19 | $set=$db->query($q); |
20 | while ($set->next()) { |
21 | if (!empty($_SESSION['friends'][$set->getString('user_id')])) { |
22 | $array=$set->getRecord(); |
23 | $array['idle_time_minutes']=floor($array['idle']/60); |
24 | $array['idle_time_seconds']=$array['idle']%60; |
25 | $active_friends[]=$array; |
26 | } |
27 | else { |
28 | $array=$set->getRecord(); |
29 | $array['idle_time_minutes']=floor($array['idle']/60); |
30 | |
31 | $array['idle_time_seconds']=$array['idle']%60; |
32 | $active_users[]=$array; |
33 | } |
34 | } |
35 | |
36 | $smarty->assign('active_users',$active_users); |
37 | $smarty->assign('active_friends',$active_friends); |
38 | } |
39 | ?> |