5

I am using PHTML encoder to encode my php file but it is giving error "Call to undefined function dl()" when i run the encoded file. Somebody please help.

<?php
    if(!function_exists("phtmldec")){
        $w=(substr(PHP_OS,0,3)=="WIN")?1:0;$ln="phtmlenc".phpversion();$cd=dirname(__FILE__);

        if($w){
            $ln=$ln.".dll";if($cd[1]==":") $cd=substr($cd,2);
        } else {
            $ln=$ln.".so";if(strlen($cd)<3) $cd=getcwd();
        }

        if(version_compare(phpversion(),"5.2.5")==-1){
            $cd1=ini_get('extension_dir');
            $cd2=PHP_EXTENSION_DIR;

            if($cd[strlen($cd)-1]!="/")$cd=$cd."/";

            if($cd1[strlen($cd1)-1]!="/")$cd1=$cd1."/";

            if($cd2[strlen($cd2)-1]!="/")$cd2=$cd2."/";

            if($cd1[1]==":") $cd1=substr($cd1,2);

            if($cd2[1]==":") $cd2=substr($cd2,2);

            $ic=substr_count($cd,"\\")+substr_count($cd,"/");
            $ic1=substr_count($cd1,"\\")+substr_count($cd1,"/");
            $ic2=substr_count($cd2,"\\")+substr_count($cd2,"/");
            $en=str_repeat("../",max($ic,$ic1,$ic2))."..".$cd.$ln;
        } else {
            $en=$ln;$r=dl($en);if(!$r)exit("Unable to load $en");
        }

        $p="F4\$A016YC2@Y(8Q[Y!2F3[@K2.0>K0Z%5^#2\\,&;5L7\$<KHL)BH<`";
        phtmldec($p);
    }
?>
aleation
  • 4,796
  • 1
  • 21
  • 35
Happy
  • 792
  • 2
  • 10
  • 32

1 Answers1

3

as @k102 mentioned dl() has been disabled by default since 5.3:

as refered on the php documentation: http://php.net/manual/en/function.dl.php

    5.3.0   dl() is now disabled in some SAPIs due to stability issues.
The only SAPIs that allow dl() are CLI and Embed. Use the Extension Loading Directives instead.

as suggested there, use the Extension Loading Directives instead: http://www.php.net/manual/en/ini.core.php#ini.extension


Basically your only choices are:

  1. Load the extension configuring it properly on the php.ini
  2. Use one of the mentioned SAPI's that still supports dl() as mentioned in the documentation: (CLI, CGI and Embed)
  3. Downgrade your php version if you really need to load it dinamically
aleation
  • 4,796
  • 1
  • 21
  • 35
  • I used 'dl(php_curl)' (dinamyc load) to enable php_curl when using `php -f file.php` method (CLI as mentioned) and was faster than edit original php.ini and than create a new once php.ini then load it with `-c /path/php.ini`. Because CLI passes filename as $argv[0], just need to check for non-emtpy $argv with `if(@!empty($argv)) dl('php_curl');` to load it. – m3nda Mar 04 '15 at 07:25
  • 1
    Are there any alterntives to load php extensions at runtime ? e.g. when you have no controll over the php ini on hosted servers ? – Radon8472 Apr 28 '20 at 12:58