Index: /extensions/whois_online/Changelog.txt.php
===================================================================
--- /extensions/whois_online/Changelog.txt.php	(revision 3695)
+++ /extensions/whois_online/Changelog.txt.php	(revision 3695)
@@ -0,0 +1,42 @@
+<?php
+/*
+Plugin Name: Whois online
+** History **
+  2009-07-28 2.0.j
+						 Minor changes in Config management
+						 Additionnal flags (Ireland, Armenia, Estonia, Kazakhstan, Belarus, Andorra, 
+						 Turkey, Albania, Bosnia and Herzegovina, Azerbaijan, Iceland, European Union,
+						 Israel, Morocco, New Caledonia and some other revised)
+						 Search Engine trapping
+  2009-05-20 2.0.i
+						 Bug resolution.
+						 Icons removed due to tablesorter constraints.
+						 Active link style on active filter.
+						 Additionnal flags (Luxemburg, Austria, Malta, and some other revised)
+  2009-05-19 2.0.h
+						 Additional links to profile and permissions corrective path with filtering.
+						 Minor optimizations.
+						 Additionnal flags (Egypt, Indonesia, Malaysia)
+  2009-05-17 2.0.g
+						 htmlspecialchars for Countries (Some City have quoted names)
+						 Keep Previous config.
+						 Additional links to profile and permissions
+						 Additionnal flags
+  2009-05-12 2.0.e and 2.0.f
+						 IPV4 Localisation
+						 Monitoring Permanence/Temporary user lists 
+						 Reporting of User accesses
+						 Most connected
+						 And more...
+  2009-04-14 2.0.d 
+						 Icon on History can be removed
+						 Appropriate titles for both links
+  2009-04-14 2.0.c 
+	           Default display on admin pages even if not displayed on other pages
+						 Bug on History Search page
+						 Appropriate titles for both links on each first access (later "Random picture")
+  2009-04-13 2.0.b 
+	           Corrective of &review and &others
+						 Automatic upgrade
+*/
+?>
Index: /extensions/whois_online/config.php
===================================================================
--- /extensions/whois_online/config.php	(revision 3694)
+++ /extensions/whois_online/config.php	(revision 3695)
@@ -16,4 +16,5 @@
 if (!defined('IN_ADMIN') or !IN_ADMIN) die('Hacking attempt!');
 global $conf, $conf_whois, $lang;
+$conf['show_gt'] = true;
 load_language('plugin.lang', WHOIS_ONLINE_PATH);
 
