PHP snippet to Smarty code -


i'm looking convert php code smarty code, struggling function part.

<?php function get_client_ip_env() {           $ipaddress = '';             if (getenv('http_client_ip'))               $ipaddress = getenv('http_client_ip');             else if(getenv('http_x_forwarded_for'))               $ipaddress = getenv('http_x_forwarded_for');             else if(getenv('http_x_forwarded'))               $ipaddress = getenv('http_x_forwarded');             else if(getenv('http_forwarded_for'))               $ipaddress = getenv('http_forwarded_for');             else if(getenv('http_forwarded'))               $ipaddress = getenv('http_forwarded');             else if(getenv('remote_addr'))               $ipaddress = getenv('remote_addr');             else             $ipaddress = 'unknown';            return $ipaddress;}            $user_ip = get_client_ip_env();           $geo = unserialize(file_get_contents("http://www.geoplugin.net/php.gp?ip=$user_ip"));           $country = $geo["geoplugin_countrycode"];              if ($country == "gb") {               echo "you great britain";              } else {               echo "please visit our other website.";             }                       ?> 

the bit can last if statement. assistance on this?

could maybe logic in file loading template in question, , pass result smarty variable? feels neater, maybe - keeping display logic separate.

in answer question though, instance use {php} tags allow write raw php code untouched when .tpl files used generate php files display page - there's more information here.

hope helps!


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -