Page 1 of 1

php code displaying on site - whats wrong?

Posted: Wed Aug 26, 2015 5:29 pm
by earcandy
I added the following php code to my template in order to redirect mobile users to my mobile site.

It works great but I can see some of the code on the main webite.

"window.location=’https://californiaschooloflaw.com/admin/mobile/'”; } ?>"

What did I miss and how can I correct this?

Code: Select all

<head>
<?php
$iphone = strpos($_SERVER[‘HTTP_USER_AGENT’],”iPhone”);
$android = strpos($_SERVER[‘HTTP_USER_AGENT’],”Android”);
$palmpre = strpos($_SERVER[‘HTTP_USER_AGENT’],”webOS”);
$berry = strpos($_SERVER[‘HTTP_USER_AGENT’],”BlackBerry”);
$ipod = strpos($_SERVER[‘HTTP_USER_AGENT’],”iPod”);

if ($iphone || $android || $palmpre || $ipod || $berry == true) 
{
    echo “<__script__>window.location=’https://californiaschooloflaw.com/admin/mobile/'</__script>”;
 }
?>
 

Re: php code displaying on site - whats wrong?

Posted: Wed Aug 26, 2015 6:13 pm
by Dr.CSS
I think that should be in a UDT but w/o the open/close PHP partand if you really want to have raw PHP in your template I think there is a setting for that in the site admin or it is a setting/parameter in the config.php...

I don't know if this is it but it turns out there is no setting in site admin to let you use raw PHP in templates...

#Allow smarty {php} tags? These could be dangerous if you don't trust your users.
$config['use_smarty_php_tags'] = false;

I think that you can use either CGSimpleSmarty or CGExtensions to do a mobile check for redirect, I used a bit of JS for it myself...

Re: php code displaying on site - whats wrong?

Posted: Wed Aug 26, 2015 6:59 pm
by calguy1000
The use_smarty_php_tags stuff was removed from CMSMS in 1.11