@@ -83,6 +84,7 @@
 if ( $sub and count($errors) == 0 and $_POST['from']=='config' and !is_adviser()) {
 	if ( $conf['Whois Online'] != serialize($conf_whois) ) {
+		$conf['Whois Online'] = serialize($conf_whois);
 		pwg_query('REPLACE INTO ' . CONFIG_TABLE . " (param,value,comment)
-    VALUES ('Whois Online','". serialize($conf_whois) ."','Whois Online configuration');");
+    VALUES ('Whois Online','". $conf['Whois Online'] ."','Whois Online configuration');");
 		array_push($infos, l10n('Configuration has been saved.'));
 	}
@@ -210,5 +212,5 @@
 	// Most members ever online was
 	if (!isset($conf_whois['Users']['count']) or $conf_whois['Users']['count'] == 0) {
-		$count = mysql_fetch_assoc(pwg_query('SELECT MAX(`id`) AS `ctr` FROM ' . USERS_TABLE));
+		$count = mysql_fetch_assoc(pwg_query('SELECT MAX(`'. $conf['user_fields']['id'] .'`) AS `ctr` FROM ' . USERS_TABLE));
 		$conf_whois['Users']['count'] = $count['ctr'];
 	}
Index: /extensions/whois_online/include/wo_functions.inc.php
===================================================================
--- /extensions/whois_online/include/wo_functions.inc.php	(revision 3695)
+++ /extensions/whois_online/include/wo_functions.inc.php	(revision 3695)
@@ -0,0 +1,33 @@
+<?php
+/* Functions */
+
+
+
+
+
+
+
+
+/*
+  returns (mixed): (string) 'bot agent name'  || (bool) false
+  @param (string) HTTP_USER_AGENT
+*/
+function is_a_bot($agent = '') 
+{
+  global $conf;
+	if ($agent == '') $agent = $_SERVER['HTTP_USER_AGENT'];
+	$botlist = array('Teoma', 'alexa', 'froogle', 'Gigabot', 'inktomi',
+	'looksmart', 'URL_Spider_SQL', 'Firefly', 'NationalDirectory', 
+	'Ask Jeeves', 'TECNOSEEK', 'InfoSeek', 'WebFindBot', 'girafabot',
+	'crawler', 'www.galaxy.com', 'Googlebot', 'Scooter', 'Slurp',
+	'msnbot', 'appie', 'FAST', 'WebBug', 'Spade', 'ZyBorg', 'rabaz',
+	'Baiduspider', 'Feedfetcher-Google', 'TechnoratiSnoop', 'Rankivabot',
+	'Mediapartners-Google', 'Sogou web spider', 'WebAlta Crawler');
+  if (isset($conf['search_agents']))
+	  $botlist = array_merge( $botlist, array_diff( $conf['search_agents'], $botlist ) );
+  foreach($botlist as $bot) {
+    if (stripos($agent, $bot)!==false) return $bot; 
+  }
+  return false;
+} 
+?>
Index: /extensions/whois_online/main.inc.php
===================================================================
--- /extensions/whois_online/main.inc.php	(revision 3694)
+++ /extensions/whois_online/main.inc.php	(revision 3695)
@@ -21,8 +21,7 @@
 // | USA.                                                                  |
 // +-----------------------------------------------------------------------+
-
 /*
 Plugin Name: Whois online
-Version: 2.0.i
+Version: 2.0.j
 Description: Who is online?
 Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=279
@@ -30,49 +29,12 @@
 Author URI: http://www.vdigital.org
 */
-/*
-
-/** History **
-  2009-05-xx 2.0.j
-						 
-						 Additionnal flags (Ireland, Armenia, Estonia, Kazakhstan, Belarus, Andorra, 
-						 Turkey, Albania, Bosnia and Herzegovina, Azerbaijan, Iceland, European Union,
-						 Israel, Morocco, New Caledonia and some other revised)
-  2009-05-20 2.0.i
-						 Bug resolution.
-						 Icons removed due to tablesorter constraints.
-						 Active link style on active filter.
-						 Additionnal flags (Luxemburg, Austria, Malta, and some other revised)
-  2009-05-19 2.0.h
-						 Additional links to profile and permissions corrective path with filtering.
-						 Minor optimizations.
-						 Additionnal flags (Egypt, Indonesia, Malaysia)
-  2009-05-17 2.0.g
-						 htmlspecialchars for Countries (Some City have quoted names)
-						 Keep Previous config.
-						 Additional links to profile and permissions
-						 Additionnal flags
-  2009-05-12 2.0.e and 2.0.f
-						 IPV4 Localisation
-						 Monitoring Permanence/Temporary user lists 
-						 Reporting of User accesses
-						 Most connected
-						 And more...
-  2009-04-14 2.0.d 
-						 Icon on History can be removed
-						 Appropriate titles for both links
-  2009-04-14 2.0.c 
-	           Default display on admin pages even if not displayed on other pages
-						 Bug on History Search page
-						 Appropriate titles for both links on each first access (later "Random picture")
-  2009-04-13 2.0.b 
-	           Corrective of &review and &others
-						 Automatic upgrade
-*/
-define('WHOIS_ONLINE_VER', '2.0.i'); 
+define('WHOIS_ONLINE_VER', '2.0.j'); 
 global $prefixeTable, $conf;
 // $conf['debug_l10n'] = true;
 if (!defined('WHOIS_ONLINE_TABLE')) define('WHOIS_ONLINE_TABLE', $prefixeTable.'whois_online');
+
 define('WHOIS_ONLINE_DIR' , basename(dirname(__FILE__)));
 define('WHOIS_ONLINE_PATH' , PHPWG_PLUGINS_PATH . WHOIS_ONLINE_DIR . '/');
 include_once(WHOIS_ONLINE_PATH.'online.php');
+/* History:  WHOIS_ONLINE_PATH.'Changelog.txt.php' */
 ?>
Index: /extensions/whois_online/maintain.inc.php
===================================================================
--- /extensions/whois_online/maintain.inc.php	(revision 3694)
+++ /extensions/whois_online/maintain.inc.php	(revision 3695)
@@ -8,64 +8,36 @@
 function plugin_activate()
 {
-	global $user;
+	global $user,$conf;
 	$query = "CREATE TABLE IF NOT EXISTS ". WHOIS_ONLINE_TABLE ." (
-  `IP` varchar(39) NOT NULL default '',
-  `hidden_IP` enum('true','false') NOT NULL default 'false',
+  `IP` varchar(39) NOT NULL DEFAULT '',
+  `hidden_IP` enum('true','false') NOT NULL DEFAULT 'false',
   `session_id` varchar(40) NOT NULL,
-  `user_id` smallint(5) NOT NULL default '0',
-  `username` varchar(100) character set utf8 collate utf8_bin NOT NULL default '',
-  `lang` char(2) character set utf8 collate utf8_bin NOT NULL default 'en',
-  `country` VARCHAR( 256 ) NOT NULL default '',
-  `permanent` enum('true','false') NOT NULL default 'false',
-  `last_access` varchar(12) NOT NULL default '',
-  `last_elm_ids` varchar(75) NOT NULL default '',
-  `last_cat_ids` varchar(75) NOT NULL default '',
-  `last_tag_ids` varchar(75) NOT NULL default '',
-  `last_sch_ids` varchar(75) NOT NULL default '',
-  `first_access_date` varchar(45) NOT NULL default '',
-  `last_dates` varchar(110) character set utf8 collate utf8_bin NOT NULL default '',
-  `elm_hits` int(10) unsigned NOT NULL default '0',
-  `pag_hits` int(10) unsigned NOT NULL default '0',
-  `db_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+  `user_id` smallint(5) NOT NULL DEFAULT '0',
+  `username` varchar(100) character set utf8 collate utf8_bin NOT NULL DEFAULT '',
+  `lang` char(2) character set utf8 collate utf8_bin NOT NULL DEFAULT 'en',
+  `country` VARCHAR( 256 ) NOT NULL DEFAULT '',
+  `user_agent` VARCHAR( 160 ) NOT NULL DEFAULT '',
+  `any_previous` VARCHAR( 256 ) NOT NULL DEFAULT '',
+  `same_previous` VARCHAR( 256 ) NOT NULL DEFAULT '',
+  `permanent` enum('true','false') NOT NULL DEFAULT 'false',
+  `last_access` varchar(12) NOT NULL DEFAULT '',
+  `last_elm_ids` varchar(75) NOT NULL DEFAULT '',
+  `last_cat_ids` varchar(75) NOT NULL DEFAULT '',
+  `last_tag_ids` varchar(75) NOT NULL DEFAULT '',
+  `last_sch_ids` varchar(75) NOT NULL DEFAULT '',
+  `first_access_date` varchar(45) NOT NULL DEFAULT '',
+  `last_dates` varchar(110) character set utf8 collate utf8_bin NOT NULL DEFAULT '',
+  `elm_hits` int(10) unsigned NOT NULL DEFAULT '0',
+  `pag_hits` int(10) unsigned NOT NULL DEFAULT '0',
+  `db_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
   PRIMARY KEY  (`session_id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 ";
 	$result = pwg_query($query);
-	if (isset($conf['Whois Online'])) {
-		$conf_whois = unserialize($conf['Whois Online']);
-		if (!isset($conf_whois['Active'])) $conf_whois['Active'] = true;
-		if (!isset($conf_whois['Delete level'])) $conf_whois['Delete level'] = 20;
-		if (!isset($conf_whois['Radar limit'])) $conf_whois['Radar limit'] = 25;
-		if (!isset($conf_whois['Webmasters'])) $conf_whois['Webmasters'] = 2;
-		if (!isset($conf_whois['Administrators'])) $conf_whois['Administrators'] = 2;
-		if (!isset($conf_whois['Obsolete limit'])) $conf_whois['Obsolete limit'] = 20;
-		if (!isset($conf_whois['Add to Plugins menu'])) $conf_whois['Add to Plugins menu'] = false;
-		if (!isset($conf_whois['Add icon to History'])) $conf_whois['Add icon to History'] = true;
-		if (!isset($conf_whois['Keep data'])) $conf_whois['Keep data'] = true;
-		if (!isset($conf_whois['Default display'])) $conf_whois['Default display'] = true;
-		if (!isset($conf_whois['Search id'])) $conf_whois['Search id'] = 0;
-		if (!isset($conf_whois['Users'])) 
-			$conf_whois['Users'] = Array('max' => 0, 'When' => date('Y-m-d'), 'count' => 0);
-		$conf['Whois Online'] = serialize($conf_whois);
+	if (!isset($conf['Whois Online'])) {
+		$conf['Whois Online'] = serialize(Array());
+		pwg_query('REPLACE INTO ' . CONFIG_TABLE . " (param,value,comment)
+		VALUES ('Whois Online','". $conf['Whois Online'] ."','Whois Online configuration');");
 	}
-	else {
-		$conf['Whois Online'] = serialize(Array(
-			'Active' => true,
-			'Delete level' => 20,
-			'Radar limit' => 25,
-			'Obsolete limit' => 20,
-			'Webmasters' => 2,
-			'Administrators' => 2,
-			'Search id' => 0,
-			'Users' => Array('max' => 0, 'When' => date('Y-m-d'), 'count' => 0),
-			'Add to Plugins menu' => false,
-			'Add icon to History' => true,
-			'Keep data' => true,
-			'Default display' => true,
-		));
-	}
-	pwg_query('REPLACE INTO ' . CONFIG_TABLE . " (param,value,comment)
-	VALUES ('Whois Online','". $conf['Whois Online'] ."','Whois Online configuration');");
-	$conf_whois = unserialize($conf['Whois Online']);
 	if (isset($conf_whois['Keep data']) and !$conf_whois['Keep data']) {
 		pwg_query('DELETE FROM ' . WHOIS_ONLINE_TABLE);
Index: /extensions/whois_online/online.php
===================================================================
--- /extensions/whois_online/online.php	(revision 3694)
+++ /extensions/whois_online/online.php	(revision 3695)
@@ -2,8 +2,7 @@
 
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-global $conf, $conf_whois;
-
+global $conf, $conf_whois, $prefixeTable;
+include_once(WHOIS_ONLINE_PATH.'include/wo_functions.inc.php');
 /* Secure Config */
-
 if (!isset($conf_whois['Active'])) $conf_whois = whois_online_conf();
 
@@ -11,18 +10,19 @@
 {
 	global $conf;
-	$conf_whois = unserialize($conf['Whois Online']);
-	if (!isset($conf_whois['Active'])) $conf_whois['Active'] = true;
-	if (!isset($conf_whois['Delete level'])) $conf_whois['Delete level'] = 20;
-	if (!isset($conf_whois['Radar limit'])) $conf_whois['Radar limit'] = 25;
-	if (!isset($conf_whois['Webmasters'])) $conf_whois['Webmasters'] = 2;
-	if (!isset($conf_whois['Administrators'])) $conf_whois['Administrators'] = 2;
-	if (!isset($conf_whois['Obsolete limit'])) $conf_whois['Obsolete limit'] = 20;
-	if (!isset($conf_whois['Add to Plugins menu'])) $conf_whois['Add to Plugins menu'] = false;
-	if (!isset($conf_whois['Add icon to History'])) $conf_whois['Add icon to History'] = true;
-	if (!isset($conf_whois['Keep data'])) $conf_whois['Keep data'] = true;
-	if (!isset($conf_whois['Default display'])) $conf_whois['Default display'] = true;
-	if (!isset($conf_whois['Search id'])) $conf_whois['Search id'] = 0;
-	if (!isset($conf_whois['Users'])) 
-		$conf_whois['Users'] = Array('max' => 0, 'When' => date('Y-m-d'), 'count' => 0);
+	$default = array(
+	  'Active' => true,
+	  'Delete level' => 20,
+	  'Radar limit' => 25,
+	  'Webmasters' => 2, // Normal
+	  'Administrators' => 2,
+	  'Obsolete limit' => 20,
+		'Default display' => true,
+	  'Add to Plugins menu' => false,
+	  'Add icon to History' => true,
+	  'Keep data' => true,
+	  'Search id' => 0,
+	  'Users' => Array('max' => 0, 'When' => date('Y-m-d'), 'count' => 0),
+	);
+	$conf_whois = array_merge($default, unserialize($conf['Whois Online']));
 	if ((!isset($conf_whois['Version'])) or $conf_whois['Version'] != WHOIS_ONLINE_VER
 		or $conf['Whois Online'] != serialize($conf_whois)) {
@@ -39,6 +39,4 @@
 
 /* Admin menus are always available */
-$conf['Add to Plugins menu'] = $conf_whois['Add to Plugins menu'];
-$conf['Add icon to History'] = $conf_whois['Add icon to History'];
 add_event_handler('get_admin_plugin_menu_links', 'whois_add_icon' );
 /* On Active */
@@ -51,21 +49,21 @@
 }
 
-/* --------------- Functions ----------------- */
-
-// pparse whois_online/default.tpl
+
+
+
+// Assume the Default display on pages
 function whois_default_display() {
 	global $template;
 	$template->set_filenames(array( 'Whois_display' => dirname(__FILE__).'/default.tpl'));
 	$template->pparse('Whois_display');
-	// Based on get_enums(USER_INFOS_TABLE, 'status') ???
 }
 
 // Add admin links
 function whois_add_icon($menu) {
-	global $conf, $lang;
-	if ($conf['Add icon to History'])
+	global $conf_whois, $lang;
+	if ($conf_whois['Add icon to History'])
 		$lang['History'] .= '</a> <a class="external" href="' . get_admin_plugin_menu_link(WHOIS_ONLINE_PATH.'config.php') . '">
 			<img class="button" src="' . WHOIS_ONLINE_PATH . 'icons/Whois_tuner.gif" alt="Whois Online configuration" title="Whois Online configuration" /></a>';
-	if ($conf['Add to Plugins menu']) array_push($menu, array(
+	if ($conf_whois['Add to Plugins menu']) array_push($menu, array(
 				'NAME' => 'Whois Online',
 				'URL' => get_admin_plugin_menu_link(WHOIS_ONLINE_PATH.'config.php'),
@@ -117,6 +115,8 @@
 		$c['Code'] = '__';
 	}
+	$new = htmlspecialchars(serialize($c),ENT_QUOTES,'UTF-8');
+	if ($new == $trace['country']) return $c;
 	pwg_query('UPDATE ' . WHOIS_ONLINE_TABLE . ' 
-      SET `country` = \'' . htmlspecialchars(serialize($c),ENT_QUOTES,'UTF-8') . '\'
+      SET `country` = \'' . $new . '\'
     WHERE `session_id` = \'' . $trace['session_id'] . '\';');
   return $c;
@@ -185,6 +185,6 @@
 	}
 	// Write or Rewrite the dedicated record
-	$query = 'REPLACE INTO ' . WHOIS_ONLINE_TABLE . ' (`IP`, `hidden_IP`, `session_id`,`user_id`,`username`,`lang`,
-	`permanent`,`last_access`,`last_elm_ids`, `last_cat_ids`, `last_tag_ids`, `last_sch_ids`,
+	$query = 'REPLACE INTO ' . WHOIS_ONLINE_TABLE . ' (`IP`, `hidden_IP`, `session_id`,`user_id`,`username`,`lang`, `user_agent`,
+	`any_previous`, `same_previous`, `permanent`,`last_access`,`last_elm_ids`, `last_cat_ids`, `last_tag_ids`, `last_sch_ids`,
 	`first_access_date`, `last_dates`, `elm_hits`, `pag_hits`)
 		VALUES (\''. $dedicated['IP'] .'\', \''
@@ -192,4 +192,7 @@
 		. $dedicated['user_id'] .'\', \''. $dedicated['username'] .'\', \''
 		. substr($lang_info['code'],0,2) .'\', \''
+		. $dedicated['user_agent'] .'\', \''
+		. $dedicated['any_previous'] .'\', \''
+		. $dedicated['same_previous'] .'\', \''
 		. $dedicated['permanent'] . '\', \''. time() .'\',  \''
 		. implode(' ',$dedicated['elm_ids']) . '\', \''
@@ -220,4 +223,18 @@
 }
 
+// Antiaspi delay conversion in seconds
+// delay in "HH:ii:ss" or "d :HH:ii:ss"
+// return delay in seconds
+function whois_online_duration($date_string)
+{
+ list($s, $i, $H, $d, $more) = 
+   array_merge(array_reverse(
+	   explode(" ",str_ireplace(':',' ', $date_string))),
+		 array(0,0,0,0,0));
+ $t = time();
+ return strtotime(sprintf("+%s days %s hours %s minutes %s seconds", 
+   $d, $H, $i, $s), $t) - $t;
+}
+
 /*
 		Main process: Analyze, set new values and prepare displayed values.
@@ -239,5 +256,5 @@
 	unset($online[0]);
 	$sid = session_id();
-
+	
 	// Step 1 - Find the User and/or IP/session_id
 	foreach ($online as $key => $record) {
@@ -358,11 +375,90 @@
 	$global['tag_ids'][$hour%12]++;
 	$global['sch_ids'][$day%14]++;
-  // !!! WARNING  !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!
+  // !!! WARNING  !!! WARNING !!! WARNING !!! WARNING !!!
 	$global['elm_ids'][10] = $current; // reference minute has changed
 	$global['cat_ids'][12] = $five;
 	$global['tag_ids'][24] = $hour;
 	$global['sch_ids'][14] = $day;
-  // !!! WARNING  !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!
-
+  // !!! WARNING  !!! WARNING !!! WARNING !!! WARNING !!!
+
+	// 5.5 - Add in previous
+  if (!isset($global['any_previous'])) {
+		pwg_query('ALTER TABLE ' . WHOIS_ONLINE_TABLE . 
+			' ADD `same_previous` VARCHAR( 256 ) NOT NULL DEFAULT \'\'  AFTER `country`;');
+		pwg_query('ALTER TABLE ' . WHOIS_ONLINE_TABLE . 
+			' ADD `any_previous` VARCHAR( 256 ) NOT NULL DEFAULT \'\'  AFTER `country`;');
+		pwg_query('ALTER TABLE ' . WHOIS_ONLINE_TABLE . 
+			' ADD `user_agent` VARCHAR( 160 ) NOT NULL DEFAULT \'\'  AFTER `country`;');
+	}
+
+	$antiaspi = array(
+    'diff' => '20 pages in 00:00:10' , // Banned for 20 access in 10 seconds or less
+    'same' => '15 pages in 00:00:30' , // Banned for 15 access on the same page in 30 seconds or less
+    'banned during' => '23:59:59' ,    // Banned time hh:mm:ss or any valid MySQL datetime expression 'YYYY-MM-DD HH:MM:SS'
+    'only guest' => true ,             // True, registred members won't be banned
+    'only picture' => false ,          // True, Check only on picture pages
+    'allowed ip' => array()            // Allowed IP array (Bots, or your fixed IP)
+  );
+  if (isset($conf['antiaspi'])) $antiaspi = array_merge($antiaspi, $conf['antiaspi']);
+
+	// For AntiAspi follow ANY PREVIOUS access
+	$access = '0:';
+	list($max_any, $maxtext) = explode(' pages in ', $antiaspi['diff']);
+	$maxtime = whois_online_duration($maxtext);
+	$prev='';
+	$previous = (isset($visit['any_previous'])) ? explode(' ', $visit['any_previous']):Array();
+	foreach ($previous as $v) {
+		$old = explode(':', $v);
+		$old[0] += $visit['delay']; 
+		if ($old[0]<$maxtime) $prev .= $old[0].': ';
+	}
+	$prev = $access . ' ' . $prev;
+	$prev = substr($prev, 0, -2);
+	$visit['any_previous'] = $prev;
+	// For AntiAspi follow ANY SAME PICTURE access
+	$access = '0:';
+	$same_elem = (isset($page['image_id'])) ? $page['image_id']:'0';
+	list($max_same, $maxtext) = explode(' pages in ', $antiaspi['same']);
+	$maxtime = whois_online_duration($maxtext);
+	$access .= $same_elem . ':';
+	$prev='';
+	$previous = (isset($visit['same_previous'])) ? explode(' ', $visit['same_previous']):Array();
+	foreach ($previous as $v) {
+		$old = explode(':', $v);
+		$old[0] += $visit['delay'];
+		if ($old[0]<$maxtime and $old[1]==$same_elem) $prev .= $old[0].':'.$old[1].': ';
+	}
+	$prev = $access . ' ' . $prev;
+	$prev = substr($prev, 0, -2);
+	$visit['same_previous'] = $prev;
+	
+	// Check limits of $visit['any_previous'] and $visit['same_previous'] 
+	// by 256 characters
+	// by $max_any and by $max_same
+	while (strlen($visit['any_previous'])>256) {
+	  $previous = explode(' ',$visit['any_previous']);
+		$oldest = array_pop($previous);
+		$visit['any_previous'] = implode(' ', $previous);
+	}
+	$ctr_any = count(explode(' ',$visit['any_previous']));
+	while (strlen($visit['same_previous'])>256) {
+	  $previous = explode(' ',$visit['same_previous']);
+		$oldest = array_pop($previous);
+		$visit['same_previous'] = implode(' ', $previous);
+	}
+	$ctr_same = count(explode(' ',$visit['same_previous']));
+	
+	$visit['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
+	$Vip =& $visit['IP'];
+	$visit['Allowed_SE'] = false;
+  if (!empty($antiaspi['allowed ip']))
+  {
+    $allowed_ips = str_replace(array('.', '%'), array('\.', '.*?'), $antiaspi['allowed ip']);
+    foreach ($allowed_ips as $ip)
+    {
+      if (preg_match("#" . $ip . "#", $Vip)) { $visit['Allowed_SE'] = true; break; }
+    }
+  }
+	
 	// Step 6 - Update (on Conf_Update and trace) and send trace to determine global tracing or not
 	$dtrace = 0;
Index: /extensions/whois_online/reload.php
===================================================================
--- /extensions/whois_online/reload.php	(revision 3694)
+++ /extensions/whois_online/reload.php	(revision 3695)
@@ -9,4 +9,5 @@
 		define('IN_ADMIN', true);
 		include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
+		$conf['show_gt'] = true;
 		$included = false;
 		load_language('plugin.lang', WHOIS_ONLINE_PATH);
@@ -79,4 +80,17 @@
 $limit = 20;
 $ql = 0; 
+$inlist = '0';
+foreach ($online as $k => $v) {
+  $inlist .= ', ' . implode( ', ', explode(' ',$online[$k]['last_elm_ids']));
+	$ql++;
+	if ($ql >= $conf_whois['Radar limit']) break;
+}
+$image = array();
+$result = pwg_query('SELECT * FROM ' . IMAGES_TABLE .
+	' WHERE id IN (' . $inlist .');');
+while ($row = mysql_fetch_assoc($result)) {
+	$images[$row['id']] = $row;
+	$images[$row['id']]['tn_url'] = get_thumbnail_url($row);
+}
 foreach ($online as $k => $v) {
   // The stupid History search will be reused instead of created... (even if History search will recreate it)
@@ -100,26 +114,18 @@
 		$online[$k]['guest'] =  false;
 	}
-	$ql++;
 	// Images queries are limited (no cluetip over $conf_whois['Radar limit'])
 	// For performance reasons
-	if ($ql <= $conf_whois['Radar limit']) {
-		$result = pwg_query('SELECT * FROM ' . IMAGES_TABLE .
-			' WHERE id IN (' . implode(', ',explode(' ',$online[$k]['last_elm_ids'])) .');');
-		while ($row = mysql_fetch_assoc($result)) {
-			$online[$k]['images'][$row['id']] = $row;
-			$online[$k]['images'][$row['id']]['ws_level'] = ($row['level']>$online[$k]['user']['level']) ? 'ws':'';
-			$online[$k]['images'][$row['id']]['tn_url'] = get_thumbnail_url($row);
-			$online[$k]['images'][$row['id']]['url_modify'] = PHPWG_ROOT_PATH . 'admin.php?page=picture_modify&image_id='.$row['id'];
-		}
-	} else {
-	// Only the id is available for links (NO LEVEL CONTROL)
-		foreach (explode(' ',$online[$k]['last_elm_ids']) as $id) {
-			if ($id > 0) {
+	$online[$k]['Bot'] = is_a_bot($online[$k]['user_agent']);
+	$online[$k]['last_ids'] = explode(' ',$online[$k]['last_elm_ids']);
+	foreach ($online[$k]['last_ids'] as $id) {
+			if (isset($images[$id])) {
+				$online[$k]['images'][$id] = $images[$id];
+				$online[$k]['images'][$id]['ws_level'] = ($images[$id]['level']>$online[$k]['user']['level']) ? 'ws':'';
+			}
 			$online[$k]['images'][$id]['id'] = $id;
-			$online[$k]['images'][$row['id']]['url_modify'] = PHPWG_ROOT_PATH . 'admin.php?page=picture_modify&image_id='.$id;
-			}
+			$online[$k]['images'][$id]['url_modify'] = PHPWG_ROOT_PATH . 'admin.php?page=picture_modify&image_id='.$id;
 		}
 	}
-}
+
 pwg_debug('*********** Radar reloaded ***********');
 $template->assign('search_results', $online);
Index: /extensions/whois_online/report.tpl
===================================================================
--- /extensions/whois_online/report.tpl	(revision 3694)
+++ /extensions/whois_online/report.tpl	(revision 3695)
@@ -42,5 +42,8 @@
 		{/if}
 	</td>
-  <td>{$detail.first_access_date}</td>
+  <td>{$detail.first_access_date} {if ($detail.Bot!==false and $detail.Allowed_SE)}<a class="other" href="#" title="{'Allowed Search engine: '|@translate}{$detail.Bot} - ({$detail.user_agent})"><sub>SE</sub></a>{/if}
+	{if ($detail.Bot!==false and !$detail.Allowed_SE and !$detail.Banned_SE)}<a href="#" title="{'Possible Banned Search engine: '|@translate}{$detail.Bot} - ({$detail.user_agent})"><sub>SE</sub></a>{/if}
+	{if ($detail.Bot!==false and $detail.Banned_SE)}<a class="external" href="#" title="{'Banned Search engine: '|@translate}{$detail.Bot} - ({$detail.user_agent})"><sub>SE</sub></a>{/if}
+	</td>
   <td>
 		<a href="./admin.php?page=user_perm&amp;user_id={$detail.user_id}" onclick="window.open(this.href); return false;" title="{'permissions'|@translate}">
