PluginProbe ʕ •ᴥ•ʔ
Firebase Authentication / 1.7.0
Firebase Authentication v1.7.0
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 / class-mo-firebase-contact-us.php
firebase-authentication Last commit date
admin 1 day ago includes 1 day ago languages 1 day ago public 1 day ago views 1 day ago README.txt 1 day ago class-mo-firebase-config.php 1 day ago class-mo-firebase-contact-us.php 1 day ago firebase-authentication.php 1 day ago index.php 1 day ago uninstall.php 1 day ago
class-mo-firebase-contact-us.php
184 lines
1 <?php
2 /**
3 * Firebase Authentication Plugin Contact Us
4 *
5 * @package Firebase Authentication Contact Us
6 */
7
8 /**
9 * Handling the query form
10 *
11 * @copyright miniOrange
12 * @license PHP License 3.0
13 * @since Class available since Release
14 */
15 class MO_Firebase_Contact_Us {
16 /**
17 * Default customer key
18 *
19 * @var string
20 */
21 private $default_customer_key = '16555';
22 /**
23 * Default customer api key
24 *
25 * @var string
26 */
27 private $default_api_key = 'fFd2XcvTGDemZvbw1bcUesNJWEqKbbUq';
28
29 /**
30 * Function for processing contact us request
31 *
32 * @param string $email Email.
33 * @param string $phone phone.
34 * @param string $query query.
35 */
36 public function mo_firebase_auth_contact_us( $email, $phone, $query ) {
37 $current_user = wp_get_current_user();
38 $version = get_option( 'mo_firebase_authentication_current_plugin_version' );
39 $query = '[WP Firebase Authentication Plugin] ' . $version . ' - ' . $query;
40 $fields = array(
41 'firstName' => $current_user->user_firstname,
42 'lastName' => $current_user->user_lastname,
43 'company' => site_url(),
44 'email' => $email,
45 'ccEmail' => 'oauthsupport@xecurify.com',
46 'phone' => $phone,
47 'query' => $query,
48 );
49 $field_string = wp_json_encode( $fields );
50
51 $url = 'https://login.xecurify.com/moas/rest/customer/contact-us';
52
53 $headers = array(
54 'Content-Type' => 'application/json',
55 'charset' => 'UTF - 8',
56 'Authorization' => 'Basic',
57 );
58 $args = array(
59 'method' => 'POST',
60 'body' => $field_string,
61 'timeout' => '15',
62 'redirection' => '5',
63 'httpversion' => '1.0',
64 'blocking' => true,
65 'headers' => $headers,
66 );
67
68 $response = wp_remote_post( $url, $args );
69 if ( is_wp_error( $response ) ) {
70 $error_message = $response->get_error_message();
71 echo 'Something went wrong: ' . esc_attr( $error_message );
72 exit();
73 }
74
75 return true;
76 }
77
78 /**
79 * Function for processing feedback form
80 *
81 * @param string $email Email.
82 * @param string $message Message.
83 * @param string $subject Subject.
84 */
85 public function mo_firebase_auth_send_email_alert( $email, $message, $subject ) {
86
87 if ( ! $this->check_internet_connection() ) {
88 return;
89 }
90
91 $url = get_option( 'mo_fb_host_name' ) . '/moas/api/notify/send';
92 $customer_key = $this->default_customer_key;
93 $api_key = $this->default_api_key;
94 $current_time_in_millis = self::get_timestamp();
95 $string_to_hash = $customer_key . $current_time_in_millis . $api_key;
96 $hash_value = hash( 'sha512', $string_to_hash );
97 $from_email = $email;
98 $subject = 'Feedback: WP Firebase Authentication Plugin';
99 $site_url = site_url();
100
101 global $user;
102 $user = wp_get_current_user();
103 $query = '[WP Firebase Authentication] : ' . $message;
104
105 $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:' . $from_email . '" target="_blank">' . $from_email . '</a><br><br>Query :' . $query . '</div>';
106
107 $fields = array(
108 'customerKey' => $customer_key,
109 'sendEmail' => true,
110 'email' => array(
111 'customerKey' => $customer_key,
112 'fromEmail' => $from_email,
113 'bccEmail' => 'oauthsupport@xecurify.com',
114 'fromName' => 'miniOrange',
115 'toEmail' => 'oauthsupport@xecurify.com',
116 'toName' => 'oauthsupport@xecurify.com',
117 'subject' => $subject,
118 'content' => $content,
119 ),
120 );
121 $field_string = wp_json_encode( $fields );
122 $headers = array( 'Content-Type' => 'application/json' );
123 $headers['Customer-Key'] = $customer_key;
124 $headers['Timestamp'] = $current_time_in_millis;
125 $headers['Authorization'] = $hash_value;
126
127 $args = array(
128 'method' => 'POST',
129 'body' => $field_string,
130 'timeout' => '15',
131 'redirection' => '5',
132 'httpversion' => '1.0',
133 'blocking' => true,
134 'headers' => $headers,
135 );
136
137 $response = wp_remote_post( $url, $args );
138
139 if ( is_wp_error( $response ) ) {
140 $error_message = $response->get_error_message();
141 echo 'Something went wrong: ' . esc_attr( $error_message );
142 exit();
143 }
144 }
145
146 /**
147 * Function to check internet connection
148 */
149 public function check_internet_connection() {
150 return (bool) @fsockopen( 'login.xecurify.com', 443, $i_errno, $s_err_str, 5 ); //phpcs:ignore -- Ignoring AlternativeFunctions warning for file handling functions.
151 }
152
153 /**
154 * Function to get current timestamp
155 */
156 public function get_timestamp() {
157 $url = get_option( 'mo_fb_host_name' ) . '/moas/rest/mobile/get-timestamp';
158 $headers = array(
159 'Content-Type' => 'application/json',
160 'charset' => 'UTF - 8',
161 'Authorization' => 'Basic',
162 );
163 $args = array(
164 'method' => 'POST',
165 'body' => array(),
166 'timeout' => '5',
167 'redirection' => '5',
168 'httpversion' => '1.0',
169 'blocking' => true,
170 'headers' => $headers,
171 );
172
173 $response = wp_remote_post( $url, $args );
174 if ( is_wp_error( $response ) ) {
175 $error_message = $response->get_error_message();
176 echo 'Something went wrong: ' . esc_attr( $error_message );
177 exit();
178 }
179
180 return wp_remote_retrieve_body( $response );
181 }
182 }
183
184