Completed
Branch decaf-fixes/main (0c91cf)
by
unknown
07:32 queued 02:36
created
core/middleware/EE_Recommended_Versions.core.php 1 patch
Indentation   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -17,75 +17,75 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * @deprecated
22
-     * @param EE_Request  $request
23
-     * @param EE_Response $response
24
-     * @return EE_Response
25
-     */
26
-    public function handle_request(EE_Request $request, EE_Response $response)
27
-    {
28
-        EE_Error::doing_it_wrong(
29
-            __METHOD__,
30
-            sprintf(
31
-                esc_html__(
32
-                    'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
33
-                    'event_espresso'
34
-                ),
35
-                'EventEspresso\core\services\request\middleware\RecommendedVersions',
36
-                '\core\services\request',
37
-                'EventEspresso\core\services\request'
38
-            ),
39
-            '4.9.52'
40
-        );
41
-        return $response;
42
-    }
20
+	/**
21
+	 * @deprecated
22
+	 * @param EE_Request  $request
23
+	 * @param EE_Response $response
24
+	 * @return EE_Response
25
+	 */
26
+	public function handle_request(EE_Request $request, EE_Response $response)
27
+	{
28
+		EE_Error::doing_it_wrong(
29
+			__METHOD__,
30
+			sprintf(
31
+				esc_html__(
32
+					'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
33
+					'event_espresso'
34
+				),
35
+				'EventEspresso\core\services\request\middleware\RecommendedVersions',
36
+				'\core\services\request',
37
+				'EventEspresso\core\services\request'
38
+			),
39
+			'4.9.52'
40
+		);
41
+		return $response;
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * @deprecated
47
-     * @param string $version_to_check
48
-     * @param string $operator
49
-     * @return bool
50
-     */
51
-    public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=')
52
-    {
53
-        EE_Error::doing_it_wrong(
54
-            __METHOD__,
55
-            sprintf(
56
-                esc_html__(
57
-                    'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
58
-                    'event_espresso'
59
-                ),
60
-                'EventEspresso\core\services\request\middleware\RecommendedVersions::compareWordPressVersion()',
61
-                '\core\services\request',
62
-                'EventEspresso\core\services\request'
63
-            ),
64
-            '4.9.52',
65
-            '5.0.0'
66
-        );
67
-        return RecommendedVersions::compareWordPressVersion($version_to_check, $operator);
68
-    }
45
+	/**
46
+	 * @deprecated
47
+	 * @param string $version_to_check
48
+	 * @param string $operator
49
+	 * @return bool
50
+	 */
51
+	public static function check_wp_version($version_to_check = EE_MIN_WP_VER_REQUIRED, $operator = '>=')
52
+	{
53
+		EE_Error::doing_it_wrong(
54
+			__METHOD__,
55
+			sprintf(
56
+				esc_html__(
57
+					'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
58
+					'event_espresso'
59
+				),
60
+				'EventEspresso\core\services\request\middleware\RecommendedVersions::compareWordPressVersion()',
61
+				'\core\services\request',
62
+				'EventEspresso\core\services\request'
63
+			),
64
+			'4.9.52',
65
+			'5.0.0'
66
+		);
67
+		return RecommendedVersions::compareWordPressVersion($version_to_check, $operator);
68
+	}
69 69
 
70 70
 
71
-    /**
72
-     * @deprecated
73
-     * @return void
74
-     */
75
-    public function minimum_wp_version_error()
76
-    {
77
-        EE_Error::doing_it_wrong(
78
-            __METHOD__,
79
-            sprintf(
80
-                esc_html__(
81
-                    'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
82
-                    'event_espresso'
83
-                ),
84
-                'EventEspresso\core\services\request\middleware\RecommendedVersions::minimumWpVersionError()',
85
-                '\core\services\request',
86
-                'EventEspresso\core\services\request'
87
-            ),
88
-            '4.9.52'
89
-        );
90
-    }
71
+	/**
72
+	 * @deprecated
73
+	 * @return void
74
+	 */
75
+	public function minimum_wp_version_error()
76
+	{
77
+		EE_Error::doing_it_wrong(
78
+			__METHOD__,
79
+			sprintf(
80
+				esc_html__(
81
+					'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
82
+					'event_espresso'
83
+				),
84
+				'EventEspresso\core\services\request\middleware\RecommendedVersions::minimumWpVersionError()',
85
+				'\core\services\request',
86
+				'EventEspresso\core\services\request'
87
+			),
88
+			'4.9.52'
89
+		);
90
+	}
91 91
 }
Please login to merge, or discard this patch.
core/middleware/EE_Middleware.core.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -20,27 +20,27 @@
 block discarded – undo
20 20
 abstract class EE_Middleware implements EEI_Request_Decorator
21 21
 {
22 22
 
23
-    /**
24
-     * @deprecated
25
-     * @param    EE_Request  $request
26
-     * @param    EE_Response $response
27
-     * @return    EE_Response
28
-     */
29
-    protected function process_request_stack(EE_Request $request, EE_Response $response)
30
-    {
31
-        EE_Error::doing_it_wrong(
32
-            __METHOD__,
33
-            sprintf(
34
-                esc_html__(
35
-                    'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
36
-                    'event_espresso'
37
-                ),
38
-                'EventEspresso\core\services\request\middleware\Middleware',
39
-                '\core\services\request',
40
-                'EventEspresso\core\services\request'
41
-            ),
42
-            '4.9.52'
43
-        );
44
-        return $response;
45
-    }
23
+	/**
24
+	 * @deprecated
25
+	 * @param    EE_Request  $request
26
+	 * @param    EE_Response $response
27
+	 * @return    EE_Response
28
+	 */
29
+	protected function process_request_stack(EE_Request $request, EE_Response $response)
30
+	{
31
+		EE_Error::doing_it_wrong(
32
+			__METHOD__,
33
+			sprintf(
34
+				esc_html__(
35
+					'This class is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
36
+					'event_espresso'
37
+				),
38
+				'EventEspresso\core\services\request\middleware\Middleware',
39
+				'\core\services\request',
40
+				'EventEspresso\core\services\request'
41
+			),
42
+			'4.9.52'
43
+		);
44
+		return $response;
45
+	}
46 46
 }
Please login to merge, or discard this patch.
core/middleware/EE_Alpha_Banner_Warning.core.php 1 patch
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -14,87 +14,87 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    /**
18
-     * @deprecated 4.9.53
19
-     * @param    EE_Request  $request
20
-     * @param    EE_Response $response
21
-     * @return    EE_Response
22
-     */
23
-    public function handle_request(EE_Request $request, EE_Response $response)
24
-    {
25
-        $this->_request = $request;
26
-        $this->_response = $response;
27
-        $this->display_alpha_banner_warning();
28
-        $this->_response = $this->process_request_stack($this->_request, $this->_response);
29
-        return $this->_response;
30
-    }
17
+	/**
18
+	 * @deprecated 4.9.53
19
+	 * @param    EE_Request  $request
20
+	 * @param    EE_Response $response
21
+	 * @return    EE_Response
22
+	 */
23
+	public function handle_request(EE_Request $request, EE_Response $response)
24
+	{
25
+		$this->_request = $request;
26
+		$this->_response = $response;
27
+		$this->display_alpha_banner_warning();
28
+		$this->_response = $this->process_request_stack($this->_request, $this->_response);
29
+		return $this->_response;
30
+	}
31 31
 
32 32
 
33
-    /**
34
-     * @deprecated
35
-     * @return    string
36
-     */
37
-    public function display_alpha_banner_warning()
38
-    {
39
-        EE_Error::doing_it_wrong(
40
-            __METHOD__,
41
-            sprintf(
42
-                esc_html__(
43
-                    'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
44
-                    'event_espresso'
45
-                ),
46
-                'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::displayPreProductionVersionWarning()',
47
-                '\core\services\request',
48
-                'EventEspresso\core\services\request'
49
-            ),
50
-            '4.9.52',
51
-            '4.10.0'
52
-        );
53
-    }
33
+	/**
34
+	 * @deprecated
35
+	 * @return    string
36
+	 */
37
+	public function display_alpha_banner_warning()
38
+	{
39
+		EE_Error::doing_it_wrong(
40
+			__METHOD__,
41
+			sprintf(
42
+				esc_html__(
43
+					'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
44
+					'event_espresso'
45
+				),
46
+				'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::displayPreProductionVersionWarning()',
47
+				'\core\services\request',
48
+				'EventEspresso\core\services\request'
49
+			),
50
+			'4.9.52',
51
+			'4.10.0'
52
+		);
53
+	}
54 54
 
55 55
 
56
-    /**
57
-     * @deprecated
58
-     * @return void
59
-     */
60
-    public function alpha_banner_admin_notice()
61
-    {
62
-        EE_Error::doing_it_wrong(
63
-            __METHOD__,
64
-            sprintf(
65
-                esc_html__(
66
-                    'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
67
-                    'event_espresso'
68
-                ),
69
-                'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::preProductionVersionAdminNotice()',
70
-                '\core\services\request',
71
-                'EventEspresso\core\services\request'
72
-            ),
73
-            '4.9.52',
74
-            '4.10.0'
75
-        );
76
-    }
56
+	/**
57
+	 * @deprecated
58
+	 * @return void
59
+	 */
60
+	public function alpha_banner_admin_notice()
61
+	{
62
+		EE_Error::doing_it_wrong(
63
+			__METHOD__,
64
+			sprintf(
65
+				esc_html__(
66
+					'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
67
+					'event_espresso'
68
+				),
69
+				'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::preProductionVersionAdminNotice()',
70
+				'\core\services\request',
71
+				'EventEspresso\core\services\request'
72
+			),
73
+			'4.9.52',
74
+			'4.10.0'
75
+		);
76
+	}
77 77
 
78 78
 
79
-    /**
80
-     * @deprecated
81
-     * @return void
82
-     */
83
-    public function alpha_banner_warning_notice()
84
-    {
85
-        EE_Error::doing_it_wrong(
86
-            __METHOD__,
87
-            sprintf(
88
-                esc_html__(
89
-                    'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
90
-                    'event_espresso'
91
-                ),
92
-                'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::preProductionVersionWarningNotice()',
93
-                '\core\services\request',
94
-                'EventEspresso\core\services\request'
95
-            ),
96
-            '4.9.52',
97
-            '4.10.0'
98
-        );
99
-    }
79
+	/**
80
+	 * @deprecated
81
+	 * @return void
82
+	 */
83
+	public function alpha_banner_warning_notice()
84
+	{
85
+		EE_Error::doing_it_wrong(
86
+			__METHOD__,
87
+			sprintf(
88
+				esc_html__(
89
+					'This method is deprecated. Please use %1$s instead. All Event Espresso request stack classes have been moved to %2$s and are now under the %3$s namespace',
90
+					'event_espresso'
91
+				),
92
+				'EventEspresso\core\services\request\middleware\PreProductionVersionWarning::preProductionVersionWarningNotice()',
93
+				'\core\services\request',
94
+				'EventEspresso\core\services\request'
95
+			),
96
+			'4.9.52',
97
+			'4.10.0'
98
+		);
99
+	}
100 100
 }
