Annotation of pkgsrc/databases/phpldapadmin/patches/patch-lib_functions.php, revision 1.4

1.4     ! khorben     1: $NetBSD: patch-lib_functions.php,v 1.3 2015/11/29 11:25:53 taca Exp $
1.1       taca        2: 
1.3       taca        3: Fix for PHP 5.5 and later: 
                      4:        https://bugzilla.redhat.com/show_bug.cgi?id=974928
1.1       taca        5: 
1.3       taca        6: --- lib/functions.php.orig     2012-10-01 06:54:14.000000000 +0000
1.1       taca        7: +++ lib/functions.php
1.4     ! khorben     8: @@ -51,7 +51,7 @@ if (file_exists(LIBDIR.'functions.custom
        !             9:  /**
        !            10:   * Loads class definition
        !            11:   */
        !            12: -function __autoload($className) {
        !            13: +function pla_autoload($className) {
        !            14:        if (file_exists(HOOKSDIR."classes/$className.php"))
        !            15:                require_once(HOOKSDIR."classes/$className.php");
        !            16:        elseif (file_exists(LIBDIR."$className.php"))
        !            17: @@ -66,6 +66,12 @@ function __autoload($className) {
        !            18:                        'type'=>'error'));
        !            19:  }
        !            20:  
        !            21: +if (version_compare(phpversion(), '7.0', '>=')) {
        !            22: +      spl_autoload_register('pla_autoload');
        !            23: +} else {
        !            24: +      eval('function __autoload($className) {pla_autoload($className);}');
        !            25: +}
        !            26: +
        !            27:  /**
        !            28:   * Strips all slashes from the specified array in place (pass by ref).
        !            29:   * @param Array The array to strip slashes from, typically one of
        !            30: @@ -994,6 +1000,22 @@ function get_custom_file($index,$filenam
        !            31:  }
        !            32:  
        !            33:  /**
        !            34: + * Replacement for create_function() which is deprecated as of PHP 7.2
        !            35: + *
        !            36: + * @param string The function arguments
        !            37: + * @param string The function code
        !            38: + */
        !            39: +function pla_create_function($args, $code) {
        !            40: +      if (version_compare(phpversion(), '7.0', '>=')) {
        !            41: +              # anonymous functions were introduced in PHP 5.3.0
        !            42: +              return eval("return function(".$args."){".$code."};");
        !            43: +      } else {
        !            44: +              # create_function is deprecated in PHP 7.2
        !            45: +              return create_function($args, $code);
        !            46: +      }
        !            47: +}
        !            48: +
        !            49: +/**
        !            50:   * Sort a multi dimensional array.
        !            51:   *
        !            52:   * @param array Multi demension array passed by reference
        !            53: @@ -1080,7 +1102,7 @@ function masort(&$data,$sortby,$rev=0) {
        !            54:  
        !            55:                $code .= 'return $c;';
        !            56:  
        !            57: -              $CACHE[$sortby] = create_function('$a, $b',$code);
        !            58: +              $CACHE[$sortby] = pla_create_function('$a, $b',$code);
        !            59:        }
        !            60:  
        !            61:        uasort($data,$CACHE[$sortby]);
        !            62: @@ -2127,7 +2149,7 @@ function password_types() {
1.3       taca       63:   *        crypt, ext_des, md5crypt, blowfish, md5, sha, smd5, ssha, sha512, or clear.
1.1       taca       64:   * @return string The hashed password.
                     65:   */
1.3       taca       66: -function password_hash($password_clear,$enc_type) {
                     67: +function pla_password_hash($password_clear,$enc_type) {
                     68:        if (DEBUG_ENABLED && (($fargs=func_get_args())||$fargs='NOARGS'))
                     69:                debug_log('Entered (%%)',1,0,__FILE__,__LINE__,__METHOD__,$fargs);
                     70:  
1.4     ! khorben    71: @@ -2318,7 +2340,7 @@ function password_check($cryptedpassword
1.3       taca       72:  
                     73:                # SHA crypted passwords
                     74:                case 'sha':
                     75: -                      if (strcasecmp(password_hash($plainpassword,'sha'),'{SHA}'.$cryptedpassword) == 0)
                     76: +                      if (strcasecmp(pla_password_hash($plainpassword,'sha'),'{SHA}'.$cryptedpassword) == 0)
                     77:                                return true;
                     78:                        else
                     79:                                return false;
1.4     ! khorben    80: @@ -2327,7 +2349,7 @@ function password_check($cryptedpassword
1.3       taca       81:  
                     82:                # MD5 crypted passwords
                     83:                case 'md5':
                     84: -                      if( strcasecmp(password_hash($plainpassword,'md5'),'{MD5}'.$cryptedpassword) == 0)
                     85: +                      if( strcasecmp(pla_password_hash($plainpassword,'md5'),'{MD5}'.$cryptedpassword) == 0)
                     86:                                return true;
                     87:                        else
                     88:                                return false;
1.4     ! khorben    89: @@ -2392,7 +2414,7 @@ function password_check($cryptedpassword
        !            90:  
        !            91:                # SHA512 crypted passwords
        !            92:                case 'sha512':
        !            93: -                      if (strcasecmp(password_hash($plainpassword,'sha512'),'{SHA512}'.$cryptedpassword) == 0)
        !            94: +                      if (strcasecmp(pla_password_hash($plainpassword,'sha512'),'{SHA512}'.$cryptedpassword) == 0)
        !            95:                                return true;
        !            96:                        else
        !            97:                                return false;
        !            98: @@ -2565,12 +2587,14 @@ function dn_unescape($dn) {
1.3       taca       99:                $a = array();
                    100:  
                    101:                foreach ($dn as $key => $rdn)
                    102: -                      $a[$key] = preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$rdn);
                    103: +                      $a[$key] = preg_replace_callback('/\\\([0-9A-Fa-f]{2})/', 
                    104: +                              function ($matches) { return chr(hexdec($matches[1])); }, $rdn );
                    105:  
                    106:                return $a;
                    107:  
                    108:        } else {
                    109: -              return preg_replace('/\\\([0-9A-Fa-f]{2})/e',"''.chr(hexdec('\\1')).''",$dn);
                    110: +              return preg_replace_callback('/\\\([0-9A-Fa-f]{2})/',
                    111: +                              function ($matches) { return chr(hexdec($matches[1])); }, $dn);
                    112:        }
                    113:  }
1.1       taca      114:  

CVSweb <webmaster@jp.NetBSD.org>