5

I just installed LDAP and PHPLDAPADMIN.Its work fine but when I want Create new entry page just refresh and nothing happend.There are a few errors:

Unrecognized error number: 8192: Function create_function() is deprecated

Errors in phpldapadmin

Thank you.

Jirka Vít
  • 51
  • 1
  • 1
  • 3

2 Answers2

22

Try this code working fine.

/usr/share/phpldapadmin/lib/functions.php on line 54

change line 54 to

function my_autoload($className) {

Add this code on line 777

spl_autoload_register("my_autoload"); 

change line 1083 to

$CACHE[$sortby] = __create_function('$a, $b',$code);

add the code below on line 1091 from the

   function __create_function($arg, $body) {
        static $cache = array();
        static $maxCacheSize = 64;
        static $sorter;

        if ($sorter === NULL) {
            $sorter = function($a, $b) {
                if ($a->hits == $b->hits) {
                    return 0;
                }

                return ($a->hits < $b->hits) ? 1 : -1;
            };
        }

        $crc = crc32($arg . "\\x00" . $body);

        if (isset($cache[$crc])) {
            ++$cache[$crc][1];
            return $cache[$crc][0];
        }

        if (sizeof($cache) >= $maxCacheSize) {
            uasort($cache, $sorter);
            array_pop($cache);
        }

        $cache[$crc] = array($cb = eval('return 
    function('.$arg.'){'.$body.'};'), 0);
        return $cb;
    }

finally restart your apache server sudo service apache2 restart

Andrew Samsonov
  • 30
  • 1
  • 1
  • 8
Senthil
  • 757
  • 2
  • 7
  • 25
  • 1
    added it written out in a link below but here it is again: https://github.com/wheelsmanx/phpldapadmin_functions – probsJustin Feb 06 '20 at 18:58
  • 1
    This fix is still working as of 27.12.2020, just check the link in the comment above and copy the functions.php into `/usr/share/phpldapadmin/lib` and don't forget to backup your old functions.php because you never know ;-) – Christoph Engwer Dec 27 '20 at 12:47
  • Worked in the repository installation of Ubuntu 18.04. Don't forget the ; guys. – Caio V. Aug 20 '21 at 23:12
2

PhpLdapAdmin uses a few functions which are deprecated in PHP 7.2. Take a look at this fix: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=890127