Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PHP tag in templates
#3
(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>
|
&copy; 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?
Reply


Messages In This Thread
PHP tag in templates - polanskiman - 01-31-2017, 06:54 AM
RE: PHP tag in templates - omarllorens - 01-31-2017, 07:16 AM
RE: PHP tag in templates - polanskiman - 01-31-2017, 07:34 AM
RE: PHP tag in templates - omarllorens - 01-31-2017, 07:54 AM
RE: PHP tag in templates - polanskiman - 01-31-2017, 08:05 AM
RE: PHP tag in templates - omarllorens - 01-31-2017, 08:17 AM
RE: PHP tag in templates - polanskiman - 01-31-2017, 08:22 AM
RE: PHP tag in templates - omarllorens - 01-31-2017, 08:27 AM
RE: PHP tag in templates - polanskiman - 01-31-2017, 08:55 AM
RE: PHP tag in templates - joebordes - 01-31-2017, 11:02 AM
RE: PHP tag in templates - polanskiman - 02-01-2017, 02:51 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)