1 | <?php |
---|
2 | // Reload might be : |
---|
3 | // - accessed thru a direct link from admin.php?page=plugin§ion=whois_online%2Fconfig.php&tab=report |
---|
4 | // - or included directly by admin.php (include_one in reporting part) |
---|
5 | // Reload won't work if Whois_Online is deactivated |
---|
6 | $included = true; |
---|
7 | if (!isset($_url)) { |
---|
8 | define('PHPWG_ROOT_PATH','../../'); |
---|
9 | define('IN_ADMIN', true); |
---|
10 | include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); |
---|
11 | $conf['show_gt'] = true; |
---|
12 | $included = false; |
---|
13 | load_language('plugin.lang', WHOIS_ONLINE_PATH); |
---|
14 | } |
---|
15 | |
---|
16 | // This is MANDATORY to secure your website ! |
---|
17 | check_status(ACCESS_ADMINISTRATOR); |
---|
18 | |
---|
19 | pwg_debug('*********** Radar reload ***********'); |
---|
20 | $conf_whois = whois_online_conf(); |
---|
21 | |
---|
22 | $sort = ' WHERE `IP` = "global" or ( 1=1 '; |
---|
23 | |
---|
24 | // Filtering on direct link parameters |
---|
25 | $case = ''; |
---|
26 | if (isset($_GET['req'])) { |
---|
27 | $case = $_GET['req']; |
---|
28 | switch($_GET['req']) { |
---|
29 | case 'members': |
---|
30 | $sort.= ' AND `user_id` <> "' . $conf['guest_id'] . '"'; |
---|
31 | break; |
---|
32 | case 'guest': |
---|
33 | $sort.= ' AND `user_id` = "' . $conf['guest_id'] . '"'; |
---|
34 | break; |
---|
35 | case 'less_24': |
---|
36 | $sort.= ' AND `last_access` > "' . (time()-(24*3600)) . '"'; |
---|
37 | break; |
---|
38 | case 'over_24': |
---|
39 | $sort.= ' AND `last_access` < "' . (time()-(24*3600)) . '"'; |
---|
40 | break; |
---|
41 | case 'pics': |
---|
42 | $sort.= ' AND `last_elm_ids` > "0 0 0 0 0 0 0 0 0 0"'; |
---|
43 | break; |
---|
44 | case 'no_pic': |
---|
45 | $sort.= ' AND `last_elm_ids` = "0 0 0 0 0 0 0 0 0 0"'; |
---|
46 | break; |
---|
47 | case 'country': |
---|
48 | $sort.= ' AND `country` <> \'' . htmlspecialchars(serialize(Array('Code' => '__', 'Name' => l10n('Unknown country'), 'City' => 'N/A',))) . '\''; |
---|
49 | break; |
---|
50 | case 'no_country': |
---|
51 | $sort.= ' AND `country` = \'' . htmlspecialchars(serialize(Array('Code' => '__', 'Name' => l10n('Unknown country'), 'City' => 'N/A',))) . '\''; |
---|
52 | break; |
---|
53 | case 'single': |
---|
54 | $sort.= ' AND LENGTH(`last_dates`) < 12'; |
---|
55 | break; |
---|
56 | case 'multi': |
---|
57 | $sort.= ' AND LENGTH(`last_dates`) > 12'; |
---|
58 | break; |
---|
59 | case 'IPs': |
---|
60 | $sort.= ' AND `hidden_IP` = "true"'; |
---|
61 | break; |
---|
62 | } |
---|
63 | } |
---|
64 | $sort .= ') |
---|
65 | ORDER BY `db_timestamp` DESC;'; |
---|
66 | $online = whois_online_get_data($sort); |
---|
67 | $global = $online[0]; unset($online[0]); |
---|
68 | $sid = session_id(); |
---|
69 | |
---|
70 | $iflag = 0; // Get the 10 first new flags on included requests ONLY (Duration reasons) |
---|
71 | |
---|
72 | // prefetch to optimize |
---|
73 | $local_guest = mysql_fetch_assoc(pwg_query('SELECT * FROM ' . USER_INFOS_TABLE . |
---|
74 | ' WHERE user_id = ' . $conf['guest_id'] .';')); |
---|
75 | |
---|
76 | $lang_tab = get_languages(); |
---|
77 | foreach ($lang_tab as $k => $v) $lang_code[substr($k,0,2)] = substr($v,0,strrpos($v,'[')-1); |
---|
78 | |
---|
79 | $bypass = false; |
---|
80 | $limit = 20; |
---|
81 | $ql = 0; |
---|
82 | $inlist = '0'; |
---|
83 | foreach ($online as $k => $v) { |
---|
84 | $inlist .= ', ' . implode( ', ', explode(' ',$online[$k]['last_elm_ids'])); |
---|
85 | $ql++; |
---|
86 | if ($ql >= $conf_whois['Radar limit']) break; |
---|
87 | } |
---|
88 | $image = array(); |
---|
89 | $result = pwg_query('SELECT * FROM ' . IMAGES_TABLE . |
---|
90 | ' WHERE id IN (' . $inlist .');'); |
---|
91 | while ($row = mysql_fetch_assoc($result)) { |
---|
92 | $images[$row['id']] = $row; |
---|
93 | $images[$row['id']]['tn_url'] = get_thumbnail_url($row); |
---|
94 | } |
---|
95 | foreach ($online as $k => $v) { |
---|
96 | // The stupid History search will be reused instead of created... (even if History search will recreate it) |
---|
97 | if ($conf['log']) $online[$k]['url_user'] = |
---|
98 | PHPWG_ROOT_PATH .'admin.php?page=history&user_id='.$online[$k]['user_id'].'&search_id='.$conf_whois['Search id']; |
---|
99 | |
---|
100 | $online[$k]['Language'] = (isset($lang_code[$v['lang']])) ? $lang_code[$v['lang']]:l10n('Deleted language'); |
---|
101 | $online[$k]['Country'] = whois_country($v, $bypass); |
---|
102 | $iflag++; |
---|
103 | $online[$k]['Flag'] = ($included) ? whois_flag($online[$k], $iflag) : whois_flag($online[$k], $iflag, $limit); |
---|
104 | if (!$included) $online[$k]['Flag'] = substr($online[$k]['Flag'],4); |
---|
105 | if ($iflag > 5) $bypass = true; // Don't search already unknown countries over 5 countries |
---|
106 | if ($v['user_id'] == $conf['guest_id']) { |
---|
107 | $online[$k]['username'] = ucwords(l10n('guest')); |
---|
108 | $online[$k]['guest'] = true; |
---|
109 | $online[$k]['user'] = $local_guest; // Prefetched guest data |
---|
110 | } |
---|
111 | else { |
---|
112 | $online[$k]['user'] = mysql_fetch_assoc(pwg_query('SELECT * FROM ' . USER_INFOS_TABLE . |
---|
113 | ' WHERE user_id = ' . $v['user_id'] .';')); |
---|
114 | $online[$k]['guest'] = false; |
---|
115 | } |
---|
116 | // Images queries are limited (no cluetip over $conf_whois['Radar limit']) |
---|
117 | // For performance reasons |
---|
118 | $online[$k]['Bot'] = is_a_bot($online[$k]['user_agent']); |
---|
119 | $online[$k]['last_ids'] = explode(' ',$online[$k]['last_elm_ids']); |
---|
120 | foreach ($online[$k]['last_ids'] as $id) { |
---|
121 | if (isset($images[$id])) { |
---|
122 | $online[$k]['images'][$id] = $images[$id]; |
---|
123 | $online[$k]['images'][$id]['ws_level'] = ($images[$id]['level']>$online[$k]['user']['level']) ? 'ws':''; |
---|
124 | } |
---|
125 | $online[$k]['images'][$id]['id'] = $id; |
---|
126 | $online[$k]['images'][$id]['url_modify'] = PHPWG_ROOT_PATH . 'admin.php?page=picture_modify&image_id='.$id; |
---|
127 | } |
---|
128 | } |
---|
129 | |
---|
130 | pwg_debug('*********** Radar reloaded ***********'); |
---|
131 | $template->assign('search_results', $online); |
---|
132 | $template->assign('Case', $case); |
---|
133 | // Send reloadable HTML |
---|
134 | if ( !$included ) { |
---|
135 | $template->set_filenames(array('reload'=> dirname(__FILE__) . '/report.tpl')); |
---|
136 | $template->pparse('reload'); |
---|
137 | } |
---|
138 | |
---|
139 | ?> |
---|