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
class-contact-us.php
199 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 | $version = get_option("mo_firebase_authentication_current_plugin_version"); |
| 10 | $query = '[WP Firebase Authentication Plugin] ' . $version . " - " . $query; |
| 11 | $fields = array( |
| 12 | 'firstName' => $current_user->user_firstname, |
| 13 | 'lastName' => $current_user->user_lastname, |
| 14 | 'company' => site_url(), |
| 15 | 'email' => $email, |
| 16 | 'ccEmail' => 'oauthsupport@xecurify.com', |
| 17 | 'phone' => $phone, |
| 18 | 'query' => $query |
| 19 | ); |
| 20 | $field_string = json_encode( $fields ); |
| 21 | |
| 22 | $url = 'https://login.xecurify.com/moas/rest/customer/contact-us'; |
| 23 | |
| 24 | $headers = array( |
| 25 | 'Content-Type' => 'application/json', |
| 26 | 'charset' => 'UTF - 8', |
| 27 | 'Authorization' => 'Basic' |
| 28 | ); |
| 29 | $args = array( |
| 30 | 'method' =>'POST', |
| 31 | 'body' => $field_string, |
| 32 | 'timeout' => '15', |
| 33 | 'redirection' => '5', |
| 34 | 'httpversion' => '1.0', |
| 35 | 'blocking' => true, |
| 36 | 'headers' => $headers, |
| 37 | ); |
| 38 | |
| 39 | $response = wp_remote_post( $url, $args ); |
| 40 | if ( is_wp_error( $response ) ) { |
| 41 | $error_message = $response->get_error_message(); |
| 42 | echo "Something went wrong: $error_message"; |
| 43 | exit(); |
| 44 | } |
| 45 | |
| 46 | return true; |
| 47 | } |
| 48 | |
| 49 | function mo_firebase_auth_demo_request_mail( $email, $message, $subject ) { |
| 50 | |
| 51 | if( ! $this->check_internet_connection() ) |
| 52 | return; |
| 53 | |
| 54 | $url = get_option( 'host_name' ) . '/moas/api/notify/send'; |
| 55 | $customerKey = $this->defaultCustomerKey; |
| 56 | $apiKey = $this->defaultApiKey; |
| 57 | $currentTimeInMillis = self::get_timestamp(); |
| 58 | $stringToHash = $customerKey . $currentTimeInMillis . $apiKey; |
| 59 | $hashValue = hash("sha512", $stringToHash); |
| 60 | $customerKeyHeader = "Customer-Key: " . $customerKey; |
| 61 | $timestampHeader = "Timestamp: " . $currentTimeInMillis; |
| 62 | $authorizationHeader = "Authorization: " . $hashValue; |
| 63 | $fromEmail = $email; |
| 64 | |
| 65 | global $user; |
| 66 | $user = wp_get_current_user(); |
| 67 | |
| 68 | $content = '<div >Hello, <br><br><b>Customer</b>: <a href="mailto:'.$fromEmail.'" target="_blank">'.$fromEmail.'</a><br>'.$message.'<br><br>Thanks<br>miniOrange Inc</div>'; |
| 69 | |
| 70 | $fields = array( |
| 71 | 'customerKey' => $customerKey, |
| 72 | 'sendEmail' => true, |
| 73 | 'email' => array( |
| 74 | 'customerKey' => $customerKey, |
| 75 | 'fromEmail' => $fromEmail, |
| 76 | 'bccEmail' => 'oauthsupport@xecurify.com', |
| 77 | 'fromName' => 'miniOrange', |
| 78 | 'toEmail' => 'oauthsupport@xecurify.com', |
| 79 | 'toName' => 'oauthsupport@xecurify.com', |
| 80 | 'subject' => $subject, |
| 81 | 'content' => $content |
| 82 | ), |
| 83 | ); |
| 84 | $field_string = json_encode($fields); |
| 85 | $headers = array( 'Content-Type' => 'application/json'); |
| 86 | $headers['Customer-Key'] = $customerKey; |
| 87 | $headers['Timestamp'] = $currentTimeInMillis; |
| 88 | $headers['Authorization'] = $hashValue; |
| 89 | |
| 90 | $args = array( |
| 91 | 'method' =>'POST', |
| 92 | 'body' => $field_string, |
| 93 | 'timeout' => '15', |
| 94 | 'redirection' => '5', |
| 95 | 'httpversion' => '1.0', |
| 96 | 'blocking' => true, |
| 97 | 'headers' => $headers, |
| 98 | ); |
| 99 | |
| 100 | $response = wp_remote_post( $url, $args ); |
| 101 | |
| 102 | if ( is_wp_error( $response ) ) { |
| 103 | $error_message = $response->get_error_message(); |
| 104 | return false; |
| 105 | } |
| 106 | return true; |
| 107 | } |
| 108 | |
| 109 | function mo_firebase_auth_send_email_alert( $email, $message, $subject ) { |
| 110 | |
| 111 | if( ! $this->check_internet_connection() ) |
| 112 | return; |
| 113 | |
| 114 | $url = get_option( 'host_name' ) . '/moas/api/notify/send'; |
| 115 | $customerKey = $this->defaultCustomerKey; |
| 116 | $apiKey = $this->defaultApiKey; |
| 117 | $currentTimeInMillis = self::get_timestamp(); |
| 118 | $stringToHash = $customerKey . $currentTimeInMillis . $apiKey; |
| 119 | $hashValue = hash("sha512", $stringToHash); |
| 120 | $customerKeyHeader = "Customer-Key: " . $customerKey; |
| 121 | $timestampHeader = "Timestamp: " . $currentTimeInMillis; |
| 122 | $authorizationHeader = "Authorization: " . $hashValue; |
| 123 | $fromEmail = $email; |
| 124 | $subject = "Feedback: WP Firebase Authentication Plugin"; |
| 125 | $site_url = site_url(); |
| 126 | |
| 127 | global $user; |
| 128 | $user = wp_get_current_user(); |
| 129 | $query = '[WP Firebase Authentication] : ' . $message; |
| 130 | |
| 131 | $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>'; |
| 132 | |
| 133 | $fields = array( |
| 134 | 'customerKey' => $customerKey, |
| 135 | 'sendEmail' => true, |
| 136 | 'email' => array( |
| 137 | 'customerKey' => $customerKey, |
| 138 | 'fromEmail' => $fromEmail, |
| 139 | 'bccEmail' => 'oauthsupport@xecurify.com', |
| 140 | 'fromName' => 'miniOrange', |
| 141 | 'toEmail' => 'oauthsupport@xecurify.com', |
| 142 | 'toName' => 'oauthsupport@xecurify.com', |
| 143 | 'subject' => $subject, |
| 144 | 'content' => $content |
| 145 | ), |
| 146 | ); |
| 147 | $field_string = json_encode($fields); |
| 148 | $headers = array( 'Content-Type' => 'application/json'); |
| 149 | $headers['Customer-Key'] = $customerKey; |
| 150 | $headers['Timestamp'] = $currentTimeInMillis; |
| 151 | $headers['Authorization'] = $hashValue; |
| 152 | |
| 153 | $args = array( |
| 154 | 'method' =>'POST', |
| 155 | 'body' => $field_string, |
| 156 | 'timeout' => '15', |
| 157 | 'redirection' => '5', |
| 158 | 'httpversion' => '1.0', |
| 159 | 'blocking' => true, |
| 160 | 'headers' => $headers, |
| 161 | ); |
| 162 | |
| 163 | $response = wp_remote_post( $url, $args ); |
| 164 | |
| 165 | if ( is_wp_error( $response ) ) { |
| 166 | $error_message = $response->get_error_message(); |
| 167 | echo "Something went wrong: $error_message"; |
| 168 | exit(); |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | function check_internet_connection() { |
| 173 | return (bool) @fsockopen('login.xecurify.com', 443, $iErrno, $sErrStr, 5); |
| 174 | } |
| 175 | |
| 176 | public function get_timestamp() { |
| 177 | $url = get_option ( 'host_name' ) . '/moas/rest/mobile/get-timestamp'; |
| 178 | $headers = array( 'Content-Type' => 'application/json', 'charset' => 'UTF - 8', 'Authorization' => 'Basic' ); |
| 179 | $args = array( |
| 180 | 'method' =>'POST', |
| 181 | 'body' => array(), |
| 182 | 'timeout' => '5', |
| 183 | 'redirection' => '5', |
| 184 | 'httpversion' => '1.0', |
| 185 | 'blocking' => true, |
| 186 | 'headers' => $headers, |
| 187 | ); |
| 188 | |
| 189 | $response = wp_remote_post( $url, $args ); |
| 190 | if ( is_wp_error( $response ) ) { |
| 191 | $error_message = $response->get_error_message(); |
| 192 | echo "Something went wrong: $error_message"; |
| 193 | exit(); |
| 194 | } |
| 195 | |
| 196 | return wp_remote_retrieve_body($response); |
| 197 | } |
| 198 | } |
| 199 | ?> |