Please login to merge, or discard this patch.
core/EE_Encryption.core.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     protected function __construct()
105 105
     {
106
-        if (! defined('ESPRESSO_ENCRYPT')) {
106
+        if ( ! defined('ESPRESSO_ENCRYPT')) {
107 107
             define('ESPRESSO_ENCRYPT', true);
108 108
         }
109 109
         if (extension_loaded('openssl')) {
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     public static function instance()
126 126
     {
127 127
         // check if class object is instantiated
128
-        if (! EE_Encryption::$_instance instanceof EE_Encryption) {
128
+        if ( ! EE_Encryption::$_instance instanceof EE_Encryption) {
129 129
             EE_Encryption::$_instance = new self();
130 130
         }
131 131
         return EE_Encryption::$_instance;
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
             $iv
333 333
         );
334 334
         // append the initialization vector
335
-        $encrypted_text .= EE_Encryption::OPENSSL_IV_DELIMITER . $iv;
335
+        $encrypted_text .= EE_Encryption::OPENSSL_IV_DELIMITER.$iv;
336 336
         // trim and maybe encode
337 337
         return $this->_use_base64_encode
338 338
             ? trim(base64_encode($encrypted_text))
@@ -525,8 +525,8 @@  discard block
 block discarded – undo
525 525
         );
526 526
         $string_bits = str_split($text_string);
527 527
         foreach ($string_bits as $k => $v) {
528
-            $temp = ord($v) + ord($key_bits[ $k ]);
529
-            $string_bits[ $k ] = chr($temp > 255 ? ($temp - 256) : $temp);
528
+            $temp = ord($v) + ord($key_bits[$k]);
529
+            $string_bits[$k] = chr($temp > 255 ? ($temp - 256) : $temp);
530 530
         }
531 531
         $encrypted_text = implode('', $string_bits);
532 532
         $encrypted_text .= EE_Encryption::ACME_ENCRYPTION_FLAG;
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
         );
571 571
         $string_bits = str_split($encrypted_text);
572 572
         foreach ($string_bits as $k => $v) {
573
-            $temp = ord($v) - ord($key_bits[ $k ]);
574
-            $string_bits[ $k ] = chr($temp < 0 ? ($temp + 256) : $temp);
573
+            $temp = ord($v) - ord($key_bits[$k]);
574
+            $string_bits[$k] = chr($temp < 0 ? ($temp + 256) : $temp);
575 575
         }
576 576
         return implode('', $string_bits);
577 577
     }
@@ -585,16 +585,16 @@  discard block
 block discarded – undo
585 585
     protected function valid_base_64($string)
586 586
     {
587 587
         // ensure data is a string
588
-        if (! is_string($string) || ! $this->_use_base64_encode) {
588
+        if ( ! is_string($string) || ! $this->_use_base64_encode) {
589 589
             return false;
590 590
         }
591 591
         $decoded = base64_decode($string, true);
592 592
         // Check if there is no invalid character in string
593
-        if (! preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) {
593
+        if ( ! preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) {
594 594
             return false;
595 595
         }
596 596
         // Decode the string in strict mode and send the response
597
-        if (! base64_decode($string, true)) {
597
+        if ( ! base64_decode($string, true)) {
598 598
             return false;
599 599
         }
600 600
         // Encode and compare it to original one
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
         $iterations = ceil($length / 40);
615 615
         $random_string = '';
616 616
         for ($i = 0; $i < $iterations; $i++) {
617
-            $random_string .= sha1(microtime(true) . mt_rand(10000, 90000));
617
+            $random_string .= sha1(microtime(true).mt_rand(10000, 90000));
618 618
         }
619 619
         $random_string = substr($random_string, 0, $length);
620 620
         return $random_string;
Please login to merge, or discard this patch.
Indentation   +672 added lines, -672 removed lines patch added patch discarded remove patch
@@ -26,676 +26,676 @@
 block discarded – undo
26 26
 class EE_Encryption implements InterminableInterface
27 27
 {
28 28
 
29
-    /**
30
-     * key used for saving the encryption key to the wp_options table
31
-     */
32
-    const ENCRYPTION_OPTION_KEY = 'ee_encryption_key';
33
-
34
-    /**
35
-     * the OPENSSL cipher method used
36
-     */
37
-    const OPENSSL_CIPHER_METHOD = 'AES-128-CBC';
38
-
39
-    /**
40
-     * WP "options_name" used to store a verified available cipher method
41
-     */
42
-    const OPENSSL_CIPHER_METHOD_OPTION_NAME = 'ee_openssl_cipher_method';
43
-
44
-    /**
45
-     * the OPENSSL digest method used
46
-     */
47
-    const OPENSSL_DIGEST_METHOD = 'sha512';
48
-
49
-    /**
50
-     * separates the encrypted text from the initialization vector
51
-     */
52
-    const OPENSSL_IV_DELIMITER = ':iv:';
53
-
54
-    /**
55
-     * appended to text encrypted using the acme encryption
56
-     */
57
-    const ACME_ENCRYPTION_FLAG = '::ae';
58
-
59
-
60
-    /**
61
-     * instance of the EE_Encryption object
62
-     */
63
-    protected static $_instance;
64
-
65
-    /**
66
-     * @var string $_encryption_key
67
-     */
68
-    protected $_encryption_key;
69
-
70
-    /**
71
-     * @var string $cipher_method
72
-     */
73
-    private $cipher_method = '';
74
-
75
-    /**
76
-     * @var array $cipher_methods
77
-     */
78
-    private $cipher_methods = array();
79
-
80
-    /**
81
-     * @var array $digest_methods
82
-     */
83
-    private $digest_methods = array();
84
-
85
-    /**
86
-     * @var boolean $_use_openssl_encrypt
87
-     */
88
-    protected $_use_openssl_encrypt = false;
89
-
90
-    /**
91
-     * @var boolean $_use_mcrypt
92
-     */
93
-    protected $_use_mcrypt = false;
94
-
95
-    /**
96
-     * @var boolean $_use_base64_encode
97
-     */
98
-    protected $_use_base64_encode = false;
99
-
100
-
101
-    /**
102
-     * protected constructor to prevent direct creation
103
-     */
104
-    protected function __construct()
105
-    {
106
-        if (! defined('ESPRESSO_ENCRYPT')) {
107
-            define('ESPRESSO_ENCRYPT', true);
108
-        }
109
-        if (extension_loaded('openssl')) {
110
-            $this->_use_openssl_encrypt = true;
111
-        } elseif (extension_loaded('mcrypt')) {
112
-            $this->_use_mcrypt = true;
113
-        }
114
-        if (function_exists('base64_encode')) {
115
-            $this->_use_base64_encode = true;
116
-        }
117
-    }
118
-
119
-
120
-    /**
121
-     * singleton method used to instantiate class object
122
-     *
123
-     * @return EE_Encryption
124
-     */
125
-    public static function instance()
126
-    {
127
-        // check if class object is instantiated
128
-        if (! EE_Encryption::$_instance instanceof EE_Encryption) {
129
-            EE_Encryption::$_instance = new self();
130
-        }
131
-        return EE_Encryption::$_instance;
132
-    }
133
-
134
-
135
-    /**
136
-     * get encryption key
137
-     *
138
-     * @return string
139
-     */
140
-    public function get_encryption_key()
141
-    {
142
-        // if encryption key has not been set
143
-        if (empty($this->_encryption_key)) {
144
-            // retrieve encryption_key from db
145
-            $this->_encryption_key = get_option(EE_Encryption::ENCRYPTION_OPTION_KEY, '');
146
-            // WHAT?? No encryption_key in the db ??
147
-            if ($this->_encryption_key === '') {
148
-                // let's make one. And md5 it to make it just the right size for a key
149
-                $new_key = md5($this->generate_random_string());
150
-                // now save it to the db for later
151
-                add_option(EE_Encryption::ENCRYPTION_OPTION_KEY, $new_key);
152
-                // here's the key - FINALLY !
153
-                $this->_encryption_key = $new_key;
154
-            }
155
-        }
156
-        return $this->_encryption_key;
157
-    }
158
-
159
-
160
-    /**
161
-     * encrypts data
162
-     *
163
-     * @param string $text_string - the text to be encrypted
164
-     * @return string
165
-     * @throws RuntimeException
166
-     */
167
-    public function encrypt($text_string = '')
168
-    {
169
-        // you give me nothing??? GET OUT !
170
-        if (empty($text_string)) {
171
-            return $text_string;
172
-        }
173
-        if ($this->_use_openssl_encrypt) {
174
-            $encrypted_text = $this->openssl_encrypt($text_string);
175
-        } else {
176
-            $encrypted_text = $this->acme_encrypt($text_string);
177
-        }
178
-        return $encrypted_text;
179
-    }
180
-
181
-
182
-    /**
183
-     * decrypts data
184
-     *
185
-     * @param string $encrypted_text - the text to be decrypted
186
-     * @return string
187
-     * @throws RuntimeException
188
-     */
189
-    public function decrypt($encrypted_text = '')
190
-    {
191
-        // you give me nothing??? GET OUT !
192
-        if (empty($encrypted_text)) {
193
-            return $encrypted_text;
194
-        }
195
-        // if PHP's mcrypt functions are installed then we'll use them
196
-        if ($this->_use_openssl_encrypt) {
197
-            $decrypted_text = $this->openssl_decrypt($encrypted_text);
198
-        } else {
199
-            $decrypted_text = $this->acme_decrypt($encrypted_text);
200
-        }
201
-        return $decrypted_text;
202
-    }
203
-
204
-
205
-    /**
206
-     * encodes string with PHP's base64 encoding
207
-     *
208
-     * @see http://php.net/manual/en/function.base64-encode.php
209
-     * @param string $text_string the text to be encoded
210
-     * @return string
211
-     */
212
-    public function base64_string_encode($text_string = '')
213
-    {
214
-        // you give me nothing??? GET OUT !
215
-        if (empty($text_string) || ! $this->_use_base64_encode) {
216
-            return $text_string;
217
-        }
218
-        // encode
219
-        return base64_encode($text_string);
220
-    }
221
-
222
-
223
-    /**
224
-     * decodes string that has been encoded with PHP's base64 encoding
225
-     *
226
-     * @see http://php.net/manual/en/function.base64-encode.php
227
-     * @param string $encoded_string the text to be decoded
228
-     * @return string
229
-     * @throws RuntimeException
230
-     */
231
-    public function base64_string_decode($encoded_string = '')
232
-    {
233
-        // you give me nothing??? GET OUT !
234
-        if (empty($encoded_string) || ! $this->valid_base_64($encoded_string)) {
235
-            return $encoded_string;
236
-        }
237
-        // decode
238
-        $decoded_string = base64_decode($encoded_string);
239
-        if ($decoded_string === false) {
240
-            throw new RuntimeException(
241
-                esc_html__('Base 64 decoding failed.', 'event_espresso')
242
-            );
243
-        }
244
-        return $decoded_string;
245
-    }
246
-
247
-
248
-    /**
249
-     * encodes  url string with PHP's base64 encoding
250
-     *
251
-     * @see http://php.net/manual/en/function.base64-encode.php
252
-     * @param string $text_string the text to be encoded
253
-     * @return string
254
-     */
255
-    public function base64_url_encode($text_string = '')
256
-    {
257
-        // you give me nothing??? GET OUT !
258
-        if (empty($text_string) || ! $this->_use_base64_encode) {
259
-            return $text_string;
260
-        }
261
-        // encode
262
-        $encoded_string = base64_encode($text_string);
263
-        // remove chars to make encoding more URL friendly
264
-        return strtr($encoded_string, '+/=', '-_,');
265
-    }
266
-
267
-
268
-    /**
269
-     * decodes  url string that has been encoded with PHP's base64 encoding
270
-     *
271
-     * @see http://php.net/manual/en/function.base64-encode.php
272
-     * @param string $encoded_string the text to be decoded
273
-     * @return string
274
-     * @throws RuntimeException
275
-     */
276
-    public function base64_url_decode($encoded_string = '')
277
-    {
278
-        // you give me nothing??? GET OUT !
279
-        if (empty($encoded_string) || ! $this->valid_base_64($encoded_string)) {
280
-            return $encoded_string;
281
-        }
282
-        // replace previously removed characters
283
-        $encoded_string = strtr($encoded_string, '-_,', '+/=');
284
-        // decode
285
-        $decoded_string = base64_decode($encoded_string);
286
-        if ($decoded_string === false) {
287
-            throw new RuntimeException(
288
-                esc_html__('Base 64 decoding failed.', 'event_espresso')
289
-            );
290
-        }
291
-        return $decoded_string;
292
-    }
293
-
294
-
295
-    /**
296
-     * encrypts data using PHP's openssl functions
297
-     *
298
-     * @param string $text_string the text to be encrypted
299
-     * @param string $cipher_method
300
-     * @param string $encryption_key
301
-     * @return string
302
-     * @throws RuntimeException
303
-     */
304
-    protected function openssl_encrypt(
305
-        $text_string = '',
306
-        $cipher_method = EE_Encryption::OPENSSL_CIPHER_METHOD,
307
-        $encryption_key = ''
308
-    ) {
309
-        // you give me nothing??? GET OUT !
310
-        if (empty($text_string)) {
311
-            return $text_string;
312
-        }
313
-        $this->cipher_method = $this->getCipherMethod($cipher_method);
314
-        // get initialization vector size
315
-        $iv_size = openssl_cipher_iv_length($this->cipher_method);
316
-        // generate initialization vector.
317
-        // The second parameter ("crypto_strong") is passed by reference,
318
-        // and is used to determines if the algorithm used was "cryptographically strong"
319
-        // openssl_random_pseudo_bytes() will toggle it to either true or false
320
-        $iv = openssl_random_pseudo_bytes($iv_size, $is_strong);
321
-        if ($iv === false || $is_strong === false) {
322
-            throw new RuntimeException(
323
-                esc_html__('Failed to generate OpenSSL initialization vector.', 'event_espresso')
324
-            );
325
-        }
326
-        // encrypt it
327
-        $encrypted_text = openssl_encrypt(
328
-            $text_string,
329
-            $this->cipher_method,
330
-            $this->getDigestHashValue(EE_Encryption::OPENSSL_DIGEST_METHOD, $encryption_key),
331
-            0,
332
-            $iv
333
-        );
334
-        // append the initialization vector
335
-        $encrypted_text .= EE_Encryption::OPENSSL_IV_DELIMITER . $iv;
336
-        // trim and maybe encode
337
-        return $this->_use_base64_encode
338
-            ? trim(base64_encode($encrypted_text))
339
-            : trim($encrypted_text);
340
-    }
341
-
342
-
343
-    /**
344
-     * Returns a cipher method that has been verified to work.
345
-     * First checks if the cached cipher has been set already and if so, returns that.
346
-     * Then tests the incoming default and returns that if it's good.
347
-     * If not, then it retrieves the previously tested and saved cipher method.
348
-     * But if that doesn't exist, then calls getAvailableCipherMethod()
349
-     * to see what is available on the server, and returns the results.
350
-     *
351
-     * @param string $cipher_method
352
-     * @return string
353
-     * @throws RuntimeException
354
-     */
355
-    protected function getCipherMethod($cipher_method = EE_Encryption::OPENSSL_CIPHER_METHOD)
356
-    {
357
-        if ($this->cipher_method !== '') {
358
-            return $this->cipher_method;
359
-        }
360
-        // verify that the default cipher method can produce an initialization vector
361
-        if (openssl_cipher_iv_length($cipher_method) === false) {
362
-            // nope? okay let's get what we found in the past to work
363
-            $cipher_method = get_option(EE_Encryption::OPENSSL_CIPHER_METHOD_OPTION_NAME, '');
364
-            // oops... haven't tested available cipher methods yet
365
-            if ($cipher_method === '' || openssl_cipher_iv_length($cipher_method) === false) {
366
-                $cipher_method = $this->getAvailableCipherMethod($cipher_method);
367
-            }
368
-        }
369
-        return $cipher_method;
370
-    }
371
-
372
-
373
-    /**
374
-     * @param string $cipher_method
375
-     * @return string
376
-     * @throws \RuntimeException
377
-     */
378
-    protected function getAvailableCipherMethod($cipher_method)
379
-    {
380
-        // verify that the incoming cipher method can produce an initialization vector
381
-        if (openssl_cipher_iv_length($cipher_method) === false) {
382
-            // nope? then check the next cipher in the list of available cipher methods
383
-            $cipher_method = next($this->cipher_methods);
384
-            // what? there's no list? then generate that list and cache it,
385
-            if (empty($this->cipher_methods)) {
386
-                $this->cipher_methods = openssl_get_cipher_methods();
387
-                // then grab the first item from the list
388
-                $cipher_method = reset($this->cipher_methods);
389
-            }
390
-            if ($cipher_method === false) {
391
-                throw new RuntimeException(
392
-                    esc_html__(
393
-                        'OpenSSL support appears to be enabled on the server, but no cipher methods are available. Please contact the server administrator.',
394
-                        'event_espresso'
395
-                    )
396
-                );
397
-            }
398
-            // verify that the next cipher method works
399
-            return $this->getAvailableCipherMethod($cipher_method);
400
-        }
401
-        // if we've gotten this far, then we found an available cipher method that works
402
-        // so save that for next time
403
-        update_option(
404
-            EE_Encryption::OPENSSL_CIPHER_METHOD_OPTION_NAME,
405
-            $cipher_method
406
-        );
407
-        return $cipher_method;
408
-    }
409
-
410
-
411
-    /**
412
-     * decrypts data that has been encrypted with PHP's openssl functions
413
-     *
414
-     * @param string $encrypted_text the text to be decrypted
415
-     * @param string $cipher_method
416
-     * @param string $encryption_key
417
-     * @return string
418
-     * @throws RuntimeException
419
-     */
420
-    protected function openssl_decrypt(
421
-        $encrypted_text = '',
422
-        $cipher_method = EE_Encryption::OPENSSL_CIPHER_METHOD,
423
-        $encryption_key = ''
424
-    ) {
425
-        // you give me nothing??? GET OUT !
426
-        if (empty($encrypted_text)) {
427
-            return $encrypted_text;
428
-        }
429
-        // decode
430
-        $encrypted_text = $this->valid_base_64($encrypted_text)
431
-            ? $this->base64_url_decode($encrypted_text)
432
-            : $encrypted_text;
433
-        $encrypted_components = explode(
434
-            EE_Encryption::OPENSSL_IV_DELIMITER,
435
-            $encrypted_text,
436
-            2
437
-        );
438
-        // check that iv exists, and if not, maybe text was encoded using mcrypt?
439
-        if ($this->_use_mcrypt && ! isset($encrypted_components[1])) {
440
-            return $this->m_decrypt($encrypted_text);
441
-        }
442
-        // decrypt it
443
-        $decrypted_text = openssl_decrypt(
444
-            $encrypted_components[0],
445
-            $this->getCipherMethod($cipher_method),
446
-            $this->getDigestHashValue(EE_Encryption::OPENSSL_DIGEST_METHOD, $encryption_key),
447
-            0,
448
-            $encrypted_components[1]
449
-        );
450
-        $decrypted_text = trim($decrypted_text);
451
-        return $decrypted_text;
452
-    }
453
-
454
-
455
-    /**
456
-     * Computes the digest hash value using the specified digest method.
457
-     * If that digest method fails to produce a valid hash value,
458
-     * then we'll grab the next digest method and recursively try again until something works.
459
-     *
460
-     * @param string $digest_method
461
-     * @param string $encryption_key
462
-     * @return string
463
-     * @throws RuntimeException
464
-     */
465
-    protected function getDigestHashValue($digest_method = EE_Encryption::OPENSSL_DIGEST_METHOD, $encryption_key = '')
466
-    {
467
-        $encryption_key = $encryption_key !== ''
468
-            ? $encryption_key
469
-            : $this->get_encryption_key();
470
-        $digest_hash_value = openssl_digest($encryption_key, $digest_method);
471
-        if ($digest_hash_value === false) {
472
-            return $this->getDigestHashValue($this->getDigestMethod());
473
-        }
474
-        return $digest_hash_value;
475
-    }
476
-
477
-
478
-    /**
479
-     * Returns the NEXT element in the $digest_methods array.
480
-     * If the $digest_methods array is empty, then we populate it
481
-     * with the available values returned from openssl_get_md_methods().
482
-     *
483
-     * @return string
484
-     * @throws \RuntimeException
485
-     */
486
-    protected function getDigestMethod()
487
-    {
488
-        $digest_method = prev($this->digest_methods);
489
-        if (empty($this->digest_methods)) {
490
-            $this->digest_methods = openssl_get_md_methods();
491
-            $digest_method = end($this->digest_methods);
492
-        }
493
-        if ($digest_method === false) {
494
-            throw new RuntimeException(
495
-                esc_html__(
496
-                    'OpenSSL support appears to be enabled on the server, but no digest methods are available. Please contact the server administrator.',
497
-                    'event_espresso'
498
-                )
499
-            );
500
-        }
501
-        return $digest_method;
502
-    }
503
-
504
-
505
-    /**
506
-     * encrypts data for acme servers that didn't bother to install PHP mcrypt
507
-     *
508
-     * @see http://stackoverflow.com/questions/800922/how-to-encrypt-string-without-mcrypt-library-in-php
509
-     * @param string $text_string the text to be decrypted
510
-     * @return string
511
-     */
512
-    protected function acme_encrypt($text_string = '')
513
-    {
514
-        // you give me nothing??? GET OUT !
515
-        if (empty($text_string)) {
516
-            return $text_string;
517
-        }
518
-        $key_bits = str_split(
519
-            str_pad(
520
-                '',
521
-                strlen($text_string),
522
-                $this->get_encryption_key(),
523
-                STR_PAD_RIGHT
524
-            )
525
-        );
526
-        $string_bits = str_split($text_string);
527
-        foreach ($string_bits as $k => $v) {
528
-            $temp = ord($v) + ord($key_bits[ $k ]);
529
-            $string_bits[ $k ] = chr($temp > 255 ? ($temp - 256) : $temp);
530
-        }
531
-        $encrypted_text = implode('', $string_bits);
532
-        $encrypted_text .= EE_Encryption::ACME_ENCRYPTION_FLAG;
533
-        return $this->_use_base64_encode
534
-            ? base64_encode($encrypted_text)
535
-            : $encrypted_text;
536
-    }
537
-
538
-
539
-    /**
540
-     * decrypts data for acme servers that didn't bother to install PHP mcrypt
541
-     *
542
-     * @see http://stackoverflow.com/questions/800922/how-to-encrypt-string-without-mcrypt-library-in-php
543
-     * @param string $encrypted_text the text to be decrypted
544
-     * @return string
545
-     * @throws RuntimeException
546
-     */
547
-    protected function acme_decrypt($encrypted_text = '')
548
-    {
549
-        // you give me nothing??? GET OUT !
550
-        if (empty($encrypted_text)) {
551
-            return $encrypted_text;
552
-        }
553
-        // decode the data ?
554
-        $encrypted_text = $this->valid_base_64($encrypted_text)
555
-            ? $this->base64_url_decode($encrypted_text)
556
-            : $encrypted_text;
557
-        if (
558
-            $this->_use_mcrypt
559
-            && strpos($encrypted_text, EE_Encryption::ACME_ENCRYPTION_FLAG) === false
560
-        ) {
561
-            return $this->m_decrypt($encrypted_text);
562
-        }
563
-        $encrypted_text = substr($encrypted_text, 0, -4);
564
-        $key_bits = str_split(
565
-            str_pad(
566
-                '',
567
-                strlen($encrypted_text),
568
-                $this->get_encryption_key(),
569
-                STR_PAD_RIGHT
570
-            )
571
-        );
572
-        $string_bits = str_split($encrypted_text);
573
-        foreach ($string_bits as $k => $v) {
574
-            $temp = ord($v) - ord($key_bits[ $k ]);
575
-            $string_bits[ $k ] = chr($temp < 0 ? ($temp + 256) : $temp);
576
-        }
577
-        return implode('', $string_bits);
578
-    }
579
-
580
-
581
-    /**
582
-     * @see http://stackoverflow.com/questions/2556345/detect-base64-encoding-in-php#30231906
583
-     * @param $string
584
-     * @return bool
585
-     */
586
-    protected function valid_base_64($string)
587
-    {
588
-        // ensure data is a string
589
-        if (! is_string($string) || ! $this->_use_base64_encode) {
590
-            return false;
591
-        }
592
-        $decoded = base64_decode($string, true);
593
-        // Check if there is no invalid character in string
594
-        if (! preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) {
595
-            return false;
596
-        }
597
-        // Decode the string in strict mode and send the response
598
-        if (! base64_decode($string, true)) {
599
-            return false;
600
-        }
601
-        // Encode and compare it to original one
602
-        return base64_encode($decoded) === $string;
603
-    }
604
-
605
-
606
-    /**
607
-     * generate random string
608
-     *
609
-     * @see http://stackoverflow.com/questions/637278/what-is-the-best-way-to-generate-a-random-key-within-php
610
-     * @param int $length number of characters for random string
611
-     * @return string
612
-     */
613
-    public function generate_random_string($length = 40)
614
-    {
615
-        $iterations = ceil($length / 40);
616
-        $random_string = '';
617
-        for ($i = 0; $i < $iterations; $i++) {
618
-            $random_string .= sha1(microtime(true) . mt_rand(10000, 90000));
619
-        }
620
-        $random_string = substr($random_string, 0, $length);
621
-        return $random_string;
622
-    }
623
-
624
-
625
-    /**
626
-     * encrypts data using PHP's mcrypt functions
627
-     *
628
-     * @deprecated 4.9.39
629
-     * @param string $text_string
630
-     * @internal   param $string - the text to be encrypted
631
-     * @return string
632
-     * @throws RuntimeException
633
-     */
634
-    protected function m_encrypt($text_string = '')
635
-    {
636
-        // you give me nothing??? GET OUT !
637
-        if (empty($text_string)) {
638
-            return $text_string;
639
-        }
640
-        // get the initialization vector size
641
-        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
642
-        // initialization vector
643
-        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
644
-        if ($iv === false) {
645
-            throw new RuntimeException(
646
-                esc_html__('Failed to generate mcrypt initialization vector.', 'event_espresso')
647
-            );
648
-        }
649
-        // encrypt it
650
-        $encrypted_text = mcrypt_encrypt(
651
-            MCRYPT_RIJNDAEL_256,
652
-            $this->get_encryption_key(),
653
-            $text_string,
654
-            MCRYPT_MODE_ECB,
655
-            $iv
656
-        );
657
-        // trim and maybe encode
658
-        return $this->_use_base64_encode
659
-            ? trim(base64_encode($encrypted_text))
660
-            : trim($encrypted_text);
661
-    }
662
-
663
-
664
-    /**
665
-     * decrypts data that has been encrypted with PHP's mcrypt functions
666
-     *
667
-     * @deprecated 4.9.39
668
-     * @param string $encrypted_text the text to be decrypted
669
-     * @return string
670
-     * @throws RuntimeException
671
-     */
672
-    protected function m_decrypt($encrypted_text = '')
673
-    {
674
-        // you give me nothing??? GET OUT !
675
-        if (empty($encrypted_text)) {
676
-            return $encrypted_text;
677
-        }
678
-        // decode
679
-        $encrypted_text = $this->valid_base_64($encrypted_text)
680
-            ? $this->base64_url_decode($encrypted_text)
681
-            : $encrypted_text;
682
-        // get the initialization vector size
683
-        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
684
-        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
685
-        if ($iv === false) {
686
-            throw new RuntimeException(
687
-                esc_html__('Failed to generate mcrypt initialization vector.', 'event_espresso')
688
-            );
689
-        }
690
-        // decrypt it
691
-        $decrypted_text = mcrypt_decrypt(
692
-            MCRYPT_RIJNDAEL_256,
693
-            $this->get_encryption_key(),
694
-            $encrypted_text,
695
-            MCRYPT_MODE_ECB,
696
-            $iv
697
-        );
698
-        $decrypted_text = trim($decrypted_text);
699
-        return $decrypted_text;
700
-    }
29
+	/**
30
+	 * key used for saving the encryption key to the wp_options table
31
+	 */
32
+	const ENCRYPTION_OPTION_KEY = 'ee_encryption_key';
33
+
34
+	/**
35
+	 * the OPENSSL cipher method used
36
+	 */
37
+	const OPENSSL_CIPHER_METHOD = 'AES-128-CBC';
38
+
39
+	/**
40
+	 * WP "options_name" used to store a verified available cipher method
41
+	 */
42
+	const OPENSSL_CIPHER_METHOD_OPTION_NAME = 'ee_openssl_cipher_method';
43
+
44
+	/**
45
+	 * the OPENSSL digest method used
46
+	 */
47
+	const OPENSSL_DIGEST_METHOD = 'sha512';
48
+
49
+	/**
50
+	 * separates the encrypted text from the initialization vector
51
+	 */
52
+	const OPENSSL_IV_DELIMITER = ':iv:';
53
+
54
+	/**
55
+	 * appended to text encrypted using the acme encryption
56
+	 */
57
+	const ACME_ENCRYPTION_FLAG = '::ae';
58
+
59
+
60
+	/**
61
+	 * instance of the EE_Encryption object
62
+	 */
63
+	protected static $_instance;
64
+
65
+	/**
66
+	 * @var string $_encryption_key
67
+	 */
68
+	protected $_encryption_key;
69
+
70
+	/**
71
+	 * @var string $cipher_method
72
+	 */
73
+	private $cipher_method = '';
74
+
75
+	/**
76
+	 * @var array $cipher_methods
77
+	 */
78
+	private $cipher_methods = array();
79
+
80
+	/**
81
+	 * @var array $digest_methods
82
+	 */
83
+	private $digest_methods = array();
84
+
85
+	/**
86
+	 * @var boolean $_use_openssl_encrypt
87
+	 */
88
+	protected $_use_openssl_encrypt = false;
89
+
90
+	/**
91
+	 * @var boolean $_use_mcrypt
92
+	 */
93
+	protected $_use_mcrypt = false;
94
+
95
+	/**
96
+	 * @var boolean $_use_base64_encode
97
+	 */
98
+	protected $_use_base64_encode = false;
99
+
100
+
101
+	/**
102
+	 * protected constructor to prevent direct creation
103
+	 */
104
+	protected function __construct()
105
+	{
106
+		if (! defined('ESPRESSO_ENCRYPT')) {
107
+			define('ESPRESSO_ENCRYPT', true);
108
+		}
109
+		if (extension_loaded('openssl')) {
110
+			$this->_use_openssl_encrypt = true;
111
+		} elseif (extension_loaded('mcrypt')) {
112
+			$this->_use_mcrypt = true;
113
+		}
114
+		if (function_exists('base64_encode')) {
115
+			$this->_use_base64_encode = true;
116
+		}
117
+	}
118
+
119
+
120
+	/**
121
+	 * singleton method used to instantiate class object
122
+	 *
123
+	 * @return EE_Encryption
124
+	 */
125
+	public static function instance()
126
+	{
127
+		// check if class object is instantiated
128
+		if (! EE_Encryption::$_instance instanceof EE_Encryption) {
129
+			EE_Encryption::$_instance = new self();
130
+		}
131
+		return EE_Encryption::$_instance;
132
+	}
133
+
134
+
135
+	/**
136
+	 * get encryption key
137
+	 *
138
+	 * @return string
139
+	 */
140
+	public function get_encryption_key()
141
+	{
142
+		// if encryption key has not been set
143
+		if (empty($this->_encryption_key)) {
144
+			// retrieve encryption_key from db
145
+			$this->_encryption_key = get_option(EE_Encryption::ENCRYPTION_OPTION_KEY, '');
146
+			// WHAT?? No encryption_key in the db ??
147
+			if ($this->_encryption_key === '') {
148
+				// let's make one. And md5 it to make it just the right size for a key
149
+				$new_key = md5($this->generate_random_string());
150
+				// now save it to the db for later
151
+				add_option(EE_Encryption::ENCRYPTION_OPTION_KEY, $new_key);
152
+				// here's the key - FINALLY !
153
+				$this->_encryption_key = $new_key;
154
+			}
155
+		}
156
+		return $this->_encryption_key;
157
+	}
158
+
159
+
160
+	/**
161
+	 * encrypts data
162
+	 *
163
+	 * @param string $text_string - the text to be encrypted
164
+	 * @return string
165
+	 * @throws RuntimeException
166
+	 */
167
+	public function encrypt($text_string = '')
168
+	{
169
+		// you give me nothing??? GET OUT !
170
+		if (empty($text_string)) {
171
+			return $text_string;
172
+		}
173
+		if ($this->_use_openssl_encrypt) {
174
+			$encrypted_text = $this->openssl_encrypt($text_string);
175
+		} else {
176
+			$encrypted_text = $this->acme_encrypt($text_string);
177
+		}
178
+		return $encrypted_text;
179
+	}
180
+
181
+
182
+	/**
183
+	 * decrypts data
184
+	 *
185
+	 * @param string $encrypted_text - the text to be decrypted
186
+	 * @return string
187
+	 * @throws RuntimeException
188
+	 */
189
+	public function decrypt($encrypted_text = '')
190
+	{
191
+		// you give me nothing??? GET OUT !
192
+		if (empty($encrypted_text)) {
193
+			return $encrypted_text;
194
+		}
195
+		// if PHP's mcrypt functions are installed then we'll use them
196
+		if ($this->_use_openssl_encrypt) {
197
+			$decrypted_text = $this->openssl_decrypt($encrypted_text);
198
+		} else {
199
+			$decrypted_text = $this->acme_decrypt($encrypted_text);
200
+		}
201
+		return $decrypted_text;
202
+	}
203
+
204
+
205
+	/**
206
+	 * encodes string with PHP's base64 encoding
207
+	 *
208
+	 * @see http://php.net/manual/en/function.base64-encode.php
209
+	 * @param string $text_string the text to be encoded
210
+	 * @return string
211
+	 */
212
+	public function base64_string_encode($text_string = '')
213
+	{
214
+		// you give me nothing??? GET OUT !
215
+		if (empty($text_string) || ! $this->_use_base64_encode) {
216
+			return $text_string;
217
+		}
218
+		// encode
219
+		return base64_encode($text_string);
220
+	}
221
+
222
+
223
+	/**
224
+	 * decodes string that has been encoded with PHP's base64 encoding
225
+	 *
226
+	 * @see http://php.net/manual/en/function.base64-encode.php
227
+	 * @param string $encoded_string the text to be decoded
228
+	 * @return string
229
+	 * @throws RuntimeException
230
+	 */
231
+	public function base64_string_decode($encoded_string = '')
232
+	{
233
+		// you give me nothing??? GET OUT !
234
+		if (empty($encoded_string) || ! $this->valid_base_64($encoded_string)) {
235
+			return $encoded_string;
236
+		}
237
+		// decode
238
+		$decoded_string = base64_decode($encoded_string);
239
+		if ($decoded_string === false) {
240
+			throw new RuntimeException(
241
+				esc_html__('Base 64 decoding failed.', 'event_espresso')
242
+			);
243
+		}
244
+		return $decoded_string;
245
+	}
246
+
247
+
248
+	/**
249
+	 * encodes  url string with PHP's base64 encoding
250
+	 *
251
+	 * @see http://php.net/manual/en/function.base64-encode.php
252
+	 * @param string $text_string the text to be encoded
253
+	 * @return string
254
+	 */
255
+	public function base64_url_encode($text_string = '')
256
+	{
257
+		// you give me nothing??? GET OUT !
258
+		if (empty($text_string) || ! $this->_use_base64_encode) {
259
+			return $text_string;
260
+		}
261
+		// encode
262
+		$encoded_string = base64_encode($text_string);
263
+		// remove chars to make encoding more URL friendly
264
+		return strtr($encoded_string, '+/=', '-_,');
265
+	}
266
+
267
+
268
+	/**
269
+	 * decodes  url string that has been encoded with PHP's base64 encoding
270
+	 *
271
+	 * @see http://php.net/manual/en/function.base64-encode.php
272
+	 * @param string $encoded_string the text to be decoded
273
+	 * @return string
274
+	 * @throws RuntimeException
275
+	 */
276
+	public function base64_url_decode($encoded_string = '')
277
+	{
278
+		// you give me nothing??? GET OUT !
279
+		if (empty($encoded_string) || ! $this->valid_base_64($encoded_string)) {
280
+			return $encoded_string;
281
+		}
282
+		// replace previously removed characters
283
+		$encoded_string = strtr($encoded_string, '-_,', '+/=');
284
+		// decode
285
+		$decoded_string = base64_decode($encoded_string);
286
+		if ($decoded_string === false) {
287
+			throw new RuntimeException(
288
+				esc_html__('Base 64 decoding failed.', 'event_espresso')
289
+			);
290
+		}
291
+		return $decoded_string;
292
+	}
293
+
294
+
295
+	/**
296
+	 * encrypts data using PHP's openssl functions
297
+	 *
298
+	 * @param string $text_string the text to be encrypted
299
+	 * @param string $cipher_method
300
+	 * @param string $encryption_key
301
+	 * @return string
302
+	 * @throws RuntimeException
303
+	 */
304
+	protected function openssl_encrypt(
305
+		$text_string = '',
306
+		$cipher_method = EE_Encryption::OPENSSL_CIPHER_METHOD,
307
+		$encryption_key = ''
308
+	) {
309
+		// you give me nothing??? GET OUT !
310
+		if (empty($text_string)) {
311
+			return $text_string;
312
+		}
313
+		$this->cipher_method = $this->getCipherMethod($cipher_method);
314
+		// get initialization vector size
315
+		$iv_size = openssl_cipher_iv_length($this->cipher_method);
316
+		// generate initialization vector.
317
+		// The second parameter ("crypto_strong") is passed by reference,
318
+		// and is used to determines if the algorithm used was "cryptographically strong"
319
+		// openssl_random_pseudo_bytes() will toggle it to either true or false
320
+		$iv = openssl_random_pseudo_bytes($iv_size, $is_strong);
321
+		if ($iv === false || $is_strong === false) {
322
+			throw new RuntimeException(
323
+				esc_html__('Failed to generate OpenSSL initialization vector.', 'event_espresso')
324
+			);
325
+		}
326
+		// encrypt it
327
+		$encrypted_text = openssl_encrypt(
328
+			$text_string,
329
+			$this->cipher_method,
330
+			$this->getDigestHashValue(EE_Encryption::OPENSSL_DIGEST_METHOD, $encryption_key),
331
+			0,
332
+			$iv
333
+		);
334
+		// append the initialization vector
335
+		$encrypted_text .= EE_Encryption::OPENSSL_IV_DELIMITER . $iv;
336
+		// trim and maybe encode
337
+		return $this->_use_base64_encode
338
+			? trim(base64_encode($encrypted_text))
339
+			: trim($encrypted_text);
340
+	}
341
+
342
+
343
+	/**
344
+	 * Returns a cipher method that has been verified to work.
345
+	 * First checks if the cached cipher has been set already and if so, returns that.
346
+	 * Then tests the incoming default and returns that if it's good.
347
+	 * If not, then it retrieves the previously tested and saved cipher method.
348
+	 * But if that doesn't exist, then calls getAvailableCipherMethod()
349
+	 * to see what is available on the server, and returns the results.
350
+	 *
351
+	 * @param string $cipher_method
352
+	 * @return string
353
+	 * @throws RuntimeException
354
+	 */
355
+	protected function getCipherMethod($cipher_method = EE_Encryption::OPENSSL_CIPHER_METHOD)
356
+	{
357
+		if ($this->cipher_method !== '') {
358
+			return $this->cipher_method;
359
+		}
360
+		// verify that the default cipher method can produce an initialization vector
361
+		if (openssl_cipher_iv_length($cipher_method) === false) {
362
+			// nope? okay let's get what we found in the past to work
363
+			$cipher_method = get_option(EE_Encryption::OPENSSL_CIPHER_METHOD_OPTION_NAME, '');
364
+			// oops... haven't tested available cipher methods yet
365
+			if ($cipher_method === '' || openssl_cipher_iv_length($cipher_method) === false) {
366
+				$cipher_method = $this->getAvailableCipherMethod($cipher_method);
367
+			}
368
+		}
369
+		return $cipher_method;
370
+	}
371
+
372
+
373
+	/**
374
+	 * @param string $cipher_method
375
+	 * @return string
376
+	 * @throws \RuntimeException
377
+	 */
378
+	protected function getAvailableCipherMethod($cipher_method)
379
+	{
380
+		// verify that the incoming cipher method can produce an initialization vector
381
+		if (openssl_cipher_iv_length($cipher_method) === false) {
382
+			// nope? then check the next cipher in the list of available cipher methods
383
+			$cipher_method = next($this->cipher_methods);
384
+			// what? there's no list? then generate that list and cache it,
385
+			if (empty($this->cipher_methods)) {
386
+				$this->cipher_methods = openssl_get_cipher_methods();
387
+				// then grab the first item from the list
388
+				$cipher_method = reset($this->cipher_methods);
389
+			}
390
+			if ($cipher_method === false) {
391
+				throw new RuntimeException(
392
+					esc_html__(
393
+						'OpenSSL support appears to be enabled on the server, but no cipher methods are available. Please contact the server administrator.',
394
+						'event_espresso'
395
+					)
396
+				);
397
+			}
398
+			// verify that the next cipher method works
399
+			return $this->getAvailableCipherMethod($cipher_method);
400
+		}
401
+		// if we've gotten this far, then we found an available cipher method that works
402
+		// so save that for next time
403
+		update_option(
404
+			EE_Encryption::OPENSSL_CIPHER_METHOD_OPTION_NAME,
405
+			$cipher_method
406
+		);
407
+		return $cipher_method;
408
+	}
409
+
410
+
411
+	/**
412
+	 * decrypts data that has been encrypted with PHP's openssl functions
413
+	 *
414
+	 * @param string $encrypted_text the text to be decrypted
415
+	 * @param string $cipher_method
416
+	 * @param string $encryption_key
417
+	 * @return string
418
+	 * @throws RuntimeException
419
+	 */
420
+	protected function openssl_decrypt(
421
+		$encrypted_text = '',
422
+		$cipher_method = EE_Encryption::OPENSSL_CIPHER_METHOD,
423
+		$encryption_key = ''
424
+	) {
425
+		// you give me nothing??? GET OUT !
426
+		if (empty($encrypted_text)) {
427
+			return $encrypted_text;
428
+		}
429
+		// decode
430
+		$encrypted_text = $this->valid_base_64($encrypted_text)
431
+			? $this->base64_url_decode($encrypted_text)
432
+			: $encrypted_text;
433
+		$encrypted_components = explode(
434
+			EE_Encryption::OPENSSL_IV_DELIMITER,
435
+			$encrypted_text,
436
+			2
437
+		);
438
+		// check that iv exists, and if not, maybe text was encoded using mcrypt?
439
+		if ($this->_use_mcrypt && ! isset($encrypted_components[1])) {
440
+			return $this->m_decrypt($encrypted_text);
441
+		}
442
+		// decrypt it
443
+		$decrypted_text = openssl_decrypt(
444
+			$encrypted_components[0],
445
+			$this->getCipherMethod($cipher_method),
446
+			$this->getDigestHashValue(EE_Encryption::OPENSSL_DIGEST_METHOD, $encryption_key),
447
+			0,
448
+			$encrypted_components[1]
449
+		);
450
+		$decrypted_text = trim($decrypted_text);
451
+		return $decrypted_text;
452
+	}
453
+
454
+
455
+	/**
456
+	 * Computes the digest hash value using the specified digest method.
457
+	 * If that digest method fails to produce a valid hash value,
458
+	 * then we'll grab the next digest method and recursively try again until something works.
459
+	 *
460
+	 * @param string $digest_method
461
+	 * @param string $encryption_key
462
+	 * @return string
463
+	 * @throws RuntimeException
464
+	 */
465
+	protected function getDigestHashValue($digest_method = EE_Encryption::OPENSSL_DIGEST_METHOD, $encryption_key = '')
466
+	{
467
+		$encryption_key = $encryption_key !== ''
468
+			? $encryption_key
469
+			: $this->get_encryption_key();
470
+		$digest_hash_value = openssl_digest($encryption_key, $digest_method);
471
+		if ($digest_hash_value === false) {
472
+			return $this->getDigestHashValue($this->getDigestMethod());
473
+		}
474
+		return $digest_hash_value;
475
+	}
476
+
477
+
478
+	/**
479
+	 * Returns the NEXT element in the $digest_methods array.
480
+	 * If the $digest_methods array is empty, then we populate it
481
+	 * with the available values returned from openssl_get_md_methods().
482
+	 *
483
+	 * @return string
484
+	 * @throws \RuntimeException
485
+	 */
486
+	protected function getDigestMethod()
487
+	{
488
+		$digest_method = prev($this->digest_methods);
489
+		if (empty($this->digest_methods)) {
490
+			$this->digest_methods = openssl_get_md_methods();
491
+			$digest_method = end($this->digest_methods);
492
+		}
493
+		if ($digest_method === false) {
494
+			throw new RuntimeException(
495
+				esc_html__(
496
+					'OpenSSL support appears to be enabled on the server, but no digest methods are available. Please contact the server administrator.',
497
+					'event_espresso'
498
+				)
499
+			);
500
+		}
501
+		return $digest_method;
502
+	}
503
+
504
+
505
+	/**
506
+	 * encrypts data for acme servers that didn't bother to install PHP mcrypt
507
+	 *
508
+	 * @see http://stackoverflow.com/questions/800922/how-to-encrypt-string-without-mcrypt-library-in-php
509
+	 * @param string $text_string the text to be decrypted
510
+	 * @return string
511
+	 */
512
+	protected function acme_encrypt($text_string = '')
513
+	{
514
+		// you give me nothing??? GET OUT !
515
+		if (empty($text_string)) {
516
+			return $text_string;
517
+		}
518
+		$key_bits = str_split(
519
+			str_pad(
520
+				'',
521
+				strlen($text_string),
522
+				$this->get_encryption_key(),
523
+				STR_PAD_RIGHT
524
+			)
525
+		);
526
+		$string_bits = str_split($text_string);
527
+		foreach ($string_bits as $k => $v) {
528
+			$temp = ord($v) + ord($key_bits[ $k ]);
529
+			$string_bits[ $k ] = chr($temp > 255 ? ($temp - 256) : $temp);
530
+		}
531
+		$encrypted_text = implode('', $string_bits);
532
+		$encrypted_text .= EE_Encryption::ACME_ENCRYPTION_FLAG;
533
+		return $this->_use_base64_encode
534
+			? base64_encode($encrypted_text)
535
+			: $encrypted_text;
536
+	}
537
+
538
+
539
+	/**
540
+	 * decrypts data for acme servers that didn't bother to install PHP mcrypt
541
+	 *
542
+	 * @see http://stackoverflow.com/questions/800922/how-to-encrypt-string-without-mcrypt-library-in-php
543
+	 * @param string $encrypted_text the text to be decrypted
544
+	 * @return string
545
+	 * @throws RuntimeException
546
+	 */
547
+	protected function acme_decrypt($encrypted_text = '')
548
+	{
549
+		// you give me nothing??? GET OUT !
550
+		if (empty($encrypted_text)) {
551
+			return $encrypted_text;
552
+		}
553
+		// decode the data ?
554
+		$encrypted_text = $this->valid_base_64($encrypted_text)
555
+			? $this->base64_url_decode($encrypted_text)
556
+			: $encrypted_text;
557
+		if (
558
+			$this->_use_mcrypt
559
+			&& strpos($encrypted_text, EE_Encryption::ACME_ENCRYPTION_FLAG) === false
560
+		) {
561
+			return $this->m_decrypt($encrypted_text);
562
+		}
563
+		$encrypted_text = substr($encrypted_text, 0, -4);
564
+		$key_bits = str_split(
565
+			str_pad(
566
+				'',
567
+				strlen($encrypted_text),
568
+				$this->get_encryption_key(),
569
+				STR_PAD_RIGHT
570
+			)
571
+		);
572
+		$string_bits = str_split($encrypted_text);
573
+		foreach ($string_bits as $k => $v) {
574
+			$temp = ord($v) - ord($key_bits[ $k ]);
575
+			$string_bits[ $k ] = chr($temp < 0 ? ($temp + 256) : $temp);
576
+		}
577
+		return implode('', $string_bits);
578
+	}
579
+
580
+
581
+	/**
582
+	 * @see http://stackoverflow.com/questions/2556345/detect-base64-encoding-in-php#30231906
583
+	 * @param $string
584
+	 * @return bool
585
+	 */
586
+	protected function valid_base_64($string)
587
+	{
588
+		// ensure data is a string
589
+		if (! is_string($string) || ! $this->_use_base64_encode) {
590
+			return false;
591
+		}
592
+		$decoded = base64_decode($string, true);
593
+		// Check if there is no invalid character in string
594
+		if (! preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) {
595
+			return false;
596
+		}
597
+		// Decode the string in strict mode and send the response
598
+		if (! base64_decode($string, true)) {
599
+			return false;
600
+		}
601
+		// Encode and compare it to original one
602
+		return base64_encode($decoded) === $string;
603
+	}
604
+
605
+
606
+	/**
607
+	 * generate random string
608
+	 *
609
+	 * @see http://stackoverflow.com/questions/637278/what-is-the-best-way-to-generate-a-random-key-within-php
610
+	 * @param int $length number of characters for random string
611
+	 * @return string
612
+	 */
613
+	public function generate_random_string($length = 40)
614
+	{
615
+		$iterations = ceil($length / 40);
616
+		$random_string = '';
617
+		for ($i = 0; $i < $iterations; $i++) {
618
+			$random_string .= sha1(microtime(true) . mt_rand(10000, 90000));
619
+		}
620
+		$random_string = substr($random_string, 0, $length);
621
+		return $random_string;
622
+	}
623
+
624
+
625
+	/**
626
+	 * encrypts data using PHP's mcrypt functions
627
+	 *
628
+	 * @deprecated 4.9.39
629
+	 * @param string $text_string
630
+	 * @internal   param $string - the text to be encrypted
631
+	 * @return string
632
+	 * @throws RuntimeException
633
+	 */
634
+	protected function m_encrypt($text_string = '')
635
+	{
636
+		// you give me nothing??? GET OUT !
637
+		if (empty($text_string)) {
638
+			return $text_string;
639
+		}
640
+		// get the initialization vector size
641
+		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
642
+		// initialization vector
643
+		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
644
+		if ($iv === false) {
645
+			throw new RuntimeException(
646
+				esc_html__('Failed to generate mcrypt initialization vector.', 'event_espresso')
647
+			);
648
+		}
649
+		// encrypt it
650
+		$encrypted_text = mcrypt_encrypt(
651
+			MCRYPT_RIJNDAEL_256,
652
+			$this->get_encryption_key(),
653
+			$text_string,
654
+			MCRYPT_MODE_ECB,
655
+			$iv
656
+		);
657
+		// trim and maybe encode
658
+		return $this->_use_base64_encode
659
+			? trim(base64_encode($encrypted_text))
660
+			: trim($encrypted_text);
661
+	}
662
+
663
+
664
+	/**
665
+	 * decrypts data that has been encrypted with PHP's mcrypt functions
666
+	 *
667
+	 * @deprecated 4.9.39
668
+	 * @param string $encrypted_text the text to be decrypted
669
+	 * @return string
670
+	 * @throws RuntimeException
671
+	 */
672
+	protected function m_decrypt($encrypted_text = '')
673
+	{
674
+		// you give me nothing??? GET OUT !
675
+		if (empty($encrypted_text)) {
676
+			return $encrypted_text;
677
+		}
678
+		// decode
679
+		$encrypted_text = $this->valid_base_64($encrypted_text)
680
+			? $this->base64_url_decode($encrypted_text)
681
+			: $encrypted_text;
682
+		// get the initialization vector size
683
+		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
684
+		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
685
+		if ($iv === false) {
686
+			throw new RuntimeException(
687
+				esc_html__('Failed to generate mcrypt initialization vector.', 'event_espresso')
688
+			);
689
+		}
690
+		// decrypt it
691
+		$decrypted_text = mcrypt_decrypt(
692
+			MCRYPT_RIJNDAEL_256,
693
+			$this->get_encryption_key(),
694
+			$encrypted_text,
695
+			MCRYPT_MODE_ECB,
696
+			$iv
697
+		);
698
+		$decrypted_text = trim($decrypted_text);
699
+		return $decrypted_text;
700
+	}
701 701
 }
Please login to merge, or discard this patch.
core/templates/espresso-ajax-notices.template.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@
 block discarded – undo
1 1
 <div id="espresso-ajax-loading" style="display:none;">
2 2
     <span class="ee-spinner ee-spin"></span><span style="display:none;">
3 3
         <?php _e(
4
-            'loading...',
5
-            'event_espresso'
6
-        ); ?></span>
4
+			'loading...',
5
+			'event_espresso'
6
+		); ?></span>
7 7
 </div>
8 8
 
9 9
 <div id="espresso-ajax-notices">
Please login to merge, or discard this patch.
core/EE_Bootstrap.core.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -14,78 +14,78 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    /**
18
-     * load_espresso_addons
19
-     * runs during the WP 'plugins_loaded' action at priority 1
20
-     * and is the initial loading phase for EE addons
21
-     * no other logic should be performed at this point
22
-     */
23
-    public static function load_espresso_addons()
24
-    {
25
-        do_action('AHEE__EE_Bootstrap__load_espresso_addons');
26
-    }
17
+	/**
18
+	 * load_espresso_addons
19
+	 * runs during the WP 'plugins_loaded' action at priority 1
20
+	 * and is the initial loading phase for EE addons
21
+	 * no other logic should be performed at this point
22
+	 */
23
+	public static function load_espresso_addons()
24
+	{
25
+		do_action('AHEE__EE_Bootstrap__load_espresso_addons');
26
+	}
27 27
 
28 28
 
29
-    /**
30
-     * detect_activations_or_upgrades
31
-     * runs during the WP 'plugins_loaded' action at priority 3
32
-     * Now that all of the addons have been loaded,
33
-     * we can determine if anything needs activating or upgrading
34
-     */
35
-    public static function detect_activations_or_upgrades()
36
-    {
37
-        do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades');
38
-    }
29
+	/**
30
+	 * detect_activations_or_upgrades
31
+	 * runs during the WP 'plugins_loaded' action at priority 3
32
+	 * Now that all of the addons have been loaded,
33
+	 * we can determine if anything needs activating or upgrading
34
+	 */
35
+	public static function detect_activations_or_upgrades()
36
+	{
37
+		do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades');
38
+	}
39 39
 
40 40
 
41
-    /**
42
-     * load_core_configuration
43
-     * runs during the WP 'plugins_loaded' action at priority 5
44
-     * Now that the database is assumed to be at the correct version
45
-     * we can load and set all of the system configurations
46
-     */
47
-    public static function load_core_configuration()
48
-    {
49
-        do_action('AHEE__EE_Bootstrap__load_core_configuration');
50
-    }
41
+	/**
42
+	 * load_core_configuration
43
+	 * runs during the WP 'plugins_loaded' action at priority 5
44
+	 * Now that the database is assumed to be at the correct version
45
+	 * we can load and set all of the system configurations
46
+	 */
47
+	public static function load_core_configuration()
48
+	{
49
+		do_action('AHEE__EE_Bootstrap__load_core_configuration');
50
+	}
51 51
 
52 52
 
53
-    /**
54
-     * register_shortcodes_modules_and_widgets
55
-     * runs during the WP 'plugins_loaded' action at priority 7
56
-     * and handles registering all o four shortcodes, modules and widgets
57
-     * so that they are ready to be used throughout the system
58
-     */
59
-    public static function register_shortcodes_modules_and_widgets()
60
-    {
61
-        do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets');
62
-    }
53
+	/**
54
+	 * register_shortcodes_modules_and_widgets
55
+	 * runs during the WP 'plugins_loaded' action at priority 7
56
+	 * and handles registering all o four shortcodes, modules and widgets
57
+	 * so that they are ready to be used throughout the system
58
+	 */
59
+	public static function register_shortcodes_modules_and_widgets()
60
+	{
61
+		do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets');
62
+	}
63 63
 
64 64
 
65
-    /**
66
-     * brew_espresso
67
-     * runs during the WP 'plugins_loaded' action at priority 9
68
-     * bootstrapping is considered complete at this point,
69
-     * so let the fun begin...
70
-     */
71
-    public static function brew_espresso()
72
-    {
73
-        do_action('AHEE__EE_Bootstrap__brew_espresso');
74
-    }
65
+	/**
66
+	 * brew_espresso
67
+	 * runs during the WP 'plugins_loaded' action at priority 9
68
+	 * bootstrapping is considered complete at this point,
69
+	 * so let the fun begin...
70
+	 */
71
+	public static function brew_espresso()
72
+	{
73
+		do_action('AHEE__EE_Bootstrap__brew_espresso');
74
+	}
75 75
 
76 76
 
77
-    /**
78
-     * @deprecated 4.9.53
79
-     */
80
-    public function run_request_stack()
81
-    {
82
-    }
77
+	/**
78
+	 * @deprecated 4.9.53
79
+	 */
80
+	public function run_request_stack()
81
+	{
82
+	}
83 83
 
84 84
 
85
-    /**
86
-     * @deprecated 4.9.53
87
-     */
88
-    public function build_request_stack()
89
-    {
90
-    }
85
+	/**
86
+	 * @deprecated 4.9.53
87
+	 */
88
+	public function build_request_stack()
89
+	{
90
+	}
91 91
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Formatter.helper.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
             return htmlspecialchars($string);
47 47
         } else {
48 48
             if ($translate === false) {
49
-                return self::ee_tep_parse_input_field_data($string, array( '"' => '&quot;' ));
49
+                return self::ee_tep_parse_input_field_data($string, array('"' => '&quot;'));
50 50
             } else {
51 51
                 return self::ee_tep_parse_input_field_data($string, $translate);
52 52
             }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 return false;
85 85
             }
86 86
         } else {
87
-            if (( $value !== '' ) && ( strtolower($value) !== 'null' ) && ( strlen(trim($value)) > 0 )) {
87
+            if (($value !== '') && (strtolower($value) !== 'null') && (strlen(trim($value)) > 0)) {
88 88
                 return true;
89 89
             } else {
90 90
                 return false;
Please login to merge, or discard this patch.
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -12,108 +12,108 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * _admin_format_content
17
-     * Text formatting function for wp_editor.
18
-     * This should fix all of the formatting issues of text output from the database.
19
-     *
20
-     * @static
21
-     * @access public
22
-     * @param  string $content content to format
23
-     * @return string          formatted content
24
-     */
25
-    public static function admin_format_content($content = '')
26
-    {
27
-        return wpautop(stripslashes_deep(html_entity_decode($content, ENT_QUOTES, "UTF-8")));
28
-    }
15
+	/**
16
+	 * _admin_format_content
17
+	 * Text formatting function for wp_editor.
18
+	 * This should fix all of the formatting issues of text output from the database.
19
+	 *
20
+	 * @static
21
+	 * @access public
22
+	 * @param  string $content content to format
23
+	 * @return string          formatted content
24
+	 */
25
+	public static function admin_format_content($content = '')
26
+	{
27
+		return wpautop(stripslashes_deep(html_entity_decode($content, ENT_QUOTES, "UTF-8")));
28
+	}
29 29
 
30 30
 
31 31
 
32
-    /**
33
-     * ee_tep_output_string
34
-     * todo: we need a description for this.
35
-     *
36
-     * @static
37
-     * @access public
38
-     * @param  string  $string    string to handle
39
-     * @param  boolean $translate //todo what is this for?
40
-     * @param  boolean $protected true then we run htmlspecialchars and return
41
-     * @return string
42
-     */
43
-    public static function ee_tep_output_string($string, $translate = false, $protected = false)
44
-    {
45
-        if ($protected === true) {
46
-            return htmlspecialchars($string);
47
-        } else {
48
-            if ($translate === false) {
49
-                return self::ee_tep_parse_input_field_data($string, array( '"' => '&quot;' ));
50
-            } else {
51
-                return self::ee_tep_parse_input_field_data($string, $translate);
52
-            }
53
-        }
54
-    }
32
+	/**
33
+	 * ee_tep_output_string
34
+	 * todo: we need a description for this.
35
+	 *
36
+	 * @static
37
+	 * @access public
38
+	 * @param  string  $string    string to handle
39
+	 * @param  boolean $translate //todo what is this for?
40
+	 * @param  boolean $protected true then we run htmlspecialchars and return
41
+	 * @return string
42
+	 */
43
+	public static function ee_tep_output_string($string, $translate = false, $protected = false)
44
+	{
45
+		if ($protected === true) {
46
+			return htmlspecialchars($string);
47
+		} else {
48
+			if ($translate === false) {
49
+				return self::ee_tep_parse_input_field_data($string, array( '"' => '&quot;' ));
50
+			} else {
51
+				return self::ee_tep_parse_input_field_data($string, $translate);
52
+			}
53
+		}
54
+	}
55 55
 
56 56
 
57 57
 
58
-    /**
59
-     * ee_tep_parse_input_field_data
60
-     *
61
-     * @param  string $data string to be "translated"
62
-     * @param         array ] $parse array in the form array( 'from' => 'to', ... )
63
-     * @return string
64
-     */
65
-    public static function ee_tep_parse_input_field_data($data, $parse)
66
-    {
67
-        return strtr(trim($data), $parse);
68
-    }
58
+	/**
59
+	 * ee_tep_parse_input_field_data
60
+	 *
61
+	 * @param  string $data string to be "translated"
62
+	 * @param         array ] $parse array in the form array( 'from' => 'to', ... )
63
+	 * @return string
64
+	 */
65
+	public static function ee_tep_parse_input_field_data($data, $parse)
66
+	{
67
+		return strtr(trim($data), $parse);
68
+	}
69 69
 
70 70
 
71 71
 
72
-    /**
73
-     * [ee_tep_not_null description]
74
-     *
75
-     * @param  string | array $value [description]
76
-     * @return bool       [description]
77
-     */
78
-    public static function ee_tep_not_null($value)
79
-    {
80
-        if (is_array($value)) {
81
-            if (count($value) > 0) {
82
-                return true;
83
-            } else {
84
-                return false;
85
-            }
86
-        } else {
87
-            if (( $value !== '' ) && ( strtolower($value) !== 'null' ) && ( strlen(trim($value)) > 0 )) {
88
-                return true;
89
-            } else {
90
-                return false;
91
-            }
92
-        }
93
-    }
72
+	/**
73
+	 * [ee_tep_not_null description]
74
+	 *
75
+	 * @param  string | array $value [description]
76
+	 * @return bool       [description]
77
+	 */
78
+	public static function ee_tep_not_null($value)
79
+	{
80
+		if (is_array($value)) {
81
+			if (count($value) > 0) {
82
+				return true;
83
+			} else {
84
+				return false;
85
+			}
86
+		} else {
87
+			if (( $value !== '' ) && ( strtolower($value) !== 'null' ) && ( strlen(trim($value)) > 0 )) {
88
+				return true;
89
+			} else {
90
+				return false;
91
+			}
92
+		}
93
+	}
94 94
 
95 95
 
96 96
 
97
-    /**
98
-     * Formats a date
99
-     *
100
-     * @param string $date
101
-     * @param string $format - format for the date
102
-     * @deprecated 4.6.12  Note, a search revealed this was not used anywhere in core or in our
103
-     *                       addons at time of writing this.  So just deprecated in case of third party use.
104
-     * @return string
105
-     * @deprecated v4.6.21
106
-     */
107
-    public static function event_date_display($date, $format = '')
108
-    {
109
-        EE_Error::doing_it_wrong(
110
-            __METHOD__,
111
-            esc_html__(
112
-                'This method is deprecated as of EE 4.6.12.  Currently it does not reformat as with prior behaviour but just returns the incoming string.  Please use the EE_Datetime helpers for Datetime on the event to display as desired.',
113
-                'event_espresso'
114
-            ),
115
-            '4.6.21'
116
-        );
117
-        return $date;
118
-    }
97
+	/**
98
+	 * Formats a date
99
+	 *
100
+	 * @param string $date
101
+	 * @param string $format - format for the date
102
+	 * @deprecated 4.6.12  Note, a search revealed this was not used anywhere in core or in our
103
+	 *                       addons at time of writing this.  So just deprecated in case of third party use.
104
+	 * @return string
105
+	 * @deprecated v4.6.21
106
+	 */
107
+	public static function event_date_display($date, $format = '')
108
+	{
109
+		EE_Error::doing_it_wrong(
110
+			__METHOD__,
111
+			esc_html__(
112
+				'This method is deprecated as of EE 4.6.12.  Currently it does not reformat as with prior behaviour but just returns the incoming string.  Please use the EE_Datetime helpers for Datetime on the event to display as desired.',
113
+				'event_espresso'
114
+			),
115
+			'4.6.21'
116
+		);
117
+		return $date;
118
+	}
119 119
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Base.helper.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -11,42 +11,42 @@
 block discarded – undo
11 11
 class EEH_Base
12 12
 {
13 13
 
14
-    /**
15
-     *  @var    array   $uri_segment_array  URL segments
16
-     *  @access     private
17
-     */
14
+	/**
15
+	 *  @var    array   $uri_segment_array  URL segments
16
+	 *  @access     private
17
+	 */
18 18
 //  final private function __construct() {}
19 19
 
20
-    /**
21
-     *      @ override magic methods
22
-     *      @ return void
23
-     */
24
-    public function __set($a, $b)
25
-    {
26
-        return false;
27
-    }
28
-    public function __get($a)
29
-    {
30
-        return false;
31
-    }
32
-    public function __isset($a)
33
-    {
34
-        return false;
35
-    }
36
-    public function __unset($a)
37
-    {
38
-        return false;
39
-    }
40
-    public function __clone()
41
-    {
42
-        return false;
43
-    }
44
-    public function __wakeup()
45
-    {
46
-        return false;
47
-    }
48
-    public function __destruct()
49
-    {
50
-        return false;
51
-    }
20
+	/**
21
+	 *      @ override magic methods
22
+	 *      @ return void
23
+	 */
24
+	public function __set($a, $b)
25
+	{
26
+		return false;
27
+	}
28
+	public function __get($a)
29
+	{
30
+		return false;
31
+	}
32
+	public function __isset($a)
33
+	{
34
+		return false;
35
+	}
36
+	public function __unset($a)
37
+	{
38
+		return false;
39
+	}
40
+	public function __clone()
41
+	{
42
+		return false;
43
+	}
44
+	public function __wakeup()
45
+	{
46
+		return false;
47
+	}
48
+	public function __destruct()
49
+	{
50
+		return false;
51
+	}
52 52
 }
Please login to merge, or discard this patch.
core/helpers/EEH_Array.helper.php 2 patches
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -13,203 +13,203 @@
 block discarded – undo
13 13
 {
14 14
 
15 15
 
16
-    /**
17
-     * This method basically works the same as the PHP core function array_diff except it allows you to compare arrays
18
-     * of EE_Base_Class objects NOTE: This will ONLY work on an array of EE_Base_Class objects
19
-     *
20
-     * @uses array_udiff core php function for setting up our own array comparison
21
-     * @uses self::_compare_objects as the custom method for array_udiff
22
-     * @param  array $array1 an array of objects
23
-     * @param  array $array2 an array of objects
24
-     * @return array         an array of objects found in array 1 that aren't found in array 2.
25
-     */
26
-    public static function object_array_diff($array1, $array2)
27
-    {
28
-        return array_udiff($array1, $array2, array('self', '_compare_objects'));
29
-    }
30
-
31
-    /**
32
-     * Given that $arr is an array, determines if it's associative or numerically AND sequentially indexed
33
-     *
34
-     * @param array $array
35
-     * @return boolean
36
-     */
37
-    public static function is_associative_array(array $array)
38
-    {
39
-        return array_keys($array) !== range(0, count($array) - 1);
40
-    }
41
-
42
-    /**
43
-     * Gets an item from the array and leave the array intact. Use in place of end()
44
-     * when you don't want to change the array
45
-     *
46
-     * @param array $arr
47
-     * @return mixed what ever is in the array
48
-     */
49
-    public static function get_one_item_from_array($arr)
50
-    {
51
-        $item = end($arr);
52
-        reset($arr);
53
-        return $item;
54
-    }
55
-
56
-    /**
57
-     * Detects if this is a multi-dimensional array (meaning that the top-level
58
-     * values are themselves array. Eg array(array(...),...)
59
-     *
60
-     * @param mixed $arr
61
-     * @return boolean
62
-     */
63
-    public static function is_multi_dimensional_array($arr)
64
-    {
65
-        if (is_array($arr)) {
66
-            $first_item = reset($arr);
67
-            if (is_array($first_item)) {
68
-                return true;// yep, there's at least 2 levels to this array
69
-            } else {
70
-                return false;// nope, only 1 level
71
-            }
72
-        } else {
73
-            return false;// its not an array at all!
74
-        }
75
-    }
76
-
77
-    /**
78
-     * Shorthand for isset( $arr[ $index ] ) ? $arr[ $index ] : $default
79
-     *
80
-     * @param array $arr
81
-     * @param mixed $index
82
-     * @param mixed $default
83
-     * @return mixed
84
-     */
85
-    public static function is_set($arr, $index, $default)
86
-    {
87
-        return isset($arr[ $index ]) ? $arr[ $index ] : $default;
88
-    }
89
-
90
-    /**
91
-     * Exactly like `maybe_unserialize`, but also accounts for a WP bug: http://core.trac.wordpress.org/ticket/26118
92
-     *
93
-     * @param mixed $value usually a string, but could be an array or object
94
-     * @return mixed the UN-serialized data
95
-     */
96
-    public static function maybe_unserialize($value)
97
-    {
98
-        $data = maybe_unserialize($value);
99
-        // it's possible that this still has serialized data if its the session.  WP has a bug, http://core.trac.wordpress.org/ticket/26118 that doesnt' unserialize this automatically.
100
-        $token = 'C';
101
-        $data = is_string($data) ? trim($data) : $data;
102
-        if (is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match("/^{$token}:[0-9]+:/s", $data)) {
103
-            return unserialize($data);
104
-        } else {
105
-            return $data;
106
-        }
107
-    }
108
-
109
-
110
-    /**
111
-     * insert_into_array
112
-     *
113
-     * @param array        $target_array the array to insert new data into
114
-     * @param array        $array_to_insert the new data to be inserted
115
-     * @param int | string $offset a known key within $target_array where new data will be inserted
116
-     * @param bool         $add_before whether to add new data before or after the offset key
117
-     * @param bool         $preserve_keys whether or not to reset numerically indexed arrays
118
-     * @return array
119
-     */
120
-    public static function insert_into_array(
121
-        $target_array = array(),
122
-        $array_to_insert = array(),
123
-        $offset = null,
124
-        $add_before = true,
125
-        $preserve_keys = true
126
-    ) {
127
-        // ensure incoming arrays are actually arrays
128
-        $target_array = (array) $target_array;
129
-        $array_to_insert = (array) $array_to_insert;
130
-        // if no offset key was supplied
131
-        if (empty($offset)) {
132
-            // use start or end of $target_array based on whether we are adding before or not
133
-            $offset = $add_before ? 0 : count($target_array);
134
-        }
135
-        // if offset key is a string, then find the corresponding numeric location for that element
136
-        $offset = is_int($offset) ? $offset : array_search($offset, array_keys($target_array));
137
-        // add one to the offset if adding after
138
-        $offset = $add_before ? $offset : $offset + 1;
139
-        // but ensure offset does not exceed the length of the array
140
-        $offset = $offset > count($target_array) ? count($target_array) : $offset;
141
-        // reindex array ???
142
-        if ($preserve_keys) {
143
-            // take a slice of the target array from the beginning till the offset,
144
-            // then add the new data
145
-            // then add another slice that starts at the offset and goes till the end
146
-            return array_slice($target_array, 0, $offset, true) + $array_to_insert + array_slice(
147
-                $target_array,
148
-                $offset,
149
-                null,
150
-                true
151
-            );
152
-        } else {
153
-            // since we don't want to preserve keys, we can use array_splice
154
-            array_splice($target_array, $offset, 0, $array_to_insert);
155
-            return $target_array;
156
-        }
157
-    }
158
-
159
-
160
-    /**
161
-     * array_merge() is slow and should never be used while looping over data
162
-     * if you don't need to preserve keys from all arrays, then using a foreach loop is much faster
163
-     * so really this acts more like array_replace( $array1, $array2 )
164
-     * or a union with the arrays flipped ( $array2 + $array1 )
165
-     * this saves a few lines of code and improves readability
166
-     *
167
-     * @param array $array1
168
-     * @param array $array2
169
-     * @return array
170
-     */
171
-    public static function merge_arrays_and_overwrite_keys(array $array1, array $array2)
172
-    {
173
-        foreach ($array2 as $key => $value) {
174
-            $array1[ $key ] = $value;
175
-        }
176
-        return $array1;
177
-    }
178
-
179
-
180
-    /**
181
-     * given a flat array like $array = array('A', 'B', 'C')
182
-     * will convert into a multidimensional array like $array[A][B][C]
183
-     * if $final_value is provided and is anything other than null,
184
-     * then that will be set as the value for the innermost array key
185
-     * like so: $array[A][B][C] = $final_value
186
-     *
187
-     * @param array $flat_array
188
-     * @param mixed $final_value
189
-     * @return array
190
-     */
191
-    public static function convert_array_values_to_keys(array $flat_array, $final_value = null)
192
-    {
193
-        $multidimensional = array();
194
-        $reference = &$multidimensional;
195
-        foreach ($flat_array as $key) {
196
-            $reference[ $key ] = array();
197
-            $reference = &$reference[ $key ];
198
-        }
199
-        if ($final_value !== null) {
200
-            $reference = $final_value;
201
-        }
202
-        return $multidimensional;
203
-    }
204
-
205
-
206
-    /**
207
-     * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
208
-     * @param array $array
209
-     * @return bool
210
-     */
211
-    public static function is_array_numerically_and_sequentially_indexed(array $array)
212
-    {
213
-        return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
214
-    }
16
+	/**
17
+	 * This method basically works the same as the PHP core function array_diff except it allows you to compare arrays
18
+	 * of EE_Base_Class objects NOTE: This will ONLY work on an array of EE_Base_Class objects
19
+	 *
20
+	 * @uses array_udiff core php function for setting up our own array comparison
21
+	 * @uses self::_compare_objects as the custom method for array_udiff
22
+	 * @param  array $array1 an array of objects
23
+	 * @param  array $array2 an array of objects
24
+	 * @return array         an array of objects found in array 1 that aren't found in array 2.
25
+	 */
26
+	public static function object_array_diff($array1, $array2)
27
+	{
28
+		return array_udiff($array1, $array2, array('self', '_compare_objects'));
29
+	}
30
+
31
+	/**
32
+	 * Given that $arr is an array, determines if it's associative or numerically AND sequentially indexed
33
+	 *
34
+	 * @param array $array
35
+	 * @return boolean
36
+	 */
37
+	public static function is_associative_array(array $array)
38
+	{
39
+		return array_keys($array) !== range(0, count($array) - 1);
40
+	}
41
+
42
+	/**
43
+	 * Gets an item from the array and leave the array intact. Use in place of end()
44
+	 * when you don't want to change the array
45
+	 *
46
+	 * @param array $arr
47
+	 * @return mixed what ever is in the array
48
+	 */
49
+	public static function get_one_item_from_array($arr)
50
+	{
51
+		$item = end($arr);
52
+		reset($arr);
53
+		return $item;
54
+	}
55
+
56
+	/**
57
+	 * Detects if this is a multi-dimensional array (meaning that the top-level
58
+	 * values are themselves array. Eg array(array(...),...)
59
+	 *
60
+	 * @param mixed $arr
61
+	 * @return boolean
62
+	 */
63
+	public static function is_multi_dimensional_array($arr)
64
+	{
65
+		if (is_array($arr)) {
66
+			$first_item = reset($arr);
67
+			if (is_array($first_item)) {
68
+				return true;// yep, there's at least 2 levels to this array
69
+			} else {
70
+				return false;// nope, only 1 level
71
+			}
72
+		} else {
73
+			return false;// its not an array at all!
74
+		}
75
+	}
76
+
77
+	/**
78
+	 * Shorthand for isset( $arr[ $index ] ) ? $arr[ $index ] : $default
79
+	 *
80
+	 * @param array $arr
81
+	 * @param mixed $index
82
+	 * @param mixed $default
83
+	 * @return mixed
84
+	 */
85
+	public static function is_set($arr, $index, $default)
86
+	{
87
+		return isset($arr[ $index ]) ? $arr[ $index ] : $default;
88
+	}
89
+
90
+	/**
91
+	 * Exactly like `maybe_unserialize`, but also accounts for a WP bug: http://core.trac.wordpress.org/ticket/26118
92
+	 *
93
+	 * @param mixed $value usually a string, but could be an array or object
94
+	 * @return mixed the UN-serialized data
95
+	 */
96
+	public static function maybe_unserialize($value)
97
+	{
98
+		$data = maybe_unserialize($value);
99
+		// it's possible that this still has serialized data if its the session.  WP has a bug, http://core.trac.wordpress.org/ticket/26118 that doesnt' unserialize this automatically.
100
+		$token = 'C';
101
+		$data = is_string($data) ? trim($data) : $data;
102
+		if (is_string($data) && strlen($data) > 1 && $data[0] == $token && preg_match("/^{$token}:[0-9]+:/s", $data)) {
103
+			return unserialize($data);
104
+		} else {
105
+			return $data;
106
+		}
107
+	}
108
+
109
+
110
+	/**
111
+	 * insert_into_array
112
+	 *
113
+	 * @param array        $target_array the array to insert new data into
114
+	 * @param array        $array_to_insert the new data to be inserted
115
+	 * @param int | string $offset a known key within $target_array where new data will be inserted
116
+	 * @param bool         $add_before whether to add new data before or after the offset key
117
+	 * @param bool         $preserve_keys whether or not to reset numerically indexed arrays
118
+	 * @return array
119
+	 */
120
+	public static function insert_into_array(
121
+		$target_array = array(),
122
+		$array_to_insert = array(),
123
+		$offset = null,
124
+		$add_before = true,
125
+		$preserve_keys = true
126
+	) {
127
+		// ensure incoming arrays are actually arrays
128
+		$target_array = (array) $target_array;
129
+		$array_to_insert = (array) $array_to_insert;
130
+		// if no offset key was supplied
131
+		if (empty($offset)) {
132
+			// use start or end of $target_array based on whether we are adding before or not
133
+			$offset = $add_before ? 0 : count($target_array);
134
+		}
135
+		// if offset key is a string, then find the corresponding numeric location for that element
136
+		$offset = is_int($offset) ? $offset : array_search($offset, array_keys($target_array));
137
+		// add one to the offset if adding after
138
+		$offset = $add_before ? $offset : $offset + 1;
139
+		// but ensure offset does not exceed the length of the array
140
+		$offset = $offset > count($target_array) ? count($target_array) : $offset;
141
+		// reindex array ???
142
+		if ($preserve_keys) {
143
+			// take a slice of the target array from the beginning till the offset,
144
+			// then add the new data
145
+			// then add another slice that starts at the offset and goes till the end
146
+			return array_slice($target_array, 0, $offset, true) + $array_to_insert + array_slice(
147
+				$target_array,
148
+				$offset,
149
+				null,
150
+				true
151
+			);
152
+		} else {
153
+			// since we don't want to preserve keys, we can use array_splice
154
+			array_splice($target_array, $offset, 0, $array_to_insert);
155
+			return $target_array;
156
+		}
157
+	}
158
+
159
+
160
+	/**
161
+	 * array_merge() is slow and should never be used while looping over data
162
+	 * if you don't need to preserve keys from all arrays, then using a foreach loop is much faster
163
+	 * so really this acts more like array_replace( $array1, $array2 )
164
+	 * or a union with the arrays flipped ( $array2 + $array1 )
165
+	 * this saves a few lines of code and improves readability
166
+	 *
167
+	 * @param array $array1
168
+	 * @param array $array2
169
+	 * @return array
170
+	 */
171
+	public static function merge_arrays_and_overwrite_keys(array $array1, array $array2)
172
+	{
173
+		foreach ($array2 as $key => $value) {
174
+			$array1[ $key ] = $value;
175
+		}
176
+		return $array1;
177
+	}
178
+
179
+
180
+	/**
181
+	 * given a flat array like $array = array('A', 'B', 'C')
182
+	 * will convert into a multidimensional array like $array[A][B][C]
183
+	 * if $final_value is provided and is anything other than null,
184
+	 * then that will be set as the value for the innermost array key
185
+	 * like so: $array[A][B][C] = $final_value
186
+	 *
187
+	 * @param array $flat_array
188
+	 * @param mixed $final_value
189
+	 * @return array
190
+	 */
191
+	public static function convert_array_values_to_keys(array $flat_array, $final_value = null)
192
+	{
193
+		$multidimensional = array();
194
+		$reference = &$multidimensional;
195
+		foreach ($flat_array as $key) {
196
+			$reference[ $key ] = array();
197
+			$reference = &$reference[ $key ];
198
+		}
199
+		if ($final_value !== null) {
200
+			$reference = $final_value;
201
+		}
202
+		return $multidimensional;
203
+	}
204
+
205
+
206
+	/**
207
+	 * @see http://stackoverflow.com/questions/173400/how-to-check-if-php-array-is-associative-or-sequential
208
+	 * @param array $array
209
+	 * @return bool
210
+	 */
211
+	public static function is_array_numerically_and_sequentially_indexed(array $array)
212
+	{
213
+		return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
214
+	}
215 215
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
         if (is_array($arr)) {
66 66
             $first_item = reset($arr);
67 67
             if (is_array($first_item)) {
68
-                return true;// yep, there's at least 2 levels to this array
68
+                return true; // yep, there's at least 2 levels to this array
69 69
             } else {
70
-                return false;// nope, only 1 level
70
+                return false; // nope, only 1 level
71 71
             }
72 72
         } else {
73
-            return false;// its not an array at all!
73
+            return false; // its not an array at all!
74 74
         }
75 75
     }
76 76
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public static function is_set($arr, $index, $default)
86 86
     {
87
-        return isset($arr[ $index ]) ? $arr[ $index ] : $default;
87
+        return isset($arr[$index]) ? $arr[$index] : $default;
88 88
     }
89 89
 
90 90
     /**
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     public static function merge_arrays_and_overwrite_keys(array $array1, array $array2)
172 172
     {
173 173
         foreach ($array2 as $key => $value) {
174
-            $array1[ $key ] = $value;
174
+            $array1[$key] = $value;
175 175
         }
176 176
         return $array1;
177 177
     }
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
         $multidimensional = array();
194 194
         $reference = &$multidimensional;
195 195
         foreach ($flat_array as $key) {
196
-            $reference[ $key ] = array();
197
-            $reference = &$reference[ $key ];
196
+            $reference[$key] = array();
197
+            $reference = &$reference[$key];
198 198
         }
199 199
         if ($final_value !== null) {
200 200
             $reference = $final_value;
Please login to merge, or discard this patch.