PluginProbe
Pie Register – User Registration, Profiles & Content Restriction / trunk
Pie Register – User Registration, Profiles & Content Restriction vtrunk
3.8.4.12 3.8.4.11 3.7.4.2 3.7.4.3 3.7.4.4 3.7.4.5 3.7.4.6 3.7.5 3.7.5.1 3.8 3.8.0.1 3.8.0.2 3.8.1 3.8.1.1 3.8.1.2 3.8.1.3 3.8.1.4 3.8.2 3.8.2.1 3.8.2.2 3.8.2.3 3.8.2.4 3.8.2.5 3.8.2.6 3.8.2.7 All 178 releases
pie-register / pie-register.php

pie-register.php in Pie Register – User Registration, Profiles & Content Restriction trunk, at pie-register.php

7,995 lines 370.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Pie Register - Basic
4 Plugin URI: https://pieregister.com/
5 Description: Create custom user registration forms, drag & drop form builder, send invitation codes, add conditional logic, 2-step authentication, assign user roles, accept payments and more!
6 Version: 3.8.4.12
7 Author: Pie Register
8 Author URI: https://pieregister.com/
9 Text Domain: pie-register
10 Domain Path: /languages
11 License: GPL-2.0-or-later
12 License URI: https://www.gnu.org/licenses/gpl-2.0.html
13 */
14
15 if (! defined('ABSPATH')) {
16 echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
17 exit;
18 }
19
20 /*
21 * Get Pie Register Dir Name
22 */
23 $piereg_dir_path = dirname(__FILE__);
24
25 // Plugin Folder Path.
26 if (!defined("PIEREG_DIR_NAME")) {
27 define("PIEREG_DIR_NAME", $piereg_dir_path);
28 }
29
30 // Plugin Folder URL.
31 if (! defined('PIEREG_PLUGIN_URL')) {
32 define('PIEREG_PLUGIN_URL', plugin_dir_url(__FILE__));
33 }
34
35 /*
36 * Include PR Files
37 */
38
39 require_once(PIEREG_DIR_NAME . '/classes/base.php');
40 require_once(PIEREG_DIR_NAME . '/classes/profile_admin.php');
41 require_once(PIEREG_DIR_NAME . '/classes/profile_front.php');
42 require_once(PIEREG_DIR_NAME . '/classes/registration_form.php');
43 require_once(PIEREG_DIR_NAME . '/classes/edit_form.php');
44 require_once(PIEREG_DIR_NAME . '/widget.php');
45 require_once(PIEREG_DIR_NAME . '/dash_widget.php');
46 require_once(PIEREG_DIR_NAME . '/piereg_walker-nav-menu.php');
47
48 /**
49 * Include PR App Services files
50 * Since 3.5
51 */
52
53 if (file_exists(PIEREG_DIR_NAME . '/classes/app/app_api.php')) require_once(PIEREG_DIR_NAME . '/classes/app/app_api.php');
54 if (file_exists(PIEREG_DIR_NAME . '/classes/app/firebase.php')) require_once(PIEREG_DIR_NAME . '/classes/app/firebase.php');
55 if (file_exists(PIEREG_DIR_NAME . '/classes/app/push.php')) require_once(PIEREG_DIR_NAME . '/classes/app/push.php');
56
57 /*
58 Move PR DB Version Name to PieRegisterBaseVariables
59 */
60 if (!function_exists("pr_licenseKey_errors")) {
61 function pr_licenseKey_errors()
62 {
63 do_action("pr_licenseKey_errors");
64 }
65 }
66
67 /**
68 * Include PR Activation Page File
69 * Since 3.8.0.3
70 */
71 if (file_exists(PIEREG_DIR_NAME . '/classes/welcome.php')) require_once(PIEREG_DIR_NAME . '/classes/welcome.php');
72
73
74 global $pie_success, $pie_error, $pie_error_msg, $pie_suucess_msg, $pagenow, $action, $profile, $errors, $piereg_math_captcha_register, $piereg_math_captcha_register_widget, $piereg_math_captcha_login, $piereg_math_captcha_login_widget, $piereg_math_captcha_forgot_pass, $piereg_math_captcha_forgot_pass_widget;
75
76 $piereg_math_captcha_register = false;
77 $piereg_math_captcha_register_widget = false;
78 $piereg_math_captcha_login = false;
79 $piereg_math_captcha_login_widget = false;
80 $piereg_math_captcha_forgot_pass = false;
81 $piereg_math_captcha_forgot_pass_widget = false;
82
83 register_activation_hook(__FILE__, 'checkPieRegisterPremiumVersion');
84
85 //Action to Perform when activating
86 function checkPieRegisterPremiumVersion()
87 {
88 if (is_plugin_active('pie-register-premium/pie-register-premium.php')) {
89 // Deactivate Premium Version
90 deactivate_plugins('pie-register-premium/pie-register-premium.php');
91 }
92
93 add_option('piereg_activated_time', time(), '', false);
94 }
95
96 if (!class_exists('PieRegister')) {
97 class PieRegister extends PieReg_Base
98 {
99 var $pie_success, $pie_error, $pie_error_msg, $pie_success_msg, $txn_id, $ipn_log, $ipn_data, $piereg_forms_per_page = array(), $postvars, $pie_pr_dec_vars_array, $pie_pr_backend_dec_vars_array, $pie_ua_renew_account_url, $pie_is_social_renew_account_call, $pie_payment_methods_dat, $pie_after_login_page_redirect_url, $is_pr_preview;
100 private $ipn_status, $ipn_debug, $post_block_content, $ipn_response = array(), $piereg_jquery_enable = false;
101
102 function __construct()
103 {
104 global $pagenow, $wp_version, $profile;
105
106 /////
107 $this->is_pr_preview = false;
108 $this->pie_pr_dec_vars_array = false;
109 $this->pie_pr_backend_dec_vars_array = false;
110 $this->pie_ua_renew_account_url = false;
111 $this->pie_is_social_renew_account_call = false;
112 $this->pie_after_login_page_redirect_url = false;
113
114 ///////////////////
115 $this->pie_payment_methods_dat = apply_filters('add_select_payment_script_', $this->pie_payment_methods_dat);
116 ///////////////////
117 $this->ipn_status = '';
118 $this->txn_id = null;
119 $this->ipn_log = true;
120 $this->ipn_response = '';
121 $this->ipn_debug = false;
122 //self::$pieinstance = $this;
123 /***********************/
124 parent::__construct();
125
126 $this->pieActions();
127 $this->pieFilters();
128 $errors = new WP_Error();
129
130 /*
131 * API Classes
132 */
133
134 if (is_admin() && ((isset($_POST['piereg_license_key']) && !empty($_POST['piereg_license_key'])) || (isset($_POST['piereg_pro_not_activated'])))) {
135 $plugin_name = untrailingslashit(plugin_basename(__FILE__)); // same as plugin slug. if a theme use a theme name like 'twentyeleven'
136 /*if
137 (post || has)*/
138 // Performs activations and deactivations of API license Keys
139 if (file_exists(PIEREG_DIR_NAME . '/classes/api/class-wc-key-api.php'))
140 require_once(PIEREG_DIR_NAME . '/classes/api/class-wc-key-api.php');
141 // Checks for software updatess
142 if (file_exists(PIEREG_DIR_NAME . '/classes/api/class-wc-plugin-update.php'))
143 require_once(PIEREG_DIR_NAME . '/classes/api/class-wc-plugin-update.php');
144 // Admin menu with the license key and license email form
145 if (file_exists(PIEREG_DIR_NAME . '/classes/api/class-wc-api-manager-menu.php'))
146 require_once(PIEREG_DIR_NAME . '/classes/api/class-wc-api-manager-menu.php');
147
148 /* Load update class to update $this plugin
149 ** This function is not using since version 3.3.0. It was previously using for premium plugin.
150 ** Function in base.php removed. Below line will also soon remove from upcoming version.
151 ** 27-08-2021
152 */
153 # $this->load_plugin_self_updater($plugin_name); // Temporary disable license checker.
154 }
155
156 //Download or View Log file
157 $this->pr_logfile_download_or_view();
158 }
159
160 function pie_main()
161 {
162 global $piereg_global_options, $pagenow;
163 $option = $piereg_global_options;
164
165 //LOCALIZATION
166 #Place your language file in the plugin folder and name it "pie-register-{language}.mo"
167 #replace {language} with your language value from wp-config.php
168 //load_textdomain( 'pie-register', ABS_PATH_TO_MO_FILE ); // OK
169
170 #$locale = ( get_locale() != '' ) ? get_locale() : 'en_US';
171 #load_textdomain( 'pie-register', WP_LANG_DIR . '/plugins/' . 'pie-register' . '-' . $locale . '.mo');
172 load_plugin_textdomain('pie-register', false, dirname(plugin_basename(__FILE__)) . '/languages/');
173
174
175 $pie_plugin_data = get_plugin_data(__FILE__);
176 $pie_plugin_version = $pie_plugin_data['Version'];
177 if (!get_option('pie_countries_v3811') && $pie_plugin_version >= "3.8.1.1") {
178 $this->updated_countries_list();
179 }
180
181 $pie_plugin_db_version = get_option('piereg_plugin_db_version');
182 if ($pie_plugin_db_version != PIEREG_DB_VERSION) {
183 $this->install_settings();
184 }
185
186 /*
187 * Define PR Version
188 */
189 if (! defined('PIEREGISTER_VERSION')) {
190 define('PIEREGISTER_VERSION', $pie_plugin_version);
191 }
192
193 $_changed_un_email_template = get_option('pie_email_template_updated_blocked_unverified_users');
194 if (!$_changed_un_email_template) {
195 $this->update_email_template_unverified_grace();
196 }
197
198 // :added elementor-preview - Fixing elementor loading issue with PR forms //
199 $this->is_pr_preview = (isset($_GET['pr_preview']) || isset($_GET['elementor-preview']) || isset($_GET['et_fb']) || (isset($_GET['preview']) && $_GET['preview'] == "true") || (isset($_GET['action']) && $_GET['action'] == 'elementor') || (isset($_GET['ct_builder']) && $_GET['ct_builder'] == 'true')) ? true : false;
200
201 // :added DIVI-preview - Fixing DIVI loading issue with PR forms //
202 $this->is_pr_preview = (isset($_GET['et_pb_preview'])) ? true : $this->is_pr_preview;
203
204 if (!function_exists('wp_get_current_user')) {
205 include_once(ABSPATH . WPINC . "/pluggable.php");
206 }
207
208 # Change User Avatar With Pie Profile Picture, If Used:
209 add_filter('get_avatar', array($this, 'pie_user_avatar'), 1, 5);
210 if (!is_admin() && (is_user_logged_in() && !current_user_can('piereg_manage_cap'))) {
211 //add_filter( 'get_avatar' , array($this,'pie_user_avatar') , 1 , 5 );
212 }
213
214 if (is_admin() && current_user_can('manage_options')) {
215 add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1000);
216 add_action('in_admin_header', array($this, 'piereg_admin_header'), 1000);
217
218 # Delete Unverified Users Over Grace Period
219 $this->deleteUnverifiedUsers();
220
221 #Assign pie register's all custom capabilities to administrator (default).
222 do_action('piereg_add_custom_cap', array('piereg_manage_cap'));
223 }
224
225 if (file_exists(PIEREG_DIR_NAME . "/editors/elementor/Elementor.php"))
226 require_once(PIEREG_DIR_NAME . "/editors/elementor/Elementor.php");
227
228 do_action('pieregister_elementor');
229
230 if (file_exists(PIEREG_DIR_NAME . "/editors/divi/Divi.php"))
231 require_once(PIEREG_DIR_NAME . "/editors/divi/Divi.php");
232
233 do_action('pieregister_divi');
234
235 add_action('wp_ajax_pie_rated', array($this, 'pieregister_rated'));
236 //add_filter( 'wp_privacy_personal_data_exporters', array($this, 'register_my_plugin_exporter'), 10);
237
238 if (current_user_can('piereg_manage_cap') && $this->show_notice_premium_users) {
239 #Pro Version Release notices
240 add_action('admin_notices', array($this, 'pie_free_notice_to_premium_users'), 1);
241 }
242
243 add_action('admin_notices', array($this, 'pie_promo_notice_security'), 1);
244 add_action('admin_notices_specific_pages', array($this, 'pie_premium_features_notice_for_free'), 1);
245
246 add_action('admin_notices', array($this, 'pie_leave_a_review_request'), 1);
247
248 add_action('piereg_notice_in_header', array($this, 'pie_gopro_notice'), 1);
249
250 # // license_expiry
251 add_action('admin_notices', array($this, 'pie_license_expire_msg'), 1);
252 add_action('wp_ajax_dismiss_pie_license_expire_msg', array($this, 'dismiss_pie_license_expire_msg'));
253
254 # // Enable Registration Notice - "Anyone Can Register"
255 add_action('admin_notices', array($this, 'pie_enable_registration_msg'), 1);
256
257 if (is_plugin_active('woocommerce/woocommerce.php') && !is_plugin_active('pie-register-woocommerce/pie-register-woocommerce.php')) {
258 add_action('admin_notices', array($this, 'pie_promo_notice_for_wc_user'), 1);
259 }
260 if (is_plugin_active('mailchimp-for-wp/mailchimp-for-wp.php') && !is_plugin_active('pie-register-mailchimp/pie-register-mailchimp.php')) {
261 add_action('admin_notices', array($this, 'pie_promo_notice_for_mc_user'), 1);
262 }
263 if (is_plugin_active('bbpress/bbpress.php') && !is_plugin_active('pie-register-bbpress/pie-register-bbpress.php')) {
264 add_action('admin_notices', array($this, 'pie_promo_notice_for_bb_user'), 1);
265 }
266 $all_plugins = get_plugins();
267
268 if (is_plugin_active('js_composer/js_composer.php') && (!array_key_exists('vc-addons-by-bit14/bit14-vc-addons.php', $all_plugins) && !array_key_exists('page-builder-addons-premium/bit14-addons.php', $all_plugins))) {
269 add_action('admin_notices', array($this, 'pie_promo_notice_for_wpb_user'), 1);
270 }
271
272 add_action('wp_ajax_dismiss_pie_promo_notice_security', array($this, 'dismiss_pie_promo_notice_security'));
273 add_action('wp_ajax_dismiss_pie_promo_notice_for_wc_user', array($this, 'dismiss_pie_promo_notice_for_wc_user'));
274 add_action('wp_ajax_dismiss_pie_promo_notice_for_mc_user', array($this, 'dismiss_pie_promo_notice_for_mc_user'));
275 add_action('wp_ajax_dismiss_pie_promo_notice_for_bb_user', array($this, 'dismiss_pie_promo_notice_for_bb_user'));
276 add_action('wp_ajax_dismiss_pie_promo_notice_for_wpb_user', array($this, 'dismiss_pie_promo_notice_for_wpb_user'));
277 add_action('wp_ajax_dismiss_pie_premium_features_notice_for_free', array($this, 'dismiss_pie_premium_features_notice_for_free'));
278 add_action('wp_ajax_dismiss_pie_leave_a_review_request', array($this, 'dismiss_pie_leave_a_review_request'));
279 add_action('wp_ajax_dismiss_pie_free_notice_to_premium_users', array($this, 'dismiss_pie_free_notice_to_premium_users'));
280
281 /*********************************************/
282 /////////////// PIEREG LOGOUT ////////////////
283 if (isset($_GET['piereg_logout_url']) && $_GET['piereg_logout_url'] == "true") {
284 $after_logout_page = (intval($option['alternate_logout']) <= 0) ? home_url() : $this->get_page_uri($option['alternate_logout']);
285 $redirect_to = (isset($_GET['redirect_to']) && !empty($_GET['redirect_to'])) ? esc_url_raw(urldecode($_GET['redirect_to'])) : $after_logout_page;
286
287 if (!isset($_GET['_logout_nonce'])) {
288 $_GET['_logout_nonce'] = wp_create_nonce('pie-log-out');
289 }
290
291 if (is_user_logged_in() && (isset($_GET['_logout_nonce']) && wp_verify_nonce($_GET['_logout_nonce'], 'pie-log-out'))) {
292 wp_logout();
293 wp_safe_redirect(esc_url_raw($redirect_to));
294 exit;
295 }
296 }
297
298 /*********************************************/
299
300 /////////// Register Scripts ////////////
301 $this->piereg_register_scripts();
302 ////////////////////////////////////////
303
304 // check to prevent php "notice: undefined index" msg
305 $theaction = '';
306 if (isset($_GET['action']))
307 $theaction = sanitize_text_field($_GET['action']);
308
309 if ((isset($_GET['show_dash_widget']) && $_GET['show_dash_widget'] == 1) and (isset($_GET['invitaion_code']) && $_GET['invitaion_code'] != "")) {
310 $this->show_invitaion_code_user();
311 }
312
313 # PAYPAL VALIDATION
314 $this->ValidPUser();
315
316 # Save Settings
317 if (isset($_POST['action']) && $_POST['action'] == 'pie_reg_update') {
318 $this->SaveSettings();
319 }
320
321 if (isset($_POST['action']) && $_POST['action'] == 'pie_reg_settings') {
322 $this->PieRegSettingsProcess();
323 }
324 // task av
325 # Admin verifying user through email
326 if (isset($_GET['action']) && $_GET['action'] == 'unverified_user') {
327 add_action('wp_body_open', array($this, 'process_verify_user_email'));
328 }
329
330 #Reset Settings to default
331 if (isset($_POST['piereg_default_settings'])) {
332 $this->piereg_default_settings();
333 }
334
335 #Admin Verify Users
336 if (isset($_POST['verifyit']))
337 $this->verifyUsers();
338
339 #Admin Send Payment Link
340 if (isset($_POST['paymentl']))
341 $this->PaymentLink();
342
343 #Admin Resend VerificatioN Email
344 if (isset($_POST['emailverifyit']))
345 $this->AdminEmailValidate();
346
347 #Admin Delete Unverified User
348 if (isset($_POST['vdeleteit']))
349 $this->AdminDeleteUnvalidated();
350
351 /*
352 * Add since 2.0.13
353 * Change email after verify
354 */
355 $this->edit_email_verification();
356 /* End */
357
358 // Payment Log File Download & Delete
359 $this->piereg_payment_log_file_action();
360
361 //Blocking wp admin for registered users
362 if (
363 ($pagenow == 'wp-login.php' && $option['block_wp_login'] == 1) &&
364 ($option['alternate_login'] && $theaction != 'logout') &&
365 (!isset($_REQUEST['interim-login']))
366 ) {
367
368 if (force_ssl_admin() && ! is_ssl()) {
369 $is_ssl = true;
370 } else {
371 $is_ssl = false;
372 }
373
374 if ($theaction == "register") {
375 if ($is_ssl) {
376 wp_safe_redirect(preg_replace('|^http://|', 'https://', $this->get_redirect_url_pie(get_permalink($option['alternate_register']))));
377 exit;
378 } else {
379 wp_safe_redirect($this->get_redirect_url_pie(get_permalink($option['alternate_register'])));
380 exit;
381 }
382 } else if ($theaction == "lostpassword") {
383 if ($is_ssl) {
384 wp_safe_redirect(preg_replace('|^http://|', 'https://', $this->get_redirect_url_pie(get_permalink($option['alternate_forgotpass']))));
385 exit;
386 } else {
387 wp_safe_redirect($this->get_redirect_url_pie(get_permalink($option['alternate_forgotpass'])));
388 exit;
389 }
390 } else if ($theaction == "") {
391 if ($is_ssl) {
392 wp_safe_redirect(preg_replace('|^http://|', 'https://', $this->get_redirect_url_pie(get_permalink($option['alternate_login']))));
393 exit;
394 } else {
395 wp_safe_redirect($this->get_redirect_url_pie(get_permalink($option['alternate_login'])));
396 exit;
397 }
398 }
399 }
400
401 //Blocking access of users to default pages if redirect is on
402
403 if ($theaction != 'logout' && $theaction != 'postpass') {
404 if ((is_user_logged_in() && $pagenow == 'wp-login.php') && ($option['redirect_user'] == 1 && $theaction != 'logout')) {
405 if (!isset($_REQUEST['interim-login'])) {
406 $this->afterLoginPage();
407 }
408 }
409 }
410 if (trim($pagenow) == "profile.php" && $option['block_WP_profile'] == 1) {
411 $current_user = wp_get_current_user();
412 if (trim($current_user->roles[0]) !== "administrator") {
413 //$profile_page = get_option("Profile_page_id");
414 $profile_page = $option['alternate_profilepage'];
415 if ($profile_page > 0) {
416 wp_safe_redirect($this->get_redirect_url_pie(get_permalink($profile_page)));
417 exit;
418 }
419 }
420 }
421
422 //Blocking wp admin for registered users
423 if (isset($_POST['pie_submit'], $_POST['piereg_registration_form_nonce']) && wp_verify_nonce($_POST['piereg_registration_form_nonce'], 'piereg_wp_registration_form_nonce')) {
424 $this->check_register_form();
425 } else if (isset($_POST['pie_renew'])) {
426 $this->renew_account();
427 }
428
429 // if the user is on the login page, then let the game begin
430 if ($theaction != 'logout' && $theaction != 'postpass') {
431 if ($pagenow == 'wp-login.php' && $theaction != 'logout') {
432 add_action('login_init', array($this, 'pieregister_login'), 1);
433 }
434 }
435
436 //OImport Export Section
437 if (isset($_POST['pie_fields_csv']) || isset($_POST['pie_meta_csv'])) {
438 $this->generateCSV();
439 } else if (isset($_FILES['csvfile']['name'])) {
440 $this->importUsers();
441 }
442
443 if (isset($_POST['pie_form'])) {
444 //This will make sure no one tempers the field from the client side
445 /*$required = array("form","username","email","password","submit");*/
446 $required = array("form", "email", "submit");
447 $length = 0;
448 foreach ($_POST['field'] as $field) {
449 if (in_array($field['type'], $required))
450 $length++;
451 }
452 if ($length == sizeof($required)) {
453 $this->saveFields();
454 }
455 }
456
457 if (isset($_GET['prfrmid']) and ((int)$_GET['prfrmid']) != 0 and isset($_GET['status']) and $_GET['status'] != "") {
458 if (current_user_can('manage_options') && isset($_GET['_wpnonce']) && wp_verify_nonce(sanitize_key($_GET['_wpnonce']), 'piereg_form_status_nonce')) {
459 $fields_id = ((int)$_GET['prfrmid']);
460 $pr_form_option = get_option("piereg_form_field_option_" . $fields_id);
461 $pr_form_option['Status'] = (strtolower(sanitize_key($_GET['status'])));
462 update_option("piereg_form_field_option_" . $fields_id, $pr_form_option);
463 }
464
465 #$this->pie_post_array['notice'] = esc_html__("Successfully Change Status of Pie Register Registration Form","pie-register");
466
467 }
468
469 if ((isset($_GET['prfrmid']) and ((int)$_GET['prfrmid']) != 0 and isset($_GET['action']) and $_GET['action'] == "delete") && $this->check_if_role_admin()) {
470
471 // if users created from Form then disable it, delete if no submission.
472 $fields_id = ((int)sanitize_key($_GET['prfrmid']));
473 $pr_all_form_info = $this->get_pr_forms_info();
474 if (count($pr_all_form_info) > 1) {
475
476 $fields_id = ((int)sanitize_key($_GET['prfrmid']));
477 $optionsform = get_option("piereg_form_field_option_" . $fields_id);
478
479 if ($optionsform['Entries'] > 0) {
480 $optionsform['IsDeleted'] = 1;
481 update_option("piereg_form_field_option_" . $fields_id, $optionsform);
482
483 // Assign new free form.
484 $this->regFormForFreeVers(true);
485 } else {
486 $this->delete_piereg_form();
487 }
488 } else {
489 $this->pie_post_array['error_message'] = esc_html__("Form deletion failed.", "pie-register");
490 }
491 }
492
493 if (
494 isset($_POST['invitaion_code_bulk_option'], $_POST['piereg_invitaion_code_bulk_option_nonce']) and isset($_POST['btn_submit_invitaion_code_bulk_option']) and isset($_POST['select_invitaion_code_bulk_option']) and $_POST['invitaion_code_bulk_option'] != "" and $_POST['btn_submit_invitaion_code_bulk_option'] != "" and wp_verify_nonce($_POST['piereg_invitaion_code_bulk_option_nonce'], 'piereg_wp_invitaion_code_bulk_option_nonce')
495 ) {
496 if (trim($_POST['invitaion_code_bulk_option']) == "delete") {
497 $this->delete_invitation_codes($_POST['select_invitaion_code_bulk_option']);
498 } else if (trim($_POST['invitaion_code_bulk_option']) == "active") {
499 $this->active_or_unactive_invitation_codes($_POST['select_invitaion_code_bulk_option'], "1");
500 } else if (trim($_POST['invitaion_code_bulk_option']) == "unactive") {
501 $this->active_or_unactive_invitation_codes($_POST['select_invitaion_code_bulk_option'], "0");
502 }
503 }
504 if ((isset($_POST['piereg_invitation_code_per_page_nonce']) && wp_verify_nonce($_POST['piereg_invitation_code_per_page_nonce'], 'piereg_wp_invitation_code_per_page_nonce')) && isset($_POST['invitation_code_per_page_items']) and $_POST['invitation_code_per_page_items'] != "") {
505 $opt = get_option(OPTION_PIE_REGISTER);
506 $val = ((int)($_POST['invitation_code_per_page_items']) != 0) ? ((int)$_POST['invitation_code_per_page_items']) : "10";
507 $opt['invitaion_codes_pagination_number'] = intval($val);
508 update_option(OPTION_PIE_REGISTER, $opt);
509 $piereg_global_options = $opt;
510 unset($opt);
511 }
512
513 if (
514 isset($_POST['custom_role_bulk_option'], $_POST['piereg_custom_role_bulk_option_nonce']) and isset($_POST['btn_submit_custom_role_bulk_option']) and isset($_POST['select_custom_role_bulk_option']) and $_POST['custom_role_bulk_option'] != "" and $_POST['btn_submit_custom_role_bulk_option'] != "" and wp_verify_nonce($_POST['piereg_custom_role_bulk_option_nonce'], 'piereg_wp_custom_role_bulk_option_nonce')
515 ) {
516
517 if (trim($_POST['custom_role_bulk_option']) == "delete") {
518 $this->delete_custom_roles($_POST['select_custom_role_bulk_option']);
519 }
520 }
521
522 if (isset($option['show_admin_bar']) && $option['show_admin_bar'] == "1") {
523 $this->subscriber_show_admin_bar(); // show/hide admin bar
524 }
525
526 if ((isset($_POST['piereg_old_version_import']) && wp_verify_nonce($_POST['piereg_old_version_import'], 'piereg_wp_old_version_import')) && (isset($_POST['import_email_template_from_version_1']) and $_POST['old_version_import'] == "yes")) {
527 $old_options = get_option("pie_register_2");
528 $new_options = get_option(OPTION_PIE_REGISTER);
529 $new_options['user_message_email_admin_verification'] = nl2br($old_options['adminvmsg']);
530 $new_options['user_message_email_email_verification'] = nl2br($old_options['emailvmsg']);
531 $new_options['user_message_email_default_template'] = nl2br($old_options['msg']);
532 update_option(OPTION_PIE_REGISTER, $new_options);
533 global $piereg_global_options;
534 $piereg_global_options = $new_options;
535 }
536
537 if (isset($option['show_custom_logo']) && $option['show_custom_logo'] == 1) {
538 if (trim($option['custom_logo_url']) != "") {
539 add_action('login_enqueue_scripts', array($this, 'piereg_login_logo'));
540 }
541 add_filter('login_headertext', array($this, 'piereg_login_logo_url_title')); // login_headertitle was deprecated.
542 add_filter('login_headerurl', array($this, 'piereg_login_logo_url'));
543 }
544
545 /*
546 * Activate addon license key
547 */
548 $this->activate_addon_license_key();
549
550 // 3.6.15
551 add_action('wp_ajax_pieregister_activate_addon', array($this, 'pieregister_activate_addon'));
552 add_action('wp_ajax_pieregister_deactivate_addon', array($this, 'pieregister_deactivate_addon'));
553 add_action('wp_ajax_pieregister_install_addon', array($this, 'pieregister_install_addon'));
554
555 // 3.7.15 - To allow properties in style attributes with wp_kses
556 add_filter('safe_style_css', function ($styles) {
557 $styles[] = 'visibility';
558 $styles[] = 'display';
559 return $styles;
560 });
561 }
562 function pieActions()
563 {
564 global $piereg_global_options, $pagenow;
565
566 add_action('wp_ajax_check_username', array($this, 'unique_user'));
567 add_action('wp_ajax_nopriv_check_username', array($this, 'unique_user'));
568
569 add_action('admin_init', array($this, 'piereg_register_scripts'));
570 add_action('admin_init', array($this, 'piereg_backendregister_scripts'));
571 #Adding Menus
572 add_action('admin_menu', array($this, 'AddPanel'));
573 // Show Pie Register Menu on the Admin Bar
574 add_action('admin_bar_menu', array($this, 'AddPanelOnAdminBar'), 999);
575
576 //Add paypal payment method
577 add_action("check_payment_method_paypal", array($this, "check_payment_method_paypal"), 10, 1);
578
579
580 //Adding "embed form" button
581 add_action('media_buttons', array($this, 'add_pie_form_button'));
582
583 if (in_array(basename($_SERVER['PHP_SELF']), array('post.php', 'page.php', 'page-new.php', 'post-new.php')) && is_admin()) {
584 add_action('admin_footer', array($this, 'add_pie_form_popup'));
585 }
586
587 //after_setup_theme {{ previously fires on after_setup_theme hook }}
588 add_action("init", array($this, "piereg_after_setup_theme"));
589
590 #Genrate Warnings
591 add_action('admin_notices', array($this, 'warnings'), 20);
592
593 add_action('init', array($this, 'pie_main'));
594 $profile = new Profile_admin();
595 add_action('show_user_profile', array($profile, "edit_user_profile"));
596 add_action('personal_options_update', array($profile, "updateMyProfile"));
597
598 add_action('edit_user_profile', array($profile, "edit_user_profile"));
599 add_action('edit_user_profile_update', array($profile, 'updateProfile'));
600
601 add_action('widgets_init', array($this, 'initPieWidget'));
602
603 add_action('get_header', array($this, 'add_ob_start'));
604 //It will redirect the User to the home page if the curren tpage is a alternate login page
605 //add_filter('get_header', array($this,'checkLoginPage'));
606
607 add_action('payment_validation_paypal', array($this, 'payment_validation_paypal'));
608
609 add_action("add_select_payment_script", array($this, "add_select_payment_script"));
610 add_filter("get_payment_content_area", array($this, "get_payment_content_area"));
611 add_action("show_icon_payment_gateway", array($this, "show_icon_payment_gateway"));
612 add_action("pr_licenseKey_errors", array($this, "print_Rpr_licenseKey_errors"), 30);
613 add_filter("piereg_messages", array($this, "modify_all_notices"));
614
615 /*update update_invitation_code form ajax*/
616 add_action('wp_ajax_pireg_update_invitation_code', array($this, 'pireg_update_invitation_code_cb_url'));
617 add_action('wp_ajax_nopriv_pireg_update_invitation_code', array($this, 'pireg_update_invitation_code_cb_url'));
618
619 //action to assign piereg_manage_cap to administrator
620 add_action('piereg_add_custom_cap', array($this, 'piereg_add_custom_cap'));
621
622 // FRONT END SCRIPTS
623 add_action('wp_enqueue_scripts', array($this, 'piereg_frontend_assets_header'));
624 add_action('wp_footer', array($this, 'piereg_frontend_assets_footer'), 15);
625 add_action('admin_enqueue_scripts', array($this, 'pie_backend_enqueue_scripts'));
626
627 if (file_exists(PIEREG_DIR_NAME . "/editors/wpbakery/wpbakery-pie-element.php") && defined('WPB_VC_VERSION'))
628 require_once(PIEREG_DIR_NAME . "/editors/wpbakery/wpbakery-pie-element.php");
629
630 if (file_exists(PIEREG_DIR_NAME . "/editors/gutenberg/gutenberg-block.php"))
631 require_once(PIEREG_DIR_NAME . "/editors/gutenberg/gutenberg-block.php");
632
633 do_action('pieregister_gutenberg');
634
635 //User Deletion
636 add_action('delete_user', array($this, 'piereg_user_deletion'));
637 #Adding Short Code Functionality
638 add_shortcode('pie_register_login', array($this, 'showLoginForm'));
639 add_shortcode('pie_register_profile', array($this, 'showProfile'));
640 add_shortcode('pie_register_forgot_password', array($this, 'showForgotPasswordForm'));
641 add_shortcode('pie_register_renew_account', array($this, 'show_renew_account'));
642 add_shortcode('pie_register_form', array($this, 'piereg_registration_form'));
643 // Adding shortcode for user's profile picture
644 // ver - 3.6.3
645 add_shortcode('pie_user_profile_pic', array($this, 'piereg_user_profile_pic'));
646 add_action("the_post", array($this, "piereg_template_restrict"));
647 //Add Post Meta Box
648 add_action('add_meta_boxes', array($this, 'piereg_add_meta_box'));
649 //Save Post Meta Box
650 add_action('save_post', array($this, 'piereg_save_meta_box_data'));
651 //Validate User expiry period
652 add_action("piereg_validate_user_expiry_period", array($this, "piereg_validate_user_expiry_period_func"), 10, 1);
653 add_action('wp_footer', array($this, 'print_multi_captcha_skin'));
654 add_action('wp_footer', array($this, 'pie_update_user_meta_admin_hash'));
655
656 if (in_array($GLOBALS['pagenow'], array('wp-login.php'))) {
657 add_filter('wp_authenticate_user', array($this, 'pie_check_status_on_login'), 10, 2);
658 }
659
660 // Send user notification when user is deleted from unverified users.
661 add_action('piereg_before_deleting_user_unverified_list', array($this, 'piereg_user_notification_user_verification_rejected'), 2);
662 //Rest API Initialized
663 $pie_api = new Pie_api();
664 }
665 function pieFilters()
666 {
667 global $piereg_global_options;
668 add_action("add_payment_method_script", array($this, "add_payment_method_script"));
669 //Add sub links in wp plugin's page
670 add_filter('plugin_row_meta', array($this, 'piereg_plugin_row_meta'), 10, 2);
671 //plugin page links
672 add_filter('plugin_action_links', array($this, 'add_action_links'), 10, 2);
673 //add_filter("Add_payment_option_PaypalStandard", array($this,'Add_payment_option_PaypalStandard'),10,1);
674 add_filter("Add_payment_option", array($this, "Add_payment_option"), 10, 3);
675 add_filter("get_payment_gateway_content", array($this, "get_paypalstandard"), 10, 3);
676
677 add_filter('allow_password_reset', array($this, 'checkUserAllowedPassReset'), 20, 2);
678 if (isset($piereg_global_options['block_wp_login']) && $piereg_global_options['block_wp_login']) {
679 add_filter('login_url', array($this, 'pie_login_url'), 88888, 1);
680 add_filter('lostpassword_url', array($this, 'pie_lostpassword_url'), 88888, 1);
681 add_filter('register_url', array($this, 'pie_registration_url'), 88888, 1);
682 add_filter('logout_url', array($this, 'piereg_logout_url'), 88888, 2);
683 add_filter('wp_nav_menu_objects', array($this, 'pie_add_logout_url_nonce'));
684 }
685 add_filter('piereg_password_reset_not_allowed_text', array($this, 'piereg_password_reset_not_allowed_text_function'), 20, 1);
686
687 /**
688 * Invitation code column added in Users grid
689 * Since v3.5.4
690 */
691 add_filter('manage_users_columns', array($this, 'pie_column_invite')); // Add column in Users Table
692 add_filter('manage_users_custom_column', array($this, 'pie_column_invite_value'), 10, 3); // Add column value in Users Table
693 add_filter('pie_manage_users_custom_column_name', array($this, 'pie_users_custom_column_name'), 10);
694 }
695 function pieregister_activate_addon()
696 {
697
698 // Run a security check.
699 if (! check_ajax_referer('pieregister_admin', 'nonce', false)) {
700 wp_send_json_error(esc_html__('Your session expired. Please reload the page.', 'pie-register'));
701 }
702
703 // Check for permissions.
704 if (! current_user_can('activate_plugins')) {
705 wp_send_json_error(esc_html__('Plugin activation is disabled for you on this site.', 'pie-register'));
706 }
707
708 if (isset($_POST['plugin'])) {
709 $type = 'addon';
710 if (! empty($_POST['type'])) {
711 $type = sanitize_key($_POST['type']);
712 }
713
714 $plugin = sanitize_text_field(wp_unslash($_POST['plugin']));
715 $activate = activate_plugins($plugin);
716
717 do_action('pieregister_plugin_activated', $plugin);
718
719 if (! is_wp_error($activate)) {
720 if ('plugin' === $type) {
721 wp_send_json_success(esc_html__('Plugin activated.', 'pie-register'));
722 } else {
723 wp_send_json_success(esc_html__('Addon activated.', 'pie-register'));
724 }
725 }
726 }
727
728 wp_send_json_error(esc_html__('Could not activate addon. Please activate from the Plugins page.', 'pie-register'));
729 }
730 function pieregister_deactivate_addon()
731 {
732
733 // Run a security check.
734 if (! check_ajax_referer('pieregister_admin', 'nonce', false)) {
735 wp_send_json_error(esc_html__('Your session expired. Please reload the page.', 'pie-register'));
736 }
737
738 // Check for permissions of activate/deactivate.
739 if (! current_user_can('activate_plugins')) {
740 wp_send_json_error(esc_html__('Plugin deactivation is disabled for you on this site.', 'pie-register'));
741 }
742
743 $type = 'addon';
744 if (! empty($_POST['type'])) {
745 $type = sanitize_key($_POST['type']);
746 }
747
748 if (isset($_POST['plugin'])) {
749 $plugin = sanitize_text_field(wp_unslash($_POST['plugin']));
750
751 deactivate_plugins($plugin);
752
753 do_action('pieregister_plugin_deactivated', $plugin);
754
755 if ('plugin' === $type) {
756 wp_send_json_success(esc_html__('Plugin deactivated.', 'pie-register'));
757 } else {
758 wp_send_json_success(esc_html__('Addon deactivated.', 'pie-register'));
759 }
760 }
761
762 wp_send_json_error(esc_html__('Could not deactivate the addon. Please deactivate from the Plugins page.', 'pie-register'));
763 }
764 function pieregister_install_addon()
765 {
766
767 if (! current_user_can('install_plugins')) {
768 wp_send_json_error('You do not have permission to install plugins.');
769 }
770
771 // Run a security check.
772 if (! check_ajax_referer('pieregister_admin', 'nonce', false)) {
773 wp_send_json_error(esc_html__('Your session expired. Please reload the page.', 'pie-register'));
774 }
775
776 $generic_error = esc_html__('There was an error while performing your request.', 'pie-register');
777
778 $type = 'addon';
779 if (! empty($_POST['type'])) {
780 $type = sanitize_key($_POST['type']);
781 }
782
783 $error = esc_html__('Could not install addon. Please download and install manually.', 'pie-register');
784
785 if (empty($_POST['plugin'])) {
786 wp_send_json_error($error);
787 }
788
789 // Set the current screen to avoid undefined notices.
790 set_current_screen('pie-register_page_pie-about-us');
791
792 // Prepare variables.
793 $url = esc_url_raw(
794 add_query_arg(
795 array(
796 'page' => 'pie-about-us',
797 ),
798 admin_url('admin.php')
799 )
800 );
801
802 $creds = request_filesystem_credentials($url, '', false, false, null);
803
804 // Check for file system permissions.
805 if (false === $creds) {
806 wp_send_json_error($error);
807 }
808
809 if (! WP_Filesystem($creds)) {
810 wp_send_json_error($error);
811 }
812
813 /*
814 * We do not need any extra credentials if we have gotten this far, so let's install the plugin.
815 */
816
817 require_once(plugin_dir_path(__FILE__) . 'classes/admin/pie-class-install-skin.php');
818 require_once(plugin_dir_path(__FILE__) . 'classes/admin/PieRegPluginSilentUpgrader.php');
819
820 // Do not allow WordPress to search/download translations, as this will break JS output.
821 remove_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20);
822
823 // Create the plugin upgrader with our custom skin.
824 $installer = new PieRegPluginSilentUpgrader(new PieReg_Install_Skin());
825
826 // Error check.
827 if (! method_exists($installer, 'install') || empty($_POST['plugin'])) {
828 wp_send_json_error($error);
829 }
830
831 $installer->install(sanitize_text_field(wp_unslash($_POST['plugin'])));
832
833 // Flush the cache and return the newly installed plugin basename.
834 wp_cache_flush();
835
836 $plugin_basename = $installer->plugin_info();
837
838 if (empty($plugin_basename)) {
839 wp_send_json_error($error);
840 }
841
842 $result = array(
843 'msg' => $generic_error,
844 'is_activated' => false,
845 'basename' => $plugin_basename,
846 );
847
848 // Check for permissions.
849 if (! current_user_can('activate_plugins')) {
850 $result['msg'] = 'plugin' === $type ? esc_html__('Plugin installed.', 'pie-register') : esc_html__('Addon installed.', 'pie-register');
851
852 wp_send_json_success($result);
853 }
854
855 // Activate the plugin silently.
856 $activated = activate_plugin($plugin_basename);
857
858 if (! is_wp_error($activated)) {
859 $result['is_activated'] = true;
860 $result['msg'] = 'plugin' === $type ? esc_html__('Plugin installed & activated.', 'pie-register') : esc_html__('Addon installed & activated.', 'pie-register');
861
862 wp_send_json_success($result);
863 }
864
865 // Fallback error just in case.
866 wp_send_json_error($result);
867 }
868 function pie_column_invite($column)
869 {
870 $column['invitation_code'] = esc_html__('Invitation Code', 'pie-register');
871 $column['registration_date'] = esc_html__('Registration Date', 'pie-register');
872 return $column;
873 }
874 function pie_column_invite_value($val, $column_name, $user_id)
875 {
876
877 $column = apply_filters('pie_manage_users_custom_column_name', 'ls_user_type');
878
879 switch ($column_name) {
880 case 'registration_date':
881 $user_registration_date = gmdate('jS F, Y h:i:s A', strtotime(get_userdata($user_id)->user_registered));
882 return $user_registration_date ? $user_registration_date : '-';
883 break;
884
885 case 'invitation_code':
886 $user_meta_data = get_user_meta($user_id, 'invite_code', true);
887 return $user_meta_data ? $user_meta_data : '-';
888 break;
889
890 case $column:
891 return apply_filters('pr_geolocation_custom_column_val', $val, $column, $user_id);
892 break;
893
894 default:
895 }
896 }
897 /*
898 * When user deletion
899 */
900 function piereg_user_deletion($user_id)
901 {
902
903 $subscribtion_method = get_user_meta($user_id, "piereg_user_subscribtion_method", true);
904 $subscribtion_id = get_user_meta($user_id, "piereg_user_subscribtion_id", true);
905
906 if (!empty($subscribtion_method) && !empty($subscribtion_id)) {
907 do_action("piereg_delete_subscribtion_on_user_deletion_" . $subscribtion_method, $user_id);
908 }
909 }
910
911 function piereg_register_scripts()
912 {
913 wp_register_script('pie_prVariablesDeclaration_script', plugins_url("/assets/js/prVariablesDeclaration.js", __FILE__), false, PIEREGISTER_VERSION);
914 wp_register_script('pie_prBackendVariablesDeclaration_script', plugins_url("/assets/js/prBackendVariablesDeclaration.js", __FILE__), false, PIEREGISTER_VERSION);
915 wp_register_script('pie_prVariablesDeclaration_script_Footer', plugins_url("/assets/js/prVariablesDeclarationFooter.js", __FILE__), '', PIEREGISTER_VERSION, true);
916 wp_register_script('pie_prBackendVariablesDeclaration_script_Footer', plugins_url("/assets/js/prBackendVariablesDeclarationFooter.js", __FILE__), '', PIEREGISTER_VERSION, true);
917 wp_register_script('prBackendCustomLogo_script', plugins_url("/assets/js/prBackendCustomLogo.js", __FILE__), '', PIEREGISTER_VERSION, true);
918 wp_register_script('pie_datepicker_js', plugins_url("/assets/js/datepicker.js", __FILE__), array('jquery'), PIEREGISTER_VERSION, false);
919 wp_register_script('pie_drag_js', plugins_url("/assets/js/drag.js", __FILE__), 'jquery', PIEREGISTER_VERSION, false);
920 wp_register_script('pie_mCustomScrollbar_js', plugins_url("/assets/js/jquery.mCustomScrollbar.min.js", __FILE__), 'jquery', PIEREGISTER_VERSION, false);
921 wp_register_script('pie_mousewheel_js', plugins_url("/assets/js/jquery.mousewheel.min.js", __FILE__), 'jquery', PIEREGISTER_VERSION, false);
922 wp_register_script('pie_phpjs_js', plugins_url("/assets/js/phpjs.js", __FILE__), 'jquery', PIEREGISTER_VERSION, false);
923 wp_register_script('pie_registermain_js', plugins_url("/assets/js/pie-register-main.js", __FILE__), 'jquery', PIEREGISTER_VERSION, false);
924 wp_register_script('pie_alphanum_js', plugins_url("/assets/js/jquery.alphanum.js", __FILE__), array('jquery'), PIEREGISTER_VERSION, false);
925 wp_register_script('pie_validation_js', plugins_url("/assets/js/piereg_validation.js", __FILE__), 'jquery', PIEREGISTER_VERSION, false);
926 wp_register_script('pie_password_checker', plugins_url("/assets/js/pie_password_checker.js", __FILE__), 'jquery', PIEREGISTER_VERSION, false);
927 wp_register_script('pie_recpatcha_script', '//www.google.com/recaptcha/api.js?onload=prRecaptchaCallBack', '', 'null', true); // &render=explicit removed
928 wp_register_script('pie_confirm_js', plugins_url("/assets/js/jquery-confirm.min.js", __FILE__), array('jquery'), PIEREGISTER_VERSION, false);
929
930 wp_register_style('pie_front_css', plugins_url("/assets/css/front.css", __FILE__), false, PIEREGISTER_VERSION, "all");
931 wp_register_style('pie_wload_css', plugins_url("/assets/css/jquery.wload.css", __FILE__), false, PIEREGISTER_VERSION, "all");
932 wp_register_style('pie_confirm_css', plugins_url("/assets/css/jquery-confirm.min.css", __FILE__), false, PIEREGISTER_VERSION, "all");
933 wp_register_style('pie_style_css', plugins_url("/assets/css/style.css", __FILE__), false, PIEREGISTER_VERSION, "all");
934 wp_register_style('pie_ui_css', plugins_url("/assets/css/pie_ui.css", __FILE__), false, PIEREGISTER_VERSION, "all");
935 wp_register_style('pie_jquery_ui', plugins_url("/assets/css/jquery-ui-theme.css", __FILE__), false, '1.12.1', "all");
936 wp_register_style('pie_font_awesome', plugins_url("/assets/css/font-awesome.min.css", __FILE__), false, '4.7.0', "all");
937
938 // For notices
939 wp_enqueue_style('pie_notice_cs', plugins_url("/assets/css/pie_notice.css", __FILE__), false, PIEREGISTER_VERSION, "all");
940 }
941 function piereg_backendregister_scripts()
942 {
943 //Styles
944 wp_register_style('pie_admin_css', plugins_url("/assets/css/admin.css", __FILE__), false, PIEREGISTER_VERSION, "all");
945 wp_register_style('pie_restrict_widget_css', plugins_url("/restrict_widget/restrict_widget_css.css", __FILE__), false, PIEREGISTER_VERSION, "all");
946 wp_register_style('pie_go_pro_menu_css', plugins_url("/assets/css/admin-go-pro-styles.css", __FILE__), false, PIEREGISTER_VERSION, "all");
947 wp_register_style('pie_addons_menu_css', plugins_url("/assets/css/admin-addons-styles.css", __FILE__), false, PIEREGISTER_VERSION, "all");
948 wp_register_style('pie_admin_about_us_menu_css', plugins_url("/assets/css/admin-about-us.css", __FILE__), false, PIEREGISTER_VERSION, "all");
949 wp_register_style('pie_admin_about_us_slick_css', plugins_url("/assets/css/slick.min.css", __FILE__), false, PIEREGISTER_VERSION, "all");
950 wp_register_style('pie_mCustomScrollbar_css', plugins_url("/assets/css/jquery.mCustomScrollbar.css", __FILE__), false, PIEREGISTER_VERSION, "all");
951 wp_register_style('pie_notification_css', plugins_url("assets/css/pie_notifications.css", __FILE__), false, PIEREGISTER_VERSION, "all");
952 wp_register_style('pie_invite_users_css', plugins_url("assets/css/pie_invite_users.css", __FILE__), false, PIEREGISTER_VERSION, "all");
953 wp_register_style('pie_welcome_css', plugins_url("assets/css/welcome.css", __FILE__), false, PIEREGISTER_VERSION, "all");
954 //Scripts
955 wp_register_script('pie_ckeditor', plugins_url("/assets/lib/ckeditor/ckeditor.js", __FILE__), 'jquery', '1.0', false);
956 wp_register_script('pie_ckeditor_jquery_adapter', plugins_url("/assets/lib/ckeditor/adapters/jquery-adapter.js", __FILE__), array('jquery', 'pie_ckeditor'), '1.0', false);
957 wp_register_script('pie_wload_js', plugins_url("/assets/js/jquery.wload.js", __FILE__), 'jquery', '1.0', false);
958 wp_register_script('pie_restrict_widget_script', plugins_url("/restrict_widget/pie_register_widget_script.js", __FILE__), 'jquery', PIEREGISTER_VERSION, false);
959
960 wp_register_script('pie_admin_about_us_menu_js', plugins_url("/assets/js/admin-about-us.js", __FILE__), 'jquery', PIEREGISTER_VERSION, false);
961
962 $strings = ['nonce' => wp_create_nonce('pieregister_admin')];
963
964 wp_localize_script(
965 'pie_admin_about_us_menu_js',
966 'pieregister_admin',
967 $strings
968 );
969
970 wp_register_script('pie_admin_about_us_slick_js', plugins_url("/assets/js/slick.min.js", __FILE__), 'jquery', PIEREGISTER_VERSION, false);
971 wp_register_script('pie_notification_js', plugins_url("assets/js/pie_notifications.js", __FILE__), array('jquery'), PIEREGISTER_VERSION, true);
972 }
973 function getVauleOrEmpty($string = false)
974 {
975 return (isset($string) && !empty($string)) ? $string : '';
976 }
977 function pieregister_maybe_utf8_encode( $string ) {
978 if ( ! is_string( $string ) || '' === $string ) {
979 return $string;
980 }
981
982 if ( function_exists( 'mb_convert_encoding' ) ) {
983 return mb_convert_encoding( $string, 'UTF-8', 'ISO-8859-1' );
984 }
985
986 if ( function_exists( 'iconv' ) ) {
987 $converted = iconv( 'ISO-8859-1', 'UTF-8//IGNORE', $string );
988 if ( false !== $converted ) {
989 return $converted;
990 }
991 }
992
993 return $string;
994 }
995 function print_multi_lang_script_vars()
996 {
997 global $piereg_global_options;
998 $opt = $piereg_global_options;
999 $fields_id = get_option("piereg_form_fields_id");
1000 $count = 0;
1001 $fields_data = $fields_data_filtered = array();
1002 $form_ids = array();
1003
1004
1005 for ($a = 1; $a <= $fields_id; $a++) {
1006 $option = get_option("piereg_form_field_option_" . $a);
1007 if (!empty($option) && is_array($option) && isset($option['Id']) && trim($option['Status']) != "" && $option['Status'] == "enable" && (!isset($option['IsDeleted']) || trim($option['IsDeleted']) != 1)) {
1008 array_push($form_ids, 'reg_form_' . $option['Id']);
1009 $fields_data = maybe_unserialize(get_option("piereg_form_fields_" . $option['Id']));
1010 $the_cap_field = "captcha";
1011 $fields_data = is_array($fields_data) ? $fields_data : [$fields_data];
1012 $fields_data_filtered = array_filter($fields_data, function ($el) use ($the_cap_field) {
1013 return (isset($el['type']) && ($el['type'] == $the_cap_field));
1014 });
1015 $reg_forms_theme['reg_form_' . $option['Id']] = $fields_data_filtered;
1016 $count++;
1017 }
1018 }
1019
1020 $is_widgetTheme = $not_widgetTheme = (isset($opt['piereg_recapthca_skin_login']) && !empty($opt['piereg_recapthca_skin_login'])) ? $opt['piereg_recapthca_skin_login'] : "red";
1021 $is_forgot_widgetTheme = $not_forgot_widgetTheme = (isset($opt['piereg_recapthca_skin_forgot_pass']) && !empty($opt['piereg_recapthca_skin_forgot_pass'])) ? $opt['piereg_recapthca_skin_forgot_pass'] : "red";
1022 $mathCaptchaOperator = wp_rand(0, 1);
1023 ////1 for add(+)
1024 ////0 for subtract(-)
1025 $mathCaptchaResult = 0;
1026 if ($mathCaptchaOperator == 1) {
1027 $mathCaptchaStart = wp_rand(1, 9);
1028 $mathCaptchaEnd = wp_rand(5, 20);
1029 $mathCaptchaResult = $mathCaptchaStart + $mathCaptchaEnd;
1030 $mathCaptchaOperator = "+";
1031 } else {
1032 $mathCaptchaStart = wp_rand(50, 30);
1033 $mathCaptchaEnd = wp_rand(5, 20);
1034 $mathCaptchaResult = $mathCaptchaStart - $mathCaptchaEnd;
1035 $mathCaptchaOperator = "-";
1036 }
1037
1038 $mathCaptchaResult1 = $mathCaptchaResult + 12;
1039 $mathCaptchaResult2 = $mathCaptchaResult + 786;
1040 $mathCaptchaResult3 = $mathCaptchaResult - 5;
1041 $mathCaptchaResult1 = base64_encode($mathCaptchaResult1);
1042 $mathCaptchaResult2 = base64_encode($mathCaptchaResult2);
1043 $mathCaptchaResult3 = base64_encode($mathCaptchaResult3);
1044 $matchCapImage_name = wp_rand(0, 10);
1045 $matchCapColor = array('rgba(0, 0, 0, 0.6)', 'rgba(153, 31, 0, 0.9)', 'rgba(64, 171, 229,0.8)', 'rgba(0, 61, 21, 0.8)', 'rgba(0, 0, 204, 0.7)', 'rgba(0, 0, 0, 0.5)', 'rgba(198, 81, 209, 1.0)', 'rgba(0, 0, 999, 0.5)', 'rgba(0, 0, 0, 0.5)', 'rgba(0, 0, 0, 0.5)', 'rgba(255, 63, 143, 0.9)');
1046
1047 $matchCapHTML = $mathCaptchaStart . " " . $mathCaptchaOperator . " " . $mathCaptchaEnd . " = ";
1048 $pie_payment_methods_data = array();
1049
1050 if (!empty($this->pie_payment_methods_dat) && count($this->pie_payment_methods_dat) > 0) {
1051 foreach ($this->pie_payment_methods_dat as $data) {
1052 $pie_payment_methods_data[$data['method']]['payment'] = $data['payment'];
1053 $pie_payment_methods_data[$data['method']]['image'] = $data['image'];
1054 }
1055 }
1056
1057 $isSocialLoginRedirectOnLogin = ((isset($opt['social_site_popup_setting']) && $opt['social_site_popup_setting'] == 1) && (isset($_POST['social_site']) && $_POST['social_site'] == "true")) ? true : false;
1058 $this->pie_pr_dec_vars_array = array(
1059 'ajaxURL' => admin_url('admin-ajax.php'),
1060 'dateY' => date_i18n("Y"), //__( 'NiceString', 'pie-register' )
1061 'piereg_startingDate' => $opt['piereg_startingDate'],
1062 'piereg_endingDate' => $opt['piereg_endingDate'],
1063 'pass_strength_indicator_label' => $this->getVauleOrEmpty($opt['pass_strength_indicator_label']),
1064 'pass_very_weak_label' => $this->getVauleOrEmpty($opt['pass_very_weak_label']),
1065 'pass_weak_label' => $this->getVauleOrEmpty($opt['pass_weak_label']),
1066 'pass_medium_label' => $this->getVauleOrEmpty($opt['pass_medium_label']),
1067 'pass_strong_label' => $this->getVauleOrEmpty($opt['pass_strong_label']),
1068 'pass_mismatch_label' => $this->getVauleOrEmpty($opt['pass_mismatch_label']),
1069 'ValidationMsgText1' => esc_html__("none", "pie-register"),
1070 'ValidationMsgText2' => esc_html__("* This field is required", "pie-register"),
1071 'ValidationMsgText3' => esc_html__("* Please select an option", "pie-register"),
1072 'ValidationMsgText4' => esc_html__("* This checkbox is required", "pie-register"),
1073 'ValidationMsgText5' => esc_html__("* Both date range fields are required", "pie-register"),
1074 'ValidationMsgText6' => esc_html__("* Field must equal test", "pie-register"),
1075 'ValidationMsgText7' => esc_html__("* Invalid ", "pie-register"),
1076 'ValidationMsgText8' => esc_html__("Date Range", "pie-register"),
1077 'ValidationMsgText9' => esc_html__("Date Time Range", "pie-register"),
1078 'ValidationMsgText10' => esc_html__("* Minimum ", "pie-register"),
1079 'ValidationMsgText11' => esc_html__(" characters required", "pie-register"),
1080 'ValidationMsgText12' => esc_html__("* Maximum ", "pie-register"),
1081 'ValidationMsgText13' => esc_html__(" characters allowed", "pie-register"),
1082 'ValidationMsgText14' => esc_html__("* You must fill-in one of the following fields", "pie-register"),
1083 'ValidationMsgText15' => esc_html__("* Minimum value is ", "pie-register"),
1084 'ValidationMsgText16' => esc_html__("* Date prior to ", "pie-register"),
1085 'ValidationMsgText17' => esc_html__("* Date past ", "pie-register"),
1086 'ValidationMsgText18' => esc_html__(" options allowed", "pie-register"),
1087 'ValidationMsgText19' => esc_html__("* Please select ", "pie-register"),
1088 'ValidationMsgText20' => esc_html__(" options", "pie-register"),
1089 'ValidationMsgText21' => esc_html__("* Fields do not match", "pie-register"),
1090 'ValidationMsgText22' => esc_html__("* Invalid credit card number", "pie-register"),
1091 'ValidationMsgText23' => esc_html__("* Invalid phone number", "pie-register"),
1092 'ValidationMsgText24' => esc_html__("* Invalid phone number. Allowed format: (xxx)xxx-xxxx", "pie-register"),
1093 'ValidationMsgText25' => esc_html__("* Minimum 10 digits starting with area code without the '+' sign.", "pie-register"),
1094 'ValidationMsgText26' => esc_html__("* Invalid email address", "pie-register"),
1095 'ValidationMsgText27' => esc_html__("* Not a valid integer", "pie-register"),
1096 'ValidationMsgText28' => esc_html__("* Invalid number", "pie-register"),
1097 'ValidationMsgText29' => esc_html__("* Invalid month", "pie-register"),
1098 'ValidationMsgText30' => esc_html__("* Invalid day", "pie-register"),
1099 'ValidationMsgText31' => esc_html__("* Invalid year", "pie-register"),
1100 'ValidationMsgText32' => esc_html__("* Invalid file extension", "pie-register"),
1101 'ValidationMsgText33' => esc_html__("* Invalid date, must be in YYYY-MM-DD format", "pie-register"),
1102 'ValidationMsgText34' => esc_html__("* Invalid IP address", "pie-register"),
1103 'ValidationMsgText35' => esc_html__("* Invalid URL", "pie-register"),
1104 'ValidationMsgText36' => esc_html__("* Numbers only", "pie-register"),
1105 'ValidationMsgText37' => esc_html__("* Letters only", "pie-register"),
1106 'ValidationMsgText38' => esc_html__("* No special characters allowed", "pie-register"),
1107 'ValidationMsgText39' => esc_html__("* This username is not available", "pie-register"),
1108 'ValidationMsgText40' => esc_html__("* Validating, please wait", "pie-register"),
1109 'ValidationMsgText41' => esc_html__("* This username is available", "pie-register"),
1110 'ValidationMsgText42' => esc_html__("* This username is not available", "pie-register"),
1111 'ValidationMsgText43' => esc_html__("* Validating, please wait", "pie-register"),
1112 'ValidationMsgText44' => esc_html__("* This name is not available", "pie-register"),
1113 'ValidationMsgText45' => esc_html__("* This name is available", "pie-register"),
1114 'ValidationMsgText46' => esc_html__("* Validating, please wait", "pie-register"),
1115 'ValidationMsgText47' => esc_html__("* This name is not available", "pie-register"),
1116 'ValidationMsgText48' => esc_html__("* Please enter HELLO", "pie-register"),
1117 'ValidationMsgText49' => esc_html__("* Invalid Date", "pie-register"),
1118 'ValidationMsgText50' => esc_html__("* Invalid Date or Date Format", "pie-register"),
1119 'ValidationMsgText51' => esc_html__("Expected Format: ", "pie-register"),
1120 'ValidationMsgText52' => esc_html__("mm/dd/yyyy hh:mm:ss AM|PM or ", "pie-register"),
1121 'ValidationMsgText53' => esc_html__("yyyy-mm-dd hh:mm:ss AM|PM", "pie-register"),
1122 'ValidationMsgText54' => esc_html__("* Invalid Username", "pie-register"),
1123 'ValidationMsgText55' => esc_html__("* Invalid File Type", "pie-register"),
1124 'ValidationMsgText56' => esc_html__("* Maximum value is ", "pie-register"),
1125 'ValidationMsgText57' => esc_html__("* Letters only", "pie-register"),
1126 'ValidationMsgText58' => esc_html__("* Only Alphanumeric characters are allowed", "pie-register"),
1127 'ValidationMsgText61' => esc_html__("* Invalid file size", "pie-register"),
1128 'ValidationMsgText59' => esc_html__("Delete", "pie-register"),
1129 'ValidationMsgText60' => esc_html__("Edit", "pie-register"),
1130 'piereg_recaptcha_type' => isset($opt['piereg_recaptcha_type']) ? $opt['piereg_recaptcha_type'] : 'v2',
1131 'reCaptcha_public_key' => isset($opt['captcha_publc']) ? $opt['captcha_publc'] : '',
1132 'reCaptchaV3_public_key' => isset($opt['captcha_publc_v3']) ? $opt['captcha_publc_v3'] : '',
1133 'reCaptcha_language' => isset($opt['piereg_recaptcha_language']) ? $opt['piereg_recaptcha_language'] : "en",
1134 'prRegFormsIds' => $form_ids,
1135 'not_widgetTheme' => $not_widgetTheme,
1136 'is_widgetTheme' => $is_widgetTheme,
1137 'not_forgot_widgetTheme' => $not_forgot_widgetTheme,
1138 'is_forgot_widgetTheme' => $fields_data_filtered,
1139 'reg_forms_theme' => $fields_data,
1140 'matchCapResult1' => $mathCaptchaResult1,
1141 'matchCapResult2' => $mathCaptchaResult2,
1142 'matchCapResult3' => $mathCaptchaResult3,
1143 'matchCapColors' => $matchCapColor,
1144 //'prMathCaptchaID' => $fff,
1145 'matchCapImgColor' => $matchCapColor[$matchCapImage_name],
1146 'matchCapImgURL' => plugins_url('/assets/images/math_captcha/' . $matchCapImage_name . '.png', __FILE__),
1147 'matchCapHTML' => $matchCapHTML,
1148 'is_socialLoginRedirect' => $this->pie_is_social_renew_account_call,
1149 'socialLoginRedirectRenewAccount' => $this->pie_ua_renew_account_url,
1150 'isSocialLoginRedirectOnLogin' => $isSocialLoginRedirectOnLogin,
1151 'socialLoginRedirectOnLoginURL' => $this->pie_after_login_page_redirect_url,
1152 'pie_payment_methods_data' => $pie_payment_methods_data,
1153 'prTimedFieldVal' => gmdate("y-m-d H:i:s"),
1154 'process_submission' => esc_html__("Processing...", "pie-register")
1155 );
1156 wp_localize_script('pie_prVariablesDeclaration_script', 'pie_pr_dec_vars', $this->pie_pr_dec_vars_array);
1157
1158 wp_enqueue_script('jquery-ui-progressbar');
1159 wp_enqueue_script('pie_prVariablesDeclaration_script');
1160 wp_enqueue_script('pie_prVariablesDeclaration_script_Footer');
1161 }
1162 //Function print_multi_lang_backend_script_vars()
1163 //Declares Variables that we need on WP Backend
1164 //Uses wp_localize to translate the variables
1165 function print_multi_lang_backend_script_vars()
1166 {
1167 global $piereg_global_options, $wp_roles, $hook_suffix;
1168 $payment_gateways_html = "";
1169 $payment_gateways_list = $this->payment_gateways_list();
1170 if (isset($payment_gateways_list) && is_array($payment_gateways_list) && !empty($payment_gateways_list)) {
1171 foreach ($payment_gateways_list as $pgKey => $pgval) {
1172 $payment_gateways_html .= '<label for="allow_payment_gateways_' . esc_attr($pgKey) . '" class="required piereg-payment-list"><input name="field[%d%][allow_payment_gateways][]" id="allow_payment_gateways_' . esc_attr($pgKey) . '" value="' . esc_attr($pgKey) . '" type="checkbox" checked="checked" class="checkbox_fields">' . esc_html($pgval) . '</label>';
1173 }
1174 }
1175 $roles = $wp_roles->roles;
1176 $user_role_option = "";
1177 $user_role_object = "";
1178 $user_role_array = array();
1179 if (isset($roles) && is_array($roles) && !empty($roles)) {
1180 foreach ($roles as $key => $value) {
1181 $user_role_array[$key] = $value['name'];
1182 }
1183 }
1184 $user_role_object = json_encode($user_role_array);
1185 $defaultMeta = $this->getDefaultMeta();
1186 $fields_data = $this->getCurrentFields();
1187 if (!is_array($fields_data) || sizeof($fields_data) == 0) {
1188 $fields_data = get_option('pie_fields_default');
1189 }
1190 $fillvalKey = array();
1191 $fillvalValue = array();
1192 $fillvalNum = 0;
1193 $options = get_option(OPTION_PIE_REGISTER);
1194
1195 foreach ($fields_data as $k => $field) {
1196
1197 if (($field['type'] == "honeypot") || $field['type'] == "submit" || $field['type'] == "" || $field['type'] == "form" || ($field['type'] == "invitation" && $options["enable_invitation_codes"] == "0" || $field['type'] == "hcaptcha")) {
1198 continue;
1199 }
1200 if ($field['type'] == "url" || $field['type'] == "aim" || $field['type'] == "yim" || $field['type'] == "jabber" || $field['type'] == "description") {
1201 $field['type'] = "default";
1202 }
1203
1204 if ($field['type'] == "html") {
1205 $field['html'] = html_entity_decode($field['html']);
1206 }
1207
1208 if (isset($field['desc']) && !empty($field['desc'])) {
1209 $field['desc'] = html_entity_decode($field['desc']);
1210 }
1211
1212 $fillvalNum++;
1213 array_push($fillvalKey, $field['id']);
1214 array_push($fillvalValue, serialize($field));
1215 }
1216 $this->pie_pr_backend_dec_vars_array = array(
1217 'ajaxURL' => admin_url('admin-ajax.php'),
1218 'hook_suffix' => $hook_suffix,
1219 'wp_content_url' => content_url(),
1220 'wp_home_url' => home_url(),
1221 'wp_site_url' => site_url(),
1222 'wp_admin_url' => admin_url(),
1223 'wp_includes_url' => includes_url(),
1224 'wp_plugins_url' => plugins_url(),
1225 'wp_pie_register_url' => PIEREG_PLUGIN_URL,
1226 'payment_gateways_list' => $payment_gateways_html,
1227 'user_default_role' => get_option("default_role"),
1228 'current_date' => date_i18n("Y"),
1229 'startingDate' => $piereg_global_options['piereg_startingDate'],
1230 'endingDate' => $piereg_global_options['piereg_endingDate'],
1231 'user_roles_array' => $user_role_array,
1232 'user_roles_object' => $user_role_object,
1233 'plsSelectForm' => esc_html__("Please select a form", "pie-register"),
1234 'isPRFormEditor' => (isset($_GET['page']) && in_array($_GET['page'], array('pie-register', 'pr_new_registration_form'))) ? true : false,
1235 'inValidFields' => esc_html__('Invalid Fields', 'pie-register'),
1236 'display_hints' => $piereg_global_options['display_hints'],
1237 'defaultMeta' => $defaultMeta,
1238 'appFormCondFldsStart' => '<div class="advance_fields"><label for="form_notification">' . __("Verifications", "pie-register") . '</label><select name="field[form][notification][]" id="form_notification" class="form_notification" style="width:100px;" ><option value="1" selected="selected">' . __("Admin Verification", "pie-register") . '</option><option value="2">' . __("E-mail Verification", "pie-register") . '</option><option value="3">' . __("E-mail & Admin Verification", "pie-register") . '</option></select><span style="color:#fff;"> ' . __("this field if", "pie-register") . ' </span><select data-selected_field="form_selected_field" name="field[form][selected_field][]" class="form_selected_field piereg_all_field_dropdown" style="width:100px;">',
1239 'appFormCondFldsEnd' => '</select>&nbsp;<select id="form_field_rule_operator" name="field[form][field_rule_operator][]" class="field_rule_operator_select" style="width:auto;"><option selected="selected" value="==">' . (__("equal", "pie-register")) . '</option><option value="!=">' . (__("not equal", "pie-register")) . '</option><option value="empty">' . (__("empty", "pie-register")) . '</option><option value="not_empty">' . (__("not empty", "pie-register")) . '</option><option value=">">' . (__("greater than", "pie-register")) . '</option><option value="<">' . (__("less than", "pie-register")) . '</option><option value="contains">' . (__("contains", "pie-register")) . '</option><option value="starts_with">' . (__("starts with", "pie-register")) . '</option><option value="ends_with">' . (__("ends with", "pie-register")) . '</option></select>&nbsp;<div class="wrap_cond_value"><input type="text" name="field[form][conditional_value][]" id="form_conditional_value" class="input_fields conditional_value" placeholder="Enter Value"></div>&nbsp;<a href="javascript:;" class="delete_conditional_value_fields" style="color:white;font-size: 13px;margin-left: 2px;">x</a></div>',
1240 'fillvalKey' => $fillvalKey,
1241 'fillvalValue' => $fillvalValue,
1242 'fillvalNo' => (max(array_filter(array_keys($fields_data), 'is_numeric')) + 1),
1243 'fillvalNum' => $fillvalNum,
1244 'block_wp_login' => $piereg_global_options['block_wp_login'],
1245 'selectLogoText' => 'Upload/Select Logo',
1246 'mediaUploadURL' => admin_url('media-upload.php')
1247
1248 );
1249 wp_localize_script('pie_prBackendVariablesDeclaration_script', 'pie_pr_backend_dec_vars', $this->pie_pr_backend_dec_vars_array);
1250 wp_enqueue_script('pie_prBackendVariablesDeclaration_script');
1251 wp_enqueue_script('pie_prBackendVariablesDeclaration_script_Footer');
1252
1253 $strings = ['nonce' => wp_create_nonce('pieregister_front_admin')];
1254
1255 wp_localize_script(
1256 'pie_prBackendVariablesDeclaration_script_Footer',
1257 'pieregister_front_admin',
1258 $strings
1259 );
1260 }
1261 // function pie_admin_enqueu_scripts
1262 //Will be replace with print_multi_lang_backend_script_vars();
1263 function pie_admin_enqueu_scripts()
1264 {
1265 $this->print_multi_lang_backend_script_vars();
1266 }
1267 function print_multi_captcha_skin()
1268 {
1269
1270 $settings = get_option(OPTION_PIE_REGISTER);
1271 $publickey = $settings['captcha_publc'];
1272
1273 $fields_id = get_option("piereg_form_fields_id");
1274 $count = 0;
1275 $form_ids = array();
1276 for ($a = 1; $a <= $fields_id; $a++) {
1277 $option = get_option("piereg_form_field_option_" . $a);
1278 if (!empty($option) && is_array($option) && isset($option['Id']) && trim($option['Status']) != "" && $option['Status'] == "enable" && (!isset($option['IsDeleted']) || trim($option['IsDeleted']) != 1)) {
1279 array_push($form_ids, 'reg_form_' . $option['Id']);
1280 $count++;
1281 }
1282 }
1283
1284 $captcha_login_script = false;
1285 $captcha_forgot_script = true;
1286 $captcha_reg_script = false;
1287 if ($settings['captcha_in_login_value'] == 1 && $settings['capthca_in_login'] == 3) {
1288 $captcha_login_script = true;
1289 }
1290 if ($settings['captcha_in_forgot_value'] == 1 && $settings['capthca_in_forgot_pass'] == 3) {
1291 $captcha_forgot_script = true;
1292 }
1293 if ($count > 0) {
1294 $captcha_reg_script = true;
1295 }
1296
1297 if ($captcha_login_script || $captcha_reg_script || $captcha_forgot_script) {
1298 }
1299 }
1300
1301 function add_admin_body_class($classes)
1302 {
1303 $classes .= ' pieregister-page';
1304 return $classes;
1305 }
1306
1307 function pie_backend_enqueue_scripts($hook_s)
1308 {
1309 global $piereg_global_options;
1310 $pr_backend_hook_suffixes = array('pie-register', 'pr_new_registration_form', 'pie-notifications', 'pie-invitation-codes', 'pie-bulk-emails', 'pie-social-login', 'pie-twilio', 'pie-export-users', 'pie-profile-search', 'pie-gateway-settings', 'pie-woocommerce', 'pie-black-listed-users', 'pie-settings', 'pie-import-export', 'unverified-users', 'pie-help', 'post.php', 'edit.php', 'post-new.php');
1311 $pr_backend_hook_suffixes = apply_filters('pr_backend_hook_suffixes', $pr_backend_hook_suffixes);
1312 $is_pr_page = array_filter($pr_backend_hook_suffixes, function ($el) use ($hook_s) {
1313 return (stripos($hook_s, $el) !== false);
1314 });
1315 if (empty($is_pr_page)) {
1316 return false;
1317 }
1318
1319 add_filter('admin_body_class', array($this, 'add_admin_body_class'));
1320 if (in_array('pie-settings', $is_pr_page)) {
1321 wp_enqueue_script('prBackendCustomLogo_script');
1322 }
1323
1324 ///////////// So We are on PR pages /////////////////
1325 //Enqueue Styles
1326 wp_enqueue_style('pie_admin_css');
1327 //wp_enqueue_style('pie_jqueryui_css');
1328 wp_enqueue_style('pie_mCustomScrollbar_css');
1329 wp_enqueue_style('pie_style_css');
1330 #wp_enqueue_style('pie_tooltip_css');
1331 wp_enqueue_style('pie_ui_css');
1332 wp_enqueue_style('pie_validation_css');
1333
1334 //Now We Enqueue Variables
1335 $this->print_multi_lang_script_vars();
1336 $this->pie_admin_enqueu_scripts();
1337
1338 wp_enqueue_script('jquery-ui-core');
1339 wp_enqueue_script('pie_datepicker_js');
1340 wp_enqueue_script('pie_drag_js');
1341 wp_enqueue_script('pie_mCustomScrollbar_js');
1342 wp_enqueue_script('pie_mousewheel_js');
1343 wp_enqueue_script('pie_phpjs_js');
1344 wp_enqueue_script('pie_registermain_js');
1345 // wp_enqueue_script('pie_admin_about_us_menu_js');
1346
1347 if (in_array('pie-settings', $is_pr_page)) {
1348 wp_enqueue_script('prBackendCustomLogo_script');
1349 }
1350
1351 //JQuery UI Effects
1352 wp_enqueue_script('jquery-ui-droppable');
1353 wp_enqueue_script('jquery-ui-tooltip');
1354 wp_enqueue_script('jquery-ui-tabs');
1355 wp_enqueue_script('jquery-ui-sortable');
1356 wp_enqueue_script('jquery-ui-datepicker');
1357 wp_enqueue_script('jquery-ui-draggable');
1358 /* wp_enqueue_script('jquery-ui-dialog'); */
1359
1360 wp_enqueue_style('pie_jquery_ui'); // jquery-ui-theme-smoothness
1361
1362 wp_enqueue_script('pie_alphanum_js');
1363 wp_enqueue_script('pie_validation_js');
1364 wp_enqueue_script("pie_ckeditor");
1365 wp_enqueue_script("pie_ckeditor_jquery_adapter");
1366 wp_enqueue_style('pie_font_awesome');
1367 }
1368
1369 function piereg_frontend_assets_header()
1370 {
1371 if (is_front_page()) {
1372 wp_enqueue_script('pie_dialog_js', plugins_url("/assets/js/dialog.js", __FILE__), array('jquery'), PIEREGISTER_VERSION, false);
1373 wp_enqueue_style('pie_dialog_css', plugins_url("/assets/css/dialog.css", __FILE__), false, PIEREGISTER_VERSION, "all");
1374 // wp_enqueue_script('jquery-ui-dialog');
1375 $this->pieregister_jquery_dialog_script();
1376 }
1377
1378 if (! is_singular()) {
1379 return;
1380 }
1381
1382 global $post;
1383
1384 if (
1385 (has_shortcode($post->post_content, 'pie_register_form') || has_shortcode($post->post_content, 'pie_register_login') || has_shortcode($post->post_content, 'pie_register_forgot_password') || has_shortcode($post->post_content, 'pie_register_profile')) || has_shortcode($post->post_content, 'pie_register_search_profile_form') || has_shortcode($post->post_content, 'pie_register_search_profile_result') || (function_exists('has_block') && has_block('pie-register/form-selector'))
1386 ) {
1387 $this->pie_frontend_enqueu_scripts();
1388 }
1389 }
1390
1391 function piereg_frontend_assets_footer()
1392 {
1393 if (empty($this->piereg_forms_per_page)) {
1394 return;
1395 }
1396
1397 $this->pie_frontend_enqueu_scripts();
1398 }
1399
1400 function pie_frontend_enqueu_scripts()
1401 {
1402 global $piereg_global_options;
1403 $this->print_multi_lang_script_vars();
1404
1405 if (isset($piereg_global_options['outputcss']) && $piereg_global_options['outputcss'] == 1) {
1406 wp_enqueue_style('pie_front_css');
1407 wp_enqueue_style('pie_validation_css');
1408 }
1409
1410 // LOAD RECAPTCHA SCRIPT IS ENABLED OR ADDED IN REGISTRATION FORM(S) - START
1411 $captcha_login_script = false;
1412 $captcha_forgot_script = false;
1413 $captcha_reg_script = false;
1414
1415 // Check if Captcha is to be added in the login form
1416 if ($piereg_global_options['captcha_in_login_value'] == 1 && $piereg_global_options['capthca_in_login'] == 3) {
1417
1418 $captcha_login_script = true;
1419 }
1420 // Check if Captcha is to be added in the reset password form
1421 if ($piereg_global_options['captcha_in_forgot_value'] == 1 && $piereg_global_options['capthca_in_forgot_pass'] == 3) {
1422 $captcha_forgot_script = true;
1423 }
1424
1425 $PR_forrms_fields_id = get_option("piereg_form_fields_id");
1426 for ($a = 1; $a <= $PR_forrms_fields_id; $a++) {
1427 $_form_fields = unserialize(get_option('piereg_form_fields_' . $a));
1428 $_form_option = get_option("piereg_form_field_option_" . $a);
1429
1430 if (!is_array($_form_fields)) continue;
1431
1432 if (!isset($_form_option['IsDeleted']) || trim($_form_option['IsDeleted']) != 1) {
1433 foreach ($_form_fields as $key => $field) {
1434 if ($field['type'] == 'captcha') {
1435 $captcha_reg_script = true;
1436 break;
1437 }
1438 }
1439 }
1440 if ($captcha_reg_script) break;
1441 }
1442
1443 if ($captcha_login_script || $captcha_reg_script || $captcha_forgot_script) {
1444 if ($piereg_global_options['piereg_recaptcha_type'] == 'v2') {
1445 wp_enqueue_script("pie_recpatcha_script");
1446 } elseif ($piereg_global_options['piereg_recaptcha_type'] == 'v3') {
1447 $recaptcha_sitekey = isset($piereg_global_options['captcha_publc_v3']) ? $piereg_global_options['captcha_publc_v3'] : "";
1448 $recaptcha_language = isset($piereg_global_options['piereg_recaptcha_language']) ? $piereg_global_options['piereg_recaptcha_language'] : "";
1449 wp_enqueue_script('pie_recpatchav3_script', '//www.google.com/recaptcha/api.js?render=' . $recaptcha_sitekey . '&hl=' . $recaptcha_language, '', 'null', true);
1450 }
1451 }
1452 // LOAD RECAPTCHA SCRIPT IS ENABLED OR ADDED IN REGISTRATION FORM(S) - END
1453
1454 wp_enqueue_script("pie_datepicker_js");
1455 wp_enqueue_script("pie_alphanum_js");
1456 wp_enqueue_script("pie_validation_js");
1457 wp_enqueue_script('password-strength-meter', false, array('jquery', 'zxcvbn-async'), 'null', true);
1458 wp_enqueue_script('pie_password_checker', false, array('password-strength-meter'), 'null', true);
1459
1460 wp_enqueue_script('jquery-ui-core');
1461 wp_enqueue_script('jquery-ui-datepicker');
1462 }
1463
1464 function check_if_role_admin()
1465 {
1466 $is_admin = false;
1467
1468 $current_user = wp_get_current_user();
1469 if (user_can($current_user, 'administrator')) {
1470 $is_admin = true;
1471 }
1472
1473 return $is_admin;
1474 }
1475
1476 function piereg_registration_form($attributes = "")
1477 {
1478 $this->piereg_ssl_template_redirect();
1479
1480 $id = !empty($form_attr) && isset($form_attr['id']) ? $form_attr['id'] : 0;
1481 $title = !empty($form_attr) && isset($form_attr['title']) ? $form_attr['title'] : "true";
1482 $description = !empty($form_attr) && isset($form_attr['description']) ? $form_attr['description'] : "true";
1483 $is_preview = false;
1484
1485 //// **** ONLY ADMINISTRATOR CAN VIEW FORM PREVIEW ELSE IT WILL SHOW PAGE CONTENT **** ////
1486 $show_preview_form = $this->check_if_role_admin();
1487 $elementor_preview = isset($_GET['action']) && $_GET['action'] == 'elementor' ? true : false;
1488 // For Form with Gutenberg Preview
1489 $gutenberg_preview = isset($_GET['context']) && $_GET['context'] == 'edit' ? true : false;
1490 // For WPBakery Frontend Preview
1491 $WPBakery_preview = isset($_GET['vc_editable']) && $_GET['vc_editable'] == 'true' ? true : false;
1492
1493 if ((isset($_GET['pr_preview']) || $elementor_preview) && $show_preview_form) {
1494 $is_preview = true;
1495 $prFormId = isset($_GET['prFormId']) ? intval(trim($_GET['prFormId'])) : '';
1496 $preview_form_id = 0;
1497
1498 if (isset($_GET['prFormId']) && $prFormId > 0) {
1499 $preview_form_id = $prFormId;
1500 }
1501 }
1502
1503 $use_free_form = false;
1504 if (!is_array($attributes)) {
1505 $use_free_form = true;
1506 }
1507
1508 if (is_array($attributes) || $is_preview || $use_free_form) {
1509
1510 if ($use_free_form && !$is_preview) {
1511 $id = $this->regFormForFreeVers();
1512 } else {
1513
1514 if (is_array($attributes)) extract($attributes);
1515
1516 if ($id != $this->regFormForFreeVers()) {
1517 $id = false;
1518 }
1519 }
1520
1521 if ($is_preview && $preview_form_id > 0) {
1522 $id = $preview_form_id;
1523 }
1524
1525 if (intval($id) != 0) {
1526 $check_form_in_db = get_option("piereg_form_fields_" . ((int)$id));
1527 if ($check_form_in_db == false || trim($check_form_in_db) == "") {
1528 $id = false;
1529 } else {
1530 $check_form_in_db = get_option("piereg_form_field_option_" . ((int)$id));
1531 if (($check_form_in_db['Status'] == "enable" && (!isset($check_form_in_db['IsDeleted']) || trim($check_form_in_db['IsDeleted']) != 1)) || $is_preview) {
1532 if (is_user_logged_in() && !is_admin() && !$is_preview && !$this->is_pr_preview && !$gutenberg_preview && !$WPBakery_preview) {
1533 $global_options = $this->get_pr_global_options();
1534
1535 // Translators: Message shown to logged-in users with a link to edit their profile.
1536 return apply_filters("pie_reg_form_logged_in_msg", sprintf(wp_kses(__("<p>Already logged in, Click <a href='%s'>here</a> to edit profile.<p>", "pie-register"), array('p' => array(), 'a' => array('href' => array()))), esc_url($this->get_page_uri($global_options["alternate_profilepage"], "edit_user=1"))));
1537 }
1538 if (!$is_preview) {
1539 $check_form_in_db['Views'] = (intval($check_form_in_db['Views']) + 1);
1540 update_option("piereg_form_field_option_" . ((int)$id), $check_form_in_db);
1541 $this->set_pr_stats("register", "view");
1542 }
1543 return $this->showForm($id, $title, $description);
1544 } else {
1545 return esc_html__("This form is disabled by the administrator.", "pie-register");
1546 }
1547 }
1548 } else {
1549 $id = false;
1550 }
1551
1552 if ($id == false) {
1553 $this->pr_error_log("Incorrect shortcode used." . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
1554 return esc_html__("Incorrect shortcode used.", "pie-register");
1555 }
1556 } else {
1557 $this->pr_error_log("Incorrect shortcode used." . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
1558 return esc_html__("Incorrect shortcode used.", "pie-register");
1559 }
1560 }
1561
1562 // ver - 3.6.3
1563 function piereg_user_profile_pic()
1564 {
1565 $this->piereg_ssl_template_redirect();
1566
1567 global $wpdb;
1568 $user_id = get_current_user_id();
1569 $data = '';
1570
1571 if ($user_id) {
1572 $result = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}usermeta WHERE `meta_key` LIKE %s AND `user_id`=%d", '%pie_profile_pic_%', $user_id));
1573
1574 if (isset($result[0]) && $result[0]->meta_value) {
1575 $imgPath = $result[0]->meta_value;
1576 } else {
1577 $imgPath = get_avatar_url($user_id);
1578 }
1579
1580 $data .= '<div class="show-profile-img">';
1581 $data .= '<div class="file-wrapper"><img src="' . esc_url($imgPath) . '" alt="' . esc_attr__('User Profile Picture', "pie-register") . '" />';
1582 $data .= '</div>';
1583 $data .= '</div>';
1584
1585 return $data;
1586 } else {
1587 return esc_html__("Incorrect shortcode used.", "pie-register");
1588 $this->pr_error_log("Incorrect shortcode used." . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
1589 }
1590 }
1591
1592 function modify_all_notices($notice)
1593 {
1594 $Start_notice = "";/*Write your message*/
1595 $End_notice = "";/*Write your message*/
1596 return $Start_notice . $notice . $End_notice;
1597 }
1598
1599 function print_Rpr_licenseKey_errors()
1600 {
1601 if (isset($_POST['PR_license_notice']))
1602 return $_POST['PR_license_notice'];
1603 }
1604 function initPieWidget()
1605 {
1606 register_widget('Pie_Register_Widget');
1607 register_widget('Pie_Login_Widget');
1608 register_widget('Pie_Forgot_Widget');
1609 }
1610
1611 //Plugin Menu Link
1612 function add_action_links($links, $file)
1613 {
1614 if ($file != plugin_basename(__FILE__))
1615 return $links;
1616
1617 $action_links = array();
1618 $action_links[] = '<a style="color:#13ad11;font-weight:700;" target="_blank" href="https://pieregister.com/plan-and-pricing/">' . esc_html__("Go Premium", "pie-register") . '</a>';
1619 $action_links[] = '<a href="' . esc_url(get_admin_url(null, 'admin.php?page=pie-settings')) . '">' . (esc_html__("Settings", "pie-register")) . '</a>';
1620
1621 return array_merge($action_links, $links);
1622 }
1623
1624 function piereg_after_setup_theme()
1625 {
1626 if (isset($_POST['log']) && isset($_POST['pwd'])) {
1627 $this->checkLogin();
1628 }
1629 }
1630
1631 /*
1632 * Restrict Post / Page Content
1633 */
1634 function piereg_template_restrict($post_object)
1635 {
1636
1637 if (is_admin()) {
1638 return $post_object;
1639 }
1640
1641 /*
1642 * Get Options
1643 */
1644
1645 $option = get_post_meta($post_object->ID, "_piereg_post_restriction");
1646 /*
1647 * Get Global Options
1648 */
1649 $global_options = $this->get_pr_global_options();
1650 $update = get_option(OPTION_PIE_REGISTER);
1651
1652 $this->post_block_content = "";
1653 $piereg_post_visibility_var = ((isset($option[0]["piereg_post_visibility"]) && $option[0]["piereg_post_visibility"] != "") ? $option[0]["piereg_post_visibility"] : "");
1654
1655 $restriction_type = isset($option[0]['piereg_restriction_type']) ? $option[0]['piereg_restriction_type'] : 0;
1656 $redirect_page = isset($option[0]['piereg_redirect_page']) && ($restriction_type == 0) && ($option[0]['piereg_redirect_page'] != -1) ? $option[0]['piereg_redirect_page'] : "";
1657
1658 if (!empty($redirect_page) && ($update['after_login'] == '-2') && !is_user_logged_in() && !is_home() && !is_front_page() && (function_exists('is_shop') && !is_shop())) {
1659 $update['after_login'] = $post_object->ID;
1660 $update['piereg_after_login_updated'] = true;
1661 update_option(OPTION_PIE_REGISTER, $update);
1662 }
1663
1664 if (is_array($piereg_post_visibility_var)) {
1665 foreach ($piereg_post_visibility_var as $key => $val) {
1666 $visible = $this->get_post_visibility($val);
1667
1668 if (!$visible) {
1669 break;
1670 }
1671 }
1672 } else {
1673 $visible = $this->get_post_visibility($piereg_post_visibility_var);
1674 }
1675 /* Restrict for Users */
1676 if (!isset($option[0]["piereg_post_visibility"])) {
1677 return $post_object;
1678 }
1679 //if Visibility status is default then return
1680 if (is_array($option[0]['piereg_post_visibility']) && in_array('default', $option[0]['piereg_post_visibility']) || !is_array($option[0]['piereg_post_visibility']) && $option[0]['piereg_post_visibility'] == "default") {
1681 return $post_object;
1682 }
1683 if (isset($option[0]) && $visible) {
1684
1685 ////0 = Redirect
1686 ////1 = Block Content
1687
1688 $page_object = get_queried_object();
1689 $page_id = get_queried_object_id();
1690
1691 if (($page_id == $post_object->ID) && isset($option[0]['piereg_restriction_type']) && $option[0]['piereg_restriction_type'] == 0) {
1692 //1st Redirect URL and 2nd Redirect Page
1693 // Current Page URL
1694 $pv_sslport = 443;
1695 $pv_URIprotocol = isset($_SERVER["HTTPS"]) ? (($_SERVER["HTTPS"] === "on" || $_SERVER["HTTPS"] === 1 || $_SERVER["SERVER_PORT"] === $pv_sslport) ? "https://" : "http://") : (($_SERVER["SERVER_PORT"] === $pv_sslport) ? "https://" : "http://");
1696
1697 $redirect_to = "redirect_to=" . $pv_URIprotocol . esc_url_raw($_SERVER["HTTP_HOST"]) . esc_url_raw($_SERVER["REQUEST_URI"]);
1698
1699 if ($option[0]['piereg_redirect_url'] != "") {
1700 // Redirtect URL
1701 $redirect_url = $option[0]['piereg_redirect_url'];
1702 //Redirect
1703 $redirect_url = isset($redirect_to) && !empty($redirect_to) ? $this->pie_modify_custom_url($redirect_url, $redirect_to) : $redirect_url;
1704 wp_safe_redirect(esc_url_raw($redirect_url));
1705 exit;
1706 } else {
1707 //Redirect Url
1708 $redirect_url = get_permalink($option[0]['piereg_redirect_page']);
1709 //Redirect
1710 $redirect_url = isset($redirect_to) && !empty($redirect_to) ? $this->pie_modify_custom_url($redirect_url, $redirect_to) : $redirect_url;
1711 if ($redirect_url) {
1712 wp_safe_redirect($redirect_url);
1713 exit;
1714 }
1715 }
1716 }
1717
1718 if ($option[0]['piereg_block_content'] != "") {
1719 $this->post_block_content = "<p>" . esc_html($option[0]['piereg_block_content']) . "</p>";
1720 add_filter("the_content", array($this, "restrict_content_post"));
1721 return $post_object;
1722 }
1723 }
1724 return $post_object;
1725 }
1726 /*
1727 * Checkl Visibility
1728 */
1729 function get_post_visibility($logic)
1730 {
1731 $visible = false;
1732 if ($logic == "default") {
1733 $visible = true;
1734 } elseif ($logic == "after_login") {
1735 $visible = !is_user_logged_in();
1736 } elseif ($logic == "before_login") {
1737 $visible = is_user_logged_in();
1738
1739 if ($this->check_if_role_admin() == true) {
1740 $visible = false;
1741 }
1742 } elseif ($logic != "") {
1743 global $current_user;
1744 $current_user = wp_get_current_user();
1745 $current_user_role = (array)$current_user->roles;
1746 $visible = !in_array($logic, $current_user_role);
1747 if ($visible && $this->check_if_role_admin() == true) {
1748 $visible = false;
1749 }
1750 }
1751 return $visible;
1752 }
1753 /*
1754 * Restrict Post/Page Content
1755 */
1756 function restrict_content_post($content)
1757 {
1758 if ($this->post_block_content != "")
1759 $content = nl2br($this->post_block_content);
1760
1761 return $content;
1762 }
1763 /*
1764 * Add Meta Box in post / page
1765 * Since version 3.1.3
1766 * - Custom post types included
1767 */
1768 function piereg_add_meta_box($postType)
1769 {
1770 $args = array(
1771 'public' => true,
1772 //'_builtin' => true
1773 );
1774
1775 $output = 'names'; // names or objects, note names is the default
1776 $operator = 'and'; // 'and' or 'or'
1777
1778 $screens = get_post_types($args, $output, $operator);
1779 unset($screens['attachment']);
1780 //$screens = array( 'post', 'page' );
1781 $user_check = true;
1782 $user_check = apply_filters('piereg_before_visibility_restrictions_metabox', $user_check);
1783 if ($user_check) {
1784 foreach ($screens as $screen) {
1785 if ($screen == 'reply') continue;
1786 add_meta_box(
1787 'pieregister_restriction_meta',
1788 // translators: %s is the screen name.
1789 sprintf(esc_html__('Pie Register - %s Restriction', 'pie-register'), ucwords($screen)),
1790 array($this, 'myplugin_meta_box_callback'),
1791 $screen
1792 );
1793 }
1794 }
1795 }
1796
1797 public function pie_leave_a_review_request()
1798 {
1799 $show_review_notice = get_option('pie_review_request_delete');
1800 if (empty($show_review_notice)) {
1801
1802 $install_date = get_option('pie_install_date', '');
1803 if (empty($install_date)) return;
1804 $diff = round((time() - strtotime($install_date)) / 24 / 60 / 60);
1805 if ($diff < 4) return;
1806
1807 $review_url = 'https://wordpress.org/support/plugin/pie-register/reviews/';
1808 ?>
1809 <div class="notice notice-info pie-admin-notice-3 is-dismissible" data-leavereview="<?php echo esc_attr(wp_create_nonce('pie_leave_review_nonce')); ?>">
1810
1811 <p><?php
1812 // Translators: %1$s is the opening HTML <a> tag for the review link, %2$s is the closing </a> tag for the link.
1813 echo wp_kses(sprintf(
1814 // Translators: %1$s is the opening HTML <a> tag for the review link, and %2$s is the closing </a> tag for the link.
1815 __('Hello there, Thank you for using Pie Register. If you are happy and satisfied, will you leave us a 5-star %1$sreview on WordPress?%2$s We would love to know about your experience so far with the plugin. Your feedback helps us grow and reach more people. Thanks!', 'pie-register'),
1816 '<a href="' . esc_url($review_url) . '" target="_blank">',
1817 '</a>'
1818 ), array('a' => array('href' => array(), 'target' => array()))); ?> </p>
1819 <p>
1820 <a href="<?php echo esc_url($review_url); ?>" target="_blank" id="pie_review_in_start" class="button button-primary">
1821 <?php esc_html_e('Sure', 'pie-register') ?>
1822 </a> &nbsp;
1823 <a href="javascript:void(0);" class="button-secondary pie_review_in_link">
1824 <?php esc_html_e('Maybe Later', 'pie-register') ?>
1825 </a>
1826 </p>
1827 </div>
1828 <script type="text/javascript">
1829 jQuery(document).on('click', '#pie_review_in_start', function(e) {
1830 jQuery(this).parents('.pie-admin-notice-3').find('.notice-dismiss').trigger('click');
1831 });
1832
1833 jQuery(document).on('click', '.pie_review_in_link', function(e) {
1834 jQuery(this).parents('.pie-admin-notice-3').find('.notice-dismiss').trigger('click');
1835 });
1836
1837 jQuery('.pie-admin-notice-3').on('click', '.notice-dismiss', function() {
1838 nonce__ = jQuery(this).parent().data('leavereview');
1839
1840 var data = {
1841 action: 'dismiss_pie_leave_a_review_request',
1842 nonce: nonce__
1843 };
1844 jQuery.post(ajaxurl, data);
1845 });
1846 </script>
1847 <?php
1848 }
1849 }
1850
1851 public function pie_gopro_notice()
1852 {
1853 ?>
1854 <div class="notice is-dismissible">
1855 <p><img src="<?php echo esc_url(PIEREG_PLUGIN_URL . 'assets/images/pie_gift_icon.png') ?>" alt="<?php echo esc_attr__('Go Pro', "pie-register") ?>" /><?php esc_html_e("Automate registrations through powerful features and addons. Get 20% off on ", 'pie-register'); ?><a href='https://pieregister.com/plan-and-pricing/?utm_source=adminarea&utm_medium=gopro&utm_campaign=viewplan/' target='_blank'><?php esc_html_e("all plans", "pie-register"); ?></a>.<?php esc_html_e(" Use code 'automate' at checkout. Limited time offer.", 'pie-register'); ?></p>
1856 </div>
1857 <?php
1858 }
1859
1860 public function dismiss_pie_leave_a_review_request()
1861 {
1862 // Run a security check.
1863 if (! check_ajax_referer('pie_leave_review_nonce', 'nonce', false) || !current_user_can('manage_options')) {
1864 wp_send_json_error(esc_html__('Something went wrong.', 'pie-register'));
1865 }
1866
1867 update_option('pie_review_request_delete', true);
1868 }
1869
1870 public function pie_license_expire_msg()
1871 {
1872 $show_review_notice = get_option('pie_license_expire_msg');
1873 $status_addon = $this->get_addons_status();
1874 $renew_url = 'https://store.genetech.co/renew-order/';
1875 if ($status_addon && empty($show_review_notice)) {
1876 ?>
1877 <div class="notice notice-info pie-notice-license-expire is-dismissible" data-expire="<?php echo esc_attr(wp_create_nonce('pie_expire_msg')); ?>">
1878 <p><?php
1879 echo wp_kses(sprintf(
1880 // Translators: %1$s is the opening HTML <a> tag for the renewal link, %2$s is the text 'here' for the status link, and %3$s is the closing </a> tag for both links.
1881 __('Your Pie Register Premium license key has expired; click %2$shere%3$s to check the status. Please %1$srenew%3$s your order to get all the plugin updates and support.', 'pie-register'),
1882 '<a href="' . esc_url($renew_url) . '" target="_blank">',
1883 '<a href="' . esc_url(get_admin_url() . "admin.php?page=pie-help&tab=license") . '" >',
1884 '</a>'
1885 ), array('a' => array('href' => array(), 'target' => array()))); ?></p>
1886 </div>
1887 <script type="text/javascript">
1888 jQuery('.pie-notice-license-expire').on('click', '.notice-dismiss', function() {
1889 nonce__ = jQuery(this).parent().data('expire');
1890
1891 var data = {
1892 action: 'dismiss_pie_license_expire_msg',
1893 nonce: nonce__
1894 };
1895 jQuery.post(ajaxurl, data);
1896 });
1897 </script>
1898 <?php
1899 }
1900 }
1901
1902 public function dismiss_pie_license_expire_msg()
1903 {
1904 // Run a security check.
1905 if (! check_ajax_referer('pie_expire_msg', 'nonce', false) || !current_user_can('manage_options')) {
1906 wp_send_json_error(esc_html__('Something went wrong.', 'pie-register'));
1907 }
1908
1909 update_option('pie_license_expire_msg', true);
1910 }
1911
1912 public function pie_enable_registration_msg()
1913 {
1914 $general_settings_page = get_admin_url(null, 'options-general.php');
1915
1916 if (!$this->is_anyone_can_register()) {
1917 ?>
1918 <div class="notice notice-info">
1919 <div>
1920 <p>
1921 <?php esc_html_e('User registration currently disabled. To enable, Go to ', 'pie-register'); ?>
1922 <a href="<?php echo esc_url($general_settings_page); ?>">
1923 <?php esc_html_e("Settings -> General", 'pie-register') ?>
1924 </a>
1925 <?php esc_html_e('and under Membership, check "Anyone can register".', 'pie-register'); ?>
1926 </p>
1927 </div>
1928 </div>
1929 <?php
1930 }
1931 }
1932
1933 /*
1934 Since version 3.6
1935 @TODO remove this notice in the future.
1936 */
1937 public function pie_promo_notice_security()
1938 {
1939 $show_release_notice = get_option('pie_promo_security_notice');
1940
1941 if (empty($show_release_notice)) {
1942
1943 ?>
1944 <div class="notice notice-info pie-admin-notice pie_security_msg is-dismissible" style="border:1px solid #ccd0d4;" data-securitynonce="<?php echo (esc_attr(wp_create_nonce('pie_notice_security_nonce'))) ?>">
1945 <h3><?php echo (wp_kses_post('<img src="' . esc_url(PIEREG_PLUGIN_URL . 'assets/images/icon-secure.png') . '" style="height:32px;vertical-align: middle;margin-right:8px;" /> Do You Want to Make Your Registration form More Secure? We hear you.', 'pie-register')); ?></h3>
1946 <p><?php echo (esc_html('The fear of bots, spammers, and fake sign-ups with registration forms is real. Pie Register’s Premium Security features render an extra-added layer of protection to your registration forms to rule-out all these possible threats.', 'pie-register')) ?></p>
1947 <p><?php echo (wp_kses_post('The <a href="https://pieregister.com/features/invitation-based-registrations/?utm_source=admindashboard&utm_medium=notification&utm_campaign=invitationcodes" target="_blank">Invitation Codes</a> for keeping your website content exclusive, Timed Form Submissions to prevent bots, <a href="https://pieregister.com/features/customizable-login-security/?utm_source=admindashboard&utm_medium=notification&utm_campaign=loginsecurity" target="_blank">Customizable Login Security</a> to throw CAPTCHA at multiple failed login attempts, and <a href="https://pieregister.com/how-to-make-your-registration-form-secure/?utm_source=admindashboard&utm_medium=notification&utm_campaign=formsecure" target="_blank">More</a>.', 'pie-register')); ?></p>
1948 </div>
1949 <script type="text/javascript">
1950 jQuery('.pie_security_msg').on('click', '.notice-dismiss', function() {
1951 nonce__ = jQuery(this).parent().data('securitynonce');
1952 var data = {
1953 action: 'dismiss_pie_promo_notice_security',
1954 nonce: nonce__
1955 };
1956 jQuery.post(ajaxurl, data);
1957 });
1958 </script>
1959 <?php
1960 }
1961 }
1962 public function dismiss_pie_promo_notice_security()
1963 {
1964 // Run a security check.
1965 if (! check_ajax_referer('pie_notice_security_nonce', 'nonce', false) || !current_user_can('manage_options')) {
1966 wp_send_json_error(esc_html__('Something went wrong.', 'pie-register'));
1967 }
1968
1969 update_option('pie_promo_security_notice', 'yes');
1970 }
1971
1972 /*
1973 Since version 3.5.4
1974 @TODO remove this notice in the future.
1975 */
1976 public function pie_premium_features_notice_for_free()
1977 {
1978 ?>
1979 <div class="notice notice-info pie-admin-notice pre-feat">
1980
1981 <p style="font-weight:700;font-size:16px;"><?php echo (esc_html('Creating Your First Registration Form', 'pireg')); ?></p>
1982
1983 <p>Creating online registration forms for your WordPress website can take a significant amount of time and effort to both code and test but using a plugin with a form builder module can make this job hassle-free. <br> With Pie Register's drag and drop form builder, you can get the job done without writing a single line of code and in almost no time.</p>
1984
1985 <p>
1986 <a target="_blank" style="color:#0073aa;" href="https://pieregister.com/documentation/how-to-create-your-first-registration-form/?utm_source=admindashboard&utm_medium=manageforms&utm_campaign=creatingforms">How to add Fields </a><br>
1987 <a target="_blank" style="color:#0073aa;" href="https://pieregister.com/documentation/settings/?utm_source=admindashboard&utm_medium=manageforms&utm_campaign=creatingforms">Complete Guide to Pie Register Settings</a><br>
1988 <a target="_blank" style="color:#0073aa;" href="https://pieregister.com/documentation/how-to-verify-and-moderate-user-registration-using-pie-register/?utm_source=admindashboard&utm_medium=manageforms&utm_campaign=creatingforms">Complete Guide to Verify Users</a><br>
1989 <a target="_blank" style="color:#0073aa;" href="https://pieregister.com/documentation/invitation-only-registrations/?utm_source=admindashboard&utm_medium=manageforms&utm_campaign=creatingforms">How to make your website exclusive using Invitation Codes</a><br>
1990 <a target="_blank" style="color:#0073aa;" href="https://pieregister.com/documentation/how-to-translate-pie-register-forms-in-a-different-language-with-loco-translate/?utm_source=admindashboard&utm_medium=manageforms&utm_campaign=creatingforms">How To Translate Pie Register Forms In a Different Language With Loco Translate</a><br>
1991 <a target="_blank" style="color:#0073aa;" href="https://pieregister.com/documentation/advanced-login-security/?utm_source=admindashboard&utm_medium=manageforms&utm_campaign=creatingforms">Advance Login Security</a><br>
1992 <a target="_blank" style="color:#0073aa;" href="https://pieregister.com/documentation/how-to-verify-and-moderate-user-registration-using-pie-register/?utm_source=admindashboard&utm_medium=manageforms&utm_campaign=creatingforms">Admin can view all the verified and unverified users under the Users tab of the WordPress dashboard</a>
1993 </p>
1994 </div>
1995 <?php
1996 }
1997
1998 public function pie_promo_notice_for_wc_user()
1999 {
2000 $show_release_notice = get_option('pie_promo_notice_for_wc_user');
2001
2002 if (empty($show_release_notice)) {
2003 $img_src = plugin_dir_url(__FILE__) . 'assets/images/pieregister-woocommerce.png';
2004 ?>
2005 <div class="notice notice-info pie-admin-notice wc_promo_users is-dismissible" data-wcuser="<?php echo esc_attr(wp_create_nonce('pie_wc_user_nonce')); ?>">
2006 <div class="pr-launch-icon">
2007 <img src="<?php echo esc_url($img_src); ?>" alt="Pie Register and Woocommerce Logo">
2008 </div>
2009 <div>
2010 <p style="font-weight:700;">WooCommerce Addon</p>
2011 <p><?php echo esc_html__(' Using WooCommerce? Synchronize the billing and shipping address on your Pie Register form with WooCommerce with our WooCommerce addon.', 'pie-register'); ?></p>
2012 <a href="https://pieregister.com/addons/woocommerce-addon/?utm_source=admindashboard&utm_medium=notification&utm_campaign=woocommerce" target="_blank" id="pie_review_in_start" class="button button-primary">
2013 <?php esc_html_e("Here's how you can do it", 'pie-register') ?>
2014 </a>
2015 </div>
2016 </div>
2017 <script type="text/javascript">
2018 jQuery('.wc_promo_users').on('click', '.notice-dismiss', function() {
2019 nonce_wc = jQuery(this).parent().data('wcuser');
2020
2021 var data = {
2022 action: 'dismiss_pie_promo_notice_for_wc_user',
2023 nonce: nonce_wc
2024 };
2025 jQuery.post(ajaxurl, data);
2026 });
2027 </script>
2028 <?php
2029 }
2030 }
2031 public function dismiss_pie_promo_notice_for_wc_user()
2032 {
2033 // Run a security check.
2034 if (! check_ajax_referer('pie_wc_user_nonce', 'nonce', false) || !current_user_can('manage_options')) {
2035 wp_send_json_error(esc_html__('Something went wrong.', 'pie-register'));
2036 }
2037
2038 update_option('pie_promo_notice_for_wc_user', 'yes');
2039 }
2040
2041 public function pie_promo_notice_for_mc_user()
2042 {
2043 $show_release_notice = get_option('pie_promo_notice_for_mc_user_2');
2044
2045 if (empty($show_release_notice)) {
2046 $img_src = plugin_dir_url(__FILE__) . 'assets/images/pieregister-mailchimp.png';
2047 ?>
2048 <div class="notice notice-info pie-admin-notice mc_promo_users is-dismissible" data-mcuser="<?php echo esc_attr(wp_create_nonce('pie_mc_user_nonce')); ?>">
2049 <div class="pr-launch-icon">
2050 <img src="<?php echo esc_url($img_src); ?>" alt="Pie Register and Mail Chimp Logo">
2051 </div>
2052 <div>
2053 <p style="font-weight:700;">Mail Chimp Addon</p>
2054 <p><?php echo esc_html('MailChimp Add-on now has the GDPR Compliance Field, Merge Fields, and a lot more.', 'pie-register'); ?></p>
2055 <a href="https://pieregister.com/addons/mailchimp-addon/?utm_source=admindashboard&utm_medium=notification&utm_campaign=mailchimp" target="_blank" id="pie_review_in_start" class="button button-primary">
2056 <?php esc_html_e("View list of new functions", 'pie-register') ?>
2057 </a>
2058 </div>
2059 </div>
2060 <script type="text/javascript">
2061 jQuery('.mc_promo_users').on('click', '.notice-dismiss', function() {
2062 nonce_mc = jQuery(this).parent().data('mcuser');
2063 var data = {
2064 action: 'dismiss_pie_promo_notice_for_mc_user',
2065 nonce: nonce_mc
2066 };
2067 jQuery.post(ajaxurl, data);
2068 });
2069 </script>
2070 <?php
2071 }
2072 }
2073 public function dismiss_pie_promo_notice_for_mc_user()
2074 {
2075 // Run a security check.
2076 if (! check_ajax_referer('pie_mc_user_nonce', 'nonce', false) || !current_user_can('manage_options')) {
2077 wp_send_json_error(esc_html__('Something went wrong.', 'pie-register'));
2078 }
2079
2080 update_option('pie_promo_notice_for_mc_user_2', 'yes');
2081 }
2082
2083 public function pie_promo_notice_for_bb_user()
2084 {
2085 $show_release_notice = get_option('pie_promo_notice_for_bb_user_3');
2086
2087 if (empty($show_release_notice)) {
2088 $img_src = plugin_dir_url(__FILE__) . 'assets/images/pieregister-bbPress.png';
2089 ?>
2090 <div class="notice notice-info pie-admin-notice bb_promo_users is-dismissible" data-bbuser="<?php echo esc_attr(wp_create_nonce('pie_bb_user_nonce')); ?>">
2091 <div class="pr-launch-icon">
2092 <img src="<?php echo esc_url($img_src); ?>" alt="Pie Register and bbPress Logo">
2093 </div>
2094 <div>
2095 <p style="font-weight:700;">bbPress Addon</p>
2096 <p><?php echo esc_html('Want to connect bbPress with Pie Register? You can now display the Pie Register fields on your bbPress user profile and let your users edit the profile directly from there.'); ?></p>
2097 <a href="https://pieregister.com/addons/bbpress-addon/?utm_source=admindashboard&utm_medium=notification&utm_campaign=bbpress" target="_blank" id="pie_review_in_start" class="button button-primary">
2098 <?php esc_html_e("Learn More", 'pie-register') ?>
2099 </a>
2100 </div>
2101 </div>
2102 <script type="text/javascript">
2103 jQuery('.bb_promo_users').on('click', '.notice-dismiss', function() {
2104 nonce_bbuser = jQuery(this).parent().data('bbuser');
2105
2106 var data = {
2107 action: 'dismiss_pie_promo_notice_for_bb_user',
2108 nonce: nonce_bbuser
2109 };
2110 jQuery.post(ajaxurl, data);
2111 });
2112 </script>
2113 <?php
2114 }
2115 }
2116 public function dismiss_pie_promo_notice_for_bb_user()
2117 {
2118 // Run a security check.
2119 if (! check_ajax_referer('pie_bb_user_nonce', 'nonce', false) || !current_user_can('manage_options')) {
2120 wp_send_json_error(esc_html__('Something went wrong.', 'pie-register'));
2121 }
2122
2123 update_option('pie_promo_notice_for_bb_user_3', 'yes');
2124 }
2125
2126 /*
2127 Since version 3.7.0.4
2128 @TODO remove this notice in the future.
2129 */
2130
2131 public function pie_promo_notice_for_wpb_user()
2132 {
2133 if (!function_exists('get_current_screen')) {
2134 require_once ABSPATH . '/wp-admin/includes/screen.php';
2135 }
2136 $screen = get_current_screen();
2137
2138 if ($screen->base == 'dashboard') {
2139 wp_enqueue_style('pie_font_awesome');
2140
2141 wp_enqueue_script("pie_admin_about_us_menu_js");
2142
2143 $can_install_plugins = true;
2144 if (! current_user_can('install_plugins')) {
2145 $can_install_plugins = false;
2146 }
2147
2148 $show_release_notice = get_option('pie_promo_notice_for_wpb_user');
2149
2150 if (empty($show_release_notice)) {
2151 $img_src = plugin_dir_url(__FILE__) . 'assets/images/pieregister-woocommerce.png';
2152 $images_url = PIEREG_PLUGIN_URL . 'assets/images/about-us/';
2153 $plugin = 'vc-addons-by-bit14/bit14-vc-addons.php';
2154 $all_plugins = get_plugins();
2155 $plugin_data = array(
2156 'icon' => $images_url . 'pb-logo.png',
2157 'name' => esc_html__('PB Add-ons for WP Bakery', 'pie-register'),
2158 'desc' => esc_html__('Build your website with premium quality All-in-One Web elements for WPBakery Page Builder.', 'pie-register'),
2159 'wporg' => 'https://wordpress.org/plugins/vc-addons-by-bit14/',
2160 'url' => 'https://downloads.wordpress.org/plugin/vc-addons-by-bit14.zip',
2161 );
2162
2163 $plugin_data = $this->get_aboutus_plugin_data($plugin, $plugin_data, $all_plugins);
2164
2165 ?>
2166 <div class="notice notice-info pie-admin-notice wpb_promo_users is-dismissible" data-wpb="<?php esc_attr(wp_create_nonce('pie_wpb_user_nonce')) ?>">
2167 <div class="pr-launch-icon">
2168 <img src="<?php echo esc_url($plugin_data['details']['icon']); ?>">
2169 </div>
2170 <div class="sib-product-container">
2171 <div class="sib-product-notice">
2172 <div class="sib-product-detail">
2173 <h5>
2174 <?php echo esc_html($plugin_data['details']['name']); ?>
2175 </h5>
2176 <p>
2177 <?php echo wp_kses_post($plugin_data['details']['desc']); ?>
2178 </p>
2179 </div>
2180 <div class="sib-product-action">
2181 <div class="product-action">
2182 <?php if ($can_install_plugins) { ?>
2183 <button class="<?php echo esc_attr($plugin_data['action_class']); ?>" data-plugin="<?php echo esc_attr($plugin_data['plugin_src']); ?>" data-type="plugin">
2184 <?php echo wp_kses_post($plugin_data['action_text']); ?>
2185 </button>
2186 <?php } else { ?>
2187 <a href="<?php echo esc_url($details['wporg']); ?>" target="_blank" rel="noopener noreferrer">
2188 <?php esc_html_e('WordPress.org', 'pie-register'); ?>
2189 <span aria-hidden="true" class="dashicons dashicons-external"></span>
2190 </a>
2191 <?php } ?>
2192 </div>
2193 </div>
2194 </div>
2195 </div>
2196 </div>
2197 <script type="text/javascript">
2198 jQuery('.wpb_promo_users').on('click', '.notice-dismiss', function() {
2199 nonce_wpb = jQuery(this).parent().data('wpb');
2200
2201 var data = {
2202 action: 'dismiss_pie_promo_notice_for_wpb_user',
2203 nonce: nonce_wpb
2204 };
2205 jQuery.post(ajaxurl, data);
2206 });
2207 </script>
2208 <?php
2209 }
2210 }
2211 }
2212 public function dismiss_pie_promo_notice_for_wpb_user()
2213 {
2214 // Run a security check.
2215 if (! check_ajax_referer('pie_wpb_user_nonce', 'nonce', false) || !current_user_can('manage_options')) {
2216 wp_send_json_error(esc_html__('Something went wrong.', 'pie-register'));
2217 }
2218
2219 update_option('pie_promo_notice_for_wpb_user', 'yes');
2220 }
2221
2222 /*
2223 Since version 3.6
2224 @TODO remove this notice in the future.
2225 */
2226 public function pie_free_notice_to_premium_users()
2227 {
2228 $show_release_notice = get_option('pie_free_notice_to_premium_users');
2229
2230 if (empty($show_release_notice)) {
2231
2232 ?>
2233 <div style="border-left-color: #c00;background-color: #f9e3e3;" class="notice notice-info free_promo_users_upgrade is-dismissible" data-alert="<?php echo (esc_attr(wp_create_nonce('pie_alert_nonce'))); ?>">
2234 <h3><?php echo esc_html('ALERT', 'pie-register'); ?>:</h3>
2235 <p style="font-size:14px;"><?php
2236 // Translators: Message displayed when the Pie Register Premium plugin is not installed, advising the user to install and activate it before changing settings.
2237 echo wp_kses(sprintf(__(' Looks like you haven\'t installed Pie Register Premium Version. Before changing any settings or option make sure to install and activate Pie Register Premium plugin. You can get the Premium plugin from <a style="color:#c30604;" target="_blank" id="pie_opt_in_start" href="%s">My Account dashboard</a></strong>.', 'pie-register'), esc_url('https://store.genetech.co/my-account')), array('a' => array('style' => array(), 'target' => array(), 'id' => array(), 'href' => array()), 'strong' => array())); ?> </p>
2238 </div>
2239 <script type="text/javascript">
2240 jQuery('.free_promo_users_upgrade').on('click', '.notice-dismiss', function() {
2241 nonce_alert = jQuery(this).parent().data('alert');
2242 var data = {
2243 action: 'dismiss_pie_free_notice_to_premium_users',
2244 nonce: nonce_alert
2245 };
2246 jQuery.post(ajaxurl, data);
2247 });
2248 </script>
2249 <?php
2250 }
2251 }
2252 public function dismiss_pie_free_notice_to_premium_users()
2253 {
2254 // Run a security check.
2255 if (! check_ajax_referer('pie_alert_nonce', 'nonce', false) || !current_user_can('manage_options')) {
2256 wp_send_json_error(esc_html__('Something went wrong.', 'pie-register'));
2257 }
2258
2259 update_option('pie_free_notice_to_premium_users', 'yes');
2260 }
2261
2262
2263 /*
2264 * Show Post Meta Box
2265 */
2266 function myplugin_meta_box_callback($post)
2267 {
2268 wp_nonce_field('myplugin_meta_box', 'myplugin_meta_box_nonce');
2269 ?>
2270 <div class="pie_register-admin-meta">
2271 <?php $result = get_post_meta($post->ID, '_piereg_post_restriction', true); ?>
2272
2273 <div class="piereg_restriction_field_area">
2274 <h2><?php esc_html_e('Visibility Restrictions', 'pie-register'); ?></h2>
2275 <input type="hidden" name="post_restriction[piereg_post_type]" value="<?php echo esc_attr($post->post_type); ?>" />
2276 <div class="piereg_label">
2277 <label for="piereg_post_visibility"><?php esc_html_e('Visibility', 'pie-register'); ?></label>
2278 </div>
2279 <div class="piereg_input">
2280 <?php
2281 if (isset($result['piereg_post_visibility']) && is_array(isset($result['piereg_post_visibility']))) {
2282 $option = !empty($result['piereg_post_visibility']) ? $result['piereg_post_visibility'] : array(0 => 'default');
2283 } else {
2284 $option = !empty($result['piereg_post_visibility']) ? $result['piereg_post_visibility'] : "default";
2285 }
2286 ?>
2287 <select multiple id="piereg_post_visibility" name="piereg_post_visibility[]">
2288 <option value="default" <?php selected(((is_array($option) && in_array('default', $option)) || (!is_array($option) && $option == 'default')), true); ?>><?php esc_html_e('Default', "pie-register") ?></option>
2289 <option value="after_login" <?php selected(((is_array($option) && in_array('after_login', $option)) || (!is_array($option) && $option == 'after_login')), true); ?>><?php esc_html_e('Show to Logged in Users', "pie-register") ?></option>
2290 <option value="before_login" <?php selected(((is_array($option) && in_array('before_login', $option)) || (!is_array($option) && $option == 'before_login')), true); ?>><?php esc_html_e('Show to users who have not logged in.', "pie-register") ?></option>
2291 <?php
2292 global $wp_roles;
2293 $role = $wp_roles->roles;
2294
2295 foreach ($role as $key => $value) {
2296 ?>
2297 <option value="<?php echo esc_attr($key) ?>" <?php selected(((is_array($option) && in_array($key, $option)) || (!is_array($option) && $option == $key)), true); ?>> <?php esc_html_e("Show to", "pie-register");
2298 echo " " . esc_html($value['name']); ?></option>
2299 <?php
2300 }
2301 ?>
2302 </select>
2303 </div>
2304 </div>
2305
2306 <div class="piereg_restriction_field_area pieregister_restriction_type_area">
2307 <div class="piereg_label"><label><?php esc_html_e('Restriction Type', 'pie-register'); ?></label></div>
2308
2309 <div class="piereg_input">
2310 <?php $restriction_option = (isset($result['piereg_restriction_type']) && $result['piereg_restriction_type'] != "") ? $result['piereg_restriction_type'] : 0; ?>
2311 <div class="piereg_input_radio">
2312 <label for="redirect">
2313 <input type="radio" id="redirect" class="piereg_restriction_type" name="post_restriction[piereg_restriction_type]" value="0" <?php echo checked($restriction_option == 0, true); ?> /><?php esc_html_e('Redirect', 'pie-register'); ?></label>
2314 </div>
2315 <div class="piereg_input_radio">
2316 <label for="block_content">
2317 <input type="radio" id="block_content" class="piereg_restriction_type" name="post_restriction[piereg_restriction_type]" value="1" <?php echo checked($restriction_option == 1, true); ?> /><?php esc_html_e('Block Content', 'pie-register'); ?></label>
2318 </div>
2319 <div>
2320 <p class="piereg_restriction_msg error"><strong><?php esc_html_e('Please Provide Either Redirect Page or Redirect URL.', 'pie-register'); ?></strong></p>
2321 </div>
2322 </div>
2323 </div>
2324
2325 <div id="pieregister_restriction_url_area" style="<?php echo ($restriction_option != 0) ? esc_attr('display:none') : '' ?>">
2326 <div class="piereg_restriction_field_area pieregister_restriction_url_area">
2327 <div class="piereg_label">
2328 <?php $option = ((isset($result['piereg_redirect_url']) && $result['piereg_redirect_url'] != "") ? $result['piereg_redirect_url'] : ""); ?>
2329 <label for="piereg_redirect_url"><?php esc_html_e('Redirect Url', 'pie-register'); ?></label>
2330 </div>
2331 <div class="piereg_input">
2332 <input type="url" id="piereg_redirect_url" name="post_restriction[piereg_redirect_url]" value="<?php echo esc_attr($option); ?>" style="width:70%;" class="pieregister_redirect_url" />
2333 </div>
2334 </div>
2335
2336 <div class="piereg_restriction_field_area pieregister_restriction_url_area">
2337 <center><strong><?php esc_html_e('OR', 'pie-register'); ?></strong></center>
2338 </div>
2339
2340 <div class="piereg_restriction_field_area pieregister_restriction_url_area">
2341 <div class="piereg_label">
2342 <?php $option = ((isset($result['piereg_redirect_page']) && $result['piereg_redirect_page'] != "") ? $result['piereg_redirect_page'] : -1); ?>
2343 <label for="piereg_redirect_page"><?php esc_html_e('Redirect Page', 'pie-register'); ?></label>
2344 </div>
2345 <div class="piereg_input">
2346 <?php
2347 $args = array("show_option_no_change" => "None", "id" => "piereg_redirect_page", "class" => "pieregister_redirect_url", "name" => "post_restriction[piereg_redirect_page]", "selected" => $option, 'echo' => 0);
2348 echo wp_kses_post(wp_dropdown_pages($args)); ?>
2349 </div>
2350 </div>
2351 </div>
2352
2353 <div class="piereg_restriction_field_area pieregister_block_content_area" style="<?php echo ($restriction_option != 1) ? esc_attr('display:none') : '' ?>">
2354 <div class="piereg_label">
2355 <?php $option = ((isset($result['piereg_block_content']) && $result['piereg_block_content'] != "") ? $result['piereg_block_content'] : ""); ?>
2356 <label for="piereg_block_content"><?php esc_html_e('Block Content', 'pie-register'); ?></label>
2357 </div>
2358 <div class="piereg_input">
2359 <textarea id="piereg_block_content" name="post_restriction[piereg_block_content]"><?php echo esc_textarea($option); ?></textarea>
2360 </div>
2361 </div>
2362 </div>
2363 <noscript><?php esc_html_e('You browser does not support Javascript. Please turn on Javascript support.', 'pie-register'); ?></noscript>
2364
2365 <?php
2366 }
2367 /*
2368 Save Post Meta Box
2369 */
2370 function piereg_save_meta_box_data($post_id)
2371 {
2372 //Don't update on Quick Edit
2373 if (defined('DOING_AJAX')) {
2374 return $post_id;
2375 }
2376 $post_restriction_meta = isset($_POST['post_restriction']) ? $this->piereg_sanitize_post_data('post_restriction', $_POST) : array();
2377
2378 if (isset($_POST['piereg_post_visibility'])) {
2379 // Sanitize piereg post visibility array
2380 $npost = array();
2381 foreach ($_POST['piereg_post_visibility'] as $key => $val) {
2382 $npost[$key] = sanitize_key($val);
2383 }
2384 $post_restriction_meta['piereg_post_visibility'] = $npost;
2385 } else {
2386 $post_restriction_meta['piereg_post_visibility'] = "default";
2387 }
2388 update_post_meta($post_id, '_piereg_post_restriction', $post_restriction_meta);
2389 }
2390
2391 private function show_invitaion_code_user()
2392 {
2393 global $errors, $wpdb;
2394 $prefix = $wpdb->prefix . "pieregister_";
2395 $inv_code = sanitize_text_field(base64_decode($_GET['invitaion_code']));
2396 if (!preg_match("/[^A-Za-z0-9-_]/", $inv_code)) {
2397
2398 $invitaion_code_users = $wpdb->get_results($wpdb->prepare("SELECT `user_login`,`user_email` FROM `wp_users` WHERE `ID` IN (SELECT user_id FROM `wp_usermeta` Where meta_key = 'invite_code' and meta_value = %s )", $inv_code));
2399
2400 if (isset($wpdb->last_error) && !empty($wpdb->last_error)) {
2401 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
2402 }
2403 ?>
2404 <style type="text/css">
2405 table.invitaion-code-table thead td,
2406 table.invitaion-code-table tfoot td {
2407 background: #333;
2408 font-size: 16px;
2409 font-weight: bold;
2410 color: #FFF;
2411 }
2412
2413 table.invitaion-code-table tr:nth-child(even) {
2414 background: #E8E8E8;
2415 }
2416
2417 table.invitaion-code-table tr:hover {
2418 background: #666;
2419 color: #FFF;
2420 }
2421 </style>
2422 <div style="width:100%">
2423 <h2><?php esc_html_e("Activation Code", "pie-register");
2424 echo " : " . esc_html($inv_code); ?></h2>
2425 <table class="invitaion-code-table" width="100%" cellpadding="10" cellspacing="0">
2426 <thead>
2427 <tr>
2428 <td><?php esc_html_e("User Name", "pie-register"); ?></td>
2429 <td><?php esc_html_e("User E-mail", "pie-register"); ?></td>
2430 </tr>
2431 </thead>
2432 <tfoot>
2433 <tr>
2434 <td><?php esc_html_e("User Name", "pie-register"); ?></td>
2435 <td><?php esc_html_e("User E-mail", "pie-register"); ?></td>
2436 </tr>
2437 </tfoot>
2438 <?php
2439 foreach ($invitaion_code_users as $row) {
2440 echo '<tr>';
2441 echo '<td>' . esc_html($row->user_login) . '</td>';
2442 echo '<td>' . esc_html($row->user_email) . '</td>';
2443 echo '</tr>';
2444 }
2445 ?>
2446 </table>
2447 </div>
2448 <?php
2449 }
2450 exit;
2451 }
2452 function piereg_login_logo()
2453 {
2454 $option = get_option(OPTION_PIE_REGISTER);
2455 $logo_data = @getimagesize($option['custom_logo_url']);
2456 ?>
2457 <style type="text/css">
2458 body.login div#login h1 a {
2459 background-image: url('<?php echo esc_url($option['custom_logo_url']); ?>');
2460 background-size: <?php echo esc_attr($logo_data[0]) . "px " . esc_attr($logo_data[1]) . "px"; ?>;
2461 width: <?php echo esc_attr($logo_data[0]) . "px "; ?>;
2462 height: <?php echo esc_attr($logo_data[1]) . "px "; ?>;
2463 }
2464 </style>
2465 <?php
2466 unset($option);
2467 }
2468 function piereg_login_logo_url_title()
2469 {
2470 $option = get_option(OPTION_PIE_REGISTER);
2471 return $option['custom_logo_tooltip'];
2472 unset($option);
2473 }
2474 function piereg_login_logo_url()
2475 {
2476 $option = get_option(OPTION_PIE_REGISTER);
2477 return $option['custom_logo_link'];
2478 unset($option);
2479 }
2480 function payment_success_cancel_after_register($query_string)
2481 {
2482 global $wpdb;
2483 $option = get_option(OPTION_PIE_REGISTER);
2484 $fields = maybe_unserialize(get_option("pie_fields"));
2485 $confirmation_type = $fields['submit']['confirmation'];
2486
2487 if ($confirmation_type == "page") {
2488 wp_safe_redirect(get_permalink($fields['submit']['page']));
2489 exit;
2490 } elseif ($confirmation_type == "redirect") {
2491 wp_safe_redirect(esc_url_raw($fields['submit']['redirect_url']));
2492 exit;
2493 } elseif ($confirmation_type == "text") {
2494 wp_safe_redirect($this->pie_modify_custom_url(get_permalink($option['alternate_login']), $query_string));
2495 exit;
2496 }
2497 }
2498 function get_redirect_url_pie($get_url)
2499 {
2500 $get_url = trim($get_url);
2501 if (!$get_url) return false;
2502 if ($_SERVER['QUERY_STRING']) {
2503 if (strpos($get_url, "?"))
2504 $url = $get_url . "&" . esc_url_raw($_SERVER['QUERY_STRING']);
2505 else
2506 $url = $get_url . "?" . esc_url_raw($_SERVER['QUERY_STRING']);
2507 } else {
2508 $url = $get_url;
2509 }
2510 return $url;
2511 }
2512 function subscriber_show_admin_bar()
2513 {
2514 global $current_user;
2515 $current_user_caps_keys = array_keys($current_user->caps);
2516 $ncaps = count($current_user_caps_keys);
2517 if ($ncaps) {
2518 //if( !in_array('administrator', $current_user->caps) )
2519 if (!array_key_exists('administrator', $current_user->caps)) {
2520 show_admin_bar(false);
2521 }
2522 }
2523 unset($current_user);
2524 }
2525
2526 function delete_piereg_form()
2527 {
2528 if (isset($_GET['prfrmid']) and ((int)$_GET['prfrmid']) != 0 and isset($_GET['action']) and $_GET['action'] == "delete") {
2529 $fields_id = ((int)sanitize_key($_GET['prfrmid']));
2530 $assign_new_free_form = false;
2531
2532 if ($this->regFormForFreeVers() == $fields_id) {
2533 $assign_new_free_form = true;
2534 }
2535
2536 delete_option("piereg_form_field_option_" . $fields_id);
2537 delete_option("piereg_form_fields_" . $fields_id);
2538 $user_role = get_option(OPTION_PIE_REGISTER);
2539 unset($user_role['pie_regis_set_user_role_' . ((int)$_GET['prfrmid'])]);
2540 update_option(OPTION_PIE_REGISTER, $user_role);
2541 unset($user_role);
2542 unset($fields_id);
2543 unset($_GET['prfrmid']);
2544
2545 if ($assign_new_free_form) {
2546 $this->regFormForFreeVers(true);
2547 }
2548 }
2549 }
2550
2551 //"Insert Form" button to the post/page edit screen
2552 function add_pie_form_button($context)
2553 {
2554 $_post_type = get_post_type();
2555 if ($_post_type == 'product')
2556 return $context;
2557
2558 $is_post_edit_page = in_array(basename($_SERVER['PHP_SELF']), array('post.php', 'page.php', 'page-new.php', 'post-new.php'));
2559 if (!$is_post_edit_page)
2560 return $context;
2561
2562 printf('<a href="%s" class="thickbox button" id="add_pie_form" title="%s"><span style="%s" class="wp-media-buttons-icon"></span>%s</a>', '#TB_inline?width=480&inlineId=select_pie_form', esc_html__("Add Pie Register Form", 'pie-register'), 'background: url(' . esc_url(PIEREG_PLUGIN_URL) . 'assets/images/form-icon.png); background-repeat: no-repeat; background-position: left bottom;', esc_html__("Add Form", "pie-register"));
2563 }
2564
2565 function checkLoginPage()
2566 {
2567 $option = get_option(OPTION_PIE_REGISTER);
2568 $current_page = get_the_ID();
2569 if ($option['block_wp_login'] == 1 && $option['redirect_user'] == 1 && $option['alternate_login'] > 0 && is_user_logged_in() && $current_page == $option['alternate_login'] && !$this->is_pr_preview) {
2570 $this->afterLoginPage();
2571 }
2572 }
2573 function add_pie_form_popup()
2574 {
2575 ?>
2576 <div id="select_pie_form" style="display:none;">
2577 <div>
2578 <div>
2579 <div style="padding:15px 15px 0 15px;">
2580 <h3 style="color:#5A5A5A!important; font-family:Georgia,Times New Roman,Times,serif!important; font-size:1.8em!important; font-weight:normal!important;"><?php esc_html__("Select A Form", "pie-register"); ?></h3>
2581 <span>
2582 <?php esc_html__("Select a form below to add it to your post or page.", "pie-register"); ?>
2583 </span>
2584 </div>
2585 <div style="padding:15px 15px 0 15px;">
2586 <select id="pie_forms">
2587 <option value=""><?php esc_attr__("Select", "pie-register") ?></option>
2588 <optgroup label="<?php esc_attr__("Registration Form", "pie-register") ?>">
2589 <?php
2590 $fields_id = get_option("piereg_form_fields_id");
2591 for ($a = 1; $a <= $fields_id; $a++) {
2592 $option = get_option("piereg_form_field_option_" . $a);
2593 if ($option != "" && (!isset($option['IsDeleted']) || trim($option['IsDeleted']) != 1)) {
2594 echo '<option value=\'[pie_register_form id="' . esc_attr($option['Id']) . '" title="true" description="true" ]\'>' . esc_html($option['Title']) . '</option>';
2595 }
2596 }
2597 ?>
2598 </optgroup>
2599 <optgroup label="<?php esc_attr_e("Other Form", "pie-register") ?>">
2600 <option value="[pie_register_login]"><?php esc_html_e("Login Form", "pie-register") ?></option>
2601 <option value="[pie_register_forgot_password]"><?php esc_html_e("Forgot Password Form", "pie-register") ?></option>
2602 <option value="[pie_register_profile]"><?php esc_html_e("Profile Page", "pie-register") ?></option>
2603 </optgroup>
2604 </select> <br />
2605 </div>
2606 <div style="padding:15px;">
2607 <input type="button" class="button-primary" value="Insert Form" onclick="addForm();" />&nbsp;&nbsp;&nbsp;
2608 <a class="button" style="color:#bbb;" href="#" onclick="tb_remove(); return false;"><?php esc_html_e("Cancel", "pie-register"); ?></a>
2609 </div>
2610 </div>
2611 </div>
2612 </div>
2613 <?php
2614 }
2615 function process_verify_user_email()
2616 {
2617
2618 if (isset($_GET['verification_key']) && !empty($_GET['verification_key'])) {
2619
2620 $unverified = get_users(array('meta_key' => 'admin_hash', 'meta_value' => sanitize_key($_GET['verification_key'])));
2621 $option = get_option(OPTION_PIE_REGISTER);
2622 if (sizeof($unverified) == 1) {
2623 $user_id = $unverified[0]->ID;
2624 $user_login = $unverified[0]->user_login;
2625 $user_email = $unverified[0]->user_email;
2626 $register_type = get_user_meta($user_id, "register_type", true);
2627
2628 if ($register_type == "admin_email_verify" && !$this->InvCodeExpired($user_id)) {
2629 update_user_meta($user_id, 'active', 0);
2630 $hash = wp_generate_password(32, false);
2631 update_user_meta($user_id, 'hash', $hash);
2632 update_user_meta($user_id, 'register_type', "email_verify");
2633
2634 $subject = html_entity_decode($option['user_subject_email_email_verification'], ENT_COMPAT, "UTF-8");
2635 $subject = $this->filterSubject($user_email, $subject);
2636 $message_temp = "";
2637 if ($option['user_formate_email_email_verification'] == "0") {
2638 $message_temp = nl2br(wp_strip_all_tags($option['user_message_email_email_verification']));
2639 } else {
2640 $message_temp = $option['user_message_email_email_verification'];
2641 }
2642 $message = $this->filterEmail($message_temp, $user_email);
2643 $from_name = $option['user_from_name_email_verification'];
2644 $from_email = $option['user_from_email_email_verification'];
2645 $reply_email = $option['user_to_email_email_verification'];
2646
2647 //Headers
2648 $headers = 'MIME-Version: 1.0' . "\r\n";
2649 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
2650
2651
2652 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
2653 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
2654 if ($reply_email) {
2655 $headers .= "Reply-To: {$reply_email}\r\n";
2656 $headers .= "Return-Path: {$reply_email}\r\n";
2657 } else {
2658 $headers .= "Reply-To: {$from_email}\r\n";
2659 $headers .= "Return-Path: {$from_email}\r\n";
2660 }
2661 if ((isset($option['user_enable_email_verification']) && $option['user_enable_email_verification'] == 1) && !wp_mail($user_email, $subject, $message, $headers)) {
2662 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
2663 } else {
2664 echo ('<div id="dialog-message" title="User Verified Successfully">
2665 <p>
2666 ' . esc_html(apply_filters("pie_user_veri_by_email_admin", esc_html__("User has been verified.", "pie-register"))) . '
2667 </p>
2668 </div>');
2669 }
2670 } elseif ($user_login == $_GET['pie_id'] && !$this->InvCodeExpired($user_id)) {
2671
2672 $user = new WP_User($user_id);
2673 do_action("piereg_action_hook_before_user_verified", $user_id, $user_login, $user_email); # newlyAddedHookFilter
2674 update_user_meta($user_id, 'active', 1);
2675 $email_user_password = get_user_meta($user_id, "email_user_password", true);
2676 $user_pass = $email_user_password == "1" ? apply_filters('piereg_email_random_generated_password', wp_generate_password()) : "";
2677
2678 /*************************************/
2679 /////////// THANK YOU E-MAIL //////////
2680 $form = new Registration_form();
2681 $subject = html_entity_decode($option['user_subject_email_email_thankyou'], ENT_COMPAT, "UTF-8");
2682 $subject = $form->filterSubject($user_email, $subject);
2683 if (!empty($user_pass)) {
2684 $user_data = array('ID' => $user_id, 'user_pass' => trim($user_pass));
2685 wp_update_user($user_data);
2686 update_user_meta($user_id, 'email_user_password', '0');
2687 }
2688 $message_temp = "";
2689 if ($option['user_formate_email_email_thankyou'] == "0") {
2690 $message_temp = nl2br(wp_strip_all_tags($option['user_message_email_email_thankyou']));
2691 } else {
2692 $message_temp = $option['user_message_email_email_thankyou'];
2693 }
2694 $message = $form->filterEmail($message_temp, $user_email, $user_pass);
2695 $from_name = $option['user_from_name_email_thankyou'];
2696 $from_email = $option['user_from_email_email_thankyou'];
2697 $reply_email = $option['user_to_email_email_thankyou'];
2698 //Headers
2699 $headers = 'MIME-Version: 1.0' . "\r\n";
2700 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
2701 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
2702 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
2703 if ($reply_email) {
2704 $headers .= "Reply-To: {$reply_email}\r\n";
2705 $headers .= "Return-Path: {$reply_email}\r\n";
2706 } else {
2707 $headers .= "Reply-To: {$from_email}\r\n";
2708 $headers .= "Return-Path: {$from_email}\r\n";
2709 }
2710 /*************************************/
2711
2712 if ((isset($option['user_enable_email_thankyou']) && $option['user_enable_email_thankyou'] == 1) && !wp_mail($user_email, $subject, $message, $headers)) {
2713 $form->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($form->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
2714 } else {
2715 echo ('<div id="dialog-message" title="User Verified Successfully">
2716 <p>
2717 ' . esc_html(apply_filters("pie_user_veri_by_email_admin", esc_html__("User has been verified.", "pie-register"))) . '
2718 </p>
2719 </div>');
2720 }
2721 // mailchimp related code within PR
2722 do_action('pireg_after_verification_users', $user);
2723 } else {
2724 if ($this->InvCodeExpired($user_id)) {
2725 echo ('<div id="dialog-message" title="Invitation Code Expired">
2726 <p>
2727 <strong>' . esc_html(ucwords(esc_html__("error", "pie-register"))) . '</strong>: ' . esc_html(apply_filters("piereg_invalid_verification_key", esc_html__("The account cannot be activated. Please contact site administrator", "pie-register"))) . '
2728 </p>
2729 </div>');
2730 } else {
2731 echo ('<div id="dialog-message" title="User Not Verified">
2732 <p>
2733 <strong>' . esc_html(ucwords(esc_html__("error", "pie-register"))) . '</strong>: ' . esc_html(apply_filters("piereg_invalid_verification_key", esc_html__("Invalid verification key", "pie-register"))) . '
2734 </p>
2735 </div>');
2736 }
2737 }
2738 } else {
2739 $user_name = sanitize_user($_GET['pie_id']);
2740 $user = get_user_by('login', $user_name);
2741 if ($user) {
2742 $user_meta = get_user_meta($user->ID, 'active');
2743 $user_meta_email = get_user_meta($user->ID, 'hash');
2744
2745 if (isset($user_meta[0]) && $user_meta[0] == 1) {
2746 echo ('<div id="dialog-message" title="User Verified">
2747 <p><strong>' . esc_html(ucwords(esc_html__("Warning", "pie-register"))) . '</strong>:
2748 ' . wp_kses_post(apply_filters("piereg_canelled_your_registration", esc_html__("User is already verified", "pie-register"))) . '
2749 </p>
2750 </div>');
2751 unset($user_meta);
2752 unset($user_meta_email);
2753 unset($user_name);
2754 unset($user);
2755 } elseif (isset($user_meta_email[0]) && $user_meta_email[0]) {
2756 echo ('<div id="dialog-message" title="User Verified">
2757 <p><strong>' . esc_html(ucwords(esc_html__("Warning", "pie-register"))) . '</strong>:
2758 ' . wp_kses_post(apply_filters("piereg_canelled_your_registration", esc_html__("User is already verified", "pie-register"))) . '
2759 </p>
2760 </div>');
2761 unset($user_meta);
2762 unset($user_meta_email);
2763 unset($user_name);
2764 unset($user);
2765 } else {
2766 echo ('<div id="dialog-message" title="User Not Verified">
2767 <p><strong>' . esc_html(ucwords(esc_html__("error", "pie-register"))) . '</strong>:
2768 ' . wp_kses_post(apply_filters("piereg_invalid_verification_key", esc_html__("Invalid verification key", "pie-register"))) . '
2769 </p>
2770 </div>');
2771 }
2772 } else {
2773 echo ('<div id="dialog-message" title="User Not Verified">
2774 <p><strong>' . esc_html(ucwords(esc_html__("error", "pie-register"))) . '</strong>:
2775 ' . wp_kses_post(apply_filters("piereg_invalid_verification_key", esc_html__("Invalid verification key", "pie-register"))) . '
2776 </p>
2777 </div>');
2778 }
2779 }
2780 }
2781 }
2782 function pie_update_user_meta_admin_hash()
2783 {
2784 $verification_key = isset($_GET['verification_key']) ? sanitize_key($_GET['verification_key']) : "";
2785 $unverified = get_users(array('meta_key' => 'admin_hash', 'meta_value' => $verification_key));
2786 if (sizeof($unverified) == 1) {
2787 $user_id = $unverified[0]->ID;
2788 $user_login = $unverified[0]->user_login;
2789 if (isset($_GET['pie_id']) && $user_login == $_GET['pie_id']) {
2790 $admin_hash = "";
2791 update_user_meta($user_id, 'admin_hash', $admin_hash);
2792 }
2793 }
2794 }
2795
2796 function process_login_form()
2797 {
2798 get_header();
2799 $this->set_pr_stats("login", "view");
2800 if (file_exists(PIEREG_DIR_NAME . "/login_form.php"))
2801 include_once("login_form.php");
2802 $output = "<div class='wrapper-wp-login-form'>";
2803 $output .= pieOutputLoginForm();
2804 $output .= "</div>";
2805 echo wp_kses($output, $this->piereg_forms_get_allowed_tags());
2806 get_footer();
2807 exit;
2808 }
2809 function checkLogin()
2810 {
2811 global $wpdb, $errors, $wp_session;
2812 $errors = new WP_Error();
2813 $option = get_option(OPTION_PIE_REGISTER);
2814
2815 if ((isset($_POST['piereg_login_form_nonce']) && wp_verify_nonce($_POST['piereg_login_form_nonce'], 'piereg_wp_login_form_nonce')) || (isset($_POST['social_site']) && $_POST['social_site'] == "true") || (isset($_POST['piereg_login_after_registration']) && $_POST['piereg_login_after_registration'] == true)) {
2816 if (empty($_POST['log']) || empty($_POST['pwd'])) {
2817 $errors->add('login-error', apply_filters("piereg_Invalid_username_or_password", esc_html__('Invalid username or password.', 'pie-register')));
2818 } else {
2819 /*
2820 * Sanitizing post data
2821 */
2822 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_login', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
2823 $error_found = 0;
2824
2825 $table_name = $wpdb->prefix . "pieregister_lockdowns";
2826 $user_ip = sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
2827 $get_results = $wpdb->get_results($wpdb->prepare("SELECT * FROM $table_name WHERE `user_ip` = %s AND `attempt_from` = 'is_login';", $user_ip));
2828
2829 $piereg_security_attempts_login_value = false;
2830
2831 if ($option['captcha_in_login_value'] == 1 && !isset($this->pie_post_array['piereg_login_after_registration'])) {
2832
2833 $attempts = false;
2834 if ($option['captcha_in_login_attempts'] > 0) {
2835 $attempts = true;
2836 } elseif ($option['captcha_in_login_attempts'] == 0) {
2837 $attempts = true;
2838 }
2839
2840 if ($attempts) {
2841 if ($option['capthca_in_login'] == 2 || (isset($this->pie_post_array['piereg_math_captcha_login']) || isset($this->pie_post_array['piereg_math_captcha_login_widget']))) {
2842 if (isset($this->pie_post_array['piereg_math_captcha_login'])) //Login form in Page
2843 {
2844 $currentTabId = intval($_COOKIE['currentTabId']);
2845 $piereg_cookie_array = ((isset($_COOKIE['tab_' . $currentTabId . '_piereg_math_captcha_Login_form']) && 0 < strpos($_COOKIE['tab_' . $currentTabId . '_piereg_math_captcha_Login_form'], '|')) ? sanitize_text_field($_COOKIE['tab_' . $currentTabId . '_piereg_math_captcha_Login_form']) : "");
2846 $piereg_cookie_array = explode("|", $piereg_cookie_array);
2847 $cookie_result1 = (intval(base64_decode($piereg_cookie_array[0])) - 12);
2848 $cookie_result2 = (intval(base64_decode($piereg_cookie_array[1])) - 786);
2849 $cookie_result3 = (intval(base64_decode($piereg_cookie_array[2])) + 5);
2850 if (($cookie_result1 == $cookie_result2) && ($cookie_result3 == $this->pie_post_array['piereg_math_captcha_login'])) {
2851 } else {
2852 if ($this->piereg_authentication($this->pie_post_array['log'], $this->pie_post_array['pwd'])) {
2853 $errors->add('login-error', apply_filters("Invalid_Security_Code", esc_html__('Invalid Security Code', 'pie-register')));
2854 } else {
2855 if ($piereg_security_attempts_login_value) {
2856 $errors->add('login-error', apply_filters("blocked_ip_due_to_many_attempts_failed", esc_html__("IP address blocked due to too many failed login attempts.", "pie-register")));
2857 }
2858 }
2859 $error_found++;
2860 }
2861 } elseif (isset($this->pie_post_array['piereg_math_captcha_login_widget'])) //Login form in widget
2862 {
2863 $currentTabId = intval($_COOKIE['currentTabId']);
2864 $piereg_cookie_array = ((isset($_COOKIE['tab_' . $currentTabId . '_piereg_math_captcha_Login_form_widget']) && 0 < strpos($_COOKIE['tab_' . $currentTabId . '_piereg_math_captcha_Login_form_widget'], '|')) ? sanitize_text_field($_COOKIE['tab_' . $currentTabId . '_piereg_math_captcha_Login_form_widget']) : "");
2865 $piereg_cookie_array = explode("|", $piereg_cookie_array);
2866 $cookie_result1 = (intval(base64_decode($piereg_cookie_array[0])) - 12);
2867 $cookie_result2 = (intval(base64_decode($piereg_cookie_array[1])) - 786);
2868 $cookie_result3 = (intval(base64_decode($piereg_cookie_array[2])) + 5);
2869 if (($cookie_result1 == $cookie_result2) && ($cookie_result3 == $this->pie_post_array['piereg_math_captcha_login_widget'])) {
2870 } else {
2871 if ($this->piereg_authentication($this->pie_post_array['log'], $this->pie_post_array['pwd'])) {
2872 $errors->add('login-error', apply_filters("Invalid_Security_Code", esc_html__('Invalid Security Code', 'pie-register')));
2873 } else {
2874 if ($piereg_security_attempts_login_value) {
2875 $errors->add('login-error', apply_filters("blocked_ip_due_to_many_attempts_failed", esc_html__("IP address blocked due to too many failed login attempts.", "pie-register")));
2876 }
2877 }
2878 $error_found++;
2879 }
2880 } else {
2881 if ($this->piereg_authentication($this->pie_post_array['log'], $this->pie_post_array['pwd'])) {
2882 $errors->add('login-error', apply_filters("Invalid_Security_Code", esc_html__('Invalid Security Code', 'pie-register')));
2883 } else {
2884 if ($piereg_security_attempts_login_value) {
2885 $errors->add('login-error', apply_filters("blocked_ip_due_to_many_attempts_failed", esc_html__("IP address blocked due to too many failed login attempts.", "pie-register")));
2886 }
2887 }
2888 $error_found++;
2889 }
2890 } //New Recaptcha
2891 elseif ($option['capthca_in_login'] == 3 || (isset($this->pie_post_array["recaptcha_challenge_field"], $this->pie_post_array["recaptcha_response_field"]) && !empty($this->pie_post_array["recaptcha_challenge_field"]) && !empty($this->pie_post_array["recaptcha_response_field"]))) {
2892 $settings = get_option(OPTION_PIE_REGISTER);
2893 if ($settings['piereg_recaptcha_type'] == "v2") {
2894 $privatekey = $settings['captcha_private'];
2895 } elseif ($settings['piereg_recaptcha_type'] == "v3") {
2896 $privatekey = $settings['captcha_private_v3'];
2897 }
2898
2899 $captcha = "";
2900 $captcha = (isset($this->pie_post_array['g-recaptcha-response']) && ! empty($this->pie_post_array['g-recaptcha-response'])) ? trim($this->pie_post_array['g-recaptcha-response']) : "";
2901
2902 $response = $this->read_file_from_url("https://www.google.com/recaptcha/api/siteverify?secret=" . trim($privatekey) . "&response=" . $captcha . "&remoteip=" . sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])));
2903 $resp = json_decode($response, true);
2904 if ($resp['success'] == false) {
2905
2906 if ($this->piereg_authentication($this->pie_post_array['log'], $this->pie_post_array['pwd'])) {
2907 $errors->add('login-error', apply_filters("Invalid_Security_Code", esc_html__('Invalid Security Code', 'pie-register')));
2908 } else {
2909 if ($piereg_security_attempts_login_value) {
2910 $errors->add('login-error', apply_filters("blocked_ip_due_to_many_attempts_failed", esc_html__("IP address blocked due to too many failed login attempts.", "pie-register")));
2911 }
2912 }
2913 $error_found++;
2914 }
2915 }
2916 }
2917 }
2918
2919 do_action('pie_validate_before_login', $errors);
2920
2921 if (sizeof($errors->errors) == 0 && $error_found == 0) {
2922 $creds['user_login'] = $this->pie_post_array['log'];
2923 // is_email($creds['user_login']) - 3.6.11
2924 $regXemail = "/^[a-zA-Z0-9.'_%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,5}/";
2925 if (preg_match($regXemail, $creds['user_login'])) {
2926 $userdata = get_user_by('email', $creds['user_login']);
2927 $creds['user_login'] = (isset($userdata->user_login)) ? strtolower($userdata->user_login) : $creds['user_login'];
2928 }
2929
2930 $this->pie_post_array['pwd'] = html_entity_decode($this->pie_post_array['pwd']);
2931 $creds['user_password'] = $this->pie_post_array['pwd'];
2932 $creds['remember'] = isset($this->pie_post_array['rememberme']);
2933
2934 $remember_user = (isset($this->pie_post_array['rememberme'])) ? true : false;
2935
2936 if (isset($this->pie_post_array['social_site']) and $this->pie_post_array['social_site'] == "true" and is_plugin_active("pie-register-social-site/pie-register-social-site.php")) {
2937 // Code for Social Login
2938 // Since v3.7.1.6 - The code has been shifted to the addon for user authentication
2939 require_once(ABSPATH . WPINC . '/user.php');
2940 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
2941 $email_add = isset($this->pie_post_array['user_email_social_site']) ? $this->pie_post_array['user_email_social_site'] : '';
2942 $user = apply_filters('piereg_user_from_social_login', $this->pie_post_array['log'], $email_add, $remember_user);
2943 } else {
2944 $piereg_secure_cookie = false;
2945 $piereg_secure_cookie = $this->PR_IS_SSL();
2946 if ($this->piereg_authentication($this->pie_post_array['log'], $this->pie_post_array['pwd'])) {
2947
2948 $user = wp_signon($creds, $piereg_secure_cookie);
2949
2950 if (!is_wp_error($user)) {
2951 $this->piereg_delete_authentication();
2952 }
2953 } else {
2954 if ($piereg_security_attempts_login_value) {
2955 $user = new WP_Error('piereg_authentication_failed', esc_html__("IP address blocked due to too many failed login attempts.", "pie-register"));
2956 }
2957 }
2958 }
2959
2960 if (is_wp_error($user)) {
2961 $user_login_error = $user->get_error_message();
2962 if (strpos(wp_strip_all_tags($user_login_error), 'Invalid username', 5) > 6 || strpos($user_login_error, 'field is empty') !== false || strpos($user_login_error, 'Unknown email') !== false || strpos($user_login_error, 'Unknown username') !== false) {
2963 $user_login_error = apply_filters('pie_invalid_username_password_msg_txt', '<strong>' . ucwords(esc_html__("error", "pie-register")) . '</strong>: ' . esc_html__("Invalid username or password", "pie-register") . '. <a href="' . esc_url($this->pie_lostpassword_url()) . '" title="' . esc_attr__("Reset your password", "pie-register") . '">' . esc_html__("Lost your password?", "pie-register") . '</a>');
2964 } else if (strpos(wp_strip_all_tags($user_login_error), 'password you entered', 9) > 10) {
2965 $user_login_error = apply_filters('pie_invalid_user_password_msg_txt', '<strong>' . ucwords(esc_html__("error", "pie-register")) . '</strong>: ' . esc_html__("Invalid username or password", "pie-register") . '. <a href="' . esc_url($this->pie_lostpassword_url()) . '" title="' . esc_attr__("Reset your password", "pie-register") . '">' . esc_html__("Lost your password?", "pie-register") . '</a>');
2966 }
2967 $errors->add('login-error', apply_filters("piereg_login_error", $user_login_error));
2968 if (isset($this->pie_post_array['piereg_login_after_registration']) && $option['login_after_register'] == 1) {
2969 $error_message = base64_encode(esc_html__("Invalid username", "pie-register"));
2970 wp_safe_redirect($this->pie_modify_custom_url($this->pie_login_url(), "pr_invalid_username=true&pr_key={$error_message}"));
2971 exit;
2972 }
2973 } else {
2974 $this->set_pr_stats("login", "used");
2975 if (in_array("administrator", (array)$user->roles)) {
2976
2977 /*
2978 * Add Since 2.0.13
2979 */
2980 if ($user) {
2981 wp_set_current_user($user->ID, $user->user_login);
2982 wp_set_auth_cookie($user->ID, $remember_user);
2983 do_action('wp_login', $user->user_login, $user);
2984 }
2985 do_action("piereg_admin_login_before_redirect_hook", $user);
2986
2987 $this->afterLoginPage();
2988 exit;
2989 } else {
2990
2991 # Hook before login from social login
2992 if (isset($this->pie_post_array['social_site']) && $this->pie_post_array['social_site'] == "true") {
2993 do_action('pie_register_after_social_login', $user);
2994 }
2995
2996 /*
2997 * Check User Expiry
2998 * Deprecate
2999 */
3000
3001 $active = get_user_meta($user->ID, "active", true);
3002
3003 //Delete User after grace Period
3004 if (!$this->deleteUsers($user->ID, $user->user_email, $user->user_registered)) {
3005 if ($active == "0") //If not active
3006 {
3007 wp_logout();
3008 $check_payment = get_option(OPTION_PIE_REGISTER);
3009
3010 // Payment Cycle Is Disabled In 3.0 Release.
3011 if ((($this->check_enable_payment_method()) == "true") && ("not" === "using")) {
3012 global $wpdb;
3013 $user_name_or_email = $this->pie_post_array['log'];
3014 $myrows = $wpdb->get_results($wpdb->prepare("SELECT ID,user_login,user_email FROM `{$wpdb->users}` where user_login = %s OR `user_email` = %s", $user_name_or_email, $user_name_or_email));
3015 if (isset($wpdb->last_error) && !empty($wpdb->last_error)) {
3016 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
3017 }
3018
3019 $errors->add('login-error', esc_html__('Please Renew your account. ', 'pie-register'));
3020 $this->pie_post_array['error'] = esc_html__('Please Renew your account', "pie-register");
3021 $auth_key = md5($myrows[0]->user_login);
3022 $user_name = trim($myrows[0]->user_login);
3023 update_user_meta($myrows[0]->ID, "pr_renew_account_hash", $auth_key);
3024
3025 $query_str = "pr_renew_account=true&auth=" . base64_encode((urlencode($user_name))) . "&auth_key=" . (urlencode($auth_key));
3026 $renew_account_url = $this->pie_modify_custom_url($this->pie_login_url($check_payment['alternate_login']), $query_str);
3027 $this->pie_ua_renew_account_url = $renew_account_url;
3028 if (
3029 isset($option['social_site_popup_setting'], $this->pie_post_array['social_site']) and
3030 $option['social_site_popup_setting'] == 1 and
3031 $this->pie_post_array['social_site'] == "true"
3032 ) {
3033 //Redirect will be triggered from js file now
3034 } else {
3035 wp_safe_redirect($renew_account_url);
3036 }
3037 exit;
3038 } else {
3039 $errors->add("login-error", apply_filters("piereg_your_account_is_not_active", esc_html__("Your account is not active", "pie-register")));
3040 }
3041 } elseif (empty($active)) {
3042 if ($user) {
3043 wp_set_current_user($user->ID, $user->user_login);
3044 wp_set_auth_cookie($user->ID, $remember_user);
3045 do_action('wp_login', $user->user_login, $user);
3046 }
3047
3048 do_action('pie_register_after_login', $user);
3049 do_action("piereg_user_login_before_redirect_hook", $user);
3050 $this->afterLoginPage();
3051 exit;
3052 } else {
3053 do_action('pie_register_after_login', $user);
3054
3055 // After Validation Show after login page.
3056 $option = get_option(OPTION_PIE_REGISTER);
3057 if (
3058 isset($option['social_site_popup_setting']) and
3059 $option['social_site_popup_setting'] == 1 and
3060 $this->pie_post_array['social_site'] == "true"
3061 ) {
3062 if ($user) {
3063 wp_set_current_user($user->ID, $user->user_login);
3064 wp_set_auth_cookie($user->ID, $remember_user);
3065 do_action('wp_login', $user->user_login, $user);
3066 }
3067
3068 do_action("piereg_user_login_before_redirect_hook", $user);
3069 $this->afterLoginPage();
3070 exit;
3071 } else {
3072 if ($user) {
3073 wp_set_current_user($user->ID, $user->user_login);
3074 wp_set_auth_cookie($user->ID, $remember_user);
3075 do_action('wp_login', $user->user_login, $user);
3076 }
3077
3078 do_action("piereg_user_login_before_redirect_hook", $user);
3079 $this->afterLoginPage();
3080 exit;
3081 }
3082 }
3083 }
3084 }
3085 }
3086 }
3087 }
3088 } else {
3089 $errors->add('login-error', apply_filters("piereg_something_went_wrong_msg", __('Something went wrong.', 'pie-register')));
3090 }
3091 }
3092 function piereg_authentication($log, $pwd)
3093 {
3094 //authenticate username and password
3095 $authenticate_user = wp_authenticate($log, $pwd);
3096 $option = get_option(OPTION_PIE_REGISTER);
3097
3098 return true;
3099 }
3100 function piereg_delete_authentication()
3101 {
3102 global $wpdb;
3103 $table_name = $wpdb->prefix . "pieregister_lockdowns";
3104 $user_ip = sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
3105 $wpdb->query($wpdb->prepare("DELETE FROM {$table_name} WHERE `user_ip` = %s AND `attempt_from` = 'is_login'", $user_ip));
3106 if (isset($wpdb->last_error) && !empty($wpdb->last_error)) {
3107 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
3108 }
3109 return true;
3110 }
3111 function pie_check_status_on_login($user, $password)
3112 {
3113 $errors = new WP_Error();
3114 if (! $user instanceof WP_User) {
3115 return $user;
3116 }
3117
3118 $status = get_user_meta($user->ID, "active", true);
3119
3120 if ($status == "0") {
3121 $message = apply_filters("piereg_your_account_is_not_active", esc_html__("Your account is not active", "pie-register"));
3122
3123 return new WP_Error('login-error', $message);
3124 }
3125
3126 return $user;
3127 }
3128 function piereg_validate_user_expiry_period_func($user)
3129 {
3130 /*
3131 * Check Payment Addons
3132 */
3133
3134 $is_active = get_user_meta($user->ID, "active", true);
3135 if (($this->check_enable_payment_method()) == "true" && $is_active == 1) {
3136 global $wpdb, $wp_session, $errors, $pr_wp_db_prefix;
3137 $datediff = (strtotime(date_i18n("Y-m-d H:m:s"))) - (strtotime($user->data->user_registered)); // current time - registeration time
3138 $datediff = floor($datediff / (86400)); //60*60*24 = 86400
3139 $pie_reg = get_option(OPTION_PIE_REGISTER);
3140 $user_id = $user->ID;
3141 $pricing_activation_cycle = 0;
3142 $user_payment_amount = "";
3143 $payment_activation_cycle = 0;
3144
3145 $piereg_pricing_key_number = get_user_meta($user_id, "piereg_pricing_key_number", true);
3146 $piereg_pricing_key_number = intval($piereg_pricing_key_number);
3147
3148 $user_registered_form_id = get_user_meta($user_id, "user_registered_form_id", true);
3149 $piereg_form_pricing_fields = get_option("piereg_form_pricing_fields");
3150 $piereg_use_starting_period = get_user_meta($user_id, "use_starting_period");
3151
3152 if (isset($piereg_form_pricing_fields["form_id_" . (intval($user_registered_form_id))]) && !empty($piereg_form_pricing_fields["form_id_" . (intval($user_registered_form_id))]) && empty($piereg_use_starting_period)) {
3153
3154 $piereg_pricing_fields = $piereg_form_pricing_fields["form_id_" . (intval($user_registered_form_id))];
3155
3156 $pricing_for = $piereg_pricing_fields['for'][$piereg_pricing_key_number];
3157 $pricing_for = intval($pricing_for);
3158 $pricing_for_period = $piereg_pricing_fields['for_period'][$piereg_pricing_key_number];
3159
3160 if (date_i18n('Y-m-d H:i:s', strtotime('+' . $pricing_for . ' ' . $pricing_for_period, strtotime($user->data->user_registered))) < date_i18n('Y-m-d H:i:s')) {
3161 update_user_meta($user->ID, 'use_starting_period', date_i18n('Y-m-d H:i:s'));
3162 $errors->add('login-error', esc_html__("Account suspended. Please renew account.", "pie-register"));
3163 update_user_meta($user->ID, 'active', 0);
3164 if ((isset($pie_reg['user_enable_user_temp_blocked_notice']) && $pie_reg['user_enable_user_temp_blocked_notice'] == 1))
3165 $this->wp_mail_send($user->data->user_email, "user_temp_blocked_notice");
3166 if ((isset($pie_reg['user_enable_user_renew_temp_blocked_account_notice']) && $pie_reg['user_enable_user_renew_temp_blocked_account_notice'] == 1))
3167 $this->wp_mail_send($user->data->user_email, 'user_renew_temp_blocked_account_notice');
3168 wp_logout();
3169 }
3170 } else {
3171 if (isset($piereg_form_pricing_fields["form_id_" . (intval($user_registered_form_id))]['activation_cycle']) && ((int)($piereg_form_pricing_fields["form_id_" . (intval($user_registered_form_id))]['activation_cycle'])) > 0) {
3172 $payment_activation_cycle = intval($piereg_form_pricing_fields["form_id_" . (intval($user_registered_form_id))]['activation_cycle']);
3173 } else {
3174 $payment_activation_cycle = intval($pie_reg['payment_setting_activation_cycle']);
3175 }
3176 }
3177
3178 if (($payment_activation_cycle) != 0) {
3179 $notice_period = ((int)$payment_activation_cycle) - ((int)$pie_reg['payment_setting_expiry_notice_days']);
3180 if ($datediff <= ((int)$payment_activation_cycle)) {
3181 $daysdiff = (intval($payment_activation_cycle) - $datediff);
3182 if ($daysdiff <= intval($pie_reg['payment_setting_expiry_notice_days'])) {
3183 $last_date = (strtotime(date_i18n("Y-m-d H:m:s")) + (86400 * (((int)$payment_activation_cycle) - $datediff)));
3184 $last_date = date_i18n("Y-m-d", $last_date);
3185 $email_variable = array();
3186 $email_variable['user_last_date'] = $last_date;
3187 if ((isset($pie_reg['user_enable_user_expiry_notice']) && $pie_reg['user_enable_user_expiry_notice'] == 1))
3188 $this->wp_mail_send($user->data->user_email, "user_expiry_notice", "", "", $email_variable);
3189 }
3190 } else {
3191 $errors->add('login-error', __("Account has been blocked.", "pie-register"));
3192 update_user_meta($user->ID, 'active', 0);
3193 if ((isset($pie_reg['user_enable_user_temp_blocked_notice']) && $pie_reg['user_enable_user_temp_blocked_notice'] == 1))
3194 $this->wp_mail_send($user->data->user_email, "user_temp_blocked_notice");
3195 if ((isset($pie_reg['user_enable_user_renew_temp_blocked_account_notice']) && $pie_reg['user_enable_user_renew_temp_blocked_account_notice'] == 1))
3196 $this->wp_mail_send($user->data->user_email, 'user_renew_temp_blocked_account_notice');
3197 wp_logout();
3198 }
3199 }
3200 }
3201 }
3202
3203 //Add the Settings and User Panels
3204 function AddPanel()
3205 {
3206 $update = get_option(OPTION_PIE_REGISTER);
3207
3208 $pie_page_suffix_1 = add_menu_page("Pie Register", esc_html__('Pie Register', 'pie-register'), 'piereg_manage_cap', 'pie-register', array($this, 'PieRegNewForm'), plugins_url("/assets/images/pr_icon.png", __FILE__), 60);
3209 add_action('admin_print_scripts-' . $pie_page_suffix_1, array($this, 'pieregister_admin_scripts_styles'));
3210
3211 $pie_page_suffix_2 = add_submenu_page('pie-register', 'Manage Forms', esc_html__('Manage Forms', "pie-register"), 'piereg_manage_cap', 'pie-register', array($this, 'PieRegNewForm'));
3212 add_action('admin_print_scripts-' . $pie_page_suffix_2, array($this, 'pieregister_admin_scripts_styles'));
3213 add_action('admin_print_scripts-' . $pie_page_suffix_2, array($this, 'pieregister_admin_scripts_styles_about_us_menu'));
3214
3215 do_action("piereg_add_addon_menu_profile_search");
3216
3217 $pie_page_suffix_3 = add_submenu_page('admin.php?page=pie-register', 'Manage Forms', esc_html__('New Form', "pie-register"), 'piereg_manage_cap', 'pr_new_registration_form', array($this, 'RegPlusEditForm'));
3218 add_action('admin_print_scripts-' . $pie_page_suffix_3, array($this, 'pieregister_ck_admin_scripts_styles'));
3219
3220 $pie_page_suffix_14 = add_submenu_page('pie-register', 'Notifications Setting', esc_html__('Email Notifications', "pie-register"), 'piereg_manage_cap', 'pie-notifications', array($this, 'PieRegNotifications'));
3221 add_action('admin_print_scripts-' . $pie_page_suffix_14, array($this, 'pieregister_ck_admin_scripts_styles'));
3222
3223 $pie_page_suffix_9 = add_submenu_page('pie-register', 'Invitation Codes', esc_html__('Invitation Codes', "pie-register"), 'piereg_manage_cap', 'pie-invitation-codes', array($this, 'PieRegInvitationCodes'));
3224 add_action('admin_print_scripts-' . $pie_page_suffix_9, array($this, 'pieregister_jquery_dialog_script'));
3225
3226 if (is_plugin_active('pie-register-aweber/pie-register-aweber.php') || is_plugin_active('pie-register-mailchimp/pie-register-mailchimp.php')) {
3227 // Restrict Users by username and ip address
3228 $pie_page_suffix_16 = add_submenu_page('pie-register', 'Marketing', esc_html__('Marketing', "pie-register"), 'piereg_manage_cap', 'pie-export-users', array($this, 'PieRegExportUsers'));
3229 add_action('admin_print_scripts-' . $pie_page_suffix_16, array($this, 'pieregister_rw_admin_scripts_styles'));
3230 }
3231
3232 // Add WooCommerce Menu in dashboard
3233 $all_plugins = get_plugins();
3234
3235 if ((!array_key_exists('pie-register-woocommerce/pie-register-woocommerce.php', $all_plugins)) || (!is_plugin_active('pie-register-woocommerce/pie-register-woocommerce.php')) || !$this->woocommerce_and_piereg_wc_addon_active) {
3236 $pie_page_suffix_24 = add_submenu_page('pie-register', 'WooCommerce', esc_html__('WooCommerce', "pie-register"), 'piereg_manage_cap', 'pie-woocommerce', array($this, 'PieWooCommerce'));
3237 add_action('admin_print_scripts-' . $pie_page_suffix_24, array($this, 'pieregister_admin_scripts_styles_addons_menu'));
3238 } else {
3239 $pie_page_suffix_21 = add_submenu_page('pie-register', 'WooCommerce', esc_html__('WooCommerce', "pie-register"), 'piereg_manage_cap', 'pie-woocommerce', array($this, 'PieRegWooCommerce'));
3240 add_action('admin_print_scripts-' . $pie_page_suffix_21, array($this, 'pieregister_rw_admin_scripts_styles'));
3241 }
3242
3243 $pie_page_suffix_18 = add_submenu_page('pie-register', 'Bulk Email', esc_html__('Bulk Email', "pie-register"), 'piereg_manage_cap', 'pie-bulkemail', array($this, 'PieRegBulkEmail'));
3244 add_action('admin_print_scripts-' . $pie_page_suffix_18, array($this, 'pieregister_admin_scripts_styles_addons_menu'));
3245
3246 /*
3247 * Add Add-ons menu in dashboard
3248 */
3249 do_action("piereg_add_addons_menu");
3250
3251 $pie_page_suffix_5 = add_submenu_page('pie-register', 'Payment Gateways Setting', esc_html__('Payment Gateways', "pie-register"), 'piereg_manage_cap', 'pie-gateway-settings', array($this, 'PieRegPaymentGateway'));
3252 add_action('admin_print_scripts-' . $pie_page_suffix_5, array($this, 'pieregister_admin_scripts_styles_go_pro_menu'));
3253
3254 $pie_page_suffix_6 = add_submenu_page('pie-register', 'Attachments', esc_html__('Attachments', "pie-register"), 'piereg_manage_cap', 'pie-attachments', array($this, 'PieRegAttachment'));
3255 add_action('admin_print_scripts-' . $pie_page_suffix_6, array($this, 'pieregister_fu_admin_scripts_styles'));
3256
3257 // Restrict Users by username and ip address
3258 $pie_page_suffix_15 = add_submenu_page('pie-register', 'User Control', esc_html__('User Control', "pie-register"), 'piereg_manage_cap', 'pie-black-listed-users', array($this, 'PieRegRestrictUsers'));
3259 add_action('admin_print_scripts-' . $pie_page_suffix_15, array($this, 'pieregister_rw_admin_scripts_styles'));
3260
3261 $pie_page_suffix_19 = add_submenu_page('pie-register', 'User Roles', esc_html__('User Roles', "pie-register"), 'piereg_manage_cap', 'pie-user-roles-custom', array($this, 'PieRegCustomRoles'));
3262 add_action('admin_print_scripts-' . $pie_page_suffix_19, array($this, 'pieregister_admin_scripts_styles'));
3263
3264 $pie_page_suffix_17 = add_submenu_page('pie-register', 'Settings', esc_html__('Settings', "pie-register"), 'piereg_manage_cap', 'pie-settings', array($this, 'PieRegSettings'));
3265 add_action('admin_print_scripts-' . $pie_page_suffix_17, array($this, 'pieregister_rw_admin_scripts_styles'));
3266
3267 $pie_page_suffix_8 = add_submenu_page('pie-register', 'Import/Export', esc_html__('Import/Export', "pie-register"), 'piereg_manage_cap', 'pie-import-export', array($this, 'PieRegImportExport'));
3268 add_action('admin_print_scripts-' . $pie_page_suffix_8, array($this, 'pieregister_admin_scripts_styles'));
3269
3270 add_filter('set-screen-option', array($this, 'pie_set_option'), 10, 3);
3271 $pie_page_suffix_11 = add_users_page('Unverified Users', esc_html__('Unverified Users', "pie-register"), 'edit_users', 'unverified-users', [$this, 'Unverified']);
3272 add_action('admin_print_scripts-' . $pie_page_suffix_11, array($this, 'pieregister_admin_scripts_styles'));
3273 add_action("load-$pie_page_suffix_11", array($this, 'pie_add_option'));
3274
3275 $pie_page_suffix_12 = add_submenu_page('pie-register', 'Help', esc_html__('Help', "pie-register"), 'piereg_manage_cap', 'pie-help', array($this, 'PieRegHelp'));
3276 add_action('admin_print_scripts-' . $pie_page_suffix_12, array($this, 'pieregister_admin_scripts_styles'));
3277
3278 // Added since v3.5.4
3279 $this->no_addon_activated = $this->anyAddonActivated();
3280
3281 if ($this->no_addon_activated) {
3282 $pie_page_suffix_14 = add_submenu_page('pie-register', 'Addons', '<span style="color: #82b3f1">' . esc_html__('Addons', "pie-register") . '</span>', 'piereg_manage_cap', 'pie-pro-features&tab=addons', array($this, 'PieRegProFeatures'));
3283 add_action('admin_print_scripts-' . $pie_page_suffix_14, array($this, 'pieregister_admin_scripts_styles_go_pro_menu'));
3284 }
3285
3286 if (!is_plugin_active('pie-register-social-site/pie-register-social-site.php')) {
3287 $pie_page_suffix_23 = add_submenu_page('pie-register', 'Social Login', esc_html__('Social Login', "pie-register"), 'piereg_manage_cap', 'pie-social-login', array($this, 'PieSocialLogin'));
3288 add_action('admin_print_scripts-' . $pie_page_suffix_23, array($this, 'pieregister_admin_scripts_styles_addons_menu'));
3289 }
3290
3291 if (!is_plugin_active('pie-register-twilio/pie-register-twilio.php')) {
3292 $pie_page_suffix_23 = add_submenu_page('pie-register', 'Twilio', esc_html__('Twilio', "pie-register"), 'piereg_manage_cap', 'pie-twilio', array($this, 'PieTwilio'));
3293 add_action('admin_print_scripts-' . $pie_page_suffix_23, array($this, 'pieregister_admin_scripts_styles_addons_menu'));
3294 }
3295
3296 if (!is_plugin_active('pie-register-mailchimp/pie-register-mailchimp.php')) {
3297 $pie_page_suffix_23 = add_submenu_page('pie-register', 'Marketing', esc_html__('Marketing', "pie-register"), 'piereg_manage_cap', 'pie-export-users', array($this, 'PieMailChimp'));
3298 add_action('admin_print_scripts-' . $pie_page_suffix_23, array($this, 'pieregister_admin_scripts_styles_addons_menu'));
3299 }
3300
3301 if (!is_plugin_active('pie-register-profile-search/pie-register-profile-search.php')) {
3302 $pie_page_suffix_23 = add_submenu_page('pie-register', 'Profile Search', esc_html__('Profile Search', "pie-register"), 'piereg_manage_cap', 'pie-profile-search', array($this, 'PieProfileSearch'));
3303 add_action('admin_print_scripts-' . $pie_page_suffix_23, array($this, 'pieregister_admin_scripts_styles_addons_menu'));
3304 }
3305
3306 if (!is_plugin_active('pie-register-geolocation/pie-register-geolocation.php')) {
3307 add_action('pie_register_geolocation_addon_page', array($this, 'PieGeoLocation'));
3308 }
3309
3310 $pie_page_suffix_13 = add_submenu_page('pie-register', 'Go Premium', '<span style="color: #82b3f1">' . esc_html__('Go Premium', "pie-register") . '</span>', 'piereg_manage_cap', 'pie-pro-features', array($this, 'PieRegProFeatures'));
3311 add_action('admin_print_scripts-' . $pie_page_suffix_13, array($this, 'pieregister_admin_scripts_styles_go_pro_menu'));
3312
3313 $pie_page_suffix_18 = add_submenu_page(
3314 'pie-register',
3315 'About Us',
3316 esc_html__('About Us', 'pie-register'),
3317 'piereg_manage_cap',
3318 'pie-about-us',
3319 array($this, 'PieAboutUs')
3320 );
3321 add_action('admin_print_scripts-' . $pie_page_suffix_18, array($this, 'pieregister_admin_scripts_styles_about_us_menu'));
3322 do_action('pie_register_add_menu');
3323 }
3324 function AddPanelOnAdminBar()
3325 {
3326 if (! $this->has_admin_bar_access()) {
3327 return;
3328 }
3329
3330 global $wp_admin_bar, $wpdb;
3331
3332 $pieregister_menu = array(
3333 array(
3334 "page" => "pie-register",
3335 "title" => "Manage Forms"
3336 ),
3337 array(
3338 "page" => "pie-notifications",
3339 "title" => "Email Notifications"
3340 ),
3341 array(
3342 "page" => "pie-invitation-codes",
3343 "title" => "Invitation Codes"
3344 ),
3345 array(
3346 "page" => "pie-settings",
3347 "title" => "Settings"
3348 ),
3349 array(
3350 "page" => "pie-help",
3351 "title" => "Help"
3352 ),
3353 array(
3354 "page" => "pie-about-us",
3355 "title" => esc_html__('About Us', 'pie-register')
3356 )
3357 );
3358
3359 $wp_admin_bar->add_menu(array(
3360 'id' => 'pie_register',
3361 'title' => esc_html__('Pie Register', 'pie-register'),
3362 'href' => get_admin_url() . 'admin.php?page=pie-register'
3363 ));
3364 foreach ($pieregister_menu as $pieregister_menu_items) {
3365 $wp_admin_bar->add_menu(
3366 array(
3367 'parent' => 'pie_register',
3368 'id' => $pieregister_menu_items['title'],
3369 'title' => $pieregister_menu_items['title'],
3370 'href' => get_admin_url() . 'admin.php?page=' . $pieregister_menu_items['page']
3371 )
3372 );
3373 }
3374 }
3375 function has_admin_bar_access()
3376 {
3377
3378 $access = false;
3379
3380 if (is_user_logged_in() && current_user_can('piereg_manage_cap')) {
3381 $access = true;
3382 }
3383
3384 return apply_filters('piereg_admin_adminbarmenu_has_access', $access);
3385 }
3386
3387 function pieregister_admin_scripts_styles()
3388 {
3389 //$this->pie_admin_enqueu_scripts();
3390 }
3391 function pieregister_admin_scripts_styles_go_pro_menu()
3392 {
3393 $this->pieregister_admin_scripts_styles();
3394 wp_enqueue_style("pie_go_pro_menu_css");
3395 }
3396 function pieregister_admin_scripts_styles_addons_menu()
3397 {
3398 $this->pieregister_admin_scripts_styles();
3399 wp_enqueue_style("pie_addons_menu_css");
3400 }
3401 function pieregister_admin_scripts_styles_about_us_menu()
3402 {
3403 wp_enqueue_style("pie_admin_about_us_menu_css");
3404 wp_enqueue_script("pie_admin_about_us_menu_js");
3405 $this->pieregister_admin_scripts_styles_slick();
3406
3407 wp_enqueue_style('pie_notification_css');
3408 wp_enqueue_script('pie_notification_js');
3409 }
3410 function piereg_invite_users()
3411 {
3412 wp_enqueue_style("pie_invite_users_css");
3413 }
3414 function pieregister_admin_scripts_styles_slick()
3415 {
3416 wp_enqueue_style("pie_admin_about_us_slick_css");
3417 wp_enqueue_script("pie_admin_about_us_slick_js");
3418 }
3419 function pieregister_ck_admin_scripts_styles()
3420 {
3421 //$this->pie_admin_enqueu_scripts();
3422 //wp_enqueue_editor();
3423 wp_enqueue_script("pie_ckeditor");
3424 wp_enqueue_script("pie_ckeditor_jquery_adapter");
3425 }
3426 function pieregister_rw_admin_scripts_styles()
3427 {
3428 //$this->pie_admin_enqueu_scripts();
3429 wp_enqueue_style("pie_restrict_widget_css");
3430 wp_enqueue_script("pie_restrict_widget_script");
3431 }
3432
3433 function pieregister_fu_admin_scripts_styles()
3434 {
3435 //$this->pie_admin_enqueu_scripts();
3436 wp_enqueue_style("pie_wload_css");
3437 wp_enqueue_script("pie_wload_js");
3438 }
3439
3440 function pieregister_jquery_dialog_script()
3441 {
3442 wp_enqueue_script('jquery-ui-dialog');
3443 $this->piereg_invite_users();
3444 }
3445
3446 function saveFields()
3447 {
3448 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
3449 if (isset($_POST['piereg_reg_form_nonce']) && wp_verify_nonce($_POST['piereg_reg_form_nonce'], 'piereg_wp_reg_form_nonce')) {
3450 if (isset($_POST['field']['form']['label']) && empty(trim($_POST['field']['form']['label']))) {
3451 $this->pie_post_array['error_message'] = esc_html__("Form title is required.", "pie-register");
3452 } else {
3453 $math_cpatcha_enable = "false";
3454 $piereg_startingDate = "1901";
3455 $piereg_endingDate = date_i18n("Y");
3456 $piereg_form_pricing_fields = get_option("piereg_form_pricing_fields");
3457 $piereg_form_pricing_fields_temp = array();
3458
3459 $this->pie_post_array['field'] = $this->piereg_sanitize_post_data('piereg_form_builder', ((isset($_POST['field']) && !empty($_POST['field'])) ? $_POST['field'] : array()));
3460 // var_dump($this->pie_post_array['field']);
3461 foreach ($this->pie_post_array['field'] as $k => $fv) {
3462
3463
3464 if (isset($fv['type']) && ($fv['type'] == 'math_captcha')) {
3465 $math_cpatcha_enable = "true";
3466 }
3467
3468 if (isset($fv['type']) && ($fv['type'] == 'submit')) {
3469 if (isset($fv["redirect_url"]) && !empty($fv["redirect_url"])) {
3470 $fv["redirect_url"] = preg_replace("/^www./i", "https://", $fv["redirect_url"]);
3471 }
3472 }
3473
3474 if ($fv['type'] == "aim" || $fv['type'] == "yim" || $fv['type'] == "jabber" || $fv['type'] == "description") {
3475 $fv['type'] = "default";
3476 }
3477
3478 //since 2.0.12
3479 if (isset($fv['type']) && ($fv['type'] == 'password')) {
3480 $meter_label_options = get_option(OPTION_PIE_REGISTER);
3481
3482 $meter_label_options['pass_strength_indicator_label'] = $fv['pass_strength_indicator_label'];
3483 $meter_label_options['pass_very_weak_label'] = $fv['pass_very_weak_label'];
3484 $meter_label_options['pass_weak_label'] = $fv['pass_weak_label'];
3485 $meter_label_options['pass_medium_label'] = $fv['pass_medium_label'];
3486 $meter_label_options['pass_strong_label'] = $fv['pass_strong_label'];
3487 $meter_label_options['pass_mismatch_label'] = $fv['pass_mismatch_label'];
3488
3489 update_option(OPTION_PIE_REGISTER, $meter_label_options);
3490 $this->set_pr_global_options($meter_label_options, OPTION_PIE_REGISTER);
3491 }
3492
3493 if (isset($fv['desc'])) {
3494 $fv['desc'] = $this->sanitize_field_options($fv['desc']);
3495 }
3496
3497 if (isset($fv['label'])) {
3498 $fv['label'] = $this->sanitize_field_options($fv['label']);
3499 }
3500
3501 if (isset($fv['validation_message'])) {
3502 $fv['validation_message'] = $this->sanitize_field_options($fv['validation_message']);
3503 }
3504
3505 if (isset($fv['css'])) {
3506 $fv['css'] = $this->sanitize_field_options($fv['css']);
3507 }
3508
3509 if (isset($fv['default_value'])) {
3510 $fv['default_value'] = $this->sanitize_field_options($fv['default_value']);
3511 }
3512
3513 if (isset($fv['placeholder'])) {
3514 $fv['placeholder'] = $this->sanitize_field_options($fv['placeholder']);
3515 }
3516
3517 if (isset($fv['type']) && ($fv['type'] == 'date')) {
3518 $pattern = '/[0-9]{4}/';
3519 $subject = isset($fv['startingDate']) ? $fv['startingDate'] : "";
3520 if (
3521 ((isset($fv['startingDate']) && strlen($fv['startingDate']) == 4) && preg_match($pattern, $subject)) &&
3522 (intval($fv['startingDate']) <= intval($fv['endingDate']))
3523 ) {
3524 $fv['startingDate'] = $fv['startingDate'];
3525 $piereg_startingDate = $fv['startingDate'];
3526 } else {
3527 $fv['startingDate'] = "1901";
3528 $piereg_startingDate = "1900";
3529 }
3530
3531 $subject = isset($fv['endingDate']) ? $fv['endingDate'] : "";
3532 if (
3533 ((isset($fv['endingDate']) && strlen($fv['endingDate']) == 4) && preg_match($pattern, $subject)) &&
3534 (intval($fv['endingDate']) >= intval($fv['startingDate']))
3535 ) {
3536 $fv['endingDate'] = $fv['endingDate'];
3537 $piereg_endingDate = $fv['endingDate'];
3538 } else {
3539 $fv['endingDate'] = date_i18n("Y");
3540 $piereg_endingDate = date_i18n("Y");
3541 }
3542 }
3543
3544 if (isset($fv['type']) && ($fv['type'] == "pricing" && "not" == "required")) {
3545 $piereg_form_pricing_fields_temp = $fv;
3546
3547 foreach ($fv['starting_price'] as $starting_price_key => $starting_price_val) {
3548 $fv['starting_price'][$starting_price_key] = sprintf('%0.2f', $starting_price_val);
3549 }
3550
3551 foreach ($fv['then_price'] as $then_price_key => $then_price_val) {
3552 $fv['then_price'][$then_price_key] = sprintf('%0.2f', $then_price_val);
3553 }
3554 }
3555 $updated_post[$k] = $fv;
3556 }
3557 if (!$this->pie_post_array['field'])
3558 $this->pie_post_array['field'] = get_option('pie_fields_default');
3559
3560 do_action("pie_fields_save");
3561 update_option("pie_fields", serialize($updated_post));
3562
3563 /*modify code for multiple registration form*/
3564 if (isset($_POST['form_id']) and intval(base64_decode($_POST['form_id'])) != 0 and isset($_POST['page']) and $_POST['page'] == "edit") {
3565 $fields_id = intval(base64_decode($_POST['form_id']));
3566
3567 // update fields
3568 update_option("piereg_form_fields_" . $fields_id, serialize($updated_post));
3569 $piereg_form_pricing_fields["form_id_" . $fields_id] = $piereg_form_pricing_fields_temp;
3570 update_option("piereg_form_pricing_fields", $piereg_form_pricing_fields);
3571
3572 // update user role
3573 $options = get_option(OPTION_PIE_REGISTER);
3574 $options['pie_regis_set_user_role_' . $fields_id] = sanitize_key($_POST['set_user_role_']);
3575 $options['piereg_startingDate_' . $fields_id] = $piereg_startingDate;
3576 $options['piereg_endingDate_' . $fields_id] = $piereg_endingDate;
3577
3578 // sync form fields with profile search forms
3579 $pie_ps_form_id = isset($options['piereg_profile_search_form_id']) ? $options['piereg_profile_search_form_id'] : "";
3580 if (!empty($pie_ps_form_id) && $pie_ps_form_id == $fields_id) {
3581
3582 $match_form_fields = array();
3583 foreach ($updated_post as $updated_posts) {
3584 if (!isset($updated_posts['label']))
3585 $updated_posts['label'] = "";
3586
3587 if ($updated_posts['type'] == 'name') {
3588 $first_name = strtolower(str_replace(' ', '_', $updated_posts['label']));
3589 $match_form_fields[$first_name . '+:+' . $updated_posts['label']] = $updated_posts['label'];
3590 $last_name = strtolower(str_replace(' ', '_', $updated_posts['label2']));
3591 $match_form_fields[$last_name . '+:+' . $updated_posts['label']] = $updated_posts['label'];
3592 } elseif ($updated_posts['type'] == 'username') {
3593 $username = str_replace(' ', '_', $updated_posts['type']);
3594 $match_form_fields[$username . '+:+' . $updated_posts['label']] = $updated_posts['label'];
3595 } elseif ($updated_posts['type'] == 'email') {
3596 $email = str_replace(' ', '_', $updated_posts['type']);
3597 $match_form_fields[$email . '+:+' . $updated_posts['label']] = $updated_posts['label'];
3598 } elseif ($updated_posts['type'] != 'math_captcha' && $updated_posts['type'] != 'captcha' && $updated_posts['type'] != 'password' && $updated_posts['type'] != 'form' && $updated_posts['type'] != 'submit' && $updated_posts['type'] != 'upload') {
3599 $other_field = 'pie_' . str_replace(' ', '_', $updated_posts['type']) . '_' . $updated_posts['id'];
3600 $match_form_fields[$other_field . '+:+' . $updated_posts['label']] = $updated_posts['label'];
3601 }
3602 }
3603
3604 foreach ($options['piereg_ps_psv_fields_label'] as $ps_fields_array) {
3605 if (!empty($ps_fields_array)) {
3606 foreach ($ps_fields_array as $key_array => $ps_fields_arr) {
3607 foreach ($ps_fields_arr as $key => $ps_fields) {
3608 if ($key != 'full_name' && $key != 'registered') {
3609 $key_check = $key . '+:+' . $ps_fields;
3610 if (!array_key_exists($key_check, $match_form_fields)) {
3611 unset($ps_fields_arr[$key]);
3612 }
3613 }
3614 }
3615 $ps_fields_ar[$key_array] = $ps_fields_arr;
3616 }
3617 }
3618 }
3619
3620 if (!empty($ps_fields_ar)) {
3621 if (empty($ps_fields_ar[1]) && array_key_exists(1, $ps_fields_ar)) {
3622 unset($ps_fields_ar[1]);
3623 } elseif (empty($ps_fields_ar[2]) && array_key_exists(2, $ps_fields_ar)) {
3624 unset($ps_fields_ar[2]);
3625 } elseif (empty($ps_fields_ar[3]) && array_key_exists(3, $ps_fields_ar)) {
3626 unset($ps_fields_ar[3]);
3627 }
3628 $ps_fields_a[$pie_ps_form_id] = $ps_fields_ar;
3629 $options['piereg_ps_psv_fields_label'] = $ps_fields_a;
3630 }
3631 }
3632
3633 // Update Wordpress Drefault User Role
3634 update_option(OPTION_PIE_REGISTER, $options);
3635 //update form title
3636 $_field['Id'] = intval($fields_id);
3637 $_field = get_option("piereg_form_field_option_" . $fields_id);
3638 $_field['Title'] = trim($this->pie_post_array['field']['form']['label']);
3639 update_option("piereg_form_field_option_" . $fields_id, $_field);
3640 }
3641 $this->pie_post_array['success_message'] = esc_html__("Settings Saved", "pie-register");
3642 }
3643 } else {
3644 $this->pie_post_array['error_message'] = esc_html__("Invalid nonce.", "pie-register");
3645 }
3646 }
3647
3648 function pieregister_login()
3649 {
3650 $option = get_option(OPTION_PIE_REGISTER);
3651 if ($option['allow_pr_edit_wplogin'] == 1) {
3652 global $errors;
3653 if (isset($_REQUEST['action'])) :
3654 $action = sanitize_key($_REQUEST['action']);
3655 else :
3656 $action = 'login';
3657 endif;
3658 switch ($action):
3659 case 'lostpassword':
3660 case 'retrievepassword':
3661 $this->process_lostpassword();
3662 break;
3663 case 'resetpass':
3664 case 'rp':
3665 $this->process_getpassword();
3666 break;
3667 case 'register':
3668 $this->process_register_form();
3669 case 'login':
3670 default:
3671 $this->process_login_form();
3672 break;
3673 endswitch;
3674 exit;
3675 }
3676 return false;
3677 }
3678 function process_register_form()
3679 {
3680
3681 global $errors;
3682
3683 $form = new Registration_form();
3684 $success = '';
3685
3686 get_header();
3687 //Printing Success Message
3688 echo wp_kses($this->outputRegForm("true", "true"), $this->piereg_forms_get_allowed_tags());
3689 $this->set_pr_stats("register", "view");
3690 get_footer();
3691
3692 exit;
3693 }
3694
3695 function check_register_form()
3696 {
3697 global $errors, $wp_session, $piereg_post_array;
3698 $option = get_option(OPTION_PIE_REGISTER);
3699
3700 if ($this->check_enable_payment_method() == "false") {
3701 $this->pie_save_registration();
3702 } else if (($this->check_enable_payment_method()) == "true") {
3703 $pricing_key_number = 0;
3704 $pricing_payment_amount = 0;
3705 if (isset($_POST['pricing'])) {
3706 $piereg_form_pricing_fields = get_option("piereg_form_pricing_fields");
3707 foreach ($piereg_form_pricing_fields['form_id_' . intval($_POST['form_id'])]['display'] as $pricing_key => $pricing_value) {
3708 if ($pricing_value == $_POST['pricing']) {
3709 $pricing_key_number = $pricing_key;
3710 break;
3711 }
3712 }
3713 $pricing_payment_amount = $piereg_form_pricing_fields['form_id_' . intval($_POST['form_id'])]["starting_price"][$pricing_key_number];
3714 }
3715
3716 if (
3717 (isset($_POST['select_payment_method']) and trim($_POST['select_payment_method']) != "" and $_POST['select_payment_method'] != "select")
3718 //|| ($pricing_payment_amount <= 0)
3719 ) {
3720 if ((isset($_POST['select_payment_method']) && ($_POST['select_payment_method'] == 'stripe')) && (isset($_POST['error_stripe']) && $_POST['error_stripe'] != "")) {
3721 $this->pie_post_array['error'] = sanitize_text_field($_POST['error_stripe']);
3722 } else if ((isset($_POST['select_payment_method']) && ($_POST['select_payment_method'] == 'authorizeNet')) && (isset($_POST['error_authorizeNet']) && $_POST['error_authorizeNet'] != "")) {
3723 $this->pie_post_array['error'] = sanitize_text_field($_POST['error_authorizeNet']);
3724 } else {
3725 $this->pie_save_registration();
3726 }
3727 } else if (isset($_POST['select_payment_method']) && (empty($_POST['select_payment_method']) || $_POST['select_payment_method'] == "select")) {
3728 $this->pie_post_array['error'] = esc_html__("Please select a payment method", "pie-register");
3729 } else {
3730 $this->pie_save_registration();
3731 }
3732 } else if (trim($wp_session['payment_error']) != "") {
3733 $this->pie_post_array['error'] = esc_html($wp_session['payment_error']);
3734 $wp_session['payment_error'] = "";
3735 $wp_session['payment_success'] = "";
3736 }
3737
3738 $piereg_post_array = $this->pie_post_array;
3739 }
3740 function piereg_generate_username($email = "", $is_generate_username = false, $username_prifex = "")
3741 {
3742 if ($is_generate_username && !isset($_POST['username'])) {
3743 $username = "";
3744 while (1) {
3745 $username = strtolower((!empty($username_prifex) ? $username_prifex . "_" : "") . wp_generate_password(7, false, false));
3746 if (!username_exists($username)) {
3747 break;
3748 }
3749 }
3750 $_POST['username'] = sanitize_user(trim($username));
3751 } else if (isset($_POST['e_mail'], $email) && !empty($_POST['e_mail']) && !isset($_POST['username']))
3752 $_POST['username'] = sanitize_email($_POST['e_mail']);
3753 else if (!isset($_POST['username']))
3754 $this->piereg_generate_username("", true);
3755 }
3756 function pie_save_registration()
3757 {
3758
3759 $form_id = 0;
3760
3761 if (isset($_POST['form_id']) && intval($_POST['form_id']) > 0) {
3762 $form_id = intval($_POST['form_id']);
3763 } else {
3764 global $errors;
3765 $errors = new WP_Error();
3766 $errors->add("registration-error", "Invalid Form");
3767 return false;
3768 }
3769
3770 $this->piereg_generate_username(sanitize_email($_POST['e_mail']), apply_filters("piereg_generate_unique_username", false), apply_filters("piereg_generate_username_with_prifex", false));
3771
3772 add_filter('wp_mail_content_type', array($this, 'set_html_content_type'));
3773 global $errors;
3774 $form = new Registration_form($form_id);
3775 $errors = $form->validateRegistration($errors);
3776 $option = get_option(OPTION_PIE_REGISTER);
3777
3778 do_action('pie_register_before_register_validate');
3779
3780 $option_user_verification = $form->piereg_get_verification_type($form->data);
3781
3782 if (sizeof($errors->errors) == 0) {
3783 do_action('pie_register_after_register_validate');
3784 global $piereg_post_array, $wp_session;
3785
3786 /**
3787 * Since version 3.6.14
3788 * Removed strtolower from $_POST['e_mail']
3789 */
3790
3791 //Inserting User
3792 $pass = isset($_POST['password']) && !empty($_POST['password']) ? html_entity_decode($_POST['password']) : '';
3793 $user_data = array(
3794 'user_pass' => $pass,
3795 'user_login' => sanitize_user($_POST['username']),
3796 'user_email' => sanitize_email($_POST['e_mail']),
3797 'user_registered' => date_i18n("Y-m-d H:i:s"),
3798 'role' => get_option('default_role')
3799 );
3800
3801 if (isset($_POST['first_name']) && !empty($_POST['first_name'])) {
3802 $display_name = sanitize_text_field($_POST['first_name']) . ((isset($_POST['last_name']) && !empty($_POST['last_name'])) ? " " . sanitize_text_field($_POST['last_name']) : "");
3803 $user_data['display_name'] = $display_name;
3804 $user_data['user_nicename'] = $display_name;
3805 }
3806
3807 if (isset($_POST['url'])) {
3808 $user_data["user_url"] = esc_url_raw($_POST['url']);
3809 }
3810
3811 $this->set_pr_stats("register", "used");
3812 $user_id = wp_insert_user($user_data);
3813
3814 $email_user_password = false;
3815
3816 if (empty($pass)) {
3817 $email_user_password = true;
3818 update_user_meta($user_id, "email_user_password", $email_user_password);
3819 }
3820 /*
3821 * Check Pricing
3822 */
3823 $pricing_user_role = "";
3824 $pricing_key_number = 0;
3825 $pricing_payment_amount = 0;
3826 $pricing_activation_cycle = 0;
3827 $piereg_form_pricing_fields = "";
3828
3829 if (isset($_POST['pricing'])) {
3830 $piereg_form_pricing_fields = get_option("piereg_form_pricing_fields");
3831 foreach ($piereg_form_pricing_fields['form_id_' . intval($form_id)]['display'] as $pricing_key => $pricing_value) {
3832 if ($pricing_value == $_POST['pricing']) {
3833 $pricing_key_number = $pricing_key;
3834 break;
3835 }
3836 }
3837 $pricing_user_role = $piereg_form_pricing_fields['form_id_' . intval($form_id)]["role"][$pricing_key_number];
3838 $pricing_payment_amount = $piereg_form_pricing_fields['form_id_' . intval($form_id)]["starting_price"][$pricing_key_number];
3839 $pricing_activation_cycle = ((intval($piereg_form_pricing_fields['form_id_' . intval($form_id)]["activation_cycle"][$pricing_key_number]) >= 0) ? intval($piereg_form_pricing_fields['form_id_' . intval($form_id)]["activation_cycle"][$pricing_key_number]) : intval($option['payment_setting_activation_cycle']));
3840 } else {
3841 $pricing_payment_amount = $option['payment_setting_amount'];
3842 $pricing_activation_cycle = (isset($option['payment_setting_activation_cycle'])) ? $option['payment_setting_activation_cycle'] : "";
3843 }
3844 /***** End Pricing *****/
3845 $form->addUser($user_id, $form_id);
3846
3847 # If user choose to add in mailchimp list.
3848 if (isset($_POST['checkbox_add_to_mailchimp']) && !empty($_POST['checkbox_add_to_mailchimp'])) {
3849 update_user_meta($user_id, 'pie_checkbox_add_to_mailchimp', wp_kses_post($_POST['checkbox_add_to_mailchimp']));
3850 }
3851
3852 /*
3853 * Update Nickname User Meta
3854 */
3855 if (isset($_POST['first_name']) && !empty($_POST['first_name'])) {
3856 update_user_meta($user_id, 'nickname', (sanitize_text_field($_POST['first_name']) . ((isset($_POST['last_name']) && !empty($_POST['last_name'])) ? " " . sanitize_text_field($_POST['last_name']) : "")));
3857 }
3858 $new_role = 'subscriber';
3859 if (intval($_POST['form_id']) != 0) {
3860 $new_role = ($option['pie_regis_set_user_role_' . intval($form_id)]); // Till v3.0.8 using strtolower()
3861 $new_role = ($new_role != "") ? $new_role : 'subscriber';
3862 $form_options = get_option("piereg_form_field_option_" . intval($form_id));
3863 $form_options['Entries'] = intval($form_options['Entries']) + 1;
3864 update_option("piereg_form_field_option_" . intval($form_id), $form_options);
3865 unset($form_options);
3866 } else {
3867 if (isset($option['pie_regis_set_user_role_']) and trim($option['pie_regis_set_user_role_']) != "") {
3868 $new_role = strtolower($option['pie_regis_set_user_role_']);
3869 $new_role = ($new_role != "") ? $new_role : 'subscriber';
3870 }
3871 }
3872 // dropdown_ur
3873 if (isset($_POST['custom_role']) && !empty($_POST['custom_role'])) {
3874 $field_options = get_option("pie_fields");
3875 $field_options = maybe_unserialize($field_options);
3876 foreach ($field_options as $field_key) {
3877 if ($field_key['type'] == 'custom_role') {
3878 foreach ($field_key['value'] as $key => $value) {
3879 if ($value == $_POST['custom_role']) {
3880 $new_role = $field_key['role_selection'][$key];
3881 // update_user_meta($user_id, "custom_role", $new_role);
3882 break;
3883 }
3884 }
3885 break;
3886 }
3887 }
3888 }
3889
3890 /*
3891 * Add Pricing Role
3892 */
3893 $new_role = ((isset($pricing_user_role) && !empty($pricing_user_role)) ? trim($pricing_user_role) : $new_role);
3894 //// update user role using wordpress function
3895 wp_update_user(array('ID' => $user_id, 'role' => $new_role));
3896 update_user_meta($user_id, "is_social", "false", $unique = false);
3897 update_user_meta($user_id, "social_site_name", "", $unique = false);
3898 update_user_meta($user_id, "user_registered_form_id", ((int)$form_id));
3899 /*
3900 * User Meta for Pricing
3901 */
3902 update_user_meta($user_id, "piereg_pricing_key_number", $pricing_key_number);
3903 update_user_meta($user_id, "piereg_pricing_payment_amount", $pricing_payment_amount);
3904 update_user_meta($user_id, "piereg_pricing_user_role", $pricing_user_role);
3905 update_user_meta($user_id, "piereg_pricing_activation_cycle", $pricing_activation_cycle);
3906
3907 $user = new WP_User($user_id);
3908
3909 /*
3910 * Add pricing variables in user object
3911 */
3912 $user_array = (array) $user;
3913 $user_array['piereg_pricing']['pricing_key_number'] = $pricing_key_number;
3914 $user_array['piereg_pricing']['pricing_payment_amount'] = $pricing_payment_amount;
3915 $user = (object) $user_array;
3916
3917 do_action('pie_register_after_user_created', $user);
3918
3919 ///////////////////////////////////////////////////
3920 /******** Admin Notification *******/
3921 if ($option_user_verification == 0 || $option_user_verification == 2 || $option_user_verification == 4) {
3922 $this->send_admin_notifications($option, $user, $pass);
3923 }
3924 ////////////////////////////////////////////////////
3925
3926 // until multiple payment gateways release we use this variable to get away with multiple gateway process
3927 $isPayPalStandard = false;
3928 if (isset($_POST['select_payment_method']) && $_POST['select_payment_method'] == 'PaypalStandard') {
3929 $isPayPalStandard = true;
3930 }
3931
3932 if ('recurring' == 'enable')
3933 $checkStartPayment = true;
3934 else
3935 $checkStartPayment = false;
3936
3937 if ($isPayPalStandard == false && isset($user_array['piereg_pricing']['pricing_payment_amount']) && floatval($user_array['piereg_pricing']['pricing_payment_amount']) <= 0) {
3938 $checkStartPayment = false;
3939 }
3940
3941
3942 /*Goto payment method Like check_payment_method_paypal*/
3943 if ($isPayPalStandard == false && $this->check_enable_payment_method() == "true" && ($checkStartPayment || isset($_POST['select_payment_method']))) {
3944
3945 if ($_POST['select_payment_method'] == "stripe" || $_POST['select_payment_method'] == "authorizeNet") {
3946 update_user_meta($user_id, 'register_type', "payment_verify");
3947 $_POST['user_id'] = $user_id;
3948 update_user_meta($user_id, 'active', 0);
3949 /*
3950 * trigger Wordpress "user_register" hook
3951 */
3952
3953 do_action("user_register", $user_id);
3954 do_action("check_payment_method_" . sanitize_text_field($_POST['select_payment_method']), $user); // function prefix check_payment_method_
3955
3956 // If payment failed
3957 if (!empty($_POST['error'])) {
3958 $this->pie_post_array['payment_failed'] = 1;
3959 $this->pie_post_array['error'] = sanitize_text_field($_POST['error']);
3960 }
3961
3962 // If payment success
3963 if (!empty($_POST['success'])) $this->pie_post_array['success'] = sanitize_text_field($_POST['success']);
3964 }
3965
3966 if ((($this->check_enable_payment_method()) == "true" and !isset($_POST['select_payment_method']) and isset($_POST['pricing'])) or
3967 (isset($_POST['select_payment_method']) and $_POST['select_payment_method'] == "" or $_POST['select_payment_method'] == "select")
3968 ) {
3969 $this->pie_post_array['error'] = esc_html__("Please select a payment method", "pie-register");
3970 }
3971 } else if (
3972 $isPayPalStandard == true && (!(empty($option['paypal_butt_id'])) && $option['enable_paypal'] == 1)
3973 /*&&
3974 ( $option['enable_authorize_net'] != 1 &&
3975 $option['enable_2checkout'] != 1 &&
3976 $option['enable_PaypalPro'] != 1 &&
3977 $option['enable_PaypalExp'] != 1 &&
3978 $option['enable_Skrill'] != 1 )*/
3979 ) {
3980 $_POST['user_id'] = $user_id;
3981 update_user_meta($user_id, 'active', 0);
3982 update_user_meta($user_id, 'register_type', "payment_verify");
3983 do_action("user_register", $user_id); // temp
3984
3985 do_action("check_payment_method_paypal", $user); // function prefix check_payment_method_
3986 } else if ($option_user_verification == 1) //Admin Verification
3987 {
3988 update_user_meta($user_id, 'active', 0);
3989 $admin_hash = wp_generate_password(32, false);
3990 update_user_meta($user_id, 'admin_hash', $admin_hash);
3991 update_user_meta($user_id, 'register_type', "admin_verify");
3992
3993 $this->send_admin_notifications($option, $user, $pass);
3994
3995 $subject = html_entity_decode($option['user_subject_email_admin_verification'], ENT_COMPAT, "UTF-8");
3996 $subject = $this->filterSubject($user, $subject);
3997 $message_temp = "";
3998 if ($option['user_formate_email_admin_verification'] == "0") {
3999 $message_temp = nl2br(wp_strip_all_tags($option['user_message_email_admin_verification']));
4000 } else {
4001 $message_temp = $option['user_message_email_admin_verification'];
4002 }
4003 $message = $form->filterEmail($message_temp, $user);
4004 $from_name = html_entity_decode($option['user_from_name_admin_verification'], ENT_COMPAT, "UTF-8");
4005 $from_email = $option['user_from_email_admin_verification'];
4006 $reply_email = $option['user_to_email_admin_verification'];
4007
4008 //Headers
4009 $headers = 'MIME-Version: 1.0' . "\r\n";
4010 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4011
4012 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
4013 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
4014 if ($reply_email) {
4015 $headers .= "Reply-To: {$reply_email}\r\n";
4016 $headers .= "Return-Path: {$reply_email}\r\n";
4017 } else {
4018 $headers .= "Reply-To: {$from_email}\r\n";
4019 $headers .= "Return-Path: {$from_email}\r\n";
4020 }
4021
4022 if ((isset($option['user_enable_admin_verification']) && $option['user_enable_admin_verification'] == 1) && !wp_mail(sanitize_email($_POST['e_mail']), $subject, $message, $headers)) {
4023 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
4024 }
4025 $this->pie_post_array['registration_success'] = apply_filters("piereg_thank_you_for_your_registration_admin_veri", __("Thank you for submitting a registration request. An email will be sent when the administrator has reviewed the request.", 'pie-register'));
4026 } else if ($option_user_verification == 2) //E-Mail Link Verification
4027 {
4028 update_user_meta($user_id, 'active', 0);
4029 $hash = wp_generate_password(32, false);
4030 update_user_meta($user_id, 'hash', $hash);
4031 update_user_meta($user_id, 'register_type', "email_verify");
4032
4033 $subject = html_entity_decode($option['user_subject_email_email_verification'], ENT_COMPAT, "UTF-8");
4034 $subject = $this->filterSubject($user, $subject);
4035 $message_temp = "";
4036 if ($option['user_formate_email_email_verification'] == "0") {
4037 $message_temp = nl2br(wp_strip_all_tags($option['user_message_email_email_verification']));
4038 } else {
4039 $message_temp = $option['user_message_email_email_verification'];
4040 }
4041 $message = $form->filterEmail($message_temp, $user, $pass);
4042 $from_name = html_entity_decode($option['user_from_name_email_verification'], ENT_COMPAT, "UTF-8");
4043 $from_email = $option['user_from_email_email_verification'];
4044 $reply_email = $option['user_to_email_email_verification'];
4045
4046 //Headers
4047 $headers = 'MIME-Version: 1.0' . "\r\n";
4048 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4049
4050
4051 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
4052 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
4053 if ($reply_email) {
4054 $headers .= "Reply-To: {$reply_email}\r\n";
4055 $headers .= "Return-Path: {$reply_email}\r\n";
4056 } else {
4057 $headers .= "Reply-To: {$from_email}\r\n";
4058 $headers .= "Return-Path: {$from_email}\r\n";
4059 }
4060
4061 if ((isset($option['user_enable_email_verification']) && $option['user_enable_email_verification'] == 1) && !wp_mail(sanitize_email($_POST['e_mail']), $subject, $message, $headers)) {
4062 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
4063 }
4064 $this->pie_post_array['registration_success'] = apply_filters("piereg_thank_you_for_your_registration_email_veri", esc_html__("Thank you for submitting a registration request. An email has been sent to verify the email address.", 'pie-register'));
4065 } else if ($option_user_verification == 0 || $option_user_verification == 4) //No verification required
4066 {
4067 add_filter('send_password_change_email', '__return_false');
4068 update_user_meta($user_id, 'active', 1);
4069
4070 $subject = html_entity_decode($option['user_subject_email_default_template'], ENT_COMPAT, "UTF-8");
4071 $subject = $this->filterSubject($user, $subject);
4072 $user_pass = $email_user_password ? apply_filters('piereg_email_random_generated_password', wp_generate_password()) : "";
4073 if (!empty($user_pass)) {
4074 $user_data = array('ID' => $user_id, 'user_pass' => trim($user_pass));
4075 wp_update_user($user_data);
4076 }
4077 $message_temp = "";
4078 if ($option['user_formate_email_default_template'] == "0") {
4079 $message_temp = (wp_strip_all_tags($option['user_message_email_default_template']));
4080 } else {
4081 $message_temp = $option['user_message_email_default_template'];
4082 }
4083 $message = $form->filterEmail($message_temp, $user, $user_pass);
4084 $from_name = html_entity_decode($option['user_from_name_default_template'], ENT_COMPAT, "UTF-8");
4085 $from_email = $option['user_from_email_default_template'];
4086 $reply_email = $option['user_to_email_default_template'];
4087
4088 //Headers
4089 $headers = 'MIME-Version: 1.0' . "\r\n";
4090 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4091
4092 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) { //Validating From
4093 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
4094 }
4095 if ($reply_email) {
4096 $headers .= "Reply-To: {$reply_email}\r\n";
4097 $headers .= "Return-Path: {$reply_email}\r\n";
4098 } else {
4099 $headers .= "Reply-To: {$from_email}\r\n";
4100 $headers .= "Return-Path: {$from_email}\r\n";
4101 }
4102
4103 if ((isset($option['user_enable_default_template']) && $option['user_enable_default_template'] == 1) && !wp_mail(sanitize_email($_POST['e_mail']), $subject, $message, $headers)) {
4104 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
4105 }
4106 }
4107
4108 if (!isset($this->pie_post_array['payment_failed'])) {
4109 /*
4110 * trigger Wordpress "user_register" hook
4111 */
4112 do_action("user_register", $user->ID);
4113 do_action('pie_register_after_register', $user);
4114 /*
4115 * User Verification and payment methods are off then Trigger Login After Registration Hook
4116 */
4117
4118 if (($option_user_verification == 0 || $option_user_verification == 4) && $this->check_enable_payment_method() == "false") {
4119 do_action('pie_register_login_after_registration', $user);
4120 }
4121 }
4122 $fields = maybe_unserialize(get_option("pie_fields"));
4123 $confirmation_type = $form->data['submit']['confirmation'];
4124
4125 if (isset($wp_session['payment_error']) && trim($wp_session['payment_error']) != "") {
4126 $this->pie_post_array['error'] = esc_html($wp_session['payment_error']);
4127 $wp_session['payment_error'] = "";
4128 $wp_session['payment_success'] = "";
4129 } else if (isset($this->pie_post_array['payment_failed']) && $this->pie_post_array['payment_failed'] == 1) {
4130 $this->pie_post_array['error'] = $this->pie_post_array['error'];
4131 } else if (isset($wp_session['payment_success']) && trim($wp_session['payment_success']) != "") {
4132 $this->pie_post_array['registration_success'] = apply_filters("piereg_payment_success", $wp_session['payment_success']);
4133 $wp_session['payment_error'] = "";
4134 $wp_session['payment_success'] = "";
4135 } else if ($confirmation_type == "" || $confirmation_type == "text") {
4136 if (empty($this->pie_post_array['registration_success'])) {
4137 $email_user_password = get_user_meta($user_id, "email_user_password", true);
4138 if ($email_user_password == '1') {
4139 $this->pie_post_array['registration_success'] = esc_html__("Thank you for registering. Password has been emailed to you.", "pie-register");
4140 } else {
4141 $this->pie_post_array['registration_success'] = stripcslashes(esc_html($form->data['submit']['message']));
4142 }
4143 }
4144 } else if ($confirmation_type == "page") {
4145 wp_safe_redirect(get_permalink($form->data['submit']['page']));
4146 exit;
4147 } else if ($confirmation_type == "redirect") {
4148 wp_safe_redirect(esc_url_raw($form->data['submit']['redirect_url']));
4149 exit;
4150 } else {
4151 if (empty($this->pie_post_array['registration_success']))
4152 $this->pie_post_array['registration_success'] = stripcslashes(esc_html($form->data['submit']['message']));
4153 }
4154
4155 $piereg_post_array = $this->pie_post_array;
4156 }
4157 }
4158
4159 function send_admin_notifications($option, $user, $pass)
4160 {
4161 $is_allowed = true;
4162 $is_allowed = apply_filters('piereg_check_email_allowed_to_send', $is_allowed, $user);
4163
4164 /******** Admin Notification *******/
4165 if ($option['enable_admin_notifications'] == "1" && $is_allowed && isset($_POST['pie_submit'])) {
4166 $message_temp = "";
4167 if ($option['admin_message_email_formate'] == "0") {
4168 $message_temp = (wp_strip_all_tags($option['admin_message_email']));
4169 } else {
4170 $message_temp = $option['admin_message_email'];
4171 }
4172 $message = $this->filterEmail($message_temp, $user, $pass);
4173 $subject = html_entity_decode($option['admin_subject_email'], ENT_COMPAT, "UTF-8");
4174 $subject = $this->filterSubject($user, $subject);
4175 $to = trim($option['admin_sendto_email']); // values can be comma seperated.
4176 $from_name = html_entity_decode(trim($option['admin_from_name']), ENT_COMPAT, "UTF-8");
4177 $from_email = trim($option['admin_from_email']);
4178 $bcc = trim($option['admin_bcc_email']);
4179 $reply_to_email = trim($option['admin_to_email']);
4180
4181 if (empty($to)) //if not valid email address then use wordpress default admin
4182 {
4183 $to = get_option('admin_email');
4184 }
4185
4186 //Headers
4187 $headers = "MIME-Version: 1.0" . "\r\n";
4188 $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
4189
4190 if (!empty($from_email)) //Validating From
4191 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
4192
4193 if (!empty($bcc)) //Validating BCC
4194 $headers .= "Bcc: " . $bcc . " \r\n";
4195
4196 if (!empty($reply_to_email)) //Validating Reply To
4197 $headers .= "Reply-To: <" . $reply_to_email . "> \r\n";
4198
4199 if ($reply_to_email)
4200 $headers .= "Return-Path: " . $reply_to_email . " \r\n";
4201 else
4202 $headers .= "Return-Path: " . $from_email . " \r\n";
4203
4204 do_action("piereg_action_before_admin_notify_email", $option, $user); # newlyAddedHookFilter
4205 if (!wp_mail($to, $subject, $message, $headers)) {
4206 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
4207 }
4208 } elseif ($option['enable_admin_notifications_profile_update'] == "1" && $is_allowed && isset($_POST['pie_submit_update'])) {
4209 global $profile_updated;
4210 if ($profile_updated == 1) {
4211 $message_temp = "";
4212 if ($option['admin_message_email_formate_profile_update'] == "0") {
4213 $message_temp = (wp_strip_all_tags($option['admin_message_email_profile_update']));
4214 } else {
4215 $message_temp = $option['admin_message_email_profile_update'];
4216 }
4217 $message = $this->filterEmail($message_temp, $user, $pass);
4218 $subject = html_entity_decode($option['admin_subject_email_profile_update'], ENT_COMPAT, "UTF-8");
4219 $subject = $this->filterSubject($user, $subject);
4220 $to = trim($option['admin_sendto_email_profile_update']); // values can be comma seperated.
4221 $from_name = html_entity_decode(trim($option['admin_from_name_profile_update']), ENT_COMPAT, "UTF-8");
4222 $from_email = trim($option['admin_from_email_profile_update']);
4223 $bcc = trim($option['admin_bcc_email_profile_update']);
4224 $reply_to_email = trim($option['admin_to_email_profile_update']);
4225
4226 if (empty($to)) //if not valid email address then use wordpress default admin
4227 {
4228 $to = get_option('admin_email');
4229 }
4230
4231 //Headers
4232 $headers = "MIME-Version: 1.0" . "\r\n";
4233 $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
4234
4235 if (!empty($from_email)) //Validating From
4236 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
4237
4238 if (!empty($bcc)) //Validating BCC
4239 $headers .= "Bcc: " . $bcc . " \r\n";
4240
4241 if (!empty($reply_to_email)) //Validating Reply To
4242 $headers .= "Reply-To: <" . $reply_to_email . "> \r\n";
4243
4244 if ($reply_to_email)
4245 $headers .= "Return-Path: " . $reply_to_email . " \r\n";
4246 else
4247 $headers .= "Return-Path: " . $from_email . " \r\n";
4248
4249 do_action("piereg_action_before_admin_notify_email", $option, $user); # newlyAddedHookFilter
4250 if (!wp_mail($to, $subject, $message, $headers)) {
4251 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
4252 }
4253 }
4254 } elseif ($option['enable_admin_notifications_cancel_subscription'] == "1" && isset($_POST['action']) && ($_POST['action'] == 'pie_register_cancel_subscription') && $is_allowed) {
4255
4256 $message_temp = "";
4257 if ($option['admin_message_email_formate_cancel_subscription'] == "0") {
4258 $message_temp = (wp_strip_all_tags($option['admin_message_email_cancel_subscription']));
4259 } else {
4260 $message_temp = $option['admin_message_email_cancel_subscription'];
4261 }
4262 $message = $this->filterEmail($message_temp, $user, $pass);
4263 $subject = html_entity_decode($option['admin_subject_email_cancel_subscription'], ENT_COMPAT, "UTF-8");
4264 $subject = $this->filterSubject($user, $subject);
4265 $to = trim($option['admin_sendto_email_cancel_subscription']); // values can be comma seperated.
4266 $from_name = html_entity_decode(trim($option['admin_from_name_cancel_subscription']), ENT_COMPAT, "UTF-8");
4267 $from_email = trim($option['admin_from_email_cancel_subscription']);
4268 $bcc = trim($option['admin_bcc_email_cancel_subscription']);
4269 $reply_to_email = trim($option['admin_to_email_cancel_subscription']);
4270
4271 if (empty($to)) //if not valid email address then use wordpress default admin
4272 {
4273 $to = get_option('admin_email');
4274 }
4275
4276 //Headers
4277 $headers = "MIME-Version: 1.0" . "\r\n";
4278 $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
4279
4280 if (!empty($from_email)) //Validating From
4281 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
4282
4283 if (!empty($bcc)) //Validating BCC
4284 $headers .= "Bcc: " . $bcc . " \r\n";
4285
4286 if (!empty($reply_to_email)) //Validating Reply To
4287 $headers .= "Reply-To: <" . $reply_to_email . "> \r\n";
4288
4289 if ($reply_to_email)
4290 $headers .= "Return-Path: " . $reply_to_email . " \r\n";
4291 else
4292 $headers .= "Return-Path: " . $from_email . " \r\n";
4293
4294 do_action("piereg_action_before_admin_notify_email", $option, $user); # newlyAddedHookFilter
4295 if (!wp_mail($to, $subject, $message, $headers)) {
4296 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
4297 }
4298 }
4299 }
4300
4301 function check_payment_method_paypal($user)
4302 {
4303 $user_id = intval($_POST['user_id']);
4304 $user_email = sanitize_email($_POST['e_mail']);
4305 add_filter('wp_mail_content_type', array($this, 'set_html_content_type'));
4306 global $errors;
4307 $form = new Registration_form();
4308 $errors = $form->validateRegistration($errors);
4309 $option = get_option(OPTION_PIE_REGISTER);
4310
4311 update_user_meta($user_id, 'active', 0);
4312 $hash = wp_generate_password(32, false);
4313 update_user_meta($user_id, 'hash', $hash);
4314
4315 $subject = html_entity_decode($option['user_subject_email_pending_payment'], ENT_COMPAT, "UTF-8");
4316 $subject = $this->filterSubject($user_email, $subject);
4317 $message_temp = "";
4318 if ($option['user_formate_email_pending_payment'] == "0") {
4319 $message_temp = nl2br(wp_strip_all_tags($option['user_message_email_pending_payment']));
4320 } else {
4321 $message_temp = $option['user_message_email_pending_payment'];
4322 }
4323
4324 $message = $form->filterEmail($message_temp, $user_email);
4325 $from_name = html_entity_decode(trim($option['user_from_name_pending_payment']), ENT_COMPAT, "UTF-8");
4326 $from_email = $option['user_from_email_pending_payment'];
4327 $reply_email = $option['user_to_email_pending_payment'];
4328
4329 //Headers
4330 $headers = 'MIME-Version: 1.0' . "\r\n";
4331 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4332
4333 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
4334 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
4335 if ($reply_email) {
4336 $headers .= "Reply-To: {$reply_email}\r\n";
4337 $headers .= "Return-Path: {$reply_email}\r\n";
4338 } else {
4339 $headers .= "Reply-To: {$from_email}\r\n";
4340 $headers .= "Return-Path: {$from_email}\r\n";
4341 }
4342
4343 if ((isset($option['user_enable_pending_payment']) && $option['user_enable_pending_payment'] == 1) && !wp_mail(sanitize_email($_POST['e_mail']), $subject, $message, $headers)) {
4344 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
4345 }
4346
4347 update_user_meta($user_id, 'register_type', "payment_verify");
4348 $paypal_url = "https://www.paypal.com/cgi-bin/webscr";
4349 if ($option['paypal_sandbox'] == "no") {
4350 $paypal_url = "https://www.paypal.com/cgi-bin/webscr";
4351 } else {
4352 $paypal_url = "https://sandbox.paypal.com/cgi-bin/webscr";
4353 }
4354
4355 $user_registered_form_id = get_user_meta($user_id, "user_registered_form_id", true);
4356
4357 $piereg_form_data = $this->getCurrentFields($user_registered_form_id);
4358
4359 foreach ($piereg_form_data as $key => $val) {
4360 if (isset($val['type']) && ($val['type'] == 'pricing')) {
4361 $hosted_btn_id = isset($val['hosted_btn_id']) && !empty($val['hosted_btn_id']) ? $val['hosted_btn_id'] : $option['paypal_butt_id'];
4362 }
4363 }
4364
4365 $nvpStr = "?cmd=_s-xclick&hosted_button_id=" . trim($hosted_btn_id) .
4366 "&custom=" . $hash . '__' . $user_id .
4367 "&bn=Genetech_SI_Custom" .
4368 "&cancel_return=" . urlencode(trailingslashit(get_bloginfo("url")) . '?action=payment_cancel&paypal=' . base64_encode($user_id)) .
4369 "&notify_url=" . urlencode(trailingslashit(get_bloginfo("url")) . '?action=ipn_success&paypal=' . base64_encode($hash . '|' . $user_id));
4370
4371 wp_redirect(esc_url_raw($paypal_url . $nvpStr));
4372 exit;
4373 }
4374
4375 function process_lostpassword()
4376 {
4377 global $errors;
4378 if (file_exists(PIEREG_DIR_NAME . "/forgot_password.php"))
4379 include_once("forgot_password.php");
4380 get_header();
4381 $this->set_pr_stats("forgot", "view");
4382
4383 $output = pieResetFormOutput();
4384 echo wp_kses($output, $this->piereg_forms_get_allowed_tags());
4385 get_footer();
4386 exit;
4387 }
4388 function process_getpassword()
4389 {
4390 global $errors;
4391 $user = check_password_reset_key(sanitize_text_field($_GET['key']), sanitize_user($_GET['login']));
4392 if (is_wp_error($user)) {
4393 wp_safe_redirect(site_url('wp-login.php?action=lostpassword&error=invalidkey'));
4394 exit;
4395 }
4396
4397 get_header();
4398 if (file_exists(PIEREG_DIR_NAME . "/get_password.php"))
4399 include_once("get_password.php");
4400 /*$get_form = piereg_get_passwird();
4401 echo $get_form;*/
4402 get_footer();
4403 exit;
4404 }
4405
4406 function pie_add_option()
4407 {
4408
4409 $option = 'per_page';
4410 $args = array(
4411 'label' => 'Number of items per page:',
4412 'default' => 10,
4413 'option' => 'pie_users_per_page'
4414 );
4415
4416 add_screen_option($option, $args);
4417 }
4418 function pie_set_option($status, $option, $value)
4419 {
4420 if ('pie_users_per_page' == $option) return $value;
4421 return $status;
4422 }
4423 function Unverified()
4424 {
4425
4426 if (file_exists(PIEREG_DIR_NAME . "/classes/unverified_pagination.php"))
4427 include_once(PIEREG_DIR_NAME . "/classes/unverified_pagination.php");
4428
4429 if (isset($this->pie_post_array['notice']) && !empty($this->pie_post_array['notice']))
4430 echo '<div id="message" class="updated fade"><p><strong>' . wp_kses_post($this->pie_post_array['notice']) . '.</strong></p></div>';
4431 if (isset($this->pie_post_array['error_message']) && !empty($this->pie_post_array['error_message']))
4432 echo '<div id="error" class="error fade"><p><strong>' . wp_kses_post($this->pie_post_array['error_message']) . '.</strong></p></div>';
4433
4434 $unverified_list = new Pie_Unverfied_users_Table();
4435 echo '<div class="wrap"><h2>' . esc_html__('Unverified Users', 'pie-register') . '</h2>';
4436
4437 if (isset($_POST['s'])) {
4438 $unverified_list->prepare_items(sanitize_text_field($_POST['s']));
4439 } else {
4440 $unverified_list->prepare_items();
4441 }
4442
4443 ?>
4444 <form method="post" id="pie-unverified-users">
4445 <input type="hidden" name="page" value="unverified-users">
4446 <?php
4447 $unverified_list->search_box('search', 'search_id');
4448 $unverified_list->display();
4449 echo '</form></div>';
4450 }
4451
4452 function verifyUsers()
4453 {
4454 if (isset($_POST['piereg_unverified_users_bulk_option_nonce']) && ! empty($_POST['piereg_unverified_users_bulk_option_nonce']) && wp_verify_nonce($_POST['piereg_unverified_users_bulk_option_nonce'], 'piereg_wp_unverified_users_bulk_option_nonce') && current_user_can('piereg_manage_cap')) {
4455 add_filter('send_password_change_email', '__return_false');
4456 $valid = isset($_POST['vusers']) ? array_map('sanitize_key', $_POST['vusers']) : "";
4457 if ($valid) {
4458 $option = get_option(OPTION_PIE_REGISTER);
4459 foreach ($valid as $user_id) {
4460 if ($user_id) {
4461 global $wpdb;
4462
4463 $register_type = get_user_meta($user_id, "register_type", true);
4464 $email_user_password = get_user_meta($user_id, "email_user_password", true);
4465 $invite_code = get_user_meta($user_id, "invite_code", true);
4466
4467 if ($register_type == "admin_email_verify") {
4468 if (!$this->InvCodeExpired($user_id)) {
4469 $user = new WP_User($user_id);
4470 $user_email = $user->user_email;
4471
4472 update_user_meta($user_id, 'active', 0);
4473 $hash = wp_generate_password(32, false);
4474 update_user_meta($user_id, 'hash', $hash);
4475 update_user_meta($user_id, 'admin_hash', "");
4476 update_user_meta($user_id, 'register_type', "email_verify");
4477
4478 $subject = html_entity_decode($option['user_subject_email_email_verification'], ENT_COMPAT, "UTF-8");
4479 $subject = $this->filterSubject($user_email, $subject);
4480 $message_temp = "";
4481 if ($option['user_formate_email_email_verification'] == "0") {
4482 $message_temp = nl2br(wp_strip_all_tags($option['user_message_email_email_verification']));
4483 } else {
4484 $message_temp = $option['user_message_email_email_verification'];
4485 }
4486 $message = $this->filterEmail($message_temp, $user_email);
4487 $from_name = html_entity_decode($option['user_from_name_email_verification'], ENT_COMPAT, "UTF-8");
4488 $from_email = $option['user_from_email_email_verification'];
4489 $reply_email = $option['user_to_email_email_verification'];
4490
4491 //Headers
4492 $headers = 'MIME-Version: 1.0' . "\r\n";
4493 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4494
4495
4496 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
4497 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
4498 if ($reply_email) {
4499 $headers .= "Reply-To: {$reply_email}\r\n";
4500 $headers .= "Return-Path: {$reply_email}\r\n";
4501 } else {
4502 $headers .= "Reply-To: {$from_email}\r\n";
4503 $headers .= "Return-Path: {$from_email}\r\n";
4504 }
4505 if ((isset($option['user_enable_email_verification']) && $option['user_enable_email_verification'] == 1) && !wp_mail($user_email, $subject, $message, $headers)) {
4506 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
4507 }
4508 $this->pie_post_array['notice'] = esc_html__("User(s) activated", "pie-register");
4509 } else {
4510 $this->pie_post_array['error'] = esc_html__("Invitation code has expired", "pie-register");
4511 }
4512 } else {
4513 if (!$this->InvCodeExpired($user_id)) {
4514 update_user_meta($user_id, 'active', 1);
4515 update_user_meta($user_id, 'admin_hash', "");
4516
4517 //Sending E-Mail to newly active user
4518 $user = new WP_User($user_id);
4519 $subject = html_entity_decode($option['user_subject_email_email_thankyou'], ENT_COMPAT, "UTF-8");
4520 $subject = $this->filterSubject($user, $subject);
4521 $user_email = $user->user_email;
4522 $user_pass = $email_user_password == "1" ? apply_filters('piereg_email_random_generated_password', wp_generate_password()) : "";
4523 if (!empty($user_pass)) {
4524 $user_data = array('ID' => $user_id, 'user_pass' => trim($user_pass));
4525 wp_update_user($user_data);
4526 }
4527 $message_temp = "";
4528 if ($option['user_formate_email_email_thankyou'] == "0") {
4529 $message_temp = nl2br(wp_strip_all_tags($option['user_message_email_email_thankyou']));
4530 } else {
4531 $message_temp = $option['user_message_email_email_thankyou'];
4532 }
4533
4534 $message = $this->filterEmail($message_temp, $user_email, $user_pass);
4535 $from_name = html_entity_decode($option['user_from_name_email_thankyou'], ENT_COMPAT, "UTF-8");
4536 $from_email = $option['user_from_email_email_thankyou'];
4537 $reply_email = $option['user_to_email_email_thankyou'];
4538
4539 //Headers
4540 $headers = 'MIME-Version: 1.0' . "\r\n";
4541 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4542
4543 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
4544 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
4545
4546 if ($reply_email) {
4547 $headers .= "Reply-To: {$reply_email}\r\n";
4548 $headers .= "Return-Path: {$reply_email}\r\n";
4549 } else {
4550 $headers .= "Reply-To: {$from_email}\r\n";
4551 $headers .= "Return-Path: {$from_email}\r\n";
4552 }
4553 if ((isset($option['user_enable_email_thankyou']) && $option['user_enable_email_thankyou'] == 1) && !wp_mail($user_email, $subject, $message, $headers)) {
4554 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
4555 }
4556 if (!empty($invite_code)) {
4557 $prefix = $wpdb->prefix . "pieregister_";
4558 $codetable = $prefix . "code";
4559 $codeDetails = $wpdb->get_results($wpdb->prepare("SELECT * FROM $codetable where BINARY name = %s and status = %d", $invite_code, 1));
4560
4561 if (!empty($codeDetails)) {
4562 $times_used = intval($codeDetails[0]->count);
4563 $usage = intval($codeDetails[0]->code_usage);
4564
4565 if ((($times_used < $usage) && ($usage != 0)) || $usage == 0) {
4566 $codes = $wpdb->query($wpdb->prepare("update $codetable set count = count + 1 where BINARY name = %s and status = %d", $invite_code, 1));
4567 }
4568 }
4569 }
4570 // mailchimp related code within PR
4571 do_action('pireg_after_verification_users', $user);
4572 $this->pie_post_array['notice'] = esc_html__("User(s) activated", "pie-register");
4573 } else {
4574 $this->pie_post_array['error'] = esc_html__("Invitation code has expired", "pie-register");
4575 }
4576 }
4577 }
4578 }
4579 } else
4580 $this->pie_post_array['notice'] = "<strong>" . esc_html__('error', 'pie-register') . ":</strong>" . esc_html__("Please select user(s) to send email.", "pie-register");
4581
4582 if (isset($this->pie_post_array['notice']) && !empty($this->pie_post_array['notice']))
4583 echo '<div id="message" class="updated fade"><p><strong>' . esc_html($this->pie_post_array['notice']) . '.</strong></p></div>';
4584 if (isset($this->pie_post_array['error']) && !empty($this->pie_post_array['error']))
4585 echo '<div id="error" class="error fade msg_belowheading"><p><strong>' . esc_html($this->pie_post_array['error']) . "</strong></p></div>";
4586 }
4587 }
4588 function InvCodeExpired($user_id)
4589 {
4590 global $wpdb;
4591
4592 $invite_code = get_user_meta($user_id, "invite_code", true);
4593 $code_ended = false;
4594 if (!empty($invite_code)) {
4595 $prefix = $wpdb->prefix . "pieregister_";
4596 $codetable = $prefix . "code";
4597 $codeDetails = $wpdb->get_results($wpdb->prepare("SELECT * FROM $codetable where BINARY name = %s and status = %d", $invite_code, 1));
4598
4599 if (!empty($codeDetails)) {
4600 $times_used = intval($codeDetails[0]->count);
4601 $usage = intval($codeDetails[0]->code_usage);
4602
4603 if ((($times_used < $usage) && ($usage != 0)) || $usage == 0) {
4604 $code_ended = false;
4605 } else {
4606 $code_ended = true;
4607 }
4608 }
4609 }
4610 return $code_ended;
4611 }
4612 function PaymentLink()
4613 {
4614 if (isset($_POST['piereg_unverified_users_bulk_option_nonce']) && ! empty($_POST['piereg_unverified_users_bulk_option_nonce']) && wp_verify_nonce($_POST['piereg_unverified_users_bulk_option_nonce'], 'piereg_wp_unverified_users_bulk_option_nonce') && current_user_can('piereg_manage_cap')) {
4615 global $wpdb;
4616 $valid = isset($_POST['vusers']) ? array_map('sanitize_key', $_POST['vusers']) : "";
4617 add_filter('wp_mail_content_type', array($this, 'set_html_content_type'));
4618 if (is_array($valid)) {
4619
4620 $option = get_option(OPTION_PIE_REGISTER);
4621 $sent = 0;
4622 foreach ($valid as $user_id) {
4623 $reg_type = get_user_meta($user_id, 'register_type');
4624 if ($reg_type[0] != "payment_verify") {
4625 continue;
4626 }
4627 $sent++;
4628 update_user_meta($user_id, 'active', 0);
4629 $hash = wp_generate_password(32, false);
4630 update_user_meta($user_id, 'hash', $hash);
4631
4632
4633 $user = new WP_User($user_id);
4634 $subject = html_entity_decode($option['user_subject_email_pending_payment_reminder'], ENT_COMPAT, "UTF-8");
4635 $subject = $this->filterSubject($user->user_email, $subject);
4636 $message_temp = "";
4637 if ($option['user_formate_email_pending_payment_reminder'] == "0") {
4638 $message_temp = nl2br(wp_strip_all_tags($option['user_message_email_pending_payment_reminder']));
4639 } else {
4640 $message_temp = $option['user_message_email_pending_payment_reminder'];
4641 }
4642
4643 $message = $this->filterEmail($message_temp, $user->user_email);
4644 $from_name = html_entity_decode($option['user_from_name_pending_payment_reminder'], ENT_COMPAT, "UTF-8");
4645 $from_email = $option['user_from_email_pending_payment_reminder'];
4646 $reply_email = $option['user_to_email_pending_payment_reminder'];
4647
4648
4649 //Headers
4650 $headers = 'MIME-Version: 1.0' . "\r\n";
4651 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4652
4653 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
4654 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
4655 if ($reply_email) {
4656 $headers .= "Reply-To: {$reply_email}\r\n";
4657 $headers .= "Return-Path: {$reply_email}\r\n";
4658 } else {
4659 $headers .= "Reply-To: {$from_email}\r\n";
4660 $headers .= "Return-Path: {$from_email}\r\n";
4661 }
4662 if ((isset($option['user_enable_pending_payment_reminder']) && $option['user_enable_pending_payment_reminder'] == 1) && !wp_mail($user->user_email, $subject, $message, $headers)) {
4663 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
4664 }
4665 }
4666 if ($sent > 0)
4667 $this->pie_post_array['notice'] = esc_html__("Payment link sent via email", "pie-register");
4668 else
4669 $this->pie_post_array['notice'] = esc_html__("Invalid User Types", "pie-register");
4670 } else {
4671 $this->pie_post_array['notice'] = "<strong>" . esc_html__('error', 'pie-register') . ":</strong>" . esc_html__("Please select user(s) to send email.", "pie-register");
4672 }
4673 }
4674 }
4675 function AdminEmailValidate()
4676 {
4677 if (isset($_POST['piereg_unverified_users_bulk_option_nonce']) && ! empty($_POST['piereg_unverified_users_bulk_option_nonce']) && wp_verify_nonce($_POST['piereg_unverified_users_bulk_option_nonce'], 'piereg_wp_unverified_users_bulk_option_nonce') && current_user_can('piereg_manage_cap')) {
4678 global $wpdb;
4679 $valid = isset($_POST['vusers']) ? array_map('sanitize_key', $_POST['vusers']) : "";
4680 add_filter('wp_mail_content_type', array($this, 'set_html_content_type'));
4681 if (is_array($valid)) {
4682 $option = get_option(OPTION_PIE_REGISTER);
4683 $sent = 0;
4684 foreach ($valid as $user_id) {
4685 $reg_type = get_user_meta($user_id, 'register_type');
4686 if ($reg_type[0] != "email_verify") {
4687 continue;
4688 }
4689 $sent++;
4690 update_user_meta($user_id, 'active', 0);
4691 $hash = wp_generate_password(32, false);
4692 update_user_meta($user_id, 'hash', $hash);
4693
4694 $user = new WP_User($user_id);
4695 $subject = html_entity_decode($option['user_subject_email_email_verification_reminder'], ENT_COMPAT, "UTF-8");
4696 $subject = $this->filterSubject($user, $subject);
4697 $message_temp = "";
4698 if ($option['user_formate_email_email_verification_reminder'] == "0") {
4699 $message_temp = nl2br(wp_strip_all_tags($option['user_message_email_email_verification_reminder']));
4700 } else {
4701 $message_temp = $option['user_message_email_email_verification_reminder'];
4702 }
4703
4704 $message = $this->filterEmail($message_temp, $user->user_email);
4705
4706 $from_name = html_entity_decode($option['user_from_name_email_verification_reminder'], ENT_COMPAT, "UTF-8");
4707 $from_email = $option['user_from_email_email_verification_reminder'];
4708 $reply_email = $option['user_to_email_email_verification_reminder'];
4709
4710 //Headers
4711 $headers = 'MIME-Version: 1.0' . "\r\n";
4712 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4713
4714 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
4715 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
4716 if ($reply_email) {
4717 $headers .= "Reply-To: {$reply_email}\r\n";
4718 $headers .= "Return-Path: {$reply_email}\r\n";
4719 } else {
4720 $headers .= "Reply-To: {$from_email}\r\n";
4721 $headers .= "Return-Path: {$from_email}\r\n";
4722 }
4723
4724 if ((isset($option['user_enable_email_verification_reminder']) && $option['user_enable_email_verification_reminder'] == 1) && !wp_mail($user->user_email, $subject, $message, $headers)) {
4725 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
4726 }
4727 }
4728 if ($sent > 0)
4729 $this->pie_post_array['notice'] = esc_html__("Verification Emails have been re-sent", "pie-register");
4730 else
4731 $this->pie_post_array['notice'] = esc_html__("Invalid User Types", "pie-register");
4732 } else
4733 $this->pie_post_array['notice'] = "<strong>" . esc_html__('error', 'pie-register') . ":</strong>" . esc_html__("Please select user(s) to send email.", "pie-register");
4734 }
4735 }
4736 function AdminDeleteUnvalidated()
4737 {
4738 if (isset($_POST['piereg_unverified_users_bulk_option_nonce']) && ! empty($_POST['piereg_unverified_users_bulk_option_nonce']) && wp_verify_nonce($_POST['piereg_unverified_users_bulk_option_nonce'], 'piereg_wp_unverified_users_bulk_option_nonce') && current_user_can('piereg_manage_cap')) {
4739 global $wpdb;
4740
4741 $piereg = get_option(OPTION_PIE_REGISTER);
4742 $valid = isset($_POST['vusers']) ? array_map('sanitize_key', $_POST['vusers']) : "";
4743 if ($valid) {
4744 include_once($this->admin_path . 'includes/user.php');
4745 foreach ($valid as $user_id) {
4746 if ($user_id) {
4747 do_action("piereg_before_deleting_user_unverified_list", $user_id); # newlyAddedHookFilter - runs before user is deleted from the unverified users' list
4748 wp_delete_user($user_id);
4749 }
4750 }
4751 $this->pie_post_array['notice'] = esc_html__("User(s) deleted", "pie-register");
4752 }
4753 }
4754 }
4755 function piereg_user_notification_user_verification_rejected($user_id)
4756 {
4757 $option = get_option(OPTION_PIE_REGISTER);
4758 $user = new WP_User($user_id);
4759 $subject = html_entity_decode($option['user_subject_email_user_verification_rejected'], ENT_COMPAT, "UTF-8");
4760 $subject = $this->filterSubject($user, $subject);
4761 $message_temp = "";
4762 if ($option['user_formate_email_user_verification_rejected'] == "0") {
4763 $message_temp = nl2br(wp_strip_all_tags($option['user_message_email_user_verification_rejected']));
4764 } else {
4765 $message_temp = $option['user_message_email_user_verification_rejected'];
4766 }
4767
4768 $message = $this->filterEmail($message_temp, $user->user_email);
4769
4770 $from_name = html_entity_decode($option['user_from_name_user_verification_rejected'], ENT_COMPAT, "UTF-8");
4771 $from_email = $option['user_from_email_user_verification_rejected'];
4772 $reply_email = $option['user_to_email_user_verification_rejected'];
4773 //Headers
4774 $headers = 'MIME-Version: 1.0' . "\r\n";
4775 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4776
4777 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
4778 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
4779 if ($reply_email) {
4780 $headers .= "Reply-To: {$reply_email}\r\n";
4781 $headers .= "Return-Path: {$reply_email}\r\n";
4782 } else {
4783 $headers .= "Reply-To: {$from_email}\r\n";
4784 $headers .= "Return-Path: {$from_email}\r\n";
4785 }
4786
4787 if ((isset($option['user_enable_user_verification_rejected']) && $option['user_enable_user_verification_rejected'] == 1) && !wp_mail($user->user_email, $subject, $message, $headers)) {
4788 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
4789 }
4790 }
4791 function cleantext($text)
4792 {
4793 foreach ($text as $key => $value) {
4794
4795 if (is_array($value)) {
4796 $this->cleantext($value);
4797 continue;
4798 }
4799
4800 $text[$key] = str_replace(chr(13), " ", $value); //remove carriage returns
4801 $text[$key] = str_replace(chr(10), " ", $value);
4802 }
4803
4804 return $text;
4805 }
4806 function disable_magic_quotes_gpc(&$value)
4807 {
4808 $value = stripslashes($value);
4809 return $value;
4810 }
4811
4812 function PieRegSettings()
4813 {
4814 if (isset($_GET['subtab']) && $_GET['subtab'] == 'role-based')
4815 $this->PieRegRedirectSettingsAction();
4816
4817 $option = get_option(OPTION_PIE_REGISTER);
4818 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegSettings.php');
4819 }
4820 function PieRegPaymentGateway()
4821 {
4822 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegPaymentGateway.php');
4823 }
4824 function PieRegAttachment()
4825 {
4826 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegAttachment.php');
4827 }
4828 function PieRegNotifications()
4829 {
4830 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegNotifications.php');
4831 }
4832 function PieRegImportExport()
4833 {
4834 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegImportExport.php');
4835 }
4836 function PieRegHelp()
4837 {
4838 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegHelp.php');
4839 }
4840 function PieRegProFeatures()
4841 {
4842 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegProFeatures.php');
4843 }
4844 function PieAboutUs()
4845 {
4846 do_action('piereg_admin_pages_before_content');
4847 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieAboutUs.php');
4848 }
4849 function PieRegRestrictUsers()
4850 {
4851 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegRestrictUsers.php');
4852 }
4853
4854 /**
4855 * PieRegCustomRoles function
4856 * Description: Create custom user roles.
4857 * Since v3.5.4
4858 */
4859 function PieRegCustomRoles()
4860 {
4861 if (isset($_POST['piereg_user_role_nonce']) || isset($_POST['piereg_user_role_delete_nonce'])) {
4862 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_user_role', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
4863
4864 if (isset($this->pie_post_array['piereg_user_role_delete_nonce']) && wp_verify_nonce($this->pie_post_array['piereg_user_role_delete_nonce'], 'piereg_wp_user_role_delete_nonce')) {
4865 global $wpdb;
4866 $custom_role_table_name = $wpdb->prefix . "pieregister_custom_user_roles";
4867
4868 if (isset($this->pie_post_array['role_del_id'])) {
4869 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
4870 if (isset($this->pie_post_array['piereg_user_role_delete_nonce']) && wp_verify_nonce($this->pie_post_array['piereg_user_role_delete_nonce'], 'piereg_wp_user_role_delete_nonce')) {
4871 if ($wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->prefix}pieregister_custom_user_roles` WHERE id = %d", array($this->pie_post_array['role_del_id'])))) {
4872 $this->pie_post_array['notice'] = esc_html__("The Role has been deleted", "pie-register");
4873 remove_role($this->pie_post_array['role_del_key']);
4874 } else {
4875 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
4876 }
4877 } else {
4878 $this->pie_post_array['error'] = esc_html__("Invalid nonce.", "pie-register");
4879 }
4880 }
4881 } else {
4882 $this->pie_post_array['error'] = esc_html__("Invalid nonce.", "pie-register");
4883 }
4884 }
4885
4886 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegCustomRoles.php');
4887 }
4888 function PieRegExportUsers()
4889 {
4890 $this->pieregister_fu_admin_scripts_styles();
4891 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegExportUsers.php');
4892 }
4893 function PieRegBulkEmail()
4894 {
4895
4896 $addon_BulkEmail_activated = get_option('piereg_api_manager_addon_BulkEmail_activated');
4897
4898
4899 if ((is_plugin_active('pie-register-bulkemail/pie-register-bulkemail.php')) && $addon_BulkEmail_activated == "Activated") {
4900 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegBulkEmail.php');
4901 } else {
4902 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/addons/PieRegBulkEmailAddon.php');
4903 }
4904 }
4905 function PieSocialLogin()
4906 {
4907 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/addons/PieRegSocialLoginAddon.php');
4908 }
4909 function PieTwilio()
4910 {
4911 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/addons/PieRegTwilioAddon.php');
4912 }
4913 function PieMailChimp()
4914 {
4915 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/addons/PieRegMailChimpAddon.php');
4916 }
4917 function PieProfileSearch()
4918 {
4919 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/addons/PieRegProfileSearchAddon.php');
4920 }
4921 function PieAuthorizeNet()
4922 {
4923 wp_enqueue_style("pie_addons_menu_css");
4924 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/addons/PieRegAuthorizeAddon.php');
4925 }
4926 function PieStripe()
4927 {
4928 wp_enqueue_style("pie_addons_menu_css");
4929 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/addons/PieRegStripeOneTimeAddon.php');
4930 }
4931 function PieGeoLocation()
4932 {
4933 wp_enqueue_style("pie_addons_menu_css");
4934 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/addons/PieRegGeoLocationAddon.php');
4935 }
4936 function PieRegWooCommerce()
4937 {
4938 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegWooCommerce.php');
4939 }
4940 function PieWooCommerce()
4941 {
4942 wp_enqueue_style("pie_addons_menu_css");
4943 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/addons/PieRegWooCommerceAddon.php');
4944 }
4945 function PieRegNewForm()
4946 {
4947 wp_enqueue_style('pie_notification_css');
4948 wp_enqueue_script('pie_notification_js');
4949 do_action('piereg_admin_pages_before_content');
4950 $this->pieregister_admin_scripts_styles_slick();
4951 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegRegistrationForm.php');
4952 }
4953 //Opening Form Editor
4954 function RegPlusEditForm()
4955 {
4956 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegEditForm.php');
4957 }
4958
4959 function PieRegSettingsProcess()
4960 {
4961 $update = get_option(OPTION_PIE_REGISTER);
4962 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
4963
4964 if (isset($_POST['piereg_settings_allusers']) && wp_verify_nonce($_POST['piereg_settings_allusers'], 'piereg_wp_settings_allusers')) {
4965
4966 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_settings_allusers', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
4967 $pie_pages = get_option("pie_pages");
4968
4969 $update['alternate_login'] = $pie_pages[0] = intval($this->pie_post_array['alternate_login']);
4970 $update['alternate_register'] = $pie_pages[1] = intval($this->pie_post_array['alternate_register']);
4971 $update['alternate_forgotpass'] = $pie_pages[2] = intval($this->pie_post_array['alternate_forgotpass']);
4972 $update['alternate_profilepage'] = $pie_pages[3] = intval($this->pie_post_array['alternate_profilepage']);
4973 $update['after_login'] = trim($this->pie_post_array['after_login']);
4974 $update['alternate_login_url'] = $this->pie_post_array['alternate_login_url'];
4975 $update['alternate_logout'] = trim($this->pie_post_array['alternate_logout']);
4976 $update['alternate_logout_url'] = $this->pie_post_array['alternate_logout_url'];
4977 update_option('pie_pages', $pie_pages);
4978 } elseif (isset($_POST['piereg_settings_ux']) && wp_verify_nonce($_POST['piereg_settings_ux'], 'piereg_wp_settings_ux')) {
4979
4980 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_settings_ux', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
4981
4982 $update['display_hints'] = isset($this->pie_post_array['display_hints']) ? intval($this->pie_post_array['display_hints']) : 0;
4983 $update['login_username_label'] = $this->pie_post_array['login_username_label'];
4984 $update['login_username_placeholder'] = $this->pie_post_array['login_username_placeholder'];
4985 $update['login_password_label'] = $this->pie_post_array['login_password_label'];
4986 $update['login_password_placeholder'] = $this->pie_post_array['login_password_placeholder'];
4987
4988 $update['forgot_pass_username_label'] = $this->pie_post_array['forgot_pass_username_label'];
4989 $update['forgot_pass_username_placeholder'] = $this->pie_post_array['forgot_pass_username_placeholder'];
4990
4991 $update['custom_logo_url'] = $this->pie_post_array['custom_logo_url'];
4992 $update['custom_logo_tooltip'] = $this->pie_post_array['custom_logo_tooltip'];
4993 $update['custom_logo_link'] = $this->pie_post_array['custom_logo_link'];
4994 $update['show_custom_logo'] = (isset($this->pie_post_array['show_custom_logo'])) ? $this->pie_post_array['show_custom_logo'] : 0;
4995 $update['outputcss'] = isset($this->pie_post_array['outputcss']) ? intval($this->pie_post_array['outputcss']) : 0;
4996 $update['outputjquery_ui'] = isset($this->pie_post_array['outputjquery_ui']) ? intval($this->pie_post_array['outputjquery_ui']) : 0;
4997
4998
4999 $custom_css = isset($this->pie_post_array['custom_css']) ? $this->pie_post_array['custom_css'] : "";
5000 $custom_css = mb_convert_encoding(wp_strip_all_tags($custom_css), 'HTML-ENTITIES', 'utf-8');
5001 $update['custom_css'] = $this->disable_magic_quotes_gpc($custom_css);
5002
5003 $tracking_code = isset($this->pie_post_array['tracking_code']) ? $this->pie_post_array['tracking_code'] : "";
5004 $tracking_code = mb_convert_encoding(wp_strip_all_tags($tracking_code), 'HTML-ENTITIES', 'utf-8');
5005 $update['tracking_code'] = $this->disable_magic_quotes_gpc($tracking_code);
5006 } elseif (isset($_POST['piereg_settings_overrides']) && wp_verify_nonce($_POST['piereg_settings_overrides'], 'piereg_wp_settings_overrides')) {
5007
5008 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_settings_overrides', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
5009
5010 $update['redirect_user'] = isset($this->pie_post_array['redirect_user']) ? intval($this->pie_post_array['redirect_user']) : 0;
5011 $update['show_admin_bar'] = isset($this->pie_post_array['show_admin_bar']) ? intval($this->pie_post_array['show_admin_bar']) : 0;
5012 $update['block_WP_profile'] = isset($this->pie_post_array['block_WP_profile']) ? intval($this->pie_post_array['block_WP_profile']) : 0;
5013 $update['block_wp_login'] = isset($this->pie_post_array['block_wp_login']) ? intval($this->pie_post_array['block_wp_login']) : 0;
5014 $update['allow_pr_edit_wplogin'] = isset($this->pie_post_array['allow_pr_edit_wplogin']) ? intval($this->pie_post_array['allow_pr_edit_wplogin']) : 0;
5015 } elseif (isset($_POST['piereg_settings_security_b']) && wp_verify_nonce($_POST['piereg_settings_security_b'], 'piereg_wp_settings_security_b')) {
5016
5017 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_settings_security_b', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
5018
5019 $update['captcha_in_login_value'] = isset($this->pie_post_array['captcha_in_login_value']) ? $this->pie_post_array['captcha_in_login_value'] : 0;
5020 $update['captcha_in_login_attempts'] = isset($this->pie_post_array['captcha_in_login_attempts']) ? $this->pie_post_array['captcha_in_login_attempts'] : 0;
5021 $update['capthca_in_login_label'] = isset($this->pie_post_array['capthca_in_login_label']) ? $this->pie_post_array['capthca_in_login_label'] : 0;
5022 $update['piereg_recapthca_skin_login'] = isset($this->pie_post_array['piereg_recapthca_skin_login']) ? $this->pie_post_array['piereg_recapthca_skin_login'] : 0;
5023 $update['capthca_in_login'] = isset($this->pie_post_array['capthca_in_login']) ? intval($this->pie_post_array['capthca_in_login']) : 0;
5024
5025 $update['captcha_in_forgot_value'] = $this->pie_post_array['captcha_in_forgot_value'];
5026 $update['capthca_in_forgot_pass_label'] = $this->pie_post_array['capthca_in_forgot_pass_label'];
5027 $update['piereg_recapthca_skin_forgot_pass'] = isset($this->pie_post_array['piereg_recapthca_skin_forgot_pass']) ? $this->pie_post_array['piereg_recapthca_skin_forgot_pass'] : 0;
5028 $update['capthca_in_forgot_pass'] = isset($this->pie_post_array['capthca_in_forgot_pass']) ? intval($this->pie_post_array['capthca_in_forgot_pass']) : 0;
5029
5030 $update['piereg_recaptcha_type'] = isset($this->pie_post_array['piereg_recaptcha_type']) ? $this->pie_post_array['piereg_recaptcha_type'] : "v2";
5031 $update['captcha_publc'] = $this->pie_post_array['captcha_publc'];
5032 $update['captcha_private'] = $this->pie_post_array['captcha_private'];
5033 $update['piereg_recaptcha_language'] = $this->pie_post_array['piereg_recaptcha_language'];
5034 $update['captcha_publc_v3'] = isset($this->pie_post_array['captcha_publc_v3']) ? $this->pie_post_array['captcha_publc_v3'] : '';
5035 $update['captcha_private_v3'] = isset($this->pie_post_array['captcha_private_v3']) ? $this->pie_post_array['captcha_private_v3'] : '';
5036
5037 $update['verification'] = intval($this->pie_post_array['verification']);
5038 $update['email_edit_verification_step'] = intval($this->pie_post_array['email_edit_verification_step']);
5039 $update['grace_period'] = intval($this->pie_post_array['grace_period']);
5040
5041 $update['restrict_bot_enabel'] = isset($this->pie_post_array['restrict_bot_enabel']) ? intval($this->pie_post_array['restrict_bot_enabel']) : "";
5042 $restrict_bot_content = isset($this->pie_post_array['restrict_bot_content']) ? mb_convert_encoding($this->pie_post_array['restrict_bot_content'], 'HTML-ENTITIES', 'utf-8') : "";
5043 $update['restrict_bot_content'] = $this->disable_magic_quotes_gpc($restrict_bot_content);
5044
5045 $restrict_bot_content_message = isset($this->pie_post_array['restrict_bot_content_message']) ? mb_convert_encoding($this->pie_post_array['restrict_bot_content_message'], 'HTML-ENTITIES', 'utf-8') : "";
5046 $update['restrict_bot_content_message'] = $this->disable_magic_quotes_gpc($restrict_bot_content_message);
5047 } elseif (isset($_POST['piereg_settings_security_advanced']) && wp_verify_nonce($_POST['piereg_settings_security_advanced'], 'piereg_wp_settings_security_advanced')) {
5048
5049 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_settings_security_advanced', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
5050
5051 $update['reg_form_submission_time_enable'] = isset($this->pie_post_array['reg_form_submission_time_enable']) ? intval($this->pie_post_array['reg_form_submission_time_enable']) : 0;
5052 $update['reg_form_submission_time'] = isset($this->pie_post_array['reg_form_submission_time']) ? intval($this->pie_post_array['reg_form_submission_time']) : 0;
5053 } else {
5054 $this->pie_post_array['error'] = esc_html__("Invalid nonce.", "pie-register");
5055 }
5056
5057 update_option(OPTION_PIE_REGISTER, $update);
5058 $this->set_pr_global_options($update, OPTION_PIE_REGISTER);
5059
5060 if (!isset($this->pie_post_array['error']) && empty($this->pie_post_array['error']))
5061 $this->pie_post_array['notice'] = apply_filters("piereg_settings_saved", esc_html__('Settings Saved', 'pie-register'));
5062 }
5063
5064 function PieRegRedirectSettingsAction()
5065 {
5066
5067 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_redirect_settings', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
5068
5069 global $wpdb;
5070 $prefix = $wpdb->prefix . "pieregister_";
5071 $piereg_table_name = $prefix . "redirect_settings";
5072 /* Change Status */
5073 if (isset($this->pie_post_array['redirect_settings_status_id']) && !empty($this->pie_post_array['redirect_settings_status_id'])) {
5074 if ($wpdb->query($wpdb->prepare("update $piereg_table_name SET `status` = CASE WHEN status = 1 THEN 0 WHEN status = 0 THEN 1 ELSE 0 END WHERE `id` = %d", intval($this->pie_post_array['redirect_settings_status_id']))))
5075 $this->pie_post_array['notice'] = esc_html__("Status has been changed.", "pie-register");
5076 else
5077 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
5078 }
5079 /* Delete Record */ elseif (isset($this->pie_post_array['redirect_settings_del_id'])) {
5080 if ($wpdb->query($wpdb->prepare("DELETE FROM $piereg_table_name WHERE `id` = %d", intval($this->pie_post_array['redirect_settings_del_id']))))
5081 $this->pie_post_array['notice'] = esc_html__("Record has been deleted", "pie-register");
5082 else
5083 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
5084 }
5085 }
5086 function PieRegInvitationCodes()
5087 {
5088 global $wpdb;
5089 $piereg = get_option(OPTION_PIE_REGISTER);
5090 $codetable = $this->codeTable();
5091 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_invitation_code', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
5092 $_data_updated = false;
5093
5094 if (isset($this->pie_post_array['invi_del_id'])) {
5095
5096 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
5097 if (isset($this->pie_post_array['piereg_invitation_code_del_form_nonce']) && wp_verify_nonce($this->pie_post_array['piereg_invitation_code_del_form_nonce'], 'piereg_wp_invitation_code_del_form_nonce')) {
5098 if ($wpdb->query($wpdb->prepare("DELETE FROM $codetable WHERE id = %d", $this->pie_post_array['invi_del_id'])))
5099 $this->pie_post_array['notice'] = esc_html__("Invitation code deleted.", "pie-register");
5100 else
5101 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
5102 } else {
5103 $this->pie_post_array['error'] = esc_html__("Invalid nonce.", "pie-register");
5104 }
5105 } else if (isset($this->pie_post_array['status_id'])) {
5106 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
5107 if (isset($this->pie_post_array['piereg_invitation_code_status_form_nonce']) && wp_verify_nonce($this->pie_post_array['piereg_invitation_code_status_form_nonce'], 'piereg_wp_invitation_code_status_form_nonce')) {
5108 if ($wpdb->query($wpdb->prepare("update $codetable SET status = CASE WHEN status = 1 THEN 0 WHEN status = 0 THEN 1 ELSE 0 END WHERE id = %s", $this->pie_post_array['status_id']))) {
5109 $this->pie_post_array['notice'] = esc_html__("Status has been changed", "pie-register");
5110 } else {
5111 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
5112 }
5113 } else {
5114 $this->pie_post_array['error'] = esc_html__("Invalid nonce.", "pie-register");
5115 }
5116 }
5117 if (isset($_POST['piereg_invitation_code_enable_nonce']) && wp_verify_nonce($_POST['piereg_invitation_code_enable_nonce'], 'piereg_wp_invitation_code_enable_nonce')) {
5118 if (isset($this->pie_post_array['hdn_enable_invitation_codes'])) {
5119 $piereg['enable_invitation_codes'] = isset($this->pie_post_array['enable_invitation_codes']) ? intval($this->pie_post_array['enable_invitation_codes']) : 0;
5120 $_data_updated = true;
5121 }
5122 }
5123 if ($_data_updated && update_option(OPTION_PIE_REGISTER, $piereg)) {
5124 $this->pie_post_array['notice'] = esc_html__("Settings Saved", "pie-register");
5125 } else if (isset($this->pie_post_array['piereg_codepass'])) {
5126
5127 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
5128 if (isset($this->pie_post_array['piereg_invitation_code_nonce']) && wp_verify_nonce($this->pie_post_array['piereg_invitation_code_nonce'], 'piereg_wp_invitation_code_nonce')) {
5129 if (isset($this->pie_post_array['add_code'])) {
5130 if (isset($this->pie_post_array['invitation_code_prefix'])) {
5131 $this->pie_post_array['error'] = esc_html__("Please activate the premium version", "pie-register");
5132 }
5133
5134 if (empty($this->pie_post_array['piereg_codepass']) || trim($this->pie_post_array['piereg_codepass']) == '') {
5135 $this->pie_post_array['error'] = esc_html__("Invitation code field is empty.", "pie-register");
5136 }
5137
5138 if (isset($this->pie_post_array['invitation_code_usage']) && !is_numeric($this->pie_post_array['invitation_code_usage']) && trim($this->pie_post_array['invitation_code_usage']) != '') {
5139 if (empty($this->pie_post_array['piereg_codepass']) || trim($this->pie_post_array['piereg_codepass']) == '') {
5140 $this->pie_post_array['error'] .= '<br/>';
5141 }
5142 $this->pie_post_array['error'] .= esc_html__("Usage must be a number greater than zero.", "pie-register");
5143 } elseif (isset($this->pie_post_array['invitation_code_usage']) && $this->pie_post_array['invitation_code_usage'] < 0 && trim($this->pie_post_array['invitation_code_usage']) != '') {
5144 if (empty($this->pie_post_array['piereg_codepass']) || trim($this->pie_post_array['piereg_codepass']) == '') {
5145 $this->pie_post_array['error'] .= '<br/>';
5146 }
5147 $this->pie_post_array['error'] .= esc_html__("Usage must be a number greater than zero.", "pie-register");
5148 }
5149
5150 $update["codepass"] = isset($this->pie_post_array['piereg_codepass']) ? $this->pie_post_array['piereg_codepass'] : '';
5151 $codespasses = array();
5152
5153 if ($update['codepass'] != "") {
5154 $codespasses = explode("\n", $update["codepass"]);
5155 }
5156
5157 $codeadded = false;
5158
5159 $count_code = 0;
5160 $count_added_code = 0;
5161 $count_special_char = 0;
5162
5163 if (is_array($codespasses) && count($codespasses) > 0) {
5164 foreach ($codespasses as $k => $v) {
5165 $v = trim($v);
5166 if ($v != '') {
5167 $count_code++;
5168
5169 if ($this->InsertCode($v)) {
5170 $count_added_code++;
5171 $codeadded = true;
5172 }
5173
5174 if (!preg_match('/^[A-Za-z0-9_-]+$/', $v)) {
5175 $count_special_char++;
5176 $special_char = true;
5177 }
5178 }
5179 }
5180 }
5181
5182 if (isset($special_char) && $special_char) {
5183 $this->pie_post_array['error'] = esc_html__("Special characters are not allowed in code field.", "pie-register");
5184 }
5185
5186 if (!$codeadded && $count_code != $count_added_code && !isset($this->pie_post_array['error'])) {
5187 $count_not_added_code = $count_code - $count_added_code - $count_special_char;
5188 $this->pie_post_array['notice'] = $count_not_added_code . esc_html__(" invitation Code(s) already exists", "pie-register");
5189 } elseif ($codeadded) {
5190 if (isset($this->pie_post_array['invitation_code_usage']) && is_numeric($this->pie_post_array['invitation_code_usage']) && $this->pie_post_array['invitation_code_usage'] >= 0) {
5191 $piereg["invitation_code_usage"] = $this->pie_post_array['invitation_code_usage'];
5192
5193 if (update_option(OPTION_PIE_REGISTER, $piereg)) {
5194 $this->pie_post_array['notice'] = esc_html__("Invitation Code(s) added successfully", "pie-register");
5195 }
5196 }
5197
5198 if ($count_code != $count_added_code) {
5199 $count_not_added_code = $count_code - $count_added_code - $count_special_char;
5200 $this->pie_post_array['notice'] = $count_added_code . esc_html__(" invitation Code(s) added successfully.", "pie-register");
5201 if ($count_not_added_code != 0) {
5202 $this->pie_post_array['notice'] .= '<br/>' . $count_not_added_code . esc_html__(" invitation Code(s) already exists", "pie-register");
5203 }
5204 } else {
5205 $this->pie_post_array['notice'] = $count_added_code . esc_html__(" invitation Code(s) added successfully", "pie-register");
5206 }
5207 }
5208 }
5209 } else {
5210
5211 $this->pie_post_array['error'] = esc_html__("Invalid nonce.", "pie-register");
5212 }
5213 }
5214 $this->include_pr_menu_pages(PIEREG_DIR_NAME . '/menus/PieRegInvitationCodes.php');
5215 }
5216 function InsertCode($name)
5217 {
5218 if (empty($name) || trim($name) == '') return false;
5219
5220 $name_lower = htmlentities(strtolower($name));
5221 $name_upper = htmlentities(strtoupper($name));
5222
5223 global $wpdb;
5224
5225 $piereg = get_option(OPTION_PIE_REGISTER);
5226
5227 $codetable = $this->codeTable();
5228 $expiry = (isset($piereg['codeexpiry'])) ? $piereg['codeexpiry'] : "";
5229 $codes = $wpdb->get_results($wpdb->prepare("SELECT * FROM $codetable WHERE BINARY `name`=%s OR `name`=%s", $name_lower, $name_upper));
5230
5231 if (isset($wpdb->last_error) && !empty($wpdb->last_error)) {
5232 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
5233 }
5234 $counts = count($codes);
5235 $wpdb->flush();
5236
5237 if ($counts > 0) {
5238 return false;
5239 }
5240
5241 if (!preg_match(apply_filters('piereg_invitation_code_char_check', '/^[A-Za-z0-9_-]+$/'), $name)) return false;
5242
5243 $name = trim(preg_replace(apply_filters('piereg_invitation_code_char_verification', '/[^A-Za-z0-9_-]/'), '', $name));
5244 if (empty($name)) return false;
5245
5246 $date = date_i18n("Y-m-d");
5247
5248 $usage = intval(sanitize_key($_POST['invitation_code_usage']));
5249 $desc = trim(sanitize_textarea_field($_POST['invitation_code_description']));
5250 $expiry_date = "0000-00-00";
5251
5252 if (!empty($usage) && !is_numeric($usage) || $usage < 0) {
5253 return false;
5254 }
5255
5256 if (!$wpdb->query($wpdb->prepare("INSERT INTO `{$wpdb->prefix}pieregister_code` (`created`,`modified`,`name`,`count`,`status`,`code_usage`,`expiry_date`,`code_description`) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)", array($date, $date, htmlentities($name), $counts, "1", $usage, $expiry_date, $desc)))) {
5257 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
5258 }
5259 $wpdb->flush();
5260 return true;
5261 }
5262 function generateCSV()
5263 {
5264
5265 if (isset($_POST['piereg_export_users_nonce']) && wp_verify_nonce($_POST['piereg_export_users_nonce'], 'piereg_wp_exportusers_nonce')) {
5266 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_export_csv', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
5267
5268 global $wpdb;
5269 $user_table = $wpdb->prefix . "users";
5270 $user_meta_table = $wpdb->prefix . "usermeta";
5271
5272
5273 $fields = "";
5274 if (isset($this->pie_post_array['pie_fields_csv']) && sizeof($this->pie_post_array['pie_fields_csv']) > 0) {
5275 $fields = implode(',', array_keys($this->pie_post_array['pie_fields_csv']));
5276 }
5277
5278 if (!isset($this->pie_post_array['pie_fields_csv']) || sizeof($this->pie_post_array['pie_fields_csv']) == 0) {
5279 $this->pie_post_array['pie_fields_csv'] = array();
5280 }
5281
5282 if (!isset($this->pie_post_array['pie_meta_csv']) || sizeof($this->pie_post_array['pie_meta_csv']) == 0) {
5283 $this->pie_post_array['pie_meta_csv'] = array();
5284 }
5285
5286
5287 $heads = array_merge(array("id" => "User ID"), $this->pie_post_array['pie_fields_csv'], $this->pie_post_array['pie_meta_csv'], array("active" => "Verified/Unverified"));
5288
5289 $query = "SELECT ID ";
5290 if ($fields) {
5291 $fields_arr = explode(',', $fields);
5292 $fields_safe = array();
5293 foreach ($fields_arr as $field_item) {
5294 $fields_safe[] = '`' . sanitize_key($field_item) . '`';
5295 }
5296 $query .= ", " . implode(',', $fields_safe) . " ";
5297 }
5298 $query .= " FROM `{$wpdb->users}` ";
5299
5300 $params = array();
5301 if ($this->pie_post_array['date_start'] != "" || $this->pie_post_array['date_end'] != "") {
5302 $_date_start = date_i18n("Y-m-d", strtotime($this->pie_post_array['date_start']));
5303 $_date_end = date_i18n("Y-m-d", strtotime($this->pie_post_array['date_end']));
5304 $date_start = FALSE;
5305 $query .= " WHERE ";
5306
5307 if ($this->pie_post_array['date_start'] != "") {
5308 $query .= " user_registered >= %s ";
5309 $params[] = $_date_start . " 00:00:00";
5310 $date_start = TRUE;
5311 }
5312
5313 if ($this->pie_post_array['date_end'] != "") {
5314 if ($date_start) {
5315 $query .= " AND ";
5316 }
5317 $query .= " user_registered <= %s ";
5318 $params[] = $_date_end . " 23:59:59";
5319 }
5320 }
5321 $query .= " ORDER BY user_login ASC";
5322
5323 // User data being fetched from the database
5324 if (!empty($params)) {
5325 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
5326 $users = $wpdb->get_results($wpdb->prepare($query, array_values($params)), ARRAY_A);
5327 } else {
5328 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
5329 $users = $wpdb->get_results($query, ARRAY_A);
5330 }
5331 if (isset($wpdb->last_error) && !empty($wpdb->last_error)) {
5332 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
5333 }
5334 global $wp_roles, $wpdb;
5335 if (sizeof($users) > 0) {
5336 // Creating the CSV of the exported user's data
5337 $dfile = "pieregister_exported_users_" . date_i18n("Y-m-d-H:i") . ".csv";
5338 header('Content-Type: application/csv');
5339 header('Content-Disposition: attachment; filename=' . $dfile);
5340 header('Pragma: no-cache');
5341 // Set headers in the exported CSV
5342 echo '"' . implode('","', array_map('esc_html', $heads)) . '"' . "\r\n";
5343
5344 foreach ($users as $user_key => $user_value) {
5345 $content_data = '';
5346 foreach ($user_value as $single_user_data) {
5347 $content_data .= '"' . esc_html($single_user_data) . '",';
5348 }
5349 if (sizeof($this->pie_post_array['pie_meta_csv']) > 0) {
5350 foreach ($this->pie_post_array['pie_meta_csv'] as $key => $value) {
5351
5352 if ($key == "wp_capabilities") {
5353 $user = get_userdata($user_value['ID']);
5354
5355 $capabilities = $user->{$wpdb->prefix . 'capabilities'};
5356
5357 if (!isset($wp_roles))
5358 $wp_roles = new WP_Roles();
5359 $meta_value = '';
5360 foreach ($wp_roles->role_names as $role => $name):
5361 if (array_key_exists($role, $capabilities))
5362 $meta_value = $name;
5363 endforeach;
5364 } else {
5365 $meta_value = get_user_meta($user_value['ID'], $key, true);
5366 }
5367
5368 $content_data .= '"' . htmlentities($meta_value, ENT_QUOTES | ENT_IGNORE, "UTF-8") . '"' . ",";
5369 }
5370 }
5371 $verification_status = get_user_meta($user_value['ID'], 'active', true);
5372 $register_type = get_user_meta($user_value['ID'], 'register_type', true);
5373 if ($verification_status == 1) {
5374 $verification_status = 'Verified';
5375 } else if ($verification_status == 0) {
5376 switch ($register_type) {
5377 case "email_verify":
5378 $verification_status = esc_html__("E-mail Verification", "pie-register");
5379 break;
5380 case "admin_verify":
5381 $verification_status = esc_html__("Admin Verification", "pie-register");
5382 break;
5383 case "admin_email_verify":
5384 $verification_status = esc_html__("E-mail & Admin Verification", "pie-register");
5385 break;
5386 case "payment_verify":
5387 $verification_status = esc_html__("Payment Verification", "pie-register");
5388 break;
5389 }
5390 } else {
5391 $verification_status = 'Null';
5392 }
5393 $content_data .= esc_html($verification_status) . ',';
5394 // Set content in the exported CSV
5395 echo esc_html(rtrim($content_data, ','));
5396 echo "\r\n";
5397 }
5398 die(); // ask baqar
5399 } else {
5400 $this->pie_post_array['error_message'] = esc_html__("No Record Found", "pie-register");
5401 }
5402 } else {
5403 $this->pie_post_array['error_message'] = esc_html__("Invalid nonce.", "pie-register");
5404 }
5405 }
5406
5407 function csv_to_array($filename = '', $delimiter = ';')
5408 {
5409 if (!file_exists($filename) || !is_readable($filename))
5410 return FALSE;
5411
5412 $header = array();
5413 $data = array();
5414
5415 global $wp_filesystem;
5416 if (empty($wp_filesystem)) {
5417 require_once ABSPATH . 'wp-admin/includes/file.php';
5418 WP_Filesystem();
5419 }
5420
5421 $csv_content = $wp_filesystem->get_contents($filename);
5422
5423 if ($csv_content !== FALSE) {
5424 $lines = explode("\n", $csv_content);
5425 foreach ($lines as $line) {
5426 $row = str_getcsv($line, $delimiter);
5427 if (empty($row) || (count($row) == 1 && $row[0] === null)) continue;
5428 if (!$header)
5429 $header = $row;
5430 else
5431 $data[] = array_combine($header, $row);
5432 }
5433 }
5434 return $data;
5435 }
5436 function importUsers()
5437 {
5438 if (isset($_POST['piereg_import_users_nonce']) && wp_verify_nonce($_POST['piereg_import_users_nonce'], 'piereg_wp_importusers_nonce')) {
5439 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_import_users', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
5440
5441 $success_import = 0;
5442 $unsuccess_import = 0;
5443 $already_exist = 0;
5444
5445 if (empty(sanitize_file_name($_FILES['csvfile']['name']))) {
5446 $this->pie_post_array['error_message'] = apply_filters("piereg_didnt_select_file_to_import", esc_html__("You did not select a file to import users", 'pie-register'));
5447 return;
5448 }
5449 $checked_user_file = realpath($_FILES['csvfile']['tmp_name']);
5450 if (!$checked_user_file) {
5451 $this->pie_post_array['error_message'] = apply_filters("piereg_didnt_select_file_to_import", esc_html__("The file can't be processed", 'pie-register'));
5452 return;
5453 }
5454
5455 $ext = pathinfo(sanitize_file_name($_FILES['csvfile']['name']), PATHINFO_EXTENSION); // To get file extension
5456 if ($ext != "csv") {
5457 $this->pie_post_array['error_message'] = esc_html__("Invalid CSV file.", 'pie-register');
5458 return;
5459 }
5460 $current_csv_file_data = "";
5461 if ($_FILES['csvfile']['tmp_name']) {
5462 $csv_data = $this->csv_to_array($checked_user_file, ',');
5463 }
5464 if (!isset($csv_data[0]) or sizeof($csv_data[0]) < 2) {
5465 $this->pie_post_array['error_message'] = esc_html__("Invalid CSV File. It must contain all the default user fields.", 'pie-register');
5466 return;
5467 }
5468 $table_fields = array(
5469 //////////// DEFAULT FEILDS //////////
5470 "User ID" => "ID",
5471 "Username" => "user_login",
5472 "Password" => 'user_pass',
5473 "Nickname" => "user_nicename",
5474 "E-mail" => "user_email",
5475 "Website" => "user_url",
5476 "User Registered" => "user_registered",
5477 "Display name" => "display_name",
5478 ///////////// USER META /////////////
5479 "First Name" => "first_name",
5480 "Last Name" => "last_name",
5481 "Biographical Info" => "description",
5482 "Role" => "wp_capabilities",
5483 "Verified/Unverified" => "active"
5484 );
5485 $user_csv_data = array();
5486 $temp_data = array();
5487 $user_default_data = array();
5488 $user_meta_key = array();
5489 if (is_array($csv_data) && !empty($csv_data)) {
5490 foreach ($csv_data as $arr_key => $arr_val) {
5491 if (!isset($arr_val['ID'])) {
5492 if (isset($arr_val['Username'])) {
5493 $user = get_user_by('login', $arr_val['Username']);
5494 } else if (isset($arr_val['E-mail'])) {
5495 $user = get_user_by('login', $arr_val['E-mail']);
5496 }
5497 if (!is_null($user) && !empty($user)) {
5498 $arr_val['User ID'] = $user->ID;
5499 }
5500 }
5501 foreach ($arr_val as $head_key => $user_data) {
5502 switch ($head_key):
5503 case 'User ID':
5504 case 'Username':
5505 case 'Password':
5506 case 'Nickname':
5507 case 'E-mail':
5508 case 'Website':
5509 case 'User Registered':
5510 case 'Display name':
5511 if (mb_detect_encoding($user_data) !== "UTF-8"):
5512 $user_default_data[$table_fields[$head_key]] = pieregister_maybe_utf8_encode( $user_data );
5513 else:
5514 $user_default_data[$table_fields[$head_key]] = $user_data;
5515 endif;
5516 break;
5517 case 'First Name':
5518 case 'Last Name':
5519 case 'Biographical Info':
5520 case 'Role':
5521 if (mb_detect_encoding($user_data) !== "UTF-8"):
5522 $user_meta_key[$table_fields[$head_key]] = pieregister_maybe_utf8_encode( $user_data );
5523 else:
5524 $user_meta_key[$table_fields[$head_key]] = $user_data;
5525 endif;
5526 case 'Verified/Unverified':
5527 if ($user_data == "Verified") {
5528 $user_data = 1;
5529 } else if (($user_data !== "Verified") && ($user_data !== "Null")) {
5530 switch ($user_data) {
5531 case "E-mail Verification":
5532 $user_meta_key['register_type'] = 'email_verify';
5533 $user_data = 0;
5534 break;
5535 case "Admin Verification":
5536 $user_meta_key['register_type'] = 'admin_verify';
5537 $user_data = 0;
5538 break;
5539 case "E-mail & Admin Verification":
5540 $user_meta_key['register_type'] = 'admin_email_verify';
5541 $user_data = 0;
5542 break;
5543 case "Payment Verification":
5544 $user_meta_key['register_type'] = 'payment_verify';
5545 $user_data = 0;
5546 break;
5547 }
5548 }
5549 if ($user_data !== "Null") {
5550 if (mb_detect_encoding($user_data) !== "UTF-8"):
5551 $user_meta_key[$table_fields[$head_key]] = pieregister_maybe_utf8_encode( $user_data );
5552 else:
5553 $user_meta_key[$table_fields[$head_key]] = $user_data;
5554 endif;
5555 }
5556 break;
5557 endswitch;
5558 $temp_data[$table_fields[$head_key]] = $user_data;
5559 }
5560 $user_csv_data[$arr_key] = $temp_data;
5561
5562 if (empty($user_default_data['user_pass'])) {
5563 $user_default_data['user_pass'] = wp_generate_password();
5564 }
5565
5566 if (username_exists($user_default_data['user_login'])) {
5567 $already_exist++;
5568 if (isset($this->pie_post_array['update_existing_users']) && $this->pie_post_array['update_existing_users'] == "yes") {
5569 unset($user_default_data['user_pass']);
5570 $user_id = wp_update_user($user_default_data);
5571 if (is_int($user_id)) {
5572 $this->update_user_meta_by_array($user_id, $user_meta_key);
5573 }
5574 }
5575 } else {
5576 if (isset($user_default_data['ID']) && get_user_by('ID', $user_default_data['ID'])) {
5577 $already_exist++;
5578 if (isset($this->pie_post_array['update_existing_users']) && $this->pie_post_array['update_existing_users'] == "yes") {
5579 unset($user_default_data['user_pass']);
5580 $user_id = wp_update_user($user_default_data);
5581 if (is_int($user_id)) {
5582 $this->update_user_meta_by_array($user_id, $user_meta_key);
5583 }
5584 }
5585 } else {
5586 unset($user_default_data['ID']);
5587 $user_id = wp_insert_user($user_default_data);
5588 if (is_int($user_id)) {
5589 do_action('piereg_new_user_import', $user_id);
5590 if (isset($user_id)) {
5591 $this->update_user_meta_by_array($user_id, $user_meta_key);
5592 }
5593 $success_import++;
5594 }
5595 }
5596 }
5597
5598 unset($temp_data);
5599 unset($user_meta_key);
5600 unset($user_default_data);
5601 }
5602 }
5603
5604 if ($success_import)
5605 $this->pie_post_array['success_message'] = esc_html("$success_import user(s) imported.");
5606
5607 if ($unsuccess_import)
5608 $this->pie_post_array['error_message'] = esc_html("$unsuccess_import user(s) do not imported.");
5609
5610 if ($already_exist) {
5611 if (isset($this->pie_post_array['update_existing_users']) && $this->pie_post_array['update_existing_users'] == "yes") {
5612 if ($success_import) {
5613 $this->pie_post_array['success_message'] .= '<br />' . sprintf(
5614 /* translators: %d: number of users updated */
5615 esc_html__('%d user(s) Updated.', 'pie-register'),
5616 $already_exist
5617 );
5618 } else {
5619 $this->pie_post_array['success_message'] = esc_html("$already_exist user(s) Update.");
5620 }
5621 } else {
5622 $this->pie_post_array['error_message'] = sprintf(esc_html('%d user(s) already exist.'), $already_exist);
5623 }
5624 }
5625 } else {
5626 $this->pie_post_array['error_message'] = esc_html__("Invalid nonce.", "pie-register");
5627 }
5628 }
5629
5630 function update_user_meta_by_array($user_id, $user_meta_keys)
5631 {
5632 if (isset($user_id) and isset($user_meta_keys)) {
5633 if (is_array($user_meta_keys)) {
5634 foreach ($user_meta_keys as $key => $val) {
5635 if ($key == "wp_capabilities") {
5636 $wp_user_object = new WP_User($user_id);
5637 $wp_user_object->set_role($val);
5638 unset($wp_user_object);
5639 } else {
5640 update_user_meta($user_id, $key, $val);
5641 }
5642 }
5643 }
5644 }
5645 }
5646
5647 function SaveSettings()
5648 {
5649 // asnitize_post here
5650 if (isset($_POST['is_deactivate_plugin_license'], $_POST['piereg_deactivate_plugin_license_nonce']) && $_POST['is_deactivate_plugin_license'] == "true" && wp_verify_nonce($_POST['piereg_deactivate_plugin_license_nonce'], 'piereg_wp_deactivate_plugin_license_nonce')) {
5651 $piereg_api_manager_menu = new Piereg_API_Manager_Example_MENU();
5652
5653 if (! function_exists('get_plugins')) {
5654 require_once $this->admin_path . 'includes/plugin.php';
5655 }
5656 $activated_plugins = get_option('active_plugins');
5657 $list_all_plugins = get_plugins();
5658
5659 foreach ($list_all_plugins as $key => $plugin) {
5660 if (in_array($key, $activated_plugins) && strpos($plugin['Name'], 'Pie Register (Add on) - ') !== false) {
5661 $addon_name = str_replace(array('Pie Register (Add on) - ', '(', ')'), '', $plugin['Name']);
5662 $addon_name = str_replace(array(' ', '.'), '_', $addon_name);
5663 $is_addon = "addon_" . $addon_name;
5664
5665 if ($is_addon == 'addon_Authorize_Net') {
5666 $is_addon = 'addon_AuthNet';
5667 }
5668
5669 $plugin_status = get_option('piereg_api_manager_' . $is_addon . '_activated');
5670
5671 if ($plugin_status == 'Activated') {
5672 $piereg_api_manager_menu->wc_am_license_key_deactivation("on", array('is_addon' => sanitize_text_field($is_addon), 'is_addon_version' => sanitize_text_field($plugin['Version'])));
5673 }
5674 }
5675 }
5676
5677 $piereg_api_manager_menu->wc_am_license_key_deactivation("on");
5678 }
5679
5680 if (isset($_POST['is_deactivate_addon']) && $_POST['is_deactivate_addon'] == "true") {
5681 $piereg_pro_not_activated = (isset($_POST['piereg_pro_not_activated'])) ? true : false;
5682
5683 $piereg_api_manager_menu = new Piereg_API_Manager_Example_MENU();
5684 $piereg_api_manager_menu->wc_am_license_key_deactivation("on", array('is_addon' => $_POST['is_deactivate_addon_license'], 'is_addon_version' => $_POST['addon_software_version'], 'is_piereg_pro_inactive' => $piereg_pro_not_activated));
5685 }
5686
5687 $update = get_option(OPTION_PIE_REGISTER);
5688 if (isset($_POST['action']) && $_POST['action'] == 'pie_reg_update') {
5689 if (isset($_POST['payment_gateway_page'], $_POST['piereg_payment_gateway_page_nonce']) && wp_verify_nonce($_POST['piereg_payment_gateway_page_nonce'], 'piereg_wp_payment_gateway_page_nonce')) {
5690 $this->pie_post_array = $this->piereg_sanitize_post_data('payment_gateway_page', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
5691
5692 $update["enable_paypal"] = (isset($this->pie_post_array['enable_paypal'])) ? intval($this->pie_post_array['enable_paypal']) : "";
5693 $update["paypal_butt_id"] = $this->disable_magic_quotes_gpc($this->pie_post_array['piereg_paypal_butt_id']);
5694 $update["paypal_sandbox"] = $this->pie_post_array['piereg_paypal_sandbox'];
5695 } else if (isset($_POST['payment_gateway_general_settings'], $_POST['piereg_payment_gateway_settings_nonce']) && wp_verify_nonce($_POST['piereg_payment_gateway_settings_nonce'], 'piereg_wp_payment_gateway_settings_nonce')) {
5696
5697 $this->pie_post_array = $this->piereg_sanitize_post_data('payment_gateway_general_settings', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
5698
5699 $payment_success_msg = trim(((isset($this->pie_post_array['payment_success_msg']) && !empty($this->pie_post_array['payment_success_msg'])) ? $this->pie_post_array['payment_success_msg'] : esc_html__("Payment was successful.", "pie-register")));
5700 $update["payment_success_msg"] = $this->disable_magic_quotes_gpc($payment_success_msg);
5701
5702 $payment_faild_msg = trim(((isset($this->pie_post_array['payment_faild_msg']) && !empty($this->pie_post_array['payment_faild_msg'])) ? $this->pie_post_array['payment_faild_msg'] : esc_html__("Payment failed.", "pie-register")));
5703 $update["payment_faild_msg"] = $this->disable_magic_quotes_gpc($payment_faild_msg);
5704
5705 $payment_renew_msg = trim(((isset($this->pie_post_array['payment_renew_msg']) && !empty($this->pie_post_array['payment_renew_msg'])) ? $this->pie_post_array['payment_renew_msg'] : esc_html__("Account needs to be activated.", "pie-register")));
5706 $update["payment_renew_msg"] = $this->disable_magic_quotes_gpc($payment_renew_msg);
5707
5708
5709 $payment_already_activate_msg = trim(((isset($this->pie_post_array['payment_already_activate_msg']) && !empty($this->pie_post_array['payment_already_activate_msg'])) ? $this->pie_post_array['payment_already_activate_msg'] : esc_html__("Account is already active.", "pie-register")));
5710 $update["payment_already_activate_msg"] = $this->disable_magic_quotes_gpc($payment_already_activate_msg);
5711 } else if (isset($_POST['admin_email_notification_page'])) {
5712 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
5713 if (isset($_POST['piereg_admin_email_notification']) && wp_verify_nonce($_POST['piereg_admin_email_notification'], 'piereg_wp_admin_email_notification')) {
5714 $this->pie_post_array = $this->piereg_sanitize_post_data('admin_email_notification_page', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
5715
5716 $update['enable_admin_notifications'] = isset($this->pie_post_array['enable_admin_notifications']) ? intval($this->pie_post_array['enable_admin_notifications']) : 0;
5717 $update['enable_admin_notifications_profile_update'] = isset($this->pie_post_array['enable_admin_notifications_profile_update']) ? intval($this->pie_post_array['enable_admin_notifications_profile_update']) : 0;
5718 $update['enable_admin_notifications_cancel_subscription'] = isset($this->pie_post_array['enable_admin_notifications_cancel_subscription']) ? intval($this->pie_post_array['enable_admin_notifications_cancel_subscription']) : 0;
5719 $update['admin_sendto_email'] = trim($this->pie_post_array['admin_sendto_email']);
5720 $update['admin_sendto_email_profile_update'] = trim($this->pie_post_array['admin_sendto_email_profile_update']);
5721 $update['admin_sendto_email_cancel_subscription'] = trim($this->pie_post_array['admin_sendto_email_cancel_subscription']);
5722
5723 // $admin_from_name = mb_convert_encoding($this->pie_post_array['admin_from_name'],'HTML-ENTITIES','utf-8');
5724 $admin_from_name = sanitize_text_field($this->pie_post_array['admin_from_name']);
5725 $update['admin_from_name'] = $this->disable_magic_quotes_gpc($admin_from_name);
5726 $admin_from_name_profile_update = sanitize_text_field($this->pie_post_array['admin_from_name_profile_update']);
5727 $update['admin_from_name_profile_update'] = $this->disable_magic_quotes_gpc($admin_from_name_profile_update);
5728 $admin_from_name_cancel_subscription = sanitize_text_field($this->pie_post_array['admin_from_name_cancel_subscription']);
5729 $update['admin_from_name_cancel_subscription'] = $this->disable_magic_quotes_gpc($admin_from_name_cancel_subscription);
5730
5731 $update['admin_from_email'] = trim($this->pie_post_array['admin_from_email']);
5732 $update['admin_to_email'] = trim($this->pie_post_array['admin_to_email']);
5733 $update['admin_bcc_email'] = trim($this->pie_post_array['admin_bcc_email']);
5734
5735 $update['admin_from_email_profile_update'] = trim($this->pie_post_array['admin_from_email_profile_update']);
5736 $update['admin_to_email_profile_update'] = trim($this->pie_post_array['admin_to_email_profile_update']);
5737 $update['admin_bcc_email_profile_update'] = trim($this->pie_post_array['admin_bcc_email_profile_update']);
5738
5739 $update['admin_from_email_cancel_subscription'] = trim($this->pie_post_array['admin_from_email_cancel_subscription']);
5740 $update['admin_to_email_cancel_subscription'] = trim($this->pie_post_array['admin_to_email_cancel_subscription']);
5741 $update['admin_bcc_email_cancel_subscription'] = trim($this->pie_post_array['admin_bcc_email_cancel_subscription']);
5742
5743 $admin_subject_email = mb_convert_encoding($this->pie_post_array['admin_subject_email'], 'HTML-ENTITIES', 'utf-8');
5744 $update['admin_subject_email'] = $this->disable_magic_quotes_gpc($admin_subject_email);
5745 $admin_subject_email_profile_update = mb_convert_encoding($this->pie_post_array['admin_subject_email_profile_update'], 'HTML-ENTITIES', 'utf-8');
5746 $update['admin_subject_email_profile_update'] = $this->disable_magic_quotes_gpc($admin_subject_email_profile_update);
5747 $admin_subject_email_cancel_subscription = mb_convert_encoding($this->pie_post_array['admin_subject_email_cancel_subscription'], 'HTML-ENTITIES', 'utf-8');
5748 $update['admin_subject_email_cancel_subscription'] = $this->disable_magic_quotes_gpc($admin_subject_email_cancel_subscription);
5749
5750 $update['admin_message_email_formate'] = isset($this->pie_post_array['admin_message_email_formate']) ? intval($this->pie_post_array['admin_message_email_formate']) : 0;
5751 $update['admin_message_email_formate_profile_update'] = isset($this->pie_post_array['admin_message_email_formate_profile_update']) ? intval($this->pie_post_array['admin_message_email_formate_profile_update']) : 0;
5752 $update['admin_message_email_formate_cancel_subscription'] = isset($this->pie_post_array['admin_message_email_formate_cancel_subscription']) ? intval($this->pie_post_array['admin_message_email_formate_cancel_subscription']) : 0;
5753
5754 $admin_message_email = mb_convert_encoding($this->pie_post_array['admin_message_email'], 'HTML-ENTITIES', 'utf-8');
5755 $update['admin_message_email'] = $this->disable_magic_quotes_gpc($admin_message_email);
5756
5757 $admin_message_email_profile_update = mb_convert_encoding($this->pie_post_array['admin_message_email_profile_update'], 'HTML-ENTITIES', 'utf-8');
5758 $update['admin_message_email_profile_update'] = $this->disable_magic_quotes_gpc($admin_message_email_profile_update);
5759
5760 $admin_message_email_cancel_subscription = mb_convert_encoding($this->pie_post_array['admin_message_email_cancel_subscription'], 'HTML-ENTITIES', 'utf-8');
5761 $update['admin_message_email_cancel_subscription'] = $this->disable_magic_quotes_gpc($admin_message_email_cancel_subscription);
5762 } else {
5763 $this->pie_post_array['error'] = esc_html__("Invalid nonce.", "pie-register");
5764 }
5765 } else if (isset($_POST['user_email_notification_page'])) {
5766 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
5767 if (isset($_POST['piereg_user_email_notification']) && wp_verify_nonce($_POST['piereg_user_email_notification'], 'piereg_wp_user_email_notification')) {
5768
5769 $this->pie_post_array = $this->piereg_sanitize_post_data('user_email_notification_page', ((isset($_POST) && !empty($_POST)) ? $_POST : array()));
5770
5771 $pie_user_email_types = get_option('pie_user_email_types');
5772
5773 foreach ($pie_user_email_types as $val => $type) {
5774 if (isset($this->pie_post_array['user_from_name_' . $val])) {
5775 $user_from_name = mb_convert_encoding(trim($this->pie_post_array['user_from_name_' . $val]), 'HTML-ENTITIES', 'utf-8');
5776 }
5777 $update['user_from_name_' . $val] = $this->disable_magic_quotes_gpc($user_from_name);
5778
5779 if (isset($this->pie_post_array['user_from_email_' . $val])) {
5780 $user_from_email = mb_convert_encoding(trim($this->pie_post_array['user_from_email_' . $val]), 'HTML-ENTITIES', 'utf-8');
5781 }
5782 $update['user_from_email_' . $val] = $this->disable_magic_quotes_gpc($user_from_email);
5783
5784 if (isset($this->pie_post_array['user_to_email_' . $val])) {
5785 $user_to_email = mb_convert_encoding(trim($this->pie_post_array['user_to_email_' . $val]), 'HTML-ENTITIES', 'utf-8');
5786 }
5787 $update['user_to_email_' . $val] = $this->disable_magic_quotes_gpc($user_to_email);
5788
5789 $user_bcc_email = "";
5790 if (isset($this->pie_post_array['user_bcc_email_' . $val])) {
5791 $user_bcc_email = mb_convert_encoding(trim($this->pie_post_array['user_bcc_email_' . $val]), 'HTML-ENTITIES', 'utf-8');
5792 }
5793 $update['user_bcc_email_' . $val] = $this->disable_magic_quotes_gpc($user_bcc_email);
5794
5795 if (isset($this->pie_post_array['user_subject_email_' . $val])) {
5796 $user_subject_email = mb_convert_encoding(trim($this->pie_post_array['user_subject_email_' . $val]), 'HTML-ENTITIES', 'utf-8');
5797 }
5798 $update['user_subject_email_' . $val] = $this->disable_magic_quotes_gpc($user_subject_email);
5799
5800 if (isset($this->pie_post_array['user_formate_email_' . $val])) {
5801 $update['user_formate_email_' . $val] = intval($this->pie_post_array['user_formate_email_' . $val]);
5802 }
5803
5804
5805 $update['user_enable_' . $val] = isset($this->pie_post_array['user_enable_' . $val]) ? intval($this->pie_post_array['user_enable_' . $val]) : 0;
5806
5807 if (isset($this->pie_post_array['user_message_email_' . $val])) {
5808 $user_message_email = mb_convert_encoding(trim($this->pie_post_array['user_message_email_' . $val]), 'HTML-ENTITIES', 'utf-8');
5809 }
5810 $update['user_message_email_' . $val] = $this->disable_magic_quotes_gpc($user_message_email);
5811 }
5812 } else {
5813 $this->pie_post_array['error'] = esc_html__("Invalid nonce.", "pie-register");
5814 }
5815 }
5816
5817 update_option(OPTION_PIE_REGISTER, $update);
5818 $this->set_pr_global_options($update, OPTION_PIE_REGISTER);
5819 if (isset($error) && trim($error) != "") {
5820 $this->pie_post_array['PR_license_notice'] = $error;
5821 }
5822 if (!isset($this->pie_post_array['error']) && empty($this->pie_post_array['error']))
5823 $this->pie_post_array['notice'] = apply_filters("piereg_settings_saved", __('Settings Saved', 'pie-register'));
5824 }
5825 }
5826
5827
5828 /*
5829 * Get Field's Name For Post
5830 * Add this snipt at 17/10/2014
5831 */
5832 function getPieregFieldName($field, $no, $field_type = "")
5833 {
5834
5835 $fieldName = "";
5836 if (isset($field['type']) && !empty($field['type']) && isset($field['id'])) {
5837 switch ($field['type']) {
5838 case "username":
5839 case "password":
5840 case "custom_role": // dropdown_ur
5841 case "pricing":
5842 $fieldName = $field['type'];
5843 break;
5844 case "email":
5845 $fieldName = "e_mail";
5846 break;
5847 case "default":
5848 $fieldName = $field['field_name'];
5849 break;
5850 default:
5851 $fieldName = $field['type'] . "_" . $field['id'];
5852 break;
5853 }
5854 }
5855
5856 return $fieldName;
5857 }
5858 function addTextField($field, $no, $field_type)
5859 {
5860 $fieldPostName = $this->getPieregFieldName($field, $no, $field_type);
5861
5862 $name = $this->createFieldName($field, $no);
5863 $id = $this->createFieldID($field, $no);
5864
5865 echo '<input disabled="disabled" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" class="input_fields" placeholder="' . ((isset($field['placeholder'])) ? esc_attr($field['placeholder']) : "") . '" type="text" value="' . ((isset($field['default_value'])) ? esc_attr($field['default_value']) : "") . '" data-field-post-name="' . esc_attr($fieldPostName) . '" />';
5866 }
5867 function addInvitationField($field, $no)
5868 {
5869 $fieldPostName = $this->getPieregFieldName($field, $no);
5870 $name = $this->createFieldName($field, $no);
5871
5872 echo '<input type="hidden" id="default_' . esc_attr($field['type']) . '">';
5873 echo '<input disabled="disabled" id="invitation_field" name="' . esc_attr($name) . '" class="input_fields" placeholder="' . esc_attr($field['placeholder']) . '" type="text" value="' . ((isset($field['default_value'])) ? esc_attr($field['default_value']) : "") . '" />';
5874 }
5875 function addTermsField($field, $no)
5876 {
5877 $name = $this->createFieldName($field, $no);
5878
5879 echo '<input type="hidden" id="default_' . esc_attr($field['type']) . '">';
5880 echo '<label for="terms_field"><input type="checkbox" name="terms" id="terms_field" value="1" class="input_fields_checkbox" checked disabled>' . ((isset($field['label'])) ? esc_html($field['label']) : "") . '</label>';
5881 }
5882 function addDefaultField($field, $no)
5883 {
5884 $fieldPostName = $this->getPieregFieldName($field, $no);
5885 $name = $this->createFieldName($field, $no);
5886 $id = $this->createFieldID($field, $no);
5887 if ($field['field_name'] == "description") {
5888 echo '<textarea rows="5" cols="73" disabled="disabled" data-field_id="piereg_field_' . esc_attr($no) . '" id="default_' . esc_attr($field['field_name']) . '" name="' . esc_attr($name) . '" style="width:100%;" data-field-post-name="' . esc_attr($fieldPostName) . '" ></textarea>';
5889 } else {
5890 echo '<input disabled="disabled" id="default_' . esc_attr($field['field_name']) . '" data-field_id="piereg_field_' . esc_attr($no) . '" name="' . esc_attr($name) . '" class="input_fields" placeholder="' . (isset($field['placeholder']) ? esc_attr($field['placeholder']) : "") . '" type="text" data-field-post-name="' . esc_attr($fieldPostName) . '" />';
5891 }
5892 echo '<input type="hidden" name="field[' . esc_attr($field['id']) . '][id]" value="' . esc_attr($field['id']) . '" id="id_' . esc_attr($field['id']) . '">';
5893 echo '<input type="hidden" name="field[' . esc_attr($field['id']) . '][type]" value="default" id="type_' . esc_attr($field['id']) . '">';
5894 echo '<input type="hidden" name="field[' . esc_attr($field['id']) . '][label]" value="' . esc_attr($field['label']) . '" id="label_' . esc_attr($field['id']) . '">';
5895 echo '<input type="hidden" name="field[' . esc_attr($field['id']) . '][field_name]" value="' . esc_attr($field['type']) . '" id="label_' . esc_attr($field['id']) . '">';
5896 echo '<input type="hidden" id="default_' . esc_attr($field['type']) . '">';
5897 }
5898 function addEmail($field, $no)
5899 {
5900 $fieldPostName = $this->getPieregFieldName($field, $no);
5901 $name = $this->createFieldName($field, $no);
5902 $id = $this->createFieldID($field, $no);
5903 $confirm_email = "display:none;";
5904
5905 echo '<input disabled="disabled" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" data-field_id="piereg_field_' . esc_attr($no) . '" class="input_fields" placeholder="' . ((isset($field['placeholder'])) ? esc_attr($field['placeholder']) : "") . '" type="text" value="' . ((isset($field['default_value'])) ? esc_attr($field['default_value']) : "") . '" data-field-post-name="' . esc_attr($fieldPostName) . '" />';
5906 if (isset($field['confirm_email'])) {
5907 $confirm_email = "";
5908 }
5909
5910 $label2 = (isset($field['label2']) and !empty($field['label2'])) ? $field['label2'] : __("Confirm E-Mail", "pie-register");
5911 echo '</div><div style="' . esc_attr($confirm_email) . '" id="field_label2_' . esc_attr($no) . '" class="label_position confrim_email_label2"><label>' . esc_html($label2) . '</label></div><div class="fields_position"><div id="confirm_email_field_' . esc_attr($no) . '" style="' . esc_attr($confirm_email) . '" class="inner_fields"><input disabled="disabled" type="text" id="pie2_' . esc_attr($id) . '" class="input_fields" placeholder="' . ((isset($field['placeholder2'])) ? esc_attr($field['placeholder2']) : "") . '" > </div>';
5912 }
5913 function addPassword($field, $no)
5914 {
5915 $fieldPostName = $this->getPieregFieldName($field, $no);
5916 $name = $this->createFieldName($field, $no);
5917 $id = $this->createFieldID($field, $no);
5918
5919 echo '<input disabled="disabled" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" class="input_fields" placeholder="' . esc_attr($field['placeholder']) . '" type="text" value="" data-field-post-name="' . esc_attr($fieldPostName) . '" />';
5920
5921 $label2 = (isset($field['label2']) and !empty($field['label2'])) ? $field['label2'] : __("Confirm Password", "pie-register");
5922 echo '</div><div id="field_label2_' . esc_attr($no) . '" class="confirm_password_field_label label_position"><label>' . esc_html($label2) . '</label></div><div class="fields_position"><div id="confirm_email_field_' . esc_attr($no) . '" class="inner_fields"><input disabled="disabled" type="text" class="confirm_password_field input_fields" id="pie2_' . esc_attr($id) . '" placeholder="' . ((isset($field['placeholder2'])) ? esc_attr($field['placeholder2']) : "") . '" > </div>';
5923 }
5924
5925 function addUpload($field, $no)
5926 {
5927 $name = $this->createFieldName($field, $no);
5928 $id = $this->createFieldID($field, $no);
5929
5930 echo '<input disabled="disabled" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" class="input_fields" type="file" />';
5931 }
5932 function addProfilePicUpload($field, $no)
5933 {
5934 $name = $this->createFieldName($field, $no);
5935 $id = $this->createFieldID($field, $no);
5936 echo '<input disabled="disabled" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" class="input_fields" type="file" />';
5937 }
5938
5939 function addAddress($field, $no)
5940 {
5941 $name = $this->createFieldName($field, $no);
5942 $id = $this->createFieldID($field, $no);
5943
5944 echo '<input type="hidden" id="default_' . esc_attr($field['type']) . '">';
5945 echo '<div class="address" id="address_fields">
5946 <input disabled="disabled" type="text" class="input_fields">
5947 <label>' . esc_html__("Street Address", "pie-register") . '</label>
5948 </div>';
5949
5950 $hideAddress2 = "";
5951 if (isset($field['hide_address2']) && $field['hide_address2']) {
5952 $hideAddress2 = 'display:none;';
5953 }
5954
5955 echo '<div class="address" id="address_address2_' . esc_attr($no) . '" style="' . esc_attr($hideAddress2) . '">
5956 <input disabled="disabled" type="text" class="input_fields">
5957 <label>' . esc_html__("Address Line 2", "pie-register") . '</label>
5958 </div>
5959 <div class="address">
5960 <div class="address2">
5961 <input disabled="disabled" type="text" class="input_fields">
5962 <label>' . esc_html__("City", "pie-register") . '</label>
5963 </div>';
5964
5965 $hide_state = "";
5966 if (isset($field['hide_state']) && $field['hide_state']) {
5967 $hide_state = 'display:none;';
5968 $hide_usstate = 'display:none;';
5969 $hide_canstate = 'display:none;';
5970 } else {
5971 if ($field['address_type'] == "International") {
5972 $hide_state = '';
5973 } else if ($field['address_type'] == "United States") {
5974 $hide_usstate = '';
5975 } else if ($field['address_type'] == "Canada") {
5976 $hide_canstate = '';
5977 }
5978 }
5979
5980
5981 echo '<div class="address2 state_div_' . esc_attr($no) . '" id="state_' . esc_attr($no) . '" style="' . esc_attr($hide_state) . '">
5982 <input disabled="disabled" type="text" class="input_fields">
5983 <label>' . esc_html__("State / Province / Region", "pie-register") . '</label>
5984 </div>
5985 <div class="address2 state_div_' . esc_attr($no) . '" id="state_us_' . esc_attr($no) . '" style="' . ((isset($hide_usstate)) ? esc_attr($hide_usstate) : "") . '">
5986 <select disabled="disabled" id="state_us_field_' . esc_attr($no) . '">
5987 <option value="" selected="selected">' . esc_html($field['us_default_state']) . '</option>
5988
5989 </select>
5990 <label>' . esc_html__("State", "pie-register") . '</label>
5991 </div>
5992 <div class="address2 state_div_' . esc_attr($no) . '" id="state_canada_' . esc_attr($no) . '" style="' . ((isset($hide_canstate)) ? esc_attr($hide_canstate) : "") . '">
5993 <select disabled="disabled" id="state_canada_field_' . esc_attr($no) . '">
5994 <option value="" selected="selected">' . esc_html($field['canada_default_state']) . '</option>
5995
5996 </select>
5997 <label>' . esc_html__("Province", "pie-register") . '</label>
5998 </div>
5999 </div>
6000 <div class="address">
6001 <div class="address2">
6002 <input disabled="disabled" type="text" class="input_fields">
6003 <label>' . esc_html__("Zip / Postal Code", "pie-register") . '</label>
6004 </div>';
6005
6006 $hideCountry = "";
6007 if (isset($field['address_type']) && $field['address_type'] != "International") {
6008 $hideCountry = 'display:none;';
6009 }
6010
6011 echo '<div id="address_country_' . esc_attr($no) . '" class="address2" style="' . esc_attr($hideCountry) . '">
6012 <select disabled="disabled">
6013 <option>' . esc_html($field['default_country']) . '</option>
6014 </select>
6015 <label>' . esc_html__("Country", "pie-register") . '</label>
6016 </div>
6017 </div>';
6018 }
6019 //pie-register-woocommerce addon
6020 function addWooCommerceBillingAddress($field, $no)
6021 {
6022 if ($this->woocommerce_and_piereg_wc_addon_active) {
6023 $name = $this->createFieldName($field, $no);
6024 $id = $this->createFieldID($field, $no);
6025
6026 echo wp_kses_post(apply_filters("pieregister_print_woocommerce_billing_address_admin", $name, $id, $field, $no));
6027 }
6028 }
6029
6030 function addWooCommerceShippingAddress($field, $no)
6031 {
6032 if ($this->woocommerce_and_piereg_wc_addon_active) {
6033 $name = $this->createFieldName($field, $no);
6034 $id = $this->createFieldID($field, $no);
6035
6036 echo wp_kses_post(apply_filters("pieregister_print_woocommerce_shipping_address_admin", $name, $id, $field, $no));
6037 }
6038 }
6039
6040 function addTextArea($field, $no)
6041 {
6042 $fieldPostName = $this->getPieregFieldName($field, $no);
6043 $name = $this->createFieldName($field, $no);
6044 $id = $this->createFieldID($field, $no);
6045
6046 echo '<textarea disabled="disabled" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" data-field_id="piereg_field_' . esc_attr($no) . '" rows="' . esc_attr($field['rows']) . '" cols="' . esc_attr($field['cols']) . '" placeholder="' . esc_attr($field['placeholder']) . '" style="width:100%;" data-field-post-name="' . esc_attr($fieldPostName) . '">' . esc_textarea($field['default_value']) . '</textarea>';
6047 }
6048
6049 function addDropdown($field, $no)
6050 {
6051 $fieldPostName = $this->getPieregFieldName($field, $no);
6052
6053 $name = $this->createFieldName($field, $no);
6054 $id = $this->createFieldID($field, $no);
6055
6056 $multiple = "";
6057
6058 $data_f_post_name = 'data-field-post-name="' . $fieldPostName . '"';
6059 if ($field['type'] == "multiselect") {
6060 $multiple = 'multiple';
6061 $name .= "[]";
6062 $data_f_post_name = "";
6063 } elseif ($field['type'] == "custom_role") {
6064 echo '<input type="hidden" id="default_' . esc_attr($field['type']) . '">';
6065 }
6066 echo '<select ' . esc_attr($multiple) . ' id="' . esc_attr($name) . '" name="' . esc_attr($name) . '" data-field_id="piereg_field_' . esc_attr($no) . '" disabled="disabled" ' . esc_attr($data_f_post_name) . '>';
6067
6068 if (sizeof($field['value']) > 0) {
6069
6070 for ($a = 0; $a < sizeof($field['value']); $a++) {
6071 $selected = '';
6072 if (isset($field['selected']) && in_array($a, $field['selected'])) {
6073 $selected = 'selected="selected"';
6074 }
6075 echo '<option ' . esc_attr($selected) . ' value="' . esc_attr($field['value'][$a]) . '">' . esc_html($field['display'][$a]) . '</option>';
6076 }
6077 }
6078 echo '</select>';
6079 }
6080 function addNumberField($field, $no)
6081 {
6082 $fieldPostName = $this->getPieregFieldName($field, $no);
6083 $name = $this->createFieldName($field, $no);
6084 $id = $this->createFieldID($field, $no);
6085
6086 echo '<input disabled="disabled" id="' . esc_attr($id) . '" name="' . esc_attr($name) . '" class="input_fields" placeholder="' . esc_attr($field['placeholder']) . '" min="' . esc_attr($field['min']) . '" max="' . esc_attr($field['max']) . '" type="number" value="' . esc_attr($field['default_value']) . '" data-field-post-name="' . esc_attr($fieldPostName) . '"/>';
6087 }
6088 function addCheckRadio($field, $no)
6089 {
6090 if (sizeof($field['value']) > 0) {
6091 $fieldPostName = $this->getPieregFieldName($field, $no);
6092 echo '<div class="radio_wrap">';
6093 $name = $this->createFieldName($field, $no);
6094 $id = $this->createFieldID($field, $no);
6095
6096 echo '<input type="hidden" data-field-post-name="' . esc_attr($fieldPostName) . '"/>';
6097 for ($a = 0; $a < sizeof($field['value']); $a++) {
6098 $checked = '';
6099 if (isset($field['selected']) && is_array($field['selected']) && in_array($a, $field['selected'])) {
6100 $checked = 'checked="checked"';
6101 }
6102 echo '<div class="wrapcheckboxes"><label>' . esc_html($field['display'][$a]) . '</label>';
6103
6104 echo '<input ' . esc_attr($checked) . ' type="' . esc_attr($field['type']) . '" name="' . esc_attr($field['type']) . '_' . esc_attr($field['id']) . '[]" class="radio_fields" disabled="disabled" ></div>';
6105 }
6106 echo '</div>';
6107 }
6108 }
6109 function addDate($field, $no)
6110 {
6111 $name = $this->createFieldName($field, $no);
6112 $id = $this->createFieldID($field, $no);
6113
6114 $datefield = 'style="display:none;"';
6115 $datepicker = 'style="display:none;"';
6116 $datedropdown = 'style="display:none;"';
6117 $calendar_icon = 'style="display:none;"';
6118 $calendar_url = 'style="display:none;"';
6119
6120 if ($field['date_type'] == "datefield") {
6121 $datefield = "";
6122 } else if ($field['date_type'] == "datepicker") {
6123 $datepicker = "";
6124 if ($field['calendar_icon'] == "calendar") {
6125 $calendar_icon = "";
6126 }
6127 } else if ($field['date_type'] == "datedropdown") {
6128 $datedropdown = "";
6129 }
6130
6131 echo '<div class="time date_format_field" id="datefield_' . esc_attr($no) . '" ' . esc_attr($datefield) . '>
6132 <div class="time_fields" id="mm_' . esc_attr($no) . '">
6133 <input disabled="disabled" type="text" class="input_fields">
6134 <label>' . esc_html__("MM", "pie-register") . '</label>
6135 </div>
6136 <div class="time_fields" id="dd_' . esc_attr($no) . '">
6137 <input disabled="disabled" type="text" class="input_fields">
6138 <label>' . esc_html__("DD", "pie-register") . '</label>
6139 </div>
6140 <div class="time_fields" id="yyyy_' . esc_attr($no) . '">
6141 <input disabled="disabled" type="text" class="input_fields">
6142 <label>' . esc_html__("YYYY", "pie-register") . '</label>
6143 </div>
6144 </div>';
6145
6146 echo '<div class="time date_format_field" id="datepicker_' . esc_attr($no) . '" ' . esc_attr($datepicker) . '>
6147 <input disabled="disabled" type="text" class="input_fields">
6148 <img src="' . esc_url(PIEREG_PLUGIN_URL . 'assets/images/calendar.png') . '" id="calendar_image_' . esc_attr($no) . '" ' . esc_attr($calendar_icon) . ' /> </div>';
6149
6150
6151
6152 echo '<div class="time date_format_field" id="datedropdown_' . esc_attr($no) . '" ' . wp_kses($datedropdown, array('style')) . '>';
6153 echo '<div class="time_fields" id="month_' . esc_attr($no) . '">
6154 <select disabled="disabled">
6155 <option>' . esc_html__("Month", "pie-register") . '</option>
6156 </select>
6157 </div>
6158 <div class="time_fields" id="day_' . esc_attr($no) . '">
6159 <select disabled="disabled">
6160 <option>' . esc_html__("Day", "pie-register") . '</option>
6161 </select>
6162 </div>
6163 <div class="time_fields" id="year_' . esc_attr($no) . '">
6164 <select disabled="disabled">
6165 <option>' . esc_html__("Year", "pie-register") . '</option>
6166 </select>
6167 </div>
6168 </div>';
6169 }
6170 function piereg_get_small_string($string, $lenght = 100, $atitional_string = "....")
6171 {
6172 $string = wp_strip_all_tags(html_entity_decode($string, ENT_COMPAT, 'UTF-8'));
6173 if (strlen($string) > $lenght) {
6174 $string = wordwrap($string, $lenght, "<br />", true);
6175 $string = explode("<br />", $string);
6176 return $string[0] . $atitional_string;
6177 }
6178 return $string;
6179 }
6180 function addHTML($field, $no)
6181 {
6182 echo '<div id="field_' . esc_attr($no) . '" class="htmldiv" id="htmlbox_' . esc_attr($no) . '_div">' . wp_kses_post($this->piereg_get_small_string($field['html'], 200)) . '</div>';
6183 }
6184 function addSectionBreak($field, $no)
6185 {
6186 echo '<div style="width:100%;float:left;border: 1px solid #aaaaaa;margin-top:25px;"></div>';
6187 }
6188 function addPageBreak($field, $no)
6189 {
6190 echo '<img src="' . esc_url(PIEREG_PLUGIN_URL . 'assets/images/pagebreak.png') . '" style="max-width:100%;" />';
6191 }
6192 function addName($field, $no)
6193 {
6194 $label2 = (isset($field['label2']) and !empty($field['label2'])) ? $field['label2'] : __("Last Name", "pie-register");
6195 $placeholder = (isset($field['placeholder']) and !empty($field['placeholder'])) ? $field['placeholder'] : "";
6196 $placeholder2 = (isset($field['placeholder2']) and !empty($field['placeholder2'])) ? $field['placeholder2'] : "";
6197 $id = $this->createFieldID($field, $no);
6198
6199 echo '<input disabled="disabled" type="text" id="' . esc_attr($id) . '" placeholder="' . esc_attr($placeholder) . '" class="input_fields" data-field-post-name="first_name">';
6200 echo '<input type="hidden" id="default_' . esc_attr($field['type']) . '">';
6201
6202 echo '</div><div id="field_label2_' . esc_attr($no) . '" class="label_position last_name_field_label"><label>' . esc_html($label2) . '</label></div><div class="fields_position"> <input disabled="disabled" type="text" id="pie2_' . esc_attr($id) . '" placeholder="' . esc_attr($placeholder2) . '" class="input_fields last_name_field" data-field-post-name="last_name">';
6203 }
6204 function addTime($field, $no)
6205 {
6206
6207 $name = $this->createFieldName($field, $no);
6208 $id = $this->createFieldID($field, $no);
6209
6210 $format = "display:none;";
6211
6212 if ($field['time_type'] == "12") {
6213 $format = "";
6214 }
6215
6216 echo '<div class="time"><div class="time_fields"><input disabled="disabled" type="text" class="input_fields"><label>' . esc_html__("HH", "pie-register") . '</label></div><span class="colon">:</span><div class="time_fields"><input disabled="disabled" type="text" class="input_fields"><label>' . esc_html__("MM", "pie-register") . '</label></div><div id="time_format_field_' . esc_attr($no) . '" class="time_fields" style="' . esc_attr($format) . '"><select disabled><option>' . esc_html__("AM", "pie-register") . '</option><option>PM</option></select></div></div>';
6217 }
6218 function addCaptcha($field, $no)
6219 {
6220 $name = $this->createFieldName($field, $no);
6221 $id = $this->createFieldID($field, $no);
6222
6223 if (isset($field['recaptcha_type']) && $field['recaptcha_type'] == 2)
6224 echo '<img id="captcha_img" src="' . esc_url(PIEREG_PLUGIN_URL . 'assets/images/new-recatpcha.png') . '" data-captcha-img-src="' . esc_url(PIEREG_PLUGIN_URL . 'assets/images/') . '" />';
6225 else
6226 echo '<img id="captcha_img" src="' . esc_url(PIEREG_PLUGIN_URL . 'assets/images/recatpcha.jpg') . '" data-captcha-img-src="' . esc_url(PIEREG_PLUGIN_URL . 'assets/images/') . '" />';
6227
6228 echo '<p>' . '<strong>' . esc_html__("Note", "pie-register") . ':</strong> ' . esc_html__("Please ensure that Re-captcha keys are entered on the Settings page", "pie-register") . '</p>';
6229 echo '<input type="hidden" id="default_' . esc_attr($field['type']) . '">';
6230 }
6231 function addMath_Captcha($field, $no)
6232 {
6233 $name = $this->createFieldName($field, $no);
6234 $id = $this->createFieldID($field, $no);
6235
6236 echo '<img id="captcha_img" src="' . esc_url(PIEREG_PLUGIN_URL . 'assets/images/math_catpcha.png') . '" />';
6237 echo '<input type="hidden" id="default_' . esc_attr($field['type']) . '">';
6238 }
6239 function addList($field, $no)
6240 {
6241 if ($field['cols'] == "0")
6242 $field['cols'] = 1;
6243
6244 $name = $this->createFieldName($field, $no);
6245 $id = $this->createFieldID($field, $no);
6246 $width = 90 / $field['cols'];
6247
6248 for ($a = 1; $a <= $field['cols']; $a++) {
6249 echo '<input type="text" id="field_' . esc_attr($no) . '" class="input_fields" style="width:' . esc_attr($width) . '%;margin-right:2px;" >';
6250 }
6251
6252 echo '<img src="' . esc_url(PIEREG_PLUGIN_URL . 'assets/images/plus.png') . '" />';
6253 }
6254 function addPricing($field, $no)
6255 {
6256 $fieldPostName = $this->getPieregFieldName($field, $no);
6257 $name = $this->createFieldName($field, $no);
6258 $id = $this->createFieldID($field, $no);
6259
6260 echo '<input type="hidden" data-field-post-name="' . esc_attr($fieldPostName) . '"/>';
6261 echo '<input type="hidden" id="default_' . esc_attr($field['type']) . '">';
6262 if (isset($field['display']) && sizeof($field['display']) > 0) {
6263 echo '<div class="piereg_pricing_radio radio_wrap" ' . ((isset($field['field_as']) && $field['field_as'] == 1) ? 'style="display: none;"' : ((!isset($field['field_as'])) ? 'style="display: none;"' : "")) . '>';
6264 echo '<input type="hidden" data-field-post-name="' . esc_attr($fieldPostName) . '"/>';
6265 for ($a = 0; $a < sizeof($field['display']); $a++) {
6266 $checked = '';
6267 if (isset($field['selected']) && is_array($field['selected']) && in_array($a, $field['selected'])) {
6268 $checked = 'checked="checked"';
6269 }
6270 echo '<label>' . esc_html($field['display'][$a]) . '</label>';
6271 echo '<input ' . esc_attr($checked) . ' type="radio" name="' . esc_attr($field['type']) . '_' . esc_attr($field['id']) . '[]" class="radio_fields" disabled="disabled" >';
6272 }
6273 echo '<input type="hidden" id="default_' . esc_attr($field['type']) . '">';
6274 echo '</div>';
6275 }
6276
6277 echo '<div class="piereg_pricing_select select_wrap" ' . ((isset($field['field_as']) && $field['field_as'] != 1) ? 'style="display: none;"' : "") . '>';
6278
6279 echo '<select id="' . esc_attr($name) . '" name="piereg_pricing" data-field_id="piereg_pricing_field_' . esc_attr($no) . '" disabled="disabled" data-field-post-name="' . esc_attr($fieldPostName) . '">';
6280 if (isset($field['display']) && sizeof($field["display"]) > 0) {
6281 for ($a = 0; $a < sizeof($field["display"]); $a++) {
6282 $selected = '';
6283 if (in_array($a, $field['selected'])) {
6284 $selected = 'selected="selected"';
6285 }
6286 echo '<option ' . ( ($selected === 'selected="selected"') ? 'selected="selected"' : '' ) . ' value="' . esc_attr($field['value'][$a]) . '">' . esc_html($field['display'][$a]) . '</option>';
6287 }
6288 }
6289 echo '</select>';
6290 echo '</div>';
6291 }
6292 function createFieldName($field)
6293 {
6294 return "field_[" . $field['id'] . "]";
6295 }
6296 function createFieldID($field, $no)
6297 {
6298 return "field_" . $field['id'];
6299 }
6300
6301 private function log_ipn_results($success)
6302 {
6303 $hostname = gethostbyaddr(sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])));
6304 // Timestamps
6305 $text = '[' . gmdate('m/d/Y g:i A') . '] - ';
6306 // Success or failure being logged?
6307 if ($success)
6308 $this->ipn_status = $text . 'SUCCESS:' . $this->ipn_status . "!\n";
6309 else
6310 $this->ipn_status = $text . 'FAIL: ' . $this->ipn_status . "!\n";
6311 // Log the POST variables
6312 $this->ipn_status .= "[From:" . $hostname . "|" . sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])) . "]IPN POST Vars Received By Paypal_IPN Response API:\n";
6313 foreach ($this->ipn_data as $key => $value) {
6314 $this->ipn_status .= "$key=" . sanitize_text_field($value) . " \n";
6315 }
6316 // Log the response from the paypal server
6317 $this->ipn_status .= "IPN Response from Paypal Server:\n" . $this->ipn_response;
6318 $this->write_to_log();
6319 }
6320 private function write_to_log()
6321 {
6322 if (! $this->ipn_log)
6323 return; // is logging turned off?
6324
6325 if (file_exists(PIE_LOG_FILE)) {
6326 global $wp_filesystem;
6327 if (empty($wp_filesystem)) {
6328 require_once ABSPATH . 'wp-admin/includes/file.php';
6329 WP_Filesystem();
6330 }
6331 $wp_filesystem->put_contents(PIE_LOG_FILE, $this->ipn_status . "\r\n", FS_CHMOD_FILE);
6332 }
6333 }
6334
6335 public function get_user_by_hash($user_data)
6336 {
6337 $data_array = explode("__", $user_data);
6338 $user = get_user_by('id', intval($data_array[1]));
6339 return sanitize_email($user->user_email);
6340 }
6341
6342 public function validate_ipn()
6343 {
6344
6345 $piereg = get_option(OPTION_PIE_REGISTER);
6346
6347 /*
6348 * IPN LOG
6349 */
6350 $user_payment_log = array();
6351 $user_payment_log['method'] = "Paypal";
6352 $user_payment_log['type'] = "Hosted Button IPN ";
6353 $user_payment_log['responce'] = $_REQUEST;
6354 $user_payment_log['date'] = date_i18n("d-m-Y H:i:s");
6355 $user_email = $this->get_user_by_hash(sanitize_text_field(wp_unslash($_REQUEST['custom'])));
6356 $log_message = print_r($user_payment_log, 1);
6357 $this->pr_payment_log($log_message);
6358 /**
6359 * v3.7.1.5 - Temporary disabled log in database.
6360 * Payment logs are logging in log file only.
6361 */
6362 $this->piereg_save_payment_log_option($user_email, "PayPal", "Hosted Button IPN", $_REQUEST);
6363
6364 unset($log_message);
6365 unset($user_payment_log);
6366 //IPN log end
6367
6368 global $wpdb;
6369 $piereg = get_option(OPTION_PIE_REGISTER);
6370 $hostname = gethostbyaddr(sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])));
6371 if (! preg_match('/paypal\.com$/', $hostname)) {
6372 $this->ipn_status = 'Validation post isn\'t from PayPal';
6373 $this->log_ipn_results(false);
6374 return false;
6375 }
6376
6377 if (isset($this->txn_id) && ($_POST['txn_id'] == $this->txn_id)) {
6378 $this->ipn_status = "txn_id have a duplicate";
6379 $this->log_ipn_results(false);
6380 return false;
6381 }
6382 // parse the paypal URL
6383 $paypal_url = ($_POST['test_ipn'] == 1) ? PIE_SSL_SAND_URL : PIE_SSL_P_URL;
6384
6385 $response = wp_remote_post($paypal_url, array(
6386 'method' => 'POST',
6387 'body' => $_POST + array('cmd' => '_notify-validate'),
6388 'timeout' => 45,
6389 'sslverify' => true,
6390 ));
6391
6392 if (is_wp_error($response)) {
6393 $this->ipn_status = "wp_remote_post error: " . $response->get_error_message();
6394 $this->log_ipn_results(false);
6395 return false;
6396 }
6397
6398 $this->ipn_response = wp_remote_retrieve_body($response);
6399
6400 // Invalid IPN transaction. Check the $ipn_status and log for details.
6401 if (!preg_match("/VERIFIED/", $this->ipn_response)) {
6402 $this->ipn_status = "IPN NOT VERIFIED\n" . print_r($this->ipn_response, 1) . "\n";
6403 $this->log_ipn_results(false);
6404 return false;
6405 } else {
6406 $this->ipn_status = "IPN VERIFIED";
6407 //////////// Verify User /////////////
6408 // paypal Variable our custom variable
6409 if (isset($_REQUEST['paypal']) && !empty($_REQUEST['paypal']))
6410 $this->processPostPayment($_REQUEST['paypal']);
6411 //////////////////////////////////////
6412 $this->log_ipn_results(true);
6413 header("HTTP/1.1 200 OK");
6414 die();
6415 return true;
6416 }
6417 header("HTTP/1.1 402 Payment Required");
6418 die();
6419 }
6420 function ValidPUser()
6421 {
6422 global $wpdb;
6423 //$piereg = get_option( 'pie_register' );
6424 $piereg = get_option(OPTION_PIE_REGISTER);
6425
6426 if (isset($_POST['txn_id']) && $_GET['action'] == 'ipn_success') {
6427 //We have a IPN to Validate
6428 $this->validate_ipn();
6429 }
6430 if (isset($_GET['action']) && $_GET['action'] == 'payment_success') {
6431 $this->payment_success_cancel_after_register("payment=success");
6432 } elseif (isset($_GET['action']) && $_GET['action'] == 'payment_cancel') {
6433 /******************************************************/
6434 $user_id = intval(base64_decode($_GET['paypal']));
6435 $user_data = get_userdata($user_id);
6436 if (is_object($user_data)) {
6437 $form = new Registration_form();
6438 //$option = get_option( 'pie_register' );
6439 $option = get_option(OPTION_PIE_REGISTER);
6440 $subject = html_entity_decode($option['user_subject_email_payment_faild'], ENT_COMPAT, "UTF-8");
6441 $subject = $this->filterSubject($user_data, $subject);
6442 $message_temp = "";
6443 if ($option['user_formate_email_payment_faild'] == "0") {
6444 $message_temp = nl2br(wp_strip_all_tags($option['user_message_email_payment_faild']));
6445 } else {
6446 $message_temp = $option['user_message_email_payment_faild'];
6447 }
6448 $message = $form->filterEmail($message_temp, $user_data, "");
6449 $from_name = html_entity_decode($option['user_from_name_payment_faild'], ENT_COMPAT, "UTF-8");
6450 $from_email = $option['user_from_email_payment_faild'];
6451 $reply_email = $option['user_to_email_payment_faild'];
6452 //Headers
6453 $headers = 'MIME-Version: 1.0' . "\r\n";
6454 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
6455
6456 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
6457 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
6458
6459 if ($reply_email) {
6460 $headers .= "Reply-To: {$reply_email}\r\n";
6461 $headers .= "Return-Path: {$reply_email}\r\n";
6462 } else {
6463 $headers .= "Reply-To: {$from_email}\r\n";
6464 $headers .= "Return-Path: {$from_email}\r\n";
6465 }
6466
6467 if ((isset($option['user_enable_payment_faild']) && $option['user_enable_payment_faild'] == 1) && !wp_mail($user_data->user_email, $subject, $message, $headers)) {
6468 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
6469 }
6470 unset($user_data);
6471 }
6472 /******************************************************/
6473 $this->payment_success_cancel_after_register("payment=cancel");
6474 } else {
6475 return false;
6476 }
6477 }
6478 function processPostPayment($custom_user_data)
6479 {
6480 if (empty($custom_user_data))
6481 return false;
6482
6483 add_filter('wp_mail_content_type', array($this, 'set_html_content_type'));
6484
6485 $custom_user_data_decode = base64_decode($custom_user_data);
6486 $return_data = explode("|", $custom_user_data_decode);
6487 $hash = $return_data[0];
6488 $user_id = intval($return_data[1]);
6489
6490 #get_usermeta deprecated
6491 $check_hash = get_user_meta($user_id, "hash", true);
6492
6493 if ($check_hash != $hash)
6494 return false;
6495
6496 if (!is_numeric($user_id))
6497 return false;
6498
6499 $user = new WP_User($user_id);
6500 $option = get_option(OPTION_PIE_REGISTER);
6501 update_user_meta($user_id, 'active', 1);
6502 update_user_meta($user_id, 'pie_paypal_txn_id', sanitize_text_field($_POST['txn_id']));
6503 update_user_meta($user_id, 'pie_paypal_payer_id', sanitize_text_field($_POST['payer_id']));
6504
6505 //Sending E-Mail to newly active user
6506 $subject = html_entity_decode($option['user_subject_email_payment_success'], ENT_COMPAT, "UTF-8");
6507 $subject = $this->filterSubject($user, $subject);
6508 $user_email = $user->data->user_email;
6509 $message_temp = "";
6510 if ($option['user_formate_email_payment_success'] == "0") {
6511 $message_temp = nl2br(wp_strip_all_tags($option['user_message_email_payment_success']));
6512 } else {
6513 $message_temp = $option['user_message_email_payment_success'];
6514 }
6515
6516 $message = $this->filterEmail($message_temp, $user);
6517 $from_name = html_entity_decode($option['user_from_name_payment_success'], ENT_COMPAT, "UTF-8");
6518 $from_email = $option['user_from_email_payment_success'];
6519 $reply_email = $option['user_to_email_payment_success'];
6520
6521 //Headers
6522 $headers = 'MIME-Version: 1.0' . "\r\n";
6523 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
6524 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
6525 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
6526 if ($reply_email) {
6527 $headers .= "Reply-To: {$reply_email}\r\n";
6528 $headers .= "Return-Path: {$reply_email}\r\n";
6529 } else {
6530 $headers .= "Reply-To: {$from_email}\r\n";
6531 $headers .= "Return-Path: {$from_email}\r\n";
6532 }
6533 if ((isset($option['user_enable_payment_success']) && $option['user_enable_payment_success'] == 1) && !wp_mail($user_email, $subject, $message, $headers)) {
6534 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
6535 }
6536 // mailchimp related code within PR
6537 do_action('pireg_after_verification_users', $user);
6538 }
6539
6540 function Add_payment_option_PaypalStandard($field_as)
6541 {
6542 $PR_options = "";
6543 $check_payment = $this->get_pr_global_options();
6544 if ($check_payment["enable_paypal"] == 1 && !empty($check_payment['paypal_butt_id'])) {
6545 if ($field_as == 0)
6546 $PR_options = '<div class="piereg_payment_selection piereg_payment_selection_paypalStandard"><label><input type="radio" name="select_payment_method" id="select_payment_method_PaypalStandard" value="PaypalStandard" data-img="' . esc_url(plugins_url("assets/images/PaypalStandard-logo.png", __FILE__)) . '" class="input_fields radio_fields piereg_select_payment_method" /><img src="' . esc_url(plugins_url("assets/images/paypal_std_btn.png", __FILE__)) . '" /></label></div>';
6547 else
6548 $PR_options = '<option value="PaypalStandard" data-img="' . esc_url(plugins_url("assets/images/PaypalStandard-logo.png", __FILE__)) . '">' . esc_html__("Paypal (Standard)", "pie-register") . '</option>';
6549 }
6550 return $PR_options;
6551 }
6552
6553 function set_html_content_type()
6554 {
6555 return 'text/html';
6556 }
6557 function deleteUsers($user_id = 0, $user_email = "", $user_registered = "", $autodelete = false)
6558 {
6559 $option = get_option(OPTION_PIE_REGISTER);
6560 $grace_period = isset($option['grace_period']) ? ((int)$option['grace_period']) : 0;
6561 $is_active = get_user_meta($user_id, 'active', true);
6562
6563 if (isset($option['enable_paypal']) && $option['enable_paypal'] == 1) {
6564 $grace = $grace_period;
6565 } else if (($this->check_enable_payment_method()) == "true") {
6566 $payment_setting_remove_user_days = isset($option['payment_setting_remove_user_days']) ? $option['payment_setting_remove_user_days'] : 0;
6567 $grace = ((int)$payment_setting_remove_user_days);
6568 } else {
6569 $grace = $grace_period;
6570 }
6571
6572 $register_type = get_user_meta($user_id, "register_type", true);
6573
6574
6575 if (($grace != 0 and $user_id != 0) and ($user_email != "" and $user_registered != "") and ($register_type != '' and $register_type != "admin_verify") && $is_active == 0) {
6576 $date = date_i18n("Y-m-d 00:00:00", strtotime("-{$grace} days"));
6577
6578 if ($user_registered < $date) {
6579 global $errors;
6580 $errors = new WP_Error();
6581
6582 if ((isset($option['user_enable_user_perm_blocked_notice']) && $option['user_enable_user_perm_blocked_notice'] == 1)) {
6583 $this->wp_mail_send($user_email, "user_perm_blocked_notice");
6584 }
6585
6586 global $wpdb;
6587 $user_table = $wpdb->prefix . "users";
6588 $user_meta_table = $wpdb->prefix . "usermeta";
6589 if (!$wpdb->query($wpdb->prepare("DELETE FROM $user_meta_table WHERE `user_id` = %d", $user_id))) {
6590 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
6591 }
6592 if (!$wpdb->query($wpdb->prepare("DELETE FROM $user_table WHERE `ID` = %d", $user_id))) {
6593 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
6594 }
6595
6596 if ($autodelete === false) {
6597 $errors->add('login-error', apply_filters("piereg_msg_deleted_unverified_user", esc_html__('Account has been removed because it was not verified before the grace period expired.', 'pie-register')));
6598 wp_logout();
6599 }
6600
6601 return true;
6602 }
6603 }
6604 return false;
6605 }
6606 function deleteUnverifiedUsers()
6607 {
6608
6609 $args = array(
6610 'meta_query' => array(
6611 'relation' => 'AND',
6612 array(
6613 'key' => 'active',
6614 'value' => '0',
6615 'compare' => '='
6616 ),
6617 array(
6618 'key' => 'register_type',
6619 'value' => 'email_verify',
6620 'compare' => '='
6621 )
6622 )
6623 );
6624
6625 $user_query = new WP_User_Query($args);
6626 $users = $user_query->get_results();
6627
6628 if (count($users) > 0) {
6629 foreach ($users as $user) {
6630 $user_email = $user->user_email;
6631 $user_login = $user->user_login;
6632
6633 if ($this->deleteUsers($user->ID, $user->user_email, $user->user_registered, true)) {
6634 $deleted = get_option("deleted_users");
6635
6636 $deleted["pie_user_" . $user_login] = $user_email;
6637 update_option("deleted_users", $deleted);
6638 }
6639 }
6640 }
6641 }
6642 function unique_user()
6643 {
6644 $username = sanitize_user($_REQUEST['fieldValue']);
6645 $validateId = sanitize_key($_REQUEST['fieldId']);
6646
6647 $arrayToJs = array();
6648 $arrayToJs[0] = $validateId;
6649
6650 if (!username_exists($username)) { // validate??
6651 $arrayToJs[1] = true; // RETURN TRUE
6652 echo json_encode($arrayToJs); // RETURN ARRAY WITH success
6653 } else {
6654 for ($x = 0; $x < 1000000; $x++) {
6655 if ($x == 990000) {
6656 $arrayToJs[1] = false;
6657 echo json_encode($arrayToJs); // RETURN ARRAY WITH ERROR
6658 }
6659 }
6660 }
6661 die();
6662 }
6663 function outputRegForm($fromwidget = false, $form_id = "0", $title = "true", $description = "true")
6664 {
6665 $form = new Registration_form_template();
6666 $success = '';
6667 $error = '';
6668 $option = get_option(OPTION_PIE_REGISTER);
6669 $registration_from_fields = '<div class="pieregformWrapper pieregWrapper">';
6670 $registration_from_fields .= '<div id="show_pie_register_error_js" class="piereg_entry-content"></div>';
6671
6672 $IsWidgetForm = "";
6673 if ($fromwidget)
6674 $IsWidgetForm = "widget_";
6675
6676 $registration_from_fields .= '<div id="pie_register_reg_form">';
6677
6678 $registration_from_fields = apply_filters('pie_register_frontend_output_before', $registration_from_fields);
6679
6680 /* Anyone can register */
6681 if ($this->is_anyone_can_register() || $this->is_pr_preview) {
6682 if (false === $this->is_pr_preview):
6683 $registration_from_fields .= '<form enctype="multipart/form-data" class="pie_register_reg_form" id="pie_' . esc_attr((trim($IsWidgetForm))) . 'regiser_form" method="post" action="' . esc_url_raw(htmlentities($_SERVER['REQUEST_URI'])) . '" data-form="' . esc_attr($form_id) . '">';
6684 if (function_exists('wp_nonce_field')):
6685 $registration_from_fields .= wp_nonce_field('piereg_wp_registration_form_nonce', 'piereg_registration_form_nonce', true, false);
6686 endif;
6687 else:
6688 $registration_from_fields .= '<form onsubmit="return false" class="prRegFormPreview" id="pie_' . esc_attr((trim($IsWidgetForm))) . 'regiser_form" data-form="' . esc_attr($form_id) . '">';
6689 endif;
6690
6691
6692 $output = $form->printFields($fromwidget, $form_id, $title, $description);
6693 if ($form->countPageBreaks() > 1) {
6694 $registration_from_fields .= '<div class="piereg_progressbar"></div>';
6695 }
6696 $registration_from_fields .= $output;
6697 if (false === $this->is_pr_preview):
6698 $registration_from_fields .= '</form>';
6699 else:
6700 $registration_from_fields .= '</form>';
6701 endif;
6702 } else {
6703 $registration_from_fields .= '<div class="alert alert-warning"><p class="piereg_warning">' . esc_html__("User registration is currently not allowed.", "pie-register") . '</p></div>';
6704 }
6705 $registration_from_fields = apply_filters('pie_register_frontend_output_after', $registration_from_fields);
6706
6707 $registration_from_fields .= '</div></div>';
6708
6709 $this->piereg_forms_per_page[$form_id] = $this->getCurrentFields($form_id);
6710
6711 return $registration_from_fields;
6712 }
6713 function showForm($id = "", $title = "true", $description = "true")
6714 {
6715 global $errors, $piereg_post_array;
6716 $option = get_option(OPTION_PIE_REGISTER);
6717 add_filter('wp_mail_content_type', array($this, 'set_html_content_type'));
6718 $classes_preset = array('piereg_container', 'pieregWrapper');
6719
6720 $classes = apply_filters('pie_register_frontend_container_class', $classes_preset);
6721
6722 $classes = implode(' ', $classes);
6723
6724 $output = '<div class="' . esc_attr($classes) . '">';
6725 if (empty($this->pie_post_array)) {
6726 $this->pie_post_array = $piereg_post_array;
6727 }
6728
6729 if (isset($_GET['action'], $_GET['key']) && $_GET['action'] == 'pie-ic' && !empty($_GET['key'])) {
6730 $invite_code = sanitize_text_field(base64_decode(urldecode(trim($_GET['key']))));
6731 $invite_code = explode('|', $invite_code);
6732 $invite_code = ($invite_code[1]) ? $invite_code[1] : "";
6733 $allowed_invite_codes = [];
6734 $manage_settings = maybe_unserialize(get_option("pie_fields"));
6735 foreach ($manage_settings as $managed_setting) {
6736 if ($managed_setting['type'] == 'invitation') {
6737 if (isset($managed_setting['allowed_codes'])) {
6738 $allowed_invite_codes = $managed_setting['allowed_codes'];
6739
6740 if (!in_array($invite_code, $allowed_invite_codes)) {
6741 $this->pie_post_array['error'] = apply_filters("piereg_invalid_invitaion_code", '<strong>' . ucwords(esc_html__('error', 'pie-register')) . '</strong>: Invalid invitation code');
6742 }
6743 break;
6744 }
6745 }
6746 }
6747 }
6748
6749 if (isset($this->pie_post_array['success']) && $this->pie_post_array['success'] != "")
6750 $output .= '<p class="piereg_message">' . apply_filters('piereg_messages', $this->pie_post_array['success'], "pie-register") . '</p>';
6751 if (isset($this->pie_post_array['error']) && $this->pie_post_array['error'] != "")
6752 $output .= '<p class="piereg_login_error">' . apply_filters('piereg_messages', $this->pie_post_array['error'], "pie-register") . '</p>';
6753
6754 if (isset($this->pie_post_array['registration_success']) && $this->pie_post_array['registration_success'] != "") {
6755 $output .= '<p class="piereg_message">' . apply_filters('piereg_messages', $this->pie_post_array['registration_success'], "pie-register") . '</p>';
6756 unset($_POST);
6757 }
6758 if (isset($errors->errors) && sizeof($errors->errors) > 0) {
6759 $error = "";
6760 foreach ($errors->errors as $key => $err) {
6761 if ($key != "login-error")
6762 $error .= $err[0] . "<br />";
6763 }
6764 if (!empty($error))
6765 $output .= '<p class="piereg_login_error">' . apply_filters('piereg_messages', $error, "pie-register") . '</p>';
6766 }
6767 $output .= $this->outputRegForm(FALSE, $id, $title, $description);
6768 $output .= '</div>';
6769 return $output;
6770 }
6771 function showLoginForm()
6772 {
6773 $this->piereg_ssl_template_redirect();
6774 global $errors, $pagenow;
6775 $option = $this->get_pr_global_options();
6776
6777 // For Form with Gutenberg or WPBakery Preview
6778 $this->is_pr_preview = ((isset($_GET['context']) && $_GET['context'] == 'edit') || (isset($_GET['vc_editable']) && $_GET['vc_editable'] == 'true')) ? true : $this->is_pr_preview;
6779
6780 if (isset($_GET['pr_renew_account']) && $_GET['pr_renew_account'] == true) {
6781 $this->pie_post_array['warning'] = esc_html__("Please renew your account", "pie-register");
6782 if (file_exists(PIEREG_DIR_NAME . "/renew_account.php"))
6783 include_once("renew_account.php");
6784
6785 $is_renew_after_auth = false;
6786 $user_array = array();
6787
6788 if (isset($_GET['auth'], $_GET['auth_key']) && !empty($_GET['auth']) && !empty($_GET['auth_key'])) {
6789 $user_name = sanitize_text_field(urldecode($_GET['auth']));
6790 $auth_key = sanitize_text_field(urldecode($_GET['auth_key']));
6791
6792 $user_name = sanitize_user(urldecode(base64_decode($user_name)));
6793 $user = get_user_by("login", $user_name);
6794
6795 if (!empty($user)) {
6796 $auth_key = sanitize_text_field($_GET['auth_key']);
6797 $auth_key_hash = get_user_meta($user->ID, "pr_renew_account_hash", true);
6798 if (!empty($auth_key_hash)) {
6799 if (trim($auth_key) == trim($auth_key_hash)) {
6800 $is_renew_after_auth = true;
6801 $user_array['username'] = $user->data->user_login;
6802 $user_array['email'] = $user->data->user_email;
6803 }
6804 }
6805 }
6806 }
6807
6808 $PR_show_renew_account = PR_show_renew_account($is_renew_after_auth, $user_array);
6809 return $PR_show_renew_account;
6810 } else {
6811 if (is_user_logged_in() && !$this->is_pr_preview && !is_admin()) {
6812 return apply_filters("pie_login_form_logged_in_msg", __("<p>You are already logged in.</p>", "pie-register"));
6813 }
6814
6815 $this->set_pr_stats("login", "view");
6816 if (file_exists(PIEREG_DIR_NAME . "/login_form.php"))
6817 include_once("login_form.php");
6818 $output = pieOutputLoginForm();
6819 return $output;
6820 }
6821 }
6822
6823 function showForgotPasswordForm()
6824 {
6825 $this->piereg_ssl_template_redirect();
6826 global $errors;
6827
6828 $option = get_option(OPTION_PIE_REGISTER);
6829 // For Form with Gutenberg Or WPBakery Preview
6830 $this->is_pr_preview = ((isset($_GET['context']) && $_GET['context'] == 'edit') || (isset($_GET['vc_editable']) && $_GET['vc_editable'] == 'true')) ? true : $this->is_pr_preview;
6831
6832 if (!is_admin() && is_user_logged_in() && !$this->is_pr_preview) {
6833 return apply_filters("pie_forgot_form_logged_in_msg", __("<p>You are already logged in.</p>", "pie-register"));
6834 } else {
6835 $this->set_pr_stats("forgot", "view");
6836
6837 if (file_exists(PIEREG_DIR_NAME . "/forgot_password.php"))
6838 include_once("forgot_password.php");
6839 $output = pieResetFormOutput();
6840 return $output;
6841 }
6842 }
6843
6844 function showProfile()
6845 {
6846 $option = $this->get_pr_global_options();
6847 $this->piereg_ssl_template_redirect();
6848 global $current_user, $pie_success, $pie_error, $pie_error_msg, $pie_suucess_msg, $profile_updated;
6849 if (is_user_logged_in()) {
6850
6851 global $current_user;
6852 wp_get_current_user();
6853 $form_id = get_user_meta($current_user->ID, "user_registered_form_id", true);
6854 if (isset($_GET['edit_user']) && $_GET['edit_user'] == "1") {
6855 $form = new Edit_form($current_user, $form_id);
6856 if (isset($_POST['pie_submit_update'], $_POST['piereg_edit_profile_nonce']) && wp_verify_nonce($_POST['piereg_edit_profile_nonce'], 'piereg_wp_edit_profile_nonce')) {
6857 $form->error = "";
6858 $errors = new WP_Error();
6859 $errors = $form->validateRegistration($errors);
6860 if (sizeof($errors->errors) > 0) {
6861 foreach ($errors->errors as $err) {
6862 $form->error .= $err[0] . "<br />";
6863 }
6864 } else {
6865 $user_data = array('ID' => $current_user->ID);
6866 if (isset($_POST['url'])) {
6867 $user_data["user_url"] = esc_url_raw($_POST['url']);
6868 $form->pie_success = 1;
6869 }
6870
6871 if ($current_user->data->user_email != $_POST['e_mail']) {
6872 $user_data["user_email"] = sanitize_email($_POST['e_mail']);
6873 $form->pie_success = 1;
6874 }
6875 if (isset($_POST['old_password']) && wp_check_password($_POST['old_password'], $current_user->data->user_pass, $current_user->ID) && $_POST['password'] != '') {
6876
6877 if (isset($_POST['confirm_password'])) {
6878 if ($_POST['password'] == $_POST['confirm_password']) {
6879 $user_data["user_pass"] = trim($_POST['password']);
6880 $form->pie_success = 1;
6881 }
6882 } else {
6883 $user_data["user_pass"] = trim($_POST['password']);
6884 $form->pie_success = 1;
6885 }
6886 }
6887
6888 $this->pie_post_array = $this->piereg_sanitize_post_data_escape(((isset($_POST) && !empty($_POST)) ? $_POST : array()));
6889
6890 # newlyAddedHookFilter
6891 do_action('piereg_update_profile_event', $current_user->ID, $form_id, $this->pie_post_array);
6892
6893 $user = get_userdata($current_user->ID);
6894
6895 $id = wp_update_user($user_data);
6896 // $form->UpdateUser();
6897 if ($form->UpdateUser() == 1) {
6898 $profile_updated = 1;
6899 }
6900 $this->send_admin_notifications($option, $user, $user->data->user_pass);
6901 do_action('piereg_after_update_profile_event');
6902 }
6903 }
6904 $output = '';
6905 $output .= '<div class="piereg_container pieregWrapper">';
6906 if ($form->pie_success)
6907 $output .= '<div class="alert alert-success"><p class="piereg_message">' . $form->pie_success_msg . '</p></div>';
6908
6909 elseif ($form->error != "")
6910 $output .= '<div class="alert alert-danger"><p class="piereg_login_error">' . $form->error . '</p></div>';
6911
6912 if (isset($this->pie_post_array['success']) && $this->pie_post_array['success'] != "")
6913 $output .= '<p class="piereg_message">' . apply_filters('piereg_messages', $this->pie_post_array['success']) . '</p>';
6914
6915 if (isset($this->pie_post_array['error']) && $this->pie_post_array['error'] != "")
6916 $output .= '<p class="piereg_login_error">' . apply_filters('piereg_messages', $this->pie_post_array['error']) . '</p>';
6917
6918 if (isset($_GET['pr_msg'], $_GET['type']) && !empty($_GET['pr_msg']) && $_GET['type'] == "success")
6919 $output .= '<p class="piereg_message">' . apply_filters('piereg_messages', sanitize_text_field(base64_decode($_GET['pr_msg']))) . '</p>';
6920 elseif (isset($_GET['pr_msg'], $_GET['type']) && !empty($_GET['pr_msg']) && $_GET['type'] == "error")
6921 $output .= '<p class="piereg_login_error">' . apply_filters('piereg_messages', sanitize_text_field(base64_decode($_GET['pr_msg']))) . '</p>';
6922
6923 if (file_exists(PIEREG_DIR_NAME . "/edit_form.php"))
6924 require_once(PIEREG_DIR_NAME . "/edit_form.php");
6925
6926 $output .= pie_edit_userdata($form_id);
6927 $output .= '</div>';
6928 return $output;
6929 } else {
6930 $form_id = get_user_meta($current_user->ID, "user_registered_form_id", true);
6931 if ($form_id == "") {
6932 $form_free_id = $this->regFormForFreeVers();
6933 update_user_meta($current_user->ID, 'user_registered_form_id', $form_free_id);
6934 $form_id = $form_free_id;
6935 }
6936
6937 $profile_front = new Profile_front($current_user, $form_id);
6938 // Newly added hook to make changes to the profile content
6939 $profile_form_data = apply_filters('piereg_after_profile_printed', $profile_front->print_user_profile($form_id));
6940 return $profile_form_data;
6941 }
6942 } else {
6943 $notloggedinmsg = esc_html__('Please', 'pie-register') . ' <a class="linkStyle1" href="' . esc_url(wp_login_url()) . '">' . esc_html__('login', 'pie-register') . '</a> ' . esc_html__('to see your profile', 'pie-register');
6944
6945 $notloggedinmsg = apply_filters('piereg_profile_if_not_loggedin', $notloggedinmsg); # newlyAddedHookFilter
6946
6947 return $notloggedinmsg;
6948 }
6949 }
6950
6951
6952 /* GDPR - Personal Data Exporter */
6953 /*
6954 function my_plugin_exporter( $email_address, $page = 1 ) {
6955
6956 $export_items = array();
6957 $user = get_user_by('email', $email_address);
6958 $user_ID = $user->ID;
6959
6960 $data = array(
6961 array(
6962 'name' => __( 'Commenter Latitude' ),
6963 'value' => 'ABC'
6964 ),
6965 array(
6966 'name' => __( 'Commenter Longitude' ),
6967 'value' => 'XYZ'
6968 )
6969 );
6970 $export_items[] = array(
6971 'group_id' => 167,
6972 'group_label' => "Comments",
6973 'item_id' => 265,
6974 'data' => $data,
6975 );
6976
6977 */
6978 /*
6979 $comments = get_comments(
6980 array(
6981 'author_email' => $email_address,
6982 'number' => $number,
6983 'paged' => $page,
6984 'order_by' => 'comment_ID',
6985 'order' => 'ASC',
6986 )
6987 );
6988
6989 foreach ( (array) $comments as $comment ) {
6990 $latitude = get_comment_meta( $comment->comment_ID, 'latitude', true );
6991 $longitude = get_comment_meta( $comment->comment_ID, 'longitude', true );
6992
6993 // Only add location data to the export if it is not empty
6994 if ( ! empty( $latitude ) ) {
6995 // Most item IDs should look like postType-postID
6996 // If you don't have a post, comment or other ID to work with,
6997 // use a unique value to avoid having this item's export
6998 // combined in the final report with other items of the same id
6999 $item_id = "comment-{$comment->comment_ID}";
7000
7001 // Core group IDs include 'comments', 'posts', etc.
7002 // But you can add your own group IDs as needed
7003 $group_id = 'comments';
7004
7005 // Optional group label. Core provides these for core groups.
7006 // If you define your own group, the first exporter to
7007 // include a label will be used as the group label in the
7008 // final exported report
7009 $group_label = __( 'Comments' );
7010
7011 // Plugins can add as many items in the item data array as they want
7012 $data = array(
7013 array(
7014 'name' => __( 'Commenter Latitude' ),
7015 'value' => $latitude
7016 ),
7017 array(
7018 'name' => __( 'Commenter Longitude' ),
7019 'value' => $longitude
7020 )
7021 );
7022
7023 $export_items[] = array(
7024 'group_id' => $group_id,
7025 'group_label' => $group_label,
7026 'item_id' => $item_id,
7027 'data' => $data,
7028 );
7029 }
7030 }
7031
7032 // Tell core if we have more comments to work on still
7033 $done = count( $comments ) < $number;
7034
7035 */
7036 /*
7037 return array(
7038 'data' => $export_items,
7039 'done' => true,
7040 );
7041
7042 }
7043 function register_my_plugin_exporter( $exporters ) {
7044 $exporters['pie-register'] = array(
7045 'exporter_friendly_name' => __( 'Pie Register - Custom Fields' ),
7046 'callback' => array($this, 'my_plugin_exporter'),
7047 );
7048
7049 return $exporters;
7050 }
7051 */
7052
7053 /* GDPR - Personal Data Exporter */
7054
7055
7056 function show_renew_account()
7057 {
7058 $this->piereg_ssl_template_redirect();
7059 if (file_exists(PIEREG_DIR_NAME . "/renew_account.php"))
7060 include_once("renew_account.php");
7061
7062 $show_renew_account = PR_show_renew_account();
7063 return $show_renew_account;
7064 }
7065
7066 function afterLoginPage()
7067 {
7068 global $wpdb, $current_user;
7069 $option = $this->get_pr_global_options();
7070 /*
7071 Get after Logged in url by current user role
7072 */
7073
7074 $redirecturi = $this->ifRedirectUrlSet($current_user);
7075 if ($redirecturi) {
7076 $this->pie_after_login_page_redirect_url = $redirecturi;
7077 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url, $option['social_site_popup_setting'], true);
7078 exit;
7079 }
7080
7081 $logged_in_url = "";
7082 $logged_in_page = "";
7083
7084 if (!isset($option['social_site_popup_setting'])) {
7085 $option['social_site_popup_setting'] = 0;
7086 }
7087
7088 if (!empty($logged_in_url) && ($logged_in_page == 0 || $logged_in_page == "")) {
7089 $this->pie_after_login_page_redirect_url = $logged_in_url;
7090 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url, $option['social_site_popup_setting'], false);
7091 exit;
7092 } elseif (!empty($logged_in_page) && $logged_in_page > 0) {
7093 $this->pie_after_login_page_redirect_url = get_permalink($logged_in_page);
7094 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url, $option['social_site_popup_setting'], true);
7095 exit;
7096 } elseif ($option['after_login'] == 'url' && !empty($option['alternate_login_url'])) {
7097 $this->pie_after_login_page_redirect_url = $option['alternate_login_url'];
7098 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url, $option['social_site_popup_setting'], false);
7099 exit;
7100 } elseif ($option['after_login'] == '-2') {
7101 $prev_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
7102 $this->afterLoginPageRedirect($prev_url, $option['social_site_popup_setting'], true);
7103 exit;
7104 } elseif ($option['after_login'] > 0) {
7105 if ($option['after_login'] != 'url') {
7106 $this->pie_after_login_page_redirect_url = get_permalink($option['after_login']);
7107
7108 if (isset($option['piereg_after_login_updated']) && $option['piereg_after_login_updated']) {
7109 $option['after_login'] = '-2';
7110 $option['piereg_after_login_updated'] = false;
7111 update_option(OPTION_PIE_REGISTER, $option);
7112 }
7113
7114 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url, $option['social_site_popup_setting'], true);
7115 exit;
7116 }
7117 } elseif (isset($_GET['redirect_to']) && $_GET['redirect_to'] != "" && !current_user_can('piereg_manage_cap')) {
7118 // When account login with activation link and not any login page assigned
7119 if ((isset($_GET['action']) && $_GET['action'] == "activate") && (isset($_GET['activation_key']) && $_GET['activation_key'] != "")) {
7120 $this->pie_after_login_page_redirect_url = site_url();
7121 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url, $option['social_site_popup_setting'], false);
7122 } else {
7123 $this->pie_after_login_page_redirect_url = esc_url_raw($_GET['redirect_to']);
7124 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url, $option['social_site_popup_setting'], false);
7125 }
7126 exit;
7127 } else {
7128 $this->pie_after_login_page_redirect_url = site_url();
7129 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url, $option['social_site_popup_setting'], false);
7130 exit;
7131 }
7132 exit;
7133 }
7134
7135 function ifRedirectUrlSet($user)
7136 {
7137 if (isset($_REQUEST['redirect_to'])) {
7138 $redirect_to = esc_url_raw($_REQUEST['redirect_to']);
7139 // Redirect to https if user wants ssl
7140 if (((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') && false) !== strpos($redirect_to, 'wp-admin'))
7141 $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
7142 } else {
7143 $redirect_to = admin_url();
7144 }
7145
7146 $requested_redirect_to = isset($_REQUEST['redirect_to']) ? esc_url_raw($_REQUEST['redirect_to']) : '';
7147 $redirect_to = apply_filters('login_redirect', $redirect_to, $requested_redirect_to, $user);
7148 $last_segment = basename($redirect_to);
7149
7150 $redirect_to = apply_filters('piereg_set_redirect_uri', $redirect_to);
7151
7152 if ($last_segment == 'wp-admin' || $redirect_to == admin_url()) {
7153 return false;
7154 }
7155
7156 return $redirect_to;
7157 }
7158
7159 function afterLoginPageRedirect($url, $social_site_popup_setting = 0, $safe = true)
7160 {
7161 if (
7162 $social_site_popup_setting == 1 and
7163 $_POST['social_site'] == "true"
7164 ) {
7165 //Redirect thru JS File
7166 } else {
7167 if ($safe)
7168 wp_safe_redirect($url);
7169 else
7170 wp_safe_redirect(esc_url_raw(html_entity_decode($url)));
7171 }
7172 exit;
7173 }
7174
7175 function add_ob_start()
7176 {
7177 ob_start();
7178 }
7179
7180 function get_paypalstandard($value, $payment_gateways = array())
7181 {
7182 $data = "";
7183 $check_payment = get_option(OPTION_PIE_REGISTER);
7184
7185 if ($check_payment["enable_paypal"] == 1 && !(empty($check_payment['paypal_butt_id'])) && in_array("PaypalStandard", $payment_gateways)) {
7186 $data .= '<img src="' . esc_url(PIEREG_PLUGIN_URL . 'assets/images/paypal_std_btn.png') . '">';
7187 $data .= '<p class="desc">' . esc_html__('Paypal (Standard) payment method applied.', 'pie-register') . '</p>';
7188 $data .= '<input type="hidden" name="select_payment_method" value="' . esc_attr($payment_gateways[0]) . '" />';
7189 }
7190
7191 return $data . $value;
7192 }
7193
7194 function Add_payment_option($send_data, $paymeny_gatways) // Only For Paypal
7195 {
7196 $check_payment = get_option(OPTION_PIE_REGISTER);
7197 if ($check_payment["enable_paypal"] == 1 && !(empty($check_payment['paypal_butt_id'])) && in_array('PaypalStandard', $paymeny_gatways)) {
7198 $string = 'Paypal (Standard)';
7199 if (strpos($send_data, $string) == false) {
7200 $send_data .= '<option data-img="' . esc_url(PIEREG_PLUGIN_URL . 'assets/images/paypal_std_btn.png') . '" value="PaypalStandard">' . (esc_html__("Paypal (Standard)", "pie-register")) . '</option>';
7201 }
7202 }
7203
7204 return $send_data;
7205 }
7206
7207 function add_payment_method_script() // Only For Paypal Standard
7208 {
7209 $check_payment = get_option(OPTION_PIE_REGISTER);
7210 if ($check_payment["enable_paypal"] == 1 && !(empty($check_payment['paypal_butt_id']))) {
7211 //Add jQuery for payment Method
7212 ?>
7213 if(jQuery(this).val() == "PaypalStandard")
7214 {
7215 payment = '<div class="payment-method-img desc"><img src="'+jQuery('option:selected',jQuery(this)).attr('data-img')+'" /></div>
7216 <div class="desc">Paypal (Standard) payment method applied.</div>';
7217 <!-- image = '<img src="'+jQuery('option:selected',jQuery(this)).attr('data-img')+'" />'; -->
7218 }
7219 <?php
7220 }
7221 }
7222
7223 function add_select_payment_script()
7224 {
7225 ?>
7226 <script type="text/javascript">
7227 var piereg = jQuery.noConflict();
7228 piereg(document).ready(function() {
7229 piereg("#select_payment_method").change(function() {
7230 if (piereg(this).val() != "") {
7231
7232 var payment = "",
7233 image = "";
7234 <?php do_action('add_payment_method_script'); ?>
7235 piereg("#show_payment_method").html(payment);
7236 // piereg("#show_payment_method_image").html(image);
7237 } else {
7238 piereg("#show_payment_method").html("");
7239 // piereg("#show_payment_method_image").html("");
7240 }
7241 });
7242 });
7243 </script>
7244 <?php
7245 }
7246 function get_payment_content_area()
7247 {
7248 $data = '<div class="fieldset">';
7249 //$data .= '<label for="select_payment_method"> </label>';
7250 // $data .= '<div id="show_payment_method_image"></div>';
7251 $data .= '<div id="show_payment_method"></div>';
7252 $data .= '</div>';
7253 return $data;
7254 }
7255 function show_icon_payment_gateway() // for paypal
7256 {
7257
7258 $button = get_option(OPTION_PIE_REGISTER);
7259 if (
7260 (!(empty($button['paypal_butt_id'])) && $button['enable_paypal'] == 1)
7261 ) {
7262 ?>
7263 <div class="fields_options submit_field">
7264 <img style="width:100%;" src="<?php echo esc_url(plugins_url('/assets/images/btn_buynowCC_LG.gif', __FILE__)); ?>" />
7265 </div>
7266 <?php
7267 }
7268 }
7269
7270 function renew_account()
7271 {
7272 global $errors;
7273 $errors = new WP_Error();
7274
7275 if (isset($_POST['piereg_renew_account_nonce']) && wp_verify_nonce($_POST['piereg_renew_account_nonce'], 'piereg_wp_renew_account_nonce')) {
7276
7277 if (isset($_POST['select_payment_method']) and trim($_POST['select_payment_method']) != "") {
7278 if (isset($_GET['auth'], $_GET['auth_key']) && !empty($_GET['auth']) && !empty($_GET['auth_key'])) {
7279 $user_name = sanitize_text_field(urldecode($_GET['auth']));
7280 $auth_key = sanitize_text_field(urldecode($_GET['auth_key']));
7281 $user_name = sanitize_user(urldecode(base64_decode($user_name)));
7282 $user = get_user_by("login", $user_name);
7283
7284 if (!empty($user)) {
7285 $auth_key = sanitize_text_field($_GET['auth_key']);
7286 $auth_key_hash = get_user_meta($user->ID, "pr_renew_account_hash", true);
7287 if (!empty($auth_key_hash)) {
7288 if (trim($auth_key) == trim($auth_key_hash)) {
7289 if (isset($user->ID)) {
7290 /*
7291 * Check Pricing
7292 */
7293 $user_id = $user->ID;
7294
7295 $pricing_key_number = get_user_meta($user_id, "piereg_pricing_key_number", true);
7296 $piereg_user_registered_form_id = get_user_meta($user_id, "user_registered_form_id", true);
7297 $piereg_use_starting_period = get_user_meta($user_id, "use_starting_period", true);
7298 $piereg_form_pricing_fields = get_option("piereg_form_pricing_fields");
7299 $piereg_pricing_fields = "";
7300 $user_array = (array) $user;
7301 if (isset($piereg_form_pricing_fields['form_id_' . (intval($piereg_user_registered_form_id))])) {
7302 $piereg_pricing_fields = $piereg_form_pricing_fields['form_id_' . (intval($piereg_user_registered_form_id))];
7303 $user_array['piereg_pricing']['pricing_key_user_role'] = $piereg_pricing_fields['role'][$pricing_key_number];
7304 if (empty($piereg_use_starting_period)) {
7305 $user_array['piereg_pricing']['pricing_payment_amount'] = $piereg_pricing_fields['starting_price'][$pricing_key_number];
7306 } else {
7307 $user_array['piereg_pricing']['pricing_payment_amount'] = $piereg_pricing_fields['then_price'][$pricing_key_number];
7308 }
7309 }
7310 $user = (object) $user_array;
7311 }
7312 } else {
7313 $user = new WP_Error("invalid_hash", "User hash mismatch");
7314 }
7315 } else {
7316 $user = new WP_Error("piereg_invalid_auth_keys_hash", apply_filters("piereg_invalid_auth_keys_hash", esc_html__("Invalid auth keys hash", "pie-register")));
7317 }
7318 } else {
7319 $user = new WP_Error("piereg_invalid_auth_keys", apply_filters("piereg_invalid_auth_keys", esc_html__("Invalid User", "pie-register")));
7320 }
7321 } else {
7322 $user = $this->piereg_user_login(sanitize_user($_POST['user_name']), $_POST['u_pass']);
7323 wp_logout();
7324 }
7325
7326 $piereg = $this->get_pr_global_options();
7327
7328 if (is_wp_error($user)) {
7329 $user_login_error = $user->get_error_message();
7330 if (strpos(wp_strip_all_tags($user_login_error), 'Invalid username', 5) > 6) {
7331 $user_login_error = '<b>' . ucwords(esc_html__("error", "pie-register")) . '</b>: ' . esc_html__("Invalid username or password", "pie-register");
7332 } else if (strpos(wp_strip_all_tags($user_login_error), 'password you entered', 9) > 10) {
7333 $user_login_error = '<strong>' . ucwords(esc_html__("error", "pie-register")) . '</strong>: ' . esc_html__("Invalid username or password", "pie-register");
7334 }
7335 $errors->add('renew-account-error', apply_filters("piereg_renew_account_error", $user_login_error));
7336 } elseif ($user->ID != 0 or $user->ID != "") {
7337 $user_meta = get_user_meta($user->ID);
7338 if ($user_meta['active'][0] == 0) {
7339 if (isset($_POST['select_payment_method']) and $_POST['select_payment_method'] != "") //Goto payment method Like check_payment_method_paypal
7340 {
7341 $_POST['user_id'] = $user->data->ID;
7342 $_POST['e_mail'] = $user->data->user_email;
7343 $_POST['username'] = $user->data->user_login;
7344 $_POST['renew_account_msg'] = apply_filters("piereg_Renew_Account", esc_html__("Renew Account", "pie-register"));
7345 $_POST['renew_account'] = "Renew Account";
7346 do_action("piereg_before_renew_account_hook", $user);
7347 do_action("check_payment_method_" . sanitize_text_field($_POST['select_payment_method']), $user);
7348 }
7349 } else {
7350 $this->pie_post_array['success'] = apply_filters("you_are_already_active", $piereg['payment_already_activate_msg']);
7351 }
7352 } else {
7353 $this->pie_post_array['error'] = apply_filters("piereg_Invalid_Username_or_Password", esc_html__("Invalid Username or Password", "pie-register"));
7354 }
7355 } else {
7356 $this->pie_post_array['error'] = apply_filters("piereg_Please_Select_any_payment_method", esc_html__("Please select a payment method", "pie-register"));
7357 }
7358 } else {
7359 $this->pie_post_array['error'] = 'Invalid nonce.';
7360 }
7361 }
7362
7363 function piereg_user_login($username, $password, $remember = false)
7364 {
7365 $result = array();
7366 if ($username != "" && $password != "") {
7367 $creds = array();
7368 $creds['user_login'] = trim($username);
7369 $creds['user_password'] = trim($password);
7370 $creds['remember'] = ((!empty($remember)) ? true : false);
7371 $piereg_secure_cookie = $this->PR_IS_SSL();
7372 if ($this->piereg_authentication($_POST['log'], trim($_POST['pwd']))) {
7373 $user = wp_signon($creds, $piereg_secure_cookie);
7374 if (!is_wp_error($user)) {
7375 $this->piereg_delete_authentication();
7376 }
7377 } else {
7378 $user = new WP_Error('piereg_authentication_failed', esc_html__("IP address blocked due to too many failed login attempts.", "pie-register"));
7379 }
7380
7381 if (isset($user->ID)) {
7382 /*
7383 * Check Pricing
7384 */
7385 $user_id = $user->ID;
7386
7387 $pricing_key_number = get_user_meta($user_id, "piereg_pricing_key_number", true);
7388 $piereg_user_registered_form_id = get_user_meta($user_id, "user_registered_form_id", true);
7389 $piereg_use_starting_period = get_user_meta($user_id, "use_starting_period", true);
7390 $piereg_form_pricing_fields = get_option("piereg_form_pricing_fields");
7391 $piereg_pricing_fields = "";
7392 $user_array = (array) $user;
7393 if (isset($piereg_form_pricing_fields['form_id_' . (intval($piereg_user_registered_form_id))])) {
7394 $piereg_pricing_fields = $piereg_form_pricing_fields['form_id_' . (intval($piereg_user_registered_form_id))];
7395 $user_array['piereg_pricing']['pricing_key_user_role'] = $piereg_pricing_fields['role'][$pricing_key_number];
7396 if (empty($piereg_use_starting_period)) {
7397 $user_array['piereg_pricing']['pricing_payment_amount'] = $piereg_pricing_fields['starting_price'][$pricing_key_number];
7398 } else {
7399 $user_array['piereg_pricing']['pricing_payment_amount'] = $piereg_pricing_fields['then_price'][$pricing_key_number];
7400 }
7401 }
7402 $user = (object) $user_array;
7403
7404 /***** End Pricing *****/
7405 }
7406 $result = $user;
7407 } else {
7408 $result['error'] = apply_filters('piereg_Invalid_Fields', esc_html__("Invalid Field(s)", 'pie-register')); # newlyAddedHookFilter
7409 }
7410 return $result;
7411 }
7412 function wp_mail_send($to_email = "", $key = "", $additional_msg = "", $msg = "", $email_variable = array())
7413 {
7414 global $errors;
7415 $errors = new WP_Error();
7416 if (trim($to_email) != "" and trim($key) != "") {
7417 $email_types = get_option(OPTION_PIE_REGISTER);
7418
7419 $message_temp = "";
7420 if ($email_types['user_formate_email_' . $key] == "0") {
7421 $message_temp = nl2br(wp_strip_all_tags($email_types['user_message_email_' . $key]));
7422 } else {
7423 $message_temp = $email_types['user_message_email_' . $key];
7424 }
7425
7426 $message = $this->filterEmail($message_temp, $to_email, "", "", $email_variable);
7427 $to = $to_email;
7428 $from_name = html_entity_decode($email_types['user_from_name_' . $key], ENT_COMPAT, "UTF-8");
7429 $from_email = $email_types['user_from_email_' . $key];
7430 $reply_to_email = $email_types['user_to_email_' . $key];
7431 $subject = html_entity_decode($email_types['user_subject_email_' . $key], ENT_COMPAT, "UTF-8");
7432 $subject = $this->filterSubject($to_email, $subject);
7433
7434 if (!filter_var($to, FILTER_VALIDATE_EMAIL)) //if not valid email address then use wordpress default admin
7435 {
7436 $to = get_option('admin_email');
7437 }
7438 //Headers
7439 $headers = 'MIME-Version: 1.0' . "\r\n";
7440 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
7441
7442 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
7443 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
7444
7445 if (!empty($reply_to_email) && filter_var($reply_to_email, FILTER_VALIDATE_EMAIL)) //Validating Reply To
7446 $headers .= 'Reply-To: <' . $reply_to_email . '> \r\n';
7447 if ($reply_to_email) {
7448 $headers .= "Return-Path: {$reply_to_email}\r\n";
7449 } else {
7450 $headers .= "Return-Path: {$from_email}\r\n";
7451 }
7452
7453 if (!wp_mail($to, $subject, $message, $headers)) {
7454 $errors->add('check-error', apply_filters("piereg_problem_and_the_email_was_probably_not_sent", esc_html__("There was a problem sending the email.", 'pie-register')));
7455 } else {
7456 if (trim($msg) != "") {
7457 $this->pie_post_array['success'] = esc_html($msg);
7458 }
7459 }
7460 }
7461 }
7462
7463 function delete_invitation_codes($ids = "0")
7464 {
7465 global $wpdb;
7466 $prefix = $wpdb->prefix . "pieregister_";
7467 $codetable = $prefix . "code";
7468
7469 $array_ids = explode(',', $ids);
7470 $count_ids = count($array_ids);
7471 $placeholders = array_fill(0, $count_ids, '%d');
7472 $format = implode(', ', $placeholders);
7473
7474 if (!$wpdb->query($wpdb->prepare("DELETE FROM $codetable WHERE `id` IN($format)", $array_ids))) {
7475 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
7476 } else {
7477 $this->pie_post_array['notice'] = esc_html__("Invitation code deleted.", "pie-register");
7478 }
7479 }
7480 function active_or_unactive_invitation_codes($ids = "0", $status = "1")
7481 {
7482 global $wpdb;
7483 $prefix = $wpdb->prefix . "pieregister_";
7484 $codetable = $prefix . "code";
7485
7486 $array_ids = explode(',', $ids);
7487 $count_ids = count($array_ids);
7488 $placeholders = array_fill(0, $count_ids, '%d');
7489 $format = implode(', ', $placeholders);
7490
7491 if (!$wpdb->query($wpdb->prepare("UPDATE $codetable SET `status`= %s WHERE `id` IN($format)", array_merge(array($status), $array_ids)))) {
7492 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
7493 } else {
7494 $this->pie_post_array['notice'] = esc_html__("Status has been changed", "pie-register");
7495 }
7496 }
7497 function pireg_update_invitation_code_cb_url()
7498 {
7499 // Run a security check.
7500 if (! check_ajax_referer('pieregister_front_admin', 'nonce', false)) {
7501 wp_send_json_error(esc_html__('Your session expired. Please reload the page.', 'pie-register'));
7502 }
7503
7504 global $wpdb;
7505 $prefix = $wpdb->prefix . "pieregister_";
7506 $codetable = $prefix . "code";
7507 $inv_code_id = intval($_POST['data']['id']);
7508 if (isset($_POST['data'])) {
7509 if (trim($_POST['data']['id']) != "" and trim($_POST['data']['value']) != "" and trim($_POST['data']['type']) != "") {
7510 global $wpdb;
7511 $sql = "";
7512 $_data_value = sanitize_text_field($_POST['data']['value']);
7513 if (trim($_POST['data']['type']) == "name") {
7514 $sql_res_sel = $wpdb->get_var($wpdb->prepare("SELECT `name` FROM `{$codetable}` WHERE BINARY `name` = %s OR `name` = %s", strtolower($_data_value), strtoupper($_data_value)));
7515 if (!$sql_res_sel) {
7516 $result = $wpdb->query($wpdb->prepare("UPDATE `{$codetable}` SET `name`=%s WHERE `id` = %d", sanitize_text_field($_POST['data']['value']), intval($_POST['data']['id'])));
7517 } else {
7518 echo "duplicate";
7519 die();
7520 }
7521 } else if (trim($_POST['data']['type']) == "code_description") {
7522 if ($_POST['data']['value'] != '') {
7523 $result = $wpdb->query($wpdb->prepare("UPDATE `{$codetable}` SET `code_description`=%s WHERE `id` = %d", sanitize_text_field($_POST['data']['value']), intval($_POST['data']['id'])));
7524 }
7525 } else if (trim($_POST['data']['type']) == "code_usage") {
7526 if (is_numeric($_data_value) && $_data_value >= 0 && trim($_data_value) != '') {
7527 $usage_count = $wpdb->get_results($wpdb->prepare("SELECT `code_usage`,`count` FROM `{$codetable}` WHERE `id` = %d", intval($_POST['data']['id'])));
7528 if (!empty($usage_count) && $_data_value >= $usage_count[0]->count) {
7529 $result = $wpdb->query($wpdb->prepare("UPDATE `{$codetable}` SET `code_usage`=%s WHERE `id` = %d", $_data_value, intval($_POST['data']['id'])));
7530 } else {
7531 echo "invalid usage";
7532 die();
7533 }
7534 }
7535 }
7536
7537 if (!isset($result) && !empty($sql)) {
7538 // For any other custom sql that might be set, though currently not used above
7539 // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
7540 $result = $wpdb->query($wpdb->prepare($sql, array($_data_value, intval($_POST['data']['id']))));
7541 }
7542
7543 if (isset($wpdb->last_error) && !empty($wpdb->last_error)) {
7544 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
7545 }
7546
7547 if (isset($result) && $result) {
7548 echo "done";
7549 } else if (isset($result) && !$result) {
7550 echo "error";
7551 }
7552 }
7553 }
7554 die();
7555 }
7556
7557 function delete_custom_roles($ids = "0")
7558 {
7559 global $wpdb;
7560 $custom_role_table_name = $wpdb->prefix . "pieregister_custom_user_roles";
7561
7562 $array_ids = explode(',', $ids);
7563 $count_ids = count($array_ids);
7564 $placeholders = array_fill(0, $count_ids, '%d');
7565 $format = implode(', ', $placeholders);
7566
7567 $role_keys = $wpdb->get_results($wpdb->prepare("SELECT `role_key` FROM `$custom_role_table_name` WHERE `id` IN($format)", $array_ids));
7568
7569
7570 if (!$wpdb->query($wpdb->prepare("DELETE FROM `$custom_role_table_name` WHERE `id` IN($format)", $array_ids))) {
7571 $this->pr_error_log($wpdb->last_error . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
7572 } else {
7573 $this->pie_post_array['notice'] = esc_html__("The User Role(s) has been deleted", "pie-register");
7574
7575 foreach ($role_keys as $role_key) {
7576 remove_role($role_key->role_key);
7577 }
7578 }
7579 }
7580
7581 function checkUserAllowedPassReset($val, $userid)
7582 {
7583 if (!$userid) return false;
7584 //Check if the user is active or not
7585 //if active true, or false
7586 global $piereg_global_options;
7587
7588 if (
7589 (isset($piereg_global_options['verification']) && ($piereg_global_options['verification'] == "2" || $piereg_global_options['verification'] == "1")) ||
7590 ((!empty($piereg_global_options['paypal_butt_id'])) && $piereg_global_options['enable_paypal'] == "1")
7591 ) {
7592 $user_active_status = get_user_meta($userid, "active", true);
7593 //If employee register from wp-register the active meta is not saved
7594 if ($user_active_status == "")
7595 return true;
7596 //If employee register from wp-register the active meta is not saved
7597 return (($user_active_status == 1) ? true : false);
7598 }
7599 return true;
7600 }
7601
7602 function piereg_password_reset_not_allowed_text_function($text)
7603 {
7604 return $text;
7605 }
7606
7607 /*
7608 * Pie Register log file download
7609 */
7610 function pr_logfile_download_or_view()
7611 {
7612 if (isset($_POST['piereg_download_log_file']) && $_POST['piereg_download_log_file'] != "") {
7613 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
7614 if (isset($_POST['piereg_download_log_file_nonce']) && wp_verify_nonce($_POST['piereg_download_log_file_nonce'], 'piereg_wp_download_log_file_nonce')) {
7615 if (file_exists(PIE_LOG_FILE . "/piereg_log.log")) {
7616 header('Content-Description: File Transfer');
7617 header('Content-Type: application/octet-stream');
7618 header('Content-Disposition: attachment; filename=' . ("PieRegister_logfile_" . date_i18n("Y-m-d-H-i-s") . ".log"));
7619 header('Expires: 0');
7620 header('Cache-Control: must-revalidate');
7621 header('Pragma: public');
7622 header('Content-Length: ' . filesize(PIE_LOG_FILE . "/piereg_log.log"));
7623 global $wp_filesystem;
7624 if (empty($wp_filesystem)) {
7625 require_once ABSPATH . 'wp-admin/includes/file.php';
7626 WP_Filesystem();
7627 }
7628 $wp_filesystem->readfile(PIE_LOG_FILE . "/piereg_log.log");
7629 exit;
7630 }
7631 } else {
7632 $this->pie_post_array['error_message'] = esc_html__("Invalid nonce.", "pie-register");
7633 }
7634 }
7635 }
7636 /*
7637 * Pie Register Log File View
7638 */
7639 function piereg_get_log_file()
7640 {
7641 //Log File Dir
7642 $file_dir = PIE_LOG_FILE . "/piereg_log.log";
7643 $result = "";
7644 $logFileData = $this->read_upload_file($file_dir);
7645 $result = htmlentities($logFileData);
7646 return $result;
7647 }
7648
7649 function check_json_file_db_version($array_json_file)
7650 {
7651 if (isset($array_json_file['piereg_plugin_db_version']) && !empty($array_json_file['piereg_plugin_db_version'])) {
7652 $import_file_db_version = $array_json_file['piereg_plugin_db_version'];
7653 $pie_plugin_db_version = get_option('piereg_plugin_db_version');
7654 if ($pie_plugin_db_version === $import_file_db_version)
7655 return true;
7656 else
7657 return false;
7658 } else
7659 return false;
7660 }
7661 function set_json_header($file_name)
7662 {
7663 header('Content-disposition: attachment; filename=' . ($file_name) . '.json');
7664 header('Content-type: application/json');
7665 }
7666
7667
7668 function piereg_plugin_row_meta($links, $file)
7669 {
7670 if ($file == PIEREG_PLUGIN_BASENAME) {
7671 $row_meta = array(
7672 'documentation' => '<a href="' . esc_url(apply_filters('pieregister_docs_url', 'https://pieregister.com/documentation/')) . '" title="' . esc_attr(__('Please refer to the Pie Register user manual.', 'pie-register')) . '" target="_blank">' . esc_html__('Documentation', 'pie-register') . '</a>',
7673 'support' => '<a href="' . esc_url(apply_filters('pieregister_support_url', 'https://wordpress.org/support/plugin/pie-register/')) . '" title="' . esc_attr(__('Please visit the support forum.', 'pie-register')) . '" target="_blank">' . esc_html__('Support', 'pie-register') . '</a>',
7674 );
7675
7676 return array_merge($links, $row_meta);
7677 }
7678
7679 return (array) $links;
7680 }
7681
7682 function activate_addon_license_key()
7683 {
7684
7685 if (isset($_POST['piereg_activate_addon_license_key'], $_POST['save_addon_license_key_settings'])) {
7686 if (isset($_POST['piereg_addon_license_key_nonce'])) {
7687 if (wp_verify_nonce($_POST['piereg_addon_license_key_nonce'], 'piereg_wp_addon_license_key_nonce')) {
7688
7689 $piereg_pro_not_activated = (isset($_POST['piereg_pro_not_activated'])) ? true : false;
7690 $LK_options = array();
7691
7692 if ($piereg_pro_not_activated) {
7693 $LK_options['api_key'] = sanitize_text_field($_POST['piereg_addon_license_key']);
7694 $LK_options['activation_email'] = sanitize_email($_POST['piereg_addon_license_email']);
7695 } else {
7696 $LK_options = get_option(PIEREG_licenSE_KEY_OPTION);
7697 }
7698
7699 $piereg_api_manager_menu = new Piereg_API_Manager_Example_MENU();
7700 $piereg_api_manager_menu->validate_addon_options(array("api_key" => $LK_options['api_key'], "activation_email" => $LK_options['activation_email'], "api_addon" => sanitize_text_field($_POST['is_activate_addon_license']), "api_addon_version" => sanitize_text_field($_POST['addon_software_version']), "is_piereg_pro_inactive" => $piereg_pro_not_activated));
7701 } else {
7702 $this->pie_post_array['error'] = esc_html__("Invalid nonce.", "pie-register");
7703 }
7704 }
7705 }
7706 }
7707 public function plugin_url()
7708 {
7709 if (isset($this->piereg_plugin_url)) return $this->piereg_plugin_url;
7710 return $this->piereg_plugin_url = plugins_url('/', __FILE__);
7711 }
7712
7713 function pie_user_avatar($avatar, $id_or_email, $size, $default, $alt)
7714 {
7715 $user = false;
7716 $profile_pic = "";
7717
7718 if (!is_admin()) {
7719 $current_user = wp_get_current_user();
7720
7721 if (is_object($id_or_email))
7722 $id_or_email = $id_or_email->user_id;
7723
7724 if (!is_numeric($id_or_email)) {
7725 $user = get_user_by('email', $id_or_email);
7726 $id_or_email = $user->ID;
7727 }
7728
7729 if (is_numeric($id_or_email) && $id_or_email != $current_user->ID) {
7730 $current_user = get_userdata($id_or_email);
7731 }
7732
7733 $profile_pic_array = get_user_meta($current_user->ID);
7734
7735 if (is_array($profile_pic_array)) {
7736 foreach ($profile_pic_array as $key => $val) {
7737 if (strpos($key, 'profile_pic') !== false) {
7738 $profile_pic = trim($val[0]);
7739 }
7740 }
7741 }
7742 }
7743
7744 if (!empty($profile_pic)) {
7745 $profile_pic = apply_filters("piereg_profile_image_url", $profile_pic, $current_user);
7746 if (is_numeric($id_or_email)) {
7747
7748 $id = (int) $id_or_email;
7749 $user = get_user_by('id', $id);
7750 } elseif (is_object($id_or_email)) {
7751
7752 if (! empty($id_or_email->user_id)) {
7753 $id = (int) $id_or_email->user_id;
7754 $user = get_user_by('id', $id);
7755 }
7756 } else {
7757 $user = get_user_by('email', $id_or_email);
7758 }
7759
7760 if ($user && is_object($user)) {
7761
7762 //if ( $user->data->ID == get_current_user_id() ) {
7763 $avatar = $profile_pic;
7764 $avatar = "<img alt='{$alt}' src='{$avatar}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
7765 //}
7766
7767 }
7768 }
7769
7770 return $avatar;
7771 }
7772
7773 function is_anyone_can_register()
7774 {
7775 return get_option("users_can_register");
7776 }
7777 function piereg_ssl_template_redirect()
7778 {
7779 if (!is_admin() && ((defined("FORCE_SSL_ADMIN") && FORCE_SSL_ADMIN == true) && !is_ssl())) { #checkbyM
7780 if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') {
7781 wp_safe_redirect(preg_replace('|^http://|', 'https://', $this->piereg_get_current_url()));
7782 exit;
7783 }
7784 }
7785 }
7786 function edit_email_verification()
7787 {
7788 if (isset($_GET['action']) && ($_GET['action'] == "current_email_verify" || $_GET['action'] == "email_edit")) {
7789 $username = sanitize_user($_GET['login']);
7790 $email_verify_key = sanitize_text_field($_GET['key']);
7791 $user_data_temp = get_user_by('login', $username);
7792 global $errors, $piereg_global_options;
7793 $errors = new WP_Error();
7794 $global_options = $piereg_global_options;
7795 $success_message = "";
7796 $type = "success";
7797 if (($_GET['action'] == "current_email_verify") && (isset($_GET['key']) && !empty($_GET['key'])) && (isset($_GET['login']) && !empty($_GET['login']))) {
7798 $email_verify_orignal_key = get_user_meta($user_data_temp->data->ID, "new_email_address_hashed", true);
7799
7800 if ($email_verify_orignal_key == $email_verify_key) {
7801 $new_email_address = get_user_meta($user_data_temp->data->ID, "new_email_address", true);
7802 $email_key = wp_generate_password(32, false);
7803 $keys_array = array("reset_email_key" => $email_key);
7804
7805 /*
7806 * Email send snipt
7807 */
7808 $subject = html_entity_decode($global_options["user_subject_email_email_edit_verification"], ENT_COMPAT, "UTF-8");
7809 $subject = $this->filterSubject($user_data_temp, $subject);
7810 $message_temp = "";
7811
7812 $message_temp = $global_options["user_message_email_email_edit_verification"];
7813 $message = $this->filterEmail($message_temp, $user_data_temp, "", false, $keys_array);
7814 $from_name = html_entity_decode($global_options["user_from_name_email_edit_verification"], ENT_COMPAT, "UTF-8");
7815 $from_email = $global_options["user_from_email_email_edit_verification"];
7816 $reply_email = $global_options["user_to_email_email_edit_verification"];
7817
7818 //Headers
7819 $headers = "MIME-Version: 1.0" . "\r\n";
7820 $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
7821
7822 if (!empty($from_email) && filter_var($from_email, FILTER_VALIDATE_EMAIL)) //Validating From
7823 $headers .= "From: " . $from_name . " <" . $from_email . "> \r\n";
7824
7825 if ($reply_email) {
7826 $headers .= "Reply-To: {$reply_email}\r\n";
7827 $headers .= "Return-Path: {$reply_email}\r\n";
7828 } else {
7829 $headers .= "Reply-To: {$from_email}\r\n";
7830 $headers .= "Return-Path: {$from_email}\r\n";
7831 }
7832
7833 if ((isset($global_options['user_enable_email_edit_verification']) && $global_options['user_enable_email_edit_verification'] == 1) && !wp_mail($new_email_address, $subject, $message, $headers)) {
7834 $this->pr_error_log("'The e-mail could not be sent. Possible reason: mail() function may have disabled by your host.'" . ($this->get_error_log_info(__FUNCTION__, __LINE__, __FILE__)));
7835 $print_message = esc_html__("There was a problem sending the email.", 'pie-register');
7836 $type = "0";
7837 }
7838
7839 /*
7840 * Update Email Hash Key
7841 */
7842 update_user_meta($user_data_temp->data->ID, "new_email_address_hashed", $email_key);
7843 if (empty($print_message)) {
7844 $print_message = esc_html__("Use the link sent to your email to verify and apply the change.", "pie-register");
7845 $type = "success";
7846 }
7847 } else {
7848 $print_message = esc_html__('Verification link has expired or is invalid.', 'pie-register');
7849 $type = "error";
7850 }
7851 } elseif (($_GET['action'] == "email_edit") && (isset($_GET['key']) && !empty($_GET['key'])) && (isset($_GET['login']) && !empty($_GET['login']))) {
7852 $email_verify_orignal_key = get_user_meta($user_data_temp->data->ID, "new_email_address_hashed", true);
7853 $old_email = get_user_meta($user_data_temp->data->ID, "new_email_address", true);
7854 if ($email_verify_orignal_key == $email_verify_key) {
7855 $user_id_temp = wp_update_user(array('ID' => $user_data_temp->data->ID, 'user_email' => $old_email));
7856 if (is_wp_error($user_id_temp)) {
7857 $print_message = esc_html__('There was a problem updating the new Email address, try again.', 'pie-register');
7858 $type = "error";
7859 } else {
7860 delete_user_meta($user_data_temp->data->ID, "new_email_address_hashed");
7861 delete_user_meta($user_data_temp->data->ID, "new_email_address");
7862 $print_message = esc_html__("New email address has been verified. Account email address has been changed.", "pie-register");
7863 $type = "success";
7864 }
7865 } else {
7866 $print_message = esc_html__('Verification link has expired or is invalid.', 'pie-register');
7867 $type = "error";
7868 }
7869 }
7870
7871 if (is_user_logged_in()) {
7872 $print_message = base64_encode($print_message);
7873 wp_safe_redirect($this->get_page_uri($global_options["alternate_profilepage"], "edit_user=1&pr_msg={$print_message}&type={$type}"));
7874 exit;
7875 } else {
7876 $_POST[$type] = $print_message;
7877 }
7878 }
7879 }
7880 /*
7881 * PR Rated
7882 */
7883 public function pieregister_rated()
7884 {
7885 // Run a security check.
7886 if (! check_ajax_referer('pie_rated_nonce', 'nonce', false)) {
7887 wp_send_json_error(esc_html__('Something went wrong.', 'pie-register'));
7888 }
7889
7890 update_option('pie_admin_footer_text_rated', 1);
7891 wp_send_json_success();
7892 }
7893
7894 /*
7895 * Payment log file Download & Delete
7896 * Payment Log section to download all Payment information
7897 */
7898 function piereg_payment_log_file_action()
7899 {
7900 if (!is_admin() || !current_user_can('manage_options'))
7901 return false;
7902
7903 if (isset($_POST['piereg_download_payment_log_file']) && isset($_POST['piereg_payment_log']) && wp_verify_nonce($_POST['piereg_payment_log'], 'piereg_wp_payment_log')) {
7904 $this->piereg_get_wp_plugable_file();
7905 // Get file contents
7906 $read_log_file = $this->read_upload_file(PIE_LOG_FILE . "/payment-log.log");
7907 if (!empty($read_log_file)) {
7908 // Send file headers
7909 header('Content-disposition: attachment; filename=payment-log-' . date_i18n("d-m-y-H-i-s") . '.log');
7910 header('Content-type: application/text');
7911 // Send the file contents, write them in the file
7912 echo esc_html($read_log_file);
7913 exit;
7914 } else {
7915 $this->pie_post_array['error'] = esc_html__("Empty Payment Log File", "pie-register");
7916 }
7917 } elseif (isset($_POST['piereg_delete_payment_log_file']) && isset($_POST['piereg_payment_log']) && wp_verify_nonce($_POST['piereg_payment_log'], 'piereg_wp_payment_log')) {
7918 $this->piereg_get_wp_plugable_file();
7919 update_option("piereg_payment_log_option", array());
7920 $this->pie_post_array['notice'] = esc_html__("Payment log successfully removed.", "pie-register");
7921 } else if (isset($_POST['piereg_download_payment_log_file']) || isset($_POST['piereg_delete_payment_log_file'])) {
7922 $this->pie_post_array['error'] = esc_html__("Invalid nonce.", "pie-register");
7923 }
7924 }
7925 }
7926 }
7927
7928 if (class_exists('PieRegister')) {
7929 $pie_register = new PieRegister();
7930 $GLOBALS['piereg_api_manager'] = $pie_register;
7931 if (isset($pie_register)) {
7932 register_activation_hook(__FILE__, array(&$pie_register, 'install_settings'));
7933 register_deactivation_hook(__FILE__, array(&$pie_register, 'deactivation_settings'));
7934
7935 if (!function_exists("pie_registration_url")) {
7936 function pie_registration_url($url = false)
7937 {
7938 return PieRegister::static_pie_registration_url($url);
7939 }
7940 }
7941
7942 if (!function_exists("pie_login_url")) {
7943 function pie_login_url($url = false)
7944 {
7945 // return PieRegister::static_pie_login_url($url);
7946
7947 global $pie_register;
7948 return $pie_register->static_pie_login_url($url);
7949 }
7950 }
7951
7952 if (!function_exists("pie_lostpassword_url")) {
7953 function pie_lostpassword_url($url = false)
7954 {
7955 return PieRegister::static_pie_lostpassword_url($url);
7956 }
7957 }
7958
7959 if (!function_exists("piereg_logout_url")) {
7960 function piereg_logout_url($url = false)
7961 {
7962 return PieRegister::static_piereg_logout_url($url);
7963 }
7964 }
7965
7966 if (!function_exists("pie_modify_custom_url")) {
7967 function pie_modify_custom_url($url, $query_string = false)
7968 {
7969 return PieRegister::static_pie_modify_custom_url($url, $query_string);
7970 }
7971 }
7972
7973 if (!function_exists("set_pr_stats")) {
7974 function set_pr_stats($stats, $type)
7975 {
7976 return PieRegister::static_set_pr_stats($stats, $type);
7977 }
7978 }
7979 }
7980
7981 if (!function_exists("uninstall_pr_ff")) {
7982 function uninstall_pr_ff()
7983 {
7984 global $pie_register;
7985 if (!is_object($pie_register)) {
7986 $pie_register = new PieRegister();
7987 }
7988 $pie_register->uninstall_settings();
7989 }
7990 }
7991 register_uninstall_hook(__FILE__, 'uninstall_pr_ff');
7992 }
7993
7994
7995