firebase-authentication
Last commit date
admin
6 years ago
includes
6 years ago
js
6 years ago
languages
6 years ago
public
6 years ago
views
6 years ago
LICENSE.txt
6 years ago
README.txt
6 years ago
class-contact-us.php
6 years ago
class-mo-firebase-config.php
6 years ago
firebase-authentication.php
6 years ago
index.php
6 years ago
uninstall.php
6 years ago
class-contact-us.php
137 lines
| 1 | <?php |
| 2 | class MO_Firebase_contact_us{ |
| 3 | private $defaultCustomerKey = "16555"; |
| 4 | private $defaultApiKey = "fFd2XcvTGDemZvbw1bcUesNJWEqKbbUq"; |
| 5 | |
| 6 | function mo_firebase_auth_contact_us( $email, $phone, $query ) { |
| 7 | global $current_user; |
| 8 | wp_get_current_user(); |
| 9 | $query = '[WP Firebase Authentication Plugin] ' . $query; |
| 10 | $fields = array( |
| 11 | 'firstName' => $current_user->user_firstname, |
| 12 | 'lastName' => $current_user->user_lastname, |
| 13 | 'company' => site_url(), |
| 14 | 'email' => $email, |
| 15 | 'ccEmail' => 'oauthsupport@xecurify.com', |
| 16 | 'phone' => $phone, |
| 17 | 'query' => $query |
| 18 | ); |
| 19 | $field_string = json_encode( $fields ); |
| 20 | |
| 21 | $url = 'https://login.xecurify.com/moas/rest/customer/contact-us'; |
| 22 | |
| 23 | $headers = array( |
| 24 | 'Content-Type' => 'application/json', |
| 25 | 'charset' => 'UTF - 8', |
| 26 | 'Authorization' => 'Basic' |
| 27 | ); |
| 28 | $args = array( |
| 29 | 'method' =>'POST', |
| 30 | 'body' => $field_string, |
| 31 | 'timeout' => '5', |
| 32 | 'redirection' => '5', |
| 33 | 'httpversion' => '1.0', |
| 34 | 'blocking' => true, |
| 35 | 'headers' => $headers, |
| 36 | ); |
| 37 | |
| 38 | $response = wp_remote_post( $url, $args ); |
| 39 | if ( is_wp_error( $response ) ) { |
| 40 | $error_message = $response->get_error_message(); |
| 41 | echo "Something went wrong: $error_message"; |
| 42 | exit(); |
| 43 | } |
| 44 | |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | function mo_firebase_auth_send_email_alert( $email, $message, $subject ) { |
| 49 | |
| 50 | if( ! $this->check_internet_connection() ) |
| 51 | return; |
| 52 | |
| 53 | $url = get_option( 'host_name' ) . '/moas/api/notify/send'; |
| 54 | $customerKey = $this->defaultCustomerKey; |
| 55 | $apiKey = $this->defaultApiKey; |
| 56 | $currentTimeInMillis = self::get_timestamp(); |
| 57 | $stringToHash = $customerKey . $currentTimeInMillis . $apiKey; |
| 58 | $hashValue = hash("sha512", $stringToHash); |
| 59 | $customerKeyHeader = "Customer-Key: " . $customerKey; |
| 60 | $timestampHeader = "Timestamp: " . $currentTimeInMillis; |
| 61 | $authorizationHeader = "Authorization: " . $hashValue; |
| 62 | $fromEmail = $email; |
| 63 | $subject = "Feedback: WP Firebase Authentication Plugin"; |
| 64 | $site_url = site_url(); |
| 65 | |
| 66 | global $user; |
| 67 | $user = wp_get_current_user(); |
| 68 | $query = '[WP Firebase Authentication] : ' . $message; |
| 69 | |
| 70 | $content = '<div >Hello, <br><br>First Name :'.$user->user_firstname.'<br><br>Last Name :'.$user->user_lastname.' <br><br>Company :<a href="'.$site_url.'" target="_blank" >'.$site_url.'</a><br><br>Email :<a href="mailto:'.$fromEmail.'" target="_blank">'.$fromEmail.'</a><br><br>Query :'.$query.'</div>'; |
| 71 | |
| 72 | $fields = array( |
| 73 | 'customerKey' => $customerKey, |
| 74 | 'sendEmail' => true, |
| 75 | 'email' => array( |
| 76 | 'customerKey' => $customerKey, |
| 77 | 'fromEmail' => $fromEmail, |
| 78 | 'bccEmail' => 'oauthsupport@xecurify.com', |
| 79 | 'fromName' => 'miniOrange', |
| 80 | 'toEmail' => 'oauthsupport@xecurify.com', |
| 81 | 'toName' => 'oauthsupport@xecurify.com', |
| 82 | 'subject' => $subject, |
| 83 | 'content' => $content |
| 84 | ), |
| 85 | ); |
| 86 | $field_string = json_encode($fields); |
| 87 | $headers = array( 'Content-Type' => 'application/json'); |
| 88 | $headers['Customer-Key'] = $customerKey; |
| 89 | $headers['Timestamp'] = $currentTimeInMillis; |
| 90 | $headers['Authorization'] = $hashValue; |
| 91 | |
| 92 | $args = array( |
| 93 | 'method' =>'POST', |
| 94 | 'body' => $field_string, |
| 95 | 'timeout' => '5', |
| 96 | 'redirection' => '5', |
| 97 | 'httpversion' => '1.0', |
| 98 | 'blocking' => true, |
| 99 | 'headers' => $headers, |
| 100 | ); |
| 101 | |
| 102 | $response = wp_remote_post( $url, $args ); |
| 103 | |
| 104 | if ( is_wp_error( $response ) ) { |
| 105 | $error_message = $response->get_error_message(); |
| 106 | echo "Something went wrong: $error_message"; |
| 107 | exit(); |
| 108 | } |
| 109 | } |
| 110 | function check_internet_connection() { |
| 111 | return (bool) @fsockopen('login.xecurify.com', 443, $iErrno, $sErrStr, 5); |
| 112 | } |
| 113 | |
| 114 | public function get_timestamp() { |
| 115 | $url = get_option ( 'host_name' ) . '/moas/rest/mobile/get-timestamp'; |
| 116 | $headers = array( 'Content-Type' => 'application/json', 'charset' => 'UTF - 8', 'Authorization' => 'Basic' ); |
| 117 | $args = array( |
| 118 | 'method' =>'POST', |
| 119 | 'body' => array(), |
| 120 | 'timeout' => '5', |
| 121 | 'redirection' => '5', |
| 122 | 'httpversion' => '1.0', |
| 123 | 'blocking' => true, |
| 124 | 'headers' => $headers, |
| 125 | ); |
| 126 | |
| 127 | $response = wp_remote_post( $url, $args ); |
| 128 | if ( is_wp_error( $response ) ) { |
| 129 | $error_message = $response->get_error_message(); |
| 130 | echo "Something went wrong: $error_message"; |
| 131 | exit(); |
| 132 | } |
| 133 | |
| 134 | return wp_remote_retrieve_body($response); |
| 135 | } |
| 136 | } |
| 137 | ?> |