Author |
Message |
Vishal
Joined: 21 Aug 2014 Posts: 5
|
Posted: Thu Aug 21, 2014 12:27 pm Post subject: Not able to decode Smarty template files (Smarty 3.1.18) |
|
|
I use Smarty 3.1.18 as a template engine in my project, After successfully encoding files (including .php,.tpl files and Smarty library) with all Obfuscation options checked, when i run my project getting following error
Fatal error: Uncaught exception 'LogicException' with message 'Function 'smartyAutoload' not found (function 'smartyAutoload' not found or invalid function name)' in C:\ccstack\htdocs\App_Encode\Smarty\libs\Smarty.class.php:0 Stack trace: #0 C:\ccstack\htdocs\App_Encode\Smarty\libs\Smarty.class.php(0): [obfuscated]() #1 C:\ccstack\htdocs\App_Encode\index.php(0): unknown() #2 {main} thrown in C:\ccstack\htdocs\App_Encode\Smarty\libs\Smarty.class.php on line 0
The patch which is provided by ionCube works for Smarty 2.* versions.
I tried replacing getContent() function in /libs/sysplugins/smarty_internal_resource_file.php with..
Code: | public function getContent(Smarty_Template_Source $source)
{
if ($source->timestamp) {
if (function_exists('ioncube_read_file')) {
return ioncube_read_file($source->filepath);
} else {
return file_get_contents($source->filepath);
}
}
if ($source instanceof Smarty_Config_Source) {
throw new SmartyException("Unable to read config {$source->type} '{$source->name}'");
}
throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
}
|
Please help me out!!  |
|
Back to top |
|
 |
liaison ionCube Support
Joined: 16 Dec 2004 Posts: 2788
|
Posted: Thu Aug 21, 2014 7:21 pm Post subject: |
|
|
The error is expected behaviour because the Encoder has renamed smartyAutoload and you are specifying its original name.
Create an obfuscation exclusion list and exclude smartyAutoload from being obfuscated. _________________ Community Admin |
|
Back to top |
|
 |
Vishal
Joined: 21 Aug 2014 Posts: 5
|
Posted: Mon Aug 25, 2014 1:03 pm Post subject: |
|
|
Hi,
Thanks for replying ..
I have created obfuscation exclusion list and mentioned all the classes and functions which were giving problem. I have encrypted both .js and .css files by mentioning in Non-PHP encryption extensions.
Now I am able to see the output of my page but not able to include external javascript or css files. Getting following error msg in firebug console... If i dont encrypt them then everything is working fine...
Code: | SyntaxError: missing ; before statement
!odMbo! |
Code: | ReferenceError: jQuery is not defined
jQuery('#Div1').show(); |
My exclusion file contain following classes and Methods
[classes]
Smarty_Template_Compiled
Smarty
Smarty_Template_Source
Smarty_Resource
Smarty_Internal_Template
Smarty_Internal_Resource_File
[methods]
compileTemplateSource
getContent
populate
smarty
source
__set
__get
__call
__construct
load
getBasename
fileExists
buildFilepath
populateCompiledFilepath
buildUniqueResourceName
renderUncompiled
getCompiled
getCompileDir
getTemplateDir
getPluginsDir
config
getUniqueTemplateName
parseResourceName
display
assign
smartyAutoload
loadPlugin
|
|
Back to top |
|
 |
Vishal
Joined: 21 Aug 2014 Posts: 5
|
Posted: Wed Aug 27, 2014 3:09 pm Post subject: |
|
|
Can anybody help me it's urgent !!! |
|
Back to top |
|
 |
liaison ionCube Support
Joined: 16 Dec 2004 Posts: 2788
|
Posted: Wed Aug 27, 2014 6:31 pm Post subject: |
|
|
.css and .js files are going to be sent directly to the browser by the web server. How will the browser know how to decrypt ionCube files? _________________ Community Admin |
|
Back to top |
|
 |
Vishal
Joined: 21 Aug 2014 Posts: 5
|
Posted: Thu Aug 28, 2014 6:41 am Post subject: |
|
|
So basically you are saying ioncube_read_file function will not help in that case?
.js and .css files are included in TPL files. |
|
Back to top |
|
 |
liaison ionCube Support
Joined: 16 Dec 2004 Posts: 2788
|
Posted: Thu Aug 28, 2014 9:39 pm Post subject: |
|
|
Not exactly, but you need to think about things a bit. A .css file is going to sent to the browser directly by the web server, so there's no chance for our software to process it. What you could do is create a php file whose job is to serve your css and js files. Pass it a parameter to say what file is to be served, and the script could then call ioncube_read_file() to decrypt the file and produce the content. So this keeps the files secure, but as the content has to reach the browser unencrypted, is there any point? Even if you prevented hot linking, the browser would still cache the js and css. To avoid that you could use headers to tell the browser not to cache, but then you're seriously impairing the end user experience by not leveraging browser caching. It's not a good path to be going down. _________________ Community Admin |
|
Back to top |
|
 |
Vishal
Joined: 21 Aug 2014 Posts: 5
|
Posted: Mon Sep 01, 2014 12:43 pm Post subject: |
|
|
Okay I get your point ...Now I am encrypting only .tpl and .php files..
Many a times I got following error
Fatal error: Class '[obfuscated]' not found in... Same in case of functions and methods..
So I had to put most of my user defined functions and classes in Obfuscation exclusion file after that my application runs fine. Is it normal? Do I have any other option? Because the actual application for which I am going to use IonCube encoder is much bigger and contains many user defined classes and functions. |
|
Back to top |
|
 |
liaison ionCube Support
Joined: 16 Dec 2004 Posts: 2788
|
Posted: Tue Sep 02, 2014 2:43 pm Post subject: |
|
|
Names needing to be called from non-encoded files would need to be excluded from obfuscation because changing the names is what obfuscation does. So what would need to be excluded would depend on how much of the application is encoded. _________________ Community Admin |
|
Back to top |
|
 |
|