PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.19
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.19
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmFormState.php +19 -3 6.46.19 View file →
@@ -13,9 +13,9 @@
13 13 */
14 14 class FrmFormState {
15 15
16 16 /**
17 - * @var FrmFormState $instance
17 + * @var FrmFormState
18 18 */
19 19 private static $instance;
20 20
21 21 /**
@@ -45,9 +45,9 @@
45 45 /**
46 46 * @return bool true if just initialized.
47 47 */
48 48 private static function maybe_initialize() {
49 - if ( ! isset( self::$instance ) ) {
49 + if ( empty( self::$instance ) ) {
50 50 self::$instance = new self();
51 51 return true;
52 52 }
53 53 return false;
@@ -144,8 +144,11 @@
144 144 /**
145 145 * @return void
146 146 */
147 147 public function render_state_field() {
148 + if ( ! self::open_ssl_is_installed() ) {
149 + return;
150 + }
148 151 if ( ! $this->state && ! self::get_state_from_request() ) {
149 152 return;
150 153 }
151 154 $state_string = $this->get_state_string();
@@ -155,8 +158,11 @@
155 158 /**
156 159 * @return string
157 160 */
158 161 private function get_state_string() {
162 + if ( ! self::open_ssl_is_installed() ) {
163 + return '';
164 + }
159 165 $secret = self::get_encryption_secret();
160 166 $compressed_state = $this->compressed_state();
161 167 $json_encoded = json_encode( $compressed_state );
162 168 $encrypted = openssl_encrypt( $json_encoded, 'AES-128-ECB', $secret );
@@ -163,8 +169,18 @@
163 169 return $encrypted;
164 170 }
165 171
166 172 /**
173 + * Returns true if open SSL is installed.
174 + *
175 + * @since 6.12
176 + * @return bool
177 + */
178 + private static function open_ssl_is_installed() {
179 + return function_exists( 'openssl_encrypt' );
180 + }
181 +
182 + /**
167 183 * Return state but with shorter keys to use for the state string.
168 184 *
169 185 * @return array
170 186 */
@@ -218,9 +234,9 @@
218 234 }
219 235
220 236 // We don't have a secret, so let's generate one.
221 237 $secret_key = is_callable( 'sodium_crypto_secretbox_keygen' ) ? sodium_crypto_secretbox_keygen() : wp_generate_password( 32, true, true );
222 - add_option( 'frm_form_state_key', base64_encode( $secret_key ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
238 + update_option( 'frm_form_state_key', base64_encode( $secret_key ), 'no' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
223 239
224 240 return $secret_key;
225 241 }
226 242 }