Possible to protect smarty templates with licensing?


I’m quite new to smarty and although I’ve been googling, reading books, and reading blogs… I can’t quite find anything relating to what I’m attempting to do. Possibly it is not possible but would like to feedback as to what direction I should follow.

Okay here is the scenario:

  1. I use a 3rd party php script that utilizes smarty for it’s template system. Thus the script comes with all the smarty files needed for smarty to work.

The script has a default set of smarty templates. The template system allows you to create your own template folder and if you use .tpl files with the same file name as the default template files, the file in the new template folder overwrites/bypasses the old file.

This allows me to completely rewrite the default theme in my own template folder, or just rewrite specific default templates files.

  1. I’ve created some custom themes for the php script, but I would like to release these templates to some of my clients. However I don’t want them to be able to give these templates away or use them on websites I didn’t authorize.

  2. I’m already using a PHP licensing system that I have setup and it’s being utilized for other projects that I have.

Now here is is I’m trying to do:

  1. In my template I have a index.tpl file. This file has the code to include the header.tpl, content.tpl, and footer.tpl files. The index.tpl file is what is used for the overall layout of the website.

  2. I have a licensecheck.php file. This file calls to my server with the license key and verifies whether or not it’s valid. This script consists of three files which is licensecheck.php, licensekey.txt, and localkey.txt.

The user enters the key in the licensekey.txt file, then when licensecheck.php is ran it grabs the key from that file and generates a local key in localkey.txt which serves as a fail-safe if the script can’t contact my server for the check.

  1. I was planning to create an /includes/ folder for these 3 files which would be located directly inside the specific template folder. Then have index.tpl call the licensecheck.php when it’s ran to verify the license.

  2. I was also planning to encode the licensecheck.php file via ioncube. I also wanted to encode the index.tpl file.

  3. I was thinking of having the licensecheck.php pass variables such as “valid” or “invalid” to the index.tpl file, and using a if statement to determine what the template should do with both values.

And here is the problem I’m seeing: (Maybe just from my lack of knowledge)

  1. smarty templates won’t work when you encode them with ioncube unless you use this patch:

The patch above requires the user to edit the smarty config, which I don’t want my clients to do. I just want them to upload the template folder and enable it in the script.

I don’t want to have to edit smarty engine files. However I’m open to the idea of me being able to write something to include with the template to make this possible.

  1. The licensecheck.php file I mentioned above, I want to encode that too via ioncube. But from my reading, it seems as though smarty won’t be able to render it if I did so without using the patch above.

I’m very open to ideas, suggestions, critiques, etc… Anything to point me into the right direction or clarify things like what can or can’t be done.

This is my first time trying to accomplish the licensing of a theme.

Thank you in advance for any replies :).
Crosses my fingers