source: extensions/whois_online/reload.php @ 3319

Last change on this file since 3319 was 3319, checked in by vdigital, 15 years ago

+ Add Whois Online to depository

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