Index: /extensions/whois_online/Changelog.txt.php
===================================================================
--- /extensions/whois_online/Changelog.txt.php	(revision 5809)
+++ /extensions/whois_online/Changelog.txt.php	(revision 5810)
@@ -3,4 +3,8 @@
 Plugin Name: Whois online
 ** History **
+  2010-04-11 2.0.k
+						 MySQL 4.1 support
+						 Alternate reading solutions: file_get_contents / fsockopen / curl
+						 Replace of deprecated functions as of PHP 5.3.0
   2009-07-28 2.0.j
 						 Minor changes in Config management
Index: /extensions/whois_online/main.inc.php
===================================================================
--- /extensions/whois_online/main.inc.php	(revision 5809)
+++ /extensions/whois_online/main.inc.php	(revision 5810)
@@ -23,5 +23,5 @@
 /*
 Plugin Name: Whois online
-Version: 2.0.j
+Version: 2.0.k
 Description: Who is online?
 Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=279
@@ -29,5 +29,5 @@
 Author URI: http://www.vdigital.org
 */
-define('WHOIS_ONLINE_VER', '2.0.j'); 
+define('WHOIS_ONLINE_VER', '2.0.k'); 
 global $prefixeTable, $conf;
 // $conf['debug_l10n'] = true;
Index: /extensions/whois_online/maintain.inc.php
===================================================================
--- /extensions/whois_online/maintain.inc.php	(revision 5809)
+++ /extensions/whois_online/maintain.inc.php	(revision 5810)
@@ -16,8 +16,8 @@
   `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 '',
+  `country` VARCHAR( 255 ) NOT NULL DEFAULT '',
   `user_agent` VARCHAR( 160 ) NOT NULL DEFAULT '',
-  `any_previous` VARCHAR( 256 ) NOT NULL DEFAULT '',
-  `same_previous` VARCHAR( 256 ) NOT NULL DEFAULT '',
+  `any_previous` VARCHAR( 255 ) NOT NULL DEFAULT '',
+  `same_previous` VARCHAR( 255 ) NOT NULL DEFAULT '',
   `permanent` enum('true','false') NOT NULL DEFAULT 'false',
   `last_access` varchar(12) NOT NULL DEFAULT '',
Index: /extensions/whois_online/online.php
===================================================================
--- /extensions/whois_online/online.php	(revision 5809)
+++ /extensions/whois_online/online.php	(revision 5810)
@@ -49,7 +49,83 @@
 }
 
-
-
-
+if ( !function_exists('pwg_get_contents') ) {
+	function pwg_get_contents($url, $mode='') {
+
+		global $pwg_mode, $pwg_prev_host;
+		$timeout = 5; // will be a parameter (only for the socket)
+
+		$host = (strtolower(substr($url,0,7)) == 'http://') ? substr($url,7) : $url;
+		$host = (strtolower(substr($host,0,8)) == 'https://') ? substr($host,8) : $host;
+		$doc = substr($host, strpos($host, '/'));
+		$host = substr($host, 0, strpos($host, '/'));
+
+		if ($pwg_prev_host != $host) $pwg_mode = ''; // What was possible with one website could be different with another
+		$pwg_prev_host = $host;
+		if (isset($pwg_mode)) $mode = $pwg_mode;
+		if ($mode == 'r') $mode = '';
+		// $mode = 'ch'; // Forcing a test '' all, 'fs' fsockopen, 'ch' cURL
+
+	// 1 - The simplest solution: file_get_contents
+	// Contraint: php.ini
+	//      ; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
+	//      allow_url_fopen = On
+		if ( $mode == '' ) {
+		  if ( true === (bool) ini_get('allow_url_fopen') ) { 
+				$value = file_get_contents($url);
+				if ( $value !== false and substr($value,0,21) != '<!DOCTYPE HTML PUBLIC') {
+					return $value;
+				}
+			}
+		}
+		if ( $mode == '' ) $mode = 'fs';
+		if ( $pwg_mode == '' ) $pwg_mode = 'fs'; // Remind it
+	// 2 - Often accepted access: fsockopen
+		if ($mode == 'fs') {
+			$fs = fsockopen($host, 80, $errno, $errstr, $timeout);
+			if ( $fs !== false ) {
+				fwrite($fs, 'GET ' . $doc . " HTTP/1.1\r\n");
+				fwrite($fs, 'Host: ' . $host . "\r\n");
+				fwrite($fs, "Connection: Close\r\n\r\n");
+				stream_set_blocking($fs, TRUE);
+				stream_set_timeout($fs,$timeout); // Again the $timeout on the get
+				$info = stream_get_meta_data($fs);
+				$value = '';
+				while ((!feof($fs)) && (!$info['timed_out'])) {
+								$value .= fgets($fs, 4096);
+								$info = stream_get_meta_data($fs);
+								flush();
+				}
+				if ( $info['timed_out'] === false  and substr($value,0,21) != '<!DOCTYPE HTML PUBLIC') return $value;
+			}
+		}
+
+		if ( $pwg_mode == 'fs' ) $pwg_mode = 'ch'; // Remind it
+	// 3 - Sometime another solution: curl_exec
+	// See http://fr2.php.net/manual/en/curl.installation.php
+	  if (function_exists('curl_init') and $pwg_mode == 'ch') {
+			$ch = @curl_init();
+			@curl_setopt($ch, CURLOPT_URL, $url);
+			@curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
+			@curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
+			@curl_setopt($ch, CURLOPT_HEADER, 1);
+			@curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0');
+			@curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+			@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
+			$value = @curl_exec($ch);
+			$header_length = @curl_getinfo($ch, CURLINFO_HEADER_SIZE);
+			$status = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
+			@curl_close($value);
+			if ($value !== false and $status >= 200 and $status < 400) {
+				$value = substr($value, $header_length);
+				// echo '<br/>-ch- ('. $value . ') <br/>';
+				return $value;
+			}
+			else $pwg_mode = 'failed'; // Sorry but remind it as well
+		}
+
+		// No other solutions
+		return false;
+	}
+}
 // Assume the Default display on pages
 function whois_default_display() {
@@ -89,5 +165,5 @@
 function whois_country($trace, $bypass = false) {
   if (!isset($trace['country'])) {
-			pwg_query('ALTER TABLE ' . WHOIS_ONLINE_TABLE . ' ADD `country` VARCHAR( 256 ) NOT NULL AFTER `lang` ;');
+			pwg_query('ALTER TABLE ' . WHOIS_ONLINE_TABLE . ' ADD `country` VARCHAR( 255 ) NOT NULL AFTER `lang` ;');
 			$trace['country']='';
 	}
@@ -96,16 +172,13 @@
 	if (isset($c['Code']) and $c['Code']!='' and $c['Code']!='__') return $c; 
 	if ($bypass and isset($c['Code']) and $c['Code']=='__') return $c;
-  $f = @fopen ('http://api.hostip.info/get_html.php?ip=' . $trace['IP'], 'r');
-	if ($f === FALSE) return Array('Code' => '__', 'Name' => l10n('Unknown country'), 'City' => 'N/A',);
-	$result='';
-	while ($l = fgets ($f, 1024)) $result .= $l;
-	fclose ($f);
-	$tokens = split ("[:\n]", $result);
-	$c = array ('Name' => $tokens[1], 'City' => $tokens[3]);
-	if (strpos ($c['Name'], '?') === FALSE) {
-		$tokens = split ("[\(\)]", $c['Name']);
-		$c['Code'] = isset($tokens[1]) ? $tokens[1]:'__';
-		$c['Name'] = ucwords ( strtolower( ereg_replace
-			(' \([^\)]+)', '', $c['Name'])));
+    $result = pwg_get_contents ('http://api.hostip.info/get_html.php?ip=' . $trace['IP'], 'r');
+	if ( $result !== false ) { 
+		$tokens = preg_split("/[:]+/", $result);
+		$c = array ('Name' => $tokens[1], 'City' => substr($tokens[3],0,-3));
+		if (strpos ($c['Name'], '?') === FALSE) {
+			$tokens = preg_split ("/[\(\)]/", $c['Name']);
+			$c['Code'] = isset($tokens[1]) ? $tokens[1]:'__';
+			$c['Name'] = ucwords ( strtolower( substr($c['Name'],0,-5)));
+		}
 	}
 	else $c = Array('Code' => '__', 'Name' => l10n('Unknown country'), 'City' => 'N/A',);
@@ -127,9 +200,9 @@
 	if (file_exists($flag)) return $flag;
 	if ( $step > $limit ) return WHOIS_ONLINE_PATH . 'flags/__.jpg';
-	$f = fopen ('http://api.hostip.info/flag.php?ip=' . $trace['IP'], 'r');
-	$result='';
-	while ($l = fgets ($f, 1024)) $result .= $l;
-	fclose ($f);
-	$f = fopen($flag,"w+");
+        $f = fopen  ('http://api.hostip.info/flag.php?ip=' . $trace['IP'], 'r');
+        $result='';
+        while ($l = fgets ($f, 1024)) $result .= $l;
+        fclose ($f);
+		$f = fopen($flag,"w+");
 	fputs($f,$result);
 	fclose($f);
@@ -385,7 +458,7 @@
   if (!isset($global['any_previous'])) {
 		pwg_query('ALTER TABLE ' . WHOIS_ONLINE_TABLE . 
-			' ADD `same_previous` VARCHAR( 256 ) NOT NULL DEFAULT \'\'  AFTER `country`;');
+			' ADD `same_previous` VARCHAR( 255 ) NOT NULL DEFAULT \'\'  AFTER `country`;');
 		pwg_query('ALTER TABLE ' . WHOIS_ONLINE_TABLE . 
-			' ADD `any_previous` VARCHAR( 256 ) NOT NULL DEFAULT \'\'  AFTER `country`;');
+			' ADD `any_previous` VARCHAR( 255 ) NOT NULL DEFAULT \'\'  AFTER `country`;');
 		pwg_query('ALTER TABLE ' . WHOIS_ONLINE_TABLE . 
 			' ADD `user_agent` VARCHAR( 160 ) NOT NULL DEFAULT \'\'  AFTER `country`;');
