0

I wonder if it is possible to create a loader file, which handles loading the ioncube loader. The usual way is that the encoded file tries to detect the ioncube loader and throws an error if it could not be found:

if(!extension_loaded('ionCube Loader')){$__oc=strtolower(substr(php_uname(),0,3));$__ln='ioncube_loader_'.$__oc.'_'.substr(phpversion(),0,3).(($__oc=='win')?'.dll':'.so');if(function_exists('dl')){@dl($__ln);}if(function_exists('_il_exec')){return _il_exec();}$__ln='/ioncube/'.$__ln;$__oid=$__id=realpath(ini_get('extension_dir'));$__here=dirname(__FILE__);if(strlen($__id)>1&&$__id[1]==':'){$__id=str_replace('\\','/',substr($__id,2));$__here=str_replace('\\','/',substr($__here,2));}$__rd=str_repeat('/..',substr_count($__id,'/')).$__here.'/';$__i=strlen($__rd);while($__i--){if($__rd[$__i]=='/'){$__lp=substr($__rd,0,$__i).$__ln;if(file_exists($__oid.$__lp)){$__ln=$__lp;break;}}}if(function_exists('dl')){@dl($__ln);}}else{die('The file '.__FILE__." is corrupted.\n");}if(function_exists('_il_exec')){return _il_exec();}echo('Site error: the file <b>'.__FILE__.'</b> requires the ionCube PHP Loader '.basename($__ln).' to be installed by the website operator. If you are the website operator please use the <a href="http://www.ioncube.com/lw/">ionCube Loader Wizard</a> to assist with installation.');exit(199);

Depending on the hosting environment, the ioncube loader is inserted e.g. via a php.ini file declaring it as a ZendExtension. It is possible to port the loading of an ZendExtenion directly to the php file and bundle the loader to the php-file instead of having the ioncube loader installed?

Stefan
  • 137
  • 13

1 Answers1

1

Not really. PHP used to have a function called dl() that could install a PHP module on the fly, and this is what the code at the start of ionCube encoded files uses with its "runtime loading" mechanism. Loaders could be bundled with an application and the application would often run without any install changes, which was great. There were some changes in PHP 5.2.5 that impacted this mechanism a little, but dl() really became less useful as of PHP 5.3 where it was removed from some SAPI's. The mechanism will still work for some servers, but a php.ini install is generally the required way now.

Nick
  • 1,334
  • 10
  • 14
  • I don't know if it's a good idea to provide a bootstrap php script to install/enhance a php.ini file to cover this issue? – Stefan Mar 13 '14 at 14:55
  • Such a PHP script would be unlikely to have write access to create a php.ini file, so in general this isn't possible. There is an ionCube Loader Wizard script that can give advice on what edit to make, which can also give a download of an edited php.ini file to install. There is now also an ionCube Loader Installer than can deploy the necessary Loader to a local or remote server over FTP or SSH. Having access to the target server, the Installer *can* create and/or edit php.ini file(s) as necessary, and is recommended to use. The Installer can also create support tickets for assistance. – Nick Mar 14 '14 at 19:13
  • Write access may be an issue, but the main issue is that people installing ioncube-encoded software do not want to be bothered with any installation way of the ioncube loader. Suppose you have (e.g. within a CMS) the usual directory containing the main index.php, the php.ini file only has to be put in the same directory. – Stefan Mar 15 '14 at 08:45
  • My idea is to simplyfy the installation process for those customers whose php.ini may be written. I'll try to create kind of a bootstrap loader that figures out if ioncube is already installed, try to install it otherwise, if this fails, an "early" error message will be thrown. – Stefan Mar 15 '14 at 08:51