Ecshop The new version cannot add PHP code directly in the template file. DWT and. LBI, why?
Because directly in the template to add PHP functions and code, not filtered, easy to create security risks. The program source code security is very important.
But what if a friend wants to add PHP code directly to the template file?
In fact, just need to change a file, namely includes/cls_template.php
Open this file to find function Fetch_str ($source)
Found in this function, approximately 288 lines
if(Preg_match_all(' ~ (<\? (?:\ w+|=)? | \?>|language\s*=\s*[\ "\ ']?php[\" \ ']?) ~is ',$source,$sp _match)) { $sp _match[1] =Array_unique($sp _match[1]); for($curr _sp= 0,$for _max2=Count($sp _match[1]);$curr _sp<$for _max2;$curr _sp++) { $source=Str_replace($sp _match[1] [$curr _sp], '%%%SMARTYSP '.$curr _sp.‘ %%%‘,$source); } for($curr _sp= 0,$for _max2=Count($sp _match[1]);$curr _sp<$for _max2;$curr _sp++) { $source=Str_replace('%%%SMARTYSP '.$curr _sp.‘ %%% ', ' <?php echo \ '.Str_replace("‘", "\‘",$sp _match[1] [$curr _sp]).‘ \ ';?> '. " \ n ",$source); } }
Remove or annotate this piece of code directly.
Log in to the background update cache, you can then insert the PHP code in the template file to try.