Salve, ho questo codice trovato in internet e funzionante sul mio server web.
	
	
	
		
come faccio tradurlo in una funzione e poi metterlo ad esempio qui:
	
	
	
		
lo trovato qui:
http://www.91weblessons.com/get-city-country-by-ip-address-in-php/
idea come fare?
grazie mille e buona giornata.
				
			
		PHP:
	
	<?php
/*Get user ip address*/
$ip_address=$_SERVER['REMOTE_ADDR'];
/*Get user ip address details with geoplugin.net*/
$geopluginURL='http://www.geoplugin.net/php.gp?ip='.$ip_address;
$addrDetailsArr = unserialize(file_get_contents($geopluginURL)); 
/*Get City name by return array*/
$city = $addrDetailsArr['geoplugin_city']; 
/*Get Country name by return array*/
$country = $addrDetailsArr['geoplugin_countryName'];
if(!$city){
   $city='Not Define';
}if(!$country){
   $country='Not Define';
}
echo '<strong>City</strong>:- '.$city.'<br/>';
echo '<strong>Country</strong>:- '.$country.'<br/>';
?>
	come faccio tradurlo in una funzione e poi metterlo ad esempio qui:
		PHP:
	
	$messaggio = "Nome:  ". $_POST["nome"]."<br />";
		$messaggio .= "Cognome:  ". $_POST["cognome"]."<br />";
		$messaggio .= "Indirizzo Ip:  ". $_SERVER["REMOTE_ADDR"]."<br />";
		$browser = getBrowser($_SERVER['HTTP_USER_AGENT']);
		$messaggio .= "Browser:  ". $browser."  <br />";
		$messaggio .= "Messaggio: <br />". nl2br(replace_text($_POST["messaggio"]))."<br />";
		$messaggio .= "=====================================================================";
		$oggetto = "Richiesta da : ".$_POST["oggetto"]."";
		
		invio_mail_contact($admin_email, $_POST["email"],$oggetto,$messaggio);
	lo trovato qui:
http://www.91weblessons.com/get-city-country-by-ip-address-in-php/
idea come fare?
grazie mille e buona giornata.