01-31-2017, 07:34 AM
(This post was last modified: 01-31-2017, 07:37 AM by polanskiman.)
(01-31-2017, 07:16 AM)omarllorens Wrote: Hi.
Since 1 month ago, I think, we have updated Smarty to version 3. So this version not support more the php tags, you can read here: http://www.smarty.net/docs/en/language.function.php.tpl
We have updated all the templates removing all the php tags and write this code into php scripts to after assign this values to smarty variables.
For example:
If you want date('Y') on your template, you have to add this to the php file that call the template like this:
PHP Code:
$smarty = new vtigerCRM_Smarty();
$smarty->assign('YEAR', date('Y'));
And now on smarty template you can use YEAR variable like this: {$YEAR}
Thank you Omar. That's good to know. However that only addresses partially my issue. The code I provided above is just a sample. The remaining code I didn't post here is the one creating most the trouble. Here it is:
Code:
{php} echo "Your are connecting from IP ";
echo $_SERVER["REMOTE_ADDR"];
function get_ip_address() {
if (!empty($_SERVER['HTTP_CLIENT_IP']) && $this->validate_ip($_SERVER['HTTP_CLIENT_IP']))
return $_SERVER['HTTP_CLIENT_IP'];
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$iplist = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
foreach ($iplist as $ip) {
if ($this->validate_ip($ip))
return $ip;
}
}
if (!empty($_SERVER['HTTP_X_FORWARDED']) && $this->validate_ip($_SERVER['HTTP_X_FORWARDED']))
return $_SERVER['HTTP_X_FORWARDED'];
if (!empty($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']) && $this->validate_ip($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']))
return $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
if (!empty($_SERVER['HTTP_FORWARDED_FOR']) && $this->validate_ip($_SERVER['HTTP_FORWARDED_FOR']))
return $_SERVER['HTTP_FORWARDED_FOR'];
if (!empty($_SERVER['HTTP_FORWARDED']) && $this->validate_ip($_SERVER['HTTP_FORWARDED']))
return $_SERVER['HTTP_FORWARDED'];
return $_SERVER['REMOTE_ADDR'];
}
function validate_ip($ip) {
if (filter_var($ip, FILTER_VALIDATE_IP,
FILTER_FLAG_IPV4 |
FILTER_FLAG_IPV6 |
FILTER_FLAG_NO_PRIV_RANGE |
FILTER_FLAG_NO_RES_RANGE) === false)
return false;
self::$ip = $ip;
return true;
}
{/php}<br>
<a href='copyright.html' target='_blank'>{$APP.LNK_READ_LICENSE}</a>
|
<a href='http://corebos.org/page/privacy-policy' target='_blank'>{$APP.LNK_PRIVACY_POLICY}</a>
|
© 2004-{php} {date('Y') {/php}
I've left the old tag to show you how it was before. So how should my code be tagged from now on?