equal
deleted
inserted
replaced
12 * obtain it through the world-wide-web, please send an email |
12 * obtain it through the world-wide-web, please send an email |
13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Ldap |
16 * @package Zend_Ldap |
17 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
18 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @version $Id: Converter.php 24593 2012-01-05 20:35:02Z matthew $ |
19 * @version $Id$ |
20 */ |
20 */ |
21 |
21 |
22 /** |
22 /** |
23 * Zend_Ldap_Converter is a collection of useful LDAP related conversion functions. |
23 * Zend_Ldap_Converter is a collection of useful LDAP related conversion functions. |
24 * |
24 * |
25 * @category Zend |
25 * @category Zend |
26 * @package Zend_Ldap |
26 * @package Zend_Ldap |
27 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
27 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
28 * @license http://framework.zend.com/license/new-bsd New BSD License |
28 * @license http://framework.zend.com/license/new-bsd New BSD License |
29 */ |
29 */ |
30 class Zend_Ldap_Converter |
30 class Zend_Ldap_Converter |
31 { |
31 { |
32 const STANDARD = 0; |
32 const STANDARD = 0; |
67 * @param string $string String to convert |
67 * @param string $string String to convert |
68 * @return string |
68 * @return string |
69 */ |
69 */ |
70 public static function hex32ToAsc($string) |
70 public static function hex32ToAsc($string) |
71 { |
71 { |
72 $string = preg_replace("/\\\([0-9A-Fa-f]{2})/e", "''.chr(hexdec('\\1')).''", $string); |
72 // Using a callback, since PHP 5.5 has deprecated the /e modifier in preg_replace. |
|
73 $string = preg_replace_callback("/\\\([0-9A-Fa-f]{2})/", array('Zend_Ldap_Converter', '_charHex32ToAsc'), $string); |
73 return $string; |
74 return $string; |
|
75 } |
|
76 |
|
77 /** |
|
78 * Convert a single slash-prefixed character from Hex32 to ASCII. |
|
79 * Used as a callback in @see hex32ToAsc() |
|
80 * @param array $matches |
|
81 * |
|
82 * @return string |
|
83 */ |
|
84 private static function _charHex32ToAsc(array $matches) |
|
85 { |
|
86 return chr(hexdec($matches[0])); |
74 } |
87 } |
75 |
88 |
76 /** |
89 /** |
77 * Convert any value to an LDAP-compatible value. |
90 * Convert any value to an LDAP-compatible value. |
78 * |
91 * |