Smarty and Encrypted Template Files
With the release of 6.5 onwards, the ionCube PHP Encoder has the ability to encrypt
any non-PHP files as well as encoding PHP files. The ionCube PHP Loader
extends PHP with functions to decrypt these files. This means that it is now possible to encrypt and distribute secure templates with your projects!
On this page we provide
a patch to the popular Smarty template engine enabling Smarty to read encrypted template files.
These encrypted template files can be created automatically by the ionCube Encoder at the same time as the PHP
scripts are encoded.
The patch to Smarty is extremely simple - we have replaced a function that reads the contents of the template
file with a call to the Loader function that reads encrypted files. Since this Loader function is able to read both
encrypted and unencrypted files, the modified version of Smarty will work seamlessly with both encrypted and regular
unencrypted templates. The same approach can undoubtedly be used for other template engines, reading/writing XML documents and configuration files, etc. Please note that the script calling
ioncube_read_file(), e.g. the template engine, must be encoded.
To apply the patch, simply comment out the method _read_file in the file Smarty.class.php in the Smarty source, and insert the replacement method. The method can be viewed by clicking the link below.