PluginProbe ʕ •ᴥ•ʔ
Firebase Authentication / 1.5.5
Firebase Authentication v1.5.5
1.7.0 trunk 1.0.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.8 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9
firebase-authentication / firebase-authentication.php
firebase-authentication Last commit date
admin 4 years ago includes 4 years ago languages 4 years ago public 4 years ago views 4 years ago README.txt 4 years ago class-contact-us.php 4 years ago class-mo-firebase-config.php 4 years ago firebase-authentication.php 4 years ago index.php 4 years ago uninstall.php 4 years ago
firebase-authentication.php
520 lines
1 <?php
2
3
4 /**
5 *
6 * @link https://miniorange.com
7 * @since 1.0.0
8 * @package Firebase_Authentication
9 *
10 * @wordpress-plugin
11 * Plugin Name: Firebase Authentication
12 * Plugin URI: firebase-authentication
13 * Description: This plugin allows login into Wordpress using Firebase as Identity provider.
14 * Version: 1.5.5
15 * Author: miniOrange
16 * Author URI: https://miniorange.com
17 * License: MIT/Expat
18 */
19
20
21 // If this file is called directly, abort.
22 if ( ! defined( 'WPINC' ) ) {
23 die;
24 }
25
26 /**
27 * Currently plugin version.
28 * Start at version 1.0.0 and use SemVer - https://semver.org
29 * Rename this for your plugin and update it as you release new versions.
30 */
31 define( 'MO_FIREBASE_AUTHENTICATION_VERSION', '1.5.5' );
32
33 /**
34 * The code that runs during plugin activation.
35 * This action is documented in includes/class-firebase-authentication-activator.php
36 */
37 function mo_firebase_activate_firebase_authentication() {
38 require_once plugin_dir_path( __FILE__ ) . 'includes/class-firebase-authentication-activator.php';
39 MO_Firebase_Authentication_Activator::activate();
40 }
41
42 /**
43 * The code that runs during plugin deactivation.
44 * This action is documented in includes/class-firebase-authentication-deactivator.php
45 */
46 function mo_firebase_deactivate_firebase_authentication() {
47 require_once plugin_dir_path( __FILE__ ) . 'includes/class-firebase-authentication-deactivator.php';
48 MO_Firebase_Authentication_Deactivator::deactivate();
49 }
50
51 register_activation_hook( __FILE__, 'mo_firebase_activate_firebase_authentication' );
52 register_deactivation_hook( __FILE__, 'mo_firebase_deactivate_firebase_authentication' );
53
54 /**
55 * The core plugin class that is used to define internationalization,
56 * admin-specific hooks, and public-facing site hooks.
57 */
58 require plugin_dir_path( __FILE__ ) . 'includes/class-firebase-authentication.php';
59 require_once 'class-mo-firebase-config.php';
60 require('views/feedback_form.php');
61 require('class-contact-us.php');
62 require('admin/class-firebase-authentication-customer.php');
63
64
65 /**
66 * Begins execution of the plugin.
67 *
68 * Since everything within the plugin is registered via hooks,
69 * then kicking off the plugin from this point in the file does
70 * not affect the page life cycle.
71 *
72 * @since 1.0.0
73 */
74 function mo_firebase_run_firebase_authentication() {
75
76 $plugin = new MO_Firebase_Authentication();
77 $plugin->run();
78
79 }
80 mo_firebase_run_firebase_authentication();
81
82 function mo_firebase_authentication_is_customer_registered() {
83 $email = get_option('mo_firebase_authentication_admin_email');
84 // $phone = get_option('mo_firebase_authentication_admin_phone');
85 $customerKey = get_option('mo_firebase_authentication_admin_customer_key');
86 // if( ! $email || ! $phone || ! $customerKey || ! is_numeric( trim( $customerKey ) ) ) {
87 if( ! $email || ! $customerKey || ! is_numeric( trim( $customerKey ) ) ) {
88
89 return 0;
90 } else {
91 return 1;
92 }
93 }
94 function mo_firebase_authentication_is_clv() {
95 $licenseKey = get_option('mo_firebase_authentication_lk');
96 $isverified = get_option('mo_firebase_authentication_lv');
97 if($isverified)
98 $isverified = mo_firebase_authentication_decrypt($isverified);
99
100 if(!empty($licenseKey) && $isverified=="true") {
101 return 1;
102 }
103 return 0;
104 }
105
106 function mo_firebase_authentication_encrypt($str){
107 $pass = get_option("mo_firebase_authentication_customer_token");
108 $pass = str_split(str_pad('', strlen($str), $pass, STR_PAD_RIGHT));
109 $stra = str_split($str);
110 foreach($stra as $k=>$v){
111 $tmp = ord($v)+ord($pass[$k]);
112 $stra[$k] = chr( $tmp > 255 ?($tmp-256):$tmp);
113 }
114 return base64_encode(join('', $stra));
115 }
116
117 function mo_firebase_authentication_decrypt($str){
118 $str = base64_decode($str);
119 $pass = get_option("mo_firebase_authentication_customer_token");
120 $pass = str_split(str_pad('', strlen($str), $pass, STR_PAD_RIGHT));
121 $stra = str_split($str);
122 foreach($stra as $k=>$v){
123 $tmp = ord($v)-ord($pass[$k]);
124 $stra[$k] = chr( $tmp < 0 ?($tmp+256):$tmp);
125 }
126 return join('', $stra);
127 }
128
129
130 class mo_firebase_authentication_login {
131 function __construct() {
132 add_action( 'init', array( $this, 'postResgiter' ) );
133 add_action( 'admin_init', array( $this, 'mo_firebase_auth_deactivate' ) );
134 if ( get_option( 'mo_enable_firebase_auth' ) == 1 ) {
135 if ( strpos( $_SERVER['REQUEST_URI'], '/wp-json' ) === false ) {
136 remove_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 );
137 remove_filter( 'authenticate', 'wp_authenticate_email_password', 20, 3 );
138 add_filter( 'authenticate', array( $this, 'mo_firebase_auth' ), 0, 3 );
139 }
140 }
141 remove_action( 'admin_notices', array( $this, 'mo_firebase_auth_success_message') );
142 remove_action( 'admin_notices', array( $this, 'mo_firebase_auth_error_message') );
143 add_action( 'admin_footer', array( $this, 'mo_firebase_auth_feedback_request' ) );
144 update_option( 'host_name', 'https://login.xecurify.com' );
145 }
146
147 function postResgiter() {
148 if ( isset( $_POST['verify_user'] ) && isset( $_REQUEST['page'] ) && sanitize_text_field( wp_unslash( $_REQUEST['page'] ) ) == 'mo_firebase_authentication' && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['mo_firebase_auth_config_field'] ) ), 'mo_firebase_auth_config_form' ) ) {
149
150 if( current_user_can( 'administrator' ) ) {
151 update_option( 'mo_firebase_auth_disable_wordpress_login', isset( $_POST['disable_wordpress_login'] ) ? (int)filter_var( $_POST['disable_wordpress_login'], FILTER_SANITIZE_NUMBER_INT ) : 0 );
152
153 update_option('mo_firebase_auth_enable_admin_wp_login', isset($_POST['mo_firebase_auth_enable_admin_wp_login']) ? $_POST['mo_firebase_auth_enable_admin_wp_login'] : 0);
154
155 $project_id = isset( $_POST['projectid'] ) ? sanitize_text_field( $_POST['projectid'] ) : '';
156 update_option( 'mo_firebase_auth_project_id', $project_id );
157
158 $api_key = isset( $_POST['apikey'] ) ? sanitize_text_field( $_POST['apikey'] ) : '';
159 update_option( 'mo_firebase_auth_api_key', $api_key );
160
161 $this->mo_firebase_auth_store_certificates();
162 update_option( 'mo_firebase_auth_message', 'Configurations saved successfully. Please <a href="' . admin_url( 'admin.php?page=mo_firebase_authentication&tab=config#test_authentication' ) .'">Test Authentication</a> before trying to Login.');
163 $this->mo_firebase_auth_show_success_message();
164 }
165 }
166 }
167
168 function mo_firebase_auth_store_certificates(){
169 $response = wp_remote_get( 'https://www.googleapis.com/robot/v1/metadata/x509/securetoken@system.gserviceaccount.com' );
170 if ( is_array( $response ) ) {
171 $header = $response['headers']; // array of http header lines
172 $body = $response['body']; // use the content
173
174 $split_result = explode( ":", $body );
175 $count = count( $split_result );
176 $kid1 = substr( $split_result[0], 5, 40 );
177 $s = explode( ",", $split_result[1] );
178 $c1 = substr( $s[0], 2, 1158 );
179 $c1 = str_replace( '\n', '', $c1 );
180 update_option( 'mo_firebase_auth_kid1', $kid1 );
181 update_option( 'mo_firebase_auth_cert1', $c1 );
182 if( $count == 3 ) {
183 $kid2 = substr( $s[1], 4, 40 );
184 $c2 = explode( "}", $split_result[2] );
185 $c2[0] = substr( $c2[0], 2, 1158 );
186 $c2[0] = str_replace( '\n', '', $c2[0] );
187 update_option( 'mo_firebase_auth_kid2', $kid2 );
188 update_option( 'mo_firebase_auth_cert2', $c2[0] );
189 } else if ( $count > 3) {
190 $kid2 = substr( $s[1], 4, 40 );
191 $s2 = explode( ",", $split_result[2] );
192 $c2 = substr( $s2[0], 2, 1158 );
193 $kid3 = substr( $s2[1], 4, 40 );
194 $c3 = explode( "}", $split_result[3] );
195 $c3[0] = substr( $c3[0], 2, 1158 );
196 $c2 = str_replace( '\n', '', $c2 );
197 update_option( 'mo_firebase_auth_kid2', $kid2 );
198 update_option( 'mo_firebase_auth_cert2', $c2 );
199 $c3[0] = str_replace( '\n', '', $c3[0] );
200 update_option( 'mo_firebase_auth_kid3', $kid3 );
201 update_option( 'mo_firebase_auth_cert3', $c3[0] );
202 }
203 } else {
204 if ( is_wp_error( $response ) ) {
205 $error_message = $response->get_error_message();
206 echo "Something went wrong: $error_message";
207 exit();
208 }
209 }
210 }
211
212 function mo_fb_clear_wp_login_errors($errors, $redirect_to){
213 return new WP_Error();
214 }
215
216
217 function mo_firebase_auth( $default_user, $username, $password ) {
218
219 if( "POST" !== sanitize_text_field( wp_unslash( $_SERVER['REQUEST_METHOD'] ) ) ) {
220 add_filter( 'wp_login_errors', array( $this, 'mo_fb_clear_wp_login_errors' ), 0, 2 );
221 return $default_user;
222 }
223
224 if ( empty( $username ) || empty ( $password ) ) {
225
226 $error = new WP_Error();
227 //create new error object and add errors to it.
228
229 if ( empty( $username ) ) { //No email
230 $error->add( 'empty_username', __( '<strong>ERROR</strong>: Email field is empty.' ) );
231 }
232
233 else if ( empty( $password ) ) { //No password
234 $error->add( 'empty_password', __( '<strong>ERROR</strong>: Password field is empty.' ) );
235 }
236 return $error;
237 }
238
239 $mo_firebase_config_obj = new Mo_Firebase_Config();
240 $fb_user = $mo_firebase_config_obj->mo_firebase_authenticate_call($username, $password);
241 $fb_user = json_decode($fb_user, true);
242
243 if(isset($fb_user['idToken'])){
244 $response = $mo_firebase_config_obj->mo_fb_login_user($fb_user['idToken']);
245 }
246 else{
247
248 $error_message = $fb_user['error']['message'];
249 if($error_message == 'INVALID_EMAIL' || $error_message == 'EMAIL_NOT_FOUND'){
250 if ( get_option( 'mo_firebase_auth_disable_wordpress_login' ) == false ) {
251 $user = get_user_by( "login", $username );
252 if ( !$user ) {
253 $user = get_user_by( "email", $username );
254 }
255 if ( $user && wp_check_password( $password, $user->data->user_pass, $user->ID ) ) {
256 return $user;
257 }
258 }
259 else if ( get_option( 'mo_firebase_auth_enable_admin_wp_login' ) ) {
260 $user = get_user_by( "login", $username );
261 if ( !$user ) {
262 $user = get_user_by( "email", $username );
263 }
264 if ( $user && $this->is_administrator_user( $user ) ) {
265
266 if ( wp_check_password( $password, $user->data->user_pass, $user->ID ) ) {
267 return $user;
268 }
269 }
270 }
271 }else{
272 $error = new WP_Error();
273 if($error_message == 'INVALID_PASSWORD'){
274 $error_message = 'The password is invalid or the user does not have a password.';
275 }
276 $error->add('firebase_error', __( '<strong>ERROR</strong>: '.$error_message ));
277 return $error;
278 }
279 }
280 return $default_user;
281 }
282
283 function mo_firebase_auth_success_message() {
284 $class = "error";
285 $message = get_option('mo_firebase_auth_message');
286 echo "<div class='" . $class . "'> <p>" . $message . "</p></div>";
287 }
288
289 function mo_firebase_auth_error_message() {
290 $class = "updated";
291 $message = get_option('mo_firebase_auth_message');
292 echo "<div class='" . $class . "'><p>" . $message . "</p></div>";
293 }
294
295 function is_administrator_user( $user ) {
296 $userRole = ( $user->roles );
297 if ( ! is_null( $userRole ) && in_array( 'administrator' , $userRole ) ) {
298 return true;
299 }
300 else {
301 return false;
302 }
303 }
304
305 private function mo_firebase_auth_show_success_message() {
306 remove_action( 'admin_notices', array( $this, 'mo_firebase_auth_success_message') );
307 add_action( 'admin_notices', array( $this, 'mo_firebase_auth_error_message') );
308 }
309
310 private function mo_firebase_auth_show_error_message() {
311 remove_action( 'admin_notices', array( $this, 'mo_firebase_auth_error_message') );
312 add_action( 'admin_notices', array( $this, 'mo_firebase_auth_success_message') );
313 }
314
315 function mo_firebase_auth_feedback_request() {
316 mo_firebase_auth_display_feedback_form();
317 }
318
319 private function mo_firebase_authentication_check_empty_or_null( $value ) {
320 if( ! isset( $value ) || empty( $value ) ) {
321 return true;
322 }
323 return false;
324 }
325
326 function mo_firebase_auth_deactivate(){
327
328 if ( isset( $_POST['option'] ) ) {
329
330 if( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == "mo_firebase_authentication_change_email" ) {
331 //Adding back button
332 update_option('mo_firebase_authentication_verify_customer', '');
333 update_option('mo_firebase_authentication_registration_status','');
334 update_option('mo_firebase_authentication_new_registration','true');
335 }
336
337 if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == "change_miniorange" ) {
338 require_once plugin_dir_path( __FILE__ ) . 'includes/class-firebase-authentication-deactivator.php';
339 MO_Firebase_Authentication_Deactivator::deactivate();
340 return;
341 }
342
343 if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == "mo_firebase_authentication_register_customer" ) { //register the admin to miniOrange
344 //validation and sanitization
345 $email = '';
346 $phone = '';
347 $password = '';
348 $confirmPassword = '';
349 $fname = '';
350 $lname = '';
351 $company = '';
352 if ( $this->mo_firebase_authentication_check_empty_or_null( $_POST['email'] ) || $this->mo_firebase_authentication_check_empty_or_null( $_POST['password'] ) || $this->mo_firebase_authentication_check_empty_or_null( $_POST['confirmPassword'] ) ) {
353 update_option( 'mo_firebase_auth_message', 'All the fields are required. Please enter valid entries.');
354 $this->mo_firebase_auth_show_error_message();
355 return;
356 } else if ( strlen( $_POST['password'] ) < 8 || strlen( $_POST['confirmPassword'] ) < 8) {
357 update_option( 'mo_firebase_auth_message', 'Choose a password with minimum length 8.');
358 $this->mo_firebase_auth_show_error_message();
359 return;
360 } else {
361 $email = sanitize_email( $_POST['email'] );
362 $phone = stripslashes( $_POST['phone'] );
363 $password = stripslashes( $_POST['password'] );
364 $confirmPassword = stripslashes( $_POST['confirmPassword'] );
365 $fname = stripslashes( $_POST['fname'] );
366 $lname = stripslashes( $_POST['lname' ] );
367 $company = stripslashes( $_POST['company'] );
368 }
369
370 update_option( 'mo_firebase_authentication_admin_email', $email );
371 update_option( 'mo_firebase_authentication_admin_phone', $phone );
372 update_option( 'mo_firebase_authentication_admin_fname', $fname );
373 update_option( 'mo_firebase_authentication_admin_lname', $lname );
374 update_option( 'mo_firebase_authentication_admin_company', $company );
375
376 if ( strcmp( $password, $confirmPassword) == 0 ) {
377 update_option( 'password', $password );
378 $customer = new MO_Firebase_Customer();
379 $email = get_option('mo_firebase_authentication_admin_email');
380 $content = json_decode( $customer->check_customer(), true );
381
382 if ( strcasecmp( $content['status'], 'CUSTOMER_NOT_FOUND') == 0 ) {
383 $response = json_decode( $customer->create_customer(), true );
384 if ( strcasecmp( $response['status'], 'SUCCESS' ) != 0 ) {
385 update_option( 'mo_firebase_auth_message', 'Failed to create customer. Try again.' );
386 }
387 $this->mo_firebase_auth_show_success_message();
388 } elseif ( strcasecmp( $content['status'], 'SUCCESS' ) == 0 ) {
389 update_option( 'mo_firebase_auth_message', 'Account already exist. Please Login.' );
390 } else {
391 update_option( 'mo_firebase_auth_message', $content['status'] );
392 }
393 $this->mo_firebase_auth_show_success_message();
394
395 } else {
396 update_option( 'mo_firebase_auth_message', 'Passwords do not match.');
397 delete_option('mo_firebase_authentication_verify_customer');
398 $this->mo_firebase_auth_show_error_message();
399 }
400
401 } if( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == "mo_firebase_authentication_goto_login" && isset( $_REQUEST['mo_firebase_authentication_goto_login_form_field'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['mo_firebase_authentication_goto_login_form_field'] ) ), 'mo_firebase_authentication_goto_login_form' )) {
402 delete_option( 'mo_firebase_authentication_new_registration' );
403 update_option( 'mo_firebase_authentication_verify_customer', 'true' );
404
405 } if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == 'mo_enable_firebase_auth' && wp_verify_nonce( $_REQUEST['mo_firebase_auth_enable_field'], 'mo_firebase_auth_enable_form' ) ){
406 update_option( 'mo_enable_firebase_auth', isset( $_POST['mo_enable_firebase_auth'] ) ? (int)filter_var( $_POST['mo_enable_firebase_auth'], FILTER_SANITIZE_NUMBER_INT ) : 0 );
407
408 } else if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == 'mo_firebase_auth_contact_us' && isset($_REQUEST['mo_firebase_auth_contact_us_field']) && wp_verify_nonce( $_REQUEST['mo_firebase_auth_contact_us_field'], 'mo_firebase_auth_contact_us_form' ) ) {
409 $email = isset( $_POST['mo_firebase_auth_contact_us_email'] ) ? sanitize_email( $_POST['mo_firebase_auth_contact_us_email'] ) : "";
410 $phone = isset( $_POST['mo_firebase_auth_contact_us_phone'] ) ? "+ ".preg_replace( '/[^0-9]/', '', $_POST['mo_firebase_auth_contact_us_phone'] ) : "";
411 //$phone = sanitize_textarea_field($_POST['mo_firebase_auth_contact_us_phone']);
412 $query = isset( $_POST['mo_firebase_auth_contact_us_query'] ) ? sanitize_textarea_field( $_POST['mo_firebase_auth_contact_us_query'] ) : "";
413 if ( $this->mo_firebase_authentication_check_empty_or_null( $email ) || $this->mo_firebase_authentication_check_empty_or_null( $query ) ) {
414 echo '<br><b style=color:red>Please fill up Email and Query fields to submit your query.</b>';
415 } else {
416 $contact_us = new MO_Firebase_contact_us();
417 $submited = $contact_us->mo_firebase_auth_contact_us( $email, $phone, $query );
418 if ( $submited == false ) {
419 update_option( 'mo_firebase_auth_message', 'Your query could not be submitted. Please try again.' );
420 $this->mo_firebase_auth_show_error_message();
421 } else {
422 update_option( 'mo_firebase_auth_message', 'Thanks for getting in touch! We shall get back to you shortly.' );
423 $this->mo_firebase_auth_show_success_message();
424 }
425 }
426
427 } else if( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == "mo_firebase_authentication_verify_customer" ) {//register the admin to miniOrange
428 //validation and sanitization
429 $email = '';
430 $password = '';
431 if( $this->mo_firebase_authentication_check_empty_or_null( $_POST['email'] ) || $this->mo_firebase_authentication_check_empty_or_null( $_POST['password'] ) ) {
432 update_option( 'mo_firebase_auth_message', 'All the fields are required. Please enter valid entries.');
433 $this->mo_firebase_auth_show_error_message();
434 return;
435 } else{
436 $email = sanitize_email( $_POST['email'] );
437 $password = stripslashes( $_POST['password'] );
438 }
439
440 update_option( 'mo_firebase_authentication_admin_email', $email );
441 update_option( 'password', $password );
442 $customer = new MO_Firebase_Customer();
443 $content = $customer->mo_firebase_auth_get_customer_key();
444 $customerKey = json_decode( $content, true );
445 if( json_last_error() == JSON_ERROR_NONE ) {
446 update_option( 'mo_firebase_authentication_admin_customer_key', $customerKey['id'] );
447 update_option( 'mo_firebase_authentication_admin_api_key', $customerKey['apiKey'] );
448 update_option( 'mo_firebase_authentication_customer_token', $customerKey['token'] );
449 if( isset( $customerKey['phone'] ) )
450 update_option( 'mo_firebase_authentication_admin_phone', $customerKey['phone'] );
451 delete_option( 'password' );
452 update_option( 'mo_firebase_auth_message', 'Customer retrieved successfully');
453 delete_option( 'mo_firebase_authentication_verify_customer' );
454 $this->mo_firebase_auth_show_success_message();
455 } else {
456 update_option( 'mo_firebase_auth_message', 'Invalid username or password. Please try again.');
457 $this->mo_firebase_auth_show_error_message();
458 }
459
460 } else if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == 'mo_firebase_auth_skip_feedback' ) {
461 deactivate_plugins( __FILE__ );
462 update_option( 'mo_firebase_auth_message', 'Plugin deactivated successfully' );
463 $this->mo_firebase_auth_show_success_message();
464
465 } else if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == 'mo_firebase_auth_feedback' && isset($_REQUEST['mo_firebase_auth_feedback_field']) && wp_verify_nonce( $_REQUEST['mo_firebase_auth_feedback_field'], 'mo_firebase_auth_feedback_form' ) ) {
466 $user = wp_get_current_user();
467 $message = 'Plugin Deactivated:';
468 $deactivate_reason = array_key_exists( 'deactivate_reason_radio', $_POST ) ? $_POST['deactivate_reason_radio'] : false;
469 $deactivate_reason_message = array_key_exists( 'query_feedback', $_POST ) ? $_POST['query_feedback'] : false;
470 if ( $deactivate_reason ) {
471 $message .= $deactivate_reason;
472 if ( isset( $deactivate_reason_message ) ) {
473 $message .= ':' . $deactivate_reason_message;
474 }
475
476 $email = $user->user_email;
477 $contact_us = new MO_Firebase_contact_us();
478 $submited = json_decode( $contact_us->mo_firebase_auth_send_email_alert( $email, $message, "Feedback: WordPress Firebase Authentication" ), true );
479 deactivate_plugins( __FILE__ );
480 update_option( 'mo_firebase_auth_message', 'Thank you for the feedback.' );
481 $this->mo_firebase_auth_show_success_message();
482
483 } else {
484 update_option( 'mo_firebase_auth_message', 'Please Select one of the reasons ,if your reason is not mentioned please select Other Reasons' );
485 $this->mo_firebase_auth_show_error_message();
486 }
487 } else if ( sanitize_text_field( wp_unslash( $_POST['option'] ) ) == 'mo_fb_demo_request_form' && isset($_REQUEST['mo_fb_demo_request_field']) && wp_verify_nonce( $_REQUEST['mo_fb_demo_request_field'], 'mo_fb_demo_request_form' ) ) {
488
489 if( current_user_can( 'administrator' ) ){
490
491 $email = sanitize_email( $_POST['mo_fb_demo_request_email'] );
492 $demo_plan = isset($_POST['mo_fb_demo_request_plan']) ? stripslashes( $_POST['mo_fb_demo_request_plan'] ) : '';
493 $query = stripslashes( $_POST['mo_fb_demo_request_usecase'] );
494
495 if( $this->mo_firebase_authentication_check_empty_or_null( $email ) || $this->mo_firebase_authentication_check_empty_or_null( $demo_plan ) || $this->mo_firebase_authentication_check_empty_or_null( $query ) ){
496
497 update_option( 'mo_firebase_auth_message', 'Please fill up usecase, email field and select a demo plan to submit your query.' );
498 $this->mo_firebase_auth_show_error_message();
499 }else{
500 $contact_us = new MO_Firebase_contact_us();
501 $message = '<b>Demo plan:</b> '.$demo_plan.'<br><b>Use-case:</b> '.$query;
502 $submited = $contact_us->mo_firebase_auth_demo_request_mail( $email, $message, 'Demo Request | Firebase Authentication for WP' );
503 if ( $submited == false ) {
504 update_option( 'mo_firebase_auth_message', 'Your query could not be submitted. Please try again.' );
505 $this->mo_firebase_auth_show_error_message();
506 } else {
507 update_option( 'mo_firebase_auth_message', 'Thanks for getting in touch! We shall get back to you shortly.' );
508 $this->mo_firebase_auth_show_success_message();
509 }
510
511 }
512
513 }
514 }
515 }
516 }
517
518 }
519
520 $mo_firebase_authentication_obj = new mo_firebase_authentication_login();