PluginProbe
Pie Register – User Registration, Profiles & Content Restriction / 3.8
Pie Register – User Registration, Profiles & Content Restriction v3.8
3.8.4.13 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 All 179 releases
pie-register / pie-register.php

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

8,063 lines 352.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 Plugin Name: Pie Register - Basic
5 Plugin URI: https://pieregister.com/
6 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!
7 Version: 3.8
8 Author: Pie Register
9 Author URI: https://pieregister.com/
10 Text Domain: pie-register
11 Domain Path: /languages
12 */
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 echo 'Hi there! I\'m just a plugin, not much I can do when called directly.';
16 exit;
17 }
18
19 /*
20 * Get Pie Register Dir Name
21 */
22 $piereg_dir_path = dirname(__FILE__);
23
24 // Plugin Folder Path.
25 if(!defined("PIEREG_DIR_NAME")){
26 define("PIEREG_DIR_NAME", $piereg_dir_path );
27 }
28
29 // Plugin Folder URL.
30 if ( ! defined( 'PIEREG_PLUGIN_URL' ) ) {
31 define( 'PIEREG_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
32 }
33
34 /*
35 * Include PR Files
36 */
37
38 require_once(PIEREG_DIR_NAME.'/classes/base.php');
39 require_once(PIEREG_DIR_NAME.'/classes/profile_admin.php');
40 require_once(PIEREG_DIR_NAME.'/classes/profile_front.php');
41 require_once(PIEREG_DIR_NAME.'/classes/registration_form.php');
42 require_once(PIEREG_DIR_NAME.'/classes/edit_form.php');
43 require_once(PIEREG_DIR_NAME.'/widget.php');
44 require_once(PIEREG_DIR_NAME.'/dash_widget.php');
45 require_once(PIEREG_DIR_NAME.'/piereg_walker-nav-menu.php');
46
47 /**
48 * Include PR App Services files
49 * Since 3.5
50 */
51
52 if(file_exists(PIEREG_DIR_NAME.'/classes/app/app_api.php')) require_once(PIEREG_DIR_NAME.'/classes/app/app_api.php');
53 if(file_exists(PIEREG_DIR_NAME.'/classes/app/firebase.php')) require_once(PIEREG_DIR_NAME.'/classes/app/firebase.php');
54 if(file_exists(PIEREG_DIR_NAME.'/classes/app/push.php')) require_once(PIEREG_DIR_NAME.'/classes/app/push.php');
55
56 /*
57 Move PR DB Version Name to PieRegisterBaseVariables
58 */
59 if (!function_exists("pr_licenseKey_errors")) {
60 function pr_licenseKey_errors() {
61 do_action("pr_licenseKey_errors");
62 }
63 }
64
65 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;
66
67 $piereg_math_captcha_register = false;
68 $piereg_math_captcha_register_widget = false;
69 $piereg_math_captcha_login = false;
70 $piereg_math_captcha_login_widget = false;
71 $piereg_math_captcha_forgot_pass = false;
72 $piereg_math_captcha_forgot_pass_widget = false;
73
74 register_activation_hook(__FILE__, 'checkPieRegisterPremiumVersion');
75
76 //Action to Perform when activating
77 function checkPieRegisterPremiumVersion()
78 {
79 if (is_plugin_active('pie-register-premium/pie-register-premium.php')) {
80 // Deactivate Premium Version
81 deactivate_plugins('pie-register-premium/pie-register-premium.php');
82 }
83
84 add_option( 'piereg_activated_time', time(), '', false );
85 }
86
87 if( !class_exists('PieRegister') ){
88 class PieRegister extends PieReg_Base{
89 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;
90 private $ipn_status,$ipn_debug,$post_block_content,$ipn_response = array(),$piereg_jquery_enable = false;
91
92 function __construct(){
93 global $pagenow,$wp_version,$profile;
94
95 /////
96 $this->is_pr_preview = false;
97 $this->pie_pr_dec_vars_array = false;
98 $this->pie_pr_backend_dec_vars_array = false;
99 $this->pie_ua_renew_account_url = false;
100 $this->pie_is_social_renew_account_call = false;
101 $this->pie_after_login_page_redirect_url = false;
102
103 ///////////////////
104 $this->pie_payment_methods_dat = apply_filters('add_select_payment_script_',$this->pie_payment_methods_dat);
105 ///////////////////
106 $this->ipn_status = '';
107 $this->txn_id = null;
108 $this->ipn_log = true;
109 $this->ipn_response = '';
110 $this->ipn_debug = false;
111 //self::$pieinstance = $this;
112 /***********************/
113 parent::__construct();
114
115 $this->pieActions();
116 $this->pieFilters();
117 $errors = new WP_Error();
118
119 /*
120 * API Classes
121 */
122
123 if( is_admin() && ( (isset($_POST['piereg_license_key']) && !empty($_POST['piereg_license_key'])) || (isset($_POST['piereg_pro_not_activated'] )) ) )
124 {
125 $plugin_name = untrailingslashit( plugin_basename( __FILE__ ) ); // same as plugin slug. if a theme use a theme name like 'twentyeleven'
126 /*if
127 (post || has)*/
128 // Performs activations and deactivations of API License Keys
129 if( file_exists(PIEREG_DIR_NAME.'/classes/api/class-wc-key-api.php') )
130 require_once(PIEREG_DIR_NAME.'/classes/api/class-wc-key-api.php');
131 // Checks for software updatess
132 if( file_exists(PIEREG_DIR_NAME.'/classes/api/class-wc-plugin-update.php') )
133 require_once(PIEREG_DIR_NAME.'/classes/api/class-wc-plugin-update.php');
134 // Admin menu with the license key and license email form
135 if( file_exists(PIEREG_DIR_NAME. '/classes/api/class-wc-api-manager-menu.php') )
136 require_once( PIEREG_DIR_NAME. '/classes/api/class-wc-api-manager-menu.php' );
137
138 /* Load update class to update $this plugin
139 ** This function is not using since version 3.3.0. It was previously using for premium plugin.
140 ** Function in base.php removed. Below line will also soon remove from upcoming version.
141 ** 27-08-2021
142 */
143 # $this->load_plugin_self_updater($plugin_name); // Temporary disable license checker.
144 }
145
146 //Download or View Log file
147 $this->pr_logfile_download_or_view();
148 }
149
150 function pie_main(){
151 global $piereg_global_options, $pagenow;
152 $option = $piereg_global_options;
153
154 //LOCALIZATION
155 #Place your language file in the plugin folder and name it "pie-register-{language}.mo"
156 #replace {language} with your language value from wp-config.php
157 //load_textdomain( 'pie-register', ABS_PATH_TO_MO_FILE ); // OK
158
159 #$locale = ( get_locale() != '' ) ? get_locale() : 'en_US';
160 #load_textdomain( 'pie-register', WP_LANG_DIR . '/plugins/' . 'pie-register' . '-' . $locale . '.mo');
161 load_plugin_textdomain( 'pie-register', false, dirname(plugin_basename(__FILE__)) . '/languages/');
162
163
164 $pie_plugin_data = get_plugin_data( __FILE__ );
165 $pie_plugin_version = $pie_plugin_data['Version'];
166 if(!get_option('pie_countries_v352') && $pie_plugin_version >= "3.5.2"){
167 $this->updated_countries_list();
168 }
169
170 $pie_plugin_db_version = get_option('piereg_plugin_db_version');
171 if($pie_plugin_db_version != PIEREG_DB_VERSION){
172 $this->install_settings();
173 }
174
175 /*
176 * Define PR Version
177 */
178 if ( ! defined( 'PIEREGISTER_VERSION' ) ) {
179 define( 'PIEREGISTER_VERSION', $pie_plugin_version );
180 }
181
182 $_changed_un_email_template = get_option('pie_email_template_updated_blocked_unverified_users');
183 if(!$_changed_un_email_template)
184 {
185 $this->update_email_template_unverified_grace();
186 }
187
188 // :added elementor-preview - Fixing elementor loading issue with PR forms //
189 $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;
190
191 // :added DIVI-preview - Fixing DIVI loading issue with PR forms //
192 $this->is_pr_preview = (isset($_GET['et_pb_preview']))?true:$this->is_pr_preview;
193
194 if(!function_exists('wp_get_current_user')) {
195 include_once(ABSPATH . WPINC . "/pluggable.php");
196 }
197
198 # Change User Avatar With Pie Profile Picture, If Used:
199 add_filter( 'get_avatar' , array($this,'pie_user_avatar') , 1 , 5 );
200 if( !is_admin() && (is_user_logged_in() && !current_user_can('administrator') ) )
201 {
202 //add_filter( 'get_avatar' , array($this,'pie_user_avatar') , 1 , 5 );
203 }
204
205 if( is_admin() && current_user_can('administrator') )
206 {
207 add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 1000 );
208
209 # Delete Unverified Users Over Grace Period
210 $this->deleteUnverifiedUsers();
211
212 #Assign pie register's all custom capabilities to administrator (default).
213 do_action('piereg_add_custom_cap',array('piereg_manage_cap'));
214 }
215
216 if( file_exists(PIEREG_DIR_NAME."/editors/elementor/Elementor.php") )
217 require_once(PIEREG_DIR_NAME."/editors/elementor/Elementor.php");
218
219 do_action( 'pieregister_elementor' );
220
221 if( file_exists(PIEREG_DIR_NAME."/editors/divi/Divi.php") )
222 require_once(PIEREG_DIR_NAME."/editors/divi/Divi.php");
223
224 do_action( 'pieregister_divi' );
225
226 add_action( 'wp_ajax_pie_rated', array( $this, 'pieregister_rated' ) );
227 //add_filter( 'wp_privacy_personal_data_exporters', array($this, 'register_my_plugin_exporter'), 10);
228
229 if( current_user_can( 'administrator' ) && $this->show_notice_premium_users ){
230 #Pro Version Release notices
231 add_action( 'admin_notices', array( $this, 'pie_free_notice_to_premium_users' ), 1 );
232 }
233
234 add_action( 'admin_notices', array( $this, 'pie_promo_notice_security' ), 1 );
235 add_action( 'admin_notices_specific_pages', array( $this, 'pie_premium_features_notice_for_free' ), 1 );
236
237 add_action( 'admin_notices', array( $this, 'pie_leave_a_review_request' ), 1 );
238
239 # // license_expiry
240 add_action( 'admin_notices', array( $this, 'pie_license_expire_msg' ), 1 );
241 add_action( 'wp_ajax_dismiss_pie_license_expire_msg', array( $this, 'dismiss_pie_license_expire_msg' ) );
242
243 # // Enable Registration Notice - "Anyone Can Register"
244 add_action( 'admin_notices', array( $this, 'pie_enable_registration_msg' ), 1 );
245
246 if( is_plugin_active('woocommerce/woocommerce.php') && !is_plugin_active('pie-register-woocommerce/pie-register-woocommerce.php') ) {
247 add_action( 'admin_notices', array( $this, 'pie_promo_notice_for_wc_user' ), 1 );
248 }
249 if( is_plugin_active('mailchimp-for-wp/mailchimp-for-wp.php') && !is_plugin_active('pie-register-mailchimp/pie-register-mailchimp.php') ) {
250 add_action( 'admin_notices', array( $this, 'pie_promo_notice_for_mc_user' ), 1 );
251 }
252 if( is_plugin_active('bbpress/bbpress.php') && !is_plugin_active('pie-register-bbpress/pie-register-bbpress.php') ) {
253 add_action( 'admin_notices', array( $this, 'pie_promo_notice_for_bb_user' ), 1 );
254 }
255 $all_plugins = get_plugins();
256
257 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 ) ) ) {
258 add_action( 'admin_notices', array( $this, 'pie_promo_notice_for_wpb_user' ), 1 );
259 }
260
261 add_action( 'wp_ajax_dismiss_pie_promo_notice_security', array( $this, 'dismiss_pie_promo_notice_security' ) );
262 add_action( 'wp_ajax_dismiss_pie_promo_notice_for_wc_user', array( $this, 'dismiss_pie_promo_notice_for_wc_user' ) );
263 add_action( 'wp_ajax_dismiss_pie_promo_notice_for_mc_user', array( $this, 'dismiss_pie_promo_notice_for_mc_user' ) );
264 add_action( 'wp_ajax_dismiss_pie_promo_notice_for_bb_user', array( $this, 'dismiss_pie_promo_notice_for_bb_user' ) );
265 add_action( 'wp_ajax_dismiss_pie_promo_notice_for_wpb_user', array( $this, 'dismiss_pie_promo_notice_for_wpb_user' ) );
266 add_action( 'wp_ajax_dismiss_pie_premium_features_notice_for_free', array( $this, 'dismiss_pie_premium_features_notice_for_free' ) );
267 add_action( 'wp_ajax_dismiss_pie_leave_a_review_request', array( $this, 'dismiss_pie_leave_a_review_request' ) );
268 add_action( 'wp_ajax_dismiss_pie_free_notice_to_premium_users', array( $this, 'dismiss_pie_free_notice_to_premium_users' ) );
269
270 /*********************************************/
271 /////////////// PIEREG LOGOUT ////////////////
272 if( isset($_GET['piereg_logout_url']) && $_GET['piereg_logout_url'] == "true" ){
273 $after_logout_page = (intval($option['alternate_logout']) <= 0)? home_url() : $this->get_page_uri($option['alternate_logout']);
274 $redirect_to = (isset($_GET['redirect_to']) && !empty($_GET['redirect_to']))? esc_url_raw(urldecode($_GET['redirect_to'])) : $after_logout_page;
275
276 if(is_user_logged_in() && (isset($_GET['_logout_nonce']) && wp_verify_nonce($_GET['_logout_nonce'], 'pie-log-out'))) {
277 wp_logout();
278 wp_redirect(esc_url_raw($redirect_to));
279 exit;
280 }
281 }
282
283 /*********************************************/
284
285 /////////// Register Scripts ////////////
286 $this->piereg_register_scripts();
287 ////////////////////////////////////////
288
289 // check to prevent php "notice: undefined index" msg
290 $theaction = '';
291 if(isset($_GET['action']))
292 $theaction = sanitize_text_field($_GET['action']);
293
294 if((isset($_GET['show_dash_widget']) && $_GET['show_dash_widget']==1) and (isset($_GET['invitaion_code']) && $_GET['invitaion_code']!="")){
295 $this->show_invitaion_code_user();
296 }
297
298 # PAYPAL VALIDATION
299 $this->ValidPUser();
300
301 # Save Settings
302 if( isset($_POST['action']) && $_POST['action'] == 'pie_reg_update' )
303 {
304 $this->SaveSettings();
305 }
306
307 if( isset($_POST['action']) && $_POST['action'] == 'pie_reg_settings' ) {
308 $this->PieRegSettingsProcess();
309 }
310 // task av
311 # Admin verifying user through email
312 if(isset($_GET['action']) && $_GET['action'] == 'unverified_user'){
313 add_action ('wp_body_open' , array( $this, 'process_verify_user_email' ));
314 }
315
316 #Reset Settings to default
317 if( isset($_POST['piereg_default_settings']) )
318 {
319 $this->piereg_default_settings();
320 }
321
322 #Admin Verify Users
323 if( isset($_POST['verifyit']) )
324 $this->verifyUsers();
325
326 #Admin Send Payment Link
327 if( isset($_POST['paymentl']) )
328 $this->PaymentLink();
329
330 #Admin Resend VerificatioN Email
331 if( isset($_POST['emailverifyit']) )
332 $this->AdminEmailValidate() ;
333
334 #Admin Delete Unverified User
335 if( isset($_POST['vdeleteit']))
336 $this->AdminDeleteUnvalidated();
337
338 /*
339 * Add since 2.0.13
340 * Change email after verify
341 */
342 $this->edit_email_verification();
343 /* End */
344
345 // Payment Log File Download & Delete
346 $this->piereg_payment_log_file_action();
347
348 //Blocking wp admin for registered users
349 if(
350 ($pagenow == 'wp-login.php' && $option['block_wp_login']==1) &&
351 ($option['alternate_login'] && $theaction != 'logout') &&
352 (!isset($_REQUEST['interim-login']))
353 ){
354
355 if ( force_ssl_admin() && ! is_ssl() ) {
356 $is_ssl = true;
357 }else{
358 $is_ssl = false;
359 }
360
361 if($theaction=="register"){
362 if($is_ssl){
363 wp_safe_redirect(preg_replace('|^http://|', 'https://', $this->get_redirect_url_pie(get_permalink($option['alternate_register']))));
364 exit;
365 }
366 else{
367 wp_safe_redirect($this->get_redirect_url_pie(get_permalink($option['alternate_register'])));
368 exit;
369 }
370
371 }
372 else if($theaction=="lostpassword")
373 {
374 if($is_ssl){
375 wp_safe_redirect(preg_replace('|^http://|', 'https://', $this->get_redirect_url_pie(get_permalink($option['alternate_forgotpass']))));
376 exit;
377 }
378 else{
379 wp_safe_redirect($this->get_redirect_url_pie(get_permalink($option['alternate_forgotpass'])));
380 exit;
381 }
382 }
383 else if($theaction=="")
384 {
385 if($is_ssl){
386 wp_safe_redirect(preg_replace('|^http://|', 'https://', $this->get_redirect_url_pie(get_permalink($option['alternate_login']))));
387 exit;
388 }
389 else{
390 wp_safe_redirect($this->get_redirect_url_pie(get_permalink($option['alternate_login'])));
391 exit;
392 }
393 }
394 }
395
396 //Blocking access of users to default pages if redirect is on
397
398 if($theaction != 'logout' && $theaction != 'postpass' )
399 {
400 if((is_user_logged_in() && $pagenow == 'wp-login.php') && ($option['redirect_user']==1 && $theaction != 'logout'))
401 {
402 if(!isset($_REQUEST['interim-login'])){
403 $this->afterLoginPage();
404 }
405 }
406 }
407 if(trim($pagenow) == "profile.php" && $option['block_WP_profile']==1 )
408 {
409 $current_user = wp_get_current_user();
410 if(trim($current_user->roles[0]) !== "administrator")
411 {
412 //$profile_page = get_option("Profile_page_id");
413 $profile_page = $option['alternate_profilepage'];
414 if($profile_page > 0){
415 wp_safe_redirect($this->get_redirect_url_pie(get_permalink($profile_page)));
416 exit;
417 }
418 }
419 }
420
421 //Blocking wp admin for registered users
422 if( isset($_POST['pie_submit'], $_POST['piereg_registration_form_nonce']) && wp_verify_nonce($_POST['piereg_registration_form_nonce'], 'piereg_wp_registration_form_nonce') )
423 {
424 $this->check_register_form();
425 }
426 else if(isset($_POST['pie_renew']))
427 {
428 $this->renew_account();
429 }
430
431 // if the user is on the login page, then let the game begin
432 if($theaction != 'logout' && $theaction != 'postpass' )
433 {
434 if ($pagenow == 'wp-login.php' && $theaction != 'logout'){
435 add_action('login_init',array($this,'pieregister_login'),1);
436 }
437 }
438
439 //OImport Export Section
440 if(isset($_POST['pie_fields_csv']) || isset($_POST['pie_meta_csv'])){
441 $this->generateCSV();
442 }
443 else if(isset($_FILES['csvfile']['name'])){
444 $this->importUsers();
445 }
446
447 if(isset($_POST['pie_form']))
448 {
449 //This will make sure no one tempers the field from the client side
450 /*$required = array("form","username","email","password","submit");*/
451 $required = array("form","email","submit");
452 $length = 0;
453 foreach($_POST['field'] as $field)
454 {
455 if(in_array($field['type'],$required))
456 $length++;
457 }
458 if($length==sizeof($required))
459 {
460 $this->saveFields();
461 }
462 }
463
464 if(isset($_GET['prfrmid']) and ((int)$_GET['prfrmid']) != 0 and isset($_GET['status']) and $_GET['status'] != "")
465 {
466 $fields_id = ((int)$_GET['prfrmid']);
467 $pr_form_option = get_option("piereg_form_field_option_".$fields_id);
468 $pr_form_option['Status'] = ( strtolower( sanitize_key($_GET['status']) ) );
469 update_option("piereg_form_field_option_".$fields_id,$pr_form_option);
470
471 #$this->pie_post_array['notice'] = esc_html__("Successfully Change Status of Pie Register Registration Form","pie-register");
472
473 }
474
475 if( ( isset($_GET['prfrmid']) and ((int)$_GET['prfrmid']) != 0 and isset($_GET['action']) and $_GET['action'] == "delete" ) && $this->check_if_role_admin() )
476 {
477
478 // if users created from Form then disable it, delete if no submission.
479 $fields_id = ((int)sanitize_key($_GET['prfrmid']));
480 $pr_all_form_info = $this->get_pr_forms_info();
481 if(count($pr_all_form_info) > 1) {
482
483 $fields_id = ((int)sanitize_key($_GET['prfrmid']));
484 $optionsform = get_option("piereg_form_field_option_".$fields_id);
485
486 if( $optionsform['Entries'] > 0 ) {
487 $optionsform['IsDeleted'] = 1;
488 update_option("piereg_form_field_option_".$fields_id,$optionsform);
489
490 // Assign new free form.
491 $this->regFormForFreeVers(true);
492 } else {
493 $this->delete_piereg_form();
494 }
495
496 } else {
497 $this->pie_post_array['error_message'] = esc_html__("Form deletion failed.","pie-register");
498 }
499 }
500
501 if(
502 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')
503 )
504 {
505 if(trim($_POST['invitaion_code_bulk_option']) == "delete")
506 {
507 $this->delete_invitation_codes($_POST['select_invitaion_code_bulk_option']);
508 }
509 else if(trim($_POST['invitaion_code_bulk_option']) == "active")
510 {
511 $this->active_or_unactive_invitation_codes($_POST['select_invitaion_code_bulk_option'],"1");
512 }
513 else if(trim($_POST['invitaion_code_bulk_option']) == "unactive")
514 {
515 $this->active_or_unactive_invitation_codes($_POST['select_invitaion_code_bulk_option'],"0");
516 }
517 }
518 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'] != "")
519 {
520 $opt = get_option(OPTION_PIE_REGISTER);
521 $val = ((int)($_POST['invitation_code_per_page_items']) != 0)? ((int)$_POST['invitation_code_per_page_items']) : "10";
522 $opt['invitaion_codes_pagination_number'] = intval( $val );
523 update_option(OPTION_PIE_REGISTER,$opt);
524 $piereg_global_options = $opt;
525 unset($opt);
526 }
527
528 if(
529 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')
530 )
531 {
532
533 if(trim($_POST['custom_role_bulk_option']) == "delete")
534 {
535 $this->delete_custom_roles($_POST['select_custom_role_bulk_option']);
536 }
537 }
538
539 if( isset($option['show_admin_bar']) && $option['show_admin_bar'] == "1" )
540 {
541 $this->subscriber_show_admin_bar();// show/hide admin bar
542 }
543
544 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" ) )
545 {
546 $old_options = get_option("pie_register_2");
547 $new_options = get_option(OPTION_PIE_REGISTER);
548 $new_options['user_message_email_admin_verification'] = nl2br($old_options['adminvmsg']);
549 $new_options['user_message_email_email_verification'] = nl2br($old_options['emailvmsg']);
550 $new_options['user_message_email_default_template'] = nl2br($old_options['msg']);
551 update_option(OPTION_PIE_REGISTER,$new_options);
552 global $piereg_global_options;
553 $piereg_global_options = $new_options;
554 }
555
556 if(isset($option['show_custom_logo']) && $option['show_custom_logo'] == 1){
557 if(trim($option['custom_logo_url']) != ""){
558 add_action( 'login_enqueue_scripts', array($this,'piereg_login_logo'));
559 }
560 add_filter( 'login_headertext', array($this,'piereg_login_logo_url_title' )); // login_headertitle was deprecated.
561 add_filter( 'login_headerurl', array($this,'piereg_login_logo_url' ));
562 }
563
564 /*
565 * Activate addon license key
566 */
567 $this->activate_addon_license_key();
568
569 // 3.6.15
570 add_action( 'wp_ajax_pieregister_activate_addon', array($this, 'pieregister_activate_addon' ));
571 add_action( 'wp_ajax_pieregister_deactivate_addon', array($this, 'pieregister_deactivate_addon' ));
572 add_action( 'wp_ajax_pieregister_install_addon', array($this, 'pieregister_install_addon' ));
573
574 // 3.7.15 - To allow properties in style attributes with wp_kses
575 add_filter( 'safe_style_css', function( $styles ) {
576 $styles[] = 'visibility';
577 $styles[] = 'display';
578 return $styles;
579 } );
580 }
581 function pieActions(){
582 global $piereg_global_options, $pagenow;
583
584 add_action('wp_ajax_check_username', array($this,'unique_user' ));
585 add_action('wp_ajax_nopriv_check_username', array($this,'unique_user' ));
586
587 add_action( 'admin_init', array($this,'piereg_register_scripts') );
588 add_action( 'admin_init', array($this,'piereg_backendregister_scripts') );
589 #Adding Menus
590 add_action( 'admin_menu', array($this,'AddPanel') );
591 // Show Pie Register Menu on the Admin Bar
592 add_action( 'admin_bar_menu', array($this,'AddPanelOnAdminBar') , 999);
593
594 //Add paypal payment method
595 add_action("check_payment_method_paypal", array($this, "check_payment_method_paypal"),10,1);
596
597
598 //Adding "embed form" button
599 add_action('media_buttons', array($this, 'add_pie_form_button'));
600
601 if(in_array(basename($_SERVER['PHP_SELF']), array('post.php', 'page.php', 'page-new.php', 'post-new.php')) && is_admin() ){
602 add_action('admin_footer', array($this, 'add_pie_form_popup'));
603 }
604
605 //after_setup_theme {{ previously fires on after_setup_theme hook }}
606 add_action("init",array($this,"piereg_after_setup_theme"));
607
608 #Genrate Warnings
609 add_action('admin_notices', array($this, 'warnings'),20);
610
611 add_action( 'init', array($this,'pie_main') );
612 $profile = new Profile_admin();
613 add_action('show_user_profile',array($profile,"edit_user_profile"));
614 add_action('personal_options_update',array($profile,"updateMyProfile"));
615
616 add_action('edit_user_profile',array($profile,"edit_user_profile"));
617 add_action('edit_user_profile_update', array($profile,'updateProfile'));
618
619 add_action( 'widgets_init', array($this,'initPieWidget'));
620
621 add_action('get_header', array($this,'add_ob_start'));
622 //It will redirect the User to the home page if the curren tpage is a alternate login page
623 //add_filter('get_header', array($this,'checkLoginPage'));
624
625 add_action('payment_validation_paypal', array($this, 'payment_validation_paypal'));
626
627 add_action("add_select_payment_script", array($this,"add_select_payment_script"));
628 add_filter("get_payment_content_area", array($this,"get_payment_content_area"));
629 add_action("show_icon_payment_gateway", array($this,"show_icon_payment_gateway"));
630 add_action("pr_licenseKey_errors",array($this,"print_Rpr_licenseKey_errors"),30);
631 add_filter("piereg_messages",array($this,"modify_all_notices"));
632
633 /*update update_invitation_code form ajax*/
634 add_action( 'wp_ajax_pireg_update_invitation_code', array($this,'pireg_update_invitation_code_cb_url' ));
635 add_action( 'wp_ajax_nopriv_pireg_update_invitation_code', array($this,'pireg_update_invitation_code_cb_url' ));
636
637 //action to assign piereg_manage_cap to administrator
638 add_action( 'piereg_add_custom_cap', array($this,'piereg_add_custom_cap' ));
639
640 // FRONT END SCRIPTS
641 add_action('wp_enqueue_scripts',array($this,'piereg_frontend_assets_header'));
642 add_action( 'wp_footer', array( $this, 'piereg_frontend_assets_footer' ), 15 );
643 add_action('admin_enqueue_scripts', array($this,'pie_backend_enqueue_scripts'));
644
645 if( file_exists(PIEREG_DIR_NAME."/editors/wpbakery/wpbakery-pie-element.php") && defined( 'WPB_VC_VERSION' ))
646 require_once(PIEREG_DIR_NAME."/editors/wpbakery/wpbakery-pie-element.php");
647
648 if( file_exists(PIEREG_DIR_NAME."/editors/gutenberg/gutenberg-block.php") )
649 require_once(PIEREG_DIR_NAME."/editors/gutenberg/gutenberg-block.php");
650
651 do_action( 'pieregister_gutenberg');
652
653 //User Deletion
654 add_action( 'delete_user', array( $this, 'piereg_user_deletion' ) );
655 #Adding Short Code Functionality
656 add_shortcode( 'pie_register_login', array($this,'showLoginForm') );
657 add_shortcode( 'pie_register_profile', array($this,'showProfile') );
658 add_shortcode( 'pie_register_forgot_password', array($this,'showForgotPasswordForm') );
659 add_shortcode( 'pie_register_renew_account', array($this,'show_renew_account') );
660 add_shortcode( 'pie_register_form', array($this,'piereg_registration_form') );
661 // Adding shortcode for user's profile picture
662 // ver - 3.6.3
663 add_shortcode( 'pie_user_profile_pic', array($this,'piereg_user_profile_pic') );
664 add_action("the_post",array($this,"piereg_template_restrict"));
665 //Add Post Meta Box
666 add_action('add_meta_boxes', array($this,'piereg_add_meta_box'));
667 //Save Post Meta Box
668 add_action('save_post', array($this,'piereg_save_meta_box_data'));
669 //Validate User expiry period
670 add_action("piereg_validate_user_expiry_period", array($this,"piereg_validate_user_expiry_period_func"),10,1);
671 add_action( 'wp_footer', array($this,'print_multi_captcha_skin' ));
672 add_action('wp_footer', array($this,'pie_update_user_meta_admin_hash' ));
673
674 if(in_array($GLOBALS['pagenow'], array('wp-login.php'))){
675 add_filter( 'wp_authenticate_user', array( $this, 'pie_check_status_on_login' ), 10, 2 );
676 }
677
678
679 //Rest API Initialized
680 $pie_api = new Pie_api();
681 }
682 function pieFilters(){
683 global $piereg_global_options;
684 add_action("add_payment_method_script", array($this,"add_payment_method_script"));
685 //Add sub links in wp plugin's page
686 add_filter( 'plugin_row_meta', array( $this, 'piereg_plugin_row_meta' ), 10, 2 );
687 //plugin page links
688 add_filter( 'plugin_action_links', array($this,'add_action_links'),10,2 );
689 //add_filter("Add_payment_option_PaypalStandard", array($this,'Add_payment_option_PaypalStandard'),10,1);
690 add_filter("Add_payment_option", array($this,"Add_payment_option"),10,3);
691 add_filter("get_payment_gateway_content", array($this,"get_paypalstandard"),10,3);
692
693 add_filter('allow_password_reset',array($this,'checkUserAllowedPassReset'),20,2);
694 if(isset($piereg_global_options['block_wp_login']) && $piereg_global_options['block_wp_login']){
695 add_filter( 'login_url', array($this,'pie_login_url'),88888,1);
696 add_filter( 'lostpassword_url', array($this,'pie_lostpassword_url'),88888,1);
697 add_filter( 'register_url', array($this,'pie_registration_url'),88888,1);
698 add_filter( 'logout_url', array($this,'piereg_logout_url'),88888,2);
699 add_filter( 'wp_nav_menu_objects', array($this,'pie_add_logout_url_nonce'));
700 }
701 add_filter( 'piereg_password_reset_not_allowed_text', array($this,'piereg_password_reset_not_allowed_text_function'),20,1);
702
703 /**
704 * Invitation code column added in Users grid
705 * Since v3.5.4
706 */
707 add_filter( 'manage_users_columns', array($this,'pie_column_invite') ); // Add column in Users Table
708 add_filter( 'manage_users_custom_column', array($this,'pie_column_invite_value'), 10, 3 ); // Add column value in Users Table
709 add_filter( 'pie_manage_users_custom_column_name', array($this,'pie_users_custom_column_name'), 10 );
710 }
711 function pieregister_activate_addon() {
712
713 // Run a security check.
714 if ( ! check_ajax_referer( 'pieregister_admin', 'nonce', false ) ) {
715 wp_send_json_error( esc_html__( 'Your session expired. Please reload the page.', 'pie-register' ) );
716 }
717
718 // Check for permissions.
719 if ( ! current_user_can( 'activate_plugins' ) ) {
720 wp_send_json_error( esc_html__( 'Plugin activation is disabled for you on this site.', 'pie-register' ) );
721 }
722
723 if ( isset( $_POST['plugin'] ) ) {
724 $type = 'addon';
725 if ( ! empty( $_POST['type'] ) ) {
726 $type = sanitize_key( $_POST['type'] );
727 }
728
729 $plugin = sanitize_text_field( wp_unslash( $_POST['plugin'] ) );
730 $activate = activate_plugins( $plugin );
731
732 do_action( 'pieregister_plugin_activated', $plugin );
733
734 if ( ! is_wp_error( $activate ) ) {
735 if ( 'plugin' === $type ) {
736 wp_send_json_success( esc_html__( 'Plugin activated.', 'pie-register' ) );
737 } else {
738 wp_send_json_success( esc_html__( 'Addon activated.', 'pie-register' ) );
739 }
740 }
741 }
742
743 wp_send_json_error( esc_html__( 'Could not activate addon. Please activate from the Plugins page.', 'pie-register' ) );
744 }
745 function pieregister_deactivate_addon() {
746
747 // Run a security check.
748 if ( ! check_ajax_referer( 'pieregister_admin', 'nonce', false ) ) {
749 wp_send_json_error( esc_html__( 'Your session expired. Please reload the page.', 'pie-register' ) );
750 }
751
752 // Check for permissions.
753 if ( ! current_user_can( 'deactivate_plugins' ) ) {
754 wp_send_json_error( esc_html__( 'Plugin deactivation is disabled for you on this site.', 'pie-register' ) );
755 }
756
757 $type = 'addon';
758 if ( ! empty( $_POST['type'] ) ) {
759 $type = sanitize_key( $_POST['type'] );
760 }
761
762 if ( isset( $_POST['plugin'] ) ) {
763 $plugin = sanitize_text_field( wp_unslash( $_POST['plugin'] ) );
764
765 deactivate_plugins( $plugin );
766
767 do_action( 'pieregister_plugin_deactivated', $plugin );
768
769 if ( 'plugin' === $type ) {
770 wp_send_json_success( esc_html__( 'Plugin deactivated.', 'pie-register' ) );
771 } else {
772 wp_send_json_success( esc_html__( 'Addon deactivated.', 'pie-register' ) );
773 }
774 }
775
776 wp_send_json_error( esc_html__( 'Could not deactivate the addon. Please deactivate from the Plugins page.', 'pie-register' ) );
777 }
778 function pieregister_install_addon() {
779
780 // Run a security check.
781 if ( ! check_ajax_referer( 'pieregister_admin', 'nonce', false ) ) {
782 wp_send_json_error( esc_html__( 'Your session expired. Please reload the page.', 'pie-register' ) );
783 }
784
785 $generic_error = esc_html__( 'There was an error while performing your request.', 'pie-register' );
786
787 $type = 'addon';
788 if ( ! empty( $_POST['type'] ) ) {
789 $type = sanitize_key( $_POST['type'] );
790 }
791
792 $error = esc_html__( 'Could not install addon. Please download and install manually.', 'pie-register' );
793
794 if ( empty( $_POST['plugin'] ) ) {
795 wp_send_json_error( $error );
796 }
797
798 // Set the current screen to avoid undefined notices.
799 set_current_screen( 'pie-register_page_pie-about-us' );
800
801 // Prepare variables.
802 $url = esc_url_raw(
803 add_query_arg(
804 array(
805 'page' => 'pie-about-us',
806 ),
807 admin_url( 'admin.php' )
808 )
809 );
810
811 $creds = request_filesystem_credentials( $url, '', false, false, null );
812
813 // Check for file system permissions.
814 if ( false === $creds ) {
815 wp_send_json_error( $error );
816 }
817
818 if ( ! WP_Filesystem( $creds ) ) {
819 wp_send_json_error( $error );
820 }
821
822 /*
823 * We do not need any extra credentials if we have gotten this far, so let's install the plugin.
824 */
825
826 require_once(plugin_dir_path( __FILE__ ) . 'classes/admin/pie-class-install-skin.php');
827 require_once(plugin_dir_path( __FILE__ ) . 'classes/admin/PieRegPluginSilentUpgrader.php');
828
829 // Do not allow WordPress to search/download translations, as this will break JS output.
830 remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
831
832 // Create the plugin upgrader with our custom skin.
833 $installer = new PieRegPluginSilentUpgrader( new PieReg_Install_Skin() );
834
835 // Error check.
836 if ( ! method_exists( $installer, 'install' ) || empty( $_POST['plugin'] ) ) {
837 wp_send_json_error( $error );
838 }
839
840 $installer->install( sanitize_text_field(wp_unslash($_POST['plugin'])) );
841
842 // Flush the cache and return the newly installed plugin basename.
843 wp_cache_flush();
844
845 $plugin_basename = $installer->plugin_info();
846
847 if ( empty( $plugin_basename ) ) {
848 wp_send_json_error( $error );
849 }
850
851 $result = array(
852 'msg' => $generic_error,
853 'is_activated' => false,
854 'basename' => $plugin_basename,
855 );
856
857 // Check for permissions.
858 if ( ! current_user_can( 'activate_plugins' ) ) {
859 $result['msg'] = 'plugin' === $type ? esc_html__( 'Plugin installed.', 'pie-register' ) : esc_html__( 'Addon installed.', 'pie-register' );
860
861 wp_send_json_success( $result );
862 }
863
864 // Activate the plugin silently.
865 $activated = activate_plugin( $plugin_basename );
866
867 if ( ! is_wp_error( $activated ) ) {
868 $result['is_activated'] = true;
869 $result['msg'] = 'plugin' === $type ? esc_html__( 'Plugin installed & activated.', 'pie-register' ) : esc_html__( 'Addon installed & activated.', 'pie-register' );
870
871 wp_send_json_success( $result );
872 }
873
874 // Fallback error just in case.
875 wp_send_json_error( $result );
876 }
877 function pie_column_invite( $column ) {
878 $column['invitation_code'] = esc_html__('Invitation Code','pie-register');
879 $column['registration_date'] = esc_html__('Registration Date','pie-register');
880 return $column;
881 }
882 function pie_column_invite_value( $val, $column_name, $user_id ) {
883
884 $column = apply_filters( 'pie_manage_users_custom_column_name','ls_user_type');
885
886 switch($column_name) {
887 case 'registration_date' :
888 $user_registration_date = date('jS F, Y h:i:s A', strtotime(get_userdata( $user_id)->user_registered)) ;
889 return $user_registration_date ? $user_registration_date : '-';
890 break;
891
892 case 'invitation_code' :
893 $user_meta_data = get_user_meta($user_id, 'invite_code', true);
894 return $user_meta_data ? $user_meta_data : '-';
895 break;
896
897 case $column:
898 return apply_filters('pr_geolocation_custom_column_val',$val,$column,$user_id);
899 break;
900
901 default:
902 }
903 }
904 /*
905 * When user deletion
906 */
907 function piereg_user_deletion( $user_id ) {
908
909 $subscribtion_method = get_user_meta( $user_id, "piereg_user_subscribtion_method", true );
910 $subscribtion_id = get_user_meta( $user_id, "piereg_user_subscribtion_id", true );
911
912 if( !empty($subscribtion_method) && !empty($subscribtion_id) )
913 {
914 do_action("piereg_delete_subscribtion_on_user_deletion_".$subscribtion_method ,$user_id);
915 }
916 }
917
918 function piereg_register_scripts(){
919 wp_register_script('pie_prVariablesDeclaration_script',plugins_url("/assets/js/prVariablesDeclaration.js",__FILE__),false,PIEREGISTER_VERSION);
920 wp_register_script('pie_prBackendVariablesDeclaration_script',plugins_url("/assets/js/prBackendVariablesDeclaration.js",__FILE__),false,PIEREGISTER_VERSION);
921 wp_register_script('pie_prVariablesDeclaration_script_Footer',plugins_url("/assets/js/prVariablesDeclarationFooter.js",__FILE__),'',PIEREGISTER_VERSION,true);
922 wp_register_script('pie_prBackendVariablesDeclaration_script_Footer',plugins_url("/assets/js/prBackendVariablesDeclarationFooter.js",__FILE__),'',PIEREGISTER_VERSION,true);
923 wp_register_script('prBackendCustomLogo_script',plugins_url("/assets/js/prBackendCustomLogo.js",__FILE__),'',PIEREGISTER_VERSION,true);
924 wp_register_script('pie_datepicker_js',plugins_url("/assets/js/datepicker.js",__FILE__),array('jquery'),PIEREGISTER_VERSION,false);
925 wp_register_script('pie_drag_js',plugins_url("/assets/js/drag.js",__FILE__),'jquery',PIEREGISTER_VERSION,false);
926 wp_register_script('pie_mCustomScrollbar_js',plugins_url("/assets/js/jquery.mCustomScrollbar.min.js",__FILE__),'jquery',PIEREGISTER_VERSION,false);
927 wp_register_script('pie_mousewheel_js',plugins_url("/assets/js/jquery.mousewheel.min.js",__FILE__),'jquery',PIEREGISTER_VERSION,false);
928 wp_register_script('pie_phpjs_js',plugins_url("/assets/js/phpjs.js",__FILE__),'jquery',PIEREGISTER_VERSION,false);
929 wp_register_script('pie_registermain_js',plugins_url("/assets/js/pie-register-main.js",__FILE__),'jquery',PIEREGISTER_VERSION,false);
930 wp_register_script('pie_alphanum_js',plugins_url("/assets/js/jquery.alphanum.js",__FILE__),array('jquery'),PIEREGISTER_VERSION,false);
931 wp_register_script('pie_validation_js',plugins_url("/assets/js/piereg_validation.js",__FILE__),'jquery',PIEREGISTER_VERSION,false);
932 wp_register_script('pie_password_checker',plugins_url("/assets/js/pie_password_checker.js",__FILE__),'jquery',PIEREGISTER_VERSION,false);
933 wp_register_script('pie_recpatcha_script','//www.google.com/recaptcha/api.js?onload=prRecaptchaCallBack','','',true); // &render=explicit removed
934
935 wp_register_style( 'pie_front_css', plugins_url("/assets/css/front.css",__FILE__),false,PIEREGISTER_VERSION, "all" );
936 wp_register_style( 'pie_wload_css', plugins_url("/assets/css/jquery.wload.css",__FILE__),false,PIEREGISTER_VERSION, "all" );
937 wp_register_style( 'pie_style_css', plugins_url("/assets/css/style.css",__FILE__),false,PIEREGISTER_VERSION, "all" );
938 wp_register_style( 'pie_ui_css', plugins_url("/assets/css/pie_ui.css",__FILE__),false,PIEREGISTER_VERSION, "all" );
939 wp_register_style( 'pie_jquery_ui', plugins_url("/assets/css/jquery-ui-theme.css",__FILE__),false,'1.12.1', "all" );
940 wp_register_style( 'pie_font_awesome', plugins_url("/assets/css/font-awesome.min.css",__FILE__),false,'4.7.0', "all" );
941
942 // For notices
943 wp_enqueue_style('pie_notice_cs',plugins_url("/assets/css/pie_notice.css",__FILE__),false,PIEREGISTER_VERSION, "all");
944 }
945 function piereg_backendregister_scripts(){
946 //Styles
947 wp_register_style( 'pie_admin_css', plugins_url("/assets/css/admin.css",__FILE__),false,PIEREGISTER_VERSION, "all" );
948 wp_register_style( 'pie_restrict_widget_css', plugins_url("/restrict_widget/restrict_widget_css.css",__FILE__),false,PIEREGISTER_VERSION, "all" );
949 wp_register_style( 'pie_go_pro_menu_css', plugins_url("/assets/css/admin-go-pro-styles.css",__FILE__),false,PIEREGISTER_VERSION, "all" );
950 wp_register_style( 'pie_admin_about_us_menu_css', plugins_url("/assets/css/admin-about-us.css",__FILE__),false,PIEREGISTER_VERSION, "all" );
951 wp_register_style( 'pie_admin_about_us_slick_css', plugins_url("/assets/css/slick.min.css",__FILE__),false,PIEREGISTER_VERSION, "all" );
952 wp_register_style( 'pie_mCustomScrollbar_css', plugins_url("/assets/css/jquery.mCustomScrollbar.css",__FILE__),false,PIEREGISTER_VERSION, "all" );
953 wp_register_style('pie_notification_css', plugins_url("assets/css/pie_notifications.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_wload_js',plugins_url("/assets/js/jquery.wload.js",__FILE__),'jquery','1.0',false);
957 wp_register_script('pie_restrict_widget_script',plugins_url("/restrict_widget/pie_register_widget_script.js",__FILE__),'jquery',PIEREGISTER_VERSION,false);
958
959 wp_register_script('pie_admin_about_us_menu_js',plugins_url("/assets/js/admin-about-us.js",__FILE__),'jquery',PIEREGISTER_VERSION,false);
960
961 $strings = ['nonce' => wp_create_nonce( 'pieregister_admin' )];
962
963 wp_localize_script(
964 'pie_admin_about_us_menu_js',
965 'pieregister_admin',
966 $strings
967 );
968
969 wp_register_script('pie_admin_about_us_slick_js',plugins_url("/assets/js/slick.min.js",__FILE__),'jquery',PIEREGISTER_VERSION,false);
970 wp_register_script('pie_notification_js',plugins_url("assets/js/pie_notifications.js", __FILE__), array('jquery'), PIEREGISTER_VERSION, true);
971 }
972 function getVauleOrEmpty($string=false){
973 return (isset($string) && !empty($string))?$string:'';
974 }
975 function print_multi_lang_script_vars(){
976 global $piereg_global_options;
977 $opt = $piereg_global_options;
978 $fields_id = get_option("piereg_form_fields_id");
979 $count = 0;
980 $fields_data = $fields_data_filtered = array();
981 $form_ids = array();
982
983
984 for($a=1;$a<=$fields_id;$a++){
985 $option = get_option("piereg_form_field_option_".$a);
986 if( !empty($option) && is_array($option) && isset($option['Id']) && trim($option['Status']) != "" && $option['Status'] == "enable" && (!isset($option['IsDeleted']) || trim($option['IsDeleted']) != 1) )
987 {
988 array_push($form_ids, 'reg_form_'.$option['Id']);
989 $fields_data = maybe_unserialize(get_option("piereg_form_fields_".$option['Id']));
990 $the_cap_field = "captcha";
991 $fields_data = is_array($fields_data) ? $fields_data : [$fields_data];
992 $fields_data_filtered = array_filter($fields_data, function($el) use ($the_cap_field) {
993 return ( isset($el['type']) && ($el['type'] == $the_cap_field) );
994 });
995 $reg_forms_theme['reg_form_'.$option['Id']] = $fields_data_filtered;
996 $count++;
997 }
998 }
999
1000 $is_widgetTheme = $not_widgetTheme = (isset($opt['piereg_recapthca_skin_login']) && !empty($opt['piereg_recapthca_skin_login']))?$opt['piereg_recapthca_skin_login']:"red";
1001 $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";
1002 $mathCaptchaOperator = rand(0,1);
1003 ////1 for add(+)
1004 ////0 for subtract(-)
1005 $mathCaptchaResult = 0;
1006 if($mathCaptchaOperator == 1){
1007 $mathCaptchaStart = rand(1,9);
1008 $mathCaptchaEnd = rand(5,20);
1009 $mathCaptchaResult = $mathCaptchaStart + $mathCaptchaEnd;
1010 $mathCaptchaOperator = "+";
1011 }
1012 else{
1013 $mathCaptchaStart = rand(50,30);
1014 $mathCaptchaEnd = rand(5,20);
1015 $mathCaptchaResult = $mathCaptchaStart - $mathCaptchaEnd;
1016 $mathCaptchaOperator = "-";
1017 }
1018
1019 $mathCaptchaResult1 = $mathCaptchaResult + 12;
1020 $mathCaptchaResult2 = $mathCaptchaResult + 786;
1021 $mathCaptchaResult3 = $mathCaptchaResult - 5;
1022 $mathCaptchaResult1 = base64_encode($mathCaptchaResult1);
1023 $mathCaptchaResult2 = base64_encode($mathCaptchaResult2);
1024 $mathCaptchaResult3 = base64_encode($mathCaptchaResult3);
1025 $matchCapImage_name = rand(0,10);
1026 $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)');
1027
1028 $matchCapHTML = $mathCaptchaStart." ".$mathCaptchaOperator." ".$mathCaptchaEnd . " = ";
1029 $pie_payment_methods_data = array();
1030
1031 if(!empty($this->pie_payment_methods_dat) && count($this->pie_payment_methods_dat) > 0){
1032 foreach($this->pie_payment_methods_dat as $data){
1033 $pie_payment_methods_data[$data['method']]['payment'] = $data['payment'];
1034 $pie_payment_methods_data[$data['method']]['image'] = $data['image'];
1035 }
1036 }
1037
1038 $isSocialLoginRedirectOnLogin = ( ( isset($opt['social_site_popup_setting']) && $opt['social_site_popup_setting'] == 1 ) && (isset($_POST['social_site']) && $_POST['social_site'] == "true"))?true:false;
1039 $this->pie_pr_dec_vars_array = array(
1040 'ajaxURL' => admin_url('admin-ajax.php'),
1041 'dateY' => date_i18n("Y"),//__( 'NiceString', 'pie-register' )
1042 'piereg_startingDate' => $opt['piereg_startingDate'],
1043 'piereg_endingDate' => $opt['piereg_endingDate'],
1044 'pass_strength_indicator_label' => $this->getVauleOrEmpty($opt['pass_strength_indicator_label']),
1045 'pass_very_weak_label' => $this->getVauleOrEmpty($opt['pass_very_weak_label']),
1046 'pass_weak_label' => $this->getVauleOrEmpty($opt['pass_weak_label']),
1047 'pass_medium_label' => $this->getVauleOrEmpty($opt['pass_medium_label']),
1048 'pass_strong_label' => $this->getVauleOrEmpty($opt['pass_strong_label']),
1049 'pass_mismatch_label' => $this->getVauleOrEmpty($opt['pass_mismatch_label']),
1050 'ValidationMsgText1' => esc_html__("none","pie-register"),
1051 'ValidationMsgText2' => esc_html__("* This field is required","pie-register"),
1052 'ValidationMsgText3' => esc_html__("* Please select an option","pie-register"),
1053 'ValidationMsgText4' => esc_html__("* This checkbox is required","pie-register"),
1054 'ValidationMsgText5' => esc_html__("* Both date range fields are required","pie-register"),
1055 'ValidationMsgText6' => esc_html__("* Field must equal test","pie-register"),
1056 'ValidationMsgText7' => esc_html__("* Invalid ","pie-register"),
1057 'ValidationMsgText8' => esc_html__("Date Range","pie-register"),
1058 'ValidationMsgText9' => esc_html__("Date Time Range","pie-register"),
1059 'ValidationMsgText10' => esc_html__("* Minimum ","pie-register"),
1060 'ValidationMsgText11' => esc_html__(" characters required","pie-register"),
1061 'ValidationMsgText12' => esc_html__("* Maximum ","pie-register"),
1062 'ValidationMsgText13' => esc_html__(" characters allowed","pie-register"),
1063 'ValidationMsgText14' => esc_html__("* You must fill-in one of the following fields","pie-register"),
1064 'ValidationMsgText15' => esc_html__("* Minimum value is ","pie-register"),
1065 'ValidationMsgText16' => esc_html__("* Date prior to ","pie-register"),
1066 'ValidationMsgText17' => esc_html__("* Date past ","pie-register"),
1067 'ValidationMsgText18' => esc_html__(" options allowed","pie-register"),
1068 'ValidationMsgText19' => esc_html__("* Please select ","pie-register"),
1069 'ValidationMsgText20' => esc_html__(" options","pie-register"),
1070 'ValidationMsgText21' => esc_html__("* Fields do not match","pie-register"),
1071 'ValidationMsgText22' => esc_html__("* Invalid credit card number","pie-register"),
1072 'ValidationMsgText23' => esc_html__("* Invalid phone number","pie-register"),
1073 'ValidationMsgText24' => esc_html__("* Invalid phone number. Allowed format: (xxx)xxx-xxxx","pie-register"),
1074 'ValidationMsgText25' => esc_html__("* Minimum 10 digits starting with area code without the '+' sign.","pie-register"),
1075 'ValidationMsgText26' => esc_html__("* Invalid email address","pie-register"),
1076 'ValidationMsgText27' => esc_html__("* Not a valid integer","pie-register"),
1077 'ValidationMsgText28' => esc_html__("* Invalid number","pie-register"),
1078 'ValidationMsgText29' => esc_html__("* Invalid month","pie-register"),
1079 'ValidationMsgText30' => esc_html__("* Invalid day","pie-register"),
1080 'ValidationMsgText31' => esc_html__("* Invalid year","pie-register"),
1081 'ValidationMsgText32' => esc_html__("* Invalid file extension","pie-register"),
1082 'ValidationMsgText33' => esc_html__("* Invalid date, must be in YYYY-MM-DD format","pie-register"),
1083 'ValidationMsgText34' => esc_html__("* Invalid IP address","pie-register"),
1084 'ValidationMsgText35' => esc_html__("* Invalid URL","pie-register"),
1085 'ValidationMsgText36' => esc_html__("* Numbers only","pie-register"),
1086 'ValidationMsgText37' => esc_html__("* Letters only","pie-register"),
1087 'ValidationMsgText38' => esc_html__("* No special characters allowed","pie-register"),
1088 'ValidationMsgText39' => esc_html__("* This username is not available","pie-register"),
1089 'ValidationMsgText40' => esc_html__("* Validating, please wait","pie-register"),
1090 'ValidationMsgText41' => esc_html__("* This username is available","pie-register"),
1091 'ValidationMsgText42' => esc_html__("* This username is not available","pie-register"),
1092 'ValidationMsgText43' => esc_html__("* Validating, please wait","pie-register"),
1093 'ValidationMsgText44' => esc_html__("* This name is not available","pie-register"),
1094 'ValidationMsgText45' => esc_html__("* This name is available","pie-register"),
1095 'ValidationMsgText46' => esc_html__("* Validating, please wait","pie-register"),
1096 'ValidationMsgText47' => esc_html__("* This name is not available","pie-register"),
1097 'ValidationMsgText48' => esc_html__("* Please enter HELLO","pie-register"),
1098 'ValidationMsgText49' => esc_html__("* Invalid Date","pie-register"),
1099 'ValidationMsgText50' => esc_html__("* Invalid Date or Date Format","pie-register"),
1100 'ValidationMsgText51' => esc_html__("Expected Format: ","pie-register"),
1101 'ValidationMsgText52' => esc_html__("mm/dd/yyyy hh:mm:ss AM|PM or ","pie-register"),
1102 'ValidationMsgText53' => esc_html__("yyyy-mm-dd hh:mm:ss AM|PM","pie-register"),
1103 'ValidationMsgText54' => esc_html__("* Invalid Username","pie-register"),
1104 'ValidationMsgText55' => esc_html__("* Invalid File Type","pie-register"),
1105 'ValidationMsgText56' => esc_html__("* Maximum value is ","pie-register"),
1106 'ValidationMsgText57' => esc_html__("* Letters only","pie-register"),
1107 'ValidationMsgText58' => esc_html__("* Only Alphanumeric characters are allowed","pie-register"),
1108 'ValidationMsgText61' => esc_html__("* Invalid file size","pie-register"),
1109 'ValidationMsgText59' => esc_html__("Delete","pie-register"),
1110 'ValidationMsgText60' => esc_html__("Edit","pie-register"),
1111 'piereg_recaptcha_type' => isset($opt['piereg_recaptcha_type']) ? $opt['piereg_recaptcha_type'] : 'v2',
1112 'reCaptcha_public_key' => isset($opt['captcha_publc']) ? $opt['captcha_publc'] : '',
1113 'reCaptchaV3_public_key' => isset($opt['captcha_publc_v3']) ? $opt['captcha_publc_v3'] : '',
1114 'reCaptcha_language' => isset($opt['piereg_recaptcha_language']) ? $opt['piereg_recaptcha_language'] : "en",
1115 'prRegFormsIds' => $form_ids,
1116 'not_widgetTheme' => $not_widgetTheme,
1117 'is_widgetTheme' => $is_widgetTheme,
1118 'not_forgot_widgetTheme' => $not_forgot_widgetTheme,
1119 'is_forgot_widgetTheme' => $fields_data_filtered,
1120 'reg_forms_theme' => $fields_data,
1121 'matchCapResult1' => $mathCaptchaResult1,
1122 'matchCapResult2' => $mathCaptchaResult2,
1123 'matchCapResult3' => $mathCaptchaResult3,
1124 'matchCapColors' => $matchCapColor,
1125 //'prMathCaptchaID' => $fff,
1126 'matchCapImgColor' => $matchCapColor[$matchCapImage_name],
1127 'matchCapImgURL' => plugins_url('/assets/images/math_captcha/'.$matchCapImage_name.'.png',__FILE__),
1128 'matchCapHTML' => $matchCapHTML,
1129 'is_socialLoginRedirect' => $this->pie_is_social_renew_account_call,
1130 'socialLoginRedirectRenewAccount' => $this->pie_ua_renew_account_url,
1131 'isSocialLoginRedirectOnLogin' => $isSocialLoginRedirectOnLogin,
1132 'socialLoginRedirectOnLoginURL' => $this->pie_after_login_page_redirect_url,
1133 'pie_payment_methods_data' => $pie_payment_methods_data,
1134 'prTimedFieldVal' => date("y-m-d H:i:s"),
1135 'process_submission' => esc_html__("Processing...","pie-register")
1136 );
1137 wp_localize_script( 'pie_prVariablesDeclaration_script', 'pie_pr_dec_vars', $this->pie_pr_dec_vars_array );
1138
1139 wp_enqueue_script('jquery-ui-progressbar');
1140 wp_enqueue_script( 'pie_prVariablesDeclaration_script' );
1141 wp_enqueue_script( 'pie_prVariablesDeclaration_script_Footer' );
1142
1143 }
1144 //Function print_multi_lang_backend_script_vars()
1145 //Declares Variables that we need on WP Backend
1146 //Uses wp_localize to translate the variables
1147 function print_multi_lang_backend_script_vars(){
1148 global $piereg_global_options,$wp_roles,$hook_suffix;
1149 $payment_gateways_html = "";
1150 $payment_gateways_list = $this->payment_gateways_list();
1151 if(isset($payment_gateways_list) && is_array($payment_gateways_list) && !empty($payment_gateways_list)){
1152 foreach($payment_gateways_list as $pgKey=>$pgval){
1153 $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>';
1154 }
1155 }
1156 $roles = $wp_roles->roles;
1157 $user_role_option = "";
1158 $user_role_object = "";
1159 $user_role_array = array();
1160 if(isset($roles) && is_array($roles) && !empty($roles)){
1161 foreach($roles as $key=>$value){
1162 $user_role_array[$key] = $value['name'];
1163 }
1164 }
1165 $user_role_object = json_encode($user_role_array);
1166 $defaultMeta = $this->getDefaultMeta();
1167 $fields_data = $this->getCurrentFields();
1168 if(!is_array($fields_data) || sizeof($fields_data) == 0) {
1169 $fields_data = get_option( 'pie_fields_default' );
1170 }
1171 $fillvalKey = array();
1172 $fillvalValue = array();
1173 $fillvalNum = 0;
1174 $options = get_option(OPTION_PIE_REGISTER);
1175
1176 foreach($fields_data as $k=>$field){
1177
1178 if( ($field['type'] == "honeypot") || $field['type']=="submit" || $field['type']=="" || $field['type']=="form" || ($field['type']=="invitation" && $options["enable_invitation_codes"]=="0" || $field['type'] == "hcaptcha") ){
1179 continue;
1180 }
1181 if($field['type'] == "url" || $field['type'] == "aim" || $field['type'] == "yim" || $field['type'] == "jabber" || $field['type'] == "description"){
1182 $field['type'] = "default";
1183 }
1184
1185 if( $field['type'] == "html" )
1186 {
1187 $field['html'] = html_entity_decode($field['html']);
1188 }
1189
1190 if(isset($field['desc']) && !empty($field['desc']))
1191 {
1192 $field['desc'] = html_entity_decode($field['desc']);
1193 }
1194
1195 $fillvalNum++;
1196 array_push($fillvalKey,$field['id']);
1197 array_push($fillvalValue,serialize($field));
1198 }
1199 $this->pie_pr_backend_dec_vars_array = array(
1200 'ajaxURL' => admin_url('admin-ajax.php'),
1201 'hook_suffix' => $hook_suffix,
1202 'wp_content_url' => content_url(),
1203 'wp_home_url' => home_url(),
1204 'wp_site_url' => site_url(),
1205 'wp_admin_url' => admin_url(),
1206 'wp_includes_url' => includes_url(),
1207 'wp_plugins_url' => plugins_url(),
1208 'wp_pie_register_url' => PIEREG_PLUGIN_URL,
1209 'payment_gateways_list' => $payment_gateways_html,
1210 'user_default_role' => get_option("default_role"),
1211 'current_date' => date_i18n("Y"),
1212 'startingDate' => $piereg_global_options['piereg_startingDate'],
1213 'endingDate' => $piereg_global_options['piereg_endingDate'],
1214 'user_roles_array' => $user_role_array,
1215 'user_roles_object' => $user_role_object,
1216 'plsSelectForm' => esc_html__("Please select a form","pie-register"),
1217 'isPRFormEditor' => (isset($_GET['page']) && in_array($_GET['page'],array('pie-register','pr_new_registration_form')))?true:false,
1218 'inValidFields' => esc_html__('Invalid Fields','pie-register'),
1219 'display_hints' => $piereg_global_options['display_hints'],
1220 'defaultMeta' => $defaultMeta,
1221 '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;">',
1222 '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>',
1223 'fillvalKey' => $fillvalKey,
1224 'fillvalValue' => $fillvalValue,
1225 'fillvalNo' => (max(array_filter(array_keys($fields_data), 'is_numeric'))+1),
1226 'fillvalNum' => $fillvalNum,
1227 'block_wp_login' => $piereg_global_options['block_wp_login'],
1228 'selectLogoText' => 'Upload/Select Logo',
1229 'mediaUploadURL' => admin_url('media-upload.php')
1230
1231 );
1232 wp_localize_script( 'pie_prBackendVariablesDeclaration_script', 'pie_pr_backend_dec_vars', $this->pie_pr_backend_dec_vars_array );
1233 wp_enqueue_script( 'pie_prBackendVariablesDeclaration_script' );
1234 wp_enqueue_script( 'pie_prBackendVariablesDeclaration_script_Footer' );
1235
1236 $strings = ['nonce' => wp_create_nonce( 'pieregister_front_admin' )];
1237
1238 wp_localize_script(
1239 'pie_prBackendVariablesDeclaration_script_Footer',
1240 'pieregister_front_admin',
1241 $strings
1242 );
1243 }
1244 // function pie_admin_enqueu_scripts
1245 //Will be replace with print_multi_lang_backend_script_vars();
1246 function pie_admin_enqueu_scripts(){
1247 $this->print_multi_lang_backend_script_vars();
1248 }
1249 function print_multi_captcha_skin() {
1250
1251 $settings = get_option(OPTION_PIE_REGISTER);
1252 $publickey = $settings['captcha_publc'];
1253
1254 $fields_id = get_option("piereg_form_fields_id");
1255 $count = 0;
1256 $form_ids = array();
1257 for($a=1;$a<=$fields_id;$a++)
1258 {
1259 $option = get_option("piereg_form_field_option_".$a);
1260 if( !empty($option) && is_array($option) && isset($option['Id']) && trim($option['Status']) != "" && $option['Status'] == "enable" && (!isset($option['IsDeleted']) || trim($option['IsDeleted']) != 1) )
1261 {
1262 array_push($form_ids, 'reg_form_'.$option['Id']);
1263 $count++;
1264 }
1265 }
1266
1267 $captcha_login_script = false;
1268 $captcha_forgot_script = true;
1269 $captcha_reg_script = false;
1270 if($settings['captcha_in_login_value'] == 1 && $settings['capthca_in_login'] == 3 ){
1271 $captcha_login_script = true;
1272 }
1273 if($settings['captcha_in_forgot_value'] == 1 && $settings['capthca_in_forgot_pass'] == 3 ){
1274 $captcha_forgot_script = true;
1275 }
1276 if($count > 0){
1277 $captcha_reg_script = true;
1278 }
1279
1280 if($captcha_login_script || $captcha_reg_script || $captcha_forgot_script){}
1281 }
1282
1283 function add_admin_body_class( $classes ) {
1284 $classes .= ' pieregister-page';
1285 return $classes;
1286 }
1287
1288 function pie_backend_enqueue_scripts($hook_s){
1289 global $piereg_global_options;
1290 $pr_backend_hook_suffixes = array('pie-register','pr_new_registration_form','pie-notifications','pie-invitation-codes','pie-bulk-emails','pie-gateway-settings','pie-black-listed-users','pie-settings','pie-import-export','unverified-users','pie-help','post.php','edit.php','post-new.php');
1291 $pr_backend_hook_suffixes = apply_filters('pr_backend_hook_suffixes',$pr_backend_hook_suffixes);
1292 $is_pr_page = array_filter($pr_backend_hook_suffixes, function($el) use ($hook_s) {
1293 return ( stripos($hook_s,$el) !== false );
1294 });
1295 if(empty($is_pr_page)){
1296 return false;
1297 }
1298
1299 add_filter( 'admin_body_class', array($this,'add_admin_body_class'));
1300 if(in_array('pie-settings', $is_pr_page))
1301 {
1302 wp_enqueue_script('prBackendCustomLogo_script');
1303 }
1304
1305 ///////////// So We are on PR pages /////////////////
1306 //Enqueue Styles
1307 wp_enqueue_style('pie_admin_css');
1308 //wp_enqueue_style('pie_jqueryui_css');
1309 wp_enqueue_style('pie_mCustomScrollbar_css');
1310 wp_enqueue_style('pie_style_css');
1311 #wp_enqueue_style('pie_tooltip_css');
1312 wp_enqueue_style('pie_ui_css');
1313 wp_enqueue_style('pie_validation_css');
1314
1315 //Now We Enqueue Variables
1316 $this->print_multi_lang_script_vars();
1317 $this->pie_admin_enqueu_scripts();
1318
1319 wp_enqueue_script('jquery-ui-core');
1320 wp_enqueue_script('pie_datepicker_js');
1321 wp_enqueue_script('pie_drag_js');
1322 wp_enqueue_script('pie_mCustomScrollbar_js');
1323 wp_enqueue_script('pie_mousewheel_js');
1324 wp_enqueue_script('pie_phpjs_js');
1325 wp_enqueue_script('pie_registermain_js');
1326 // wp_enqueue_script('pie_admin_about_us_menu_js');
1327
1328 if(in_array('pie-settings', $is_pr_page)) {
1329 wp_enqueue_script('prBackendCustomLogo_script');
1330 }
1331
1332 //JQuery UI Effects
1333 wp_enqueue_script('jquery-ui-droppable');
1334 wp_enqueue_script('jquery-ui-tooltip');
1335 wp_enqueue_script('jquery-ui-tabs');
1336 wp_enqueue_script('jquery-ui-sortable');
1337 wp_enqueue_script('jquery-ui-datepicker');
1338 wp_enqueue_script('jquery-ui-draggable');
1339 /* wp_enqueue_script('jquery-ui-dialog'); */
1340
1341 wp_enqueue_style('pie_jquery_ui'); // jquery-ui-theme-smoothness
1342
1343 wp_enqueue_script('pie_alphanum_js');
1344 wp_enqueue_script('pie_validation_js');
1345 wp_enqueue_script("pie_ckeditor");
1346 wp_enqueue_style('pie_font_awesome');
1347 }
1348
1349 function piereg_frontend_assets_header(){
1350 if(is_front_page()){
1351 wp_enqueue_script('pie_dialog_js',plugins_url("/assets/js/dialog.js",__FILE__),array('jquery'),PIEREGISTER_VERSION,false);
1352 wp_enqueue_style('pie_dialog_css',plugins_url("/assets/css/dialog.css",__FILE__),false,PIEREGISTER_VERSION,"all");
1353 // wp_enqueue_script('jquery-ui-dialog');
1354 $this->pieregister_jquery_dialog_script();
1355 }
1356
1357 if ( ! is_singular() ) {
1358 return;
1359 }
1360
1361 global $post;
1362
1363 if (
1364 ( 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' ) )
1365 ) {
1366 $this->pie_frontend_enqueu_scripts();
1367 }
1368 }
1369
1370 function piereg_frontend_assets_footer(){
1371 if ( empty( $this->piereg_forms_per_page ) ) {
1372 return;
1373 }
1374
1375 $this->pie_frontend_enqueu_scripts();
1376 }
1377
1378 function pie_frontend_enqueu_scripts(){
1379 global $piereg_global_options;
1380 $this->print_multi_lang_script_vars();
1381
1382 if(isset($piereg_global_options['outputcss']) && $piereg_global_options['outputcss'] == 1){
1383 wp_enqueue_style( 'pie_front_css' );
1384 wp_enqueue_style( 'pie_validation_css' );
1385 }
1386
1387 // LOAD RECAPTCHA SCRIPT IS ENABLED OR ADDED IN REGISTRATION FORM(S) - START
1388 $captcha_login_script = false;
1389 $captcha_forgot_script = false;
1390 $captcha_reg_script = false;
1391
1392 // Check if Captcha is to be added in the login form
1393 if($piereg_global_options['captcha_in_login_value'] == 1 && $piereg_global_options['capthca_in_login'] == 3 ){
1394
1395 $captcha_login_script = true;
1396 }
1397 // Check if Captcha is to be added in the reset password form
1398 if($piereg_global_options['captcha_in_forgot_value'] == 1 && $piereg_global_options['capthca_in_forgot_pass'] == 3 ){
1399 $captcha_forgot_script = true;
1400 }
1401
1402 $PR_forrms_fields_id = get_option("piereg_form_fields_id");
1403 for($a=1;$a<=$PR_forrms_fields_id;$a++)
1404 {
1405 $_form_fields = unserialize(get_option('piereg_form_fields_'.$a));
1406 $_form_option = get_option("piereg_form_field_option_".$a);
1407
1408 if( !is_array($_form_fields) ) continue;
1409
1410 if( !isset($_form_option['IsDeleted']) || trim($_form_option['IsDeleted']) != 1 )
1411 {
1412 foreach($_form_fields as $key=>$field)
1413 {
1414 if($field['type'] == 'captcha')
1415 {
1416 $captcha_reg_script = true;
1417 break;
1418 }
1419 }
1420 }
1421 if($captcha_reg_script) break;
1422 }
1423
1424 if($captcha_login_script || $captcha_reg_script || $captcha_forgot_script){
1425 if($piereg_global_options['piereg_recaptcha_type'] == 'v2'){
1426 wp_enqueue_script("pie_recpatcha_script" );
1427 }elseif($piereg_global_options['piereg_recaptcha_type'] == 'v3'){
1428 $recaptcha_sitekey = isset($piereg_global_options['captcha_publc_v3']) ? $piereg_global_options['captcha_publc_v3'] : "";
1429 $recaptcha_language = isset($piereg_global_options['piereg_recaptcha_language']) ? $piereg_global_options['piereg_recaptcha_language'] : "";
1430 wp_enqueue_script('pie_recpatchav3_script','//www.google.com/recaptcha/api.js?render='.$recaptcha_sitekey.'&hl='.$recaptcha_language,'','',true);
1431 }
1432 }
1433 // LOAD RECAPTCHA SCRIPT IS ENABLED OR ADDED IN REGISTRATION FORM(S) - END
1434
1435 wp_enqueue_script("pie_datepicker_js" );
1436 wp_enqueue_script("pie_alphanum_js");
1437 wp_enqueue_script("pie_validation_js");
1438 wp_enqueue_script('password-strength-meter',false,array('jquery','zxcvbn-async'),'',true);
1439 wp_enqueue_script('pie_password_checker',false,array('password-strength-meter'),'',true);
1440
1441 wp_enqueue_script('jquery-ui-core');
1442 wp_enqueue_script('jquery-ui-datepicker');
1443 }
1444
1445 function check_if_role_admin()
1446 {
1447 $is_admin = false;
1448
1449 $current_user = wp_get_current_user();
1450 if (user_can( $current_user, 'administrator' )) {
1451 $is_admin = true;
1452 }
1453
1454 return $is_admin;
1455 }
1456
1457 function piereg_registration_form($attributes="") {
1458 $this->piereg_ssl_template_redirect();
1459
1460 $id = !empty($form_attr) && isset($form_attr['id']) ? $form_attr['id'] : 0;
1461 $title = !empty($form_attr) && isset($form_attr['title']) ? $form_attr['title'] : "true" ;
1462 $description = !empty($form_attr) && isset($form_attr['description']) ? $form_attr['description'] : "true" ;
1463 $is_preview = false;
1464
1465 //// **** ONLY ADMINISTRATOR CAN VIEW FORM PREVIEW ELSE IT WILL SHOW PAGE CONTENT **** ////
1466 $show_preview_form = $this->check_if_role_admin();
1467 $elementor_preview = isset($_GET['action']) && $_GET['action'] == 'elementor' ? true : false;
1468 // For Form with Gutenberg Preview
1469 $gutenberg_preview = isset($_GET['context']) && $_GET['context'] == 'edit' ? true : false;
1470 // For WPBakery Frontend Preview
1471 $WPBakery_preview = isset($_GET['vc_editable']) && $_GET['vc_editable'] == 'true' ? true : false;
1472
1473 if( (isset($_GET['pr_preview']) || $elementor_preview ) && $show_preview_form ){
1474 $is_preview = true;
1475 $prFormId = isset($_GET['prFormId']) ? intval(trim($_GET['prFormId'])) : '';
1476 $preview_form_id = 0;
1477
1478 if(isset($_GET['prFormId']) && $prFormId > 0){
1479 $preview_form_id = $prFormId;
1480 }
1481
1482 }
1483
1484 $use_free_form = false;
1485 if( !is_array($attributes) ){
1486 $use_free_form = true;
1487 }
1488
1489 if(is_array($attributes) || $is_preview || $use_free_form ){
1490
1491 if( $use_free_form && !$is_preview )
1492 {
1493 $id = $this->regFormForFreeVers();
1494 }
1495 else {
1496
1497 if(is_array($attributes)) extract($attributes);
1498
1499 if( $id != $this->regFormForFreeVers() ) {
1500 $id = false;
1501 }
1502
1503 }
1504
1505 if($is_preview && $preview_form_id > 0){
1506 $id = $preview_form_id;
1507 }
1508
1509 if( intval($id) != 0 )
1510 {
1511 $check_form_in_db = get_option("piereg_form_fields_".((int)$id));
1512 if($check_form_in_db == false || trim($check_form_in_db) == "")
1513 {
1514 $id = false;
1515 }else{
1516 $check_form_in_db = get_option("piereg_form_field_option_".((int)$id));
1517 if( ($check_form_in_db['Status'] == "enable" && (!isset($check_form_in_db['IsDeleted']) || trim($check_form_in_db['IsDeleted']) != 1) ) || $is_preview){
1518 if (is_user_logged_in() && !is_admin() && !$is_preview && !$this->is_pr_preview && !$gutenberg_preview && !$WPBakery_preview ) {
1519 $global_options = $this->get_pr_global_options();
1520
1521 return apply_filters("pie_reg_form_logged_in_msg",sprintf(__("<p>Already logged in, Click <a href='%s'>here</a> to edit profile.<p>","pie-register"),esc_url($this->get_page_uri($global_options["alternate_profilepage"],"edit_user=1")) ) );
1522 }
1523 if(!$is_preview){
1524 $check_form_in_db['Views'] = ( intval($check_form_in_db['Views'])+1 );
1525 update_option("piereg_form_field_option_".((int)$id),$check_form_in_db);
1526 $this->set_pr_stats("register","view");
1527 }
1528 return $this->showForm($id,$title,$description);
1529 }else{
1530 return esc_html__("This form is disabled by the administrator.","pie-register");
1531 }
1532 }
1533 }else{
1534 $id = false;
1535 }
1536
1537 if($id == false){
1538 $this->pr_error_log("Incorrect shortcode used.".($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
1539 return esc_html__("Incorrect shortcode used.","pie-register");
1540 }
1541 }
1542 else{
1543 $this->pr_error_log("Incorrect shortcode used.".($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
1544 return esc_html__("Incorrect shortcode used.","pie-register");
1545 }
1546
1547 }
1548
1549 // ver - 3.6.3
1550 function piereg_user_profile_pic(){
1551 $this->piereg_ssl_template_redirect();
1552
1553 global $wpdb;
1554 $user_id = get_current_user_id();
1555 $data = '';
1556
1557 if($user_id){
1558 $sql_query = "SELECT * FROM {$wpdb->prefix}usermeta WHERE `meta_key` LIKE '%pie_profile_pic_%' AND `user_id`={$user_id}";
1559
1560 $result = $wpdb->get_results($sql_query);
1561
1562 if(isset($result[0]) && $result[0]->meta_value){
1563 $imgPath = $result[0]->meta_value;
1564 }else{
1565 $imgPath = get_avatar_url($user_id);
1566 }
1567
1568 $data .= '<div class="show-profile-img">';
1569 $data .= '<div class="file-wrapper"><img src="'.esc_url($imgPath).'" alt="'.esc_attr__('User Profile Picture',"pie-register").'" />';
1570 $data .= '</div>';
1571 $data .= '</div>';
1572
1573 return $data;
1574 }else{
1575 return esc_html__("Incorrect shortcode used.","pie-register");
1576 $this->pr_error_log("Incorrect shortcode used.".($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
1577 }
1578 }
1579
1580 function modify_all_notices($notice)
1581 {
1582 $Start_notice = "";/*Write your message*/
1583 $End_notice = "";/*Write your message*/
1584 return $Start_notice.$notice.$End_notice;
1585 }
1586
1587 function print_Rpr_licenseKey_errors()
1588 {
1589 if(isset($_POST['PR_license_notice']))
1590 return $_POST['PR_license_notice'];
1591 }
1592 function initPieWidget()
1593 {
1594 register_widget( 'Pie_Register_Widget' );
1595 register_widget( 'Pie_Login_Widget' );
1596 register_widget( 'Pie_Forgot_Widget' );
1597 }
1598
1599 //Plugin Menu Link
1600 function add_action_links( $links, $file )
1601 {
1602 if ( $file != plugin_basename( __FILE__ ))
1603 return $links;
1604
1605 $links[] = '<a style="color:#13ad11;" target="_blank" href="https://pieregister.com/plan-and-pricing/">'.esc_html__("Go Premium","pie-register").'</a>';
1606 $links[] = '<a href="'. esc_url(get_admin_url(null, 'admin.php?page=pie-settings')) .'">'.(esc_html__("Settings","pie-register")).'</a>';
1607 return $links;
1608 }
1609
1610 function piereg_after_setup_theme(){
1611 if(isset($_POST['log']) && isset($_POST['pwd'])){
1612 $this->checkLogin();
1613 }
1614 }
1615
1616 /*
1617 * Restrict Post / Page Content
1618 */
1619 function piereg_template_restrict($post_object){
1620 /*
1621 * Get Options
1622 */
1623
1624 $option = get_post_meta($post_object->ID,"_piereg_post_restriction");
1625 /*
1626 * Get Global Options
1627 */
1628 $global_options = $this->get_pr_global_options();
1629
1630 $this->post_block_content = "";
1631 $piereg_post_visibility_var = ((isset($option[0]["piereg_post_visibility"]) && $option[0]["piereg_post_visibility"] != "")?$option[0]["piereg_post_visibility"]:"");
1632 if ( is_array($piereg_post_visibility_var) )
1633 {
1634 foreach ($piereg_post_visibility_var as $key => $val)
1635 {
1636 $visible = $this->get_post_visibility($val);
1637
1638 if (!$visible)
1639 {
1640 break;
1641 }
1642 }
1643 }
1644 else
1645 {
1646 $visible = $this->get_post_visibility($piereg_post_visibility_var);
1647 }
1648 /* Restrict for Users */
1649 if(!isset($option[0]["piereg_post_visibility"])){
1650 return $post_object;
1651 }
1652 //if Visibility status is default then return
1653 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")
1654 {
1655 return $post_object;
1656 }
1657 if( isset($option[0]) && $visible ){
1658
1659 ////0 = Redirect
1660 ////1 = Block Content
1661
1662 $page_object = get_queried_object();
1663 $page_id = get_queried_object_id();
1664
1665 if(($page_id == $post_object->ID) && isset($option[0]['piereg_restriction_type']) && $option[0]['piereg_restriction_type'] == 0)
1666 {
1667 //1st Redirect URL and 2nd Redirect Page
1668 // Current Page URL
1669 $pv_sslport = 443;
1670 $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://");
1671
1672 $redirect_to = "redirect_to=".$pv_URIprotocol.esc_url_raw($_SERVER["HTTP_HOST"]) . esc_url_raw($_SERVER["REQUEST_URI"]) ;
1673
1674 if($option[0]['piereg_redirect_url'] != ""){
1675 // Redirtect URL
1676 $redirect_url = $option[0]['piereg_redirect_url'];
1677 //Redirect
1678 $redirect_url = isset($redirect_to) && !empty($redirect_to) ? $this->pie_modify_custom_url($redirect_url , $redirect_to) : $redirect_url;
1679 wp_redirect(esc_url_raw($redirect_url));
1680 exit;
1681 }else{
1682 //Redirect Url
1683 $redirect_url = get_permalink($option[0]['piereg_redirect_page']);
1684 //Redirect
1685 $redirect_url = isset($redirect_to) && !empty($redirect_to) ? $this->pie_modify_custom_url($redirect_url , $redirect_to) : $redirect_url;
1686 if($redirect_url)
1687 {
1688 wp_safe_redirect($redirect_url);
1689 exit;
1690 }
1691 }
1692 }
1693
1694 if( $option[0]['piereg_block_content'] != "" )
1695 {
1696 $this->post_block_content = "<p>".esc_html($option[0]['piereg_block_content'])."</p>";
1697 add_filter("the_content",array($this,"restrict_content_post"));
1698 return $post_object;
1699 }
1700 }
1701 return $post_object;
1702 }
1703 /*
1704 * Checkl Visibility
1705 */
1706 function get_post_visibility($logic){
1707 $visible = false;
1708 if($logic == "default"){
1709 $visible = true;
1710 }
1711 elseif($logic == "after_login"){
1712 $visible = !is_user_logged_in();
1713 }
1714 elseif($logic == "before_login"){
1715 $visible = is_user_logged_in();
1716
1717 if( $this->check_if_role_admin() == true ){
1718 $visible = false;
1719 }
1720 }
1721 elseif($logic != "" ){
1722 global $current_user;
1723 $current_user = wp_get_current_user();
1724 $current_user_role = (array)$current_user->roles;
1725 $visible = !in_array( $logic, $current_user_role );
1726 if($visible && $this->check_if_role_admin() == true)
1727 {
1728 $visible = false;
1729 }
1730 }
1731 return $visible;
1732 }
1733 /*
1734 * Restrict Post/Page Content
1735 */
1736 function restrict_content_post($content){
1737 if($this->post_block_content != "")
1738 $content = nl2br($this->post_block_content);
1739
1740 return $content;
1741 }
1742 /*
1743 * Add Meta Box in post / page
1744 * Since version 3.1.3
1745 * - Custom post types included
1746 */
1747 function piereg_add_meta_box($postType) {
1748 $args = array(
1749 'public' => true,
1750 //'_builtin' => true
1751 );
1752
1753 $output = 'names'; // names or objects, note names is the default
1754 $operator = 'and'; // 'and' or 'or'
1755
1756 $screens = get_post_types( $args, $output, $operator );
1757 unset($screens['attachment']);
1758 //$screens = array( 'post', 'page' );
1759 $user_check = true;
1760 $user_check = apply_filters('piereg_before_visibility_restrictions_metabox', $user_check);
1761 if($user_check){
1762 foreach ( $screens as $screen ) {
1763 add_meta_box(
1764 'pieregister_restriction_meta',
1765 esc_html__( 'Pie Register - '.ucwords($screen).' Restriction', 'pie-register' ),
1766 array($this,'myplugin_meta_box_callback'),
1767 $screen
1768 );
1769 }
1770 }
1771 }
1772
1773 public function pie_leave_a_review_request()
1774 {
1775 $show_review_notice = get_option( 'pie_review_request_delete' );
1776 if ( empty( $show_review_notice ) ) {
1777
1778 $install_date = get_option('pie_install_date', '');
1779 if (empty($install_date)) return;
1780 $diff = round((time() - strtotime($install_date)) / 24 / 60 / 60);
1781 if ($diff < 4) return;
1782
1783 $review_url = 'https://wordpress.org/support/plugin/pie-register/reviews/';
1784 ?>
1785 <div class="notice notice-info pie-admin-notice-3 is-dismissible" data-leavereview= "<?php echo esc_attr(wp_create_nonce('pie_leave_review_nonce')); ?>">
1786 <p><?php echo sprintf(
1787 __( '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'),
1788 '<a href="' . esc_url($review_url) . '" target="_blank">',
1789 '</a>'
1790 ); ?></p>
1791 <p>
1792 <a href="<?php echo esc_url($review_url); ?>" target="_blank" id="pie_review_in_start" class="button button-primary">
1793 <?php esc_html_e( 'Sure', 'pie-register' ) ?>
1794 </a> &nbsp;
1795 <a href="javascript:void(0);" class="button-secondary pie_review_in_link">
1796 <?php esc_html_e( 'Maybe Later', 'pie-register' ) ?>
1797 </a>
1798 </p>
1799 </div>
1800 <script type="text/javascript">
1801 jQuery(document).on('click', '#pie_review_in_start', function (e) {
1802 jQuery(this).parents('.pie-admin-notice-3').find( '.notice-dismiss' ).trigger('click');
1803 });
1804
1805 jQuery(document).on('click', '.pie_review_in_link', function (e) {
1806 jQuery(this).parents('.pie-admin-notice-3').find( '.notice-dismiss' ).trigger('click');
1807 });
1808
1809 jQuery( '.pie-admin-notice-3' ).on( 'click', '.notice-dismiss', function() {
1810 nonce__ = jQuery(this).parent().data('leavereview');
1811
1812 var data = {
1813 action: 'dismiss_pie_leave_a_review_request',
1814 nonce: nonce__
1815 };
1816 jQuery.post( ajaxurl, data );
1817 });
1818 </script>
1819 <?php
1820 }
1821 }
1822
1823 public function dismiss_pie_leave_a_review_request()
1824 {
1825 // Run a security check.
1826 if ( ! check_ajax_referer( 'pie_leave_review_nonce', 'nonce', false ) || !current_user_can('manage_options') ) {
1827 wp_send_json_error( esc_html__( 'Something went wrong.', 'pie-register' ) );
1828 }
1829
1830 update_option( 'pie_review_request_delete', true );
1831 }
1832
1833 public function pie_license_expire_msg()
1834 {
1835 $show_review_notice = get_option( 'pie_license_expire_msg' );
1836 $status_addon = $this->get_addons_status();
1837 $renew_url = 'https://store.genetech.co/renew-order/';
1838 if($status_addon && empty( $show_review_notice )) {
1839 ?>
1840 <div class="notice notice-info pie-notice-license-expire is-dismissible" data-expire= "<?php echo esc_attr(wp_create_nonce('pie_expire_msg')); ?>">
1841 <p><?php echo sprintf(
1842 __( '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'),
1843 '<a href="' . esc_url($renew_url) . '" target="_blank">',
1844 '<a href="'.esc_url(get_admin_url()."admin.php?page=pie-help&tab=license").'" >',
1845 '</a>'
1846 ); ?></p>
1847 </div>
1848 <script type="text/javascript">
1849 jQuery( '.pie-notice-license-expire' ).on( 'click', '.notice-dismiss', function() {
1850 nonce__ = jQuery(this).parent().data('expire');
1851
1852 var data = {
1853 action: 'dismiss_pie_license_expire_msg',
1854 nonce: nonce__
1855 };
1856 jQuery.post( ajaxurl, data );
1857 });
1858 </script>
1859 <?php
1860 }
1861 }
1862
1863 public function dismiss_pie_license_expire_msg()
1864 {
1865 // Run a security check.
1866 if ( ! check_ajax_referer( 'pie_expire_msg', 'nonce', false ) || !current_user_can('manage_options') ) {
1867 wp_send_json_error( esc_html__( 'Something went wrong.', 'pie-register' ) );
1868 }
1869
1870 update_option( 'pie_license_expire_msg', true );
1871 }
1872
1873 public function pie_enable_registration_msg()
1874 {
1875 $general_settings_page = get_admin_url(null, 'options-general.php');
1876
1877 if ( !$this->is_anyone_can_register() )
1878 {
1879 ?>
1880 <div class="notice notice-info">
1881 <div>
1882 <p>
1883 <?php esc_html_e( 'User registration currently disabled. To enable, Go to ','pie-register'); ?>
1884 <a href="<?php echo esc_url($general_settings_page); ?>" >
1885 <?php esc_html_e( "Settings -> General", 'pie-register' ) ?>
1886 </a>
1887 <?php esc_html_e( 'and under Membership, check "Anyone can register".','pie-register'); ?>
1888 </p>
1889 </div>
1890 </div>
1891 <?php
1892 }
1893 }
1894
1895 /*
1896 Since version 3.6
1897 @TODO remove this notice in the future.
1898 */
1899 public function pie_promo_notice_security()
1900 {
1901 $show_release_notice = get_option( 'pie_promo_security_notice' );
1902
1903 if ( empty( $show_release_notice ) ) {
1904
1905 ?>
1906 <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'))) ?>">
1907 <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>
1908 <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>
1909 <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>
1910 </div>
1911 <script type="text/javascript">
1912
1913 jQuery( '.pie_security_msg' ).on( 'click', '.notice-dismiss', function() {
1914 nonce__ = jQuery(this).parent().data('securitynonce');
1915 var data = {
1916 action: 'dismiss_pie_promo_notice_security',
1917 nonce: nonce__
1918 };
1919 jQuery.post( ajaxurl, data );
1920 });
1921 </script>
1922 <?php
1923 }
1924 }
1925 public function dismiss_pie_promo_notice_security()
1926 {
1927 // Run a security check.
1928 if ( ! check_ajax_referer( 'pie_notice_security_nonce', 'nonce', false ) || !current_user_can('manage_options') ) {
1929 wp_send_json_error( esc_html__( 'Something went wrong.', 'pie-register' ) );
1930 }
1931
1932 update_option( 'pie_promo_security_notice', 'yes' );
1933 }
1934
1935 /*
1936 Since version 3.5.4
1937 @TODO remove this notice in the future.
1938 */
1939 public function pie_premium_features_notice_for_free()
1940 {
1941 ?>
1942 <div class="notice notice-info pie-admin-notice pre-feat">
1943
1944 <p style="font-weight:700;font-size:16px;"><?php echo ( esc_html( 'Creating Your First Registration Form','pireg')); ?></p>
1945
1946 <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>
1947
1948 <p>
1949 <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>
1950 <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>
1951 <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>
1952 <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>
1953 </p>
1954 </div>
1955 <?php
1956 }
1957
1958 public function pie_promo_notice_for_wc_user()
1959 {
1960 $show_release_notice = get_option( 'pie_promo_notice_for_wc_user' );
1961
1962 if ( empty( $show_release_notice ) ) {
1963 $img_src = plugin_dir_url(__FILE__).'assets/images/pieregister-woocommerce.png';
1964 ?>
1965 <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')); ?>">
1966 <div class="pr-launch-icon">
1967 <img src="<?php echo esc_url($img_src); ?>" alt="Pie Register and Woocommerce Logo">
1968 </div>
1969 <div>
1970 <p style="font-weight:700;">WooCommerce Addon</p>
1971 <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>
1972 <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">
1973 <?php esc_html_e( "Here's how you can do it", 'pie-register' ) ?>
1974 </a>
1975 </div>
1976 </div>
1977 <script type="text/javascript">
1978
1979 jQuery( '.wc_promo_users' ).on( 'click', '.notice-dismiss', function() {
1980 nonce_wc = jQuery(this).parent().data('wcuser');
1981
1982 var data = {
1983 action: 'dismiss_pie_promo_notice_for_wc_user',
1984 nonce: nonce_wc
1985 };
1986 jQuery.post( ajaxurl, data );
1987 });
1988 </script>
1989 <?php
1990 }
1991 }
1992 public function dismiss_pie_promo_notice_for_wc_user()
1993 {
1994 // Run a security check.
1995 if ( ! check_ajax_referer( 'pie_wc_user_nonce', 'nonce', false ) || !current_user_can('manage_options') ) {
1996 wp_send_json_error( esc_html__( 'Something went wrong.', 'pie-register' ) );
1997 }
1998
1999 update_option( 'pie_promo_notice_for_wc_user', 'yes' );
2000 }
2001
2002 public function pie_promo_notice_for_mc_user()
2003 {
2004 $show_release_notice = get_option( 'pie_promo_notice_for_mc_user_2' );
2005
2006 if ( empty( $show_release_notice ) ) {
2007 $img_src = plugin_dir_url(__FILE__).'assets/images/pieregister-mailchimp.png';
2008 ?>
2009 <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')); ?>">
2010 <div class="pr-launch-icon">
2011 <img src="<?php echo esc_url($img_src); ?>" alt="Pie Register and Mail Chimp Logo">
2012 </div>
2013 <div>
2014 <p style="font-weight:700;">Mail Chimp Addon</p>
2015 <p><?php echo esc_html( 'MailChimp Add-on now has the GDPR Compliance Field, Merge Fields, and a lot more.','pie-register'); ?></p>
2016 <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">
2017 <?php esc_html_e( "View list of new functions", 'pie-register' ) ?>
2018 </a>
2019 </div>
2020 </div>
2021 <script type="text/javascript">
2022 jQuery( '.mc_promo_users' ).on( 'click', '.notice-dismiss', function() {
2023 nonce_mc = jQuery(this).parent().data('mcuser');
2024 var data = {
2025 action: 'dismiss_pie_promo_notice_for_mc_user',
2026 nonce: nonce_mc
2027 };
2028 jQuery.post( ajaxurl, data );
2029 });
2030 </script>
2031 <?php
2032 }
2033 }
2034 public function dismiss_pie_promo_notice_for_mc_user()
2035 {
2036 // Run a security check.
2037 if ( ! check_ajax_referer( 'pie_mc_user_nonce', 'nonce', false ) || !current_user_can('manage_options') ) {
2038 wp_send_json_error( esc_html__( 'Something went wrong.', 'pie-register' ) );
2039 }
2040
2041 update_option( 'pie_promo_notice_for_mc_user_2', 'yes' );
2042 }
2043
2044 public function pie_promo_notice_for_bb_user()
2045 {
2046 $show_release_notice = get_option( 'pie_promo_notice_for_bb_user_3' );
2047
2048 if ( empty( $show_release_notice ) ) {
2049 $img_src = plugin_dir_url(__FILE__).'assets/images/pieregister-bbPress.png';
2050 ?>
2051 <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')); ?>">
2052 <div class="pr-launch-icon">
2053 <img src="<?php echo esc_url($img_src); ?>" alt="Pie Register and bbPress Logo">
2054 </div>
2055 <div>
2056 <p style="font-weight:700;">bbPress Addon</p>
2057 <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>
2058 <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">
2059 <?php esc_html_e( "Learn More", 'pie-register' ) ?>
2060 </a>
2061 </div>
2062 </div>
2063 <script type="text/javascript">
2064 jQuery( '.bb_promo_users' ).on( 'click', '.notice-dismiss', function() {
2065 nonce_bbuser = jQuery(this).parent().data('bbuser');
2066
2067 var data = {
2068 action: 'dismiss_pie_promo_notice_for_bb_user',
2069 nonce: nonce_bbuser
2070 };
2071 jQuery.post( ajaxurl, data );
2072 });
2073 </script>
2074 <?php
2075 }
2076 }
2077 public function dismiss_pie_promo_notice_for_bb_user()
2078 {
2079 // Run a security check.
2080 if ( ! check_ajax_referer( 'pie_bb_user_nonce', 'nonce', false ) || !current_user_can('manage_options') ) {
2081 wp_send_json_error( esc_html__( 'Something went wrong.', 'pie-register' ) );
2082 }
2083
2084 update_option( 'pie_promo_notice_for_bb_user_3', 'yes' );
2085 }
2086
2087 /*
2088 Since version 3.7.0.4
2089 @TODO remove this notice in the future.
2090 */
2091
2092 public function pie_promo_notice_for_wpb_user()
2093 {
2094 if ( !function_exists( 'get_current_screen' ) ) {
2095 require_once ABSPATH . '/wp-admin/includes/screen.php';
2096 }
2097 $screen = get_current_screen();
2098
2099 if($screen->base == 'dashboard'){
2100 wp_enqueue_style('pie_font_awesome');
2101
2102 wp_enqueue_script("pie_admin_about_us_menu_js" );
2103
2104 $can_install_plugins = true;
2105 if ( ! current_user_can( 'install_plugins' ) ) {
2106 $can_install_plugins = false;
2107 }
2108
2109 $show_release_notice = get_option( 'pie_promo_notice_for_wpb_user' );
2110
2111 if ( empty( $show_release_notice ) ) {
2112 $img_src = plugin_dir_url(__FILE__).'assets/images/pieregister-woocommerce.png';
2113 $images_url = PIEREG_PLUGIN_URL . 'assets/images/about-us/';
2114 $plugin = 'vc-addons-by-bit14/bit14-vc-addons.php';
2115 $all_plugins = get_plugins();
2116 $plugin_data = array(
2117 'icon' => $images_url . 'pb-logo.png',
2118 'name' => esc_html__( 'PB Add-ons for WP Bakery', 'pie-register' ),
2119 'desc' => esc_html__( 'Build your website with premium quality All-in-One Web elements for WPBakery Page Builder.', 'pie-register' ),
2120 'wporg' => 'https://wordpress.org/plugins/vc-addons-by-bit14/',
2121 'url' => 'https://downloads.wordpress.org/plugin/vc-addons-by-bit14.zip',
2122 );
2123
2124 $plugin_data = $this->get_aboutus_plugin_data( $plugin, $plugin_data, $all_plugins );
2125
2126 ?>
2127 <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')) ?>">
2128 <div class="pr-launch-icon">
2129 <img src="<?php echo esc_url( $plugin_data['details']['icon'] ); ?>">
2130 </div>
2131 <div class="sib-product-container">
2132 <div class="sib-product-notice">
2133 <div class="sib-product-detail">
2134 <h5>
2135 <?php echo esc_html( $plugin_data['details']['name'] ); ?>
2136 </h5>
2137 <p>
2138 <?php echo wp_kses_post( $plugin_data['details']['desc'] ); ?>
2139 </p>
2140 </div>
2141 <div class="sib-product-action">
2142 <div class="product-action">
2143 <?php if ( $can_install_plugins ) { ?>
2144 <button class="<?php echo esc_attr( $plugin_data['action_class'] ); ?>" data-plugin="<?php echo esc_attr( $plugin_data['plugin_src'] ); ?>" data-type="plugin">
2145 <?php echo wp_kses_post( $plugin_data['action_text'] ); ?>
2146 </button>
2147 <?php } else { ?>
2148 <a href="<?php echo esc_url( $details['wporg'] ); ?>" target="_blank" rel="noopener noreferrer">
2149 <?php esc_html_e( 'WordPress.org', 'pie-register' ); ?>
2150 <span aria-hidden="true" class="dashicons dashicons-external"></span>
2151 </a>
2152 <?php } ?>
2153 </div>
2154 </div>
2155 </div>
2156 </div>
2157 </div>
2158 <script type="text/javascript">
2159
2160 jQuery( '.wpb_promo_users' ).on( 'click', '.notice-dismiss', function() {
2161 nonce_wpb = jQuery(this).parent().data('wpb');
2162
2163 var data = {
2164 action: 'dismiss_pie_promo_notice_for_wpb_user',
2165 nonce: nonce_wpb
2166 };
2167 jQuery.post( ajaxurl, data );
2168 });
2169 </script>
2170 <?php
2171 }
2172 }
2173 }
2174 public function dismiss_pie_promo_notice_for_wpb_user()
2175 {
2176 // Run a security check.
2177 if ( ! check_ajax_referer( 'pie_wpb_user_nonce', 'nonce', false ) || !current_user_can('manage_options') ) {
2178 wp_send_json_error( esc_html__( 'Something went wrong.', 'pie-register' ) );
2179 }
2180
2181 update_option( 'pie_promo_notice_for_wpb_user', 'yes' );
2182 }
2183
2184 /*
2185 Since version 3.6
2186 @TODO remove this notice in the future.
2187 */
2188 public function pie_free_notice_to_premium_users()
2189 {
2190 $show_release_notice = get_option( 'pie_free_notice_to_premium_users' );
2191
2192 if ( empty( $show_release_notice ) ) {
2193
2194 ?>
2195 <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_e(wp_create_nonce('pie_alert_nonce'))); ?>">
2196 <h3><?php echo esc_html('ALERT','pie-register'); ?>:</h3>
2197 <p style="font-size:14px;"><?php echo 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')); ?></p>
2198 </div>
2199 <script type="text/javascript">
2200
2201 jQuery( '.free_promo_users_upgrade' ).on( 'click', '.notice-dismiss', function() {
2202 nonce_alert = jQuery(this).parent().data('alert');
2203 var data = {
2204 action: 'dismiss_pie_free_notice_to_premium_users',
2205 nonce: nonce_alert
2206 };
2207 jQuery.post( ajaxurl, data );
2208 });
2209 </script>
2210 <?php
2211 }
2212 }
2213 public function dismiss_pie_free_notice_to_premium_users()
2214 {
2215 // Run a security check.
2216 if ( ! check_ajax_referer( 'pie_alert_nonce', 'nonce', false ) || !current_user_can('manage_options') ) {
2217 wp_send_json_error( esc_html__( 'Something went wrong.', 'pie-register' ) );
2218 }
2219
2220 update_option( 'pie_free_notice_to_premium_users', 'yes' );
2221 }
2222
2223
2224 /*
2225 * Show Post Meta Box
2226 */
2227 function myplugin_meta_box_callback( $post ) {
2228 wp_nonce_field( 'myplugin_meta_box', 'myplugin_meta_box_nonce' );
2229 ?>
2230 <div class="pie_register-admin-meta">
2231 <?php $result = get_post_meta( $post->ID, '_piereg_post_restriction', true );?>
2232
2233 <div class="piereg_restriction_field_area">
2234 <h2><?php esc_html_e( 'Visibility Restrictions', 'pie-register' ); ?></h2>
2235 <input type="hidden" name="post_restriction[piereg_post_type]" value="<?php echo esc_attr($post->post_type); ?>" />
2236 <div class="piereg_label">
2237 <label for="piereg_post_visibility"><?php esc_html_e( 'Visibility', 'pie-register' ); ?></label>
2238 </div>
2239 <div class="piereg_input">
2240 <?php
2241 if ( isset($result['piereg_post_visibility']) && is_array(isset($result['piereg_post_visibility'])) )
2242 {
2243 $option = !empty($result['piereg_post_visibility']) ? $result['piereg_post_visibility'] : array( 0 => 'default' );
2244 }
2245 else
2246 {
2247 $option = !empty($result['piereg_post_visibility']) ? $result['piereg_post_visibility'] : "default";
2248 }
2249 ?>
2250 <select multiple id="piereg_post_visibility" name="piereg_post_visibility[]">
2251 <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>
2252 <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>
2253 <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>
2254 <?php
2255 global $wp_roles;
2256 $role = $wp_roles->roles;
2257
2258 foreach($role as $key => $value)
2259 {
2260 ?>
2261 <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");echo " ".esc_html($value['name']); ?></option>
2262 <?php
2263 }
2264 ?>
2265 </select>
2266 </div>
2267 </div>
2268
2269 <div class="piereg_restriction_field_area pieregister_restriction_type_area">
2270 <div class="piereg_label"><label><?php esc_html_e( 'Restriction Type', 'pie-register' ); ?></label></div>
2271
2272 <div class="piereg_input">
2273 <?php $restriction_option = (isset($result['piereg_restriction_type']) && $result['piereg_restriction_type'] != "") ? $result['piereg_restriction_type'] : 0; ?>
2274 <div class="piereg_input_radio">
2275 <label for="redirect">
2276 <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>
2277 </div>
2278 <div class="piereg_input_radio">
2279 <label for="block_content">
2280 <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>
2281 </div>
2282 <div ><p class="piereg_restriction_msg error" ><strong><?php esc_html_e( 'Please Provide Either Redirect Page or Redirect URL.', 'pie-register' ); ?></strong></p></div>
2283 </div>
2284 </div>
2285
2286 <div id="pieregister_restriction_url_area" style="<?php echo ($restriction_option != 0)? esc_attr('display:none') : '' ?>" >
2287 <div class="piereg_restriction_field_area pieregister_restriction_url_area">
2288 <div class="piereg_label">
2289 <?php $option = ((isset($result['piereg_redirect_url']) && $result['piereg_redirect_url'] != "") ? $result['piereg_redirect_url'] : ""); ?>
2290 <label for="piereg_redirect_url"><?php esc_html_e( 'Redirect Url', 'pie-register' ); ?></label>
2291 </div>
2292 <div class="piereg_input">
2293 <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" />
2294 </div>
2295 </div>
2296
2297 <div class="piereg_restriction_field_area pieregister_restriction_url_area">
2298 <center><strong><?php esc_html_e('OR','pie-register'); ?></strong></center>
2299 </div>
2300
2301 <div class="piereg_restriction_field_area pieregister_restriction_url_area">
2302 <div class="piereg_label">
2303 <?php $option = ((isset($result['piereg_redirect_page']) && $result['piereg_redirect_page'] != "") ? $result['piereg_redirect_page'] : -1); ?>
2304 <label for="piereg_redirect_page"><?php esc_html_e( 'Redirect Page', 'pie-register' ); ?></label>
2305 </div>
2306 <div class="piereg_input">
2307 <?php
2308 $args = array("show_option_no_change"=>"None","id"=>"piereg_redirect_page","class"=>"pieregister_redirect_url","name"=>"post_restriction[piereg_redirect_page]","selected"=>$option);
2309 wp_dropdown_pages( $args ); ?>
2310 </div>
2311 </div>
2312 </div>
2313
2314 <div class="piereg_restriction_field_area pieregister_block_content_area" style="<?php echo ($restriction_option != 1) ? esc_attr('display:none') : '' ?>" >
2315 <div class="piereg_label">
2316 <?php $option = ((isset($result['piereg_block_content']) && $result['piereg_block_content'] != "") ? $result['piereg_block_content'] : ""); ?>
2317 <label for="piereg_block_content"><?php esc_html_e( 'Block Content', 'pie-register' ); ?></label>
2318 </div>
2319 <div class="piereg_input">
2320 <textarea id="piereg_block_content" name="post_restriction[piereg_block_content]"><?php echo esc_textarea($option); ?></textarea>
2321 </div>
2322 </div>
2323 </div>
2324 <noscript><?php esc_html_e('You browser does not support Javascript. Please turn on Javascript support.','pie-register'); ?></noscript>
2325
2326 <?php
2327 }
2328 /*
2329 Save Post Meta Box
2330 */
2331 function piereg_save_meta_box_data( $post_id ) {
2332 //Don't update on Quick Edit
2333 if (defined('DOING_AJAX') ) {
2334 return $post_id;
2335 }
2336 $post_restriction_meta = isset($_POST['post_restriction']) ? $this->piereg_sanitize_post_data( 'post_restriction', $_POST ) : array();
2337
2338 if ( isset( $_POST['piereg_post_visibility'] ) )
2339 {
2340 // Sanitize piereg post visibility array
2341 $npost = array();
2342 foreach ( $_POST['piereg_post_visibility'] as $key=>$val )
2343 {
2344 $npost[$key] = sanitize_key( $val );
2345 }
2346 $post_restriction_meta['piereg_post_visibility'] = $npost;
2347 }
2348 else
2349 {
2350 $post_restriction_meta['piereg_post_visibility'] = "default";
2351 }
2352 update_post_meta( $post_id, '_piereg_post_restriction', $post_restriction_meta );
2353 }
2354
2355 private function show_invitaion_code_user(){
2356 global $errors,$wpdb;
2357 $prefix=$wpdb->prefix."pieregister_";
2358 $inv_code = sanitize_text_field(base64_decode($_GET['invitaion_code']));
2359 if (!preg_match("/[^A-Za-z0-9-_]/", $inv_code)) {
2360
2361 $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 ) );
2362
2363 if(isset($wpdb->last_error) && !empty($wpdb->last_error)){
2364 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
2365 }
2366 ?>
2367 <style type="text/css">
2368 table.invitaion-code-table thead td,table.invitaion-code-table tfoot td{
2369 background:#333;
2370 font-size:16px;
2371 font-weight:bold;
2372 color:#FFF;
2373 }
2374 table.invitaion-code-table tr:nth-child(even){background:#E8E8E8;}
2375 table.invitaion-code-table tr:hover{background:#666;color:#FFF;}
2376 </style>
2377 <div style="width:100%">
2378 <h2><?php esc_html_e("Activation Code","pie-register");echo " : ".esc_html($inv_code); ?></h2>
2379 <table class="invitaion-code-table" width="100%" cellpadding="10" cellspacing="0">
2380 <thead>
2381 <tr>
2382 <td><?php esc_html_e("User Name","pie-register"); ?></td>
2383 <td><?php esc_html_e("User E-mail","pie-register"); ?></td>
2384 </tr>
2385 </thead>
2386 <tfoot>
2387 <tr>
2388 <td><?php esc_html_e("User Name","pie-register"); ?></td>
2389 <td><?php esc_html_e("User E-mail","pie-register"); ?></td>
2390 </tr>
2391 </tfoot>
2392 <?php
2393 foreach($invitaion_code_users as $row){
2394 echo '<tr>';
2395 echo '<td>'.esc_html($row->user_login).'</td>';
2396 echo '<td>'.esc_html($row->user_email).'</td>';
2397 echo '</tr>';
2398 }
2399 ?>
2400 </table>
2401 </div>
2402 <?php
2403 }
2404 exit;
2405 }
2406 function piereg_login_logo() {
2407 $option = get_option(OPTION_PIE_REGISTER);
2408 $logo_data = @getimagesize($option['custom_logo_url']);
2409 ?>
2410 <style type="text/css">
2411 body.login div#login h1 a {
2412 background-image: url('<?php echo esc_url($option['custom_logo_url']); ?>');
2413 background-size:<?php echo esc_attr($logo_data[0])."px ".esc_attr($logo_data[1])."px"; ?>;
2414 width:<?php echo esc_attr($logo_data[0])."px "; ?>;
2415 height:<?php echo esc_attr($logo_data[1])."px "; ?>;
2416 }
2417 </style>
2418 <?php
2419 unset($option);
2420 }
2421 function piereg_login_logo_url_title() {
2422 $option = get_option(OPTION_PIE_REGISTER);
2423 return $option['custom_logo_tooltip'];
2424 unset($option);
2425 }
2426 function piereg_login_logo_url() {
2427 $option = get_option(OPTION_PIE_REGISTER);
2428 return $option['custom_logo_link'];
2429 unset($option);
2430 }
2431 function payment_success_cancel_after_register($query_string){
2432 global $wpdb;
2433 $option = get_option(OPTION_PIE_REGISTER);
2434 $fields = maybe_unserialize(get_option("pie_fields"));
2435 $confirmation_type = $fields['submit']['confirmation'];
2436
2437 if($confirmation_type == "page"){
2438 wp_safe_redirect(get_permalink($fields['submit']['page']));
2439 exit;
2440 }elseif($confirmation_type == "redirect"){
2441 wp_redirect(esc_url_raw($fields['submit']['redirect_url']));
2442 exit;
2443 }elseif($confirmation_type == "text" ){
2444 wp_safe_redirect($this->pie_modify_custom_url(get_permalink($option['alternate_login']),$query_string));
2445 exit;
2446 }
2447 }
2448 function get_redirect_url_pie($get_url){
2449 $get_url = trim($get_url);
2450 if(!$get_url) return false;
2451 if($_SERVER['QUERY_STRING']){
2452 if(strpos($get_url,"?"))
2453 $url = $get_url."&".esc_url_raw($_SERVER['QUERY_STRING']);
2454 else
2455 $url = $get_url."?".esc_url_raw($_SERVER['QUERY_STRING']);
2456 }
2457 else{
2458 $url = $get_url;
2459 }
2460 return $url;
2461 }
2462 function subscriber_show_admin_bar()
2463 {
2464 global $current_user;
2465 $current_user_caps_keys = array_keys($current_user->caps);
2466 $ncaps = count($current_user_caps_keys);
2467 if($ncaps) {
2468 //if( !in_array('administrator', $current_user->caps) )
2469 if( !array_key_exists('administrator', $current_user->caps) )
2470 {
2471 show_admin_bar( false );
2472 }
2473 }
2474 unset($current_user);
2475 }
2476
2477 function delete_piereg_form()
2478 {
2479 if(isset($_GET['prfrmid']) and ((int)$_GET['prfrmid']) != 0 and isset($_GET['action']) and $_GET['action'] == "delete")
2480 {
2481 $fields_id = ((int)sanitize_key($_GET['prfrmid']));
2482 $assign_new_free_form = false;
2483
2484 if( $this->regFormForFreeVers() == $fields_id ) {
2485 $assign_new_free_form = true;
2486 }
2487
2488 delete_option("piereg_form_field_option_".$fields_id);
2489 delete_option("piereg_form_fields_".$fields_id);
2490 $user_role = get_option(OPTION_PIE_REGISTER);
2491 unset($user_role['pie_regis_set_user_role_'.((int)$_GET['prfrmid'])]);
2492 update_option(OPTION_PIE_REGISTER,$user_role);
2493 unset($user_role);
2494 unset($fields_id);
2495 unset($_GET['prfrmid']);
2496
2497 if( $assign_new_free_form ) {
2498 $this->regFormForFreeVers(true);
2499 }
2500 }
2501 }
2502
2503 //"Insert Form" button to the post/page edit screen
2504 function add_pie_form_button($context)
2505 {
2506 $_post_type = get_post_type();
2507 if($_post_type == 'product')
2508 return $context;
2509
2510 $is_post_edit_page = in_array(basename($_SERVER['PHP_SELF']), array('post.php', 'page.php', 'page-new.php', 'post-new.php'));
2511 if(!$is_post_edit_page)
2512 return $context;
2513
2514 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('.PIEREG_PLUGIN_URL.'assets/images/form-icon.png); background-repeat: no-repeat; background-position: left bottom;',esc_html__("Add Form","pie-register"));
2515
2516 }
2517
2518 function checkLoginPage()
2519 {
2520 $option = get_option(OPTION_PIE_REGISTER);
2521 $current_page = get_the_ID();
2522 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 )
2523 {
2524 $this->afterLoginPage();
2525 }
2526 }
2527 function add_pie_form_popup()
2528 {
2529 ?>
2530 <div id="select_pie_form" style="display:none;">
2531 <div >
2532 <div>
2533 <div style="padding:15px 15px 0 15px;">
2534 <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>
2535 <span>
2536 <?php esc_html__("Select a form below to add it to your post or page.", "pie-register"); ?>
2537 </span>
2538 </div>
2539 <div style="padding:15px 15px 0 15px;">
2540 <select id="pie_forms">
2541 <option value=""><?php esc_attr__("Select","pie-register") ?></option>
2542 <optgroup label="<?php esc_attr__("Registration Form","pie-register") ?>">
2543 <?php
2544 $fields_id = get_option("piereg_form_fields_id");
2545 for($a=1;$a<=$fields_id;$a++)
2546 {
2547 $option = get_option("piereg_form_field_option_".$a);
2548 if($option != "" && (!isset($option['IsDeleted']) || trim($option['IsDeleted']) != 1) )
2549 {
2550 echo '<option value=\'[pie_register_form id="'.esc_attr($option['Id']).'" title="true" description="true" ]\'>'.esc_html($option['Title']).'</option>';
2551 }
2552 }
2553 ?>
2554 </optgroup>
2555 <optgroup label="<?php esc_attr_e("Other Form","pie-register") ?>">
2556 <option value="[pie_register_login]"><?php esc_html_e("Login Form","pie-register") ?></option>
2557 <option value="[pie_register_forgot_password]"><?php esc_html_e("Forgot Password Form","pie-register") ?></option>
2558 <option value="[pie_register_profile]"><?php esc_html_e("Profile Page","pie-register") ?></option>
2559 </optgroup>
2560 </select> <br/>
2561 </div>
2562 <div style="padding:15px;">
2563 <input type="button" class="button-primary" value="Insert Form" onclick="addForm();"/>&nbsp;&nbsp;&nbsp;
2564 <a class="button" style="color:#bbb;" href="#" onclick="tb_remove(); return false;"><?php esc_html_e("Cancel", "pie-register"); ?></a>
2565 </div>
2566 </div>
2567 </div>
2568 </div>
2569 <?php
2570 }
2571 function process_verify_user_email(){
2572
2573 if(isset($_GET['verification_key']) && !empty($_GET['verification_key'])){
2574
2575 $unverified = get_users(array('meta_key'=> 'admin_hash','meta_value' => sanitize_key($_GET['verification_key'])));
2576 $option = get_option(OPTION_PIE_REGISTER);
2577 if(sizeof($unverified )==1)
2578 {
2579 $user_id = $unverified[0]->ID;
2580 $user_login = $unverified[0]->user_login;
2581 $user_email = $unverified[0]->user_email;
2582 $register_type = get_user_meta( $user_id , "register_type" , true);
2583
2584 if($register_type == "admin_email_verify" && !$this->InvCodeExpired($user_id) ){
2585 update_user_meta( $user_id, 'active', 0);
2586 $hash = md5( time() );
2587 update_user_meta( $user_id, 'hash', $hash );
2588 update_user_meta( $user_id, 'register_type', "email_verify");
2589
2590 $subject = html_entity_decode($option['user_subject_email_email_verification'],ENT_COMPAT,"UTF-8");
2591 $subject = $this->filterSubject($user_email,$subject);
2592 $message_temp = "";
2593 if($option['user_formate_email_email_verification'] == "0"){
2594 $message_temp = nl2br(strip_tags($option['user_message_email_email_verification']));
2595 }else{
2596 $message_temp = $option['user_message_email_email_verification'];
2597 }
2598 $message = $this->filterEmail($message_temp,$user_email );
2599 $from_name = $option['user_from_name_email_verification'];
2600 $from_email = $option['user_from_email_email_verification'];
2601 $reply_email = $option['user_to_email_email_verification'];
2602
2603 //Headers
2604 $headers = 'MIME-Version: 1.0' . "\r\n";
2605 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
2606
2607
2608 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL))//Validating From
2609 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
2610 if($reply_email){
2611 $headers .= "Reply-To: {$reply_email}\r\n";
2612 $headers .= "Return-Path: {$reply_email}\r\n";
2613 }else{
2614 $headers .= "Reply-To: {$from_email}\r\n";
2615 $headers .= "Return-Path: {$from_email}\r\n";
2616 }
2617 if((isset($option['user_enable_email_verification']) && $option['user_enable_email_verification'] == 1) && !wp_mail($user_email, $subject, $message , $headers)){
2618 $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__)));
2619 }else{
2620 echo('<div id="dialog-message" title="User Verified Successfully">
2621 <p>
2622 '.apply_filters("pie_user_veri_by_email_admin",esc_html__("User has been verified.","pie-register")).'
2623 </p>
2624 </div>');
2625 }
2626 }elseif($user_login == $_GET['pie_id'] && !$this->InvCodeExpired($user_id) ){
2627
2628 $user = new WP_User($user_id);
2629 do_action( "piereg_action_hook_before_user_verified", $user_id, $user_login, $user_email ); # newlyAddedHookFilter
2630 update_user_meta( $user_id, 'active', 1);
2631 $email_user_password = get_user_meta( $user_id , "email_user_password" , true);
2632 $user_pass = $email_user_password == "1" ? apply_filters('piereg_email_random_generated_password', wp_generate_password() ) : "";
2633
2634 /*************************************/
2635 /////////// THANK YOU E-MAIL //////////
2636 $form = new Registration_form();
2637 $subject = html_entity_decode($option['user_subject_email_email_thankyou'],ENT_COMPAT,"UTF-8");
2638 $subject = $form->filterSubject($user_email,$subject);
2639 if ( !empty($user_pass) )
2640 {
2641 $user_data = array( 'ID' => $user_id, 'user_pass' => trim($user_pass) );
2642 wp_update_user( $user_data );
2643 update_user_meta( $user_id, 'email_user_password', '0' );
2644 }
2645 $message_temp = "";
2646 if($option['user_formate_email_email_thankyou'] == "0"){
2647 $message_temp = nl2br(strip_tags($option['user_message_email_email_thankyou']));
2648 }else{
2649 $message_temp = $option['user_message_email_email_thankyou'];
2650 }
2651 $message = $form->filterEmail($message_temp,$user_email,$user_pass);
2652 $from_name = $option['user_from_name_email_thankyou'];
2653 $from_email = $option['user_from_email_email_thankyou'];
2654 $reply_email = $option['user_to_email_email_thankyou'];
2655 //Headers
2656 $headers = 'MIME-Version: 1.0' . "\r\n";
2657 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
2658 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL))//Validating From
2659 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
2660 if($reply_email){
2661 $headers .= "Reply-To: {$reply_email}\r\n";
2662 $headers .= "Return-Path: {$reply_email}\r\n";
2663 }else{
2664 $headers .= "Reply-To: {$from_email}\r\n";
2665 $headers .= "Return-Path: {$from_email}\r\n";
2666 }
2667 /*************************************/
2668
2669 if( (isset($option['user_enable_email_thankyou']) && $option['user_enable_email_thankyou'] == 1) && !wp_mail($user_email, $subject, $message , $headers)){
2670 $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__)));
2671 }else{
2672 echo('<div id="dialog-message" title="User Verified Successfully">
2673 <p>
2674 '.apply_filters("pie_user_veri_by_email_admin",esc_html__("User has been verified.","pie-register")).'
2675 </p>
2676 </div>');
2677 }
2678 // mailchimp related code within PR
2679 do_action('pireg_after_verification_users', $user);
2680 }
2681 else
2682 {
2683 if ( $this->InvCodeExpired($user_id) )
2684 {
2685 echo('<div id="dialog-message" title="Invitation Code Expired">
2686 <p>
2687 <strong>'.ucwords(esc_html__("error","pie-register")).'</strong>: '.apply_filters("piereg_invalid_verification_key",esc_html__("The account cannot be activated. Please contact site administrator","pie-register"))).'
2688 </p>
2689 </div>';
2690 } else {
2691 echo('<div id="dialog-message" title="User Not Verified">
2692 <p>
2693 <strong>'.ucwords(esc_html__("error","pie-register")).'</strong>: '.apply_filters("piereg_invalid_verification_key",esc_html__("Invalid verification key","pie-register"))).'
2694 </p>
2695 </div>';
2696 }
2697 }
2698 }else{
2699 $user_name = sanitize_user($_GET['pie_id']);
2700 $user = get_user_by('login',$user_name);
2701 if($user){
2702 $user_meta = get_user_meta( $user->ID, 'active');
2703 $user_meta_email = get_user_meta($user->ID,'hash');
2704
2705 if(isset($user_meta[0]) && $user_meta[0] == 1){
2706 echo('<div id="dialog-message" title="User Verified">
2707 <p><strong>'.ucwords(esc_html__("Warning","pie-register")).'</strong>:
2708 '.apply_filters("piereg_canelled_your_registration",esc_html__("User is already verified","pie-register")).'
2709 </p>
2710 </div>');
2711 unset($user_meta);
2712 unset($user_meta_email);
2713 unset($user_name);
2714 unset($user);
2715 }elseif(isset($user_meta_email[0]) && $user_meta_email[0]){
2716 echo('<div id="dialog-message" title="User Verified">
2717 <p><strong>'.ucwords(esc_html__("Warning","pie-register")).'</strong>:
2718 '.apply_filters("piereg_canelled_your_registration",esc_html__("User is already verified","pie-register")).'
2719 </p>
2720 </div>');
2721 unset($user_meta);
2722 unset($user_meta_email);
2723 unset($user_name);
2724 unset($user);
2725 }
2726 else{
2727 echo('<div id="dialog-message" title="User Not Verified">
2728 <p><strong>'.ucwords(esc_html__("error","pie-register")).'</strong>:
2729 '.apply_filters("piereg_invalid_verification_key",esc_html__("Invalid verification key","pie-register")).'
2730 </p>
2731 </div>');
2732 }
2733 }
2734 else{
2735 echo('<div id="dialog-message" title="User Not Verified">
2736 <p><strong>'.ucwords(esc_html__("error","pie-register")).'</strong>:
2737 '.apply_filters("piereg_invalid_verification_key",esc_html__("Invalid verification key","pie-register")).'
2738 </p>
2739 </div>');
2740 }
2741 }
2742 }
2743 }
2744 function pie_update_user_meta_admin_hash() {
2745 $verification_key = isset($_GET['verification_key']) ? sanitize_key($_GET['verification_key']) : "";
2746 $unverified = get_users(array('meta_key'=> 'admin_hash','meta_value' => $verification_key));
2747 if(sizeof($unverified )==1)
2748 {
2749 $user_id = $unverified[0]->ID;
2750 $user_login = $unverified[0]->user_login;
2751 if( isset($_GET['pie_id']) && $user_login == $_GET['pie_id'])
2752 {
2753 $admin_hash = "";
2754 update_user_meta( $user_id, 'admin_hash', $admin_hash );
2755 }
2756 }
2757 }
2758
2759 function process_login_form(){
2760 get_header();
2761 $this->set_pr_stats("login","view");
2762 if( file_exists(PIEREG_DIR_NAME . "/login_form.php") )
2763 include_once("login_form.php");
2764 $output = "<div class='wrapper-wp-login-form'>";
2765 $output .= pieOutputLoginForm();
2766 $output .= "</div>";
2767 echo wp_kses($output, $this->piereg_forms_get_allowed_tags());
2768 get_footer();
2769 exit;
2770 }
2771 function checkLogin(){
2772 global $wpdb, $errors, $wp_session;
2773 $errors = new WP_Error();
2774 $option = get_option(OPTION_PIE_REGISTER);
2775
2776 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) )
2777 {
2778 if(empty($_POST['log']) || empty($_POST['pwd']))
2779 {
2780 $errors->add('login-error',apply_filters("piereg_Invalid_username_or_password",esc_html__('Invalid username or password.','pie-register')));
2781 }
2782 else
2783 {
2784 /*
2785 * Sanitizing post data
2786 */
2787 $this->pie_post_array = $this->piereg_sanitize_post_data( 'piereg_login', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
2788 $error_found = 0;
2789
2790 $table_name = $wpdb->prefix . "pieregister_lockdowns";
2791 $user_ip = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
2792 $get_results = $wpdb->get_results($wpdb->prepare("SELECT * FROM `".$table_name."` WHERE `user_ip` = %s AND `attempt_from` = 'is_login';",$user_ip));
2793
2794 $piereg_security_attempts_login_value = false;
2795
2796 if($option['captcha_in_login_value'] == 1 && !isset($this->pie_post_array['piereg_login_after_registration']) ){
2797
2798 $attempts = false;
2799 if( $option['captcha_in_login_attempts'] > 0 ){
2800 $attempts = true;
2801 }elseif( $option['captcha_in_login_attempts'] == 0 ){
2802 $attempts = true;
2803 }
2804
2805 if( $attempts ){
2806 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']) ) ){
2807 if(isset($this->pie_post_array['piereg_math_captcha_login']))//Login form in Page
2808 {
2809 $currentTabId = intval($_COOKIE['currentTabId']);
2810 $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']) : "");
2811 $piereg_cookie_array = explode("|",$piereg_cookie_array);
2812 $cookie_result1 = (intval(base64_decode($piereg_cookie_array[0])) - 12);
2813 $cookie_result2 = (intval(base64_decode($piereg_cookie_array[1])) - 786);
2814 $cookie_result3 = (intval(base64_decode($piereg_cookie_array[2])) + 5);
2815 if( ($cookie_result1 == $cookie_result2) && ($cookie_result3 == $this->pie_post_array['piereg_math_captcha_login'])){
2816 }
2817 else{
2818 if($this->piereg_authentication($this->pie_post_array['log'],$this->pie_post_array['pwd'])){
2819 $errors->add('login-error',apply_filters("Invalid_Security_Code",esc_html__('Invalid Security Code','pie-register')));
2820 }else{
2821 if( $piereg_security_attempts_login_value ){
2822 $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")));
2823 }
2824 }
2825 $error_found++;
2826 }
2827 }
2828 elseif(isset($this->pie_post_array['piereg_math_captcha_login_widget']))//Login form in widget
2829 {
2830 $currentTabId = intval($_COOKIE['currentTabId']);
2831 $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']) : "");
2832 $piereg_cookie_array = explode("|",$piereg_cookie_array);
2833 $cookie_result1 = (intval(base64_decode($piereg_cookie_array[0])) - 12);
2834 $cookie_result2 = (intval(base64_decode($piereg_cookie_array[1])) - 786);
2835 $cookie_result3 = (intval(base64_decode($piereg_cookie_array[2])) + 5);
2836 if( ($cookie_result1 == $cookie_result2) && ($cookie_result3 == $this->pie_post_array['piereg_math_captcha_login_widget'])){
2837 }
2838 else{
2839 if($this->piereg_authentication($this->pie_post_array['log'],$this->pie_post_array['pwd'])){
2840 $errors->add('login-error',apply_filters("Invalid_Security_Code",esc_html__('Invalid Security Code','pie-register')));
2841 }else{
2842 if( $piereg_security_attempts_login_value ){
2843 $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")));
2844 }
2845 }
2846 $error_found++;
2847 }
2848 }else{
2849 if($this->piereg_authentication($this->pie_post_array['log'],$this->pie_post_array['pwd'])){
2850 $errors->add('login-error',apply_filters("Invalid_Security_Code",esc_html__('Invalid Security Code','pie-register')));
2851 }else{
2852 if( $piereg_security_attempts_login_value ){
2853 $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")));
2854 }
2855 }
2856 $error_found++;
2857 }
2858 }//New Recaptcha
2859 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"]) ) ){
2860 $settings = get_option(OPTION_PIE_REGISTER);
2861 if($settings['piereg_recaptcha_type'] == "v2"){
2862 $privatekey = $settings['captcha_private'];
2863 }elseif($settings['piereg_recaptcha_type'] == "v3"){
2864 $privatekey = $settings['captcha_private_v3'];
2865 }
2866
2867 $captcha = "";
2868 $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']) : "";
2869
2870 $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'] ) ) );
2871 $resp = json_decode($response,true);
2872 if($resp['success'] == false){
2873
2874 if($this->piereg_authentication($this->pie_post_array['log'],$this->pie_post_array['pwd'])){
2875 $errors->add('login-error',apply_filters("Invalid_Security_Code",esc_html__('Invalid Security Code','pie-register')));
2876 }else{
2877 if( $piereg_security_attempts_login_value ){
2878 $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")));
2879 }
2880 }
2881 $error_found++;
2882 }
2883 }
2884 }
2885 }
2886
2887 do_action('pie_validate_before_login', $errors);
2888
2889 if( sizeof($errors->errors) == 0 && $error_found == 0){
2890 $creds['user_login'] = $this->pie_post_array['log'];
2891 // is_email($creds['user_login']) - 3.6.11
2892 $regXemail = "/^[a-zA-Z0-9.'_%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,5}/";
2893 if( preg_match($regXemail,$creds['user_login']) )
2894 {
2895 $userdata = get_user_by('email', $creds['user_login']);
2896 $creds['user_login'] = (isset($userdata->user_login)) ? strtolower($userdata->user_login) : $creds['user_login'];
2897 }
2898
2899 $this->pie_post_array['pwd'] = html_entity_decode($this->pie_post_array['pwd']);
2900 $creds['user_password'] = $this->pie_post_array['pwd'];
2901 $creds['remember'] = isset($this->pie_post_array['rememberme']);
2902
2903 $remember_user = (isset($this->pie_post_array['rememberme'])) ? true : false ;
2904
2905 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"))
2906 {
2907 // Code for Social Login
2908 // Since v3.7.1.6 - The code has been shifted to the addon for user authentication
2909 require_once( ABSPATH . WPINC . '/user.php' );
2910 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
2911 $email_add = isset($this->pie_post_array['user_email_social_site']) ? $this->pie_post_array['user_email_social_site'] : '';
2912 $user = apply_filters( 'piereg_user_from_social_login', $this->pie_post_array['log'], $email_add, $remember_user );
2913 }
2914 else
2915 {
2916 $piereg_secure_cookie = false;
2917 $piereg_secure_cookie = $this->PR_IS_SSL();
2918 if($this->piereg_authentication($this->pie_post_array['log'],$this->pie_post_array['pwd'])){
2919
2920 $user = wp_signon( $creds, $piereg_secure_cookie);
2921
2922 if ( !is_wp_error($user) ){
2923 $this->piereg_delete_authentication();
2924 }
2925 }else{
2926 if( $piereg_security_attempts_login_value ){
2927 $user = new WP_Error('piereg_authentication_failed', esc_html__("IP address blocked due to too many failed login attempts.","pie-register"));
2928 }
2929 }
2930 }
2931
2932 if ( is_wp_error($user))
2933 {
2934 $user_login_error = $user->get_error_message();
2935 if(strpos(strip_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 )
2936 {
2937 $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>');
2938 }else if(strpos(strip_tags($user_login_error),'password you entered',9) > 10)
2939 {
2940 $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>');
2941 }
2942 $errors->add('login-error',apply_filters("piereg_login_error",$user_login_error));
2943 if(isset($this->pie_post_array['piereg_login_after_registration']) && $option['login_after_register'] == 1){
2944 $error_message = base64_encode(esc_html__("Invalid username","pie-register"));
2945 wp_safe_redirect($this->pie_modify_custom_url($this->pie_login_url(),"pr_invalid_username=true&pr_key={$error_message}"));
2946 exit;
2947 }
2948 }
2949 else
2950 {
2951 $this->set_pr_stats("login","used");
2952 if(in_array("administrator",(array)$user->roles)){
2953
2954 /*
2955 * Add Since 2.0.13
2956 */
2957 if( $user ) {
2958 wp_set_current_user( $user->ID, $user->user_login );
2959 wp_set_auth_cookie( $user->ID, $remember_user );
2960 do_action( 'wp_login', $user->user_login, $user );
2961 }
2962 do_action("piereg_admin_login_before_redirect_hook",$user);
2963
2964 $this->afterLoginPage();
2965 exit;
2966 }
2967 else{
2968
2969 # Hook before login from social login
2970 if( isset($this->pie_post_array['social_site']) && $this->pie_post_array['social_site'] == "true" )
2971 {
2972 do_action('pie_register_after_social_login',$user);
2973 }
2974
2975 /*
2976 * Check User Expiry
2977 * Deprecate
2978 */
2979
2980 $active = get_user_meta($user->ID,"active",true);
2981
2982 //Delete User after grace Period
2983 if(!$this->deleteUsers($user->ID,$user->user_email,$user->user_registered)){
2984 if($active == "0")//If not active
2985 {
2986 wp_logout();
2987 $check_payment = get_option(OPTION_PIE_REGISTER);
2988
2989 // Payment Cycle Is Disabled In 3.0 Release.
2990 if((($this->check_enable_payment_method()) == "true") && ("not" === "using") )
2991 {
2992 global $wpdb,$pr_wp_db_prefix;
2993 $user_name_or_email = esc_sql($this->pie_post_array['log']);
2994 $myrows = $wpdb->get_results( $wpdb->prepare("SELECT ID,user_login,user_email FROM `".($pr_wp_db_prefix)."users` where user_login = %s OR `user_email` = %s", $user_name_or_email, $user_name_or_email) );
2995 if(isset($wpdb->last_error) && !empty($wpdb->last_error)){
2996 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
2997 }
2998
2999 $errors->add('login-error',esc_html__('Please Renew your account. ','pie-register'));
3000 $this->pie_post_array['error'] = esc_html__('Please Renew your account',"pie-register");
3001 $auth_key = md5( $myrows[0]->user_login );
3002 $user_name = trim( $myrows[0]->user_login );
3003 update_user_meta( $myrows[0]->ID , "pr_renew_account_hash" , $auth_key );
3004
3005 $query_str = "pr_renew_account=true&auth=".base64_encode((urlencode($user_name)))."&auth_key=".(urlencode($auth_key));
3006 $renew_account_url = $this->pie_modify_custom_url($this->pie_login_url($check_payment['alternate_login']),$query_str);
3007 $this->pie_ua_renew_account_url = $renew_account_url;
3008 if(
3009 isset($option['social_site_popup_setting'],$this->pie_post_array['social_site']) and
3010 $option['social_site_popup_setting'] == 1 and
3011 $this->pie_post_array['social_site'] == "true"
3012 )
3013 {
3014 //Redirect will be triggered from js file now
3015 }
3016 else{
3017 wp_safe_redirect($renew_account_url);
3018 }
3019 exit;
3020 }
3021 else
3022 {
3023 $errors->add("login-error",apply_filters("piereg_your_account_is_not_active",esc_html__("Your account is not active","pie-register")));
3024 }
3025 }elseif(empty($active)){
3026 if( $user ) {
3027 wp_set_current_user( $user->ID, $user->user_login );
3028 wp_set_auth_cookie( $user->ID, $remember_user );
3029 do_action( 'wp_login', $user->user_login, $user );
3030 }
3031
3032 do_action('pie_register_after_login',$user);
3033 do_action("piereg_user_login_before_redirect_hook",$user);
3034 $this->afterLoginPage();
3035 exit;
3036 }
3037 else
3038 {
3039 do_action('pie_register_after_login',$user);
3040
3041 // After Validation Show after login page.
3042 $option = get_option(OPTION_PIE_REGISTER);
3043 if(
3044 isset($option['social_site_popup_setting']) and
3045 $option['social_site_popup_setting'] == 1 and
3046 $this->pie_post_array['social_site'] == "true"
3047 )
3048 {
3049 if( $user ) {
3050 wp_set_current_user( $user->ID, $user->user_login );
3051 wp_set_auth_cookie( $user->ID, $remember_user );
3052 do_action( 'wp_login', $user->user_login, $user );
3053 }
3054
3055 do_action("piereg_user_login_before_redirect_hook",$user);
3056 $this->afterLoginPage();
3057 exit;
3058 }
3059 else
3060 {
3061 if( $user ) {
3062 wp_set_current_user( $user->ID, $user->user_login );
3063 wp_set_auth_cookie( $user->ID, $remember_user );
3064 do_action( 'wp_login', $user->user_login, $user );
3065 }
3066
3067 do_action("piereg_user_login_before_redirect_hook",$user);
3068 $this->afterLoginPage();
3069 exit;
3070 }
3071 }
3072 }
3073 }
3074 }
3075 }
3076 }
3077 }
3078 else
3079 {
3080 $errors->add('login-error',apply_filters("piereg_something_went_wrong_msg",__('Something went wrong.','pie-register')));
3081 }
3082 }
3083 function piereg_authentication($log,$pwd){
3084 //authenticate username and password
3085 $authenticate_user = wp_authenticate($log,$pwd);
3086 $option = get_option(OPTION_PIE_REGISTER);
3087
3088 return true;
3089 }
3090 function piereg_delete_authentication(){
3091 global $wpdb;
3092 $table_name = $wpdb->prefix . "pieregister_lockdowns";
3093 $user_ip = sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
3094 $wpdb->query($wpdb->prepare("DELETE FROM `".$table_name."` WHERE `user_ip` = %s AND `attempt_from` = 'is_login'",$user_ip));
3095 if(isset($wpdb->last_error) && !empty($wpdb->last_error)){
3096 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
3097 }
3098 return true;
3099 }
3100 function pie_check_status_on_login($user, $password){
3101 $errors = new WP_Error();
3102 if( ! $user instanceof WP_User ) {
3103 return $user;
3104 }
3105
3106 $status = get_user_meta($user->ID,"active",true);
3107
3108 if($status == "0"){
3109 $message = apply_filters("piereg_your_account_is_not_active",esc_html__("Your account is not active","pie-register"));
3110
3111 return new WP_Error( 'login-error', $message );
3112 }
3113
3114 return $user;
3115 }
3116 function piereg_validate_user_expiry_period_func($user)
3117 {
3118 /*
3119 * Check Payment Addons
3120 */
3121
3122 $is_active = get_user_meta($user->ID,"active",true);
3123 if( ($this->check_enable_payment_method()) == "true" && $is_active == 1)
3124 {
3125 global $wpdb, $wp_session,$errors,$pr_wp_db_prefix;
3126 $datediff = (strtotime(date_i18n("Y-m-d H:m:s"))) - (strtotime($user->data->user_registered)); // current time - registeration time
3127 $datediff = floor($datediff/(86400));//60*60*24 = 86400
3128 $pie_reg = get_option(OPTION_PIE_REGISTER);
3129 $user_id = $user->ID;
3130 $pricing_activation_cycle = 0;
3131 $user_payment_amount = "";
3132 $payment_activation_cycle = 0;
3133
3134 $piereg_pricing_key_number = get_user_meta( $user_id , "piereg_pricing_key_number" , true );
3135 $piereg_pricing_key_number = intval($piereg_pricing_key_number);
3136
3137 $user_registered_form_id = get_user_meta($user_id, "user_registered_form_id" , true);
3138 $piereg_form_pricing_fields = get_option("piereg_form_pricing_fields");
3139 $piereg_use_starting_period = get_user_meta( $user_id , "use_starting_period" );
3140
3141 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)){
3142
3143 $piereg_pricing_fields = $piereg_form_pricing_fields["form_id_".(intval($user_registered_form_id))];
3144
3145 $pricing_for = $piereg_pricing_fields['for'][$piereg_pricing_key_number];
3146 $pricing_for = intval($pricing_for);
3147 $pricing_for_period = $piereg_pricing_fields['for_period'][$piereg_pricing_key_number];
3148
3149 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')){
3150 update_user_meta( $user->ID, 'use_starting_period', date_i18n('Y-m-d H:i:s'));
3151 $errors->add('login-error',esc_html__("Account suspended. Please renew account.","pie-register"));
3152 update_user_meta( $user->ID, 'active', 0);
3153 if((isset($pie_reg['user_enable_user_temp_blocked_notice']) && $pie_reg['user_enable_user_temp_blocked_notice'] == 1) )
3154 $this->wp_mail_send($user->data->user_email,"user_temp_blocked_notice");
3155 if((isset($pie_reg['user_enable_user_renew_temp_blocked_account_notice']) && $pie_reg['user_enable_user_renew_temp_blocked_account_notice'] == 1) )
3156 $this->wp_mail_send($user->data->user_email,'user_renew_temp_blocked_account_notice');
3157 wp_logout();
3158 }
3159 }
3160 else{
3161 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)
3162 {
3163 $payment_activation_cycle = intval($piereg_form_pricing_fields["form_id_".(intval($user_registered_form_id))]['activation_cycle']);
3164 }else{
3165 $payment_activation_cycle = intval($pie_reg['payment_setting_activation_cycle']);
3166 }
3167 }
3168
3169 if( ($payment_activation_cycle) != 0)
3170 {
3171 $notice_period = ((int)$payment_activation_cycle) - ((int)$pie_reg['payment_setting_expiry_notice_days']);
3172 if( $datediff <= ((int)$payment_activation_cycle) )
3173 {
3174 $daysdiff = (intval($payment_activation_cycle) - $datediff);
3175 if($daysdiff <= intval($pie_reg['payment_setting_expiry_notice_days']))
3176 {
3177 $last_date = ( strtotime(date_i18n("Y-m-d H:m:s")) + (86400 * ( ((int)$payment_activation_cycle) - $datediff ) ) );
3178 $last_date = date_i18n("Y-m-d",$last_date);
3179 $email_variable = array();
3180 $email_variable['user_last_date'] = $last_date;
3181 if((isset($pie_reg['user_enable_user_expiry_notice']) && $pie_reg['user_enable_user_expiry_notice'] == 1) )
3182 $this->wp_mail_send($user->data->user_email,"user_expiry_notice","","",$email_variable);
3183 }
3184 }
3185 else
3186 {
3187 $errors->add('login-error',__("Account has been blocked.","pie-register"));
3188 update_user_meta( $user->ID, 'active', 0);
3189 if((isset($pie_reg['user_enable_user_temp_blocked_notice']) && $pie_reg['user_enable_user_temp_blocked_notice'] == 1) )
3190 $this->wp_mail_send($user->data->user_email,"user_temp_blocked_notice");
3191 if((isset($pie_reg['user_enable_user_renew_temp_blocked_account_notice']) && $pie_reg['user_enable_user_renew_temp_blocked_account_notice'] == 1) )
3192 $this->wp_mail_send($user->data->user_email,'user_renew_temp_blocked_account_notice');
3193 wp_logout();
3194
3195 }
3196 }
3197 }
3198 }
3199
3200 //Add the Settings and User Panels
3201 function AddPanel()
3202 {
3203 $update = get_option(OPTION_PIE_REGISTER);
3204
3205 $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 );
3206 add_action('admin_print_scripts-' . $pie_page_suffix_1 , array($this,'pieregister_admin_scripts_styles'));
3207
3208 $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'));
3209 add_action('admin_print_scripts-' . $pie_page_suffix_2 , array($this,'pieregister_admin_scripts_styles'));
3210 add_action('admin_print_scripts-' . $pie_page_suffix_2 , array($this,'pieregister_admin_scripts_styles_about_us_menu'));
3211
3212 do_action("piereg_add_addon_menu_profile_search");
3213
3214 $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') );
3215 add_action('admin_print_scripts-' . $pie_page_suffix_3 , array($this,'pieregister_ck_admin_scripts_styles'));
3216
3217 $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') );
3218 add_action('admin_print_scripts-' . $pie_page_suffix_14 , array($this,'pieregister_ck_admin_scripts_styles'));
3219
3220 $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'));
3221 add_action('admin_print_scripts-' . $pie_page_suffix_9 , array($this,'pieregister_jquery_dialog_script'));
3222
3223 if( is_plugin_active('pie-register-aweber/pie-register-aweber.php') || is_plugin_active('pie-register-mailchimp/pie-register-mailchimp.php') )
3224 {
3225 // Restrict Users by username and ip address
3226 $pie_page_suffix_16 = add_submenu_page( 'pie-register', 'Marketing', esc_html__('Marketing',"pie-register") , 'piereg_manage_cap', 'pie-export-users', array($this, 'PieRegExportUsers'));
3227 add_action('admin_print_scripts-' . $pie_page_suffix_16, array($this,'pieregister_rw_admin_scripts_styles'));
3228 }
3229
3230 if( is_plugin_active('pie-register-bulkemail/pie-register-bulkemail.php') )
3231 {
3232 $addon_BulkEmail_activated = get_option( 'piereg_api_manager_addon_BulkEmail_activated' );
3233
3234 if ($addon_BulkEmail_activated == "Activated")
3235 {
3236 $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'));
3237 add_action('admin_print_scripts-' . $pie_page_suffix_18, array($this,'pieregister_admin_scripts_styles'));
3238 }
3239 }
3240
3241 /*
3242 * Add Add-ons menu in dashboard
3243 */
3244 do_action("piereg_add_addons_menu");
3245
3246 $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') );
3247 add_action('admin_print_scripts-' . $pie_page_suffix_5 , array($this,'pieregister_admin_scripts_styles'));
3248
3249 $pie_page_suffix_6 = add_submenu_page( 'pie-register', 'Attachments', esc_html__('Attachments',"pie-register") , 'piereg_manage_cap', 'pie-attachments', array($this, 'PieRegAttachment') );
3250 add_action('admin_print_scripts-' . $pie_page_suffix_6 , array($this,'pieregister_fu_admin_scripts_styles'));
3251
3252 // Restrict Users by username and ip address
3253 $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'));
3254 add_action('admin_print_scripts-' . $pie_page_suffix_15, array($this,'pieregister_rw_admin_scripts_styles'));
3255
3256 $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'));
3257 add_action('admin_print_scripts-' . $pie_page_suffix_19 , array($this,'pieregister_admin_scripts_styles'));
3258
3259 $pie_page_suffix_17 = add_submenu_page( 'pie-register', 'Settings', esc_html__('Settings',"pie-register") , 'piereg_manage_cap', 'pie-settings', array($this, 'PieRegSettings') );
3260 add_action('admin_print_scripts-' . $pie_page_suffix_17 , array($this,'pieregister_rw_admin_scripts_styles'));
3261
3262 $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'));
3263 add_action('admin_print_scripts-' . $pie_page_suffix_8 , array($this,'pieregister_admin_scripts_styles'));
3264
3265 add_filter('set-screen-option', array($this,'pie_set_option'), 10, 3);
3266 $pie_page_suffix_11 = add_users_page( 'Unverified Users', esc_html__('Unverified Users',"pie-register") , 'edit_users', 'unverified-users', [$this, 'Unverified'] );
3267 add_action('admin_print_scripts-' . $pie_page_suffix_11 , array($this,'pieregister_admin_scripts_styles'));
3268 add_action( "load-$pie_page_suffix_11", array($this,'pie_add_option') );
3269
3270 $pie_page_suffix_12 = add_submenu_page( 'pie-register', 'Help', esc_html__('Help',"pie-register") , 'piereg_manage_cap', 'pie-help', array($this, 'PieRegHelp'));
3271 add_action('admin_print_scripts-' . $pie_page_suffix_12, array($this,'pieregister_admin_scripts_styles'));
3272
3273 // Added since v3.5.4
3274 $this->no_addon_activated = $this->anyAddonActivated();
3275
3276 if( $this->no_addon_activated )
3277 {
3278 $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'));
3279 add_action('admin_print_scripts-' . $pie_page_suffix_14, array($this,'pieregister_admin_scripts_styles_go_pro_menu'));
3280 }
3281
3282 $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'));
3283 add_action('admin_print_scripts-' . $pie_page_suffix_13, array($this,'pieregister_admin_scripts_styles_go_pro_menu'));
3284
3285 $pie_page_suffix_18 = add_submenu_page(
3286 'pie-register',
3287 'About Us',
3288 esc_html__( 'About Us', 'pie-register') , 'piereg_manage_cap', 'pie-about-us', array($this, 'PieAboutUs'));
3289 add_action('admin_print_scripts-' . $pie_page_suffix_18, array($this,'pieregister_admin_scripts_styles_about_us_menu'));
3290 do_action('pie_register_add_menu');
3291 }
3292 function AddPanelOnAdminBar(){
3293 if ( ! $this->has_admin_bar_access() ) {
3294 return;
3295 }
3296
3297 global $wp_admin_bar, $wpdb;
3298
3299 $pieregister_menu = array(
3300 array(
3301 "page" => "pie-register",
3302 "title" => "Manage Forms"
3303 ),
3304 array(
3305 "page" => "pie-notifications",
3306 "title" => "Email Notifications"
3307 ),
3308 array(
3309 "page" => "pie-invitation-codes",
3310 "title" => "Invitation Codes"
3311 ),
3312 array(
3313 "page" => "pie-settings",
3314 "title" => "Settings"
3315 ),
3316 array(
3317 "page" => "pie-help",
3318 "title" => "Help"
3319 ),
3320 array(
3321 "page" => "pie-about-us",
3322 "title" => esc_html__( 'About Us', 'pie-register')
3323 )
3324 );
3325
3326 $wp_admin_bar->add_menu( array(
3327 'id' => 'pie_register',
3328 'title' => esc_html__( 'Pie Register', 'pie-register'),
3329 'href' => get_admin_url().'admin.php?page=pie-register'
3330 ));
3331 foreach($pieregister_menu as $pieregister_menu_items){
3332 $wp_admin_bar->add_menu( array(
3333 'parent' => 'pie_register',
3334 'id' => $pieregister_menu_items['title'],
3335 'title' => $pieregister_menu_items['title'],
3336 'href' => get_admin_url().'admin.php?page='.$pieregister_menu_items['page']
3337 )
3338 );
3339
3340 }
3341
3342 }
3343 function has_admin_bar_access(){
3344
3345 $access = false;
3346
3347 if ( is_user_logged_in() && current_user_can( 'administrator' ) ) {
3348 $access = true;
3349 }
3350
3351 return apply_filters( 'piereg_admin_adminbarmenu_has_access', $access );
3352 }
3353
3354 function pieregister_admin_scripts_styles(){
3355 //$this->pie_admin_enqueu_scripts();
3356 }
3357 function pieregister_admin_scripts_styles_go_pro_menu()
3358 {
3359 $this->pieregister_admin_scripts_styles();
3360 wp_enqueue_style("pie_go_pro_menu_css" );
3361
3362 }
3363 function pieregister_admin_scripts_styles_about_us_menu()
3364 {
3365 wp_enqueue_style("pie_admin_about_us_menu_css" );
3366 wp_enqueue_script("pie_admin_about_us_menu_js" );
3367 $this->pieregister_admin_scripts_styles_slick();
3368
3369 wp_enqueue_style('pie_notification_css');
3370 wp_enqueue_script('pie_notification_js');
3371 }
3372 function pieregister_admin_scripts_styles_slick(){
3373 wp_enqueue_style("pie_admin_about_us_slick_css" );
3374 wp_enqueue_script("pie_admin_about_us_slick_js" );
3375 }
3376 function pieregister_ck_admin_scripts_styles(){
3377 //$this->pie_admin_enqueu_scripts();
3378 //wp_enqueue_editor();
3379 wp_enqueue_script("pie_ckeditor");
3380 }
3381 function pieregister_rw_admin_scripts_styles(){
3382 //$this->pie_admin_enqueu_scripts();
3383 wp_enqueue_style("pie_restrict_widget_css" );
3384 wp_enqueue_script("pie_restrict_widget_script");
3385 }
3386
3387 function pieregister_fu_admin_scripts_styles(){
3388 //$this->pie_admin_enqueu_scripts();
3389 wp_enqueue_style("pie_wload_css" );
3390 wp_enqueue_script("pie_wload_js");
3391 }
3392
3393 function pieregister_jquery_dialog_script(){
3394 wp_enqueue_script('jquery-ui-dialog');
3395 }
3396
3397 function saveFields()
3398 {
3399 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
3400 if(isset($_POST['piereg_reg_form_nonce']) && wp_verify_nonce( $_POST['piereg_reg_form_nonce'], 'piereg_wp_reg_form_nonce' ))
3401 {
3402 if ( isset( $_POST['field']['form']['label'] ) && empty( trim( $_POST['field']['form']['label'] ) ) )
3403 {
3404 $this->pie_post_array['error_message'] = esc_html__("Form title is required.","pie-register");
3405 } else {
3406 $math_cpatcha_enable = "false";
3407 $piereg_startingDate = "1901";
3408 $piereg_endingDate = date_i18n("Y");
3409 $piereg_form_pricing_fields = get_option("piereg_form_pricing_fields");
3410 $piereg_form_pricing_fields_temp = array();
3411
3412 $this->pie_post_array['field'] = $this->piereg_sanitize_post_data( 'piereg_form_builder', ( (isset($_POST['field']) && !empty($_POST['field']))?$_POST['field'] : array() ) );
3413 // var_dump($this->pie_post_array['field']);
3414 foreach($this->pie_post_array['field'] as $k=>$fv){
3415
3416
3417 if( isset($fv['type']) && ($fv['type'] == 'math_captcha')){
3418 $math_cpatcha_enable = "true";
3419 }
3420
3421 if( isset($fv['type']) && ($fv['type'] == 'submit')){
3422 if( isset($fv["redirect_url"]) && !empty($fv["redirect_url"]) ){
3423 $fv["redirect_url"] = preg_replace("/^www./i", "https://", $fv["redirect_url"] );
3424 }
3425 }
3426
3427 if($fv['type'] == "aim" || $fv['type'] == "yim" || $fv['type'] == "jabber" || $fv['type'] == "description"){
3428 $fv['type'] = "default";
3429 }
3430
3431 //since 2.0.12
3432 if( isset($fv['type']) && ($fv['type'] == 'password')){
3433 $meter_label_options = get_option(OPTION_PIE_REGISTER);
3434
3435 $meter_label_options['pass_strength_indicator_label'] = $fv['pass_strength_indicator_label'];
3436 $meter_label_options['pass_very_weak_label'] = $fv['pass_very_weak_label'];
3437 $meter_label_options['pass_weak_label'] = $fv['pass_weak_label'];
3438 $meter_label_options['pass_medium_label'] = $fv['pass_medium_label'];
3439 $meter_label_options['pass_strong_label'] = $fv['pass_strong_label'];
3440 $meter_label_options['pass_mismatch_label'] = $fv['pass_mismatch_label'];
3441
3442 update_option(OPTION_PIE_REGISTER, $meter_label_options );
3443 $this->set_pr_global_options($meter_label_options, OPTION_PIE_REGISTER );
3444 }
3445
3446 if(isset($fv['desc'])) {
3447 $fv['desc'] = $this->sanitize_field_options($fv['desc']);
3448 }
3449
3450 if(isset($fv['label'])) {
3451 $fv['label'] = $this->sanitize_field_options($fv['label']);
3452 }
3453
3454 if(isset($fv['validation_message'])) {
3455 $fv['validation_message'] = $this->sanitize_field_options($fv['validation_message']);
3456 }
3457
3458 if(isset($fv['css'])) {
3459 $fv['css'] = $this->sanitize_field_options($fv['css']);
3460 }
3461
3462 if(isset($fv['default_value'])) {
3463 $fv['default_value'] = $this->sanitize_field_options($fv['default_value']);
3464 }
3465
3466 if(isset($fv['placeholder'])) {
3467 $fv['placeholder'] = $this->sanitize_field_options($fv['placeholder']);
3468 }
3469
3470 if( isset($fv['type']) && ($fv['type'] == 'date')){
3471 $pattern = '/[0-9]{4}/';
3472 $subject = isset($fv['startingDate']) ? $fv['startingDate'] : "";
3473 if(
3474 ( (isset($fv['startingDate']) && strlen($fv['startingDate']) == 4) && preg_match($pattern, $subject))&&
3475 (intval($fv['startingDate']) <= intval($fv['endingDate']))
3476 ){
3477 $fv['startingDate'] = $fv['startingDate'];
3478 $piereg_startingDate = $fv['startingDate'];
3479 }
3480 else{
3481 $fv['startingDate'] = "1901";
3482 $piereg_startingDate = "1900";
3483 }
3484
3485 $subject = isset($fv['endingDate']) ? $fv['endingDate'] : "";
3486 if(
3487 ( (isset($fv['endingDate']) && strlen($fv['endingDate']) == 4) && preg_match($pattern, $subject)) &&
3488 (intval($fv['endingDate']) >= intval($fv['startingDate']))
3489 ){
3490 $fv['endingDate'] = $fv['endingDate'];
3491 $piereg_endingDate = $fv['endingDate'];
3492 }
3493 else{
3494 $fv['endingDate'] = date_i18n("Y");
3495 $piereg_endingDate = date_i18n("Y");
3496 }
3497 }
3498
3499 if(isset($fv['type']) && ($fv['type'] == "pricing" && "not" == "required" ))
3500 {
3501 $piereg_form_pricing_fields_temp = $fv;
3502
3503 foreach($fv['starting_price'] as $starting_price_key=>$starting_price_val)
3504 {
3505 $fv['starting_price'][$starting_price_key] = sprintf('%0.2f', $starting_price_val);
3506 }
3507
3508 foreach($fv['then_price'] as $then_price_key=>$then_price_val)
3509 {
3510 $fv['then_price'][$then_price_key] = sprintf('%0.2f', $then_price_val);
3511 }
3512
3513 }
3514 $updated_post[$k] = $fv;
3515 }
3516 if(!$this->pie_post_array['field'])
3517 $this->pie_post_array['field'] = get_option( 'pie_fields_default' );
3518
3519 do_action("pie_fields_save");
3520 update_option("pie_fields",serialize($updated_post));
3521
3522 /*modify code for multiple registration form*/
3523 if(isset($_POST['form_id']) and intval(base64_decode($_POST['form_id'])) != 0 and isset($_POST['page']) and $_POST['page'] == "edit")
3524 {
3525 $fields_id = intval(base64_decode($_POST['form_id']));
3526
3527 // update fields
3528 update_option("piereg_form_fields_".$fields_id,serialize($updated_post));
3529 $piereg_form_pricing_fields["form_id_".$fields_id] = $piereg_form_pricing_fields_temp;
3530 update_option("piereg_form_pricing_fields",$piereg_form_pricing_fields);
3531
3532 // update user role
3533 $options = get_option(OPTION_PIE_REGISTER);
3534 $options['pie_regis_set_user_role_'.$fields_id] = sanitize_key($_POST['set_user_role_']);
3535 $options['piereg_startingDate_'.$fields_id] = $piereg_startingDate;
3536 $options['piereg_endingDate_'.$fields_id] = $piereg_endingDate;
3537
3538 // sync form fields with profile search forms
3539 $pie_ps_form_id = isset($options['piereg_profile_search_form_id']) ? $options['piereg_profile_search_form_id'] : "";
3540 if(!empty($pie_ps_form_id) && $pie_ps_form_id == $fields_id){
3541
3542 $match_form_fields = array();
3543 foreach($updated_post as $updated_posts){
3544 if( !isset($updated_posts['label']) )
3545 $updated_posts['label'] = "";
3546
3547 if($updated_posts['type'] == 'name'){
3548 $first_name = strtolower(str_replace(' ' , '_', $updated_posts['label']));
3549 $match_form_fields[$first_name.'+:+'.$updated_posts['label']] = $updated_posts['label'];
3550 $last_name = strtolower(str_replace(' ' , '_', $updated_posts['label2']));
3551 $match_form_fields[$last_name.'+:+'.$updated_posts['label']] = $updated_posts['label'];
3552 }elseif($updated_posts['type'] == 'username'){
3553 $username = str_replace(' ' , '_', $updated_posts['type']);
3554 $match_form_fields[$username.'+:+'.$updated_posts['label']] = $updated_posts['label'];
3555 }elseif($updated_posts['type'] == 'email'){
3556 $email = str_replace(' ' , '_', $updated_posts['type']);
3557 $match_form_fields[$email.'+:+'.$updated_posts['label']] = $updated_posts['label'];
3558 }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'){
3559 $other_field = 'pie_'.str_replace(' ' , '_', $updated_posts['type']).'_'.$updated_posts['id'];
3560 $match_form_fields[$other_field.'+:+'.$updated_posts['label']] = $updated_posts['label'];
3561 }
3562 }
3563
3564 foreach($options['piereg_ps_psv_fields_label'] as $ps_fields_array){
3565 if(!empty($ps_fields_array)){
3566 foreach($ps_fields_array as $key_array=>$ps_fields_arr){
3567 foreach($ps_fields_arr as $key=>$ps_fields){
3568 if($key != 'full_name' && $key != 'registered'){
3569 $key_check = $key.'+:+'.$ps_fields;
3570 if(!array_key_exists($key_check, $match_form_fields)){
3571 unset($ps_fields_arr[$key]);
3572 }
3573 }
3574 }
3575 $ps_fields_ar[$key_array] = $ps_fields_arr;
3576 }
3577 }
3578 }
3579
3580 if(!empty($ps_fields_ar)){
3581 if( empty($ps_fields_ar[1]) && array_key_exists(1, $ps_fields_ar) ){
3582 unset($ps_fields_ar[1]);
3583 }elseif( empty($ps_fields_ar[2]) && array_key_exists(2, $ps_fields_ar) ){
3584 unset($ps_fields_ar[2]);
3585 }elseif( empty($ps_fields_ar[3]) && array_key_exists(3, $ps_fields_ar) ){
3586 unset($ps_fields_ar[3]);
3587 }
3588 $ps_fields_a[$pie_ps_form_id] = $ps_fields_ar;
3589 $options['piereg_ps_psv_fields_label'] = $ps_fields_a;
3590 }
3591 }
3592
3593 // Update Wordpress Drefault User Role
3594 update_option(OPTION_PIE_REGISTER,$options);
3595 //update form title
3596 $_field['Id'] = intval( $fields_id );
3597 $_field = get_option("piereg_form_field_option_".$fields_id);
3598 $_field['Title'] = trim( $this->pie_post_array['field']['form']['label'] );
3599 update_option("piereg_form_field_option_".$fields_id,$_field);
3600 }
3601 $this->pie_post_array['success_message'] = esc_html__("Settings Saved","pie-register");
3602 }
3603 }
3604 else{
3605 $this->pie_post_array['error_message'] = esc_html__("Invalid nonce.","pie-register");
3606 }
3607 }
3608
3609 function pieregister_login()
3610 {
3611 $option = get_option(OPTION_PIE_REGISTER);
3612 if($option['allow_pr_edit_wplogin'] == 1){
3613 global $errors;
3614 if (isset($_REQUEST['action'])) :
3615 $action = sanitize_key($_REQUEST['action']);
3616 else :
3617 $action = 'login';
3618 endif;
3619 switch($action) :
3620 case 'lostpassword' :
3621 case 'retrievepassword' :
3622 $this->process_lostpassword();
3623 break;
3624 case 'resetpass' :
3625 case 'rp' :
3626 $this->process_getpassword();
3627 break;
3628 case 'register':
3629 $this->process_register_form();
3630 case 'login':
3631 default:
3632 $this->process_login_form();
3633 break;
3634 endswitch;
3635 exit;
3636 }
3637 return false;
3638 }
3639 function process_register_form()
3640 {
3641
3642 global $errors;
3643
3644 $form = new Registration_form();
3645 $success = '' ;
3646
3647 get_header();
3648 //Printing Success Message
3649 echo wp_kses($this->outputRegForm("true","true"), $this->piereg_forms_get_allowed_tags());
3650 $this->set_pr_stats("register","view");
3651 get_footer();
3652
3653 exit;
3654 }
3655
3656 function check_register_form()
3657 {
3658 global $errors, $wp_session, $piereg_post_array;
3659 $option = get_option(OPTION_PIE_REGISTER);
3660
3661 if( $this->check_enable_payment_method() == "false" )
3662 {
3663 $this->pie_save_registration();
3664 }
3665 else if(($this->check_enable_payment_method()) == "true")
3666 {
3667 $pricing_key_number = 0;
3668 $pricing_payment_amount = 0;
3669 if(isset($_POST['pricing'])){
3670 $piereg_form_pricing_fields = get_option("piereg_form_pricing_fields");
3671 foreach($piereg_form_pricing_fields['form_id_'.intval($_POST['form_id'])]['display'] as $pricing_key=>$pricing_value){
3672 if($pricing_value == $_POST['pricing']){
3673 $pricing_key_number = $pricing_key;
3674 break;
3675 }
3676 }
3677 $pricing_payment_amount = $piereg_form_pricing_fields['form_id_'.intval($_POST['form_id'])]["starting_price"][$pricing_key_number];
3678 }
3679
3680 if(
3681 (isset($_POST['select_payment_method']) and trim($_POST['select_payment_method']) != "" and $_POST['select_payment_method'] != "select")
3682 //|| ($pricing_payment_amount <= 0)
3683 )
3684 {
3685 if((isset($_POST['select_payment_method']) && ($_POST['select_payment_method'] == 'stripe') ) && (isset($_POST['error_stripe']) && $_POST['error_stripe'] != ""))
3686 {
3687 $this->pie_post_array['error'] = sanitize_text_field($_POST['error_stripe']);
3688 }
3689 else if((isset($_POST['select_payment_method']) && ($_POST['select_payment_method'] == 'authorizeNet') ) && (isset($_POST['error_authorizeNet']) && $_POST['error_authorizeNet'] != "") ){
3690 $this->pie_post_array['error'] = sanitize_text_field($_POST['error_authorizeNet']);
3691 }
3692 else {
3693 $this->pie_save_registration();
3694 }
3695 }
3696 else if( isset($_POST['select_payment_method']) && ( empty($_POST['select_payment_method']) || $_POST['select_payment_method'] == "select" ) )
3697 {
3698 $this->pie_post_array['error'] = esc_html__("Please select a payment method","pie-register");
3699 }
3700 else{
3701 $this->pie_save_registration();
3702 }
3703 }
3704 else if(trim($wp_session['payment_error']) != "")
3705 {
3706 $this->pie_post_array['error'] = esc_html__($wp_session['payment_error'],"pie-register");
3707 $wp_session['payment_error'] = "";
3708 $wp_session['payment_success'] = "";
3709 }
3710
3711 $piereg_post_array = $this->pie_post_array;
3712 }
3713 function piereg_generate_username($email = "",$is_generate_username = false,$username_prifex = ""){
3714 if($is_generate_username && !isset($_POST['username']) ){
3715 $username = "";
3716 while(1){
3717 $username = strtolower( ( !empty($username_prifex) ? $username_prifex . "_" : "" ) .wp_generate_password( 7, false, false));
3718 if(!username_exists($username)){
3719 break;
3720 }
3721 }
3722 $_POST['username'] = sanitize_user(trim($username));
3723 }
3724 else if(isset($_POST['e_mail'],$email) && !empty($_POST['e_mail']) && !isset($_POST['username']))
3725 $_POST['username'] = sanitize_email($_POST['e_mail']);
3726 else if(!isset($_POST['username']))
3727 $this->piereg_generate_username("",true);
3728 }
3729 function pie_save_registration()
3730 {
3731
3732 $form_id = 0;
3733
3734 if(isset($_POST['form_id']) && intval($_POST['form_id']) > 0)
3735 {
3736 $form_id = intval($_POST['form_id']);
3737 }
3738 else{
3739 global $errors;
3740 $errors = new WP_Error();
3741 $errors->add("registration-error","Invalid Form");
3742 return false;
3743 }
3744
3745 $this->piereg_generate_username(sanitize_email($_POST['e_mail']), apply_filters("piereg_generate_unique_username",false), apply_filters("piereg_generate_username_with_prifex",false));
3746
3747 add_filter('wp_mail_content_type', array($this,'set_html_content_type'));
3748 global $errors;
3749 $form = new Registration_form($form_id);
3750 $errors = $form->validateRegistration($errors);
3751 $option = get_option(OPTION_PIE_REGISTER);
3752
3753 do_action('pie_register_before_register_validate');
3754
3755 $option_user_verification = $form->piereg_get_verification_type($form->data);
3756
3757 if(sizeof($errors->errors) == 0)
3758 {
3759 do_action('pie_register_after_register_validate');
3760 global $piereg_post_array, $wp_session;
3761
3762 /**
3763 * Since version 3.6.14
3764 * Removed strtolower from $_POST['e_mail']
3765 */
3766
3767 //Inserting User
3768 $pass = isset($_POST['password']) && !empty($_POST['password']) ? html_entity_decode($_POST['password']) : '';
3769 $user_data = array(
3770 'user_pass' => $pass,
3771 'user_login' => sanitize_user($_POST['username']),
3772 'user_email' => sanitize_email($_POST['e_mail']),
3773 'user_registered'=> date_i18n("Y-m-d H:i:s"),
3774 'role' => get_option('default_role')
3775 );
3776
3777 if(isset($_POST['first_name']) && !empty($_POST['first_name']) )
3778 {
3779 $display_name = sanitize_text_field($_POST['first_name']).((isset($_POST['last_name']) && !empty($_POST['last_name']))?" ".sanitize_text_field($_POST['last_name']):"");
3780 $user_data['display_name'] = $display_name;
3781 $user_data['user_nicename'] = $display_name;
3782 }
3783
3784 if(isset($_POST['url']))
3785 {
3786 $user_data["user_url"] = esc_url_raw($_POST['url']);
3787 }
3788
3789 $this->set_pr_stats("register","used");
3790 $user_id = wp_insert_user( $user_data );
3791
3792 $email_user_password = false;
3793
3794 if ( empty($pass) )
3795 {
3796 $email_user_password = true;
3797 update_user_meta( $user_id , "email_user_password" , $email_user_password);
3798 }
3799 /*
3800 * Check Pricing
3801 */
3802 $pricing_user_role = "";
3803 $pricing_key_number = 0;
3804 $pricing_payment_amount = 0;
3805 $pricing_activation_cycle = 0;
3806 $piereg_form_pricing_fields = "";
3807
3808 if(isset($_POST['pricing'])){
3809 $piereg_form_pricing_fields = get_option("piereg_form_pricing_fields");
3810 foreach($piereg_form_pricing_fields['form_id_'.intval($form_id)]['display'] as $pricing_key=>$pricing_value){
3811 if($pricing_value == $_POST['pricing']){
3812 $pricing_key_number = $pricing_key;
3813 break;
3814 }
3815 }
3816 $pricing_user_role = $piereg_form_pricing_fields['form_id_'.intval($form_id)]["role"][$pricing_key_number];
3817 $pricing_payment_amount = $piereg_form_pricing_fields['form_id_'.intval($form_id)]["starting_price"][$pricing_key_number];
3818 $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']) );
3819 }else{
3820 $pricing_payment_amount = $option['payment_setting_amount'];
3821 $pricing_activation_cycle = (isset($option['payment_setting_activation_cycle'])) ? $option['payment_setting_activation_cycle'] : "";
3822 }
3823 /***** End Pricing *****/
3824 $form->addUser($user_id,$form_id);
3825
3826 # If user choose to add in mailchimp list.
3827 if(isset($_POST['checkbox_add_to_mailchimp']) && !empty($_POST['checkbox_add_to_mailchimp']) )
3828 {
3829 update_user_meta( $user_id, 'pie_checkbox_add_to_mailchimp', wp_kses_post($_POST['checkbox_add_to_mailchimp']) );
3830 }
3831
3832 /*
3833 * Update Nickname User Meta
3834 */
3835 if(isset($_POST['first_name']) && !empty($_POST['first_name']) )
3836 {
3837 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']) : "" )) );
3838 }
3839 $new_role = 'subscriber';
3840 if( intval($_POST['form_id']) != 0)
3841 {
3842 $new_role = ($option['pie_regis_set_user_role_'.intval($form_id)]); // Till v3.0.8 using strtolower()
3843 $new_role = ( $new_role != "") ? $new_role : 'subscriber';
3844 $form_options = get_option("piereg_form_field_option_".intval($form_id));
3845 $form_options['Entries'] = intval($form_options['Entries']) + 1;
3846 update_option("piereg_form_field_option_".intval($form_id),$form_options);
3847 unset($form_options);
3848 }
3849 else
3850 {
3851 if(isset($option['pie_regis_set_user_role_']) and trim($option['pie_regis_set_user_role_']) != "")
3852 {
3853 $new_role = strtolower($option['pie_regis_set_user_role_']);
3854 $new_role = ( $new_role != "") ? $new_role : 'subscriber';
3855 }
3856 }
3857 // dropdown_ur
3858 if(isset($_POST['custom_role']) && !empty($_POST['custom_role'])){
3859 $field_options = get_option("pie_fields");
3860 $field_options = maybe_unserialize($field_options);
3861 foreach($field_options as $field_key){
3862 if($field_key['type'] == 'custom_role'){
3863 foreach($field_key['value'] as $key=>$value){
3864 if($value == $_POST['custom_role']){
3865 $new_role = $field_key['role_selection'][ $key];
3866 // update_user_meta($user_id, "custom_role", $new_role);
3867 break;
3868 }
3869 }
3870 break;
3871 }
3872 }
3873 }
3874
3875 /*
3876 * Add Pricing Role
3877 */
3878 $new_role = ( ( isset($pricing_user_role) && !empty($pricing_user_role) ) ? trim($pricing_user_role) : $new_role );
3879 //// update user role using wordpress function
3880 wp_update_user( array ('ID' => $user_id, 'role' => $new_role ) ) ;
3881 update_user_meta( $user_id, "is_social", "false", $unique = false );
3882 update_user_meta( $user_id, "social_site_name", "", $unique = false );
3883 update_user_meta( $user_id, "user_registered_form_id", ((int)$form_id) );
3884 /*
3885 * User Meta for Pricing
3886 */
3887 update_user_meta( $user_id, "piereg_pricing_key_number", $pricing_key_number );
3888 update_user_meta( $user_id, "piereg_pricing_payment_amount", $pricing_payment_amount );
3889 update_user_meta( $user_id, "piereg_pricing_user_role", $pricing_user_role );
3890 update_user_meta( $user_id, "piereg_pricing_activation_cycle", $pricing_activation_cycle );
3891
3892 $user = new WP_User($user_id);
3893
3894 /*
3895 * Add pricing variables in user object
3896 */
3897 $user_array = (array) $user;
3898 $user_array['piereg_pricing']['pricing_key_number'] = $pricing_key_number;
3899 $user_array['piereg_pricing']['pricing_payment_amount'] = $pricing_payment_amount;
3900 $user = (object) $user_array;
3901
3902 do_action('pie_register_after_user_created',$user);
3903
3904 ///////////////////////////////////////////////////
3905 /******** Admin Notification *******/
3906 if($option_user_verification == 0 || $option_user_verification == 2 || $option_user_verification == 4){
3907 $this->send_admin_notifications($option,$user,$pass);
3908 }
3909 ////////////////////////////////////////////////////
3910
3911 // until multiple payment gateways release we use this variable to get away with multiple gateway process
3912 $isPayPalStandard = false;
3913 if( isset($_POST['select_payment_method']) && $_POST['select_payment_method'] == 'PaypalStandard' ) {
3914 $isPayPalStandard = true;
3915 }
3916
3917 if( 'recurring' == 'enable' )
3918 $checkStartPayment = true;
3919 else
3920 $checkStartPayment = false;
3921
3922 if( $isPayPalStandard == false && isset($user_array['piereg_pricing']['pricing_payment_amount']) && floatval($user_array['piereg_pricing']['pricing_payment_amount']) <= 0){
3923 $checkStartPayment = false;
3924 }
3925
3926
3927 /*Goto payment method Like check_payment_method_paypal*/
3928 if( $isPayPalStandard == false && $this->check_enable_payment_method() == "true" && ($checkStartPayment || isset($_POST['select_payment_method']) ) )
3929 {
3930
3931 if( $_POST['select_payment_method'] == "stripe" || $_POST['select_payment_method'] == "authorizeNet"){
3932 update_user_meta( $user_id, 'register_type', "payment_verify");
3933 $_POST['user_id'] = $user_id;
3934 update_user_meta( $user_id, 'active', 0);
3935 /*
3936 * trigger Wordpress "user_register" hook
3937 */
3938
3939 do_action("user_register",$user_id);
3940 do_action("check_payment_method_".sanitize_text_field($_POST['select_payment_method']),$user);// function prefix check_payment_method_
3941
3942 // If payment failed
3943 if(!empty($_POST['error'])) {
3944 $this->pie_post_array['payment_failed'] = 1;
3945 $this->pie_post_array['error'] = sanitize_text_field($_POST['error']);
3946 }
3947
3948 // If payment success
3949 if(!empty($_POST['success'])) $this->pie_post_array['success'] = sanitize_text_field($_POST['success']);
3950
3951 }
3952
3953 if( (($this->check_enable_payment_method()) == "true" and !isset($_POST['select_payment_method']) and isset($_POST['pricing']) ) or
3954 ( isset($_POST['select_payment_method']) and $_POST['select_payment_method'] == "" or $_POST['select_payment_method'] == "select")
3955 )
3956 {
3957 $this->pie_post_array['error'] = esc_html__("Please select a payment method","pie-register");
3958 }
3959 }
3960 else if( $isPayPalStandard == true && (!(empty($option['paypal_butt_id'])) && $option['enable_paypal']==1)
3961 /*&&
3962 ( $option['enable_authorize_net'] != 1 &&
3963 $option['enable_2checkout'] != 1 &&
3964 $option['enable_PaypalPro'] != 1 &&
3965 $option['enable_PaypalExp'] != 1 &&
3966 $option['enable_Skrill'] != 1 )*/
3967 )
3968 {
3969 $_POST['user_id'] = $user_id;
3970 update_user_meta( $user_id, 'active', 0);
3971 update_user_meta( $user_id, 'register_type', "payment_verify");
3972 do_action("user_register",$user_id); // temp
3973
3974 do_action("check_payment_method_paypal",$user);// function prefix check_payment_method_
3975 }
3976 else if($option_user_verification == 1 )//Admin Verification
3977 {
3978 update_user_meta( $user_id, 'active', 0);
3979 $admin_hash = md5( time() );
3980 update_user_meta( $user_id, 'admin_hash', $admin_hash);
3981 update_user_meta( $user_id, 'register_type', "admin_verify");
3982
3983 $this->send_admin_notifications($option,$user,$pass);
3984
3985 $subject = html_entity_decode($option['user_subject_email_admin_verification'],ENT_COMPAT,"UTF-8");
3986 $subject = $this->filterSubject($user,$subject);
3987 $message_temp = "";
3988 if($option['user_formate_email_admin_verification'] == "0"){
3989 $message_temp = nl2br(strip_tags($option['user_message_email_admin_verification']));
3990 }else{
3991 $message_temp = $option['user_message_email_admin_verification'];
3992 }
3993 $message = $form->filterEmail($message_temp,$user);
3994 $from_name = $option['user_from_name_admin_verification'];
3995 $from_email = $option['user_from_email_admin_verification'];
3996 $reply_email = $option['user_to_email_admin_verification'];
3997
3998 //Headers
3999 $headers = 'MIME-Version: 1.0' . "\r\n";
4000 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4001
4002 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL))//Validating From
4003 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
4004 if($reply_email){
4005 $headers .= "Reply-To: {$reply_email}\r\n";
4006 $headers .= "Return-Path: {$reply_email}\r\n";
4007 }else{
4008 $headers .= "Reply-To: {$from_email}\r\n";
4009 $headers .= "Return-Path: {$from_email}\r\n";
4010 }
4011
4012 if((isset($option['user_enable_admin_verification']) && $option['user_enable_admin_verification'] == 1) && !wp_mail(sanitize_email($_POST['e_mail']), $subject, $message , $headers)){
4013 $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__)));
4014 }
4015 $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'));
4016 }
4017
4018 else if($option_user_verification == 2 )//E-Mail Link Verification
4019 {
4020 update_user_meta( $user_id, 'active', 0);
4021 $hash = md5( time() );
4022 update_user_meta( $user_id, 'hash', $hash );
4023 update_user_meta( $user_id, 'register_type', "email_verify");
4024
4025 $subject = html_entity_decode($option['user_subject_email_email_verification'],ENT_COMPAT,"UTF-8");
4026 $subject = $this->filterSubject($user,$subject);
4027 $message_temp = "";
4028 if($option['user_formate_email_email_verification'] == "0"){
4029 $message_temp = nl2br(strip_tags($option['user_message_email_email_verification']));
4030 }else{
4031 $message_temp = $option['user_message_email_email_verification'];
4032 }
4033 $message = $form->filterEmail($message_temp,$user, $pass );
4034 $from_name = $option['user_from_name_email_verification'];
4035 $from_email = $option['user_from_email_email_verification'];
4036 $reply_email = $option['user_to_email_email_verification'];
4037
4038 //Headers
4039 $headers = 'MIME-Version: 1.0' . "\r\n";
4040 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4041
4042
4043 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL))//Validating From
4044 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
4045 if($reply_email){
4046 $headers .= "Reply-To: {$reply_email}\r\n";
4047 $headers .= "Return-Path: {$reply_email}\r\n";
4048 }else{
4049 $headers .= "Reply-To: {$from_email}\r\n";
4050 $headers .= "Return-Path: {$from_email}\r\n";
4051 }
4052
4053 if((isset($option['user_enable_email_verification']) && $option['user_enable_email_verification'] == 1) && !wp_mail(sanitize_email($_POST['e_mail']), $subject, $message , $headers)){
4054 $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__)));
4055 }
4056 $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'));
4057
4058 }
4059
4060 else if($option_user_verification == 0 || $option_user_verification == 4 )//No verification required
4061 {
4062 add_filter( 'send_password_change_email', '__return_false' );
4063 update_user_meta( $user_id, 'active', 1);
4064
4065 $subject = html_entity_decode($option['user_subject_email_default_template'],ENT_COMPAT,"UTF-8");
4066 $subject = $this->filterSubject($user,$subject);
4067 $user_pass = $email_user_password ? apply_filters('piereg_email_random_generated_password', wp_generate_password() ) : "";
4068 if ( !empty($user_pass) )
4069 {
4070 $user_data = array( 'ID' => $user_id, 'user_pass' => trim($user_pass) );
4071 wp_update_user( $user_data );
4072 }
4073 $message_temp = "";
4074 if($option['user_formate_email_default_template'] == "0"){
4075 $message_temp = (strip_tags($option['user_message_email_default_template']));
4076 }else{
4077 $message_temp = $option['user_message_email_default_template'];
4078 }
4079 $message = $form->filterEmail($message_temp,$user, $user_pass );
4080 $from_name = $option['user_from_name_default_template'];
4081 $from_email = $option['user_from_email_default_template'];
4082 $reply_email = $option['user_to_email_default_template'];
4083
4084 //Headers
4085 $headers = 'MIME-Version: 1.0' . "\r\n";
4086 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4087
4088 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL)){//Validating From
4089 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
4090 }
4091 if($reply_email){
4092 $headers .= "Reply-To: {$reply_email}\r\n";
4093 $headers .= "Return-Path: {$reply_email}\r\n";
4094 }else{
4095 $headers .= "Reply-To: {$from_email}\r\n";
4096 $headers .= "Return-Path: {$from_email}\r\n";
4097 }
4098
4099 if((isset($option['user_enable_default_template']) && $option['user_enable_default_template'] == 1) && !wp_mail(sanitize_email($_POST['e_mail']), $subject, $message , $headers)){
4100 $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__)));
4101 }
4102
4103 }
4104
4105 if( !isset($this->pie_post_array['payment_failed']) )
4106 {
4107 /*
4108 * trigger Wordpress "user_register" hook
4109 */
4110 do_action("user_register",$user->ID);
4111 do_action('pie_register_after_register',$user);
4112 /*
4113 * User Verification and payment methods are off then Trigger Login After Registration Hook
4114 */
4115
4116 if( ( $option_user_verification == 0 || $option_user_verification == 4 ) && $this->check_enable_payment_method() == "false" ){
4117 do_action('pie_register_login_after_registration',$user);
4118 }
4119 }
4120 $fields = maybe_unserialize(get_option("pie_fields"));
4121 $confirmation_type = $form->data['submit']['confirmation'];
4122
4123 if( isset($wp_session['payment_error']) && trim($wp_session['payment_error']) != "")
4124 {
4125 $this->pie_post_array['error'] = esc_html__($wp_session['payment_error'],"pie-register");
4126 $wp_session['payment_error'] = "";
4127 $wp_session['payment_success'] = "";
4128 }
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 }
4132 else if( isset($wp_session['payment_success']) && trim($wp_session['payment_success']) != "")
4133 {
4134 $this->pie_post_array['registration_success'] = apply_filters("piereg_payment_success",esc_html__($wp_session['payment_success'],"pie-register"));
4135 $wp_session['payment_error'] = "";
4136 $wp_session['payment_success'] = "";
4137 }
4138 else if($confirmation_type == "" || $confirmation_type == "text" )
4139 {
4140 if(empty($this->pie_post_array['registration_success']))
4141 {
4142 $email_user_password = get_user_meta( $user_id , "email_user_password" , true);
4143 if( $email_user_password == '1' )
4144 {
4145 $this->pie_post_array['registration_success'] = esc_html__("Thank you for registering. Password has been emailed to you.","pie-register");
4146 }else{
4147 $this->pie_post_array['registration_success'] = stripcslashes(esc_html__($form->data['submit']['message'],"pie-register"));
4148 }
4149
4150 }
4151 }
4152 else if($confirmation_type == "page")
4153 {
4154 wp_safe_redirect(get_permalink($form->data['submit']['page']));
4155 exit;
4156 }
4157 else if($confirmation_type == "redirect")
4158 {
4159 wp_redirect(esc_url_raw($form->data['submit']['redirect_url']));
4160 exit;
4161 }
4162 else
4163 {
4164 if(empty($this->pie_post_array['registration_success']))
4165 $this->pie_post_array['registration_success'] = stripcslashes(esc_html__($form->data['submit']['message'],"pie-register"));
4166 }
4167
4168 $piereg_post_array = $this->pie_post_array;
4169 }
4170 }
4171
4172 function send_admin_notifications($option,$user,$pass){
4173 $is_allowed = true;
4174 $is_allowed = apply_filters('piereg_check_email_allowed_to_send', $is_allowed, $user);
4175
4176 /******** Admin Notification *******/
4177 if( $option['enable_admin_notifications']=="1" && $is_allowed && isset($_POST['pie_submit']) )
4178 {
4179 $message_temp = "";
4180 if($option['admin_message_email_formate'] == "0"){
4181 $message_temp = (strip_tags($option['admin_message_email']));
4182 }else{
4183 $message_temp = $option['admin_message_email'];
4184 }
4185 $message = $this->filterEmail($message_temp,$user,$pass);
4186 $subject = html_entity_decode($option['admin_subject_email'],ENT_COMPAT,"UTF-8");
4187 $subject = $this->filterSubject($user,$subject);
4188 $to = trim($option['admin_sendto_email']); // values can be comma seperated.
4189 $from_name = trim($option['admin_from_name']);
4190 $from_email = trim($option['admin_from_email']);
4191 $bcc = trim($option['admin_bcc_email']);
4192 $reply_to_email = trim($option['admin_to_email']);
4193
4194 if(empty($to))//if not valid email address then use wordpress default admin
4195 {
4196 $to = get_option('admin_email');
4197 }
4198
4199 //Headers
4200 $headers = "MIME-Version: 1.0" . "\r\n";
4201 $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
4202
4203 if(!empty($from_email))//Validating From
4204 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
4205
4206 if(!empty($bcc))//Validating BCC
4207 $headers .= "Bcc: " . $bcc . " \r\n";
4208
4209 if(!empty($reply_to_email))//Validating Reply To
4210 $headers .= "Reply-To: <".$reply_to_email."> \r\n";
4211
4212 if($reply_to_email)
4213 $headers .= "Return-Path: ".$reply_to_email." \r\n";
4214 else
4215 $headers .= "Return-Path: ".$from_email." \r\n";
4216
4217 do_action("piereg_action_before_admin_notify_email", $option, $user); # newlyAddedHookFilter
4218 if(!wp_mail($to,$subject, $message,$headers)){
4219 $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__)));
4220 }
4221 }
4222 elseif($option['enable_admin_notifications_profile_update']=="1" && $is_allowed && isset($_POST['pie_submit_update']) )
4223 {
4224 global $profile_updated;
4225 if ( $profile_updated == 1 )
4226 {
4227 $message_temp = "";
4228 if($option['admin_message_email_formate_profile_update'] == "0"){
4229 $message_temp = (strip_tags($option['admin_message_email_profile_update']));
4230 }else{
4231 $message_temp = $option['admin_message_email_profile_update'];
4232 }
4233 $message = $this->filterEmail($message_temp,$user,$pass);
4234 $subject = html_entity_decode($option['admin_subject_email_profile_update'],ENT_COMPAT,"UTF-8");
4235 $subject = $this->filterSubject($user,$subject);
4236 $to = trim($option['admin_sendto_email_profile_update']); // values can be comma seperated.
4237 $from_name = trim($option['admin_from_name_profile_update']);
4238 $from_email = trim($option['admin_from_email_profile_update']);
4239 $bcc = trim($option['admin_bcc_email_profile_update']);
4240 $reply_to_email = trim($option['admin_to_email_profile_update']);
4241
4242 if(empty($to))//if not valid email address then use wordpress default admin
4243 {
4244 $to = get_option('admin_email');
4245 }
4246
4247 //Headers
4248 $headers = "MIME-Version: 1.0" . "\r\n";
4249 $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
4250
4251 if(!empty($from_email))//Validating From
4252 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
4253
4254 if(!empty($bcc))//Validating BCC
4255 $headers .= "Bcc: " . $bcc . " \r\n";
4256
4257 if(!empty($reply_to_email))//Validating Reply To
4258 $headers .= "Reply-To: <".$reply_to_email."> \r\n";
4259
4260 if($reply_to_email)
4261 $headers .= "Return-Path: ".$reply_to_email." \r\n";
4262 else
4263 $headers .= "Return-Path: ".$from_email." \r\n";
4264
4265 do_action("piereg_action_before_admin_notify_email", $option, $user); # newlyAddedHookFilter
4266 if(!wp_mail($to,$subject, $message,$headers)){
4267 $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__)));
4268 }
4269 }
4270 }
4271 }
4272
4273 function check_payment_method_paypal($user)
4274 {
4275 $user_id = intval($_POST['user_id']);
4276 $user_email = sanitize_email($_POST['e_mail']);
4277 add_filter( 'wp_mail_content_type', array($this,'set_html_content_type' ));
4278 global $errors;
4279 $form = new Registration_form();
4280 $errors = $form->validateRegistration($errors);
4281 $option = get_option(OPTION_PIE_REGISTER);
4282
4283 update_user_meta( $user_id, 'active', 0);
4284 $hash = md5( time() );
4285 update_user_meta( $user_id, 'hash', $hash );
4286
4287 $subject = html_entity_decode($option['user_subject_email_pending_payment'],ENT_COMPAT,"UTF-8");
4288 $subject = $this->filterSubject($user_email,$subject);
4289 $message_temp = "";
4290 if($option['user_formate_email_pending_payment'] == "0"){
4291 $message_temp = nl2br(strip_tags($option['user_message_email_pending_payment']));
4292 }else{
4293 $message_temp = $option['user_message_email_pending_payment'];
4294 }
4295
4296 $message = $form->filterEmail($message_temp,$user_email);
4297 $from_name = $option['user_from_name_pending_payment'];
4298 $from_email = $option['user_from_email_pending_payment'];
4299 $reply_email = $option['user_to_email_pending_payment'];
4300
4301 //Headers
4302 $headers = 'MIME-Version: 1.0' . "\r\n";
4303 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4304
4305 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL))//Validating From
4306 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
4307 if($reply_email){
4308 $headers .= "Reply-To: {$reply_email}\r\n";
4309 $headers .= "Return-Path: {$reply_email}\r\n";
4310 }else{
4311 $headers .= "Reply-To: {$from_email}\r\n";
4312 $headers .= "Return-Path: {$from_email}\r\n";
4313 }
4314
4315 if( (isset($option['user_enable_pending_payment']) && $option['user_enable_pending_payment'] == 1) && !wp_mail(sanitize_email($_POST['e_mail']), $subject, $message , $headers)){
4316 $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__)));
4317 }
4318
4319 update_user_meta( $user_id, 'register_type', "payment_verify");
4320 $paypal_url = "https://www.paypal.com/cgi-bin/webscr";
4321 if($option['paypal_sandbox']=="no")
4322 {
4323 $paypal_url = "https://www.paypal.com/cgi-bin/webscr";
4324
4325 }
4326 else
4327 {
4328 $paypal_url = "https://sandbox.paypal.com/cgi-bin/webscr";
4329 }
4330
4331 $nvpStr = "?cmd=_s-xclick&hosted_button_id=".trim($option['paypal_butt_id']).
4332 "&custom=".$hash.'__'.$user_id.
4333 "&bn=Genetech_SI_Custom".
4334 "&cancel_return=".urlencode( trailingslashit(get_bloginfo("url")).'?action=payment_cancel&paypal='.base64_encode($user_id) ).
4335 "&notify_url=".urlencode( trailingslashit(get_bloginfo("url")).'?action=ipn_success&paypal='.base64_encode( $hash.'|'.$user_id ) );
4336
4337 wp_redirect(esc_url_raw($paypal_url.$nvpStr));
4338 exit;
4339 }
4340
4341 function process_lostpassword()
4342 {
4343 global $errors ;
4344 if( file_exists(PIEREG_DIR_NAME . "/forgot_password.php") )
4345 include_once("forgot_password.php");
4346 get_header();
4347 $this->set_pr_stats("forgot","view");
4348
4349 $output = pieResetFormOutput();
4350 echo wp_kses( $output, $this->piereg_forms_get_allowed_tags() );
4351 get_footer();
4352 exit;
4353 }
4354 function process_getpassword()
4355 {
4356 global $errors ;
4357 $user = check_password_reset_key(sanitize_text_field($_GET['key']), sanitize_user($_GET['login']));
4358 if ( is_wp_error($user) )
4359 {
4360 wp_safe_redirect( site_url('wp-login.php?action=lostpassword&error=invalidkey') );
4361 exit;
4362 }
4363
4364 get_header();
4365 if( file_exists(PIEREG_DIR_NAME . "/get_password.php") )
4366 include_once("get_password.php");
4367 /*$get_form = piereg_get_passwird();
4368 echo $get_form;*/
4369 get_footer();
4370 exit;
4371 }
4372
4373 function pie_add_option() {
4374
4375 $option = 'per_page';
4376 $args = array(
4377 'label' => 'Number of items per page:',
4378 'default' => 10,
4379 'option' => 'pie_users_per_page'
4380 );
4381
4382 add_screen_option( $option, $args );
4383
4384 }
4385 function pie_set_option($status, $option, $value) {
4386 if ( 'pie_users_per_page' == $option ) return $value;
4387 return $status;
4388
4389 }
4390 function Unverified(){
4391
4392 if( file_exists(PIEREG_DIR_NAME."/classes/unverified_pagination.php") )
4393 include_once( PIEREG_DIR_NAME."/classes/unverified_pagination.php");
4394
4395 if( isset($this->pie_post_array['notice']) && !empty($this->pie_post_array['notice']) )
4396 echo '<div id="message" class="updated fade"><p><strong>' . wp_kses_post($this->pie_post_array['notice']) . '.</strong></p></div>';
4397 if( isset($this->pie_post_array['error_message']) && !empty($this->pie_post_array['error_message']) )
4398 echo '<div id="error" class="error fade"><p><strong>' . wp_kses_post($this->pie_post_array['error_message']) . '.</strong></p></div>';
4399
4400 $unverified_list = new Pie_Unverfied_users_Table();
4401 echo '<div class="wrap"><h2>'.__('Unverified Users', 'pie-register').'</h2>';
4402
4403 if( isset($_POST['s']) ){
4404 $unverified_list->prepare_items(sanitize_text_field($_POST['s']));
4405 } else {
4406 $unverified_list->prepare_items();
4407 }
4408
4409 ?>
4410 <form method="post" id="pie-unverified-users">
4411 <input type="hidden" name="page" value="unverified-users">
4412 <?php
4413 $unverified_list->search_box( 'search', 'search_id' );
4414 $unverified_list->display();
4415 echo '</form></div>';
4416 }
4417
4418 function verifyUsers()
4419 {
4420 add_filter( 'send_password_change_email', '__return_false' );
4421 $valid = isset($_POST['vusers']) ? array_map( 'sanitize_key', $_POST['vusers'] ) : "";
4422 if($valid)
4423 {
4424 $option = get_option(OPTION_PIE_REGISTER);
4425 foreach( $valid as $user_id )
4426 {
4427 if ( $user_id )
4428 {
4429 global $wpdb;
4430
4431 $register_type = get_user_meta( $user_id , "register_type" , true);
4432 $email_user_password = get_user_meta( $user_id , "email_user_password" , true);
4433 $invite_code = get_user_meta( $user_id , "invite_code" , true);
4434
4435 if($register_type == "admin_email_verify")
4436 {
4437 if ( !$this->InvCodeExpired($user_id) )
4438 {
4439 $user = new WP_User($user_id);
4440 $user_email = $user->user_email;
4441
4442 update_user_meta( $user_id, 'active', 0);
4443 $hash = md5( time() );
4444 update_user_meta( $user_id, 'hash', $hash );
4445 update_user_meta( $user_id, 'admin_hash',"");
4446 update_user_meta( $user_id, 'register_type', "email_verify");
4447
4448 $subject = html_entity_decode($option['user_subject_email_email_verification'],ENT_COMPAT,"UTF-8");
4449 $subject = $this->filterSubject($user_email,$subject);
4450 $message_temp = "";
4451 if($option['user_formate_email_email_verification'] == "0"){
4452 $message_temp = nl2br(strip_tags($option['user_message_email_email_verification']));
4453 }else{
4454 $message_temp = $option['user_message_email_email_verification'];
4455 }
4456 $message = $this->filterEmail($message_temp,$user_email );
4457 $from_name = $option['user_from_name_email_verification'];
4458 $from_email = $option['user_from_email_email_verification'];
4459 $reply_email = $option['user_to_email_email_verification'];
4460
4461 //Headers
4462 $headers = 'MIME-Version: 1.0' . "\r\n";
4463 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4464
4465
4466 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL))//Validating From
4467 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
4468 if($reply_email){
4469 $headers .= "Reply-To: {$reply_email}\r\n";
4470 $headers .= "Return-Path: {$reply_email}\r\n";
4471 }else{
4472 $headers .= "Reply-To: {$from_email}\r\n";
4473 $headers .= "Return-Path: {$from_email}\r\n";
4474 }
4475 if((isset($option['user_enable_email_verification']) && $option['user_enable_email_verification'] == 1) && !wp_mail($user_email, $subject, $message , $headers)){
4476 $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__)));
4477 }
4478 $this->pie_post_array['notice'] = esc_html__("User(s) activated");
4479 } else {
4480 $this->pie_post_array['error'] = esc_html__("Invitation code has expired", "pie-register");
4481 }
4482 }else{
4483 if ( !$this->InvCodeExpired($user_id) )
4484 {
4485 update_user_meta( $user_id, 'active',1);
4486 update_user_meta( $user_id, 'admin_hash',"");
4487
4488 //Sending E-Mail to newly active user
4489 $user = new WP_User($user_id);
4490 $subject = html_entity_decode($option['user_subject_email_email_thankyou'],ENT_COMPAT,"UTF-8");
4491 $subject = $this->filterSubject($user,$subject);
4492 $user_email = $user->user_email;
4493 $user_pass = $email_user_password == "1" ? apply_filters('piereg_email_random_generated_password', wp_generate_password() ) : "";
4494 if ( !empty($user_pass) )
4495 {
4496 $user_data = array( 'ID' => $user_id, 'user_pass' => trim($user_pass) );
4497 wp_update_user( $user_data );
4498 }
4499 $message_temp = "";
4500 if($option['user_formate_email_email_thankyou'] == "0"){
4501 $message_temp = nl2br(strip_tags($option['user_message_email_email_thankyou']));
4502 }else{
4503 $message_temp = $option['user_message_email_email_thankyou'];
4504 }
4505
4506 $message = $this->filterEmail($message_temp,$user_email,$user_pass);
4507 $from_name = $option['user_from_name_email_thankyou'];
4508 $from_email = $option['user_from_email_email_thankyou'];
4509 $reply_email = $option['user_to_email_email_thankyou'];
4510
4511 //Headers
4512 $headers = 'MIME-Version: 1.0' . "\r\n";
4513 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4514
4515 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL))//Validating From
4516 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
4517
4518 if($reply_email){
4519 $headers .= "Reply-To: {$reply_email}\r\n";
4520 $headers .= "Return-Path: {$reply_email}\r\n";
4521 }else{
4522 $headers .= "Reply-To: {$from_email}\r\n";
4523 $headers .= "Return-Path: {$from_email}\r\n";
4524 }
4525 if((isset($option['user_enable_email_thankyou']) && $option['user_enable_email_thankyou'] == 1) && !wp_mail($user_email, $subject, $message , $headers)){
4526 $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__)));
4527 }
4528 if ( !empty($invite_code) )
4529 {
4530 $prefix = $wpdb->prefix."pieregister_";
4531 $codetable = $prefix."code";
4532 $codeDetails = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $codetable where BINARY name = %s and status = %d", $invite_code, 1) );
4533
4534 if ( !empty($codeDetails) )
4535 {
4536 $times_used = intval($codeDetails[0]->count);
4537 $usage = intval($codeDetails[0]->code_usage);
4538
4539 if( (($times_used < $usage) && ($usage != 0)) || $usage == 0 )
4540 {
4541 $codes = $wpdb->query( $wpdb->prepare("update $codetable set count = count + 1 where BINARY name = %s and status = %d", $invite_code, 1) );
4542 }
4543 }
4544 }
4545 // mailchimp related code within PR
4546 do_action('pireg_after_verification_users', $user);
4547 $this->pie_post_array['notice'] = esc_html__("User(s) activated");
4548 } else {
4549 $this->pie_post_array['error'] = esc_html__("Invitation code has expired", "pie-register");
4550 }
4551 }
4552 }
4553 }
4554 }
4555 else
4556 $this->pie_post_array['notice'] = "<strong>".__('error','pie-register').":</strong>".__("Please select user(s) to send email.", "pie-register");
4557
4558 if(isset( $this->pie_post_array['notice'] ) && !empty( $this->pie_post_array['notice'] ))
4559 echo '<div id="message" class="updated fade"><p><strong>' . esc_html($this->pie_post_array['notice']) . '.</strong></p></div>';
4560 if( isset($this->pie_post_array['error']) && !empty( $this->pie_post_array['error'] ) )
4561 echo '<div id="error" class="error fade msg_belowheading"><p><strong>' . esc_html($this->pie_post_array['error']) . "</strong></p></div>";
4562 }
4563 function InvCodeExpired($user_id)
4564 {
4565 global $wpdb;
4566
4567 $invite_code = get_user_meta( $user_id , "invite_code" , true);
4568 $code_ended = false;
4569 if ( !empty($invite_code) )
4570 {
4571 $prefix = $wpdb->prefix."pieregister_";
4572 $codetable = $prefix."code";
4573 $codeDetails = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $codetable where BINARY name = %s and status = %d", $invite_code, 1) );
4574
4575 if ( !empty($codeDetails) )
4576 {
4577 $times_used = intval($codeDetails[0]->count);
4578 $usage = intval($codeDetails[0]->code_usage);
4579
4580 if( (($times_used < $usage) && ($usage != 0)) || $usage == 0 )
4581 {
4582 $code_ended = false;
4583 } else {
4584 $code_ended = true;
4585 }
4586 }
4587 }
4588 return $code_ended;
4589 }
4590 function PaymentLink()
4591 {
4592 global $wpdb;
4593 $valid = isset($_POST['vusers']) ? array_map( 'sanitize_key', $_POST['vusers'] ) : "";
4594 add_filter( 'wp_mail_content_type', array($this,'set_html_content_type' ));
4595 if( is_array($valid))
4596 {
4597
4598 $option = get_option(OPTION_PIE_REGISTER);
4599 $sent = 0;
4600 foreach( $valid as $user_id )
4601 {
4602 $reg_type = get_user_meta($user_id, 'register_type');
4603 if($reg_type[0] != "payment_verify")
4604 {
4605 continue;
4606 }
4607 $sent++;
4608 update_user_meta( $user_id, 'active', 0);
4609 $hash = md5( time() );
4610 update_user_meta( $user_id, 'hash', $hash );
4611
4612
4613 $user = new WP_User($user_id);
4614 $subject = html_entity_decode($option['user_subject_email_pending_payment_reminder'],ENT_COMPAT,"UTF-8");
4615 $subject = $this->filterSubject($user->user_email,$subject);
4616 $message_temp = "";
4617 if($option['user_formate_email_pending_payment_reminder'] == "0"){
4618 $message_temp = nl2br(strip_tags($option['user_message_email_pending_payment_reminder']));
4619 }else{
4620 $message_temp = $option['user_message_email_pending_payment_reminder'];
4621 }
4622
4623 $message = $this->filterEmail($message_temp,$user->user_email );
4624 $from_name = $option['user_from_name_pending_payment_reminder'];
4625 $from_email = $option['user_from_email_pending_payment_reminder'];
4626 $reply_email = $option['user_to_email_pending_payment_reminder'];
4627
4628
4629 //Headers
4630 $headers = 'MIME-Version: 1.0' . "\r\n";
4631 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4632
4633 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL))//Validating From
4634 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
4635 if($reply_email){
4636 $headers .= "Reply-To: {$reply_email}\r\n";
4637 $headers .= "Return-Path: {$reply_email}\r\n";
4638 }else{
4639 $headers .= "Reply-To: {$from_email}\r\n";
4640 $headers .= "Return-Path: {$from_email}\r\n";
4641 }
4642 if((isset($option['user_enable_pending_payment_reminder']) && $option['user_enable_pending_payment_reminder'] == 1) && !wp_mail($user->user_email, $subject, $message , $headers)){
4643 $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__)));
4644 }
4645 }
4646 if($sent > 0)
4647 $this->pie_post_array['notice'] = esc_html__("Payment link sent via email", "pie-register");
4648 else
4649 $this->pie_post_array['notice'] = esc_html__("Invalid User Types", "pie-register");
4650
4651 }
4652 else
4653 {
4654 $this->pie_post_array['notice'] = "<strong>".esc_html__('error','pie-register').":</strong>".esc_html__("Please select user(s) to send email.", "pie-register");
4655 }
4656 }
4657 function AdminEmailValidate()
4658 {
4659 global $wpdb;
4660 $valid = isset($_POST['vusers']) ? array_map( 'sanitize_key', $_POST['vusers'] ) : "";
4661 add_filter( 'wp_mail_content_type', array($this,'set_html_content_type' ));
4662 if( is_array($valid) )
4663 {
4664 $option = get_option(OPTION_PIE_REGISTER);
4665 $sent = 0;
4666 foreach( $valid as $user_id )
4667 {
4668 $reg_type = get_user_meta($user_id, 'register_type');
4669 if($reg_type[0] != "email_verify")
4670 {
4671 continue;
4672 }
4673 $sent ++;
4674 update_user_meta( $user_id, 'active', 0);
4675 $hash = md5( time() );
4676 update_user_meta( $user_id, 'hash', $hash );
4677
4678 $user = new WP_User($user_id);
4679 $subject = html_entity_decode($option['user_subject_email_email_verification_reminder'],ENT_COMPAT,"UTF-8");
4680 $subject = $this->filterSubject($user,$subject);
4681 $message_temp = "";
4682 if($option['user_formate_email_email_verification_reminder'] == "0"){
4683 $message_temp = nl2br(strip_tags($option['user_message_email_email_verification_reminder']));
4684 }else{
4685 $message_temp = $option['user_message_email_email_verification_reminder'];
4686 }
4687
4688 $message = $this->filterEmail($message_temp,$user->user_email );
4689
4690 $from_name = $option['user_from_name_email_verification_reminder'];
4691 $from_email = $option['user_from_email_email_verification_reminder'];
4692 $reply_email = $option['user_to_email_email_verification_reminder'];
4693
4694 //Headers
4695 $headers = 'MIME-Version: 1.0' . "\r\n";
4696 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
4697
4698 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL))//Validating From
4699 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
4700 if($reply_email){
4701 $headers .= "Reply-To: {$reply_email}\r\n";
4702 $headers .= "Return-Path: {$reply_email}\r\n";
4703 }else{
4704 $headers .= "Reply-To: {$from_email}\r\n";
4705 $headers .= "Return-Path: {$from_email}\r\n";
4706 }
4707
4708 if((isset($option['user_enable_email_verification_reminder']) && $option['user_enable_email_verification_reminder'] == 1) && !wp_mail($user->user_email, $subject, $message , $headers)){
4709 $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__)));
4710 }
4711 }
4712 if($sent > 0)
4713 $this->pie_post_array['notice'] = esc_html__("Verification Emails have been re-sent", "pie-register");
4714 else
4715 $this->pie_post_array['notice'] = esc_html__("Invalid User Types", "pie-register");
4716 }
4717 else
4718 $this->pie_post_array['notice'] = "<strong>".esc_html__('error','pie-register').":</strong>".esc_html__("Please select user(s) to send email.", "pie-register");
4719 }
4720 function AdminDeleteUnvalidated()
4721 {
4722 global $wpdb;
4723
4724 $piereg = get_option(OPTION_PIE_REGISTER);
4725 $valid = isset($_POST['vusers']) ? array_map( 'sanitize_key', $_POST['vusers'] ) : "";
4726 if($valid)
4727 {
4728 include_once( $this->admin_path . 'includes/user.php' );
4729 foreach( $valid as $user_id )
4730 {
4731 if ( $user_id )
4732 {
4733 do_action("piereg_before_deleting_user_unverified_list", $user_id); # newlyAddedHookFilter - runs before user is deleted from the unverified users' list
4734 wp_delete_user($user_id);
4735 }
4736 }
4737 $this->pie_post_array['notice'] = esc_html__("User(s) deleted");
4738 }
4739 }
4740 function cleantext($text)
4741 {
4742 foreach($text as $key => $value){
4743
4744 if( is_array( $value ) ) {
4745 $this->cleantext($value);
4746 continue;
4747 }
4748
4749 $text[$key] = str_replace(chr(13), " ", $value); //remove carriage returns
4750 $text[$key] = str_replace(chr(10), " ", $value);
4751 }
4752
4753 return $text;
4754 }
4755 function disable_magic_quotes_gpc(&$value)
4756 {
4757 $value = stripslashes($value);
4758 return $value;
4759 }
4760
4761 function PieRegSettings()
4762 {
4763 if( isset($_GET['subtab']) && $_GET['subtab'] == 'role-based' )
4764 $this->PieRegRedirectSettingsAction();
4765
4766 $option = get_option(OPTION_PIE_REGISTER);
4767 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegSettings.php');
4768 }
4769 function PieRegPaymentGateway()
4770 {
4771 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegPaymentGateway.php');
4772 }
4773 function PieRegAttachment()
4774 {
4775 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegAttachment.php');
4776 }
4777 function PieRegNotifications()
4778 {
4779 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegNotifications.php');
4780 }
4781 function PieRegImportExport()
4782 {
4783 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegImportExport.php');
4784 }
4785 function PieRegHelp()
4786 {
4787 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegHelp.php');
4788 }
4789 function PieRegProFeatures()
4790 {
4791 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegProFeatures.php');
4792 }
4793 function PieAboutUs()
4794 {
4795 do_action( 'piereg_admin_pages_before_content' );
4796 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieAboutUs.php');
4797 }
4798 function PieRegRestrictUsers()
4799 {
4800 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegRestrictUsers.php');
4801 }
4802
4803 /**
4804 * PieRegCustomRoles function
4805 * Description: Create custom user roles.
4806 * Since v3.5.4
4807 */
4808 function PieRegCustomRoles()
4809 {
4810 if( isset($_POST['piereg_user_role_nonce']) || isset($_POST['piereg_user_role_delete_nonce']) )
4811 {
4812 $this->pie_post_array = $this->piereg_sanitize_post_data( 'piereg_user_role', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
4813
4814 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' ))
4815 {
4816 global $wpdb;
4817 $custom_role_table_name = $wpdb->prefix."pieregister_custom_user_roles";
4818
4819 if(isset($this->pie_post_array['role_del_id'])){
4820 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
4821 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' ))
4822 {
4823 if($wpdb->query( $wpdb->prepare("DELETE FROM ".$custom_role_table_name." WHERE id = %d", $this->pie_post_array['role_del_id']) )){
4824 $this->pie_post_array['notice'] = esc_html__("The Role has been deleted","pie-register");
4825 remove_role( $this->pie_post_array['role_del_key']);
4826 }
4827 else{
4828 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
4829 }
4830 }else{
4831 $this->pie_post_array['error'] = esc_html__("Invalid nonce.","pie-register");
4832 }
4833
4834 }
4835 }else{
4836 $this->pie_post_array['error'] = esc_html__("Invalid nonce.","pie-register");
4837 }
4838 }
4839
4840 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegCustomRoles.php');
4841 }
4842 function PieRegExportUsers()
4843 {
4844 $this->pieregister_fu_admin_scripts_styles();
4845 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegExportUsers.php');
4846 }
4847 function PieRegBulkEmail()
4848 {
4849 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegBulkEmail.php');
4850 }
4851 function PieRegNewForm()
4852 {
4853 wp_enqueue_style('pie_notification_css');
4854 wp_enqueue_script('pie_notification_js');
4855 do_action( 'piereg_admin_pages_before_content' );
4856 $this->pieregister_admin_scripts_styles_slick();
4857 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegRegistrationForm.php');
4858 }
4859 //Opening Form Editor
4860 function RegPlusEditForm(){
4861 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegEditForm.php');
4862 }
4863
4864 function PieRegSettingsProcess() {
4865 $update = get_option(OPTION_PIE_REGISTER);
4866 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
4867
4868 if(isset($_POST['piereg_settings_allusers']) && wp_verify_nonce( $_POST['piereg_settings_allusers'], 'piereg_wp_settings_allusers' )) {
4869
4870 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_settings_allusers', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
4871 $pie_pages = get_option("pie_pages");
4872
4873 $update['alternate_login'] = $pie_pages[0] = intval($this->pie_post_array['alternate_login']);
4874 $update['alternate_register'] = $pie_pages[1] = intval($this->pie_post_array['alternate_register']);
4875 $update['alternate_forgotpass'] = $pie_pages[2] = intval($this->pie_post_array['alternate_forgotpass']);
4876 $update['alternate_profilepage'] = $pie_pages[3] = intval($this->pie_post_array['alternate_profilepage']);
4877 $update['after_login'] = trim($this->pie_post_array['after_login']);
4878 $update['alternate_login_url'] = $this->pie_post_array['alternate_login_url'];
4879 $update['alternate_logout'] = trim($this->pie_post_array['alternate_logout']);
4880 $update['alternate_logout_url'] = $this->pie_post_array['alternate_logout_url'];
4881 update_option('pie_pages', $pie_pages);
4882
4883 } elseif(isset($_POST['piereg_settings_ux']) && wp_verify_nonce( $_POST['piereg_settings_ux'], 'piereg_wp_settings_ux' )) {
4884
4885 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_settings_ux', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
4886
4887 $update['display_hints'] = isset($this->pie_post_array['display_hints']) ? intval($this->pie_post_array['display_hints']) :0;
4888 $update['login_username_label'] = $this->pie_post_array['login_username_label'];
4889 $update['login_username_placeholder'] = $this->pie_post_array['login_username_placeholder'];
4890 $update['login_password_label'] = $this->pie_post_array['login_password_label'];
4891 $update['login_password_placeholder'] = $this->pie_post_array['login_password_placeholder'];
4892
4893 $update['forgot_pass_username_label'] = $this->pie_post_array['forgot_pass_username_label'];
4894 $update['forgot_pass_username_placeholder'] = $this->pie_post_array['forgot_pass_username_placeholder'];
4895
4896 $update['custom_logo_url'] = $this->pie_post_array['custom_logo_url'];
4897 $update['custom_logo_tooltip'] = $this->pie_post_array['custom_logo_tooltip'];
4898 $update['custom_logo_link'] = $this->pie_post_array['custom_logo_link'];
4899 $update['show_custom_logo'] = (isset($this->pie_post_array['show_custom_logo']))?$this->pie_post_array['show_custom_logo']:0;
4900 $update['outputcss'] = isset($this->pie_post_array['outputcss']) ? intval($this->pie_post_array['outputcss']) :0;
4901 $update['outputjquery_ui'] = isset($this->pie_post_array['outputjquery_ui']) ? intval($this->pie_post_array['outputjquery_ui']) :0;
4902
4903
4904 $custom_css = isset( $this->pie_post_array['custom_css'] ) ? $this->pie_post_array['custom_css'] : "";
4905 $custom_css = mb_convert_encoding(strip_tags($custom_css),'HTML-ENTITIES','utf-8');
4906 $update['custom_css'] = $this->disable_magic_quotes_gpc($custom_css);
4907
4908 $tracking_code = isset( $this->pie_post_array['tracking_code'] ) ? $this->pie_post_array['tracking_code'] : "";
4909 $tracking_code = mb_convert_encoding(strip_tags($tracking_code),'HTML-ENTITIES','utf-8');
4910 $update['tracking_code'] = $this->disable_magic_quotes_gpc($tracking_code);
4911
4912 } elseif(isset($_POST['piereg_settings_overrides']) && wp_verify_nonce( $_POST['piereg_settings_overrides'], 'piereg_wp_settings_overrides' )) {
4913
4914 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_settings_overrides', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
4915
4916 $update['redirect_user'] = isset($this->pie_post_array['redirect_user']) ? intval($this->pie_post_array['redirect_user']) :0;
4917 $update['show_admin_bar'] = isset($this->pie_post_array['show_admin_bar']) ? intval($this->pie_post_array['show_admin_bar']) :0;
4918 $update['block_WP_profile'] = isset($this->pie_post_array['block_WP_profile']) ? intval($this->pie_post_array['block_WP_profile']) :0;
4919 $update['block_wp_login'] = isset($this->pie_post_array['block_wp_login']) ? intval($this->pie_post_array['block_wp_login']) :0;
4920 $update['allow_pr_edit_wplogin'] = isset($this->pie_post_array['allow_pr_edit_wplogin']) ? intval($this->pie_post_array['allow_pr_edit_wplogin']) :0;
4921
4922 } elseif(isset($_POST['piereg_settings_security_b']) && wp_verify_nonce( $_POST['piereg_settings_security_b'], 'piereg_wp_settings_security_b' )) {
4923
4924 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_settings_security_b', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
4925
4926 $update['captcha_in_login_value'] = isset($this->pie_post_array['captcha_in_login_value']) ? $this->pie_post_array['captcha_in_login_value']: 0;
4927 $update['captcha_in_login_attempts'] = isset($this->pie_post_array['captcha_in_login_attempts']) ? $this->pie_post_array['captcha_in_login_attempts']: 0;
4928 $update['capthca_in_login_label'] = isset($this->pie_post_array['capthca_in_login_label']) ? $this->pie_post_array['capthca_in_login_label']: 0;
4929 $update['piereg_recapthca_skin_login'] = isset($this->pie_post_array['piereg_recapthca_skin_login']) ? $this->pie_post_array['piereg_recapthca_skin_login'] : 0;
4930 $update['capthca_in_login'] = isset($this->pie_post_array['capthca_in_login']) ? intval($this->pie_post_array['capthca_in_login']) : 0;
4931
4932 $update['captcha_in_forgot_value'] = $this->pie_post_array['captcha_in_forgot_value'];
4933 $update['capthca_in_forgot_pass_label'] = $this->pie_post_array['capthca_in_forgot_pass_label'];
4934 $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;
4935 $update['capthca_in_forgot_pass'] = isset($this->pie_post_array['capthca_in_forgot_pass']) ? intval($this->pie_post_array['capthca_in_forgot_pass']) : 0;
4936
4937 $update['piereg_recaptcha_type'] = isset($this->pie_post_array['piereg_recaptcha_type']) ? $this->pie_post_array['piereg_recaptcha_type'] : "v2";
4938 $update['captcha_publc'] = $this->pie_post_array['captcha_publc'];
4939 $update['captcha_private'] = $this->pie_post_array['captcha_private'];
4940 $update['piereg_recaptcha_language'] = $this->pie_post_array['piereg_recaptcha_language'];
4941 $update['captcha_publc_v3'] = isset($this->pie_post_array['captcha_publc_v3']) ? $this->pie_post_array['captcha_publc_v3'] : '';
4942 $update['captcha_private_v3'] = isset($this->pie_post_array['captcha_private_v3']) ? $this->pie_post_array['captcha_private_v3'] : '';
4943
4944 $update['verification'] = intval($this->pie_post_array['verification']);
4945 $update['email_edit_verification_step'] = intval($this->pie_post_array['email_edit_verification_step']);
4946 $update['grace_period'] = intval($this->pie_post_array['grace_period']);
4947
4948 $update['restrict_bot_enabel'] = isset($this->pie_post_array['restrict_bot_enabel']) ? intval($this->pie_post_array['restrict_bot_enabel']) : "";
4949 $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') : "";
4950 $update['restrict_bot_content'] = $this->disable_magic_quotes_gpc($restrict_bot_content);
4951
4952 $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'): "";
4953 $update['restrict_bot_content_message'] = $this->disable_magic_quotes_gpc($restrict_bot_content_message);
4954
4955 } elseif(isset($_POST['piereg_settings_security_advanced']) && wp_verify_nonce( $_POST['piereg_settings_security_advanced'], 'piereg_wp_settings_security_advanced' )){
4956
4957 $this->pie_post_array = $this->piereg_sanitize_post_data('piereg_settings_security_advanced', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
4958
4959 $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;
4960 $update['reg_form_submission_time'] = isset($this->pie_post_array['reg_form_submission_time']) ? intval($this->pie_post_array['reg_form_submission_time']):0;
4961
4962 } else {
4963 $this->pie_post_array['error'] = esc_html__("Invalid nonce.","pie-register");
4964 }
4965
4966 update_option(OPTION_PIE_REGISTER, $update );
4967 $this->set_pr_global_options($update, OPTION_PIE_REGISTER );
4968
4969 if(!isset($this->pie_post_array['error']) && empty($this->pie_post_array['error']))
4970 $this->pie_post_array['notice'] = apply_filters("piereg_settings_saved",esc_html__('Settings Saved', 'pie-register'));
4971
4972 }
4973
4974 function PieRegRedirectSettingsAction(){
4975
4976 $this->pie_post_array = $this->piereg_sanitize_post_data( 'piereg_redirect_settings', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
4977
4978 global $wpdb;
4979 $prefix=$wpdb->prefix."pieregister_";
4980 $piereg_table_name =$prefix."redirect_settings";
4981 /* Change Status */
4982 if( isset($this->pie_post_array['redirect_settings_status_id']) && !empty($this->pie_post_array['redirect_settings_status_id']) ){
4983 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']))))
4984 $this->pie_post_array['notice'] = esc_html__("Status has been changed.","pie-register");
4985 else
4986 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
4987 }
4988 /* Delete Record */
4989 elseif(isset($this->pie_post_array['redirect_settings_del_id'])){
4990 if($wpdb->query($wpdb->prepare("DELETE FROM `".$piereg_table_name."` WHERE `id` = %d", intval($this->pie_post_array['redirect_settings_del_id']))))
4991 $this->pie_post_array['notice'] = esc_html__("Record has been deleted","pie-register");
4992 else
4993 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
4994 }
4995 }
4996 function PieRegInvitationCodes()
4997 {
4998 global $wpdb;
4999 $piereg = get_option(OPTION_PIE_REGISTER);
5000 $codetable = $this->codeTable();
5001 $this->pie_post_array = $this->piereg_sanitize_post_data( 'piereg_invitation_code', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
5002 $_data_updated = false;
5003
5004 if( isset($this->pie_post_array['invi_del_id']) )
5005 {
5006
5007 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
5008 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' ))
5009 {
5010 if($wpdb->query( $wpdb->prepare("DELETE FROM ".$codetable." WHERE id = %d", $this->pie_post_array['invi_del_id']) ))
5011 $this->pie_post_array['notice'] = esc_html__("Invitation code deleted.","pie-register");
5012 else
5013 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
5014 }else{
5015 $this->pie_post_array['error'] = esc_html__("Invalid nonce.","pie-register");
5016 }
5017 }
5018
5019 else if( isset($this->pie_post_array['status_id']) )
5020 {
5021 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
5022 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' ))
5023 {
5024 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']) )){
5025 $this->pie_post_array['notice'] = esc_html__("Status has been changed","pie-register");
5026 }else{
5027 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
5028 }
5029 }else{
5030 $this->pie_post_array['error'] = esc_html__("Invalid nonce.","pie-register");
5031 }
5032 }
5033 if( isset($_POST['piereg_invitation_code_enable_nonce']) && wp_verify_nonce( $_POST['piereg_invitation_code_enable_nonce'], 'piereg_wp_invitation_code_enable_nonce' ) )
5034 {
5035 if( isset($this->pie_post_array['hdn_enable_invitation_codes']) )
5036 {
5037 $piereg['enable_invitation_codes'] = isset($this->pie_post_array['enable_invitation_codes']) ? intval($this->pie_post_array['enable_invitation_codes']) : 0;
5038 $_data_updated = true;
5039 }
5040 }
5041 if( $_data_updated && update_option(OPTION_PIE_REGISTER,$piereg)){
5042 $this->pie_post_array['notice'] = esc_html__("Settings Saved","pie-register");
5043 }
5044 else if( isset($this->pie_post_array['piereg_codepass']) )
5045 {
5046
5047 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
5048 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' ))
5049 {
5050 if(isset($this->pie_post_array['add_code'])){
5051 if(isset($this->pie_post_array['invitation_code_prefix'])){
5052 $this->pie_post_array['error'] = esc_html__("Please activate the premium version","pie-register");
5053 }
5054
5055 if(empty($this->pie_post_array['piereg_codepass']) || trim($this->pie_post_array['piereg_codepass']) == ''){
5056 $this->pie_post_array['error'] = esc_html__("Invitation code field is empty.","pie-register");
5057 }
5058
5059 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']) != ''){
5060 if(empty($this->pie_post_array['piereg_codepass']) || trim($this->pie_post_array['piereg_codepass']) == ''){
5061 $this->pie_post_array['error'] .= '<br/>';
5062 }
5063 $this->pie_post_array['error'] .= esc_html__("Usage must be a number greater than zero.","pie-register");
5064 }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']) != ''){
5065 if(empty($this->pie_post_array['piereg_codepass']) || trim($this->pie_post_array['piereg_codepass']) == ''){
5066 $this->pie_post_array['error'] .= '<br/>';
5067 }
5068 $this->pie_post_array['error'] .= esc_html__("Usage must be a number greater than zero.","pie-register");
5069 }
5070
5071 $update["codepass"] = isset($this->pie_post_array['piereg_codepass']) ? $this->pie_post_array['piereg_codepass'] : '';
5072 $codespasses = array();
5073
5074 if($update['codepass'] != ""){
5075 $codespasses=explode("\n",$update["codepass"]);
5076 }
5077
5078 $codeadded = false;
5079
5080 $count_code = 0;
5081 $count_added_code = 0;
5082 $count_special_char = 0;
5083
5084 if( is_array($codespasses ) && count($codespasses) > 0 )
5085 {
5086 foreach( $codespasses as $k=>$v )
5087 {
5088 $v = trim($v);
5089 if($v != '')
5090 {
5091 $count_code++;
5092
5093 if( $this->InsertCode($v) )
5094 {
5095 $count_added_code++;
5096 $codeadded = true;
5097 }
5098
5099 if(!preg_match('/^[A-Za-z0-9_-]+$/', $v))
5100 {
5101 $count_special_char++;
5102 $special_char = true;
5103 }
5104 }
5105 }
5106 }
5107
5108 if(isset($special_char) && $special_char){
5109 $this->pie_post_array['error'] = esc_html__("Special characters are not allowed in code field.","pie-register");
5110 }
5111
5112 if(!$codeadded && $count_code != $count_added_code && !isset($this->pie_post_array['error'])){
5113 $count_not_added_code = $count_code - $count_added_code - $count_special_char;
5114 $this->pie_post_array['notice'] = $count_not_added_code.esc_html__(" invitation Code(s) already exists","pie-register");
5115 }elseif($codeadded) {
5116 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)
5117 {
5118 $piereg["invitation_code_usage"] = $this->pie_post_array['invitation_code_usage'];
5119
5120 if(update_option(OPTION_PIE_REGISTER,$piereg))
5121 {
5122 $this->pie_post_array['notice'] = esc_html__("Invitation Code(s) added successfully","pie-register");
5123 }
5124 }
5125
5126 if($count_code != $count_added_code){
5127 $count_not_added_code = $count_code - $count_added_code - $count_special_char;
5128 $this->pie_post_array['notice'] = $count_added_code.esc_html__(" invitation Code(s) added successfully.","pie-register");
5129 if($count_not_added_code != 0){
5130 $this->pie_post_array['notice'] .= '<br/>'.$count_not_added_code.esc_html__(" invitation Code(s) already exists","pie-register");
5131 }
5132 }else{
5133 $this->pie_post_array['notice'] = $count_added_code.esc_html__(" invitation Code(s) added successfully","pie-register");
5134 }
5135 }
5136 }
5137 }else{
5138
5139 $this->pie_post_array['error'] = esc_html__("Invalid nonce.","pie-register");
5140 }
5141 }
5142 $this->include_pr_menu_pages(PIEREG_DIR_NAME.'/menus/PieRegInvitationCodes.php');
5143 }
5144 function InsertCode($name)
5145 {
5146 if(empty($name) || trim($name) == '') return false;
5147
5148 $name_lower = htmlentities( strtolower($name) );
5149 $name_upper = htmlentities( strtoupper($name) );
5150
5151 global $wpdb;
5152
5153 $piereg=get_option(OPTION_PIE_REGISTER);
5154
5155 $codetable=$this->codeTable();
5156 $expiry = (isset($piereg['codeexpiry'])) ? $piereg['codeexpiry']: "";
5157 $codes = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $codetable WHERE BINARY `name`=%s OR `name`=%s" , $name_lower, $name_upper) );
5158
5159 if(isset($wpdb->last_error) && !empty($wpdb->last_error)){
5160 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
5161 }
5162 $counts = count($codes);
5163 $wpdb->flush();
5164
5165 if( $counts > 0 )
5166 {
5167 return false;
5168 }
5169
5170 if(!preg_match(apply_filters( 'piereg_invitation_code_char_check', '/^[A-Za-z0-9_-]+$/'), $name)) return false;
5171
5172 $name = trim( preg_replace( apply_filters( 'piereg_invitation_code_char_verification', '/[^A-Za-z0-9_-]/'), '', $name) );
5173 if(empty($name)) return false;
5174
5175 $date = date_i18n("Y-m-d");
5176
5177 $usage = intval(sanitize_key($_POST['invitation_code_usage']));
5178 $desc = trim(sanitize_textarea_field($_POST['invitation_code_description']));
5179 $expiry_date = "0000-00-00";
5180
5181 if(!empty($usage) && !is_numeric($usage) || $usage < 0){
5182 return false;
5183 }
5184
5185 if(!$wpdb->query( $wpdb->prepare("INSERT INTO ".$codetable." (`created`,`modified`,`name`,`count`,`status`,`code_usage`,`expiry_date`,`code_description`)VALUES(%s,%s,%s,%s,%s,%s,%s,%s)", $date, $date, htmlentities($name), $counts, "1", $usage, $expiry_date,$desc) )){
5186 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
5187 }
5188 $wpdb->flush();
5189 return true;
5190
5191 }
5192 function generateCSV()
5193 {
5194
5195 if(isset($_POST['piereg_export_users_nonce']) && wp_verify_nonce( $_POST['piereg_export_users_nonce'], 'piereg_wp_exportusers_nonce' ))
5196 {
5197 $this->pie_post_array = $this->piereg_sanitize_post_data( 'piereg_export_csv', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
5198
5199 global $wpdb;
5200 $user_table = $wpdb->prefix . "users";
5201 $user_meta_table = $wpdb->prefix . "usermeta";
5202
5203
5204 $fields = "";
5205 if( isset($this->pie_post_array['pie_fields_csv']) && sizeof($this->pie_post_array['pie_fields_csv']) > 0) {
5206 $fields = implode(',',array_keys($this->pie_post_array['pie_fields_csv']));
5207 }
5208
5209 if( !isset($this->pie_post_array['pie_fields_csv']) || sizeof($this->pie_post_array['pie_fields_csv']) == 0 ) {
5210 $this->pie_post_array['pie_fields_csv'] = array();
5211 }
5212
5213 if( !isset($this->pie_post_array['pie_meta_csv']) || sizeof($this->pie_post_array['pie_meta_csv']) == 0 ) {
5214 $this->pie_post_array['pie_meta_csv'] = array();
5215 }
5216
5217
5218 $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"));
5219
5220 $query = "SELECT ID ";
5221 $query .= ($fields)?",$fields " : "";
5222 $query .= " FROM $user_table ";
5223
5224 if($this->pie_post_array['date_start'] != "" || $this->pie_post_array['date_end'] != "")
5225 {
5226 $_date_start = date_i18n("Y-m-d",strtotime($this->pie_post_array['date_start']));
5227 $_date_end = date_i18n("Y-m-d",strtotime($this->pie_post_array['date_end']));
5228 $date_start = FALSE;
5229 $query .= " where ";
5230
5231 if($this->pie_post_array['date_start'] != "")
5232 {
5233 $query .= " user_registered >= '{$_date_start} 00:00:00' ";
5234 $date_start = TRUE;
5235 }
5236
5237 if($this->pie_post_array['date_end'] != "")
5238 {
5239 if($date_start)
5240 {
5241 $query .= " AND ";
5242 }
5243 $query .= " user_registered <= '{$_date_end} 23:59:59' ";
5244 }
5245 }
5246 $query .= " order by user_login asc";
5247
5248 /*$sql_pre = $wpdb->prepare( $query, $user_table );
5249 $users = $wpdb->get_results( $sql_pre, ARRAY_A ); #WPS*/
5250 // User data being fetched from the database
5251 $users = $wpdb->get_results($query,ARRAY_A);
5252 if(isset($wpdb->last_error) && !empty($wpdb->last_error)){
5253 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
5254 }
5255 global $wp_roles,$wpdb;
5256 if(sizeof($users ) > 0){
5257 // Creating the CSV of the exported user's data
5258 $dfile = "pieregister_exported_users_".date_i18n("Y-m-d-H:i").".csv";
5259 header('Content-Type: application/csv');
5260 header('Content-Disposition: attachment; filename='.$dfile);
5261 header('Pragma: no-cache');
5262 // Set headers in the exported CSV
5263 echo '"'.implode('","',$heads).'"'."\r\n";
5264
5265 foreach ($users as $user_key=>$user_value){
5266 $content_data = '';
5267 foreach($user_value as $single_user_data){
5268 $content_data.='"'.$single_user_data.'",';
5269 }
5270 if(sizeof($this->pie_post_array['pie_meta_csv']) > 0){
5271 foreach($this->pie_post_array['pie_meta_csv'] as $key=>$value){
5272
5273 if($key == "wp_capabilities"){
5274 $user = get_userdata( $user_value['ID'] );
5275
5276 $capabilities = $user->{$wpdb->prefix . 'capabilities'};
5277
5278 if ( !isset( $wp_roles ) )
5279 $wp_roles = new WP_Roles();
5280 $meta_value = '';
5281 foreach ( $wp_roles->role_names as $role => $name ):
5282 if ( array_key_exists( $role, $capabilities ) )
5283 $meta_value = $name;
5284 endforeach;
5285 }
5286 else{
5287 $meta_value = get_user_meta($user_value['ID'],$key,true);
5288 }
5289
5290 $content_data.='"'.htmlentities($meta_value, ENT_QUOTES | ENT_IGNORE, "UTF-8").'"'.",";
5291 }
5292 }
5293 $verification_status = get_user_meta($user_value['ID'],'active',true);
5294 $register_type = get_user_meta($user_value['ID'],'register_type',true);
5295 if ( $verification_status == 1 )
5296 {
5297 $verification_status = 'Verified';
5298 }
5299 else if ( $verification_status == 0 )
5300 {
5301 switch($register_type){
5302 case "email_verify":
5303 $verification_status = esc_html__("E-mail Verification","pie-register");
5304 break;
5305 case "admin_verify":
5306 $verification_status = esc_html__("Admin Verification","pie-register");
5307 break;
5308 case "admin_email_verify":
5309 $verification_status = esc_html__("E-mail & Admin Verification","pie-register");
5310 break;
5311 case "payment_verify":
5312 $verification_status = esc_html__("Payment Verification","pie-register");
5313 break;
5314 }
5315 } else {
5316 $verification_status = 'Null';
5317 }
5318 $content_data .= $verification_status.',';
5319 // Set content in the exported CSV
5320 echo rtrim($content_data,',');
5321 echo "\r\n";
5322 }
5323 die(); // ask baqar
5324 }
5325 else
5326 {
5327 $this->pie_post_array['error_message'] = esc_html__("No Record Found","pie-register");
5328 }
5329 }else{
5330 $this->pie_post_array['error_message'] = esc_html__("Invalid nonce.","pie-register");
5331 }
5332 }
5333
5334 function csv_to_array($filename='', $delimiter=';'){
5335 if(!file_exists($filename) || !is_readable($filename))
5336 return FALSE;
5337
5338 $header = array();
5339 $data = array();
5340
5341 if (($handle = fopen($filename, 'r')) !== FALSE)
5342 {
5343 while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
5344 {
5345 if(!$header)
5346 $header = $row;
5347 else
5348 $data[] = array_combine($header, $row);
5349 }
5350 fclose($handle);
5351 }
5352 return $data;
5353 }
5354 function importUsers()
5355 {
5356 if(isset($_POST['piereg_import_users_nonce']) && wp_verify_nonce( $_POST['piereg_import_users_nonce'], 'piereg_wp_importusers_nonce' ))
5357 {
5358 $this->pie_post_array = $this->piereg_sanitize_post_data( 'piereg_import_users', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
5359
5360 $success_import = 0;
5361 $unsuccess_import = 0;
5362 $already_exist = 0;
5363
5364 if(empty(sanitize_file_name($_FILES['csvfile']['name'])))
5365 {
5366 $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'));
5367 return;
5368 }
5369 $checked_user_file = realpath($_FILES['csvfile']['tmp_name']);
5370 if(!$checked_user_file){
5371 $this->pie_post_array['error_message'] = apply_filters("piereg_didnt_select_file_to_import",esc_html__("The file can't be processed",'pie-register'));
5372 return;
5373 }
5374
5375 $ext = pathinfo(sanitize_file_name($_FILES['csvfile']['name']), PATHINFO_EXTENSION); // To get file extension
5376 if($ext != "csv")
5377 {
5378 $this->pie_post_array['error_message'] = esc_html__("Invalid CSV file.",'pie-register');
5379 return;
5380 }
5381 $current_csv_file_data = "";
5382 if ($_FILES['csvfile']['tmp_name']){
5383 $csv_data = $this->csv_to_array($checked_user_file,',');
5384 }
5385 if(!isset($csv_data[0]) or sizeof($csv_data[0]) < 2)
5386 {
5387 $this->pie_post_array['error_message'] = esc_html__("Invalid CSV File. It must contain all the default user fields.",'pie-register');
5388 return;
5389 }
5390 $table_fields = array(
5391 //////////// DEFAULT FEILDS //////////
5392 "User ID"=>"ID",
5393 "Username"=>"user_login",
5394 "Password"=>'user_pass',
5395 "Nickname"=>"user_nicename",
5396 "E-mail"=>"user_email",
5397 "Website"=>"user_url",
5398 "User Registered"=>"user_registered",
5399 "Display name"=>"display_name",
5400 ///////////// USER META /////////////
5401 "First Name"=>"first_name",
5402 "Last Name"=>"last_name",
5403 "Biographical Info"=>"description",
5404 "Role"=>"wp_capabilities",
5405 "Verified/Unverified"=>"active");
5406 $user_csv_data = array();
5407 $temp_data = array();
5408 $user_default_data = array();
5409 $user_meta_key = array();
5410 if(is_array($csv_data) && !empty($csv_data))
5411 {
5412 foreach($csv_data as $arr_key=>$arr_val){
5413 foreach($arr_val as $head_key=>$user_data){
5414 switch($head_key):
5415 case 'User ID' :
5416 case 'Username' :
5417 case 'Password' :
5418 case 'Nickname' :
5419 case 'E-mail' :
5420 case 'Website' :
5421 case 'User Registered' :
5422 case 'Display name' :
5423 if( mb_detect_encoding($user_data) !== "UTF-8"):
5424 $user_default_data[$table_fields[$head_key]] = utf8_encode($user_data);
5425 else:
5426 $user_default_data[$table_fields[$head_key]] = $user_data;
5427 endif;
5428 break;
5429 case 'First Name' :
5430 case 'Last Name' :
5431 case 'Biographical Info' :
5432 case 'Role' :
5433 if( mb_detect_encoding($user_data) !== "UTF-8"):
5434 $user_meta_key[$table_fields[$head_key]] = utf8_encode($user_data);
5435 else:
5436 $user_meta_key[$table_fields[$head_key]] = $user_data;
5437 endif;
5438 case 'Verified/Unverified' :
5439 if ( $user_data == "Verified" )
5440 {
5441 $user_data = 1;
5442 } else if ( ($user_data !== "Verified") && ($user_data !== "Null") )
5443 {
5444 switch($user_data){
5445 case "E-mail Verification":
5446 $user_meta_key['register_type'] = 'email_verify';
5447 $user_data = 0;
5448 break;
5449 case "Admin Verification":
5450 $user_meta_key['register_type'] = 'admin_verify';
5451 $user_data = 0;
5452 break;
5453 case "E-mail & Admin Verification":
5454 $user_meta_key['register_type'] = 'admin_email_verify';
5455 $user_data = 0;
5456 break;
5457 case "Payment Verification":
5458 $user_meta_key['register_type'] = 'payment_verify';
5459 $user_data = 0;
5460 break;
5461 }
5462 }
5463 if ( $user_data !== "Null" )
5464 {
5465 if( mb_detect_encoding($user_data) !== "UTF-8"):
5466 $user_meta_key[$table_fields[$head_key]] = utf8_encode($user_data);
5467 else:
5468 $user_meta_key[$table_fields[$head_key]] = $user_data;
5469 endif;
5470 }
5471 break;
5472 endswitch;
5473 $temp_data[$table_fields[$head_key]] = $user_data;
5474 }
5475 $user_csv_data[$arr_key] = $temp_data;
5476
5477 if( empty($user_default_data['user_pass']) )
5478 {
5479 $user_default_data['user_pass'] = wp_generate_password();
5480 }
5481
5482 if ( username_exists( $user_default_data['user_login'] ) ){
5483 $already_exist++;
5484 if(isset($this->pie_post_array['update_existing_users']) && $this->pie_post_array['update_existing_users'] == "yes"){
5485 unset($user_default_data['user_pass']);
5486 $user_id = wp_update_user($user_default_data);
5487 if(is_int($user_id)){
5488 $this->update_user_meta_by_array($user_id,$user_meta_key);
5489 }
5490 }
5491 }else{
5492 if(get_user_by('ID',$user_default_data['ID'])){
5493 $already_exist++;
5494 if(isset($this->pie_post_array['update_existing_users']) && $this->pie_post_array['update_existing_users'] == "yes"){
5495 unset($user_default_data['user_pass']);
5496 $user_id = wp_update_user($user_default_data);
5497 if(is_int($user_id)){
5498 $this->update_user_meta_by_array($user_id,$user_meta_key);
5499 }
5500 }
5501 }else{
5502 unset($user_default_data['ID']);
5503 $user_id = wp_insert_user($user_default_data);
5504 if( is_int($user_id) )
5505 {
5506 do_action('piereg_new_user_import', $user_id);
5507 if(isset($user_id)){
5508 $this->update_user_meta_by_array($user_id,$user_meta_key);
5509 }
5510 $success_import++;
5511 }
5512 }
5513 }
5514
5515 unset($temp_data);
5516 unset($user_meta_key);
5517 unset($user_default_data);
5518 }
5519 }
5520
5521 if($success_import)
5522 $this->pie_post_array['success_message'] = esc_html__("$success_import user(s) imported.",'pie-register');
5523
5524 if($unsuccess_import)
5525 $this->pie_post_array['error_message'] = esc_html__("$unsuccess_import user(s) do not imported.",'pie-register');
5526
5527 if($already_exist){
5528 if(isset($this->pie_post_array['update_existing_users']) && $this->pie_post_array['update_existing_users'] == "yes"){
5529 if($success_import) {$this->pie_post_array['success_message'] .= "<br />".esc_html__("$already_exist user(s) Update.",'pie-register');}
5530 else {$this->pie_post_array['success_message'] = esc_html__("$already_exist user(s) Update.",'pie-register');}
5531 }else{
5532 $this->pie_post_array['error_message'] = esc_html__("$already_exist user(s) already exist.",'pie-register');
5533 }
5534 }
5535 }else{
5536 $this->pie_post_array['error_message'] = esc_html__("Invalid nonce.","pie-register");
5537 }
5538 }
5539
5540 function update_user_meta_by_array($user_id,$user_meta_keys)
5541 {
5542 if(isset($user_id) and isset($user_meta_keys))
5543 {
5544 if(is_array($user_meta_keys)){
5545 foreach($user_meta_keys as $key=>$val){
5546 if($key == "wp_capabilities"){
5547 $wp_user_object = new WP_User($user_id);
5548 $wp_user_object->set_role($val);
5549 unset($wp_user_object);
5550 }else{
5551 update_user_meta($user_id,$key,$val);
5552 }
5553 }
5554 }
5555 }
5556 }
5557
5558 function SaveSettings()
5559 {
5560 // asnitize_post here
5561 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') )
5562 {
5563 $piereg_api_manager_menu = new Piereg_API_Manager_Example_MENU();
5564
5565 if ( ! function_exists( 'get_plugins' ) ) {
5566 require_once $this->admin_path . 'includes/plugin.php';
5567 }
5568 $activated_plugins = get_option('active_plugins');
5569 $list_all_plugins = get_plugins();
5570
5571 foreach( $list_all_plugins as $key => $plugin )
5572 {
5573 if( in_array($key,$activated_plugins) && strpos($plugin['Name'],'Pie Register (Add on) - ') !== false )
5574 {
5575 $addon_name = str_replace(array('Pie Register (Add on) - ', '(', ')'), '', $plugin['Name']);
5576 $addon_name = str_replace(array(' ', '.'), '_', $addon_name);
5577 $is_addon = "addon_" . $addon_name;
5578
5579 if($is_addon == 'addon_Authorize_Net')
5580 {
5581 $is_addon = 'addon_AuthNet';
5582 }
5583
5584 $plugin_status = get_option( 'piereg_api_manager_'.$is_addon.'_activated' );
5585
5586 if( $plugin_status == 'Activated' ) {
5587 $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'])) );
5588 }
5589 }
5590 }
5591
5592 $piereg_api_manager_menu->wc_am_license_key_deactivation( "on" );
5593 }
5594
5595 if(isset($_POST['is_deactivate_addon']) && $_POST['is_deactivate_addon'] == "true")
5596 {
5597 $piereg_pro_not_activated = ( isset($_POST['piereg_pro_not_activated']) ) ? true: false;
5598
5599 $piereg_api_manager_menu = new Piereg_API_Manager_Example_MENU();
5600 $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) );
5601 }
5602
5603 $update = get_option(OPTION_PIE_REGISTER);
5604 if( isset($_POST['action']) && $_POST['action'] == 'pie_reg_update' )
5605 {
5606 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') )
5607 {
5608 $this->pie_post_array = $this->piereg_sanitize_post_data( 'payment_gateway_page', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
5609
5610 $update["enable_paypal"] = (isset($this->pie_post_array['enable_paypal'])) ? intval($this->pie_post_array['enable_paypal']) : "";
5611 $update["paypal_butt_id"] = $this->disable_magic_quotes_gpc($this->pie_post_array['piereg_paypal_butt_id']);
5612 $update["paypal_sandbox"] = $this->pie_post_array['piereg_paypal_sandbox'];
5613 }
5614 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') ){
5615
5616 $this->pie_post_array = $this->piereg_sanitize_post_data( 'payment_gateway_general_settings', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
5617
5618 $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")));
5619 $update["payment_success_msg"] = $this->disable_magic_quotes_gpc($payment_success_msg);
5620
5621 $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")));
5622 $update["payment_faild_msg"] = $this->disable_magic_quotes_gpc($payment_faild_msg);
5623
5624 $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")));
5625 $update["payment_renew_msg"] = $this->disable_magic_quotes_gpc($payment_renew_msg);
5626
5627
5628 $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")));
5629 $update["payment_already_activate_msg"] = $this->disable_magic_quotes_gpc($payment_already_activate_msg);
5630 }
5631 else if(isset($_POST['admin_email_notification_page'])){
5632 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
5633 if(isset($_POST['piereg_admin_email_notification']) && wp_verify_nonce( $_POST['piereg_admin_email_notification'], 'piereg_wp_admin_email_notification' ))
5634 {
5635 $this->pie_post_array = $this->piereg_sanitize_post_data( 'admin_email_notification_page', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
5636
5637 $update['enable_admin_notifications'] = isset($this->pie_post_array['enable_admin_notifications']) ? intval($this->pie_post_array['enable_admin_notifications']) : 0;
5638 $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;
5639 $update['admin_sendto_email'] = trim($this->pie_post_array['admin_sendto_email']);
5640 $update['admin_sendto_email_profile_update'] = trim($this->pie_post_array['admin_sendto_email_profile_update']);
5641
5642 // $admin_from_name = mb_convert_encoding($this->pie_post_array['admin_from_name'],'HTML-ENTITIES','utf-8');
5643 $admin_from_name = sanitize_text_field( $this->pie_post_array['admin_from_name']);
5644 $update['admin_from_name'] = $this->disable_magic_quotes_gpc($admin_from_name);
5645 $admin_from_name_profile_update = sanitize_text_field( $this->pie_post_array['admin_from_name_profile_update']);
5646 $update['admin_from_name_profile_update'] = $this->disable_magic_quotes_gpc($admin_from_name_profile_update);
5647
5648 $update['admin_from_email'] = trim($this->pie_post_array['admin_from_email']);
5649 $update['admin_to_email'] = trim($this->pie_post_array['admin_to_email']);
5650 $update['admin_bcc_email'] = trim($this->pie_post_array['admin_bcc_email']);
5651
5652 $update['admin_from_email_profile_update'] = trim($this->pie_post_array['admin_from_email_profile_update']);
5653 $update['admin_to_email_profile_update'] = trim($this->pie_post_array['admin_to_email_profile_update']);
5654 $update['admin_bcc_email_profile_update'] = trim($this->pie_post_array['admin_bcc_email_profile_update']);
5655
5656 $admin_subject_email = mb_convert_encoding($this->pie_post_array['admin_subject_email'],'HTML-ENTITIES','utf-8');
5657 $update['admin_subject_email'] = $this->disable_magic_quotes_gpc($admin_subject_email);
5658 $admin_subject_email_profile_update = mb_convert_encoding($this->pie_post_array['admin_subject_email_profile_update'],'HTML-ENTITIES','utf-8');
5659 $update['admin_subject_email_profile_update'] = $this->disable_magic_quotes_gpc($admin_subject_email_profile_update);
5660
5661 $update['admin_message_email_formate'] = isset($this->pie_post_array['admin_message_email_formate']) ? intval($this->pie_post_array['admin_message_email_formate']) :0;
5662 $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;
5663
5664 $admin_message_email = mb_convert_encoding($this->pie_post_array['admin_message_email'],'HTML-ENTITIES','utf-8');
5665 $update['admin_message_email'] = $this->disable_magic_quotes_gpc($admin_message_email);
5666
5667 $admin_message_email_profile_update = mb_convert_encoding($this->pie_post_array['admin_message_email_profile_update'],'HTML-ENTITIES','utf-8');
5668 $update['admin_message_email_profile_update'] = $this->disable_magic_quotes_gpc($admin_message_email_profile_update);
5669
5670 }else{
5671 $this->pie_post_array['error'] = esc_html__("Invalid nonce.","pie-register");
5672 }
5673 }
5674 else if(isset($_POST['user_email_notification_page']))
5675 {
5676 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
5677 if(isset($_POST['piereg_user_email_notification']) && wp_verify_nonce( $_POST['piereg_user_email_notification'], 'piereg_wp_user_email_notification' ))
5678 {
5679
5680 $this->pie_post_array = $this->piereg_sanitize_post_data( 'user_email_notification_page', ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
5681
5682 $pie_user_email_types = get_option( 'pie_user_email_types');
5683
5684 foreach ($pie_user_email_types as $val=>$type)
5685 {
5686 if( isset($this->pie_post_array['user_from_name_'.$val]) )
5687 {
5688 $user_from_name = mb_convert_encoding(trim($this->pie_post_array['user_from_name_'.$val]),'HTML-ENTITIES','utf-8');
5689 }
5690 $update['user_from_name_'.$val] = $this->disable_magic_quotes_gpc($user_from_name);
5691
5692 if( isset($this->pie_post_array['user_from_email_'.$val]) )
5693 {
5694 $user_from_email = mb_convert_encoding(trim($this->pie_post_array['user_from_email_'.$val]),'HTML-ENTITIES','utf-8');
5695 }
5696 $update['user_from_email_'.$val] = $this->disable_magic_quotes_gpc($user_from_email);
5697
5698 if( isset($this->pie_post_array['user_to_email_'.$val]) )
5699 {
5700 $user_to_email = mb_convert_encoding(trim($this->pie_post_array['user_to_email_'.$val]),'HTML-ENTITIES','utf-8');
5701 }
5702 $update['user_to_email_'.$val] = $this->disable_magic_quotes_gpc($user_to_email);
5703
5704 $user_bcc_email = "";
5705 if( isset($this->pie_post_array['user_bcc_email_'.$val]) )
5706 {
5707 $user_bcc_email = mb_convert_encoding(trim($this->pie_post_array['user_bcc_email_'.$val]),'HTML-ENTITIES','utf-8');
5708 }
5709 $update['user_bcc_email_'.$val] = $this->disable_magic_quotes_gpc($user_bcc_email);
5710
5711 if( isset($this->pie_post_array['user_subject_email_'.$val]) )
5712 {
5713 $user_subject_email = mb_convert_encoding(trim($this->pie_post_array['user_subject_email_'.$val]),'HTML-ENTITIES','utf-8');
5714 }
5715 $update['user_subject_email_'.$val] = $this->disable_magic_quotes_gpc($user_subject_email);
5716
5717 if( isset($this->pie_post_array['user_formate_email_'.$val]) )
5718 {
5719 $update['user_formate_email_'.$val] = intval($this->pie_post_array['user_formate_email_'.$val]);
5720 }
5721
5722
5723 $update['user_enable_'.$val] = isset($this->pie_post_array['user_enable_'.$val]) ? intval($this->pie_post_array['user_enable_'.$val]) : 0;
5724
5725 if( isset($this->pie_post_array['user_message_email_'.$val]) )
5726 {
5727 $user_message_email = mb_convert_encoding(trim($this->pie_post_array['user_message_email_'.$val]),'HTML-ENTITIES','utf-8');
5728 }
5729 $update['user_message_email_'.$val] = $this->disable_magic_quotes_gpc($user_message_email);
5730 }
5731 }else{
5732 $this->pie_post_array['error'] = esc_html__("Invalid nonce.","pie-register");
5733 }
5734 }
5735
5736 update_option(OPTION_PIE_REGISTER, $update );
5737 $this->set_pr_global_options($update, OPTION_PIE_REGISTER );
5738 if( isset($error) && trim($error) != "" )
5739 {
5740 $this->pie_post_array['PR_license_notice'] = $error;
5741 }
5742 if(!isset($this->pie_post_array['error']) && empty($this->pie_post_array['error']))
5743 $this->pie_post_array['notice'] = apply_filters("piereg_settings_saved",__('Settings Saved', 'pie-register'));
5744
5745 }
5746 }
5747
5748
5749 /*
5750 * Get Field's Name For Post
5751 * Add this snipt at 17/10/2014
5752 */
5753 function getPieregFieldName($field,$no,$field_type = ""){
5754
5755 $fieldName = "";
5756 if(isset($field['type']) && !empty($field['type']) && isset($field['id']) )
5757 {
5758 switch($field['type']){
5759 case "username":
5760 case "password":
5761 case "custom_role": // dropdown_ur
5762 case "pricing":
5763 $fieldName = $field['type'];
5764 break;
5765 case "email":
5766 $fieldName = "e_mail";
5767 break;
5768 case "default":
5769 $fieldName = $field['field_name'];
5770 break;
5771 default:
5772 $fieldName = $field['type']."_".$field['id'];
5773 break;
5774 }
5775 }
5776
5777 return $fieldName;
5778 }
5779 function addTextField($field,$no,$field_type)
5780 {
5781 $fieldPostName = $this->getPieregFieldName($field,$no,$field_type);
5782
5783 $name = $this->createFieldName($field,$no);
5784 $id = $this->createFieldID($field,$no);
5785
5786 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).'" />';
5787
5788 }
5789 function addInvitationField($field,$no)
5790 {
5791 $fieldPostName = $this->getPieregFieldName($field,$no);
5792 $name = $this->createFieldName($field,$no);
5793
5794 echo '<input type="hidden" id="default_'.esc_attr($field['type']).'">';
5795 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']): "" ).'" />';
5796
5797 }
5798 function addTermsField($field,$no)
5799 {
5800 $name = $this->createFieldName($field,$no);
5801
5802 echo '<input type="hidden" id="default_'.esc_attr($field['type']).'">';
5803 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>';
5804
5805 }
5806 function addDefaultField($field,$no)
5807 {
5808 $fieldPostName = $this->getPieregFieldName($field,$no);
5809 $name = $this->createFieldName($field,$no);
5810 $id = $this->createFieldID($field,$no);
5811 if($field['field_name']=="description")
5812 {
5813 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>';
5814 }
5815 else
5816 {
5817 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).'" />';
5818 }
5819 echo '<input type="hidden" name="field['.esc_attr($field['id']).'][id]" value="'.esc_attr($field['id']).'" id="id_'.esc_attr($field['id']).'">';
5820 echo '<input type="hidden" name="field['.esc_attr($field['id']).'][type]" value="default" id="type_'.esc_attr($field['id']).'">';
5821 echo '<input type="hidden" name="field['.esc_attr($field['id']).'][label]" value="'.esc_attr($field['label']).'" id="label_'.esc_attr($field['id']).'">';
5822 echo '<input type="hidden" name="field['.esc_attr($field['id']).'][field_name]" value="'.esc_attr($field['type']).'" id="label_'.esc_attr($field['id']).'">';
5823 echo '<input type="hidden" id="default_'.esc_attr($field['type']).'">';
5824 }
5825 function addEmail($field,$no)
5826 {
5827 $fieldPostName = $this->getPieregFieldName($field,$no);
5828 $name = $this->createFieldName($field,$no);
5829 $id = $this->createFieldID($field,$no);
5830 $confirm_email = "display:none;";
5831
5832 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).'" />';
5833 if(isset($field['confirm_email']))
5834 {
5835 $confirm_email = "";
5836 }
5837
5838 $label2 = (isset($field['label2']) and !empty($field['label2']))?$field['label2'] : __("Confirm E-Mail","pie-register");
5839 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>';
5840 }
5841 function addPassword($field,$no)
5842 {
5843 $fieldPostName = $this->getPieregFieldName($field,$no);
5844 $name = $this->createFieldName($field,$no);
5845 $id = $this->createFieldID($field,$no);
5846
5847 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).'" />';
5848
5849 $label2 = (isset($field['label2']) and !empty($field['label2']))?$field['label2'] : __("Confirm Password","pie-register");
5850 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>';
5851 }
5852
5853 function addUpload($field,$no)
5854 {
5855 $name = $this->createFieldName($field,$no);
5856 $id = $this->createFieldID($field,$no);
5857
5858 echo '<input disabled="disabled" id="'.esc_attr($id).'" name="'.esc_attr($name).'" class="input_fields" type="file" />';
5859 }
5860 function addProfilePicUpload($field,$no)
5861 {
5862 $name = $this->createFieldName($field,$no);
5863 $id = $this->createFieldID($field,$no);
5864 echo '<input disabled="disabled" id="'.esc_attr($id).'" name="'.esc_attr($name).'" class="input_fields" type="file" />';
5865 }
5866
5867 function addAddress($field,$no)
5868 {
5869 $name = $this->createFieldName($field,$no);
5870 $id = $this->createFieldID($field,$no);
5871
5872 echo '<input type="hidden" id="default_'.esc_attr($field['type']).'">';
5873 echo '<div class="address" id="address_fields">
5874 <input disabled="disabled" type="text" class="input_fields">
5875 <label>'.esc_html__("Street Address","pie-register").'</label>
5876 </div>';
5877
5878 $hideAddress2= "";
5879 if(isset($field['hide_address2']) && $field['hide_address2'])
5880 {
5881 $hideAddress2 = 'display:none;';
5882 }
5883
5884 echo '<div class="address" id="address_address2_'.esc_attr($no).'" style="'.esc_attr($hideAddress2).'">
5885 <input disabled="disabled" type="text" class="input_fields">
5886 <label>'.esc_html__("Address Line 2","pie-register").'</label>
5887 </div>
5888 <div class="address">
5889 <div class="address2">
5890 <input disabled="disabled" type="text" class="input_fields">
5891 <label>'.esc_html__("City","pie-register").'</label>
5892 </div>';
5893
5894 $hide_state = "";
5895 if(isset($field['hide_state']) && $field['hide_state'])
5896 {
5897 $hide_state = 'display:none;';
5898 $hide_usstate = 'display:none;';
5899 $hide_canstate = 'display:none;';
5900 }
5901 else
5902 {
5903 if($field['address_type'] == "International")
5904 {
5905 $hide_state = '';
5906 }
5907 else if($field['address_type'] == "United States")
5908 {
5909 $hide_usstate = '';
5910 }
5911 else if($field['address_type'] == "Canada")
5912 {
5913 $hide_canstate = '';
5914 }
5915 }
5916
5917
5918 echo '<div class="address2 state_div_'.esc_attr($no).'" id="state_'.esc_attr($no).'" style="'.esc_attr($hide_state) .'">
5919 <input disabled="disabled" type="text" class="input_fields">
5920 <label>'.esc_html__("State / Province / Region","pie-register").'</label>
5921 </div>
5922 <div class="address2 state_div_'.esc_attr($no).'" id="state_us_'.esc_attr($no).'" style="'.((isset($hide_usstate))?esc_attr($hide_usstate):"") .'">
5923 <select disabled="disabled" id="state_us_field_'.esc_attr($no).'">
5924 <option value="" selected="selected">'.esc_html($field['us_default_state']).'</option>
5925
5926 </select>
5927 <label>'.esc_html__("State","pie-register").'</label>
5928 </div>
5929 <div class="address2 state_div_'.esc_attr($no).'" id="state_canada_'.esc_attr($no).'" style="'.((isset($hide_canstate))?esc_attr($hide_canstate):"").'">
5930 <select disabled="disabled" id="state_canada_field_'.esc_attr($no).'">
5931 <option value="" selected="selected">'.esc_html($field['canada_default_state']).'</option>
5932
5933 </select>
5934 <label>'.esc_html__("Province","pie-register").'</label>
5935 </div>
5936 </div>
5937 <div class="address">
5938 <div class="address2">
5939 <input disabled="disabled" type="text" class="input_fields">
5940 <label>'.esc_html__("Zip / Postal Code","pie-register").'</label>
5941 </div>';
5942
5943 $hideCountry = "";
5944 if(isset($field['address_type']) && $field['address_type'] != "International")
5945 {
5946 $hideCountry = 'display:none;';
5947 }
5948
5949 echo '<div id="address_country_'.esc_attr($no).'" class="address2" style="'.esc_attr($hideCountry).'">
5950 <select disabled="disabled">
5951 <option>'.esc_html($field['default_country']).'</option>
5952 </select>
5953 <label>'.esc_html__("Country","pie-register").'</label>
5954 </div>
5955 </div>';
5956 }
5957 //pie-register-woocommerce addon
5958 function addWooCommerceBillingAddress($field,$no)
5959 {
5960 if ($this->woocommerce_and_piereg_wc_addon_active)
5961 {
5962 $name = $this->createFieldName($field,$no);
5963 $id = $this->createFieldID($field,$no);
5964
5965 echo apply_filters("pieregister_print_woocommerce_billing_address_admin", $name, $id, $field, $no);
5966 }
5967 }
5968
5969 function addWooCommerceShippingAddress($field,$no)
5970 {
5971 if ($this->woocommerce_and_piereg_wc_addon_active)
5972 {
5973 $name = $this->createFieldName($field,$no);
5974 $id = $this->createFieldID($field,$no);
5975
5976 echo apply_filters("pieregister_print_woocommerce_shipping_address_admin", $name, $id, $field, $no);
5977 }
5978 }
5979
5980 function addTextArea($field,$no)
5981 {
5982 $fieldPostName = $this->getPieregFieldName($field,$no);
5983 $name = $this->createFieldName($field,$no);
5984 $id = $this->createFieldID($field,$no);
5985
5986 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>';
5987
5988 }
5989
5990 function addDropdown($field,$no)
5991 {
5992 $fieldPostName = $this->getPieregFieldName($field,$no);
5993
5994 $name = $this->createFieldName($field,$no);
5995 $id = $this->createFieldID($field,$no);
5996
5997 $multiple = "";
5998
5999 $data_f_post_name = 'data-field-post-name="'.$fieldPostName.'"';
6000 if($field['type']=="multiselect")
6001 {
6002 $multiple = 'multiple';
6003 $name .= "[]";
6004 $data_f_post_name = "";
6005 }elseif($field['type']=="custom_role"){
6006 echo '<input type="hidden" id="default_'.esc_attr($field['type']).'">';
6007 }
6008 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).'>';
6009
6010 if(sizeof($field['value']) > 0)
6011 {
6012
6013 for($a = 0 ; $a < sizeof($field['value']) ; $a++)
6014 {
6015 $selected = '';
6016 if(isset($field['selected']) && in_array($a,$field['selected']))
6017 {
6018 $selected = 'selected="selected"';
6019 }
6020 echo '<option '.esc_attr($selected).' value="'.esc_attr($field['value'][$a]).'">'.esc_html($field['display'][$a]).'</option>';
6021 }
6022 }
6023 echo '</select>';
6024 }
6025 function addNumberField($field,$no)
6026 {
6027 $fieldPostName = $this->getPieregFieldName($field,$no);
6028 $name = $this->createFieldName($field,$no);
6029 $id = $this->createFieldID($field,$no);
6030
6031 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).'"/>';
6032 }
6033 function addCheckRadio($field,$no)
6034 {
6035 if(sizeof($field['value']) > 0)
6036 {
6037 $fieldPostName = $this->getPieregFieldName($field,$no);
6038 echo '<div class="radio_wrap">';
6039 $name = $this->createFieldName($field,$no);
6040 $id = $this->createFieldID($field,$no);
6041
6042 echo '<input type="hidden" data-field-post-name="'.esc_attr($fieldPostName).'"/>';
6043 for($a = 0 ; $a < sizeof($field['value']) ; $a++)
6044 {
6045 $checked = '';
6046 if(isset($field['selected']) && is_array($field['selected']) && in_array($a,$field['selected']))
6047 {
6048 $checked = 'checked="checked"';
6049 }
6050 echo '<div class="wrapcheckboxes"><label>'.esc_html($field['display'][$a]).'</label>';
6051
6052 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>';
6053 }
6054 echo '</div>';
6055 }
6056 }
6057 function addDate($field,$no)
6058 {
6059 $name = $this->createFieldName($field,$no);
6060 $id = $this->createFieldID($field,$no);
6061
6062 $datefield = 'style="display:none;"';
6063 $datepicker = 'style="display:none;"';
6064 $datedropdown = 'style="display:none;"';
6065 $calendar_icon = 'style="display:none;"';
6066 $calendar_url = 'style="display:none;"';
6067
6068 if($field['date_type'] == "datefield")
6069 {
6070 $datefield = "";
6071 }
6072 else if($field['date_type'] == "datepicker")
6073 {
6074 $datepicker = "";
6075 if($field['calendar_icon'] == "calendar")
6076 {
6077 $calendar_icon = "";
6078 }
6079 }
6080 else if($field['date_type'] == "datedropdown")
6081 {
6082 $datedropdown = "";
6083 }
6084
6085 echo '<div class="time date_format_field" id="datefield_'.esc_attr($no).'" '.esc_attr($datefield).'>
6086 <div class="time_fields" id="mm_'.esc_attr($no).'">
6087 <input disabled="disabled" type="text" class="input_fields">
6088 <label>'.esc_html__("MM","pie-register").'</label>
6089 </div>
6090 <div class="time_fields" id="dd_'.esc_attr($no).'">
6091 <input disabled="disabled" type="text" class="input_fields">
6092 <label>'.esc_html__("DD","pie-register").'</label>
6093 </div>
6094 <div class="time_fields" id="yyyy_'.esc_attr($no).'">
6095 <input disabled="disabled" type="text" class="input_fields">
6096 <label>'.esc_html__("YYYY","pie-register").'</label>
6097 </div>
6098 </div>';
6099
6100 echo '<div class="time date_format_field" id="datepicker_'.esc_attr($no).'" '.esc_attr($datepicker).'>
6101 <input disabled="disabled" type="text" class="input_fields">
6102 <img src="'.esc_url(PIEREG_PLUGIN_URL.'assets/images/calendar.png').'" id="calendar_image_'.esc_attr($no).'" '.esc_attr($calendar_icon).' /> </div>';
6103
6104
6105
6106 echo '<div class="time date_format_field" id="datedropdown_'.esc_attr($no).'" '.$datedropdown.'>
6107 <div class="time_fields" id="month_'.esc_attr($no).'">
6108 <select disabled="disabled">
6109 <option>'.esc_html__("Month","pie-register").'</option>
6110 </select>
6111 </div>
6112 <div class="time_fields" id="day_'.esc_attr($no).'">
6113 <select disabled="disabled">
6114 <option>'.esc_html__("Day","pie-register").'</option>
6115 </select>
6116 </div>
6117 <div class="time_fields" id="year_'.esc_attr($no).'">
6118 <select disabled="disabled">
6119 <option>'.esc_html__("Year","pie-register").'</option>
6120 </select>
6121 </div>
6122 </div>';
6123
6124
6125 }
6126 function piereg_get_small_string($string,$lenght=100,$atitional_string = "...."){
6127 $string = strip_tags(html_entity_decode( $string , ENT_COMPAT, 'UTF-8'));
6128 if(strlen($string) > $lenght){
6129 $string = wordwrap($string, $lenght, "<br />", true);
6130 $string = explode("<br />",$string);
6131 return $string[0].$atitional_string;
6132 }
6133 return $string;
6134 }
6135 function addHTML($field,$no)
6136 {
6137 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>';
6138 }
6139 function addSectionBreak($field,$no)
6140 {
6141 echo '<div style="width:100%;float:left;border: 1px solid #aaaaaa;margin-top:25px;"></div>';
6142 }
6143 function addPageBreak($field,$no)
6144 {
6145 echo '<img src="'.esc_url(PIEREG_PLUGIN_URL.'assets/images/pagebreak.png').'" style="max-width:100%;" />';
6146 }
6147 function addName($field,$no)
6148 {
6149 $label2 = (isset($field['label2']) and !empty($field['label2']))?$field['label2'] : __("Last Name","pie-register");
6150 $placeholder = (isset($field['placeholder']) and !empty($field['placeholder']))?$field['placeholder'] : "";
6151 $placeholder2 = (isset($field['placeholder2']) and !empty($field['placeholder2']))?$field['placeholder2'] : "";
6152 $id = $this->createFieldID($field,$no);
6153
6154 echo '<input disabled="disabled" type="text" id="'.esc_attr($id).'" placeholder="'.esc_attr($placeholder).'" class="input_fields" data-field-post-name="first_name">';
6155 echo '<input type="hidden" id="default_'.esc_attr($field['type']).'">';
6156
6157 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">';
6158 }
6159 function addTime($field,$no)
6160 {
6161
6162 $name = $this->createFieldName($field,$no);
6163 $id = $this->createFieldID($field,$no);
6164
6165 $format = "display:none;";
6166
6167 if($field['time_type']=="12")
6168 {
6169 $format = "";
6170 }
6171
6172 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>';
6173
6174
6175 }
6176 function addCaptcha($field,$no)
6177 {
6178 $name = $this->createFieldName($field,$no);
6179 $id = $this->createFieldID($field,$no);
6180
6181 if(isset($field['recaptcha_type']) && $field['recaptcha_type'] == 2)
6182 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/').'" />';
6183 else
6184 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/').'" />';
6185
6186 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>';
6187 echo '<input type="hidden" id="default_'.esc_attr($field['type']).'">';
6188 }
6189 function addMath_Captcha($field,$no)
6190 {
6191 $name = $this->createFieldName($field,$no);
6192 $id = $this->createFieldID($field,$no);
6193
6194 echo '<img id="captcha_img" src="'.esc_url(PIEREG_PLUGIN_URL.'assets/images/math_catpcha.png').'" />';
6195 echo '<input type="hidden" id="default_'.esc_attr($field['type']).'">';
6196 }
6197 function addList($field,$no)
6198 {
6199 if($field['cols']=="0")
6200 $field['cols'] = 1;
6201
6202 $name = $this->createFieldName($field,$no);
6203 $id = $this->createFieldID($field,$no);
6204 $width = 90 / $field['cols'];
6205
6206 for($a = 1 ; $a <= $field['cols'] ;$a ++)
6207 {
6208 echo '<input type="text" id="field_'.esc_attr($no).'" class="input_fields" style="width:'.esc_attr($width).'%;margin-right:2px;" >';
6209 }
6210
6211 echo '<img src="'.esc_url(PIEREG_PLUGIN_URL.'assets/images/plus.png').'" />';
6212 }
6213 function addPricing($field,$no)
6214 {
6215 $fieldPostName = $this->getPieregFieldName($field,$no);
6216 $name = $this->createFieldName($field,$no);
6217 $id = $this->createFieldID($field,$no);
6218
6219 echo '<input type="hidden" data-field-post-name="'.esc_attr($fieldPostName).'"/>';
6220 echo '<input type="hidden" id="default_'.esc_attr($field['type']).'">';
6221 if(isset($field['display']) && sizeof($field['display']) > 0)
6222 {
6223 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;"':"")).'>';
6224 echo '<input type="hidden" data-field-post-name="'.esc_attr($fieldPostName).'"/>';
6225 for($a = 0 ; $a < sizeof($field['display']) ; $a++)
6226 {
6227 $checked = '';
6228 if(isset($field['selected']) && is_array($field['selected']) && in_array($a,$field['selected']))
6229 {
6230 $checked = 'checked="checked"';
6231 }
6232 echo '<label>'.esc_html($field['display'][$a]).'</label>';
6233 echo '<input '.esc_attr($checked).' type="radio" name="'.esc_attr($field['type']).'_'.esc_attr($field['id']).'[]" class="radio_fields" disabled="disabled" >';
6234 }
6235 echo '<input type="hidden" id="default_'.esc_attr($field['type']).'">';
6236 echo '</div>';
6237 }
6238
6239 echo '<div class="piereg_pricing_select select_wrap" '.((isset($field['field_as']) && $field['field_as'] != 1)?'style="display: none;"':"").'>';
6240
6241 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).'">';
6242 if(isset($field['display']) && sizeof($field["display"]) > 0)
6243 {
6244 for($a = 0 ; $a < sizeof($field["display"]) ; $a++)
6245 {
6246 $selected = '';
6247 if(in_array($a,$field['selected']))
6248 {
6249 $selected = 'selected="selected"';
6250 }
6251 echo '<option '.$selected.' value="'.esc_attr($field['value'][$a]).'">'.esc_html($field['display'][$a]).'</option>';
6252 }
6253 }
6254 echo '</select>';
6255 echo '</div>';
6256
6257 }
6258 function createFieldName($field)
6259 {
6260 return "field_[".$field['id']."]";
6261 }
6262 function createFieldID($field,$no)
6263 {
6264 return "field_".$field['id'];
6265 }
6266
6267 private function log_ipn_results($success) {
6268 $hostname = gethostbyaddr( sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) );
6269 // Timestamps
6270 $text = '[' . date ( 'm/d/Y g:i A' ) . '] - ';
6271 // Success or failure being logged?
6272 if ($success)
6273 $this->ipn_status = $text . 'SUCCESS:' . $this->ipn_status . "!\n";
6274 else
6275 $this->ipn_status = $text . 'FAIL: ' . $this->ipn_status . "!\n";
6276 // Log the POST variables
6277 $this->ipn_status .= "[From:" . $hostname . "|" . sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) . "]IPN POST Vars Received By Paypal_IPN Response API:\n";
6278 foreach ( $this->ipn_data as $key => $value ) {
6279 $this->ipn_status .= "$key=$value \n";
6280 }
6281 // Log the response from the paypal server
6282 $this->ipn_status .= "IPN Response from Paypal Server:\n" . $this->ipn_response;
6283 $this->write_to_log();
6284 }
6285 private function write_to_log() {
6286 if (! $this->ipn_log)
6287 return; // is logging turned off?
6288
6289 if(file_exists(PIE_LOG_FILE))
6290 {
6291 // Write to log
6292 $fp = fopen ( PIE_LOG_FILE , 'a+' );
6293 fwrite ( $fp, $this->ipn_status . "\r\n" );
6294 fclose ( $fp ); // close file
6295 //chmod ( PIE_LOG_FILE , 0600 );
6296 }
6297 }
6298
6299 public function get_user_by_hash($user_data){
6300 $data_array = explode("__",$user_data);
6301 $user = get_user_by('id', $data_array[1]);
6302 return sanitize_email($user->user_email);
6303 }
6304
6305 public function validate_ipn() {
6306
6307 /*
6308 * IPN LOG
6309 */
6310 $user_payment_log = array();
6311 $user_payment_log['method'] = "Paypal";
6312 $user_payment_log['type'] = "Hosted Button IPN ";
6313 $user_payment_log['responce'] = $_REQUEST;
6314 $user_payment_log['date'] = date_i18n("d-m-Y H:i:s");
6315 $user_email = $this->get_user_by_hash($_REQUEST['custom']);
6316 $log_message = print_r( $user_payment_log, 1 );
6317 $this->pr_payment_log($log_message);
6318 /**
6319 * v3.7.1.5 - Temporary disabled log in database.
6320 * Payment logs are logging in log file only.
6321 */
6322 // $this->piereg_save_payment_log_option( $user_email, "PayPal", "Hosted Button IPN", $_REQUEST );
6323 unset($log_message);
6324 unset($user_payment_log);
6325 //IPN log end
6326
6327 global $wpdb;
6328 $piereg = get_option(OPTION_PIE_REGISTER);
6329 $hostname = gethostbyaddr ( sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) );
6330 if (! preg_match ( '/paypal\.com$/', $hostname )) {
6331 $this->ipn_status = 'Validation post isn\'t from PayPal';
6332 $this->log_ipn_results ( false );
6333 return false;
6334 }
6335
6336 if (isset($this->txn_id) && ($_POST['txn_id']==$this->txn_id)) {
6337 $this->ipn_status = "txn_id have a duplicate";
6338 $this->log_ipn_results ( false );
6339 return false;
6340 }
6341
6342 // parse the paypal URL
6343 $paypal_url = ($_POST['test_ipn'] == 1) ? PIE_SSL_SAND_URL : PIE_SSL_P_URL;
6344 $url_parsed = parse_url($paypal_url);
6345
6346 // generate the post string from the _POST vars aswell as load the
6347 // _POST vars into an arry so we can play with them from the calling
6348 // script.
6349 $post_string = '';
6350
6351 foreach ($_POST as $field=>$value) {
6352 $this->ipn_data["$field"] = $value;
6353 $post_string .= $field.'='.urlencode(stripslashes($value)).'&';
6354 }
6355 $post_string.="cmd=_notify-validate"; // append ipn command
6356
6357 // open the connection to paypal
6358 if ($piereg['paypal_sandbox'] == "yes") {
6359 $fp = fsockopen ( 'tls://www.sandbox.paypal.com', "443", $err_num, $err_str, 60 );
6360 if(!$fp) {
6361 $fp = fsockopen ( 'ssl://www.sandbox.paypal.com', "443", $err_num, $err_str, 60 );
6362 }
6363 }else{
6364 $fp = fsockopen ( 'tls://www.paypal.com', "443", $err_num, $err_str, 60 );
6365 if(!$fp) {
6366 $fp = fsockopen ( 'ssl://www.paypal.com', "443", $err_num, $err_str, 60 );
6367 }
6368 }
6369
6370 if(!$fp) {
6371 // could not open the connection. If loggin is on, the error message
6372 // will be in the log.
6373 $this->ipn_status = "fsockopen error no. $err_num: $err_str";
6374 $this->log_ipn_results(false);
6375 return false;
6376 } else {
6377 // Post the data back to paypal
6378 fputs($fp, "POST $url_parsed[path] HTTP/1.1\r\n");
6379 fputs($fp, "Host: $url_parsed[host]\r\n");
6380 fputs($fp, "User-Agent: Pie-Register IPN Validation Service\r\n");
6381 fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
6382 fputs($fp, "Content-length: ".strlen($post_string)."\r\n");
6383 fputs($fp, "Connection: close\r\n\r\n");
6384 fputs($fp, $post_string . "\r\n\r\n");
6385
6386 // loop through the response from the server and append to variable
6387 while(!feof($fp)) {
6388 $this->ipn_response .= fgets($fp, 1024);
6389 }
6390 fclose($fp); // close connection
6391 }
6392
6393 // Invalid IPN transaction. Check the $ipn_status and log for details.
6394 if (!preg_match("/VERIFIED/",$this->ipn_response)) {
6395 $this->ipn_status = "IPN NOT VERIFIED\n".print_r($this->ipn_response,1)."\n";
6396 $this->log_ipn_results(false);
6397 return false;
6398 } else {
6399 $this->ipn_status = "IPN VERIFIED";
6400 //////////// Verify User /////////////
6401 // paypal Variable our custom variable
6402 if( isset($_REQUEST['paypal']) && !empty($_REQUEST['paypal']) )
6403 $this->processPostPayment($_REQUEST['paypal']);
6404 //////////////////////////////////////
6405 $this->log_ipn_results(true);
6406 header("HTTP/1.1 200 OK");
6407 die();
6408 return true;
6409 }
6410 header("HTTP/1.1 402 Payment Required");
6411 die();
6412 }
6413 function ValidPUser(){
6414 global $wpdb;
6415 //$piereg = get_option( 'pie_register' );
6416 $piereg = get_option(OPTION_PIE_REGISTER);
6417
6418 if(isset($_POST['txn_id']) && $_GET['action'] == 'ipn_success'){
6419 //We have a IPN to Validate
6420 $this->validate_ipn();
6421 }
6422 if(isset($_GET['action']) && $_GET['action'] == 'payment_success'){
6423 $this->payment_success_cancel_after_register("payment=success");
6424 }elseif(isset($_GET['action']) && $_GET['action'] == 'payment_cancel'){
6425 /******************************************************/
6426 $user_id = intval(base64_decode($_GET['paypal']));
6427 $user_data = get_userdata($user_id);
6428 if(is_object($user_data)){
6429 $form = new Registration_form();
6430 //$option = get_option( 'pie_register' );
6431 $option = get_option(OPTION_PIE_REGISTER);
6432 $subject = html_entity_decode($option['user_subject_email_payment_faild'],ENT_COMPAT,"UTF-8");
6433 $subject = $this->filterSubject($user_data,$subject);
6434 $message_temp = "";
6435 if($option['user_formate_email_payment_faild'] == "0"){
6436 $message_temp = nl2br(strip_tags($option['user_message_email_payment_faild']));
6437 }else{
6438 $message_temp = $option['user_message_email_payment_faild'];
6439 }
6440 $message = $form->filterEmail($message_temp,$user_data, "" );
6441 $from_name = $option['user_from_name_payment_faild'];
6442 $from_email = $option['user_from_email_payment_faild'];
6443 $reply_email = $option['user_to_email_payment_faild'];
6444 //Headers
6445 $headers = 'MIME-Version: 1.0' . "\r\n";
6446 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
6447
6448 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL))//Validating From
6449 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
6450
6451 if($reply_email){
6452 $headers .= "Reply-To: {$reply_email}\r\n";
6453 $headers .= "Return-Path: {$reply_email}\r\n";
6454
6455 }else{
6456 $headers .= "Reply-To: {$from_email}\r\n";
6457 $headers .= "Return-Path: {$from_email}\r\n";
6458 }
6459
6460 if((isset($option['user_enable_payment_faild']) && $option['user_enable_payment_faild'] == 1) && !wp_mail($user_data->user_email, $subject, $message , $headers)){
6461 $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__)));
6462 }
6463 unset($user_data);
6464 }
6465 /******************************************************/
6466 $this->payment_success_cancel_after_register("payment=cancel");
6467 }else{
6468 return false;
6469 }
6470 }
6471 function processPostPayment( $custom_user_data )
6472 {
6473 if( empty($custom_user_data) )
6474 return false;
6475
6476 add_filter( 'wp_mail_content_type', array($this,'set_html_content_type' ));
6477
6478 $custom_user_data_decode = base64_decode($custom_user_data);
6479 $return_data = explode( "|", $custom_user_data_decode );
6480 $hash = $return_data[0];
6481 $user_id = intval($return_data[1]);
6482
6483 #get_usermeta deprecated
6484 $check_hash = get_user_meta( $user_id, "hash", true);
6485
6486 if($check_hash != $hash)
6487 return false;
6488
6489 if(!is_numeric($user_id ))
6490 return false;
6491
6492 $user = new WP_User($user_id);
6493 $option = get_option(OPTION_PIE_REGISTER);
6494 update_user_meta( $user_id, 'active',1);
6495 update_user_meta( $user_id, 'pie_paypal_txn_id', sanitize_text_field($_POST['txn_id']));
6496 update_user_meta( $user_id, 'pie_paypal_payer_id', sanitize_text_field($_POST['payer_id']));
6497
6498 //Sending E-Mail to newly active user
6499 $subject = html_entity_decode($option['user_subject_email_payment_success'],ENT_COMPAT,"UTF-8");
6500 $subject = $this->filterSubject($user,$subject);
6501 $user_email = $user->data->user_email;
6502 $message_temp = "";
6503 if($option['user_formate_email_payment_success'] == "0"){
6504 $message_temp = nl2br(strip_tags($option['user_message_email_payment_success']));
6505 }else{
6506 $message_temp = $option['user_message_email_payment_success'];
6507 }
6508
6509 $message = $this->filterEmail($message_temp,$user);
6510 $from_name = $option['user_from_name_payment_success'];
6511 $from_email = $option['user_from_email_payment_success'];
6512 $reply_email = $option['user_to_email_payment_success'];
6513
6514 //Headers
6515 $headers = 'MIME-Version: 1.0' . "\r\n";
6516 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
6517 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL))//Validating From
6518 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
6519 if($reply_email){
6520 $headers .= "Reply-To: {$reply_email}\r\n";
6521 $headers .= "Return-Path: {$reply_email}\r\n";
6522 }else{
6523 $headers .= "Reply-To: {$from_email}\r\n";
6524 $headers .= "Return-Path: {$from_email}\r\n";
6525 }
6526 if((isset($option['user_enable_payment_success']) && $option['user_enable_payment_success'] == 1) && !wp_mail($user_email, $subject, $message , $headers)){
6527 $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__)));
6528 }
6529 // mailchimp related code within PR
6530 do_action('pireg_after_verification_users', $user);
6531 }
6532
6533 function Add_payment_option_PaypalStandard($field_as)
6534 {
6535 $PR_options = "";
6536 $check_payment = $this->get_pr_global_options();
6537 if( $check_payment["enable_paypal"] == 1 && !empty($check_payment['paypal_butt_id']) )
6538 {
6539 if( $field_as == 0 )
6540 $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>';
6541 else
6542 $PR_options = '<option value="PaypalStandard" data-img="'.esc_url(plugins_url("assets/images/PaypalStandard-logo.png",__FILE__)).'">'.esc_html__("Paypal (Standard)","pie-register").'</option>';
6543 }
6544 return $PR_options;
6545 }
6546
6547 function set_html_content_type()
6548 {
6549 return 'text/html';
6550 }
6551 function deleteUsers($user_id = 0,$user_email = "",$user_registered = "",$autodelete = false)
6552 {
6553 $option = get_option(OPTION_PIE_REGISTER);
6554 $grace_period = isset($option['grace_period']) ? ((int)$option['grace_period']) : 0;
6555 $is_active = get_user_meta($user_id, 'active', true);
6556
6557 if( isset($option['enable_paypal']) && $option['enable_paypal'] == 1 )
6558 {
6559 $grace = $grace_period;
6560 }
6561 else if(($this->check_enable_payment_method()) == "true" )
6562 {
6563 $payment_setting_remove_user_days = isset($option['payment_setting_remove_user_days']) ? $option['payment_setting_remove_user_days'] : 0;
6564 $grace = ((int)$payment_setting_remove_user_days);
6565 }
6566 else
6567 {
6568 $grace = $grace_period;
6569 }
6570
6571 $register_type = get_user_meta( $user_id , "register_type" , true);
6572
6573
6574 if( ($grace != 0 and $user_id != 0) and ($user_email != "" and $user_registered != "") and ($register_type != '' and $register_type != "admin_verify") && $is_active == 0 )
6575 {
6576 $date = date_i18n("Y-m-d 00:00:00",strtotime("-{$grace} days"));
6577
6578 if($user_registered < $date)
6579 {
6580 global $errors;
6581 $errors = new WP_Error();
6582
6583 if((isset($option['user_enable_user_perm_blocked_notice']) && $option['user_enable_user_perm_blocked_notice'] == 1))
6584 {
6585 $this->wp_mail_send($user_email,"user_perm_blocked_notice");
6586 }
6587
6588 global $wpdb;
6589 $user_table = $wpdb->prefix."users";
6590 $user_meta_table = $wpdb->prefix."usermeta";
6591 if(!$wpdb->query( $wpdb->prepare("DELETE FROM `".$user_meta_table."` WHERE `user_id` = %d", $user_id) )){
6592 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
6593 }
6594 if(!$wpdb->query( $wpdb->prepare("DELETE FROM `".$user_table."` WHERE `ID` = %d", $user_id) )){
6595 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
6596 }
6597
6598 if( $autodelete === false )
6599 {
6600 $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')));
6601 wp_logout();
6602 }
6603
6604 return true;
6605 }
6606 }
6607 return false;
6608 }
6609 function deleteUnverifiedUsers()
6610 {
6611
6612 $args = array(
6613 'meta_query' => array(
6614 'relation' => 'AND',
6615 array(
6616 'key' => 'active',
6617 'value' => '0',
6618 'compare' => '='
6619 ),
6620 array(
6621 'key' => 'register_type',
6622 'value' => 'email_verify',
6623 'compare' => '='
6624 )
6625 )
6626 );
6627
6628 $user_query = new WP_User_Query( $args );
6629 $users = $user_query->get_results();
6630
6631 if(count($users) > 0)
6632 {
6633 foreach($users as $user)
6634 {
6635 $user_email = $user->user_email;
6636 $user_login = $user->user_login;
6637
6638 if($this->deleteUsers($user->ID,$user->user_email,$user->user_registered,true))
6639 {
6640 $deleted = get_option("deleted_users");
6641
6642 $deleted["pie_user_" . $user_login] = $user_email;
6643 update_option("deleted_users",$deleted);
6644 }
6645 }
6646 }
6647 }
6648 function unique_user()
6649 {
6650 $username = sanitize_user($_REQUEST['fieldValue']);
6651 $validateId = sanitize_key($_REQUEST['fieldId']);
6652
6653 $arrayToJs = array();
6654 $arrayToJs[0] = $validateId;
6655
6656 if(!username_exists($username ))
6657 { // validate??
6658 $arrayToJs[1] = true; // RETURN TRUE
6659 echo json_encode($arrayToJs); // RETURN ARRAY WITH success
6660 }
6661 else
6662 {
6663 for($x=0;$x<1000000;$x++)
6664 {
6665 if($x == 990000)
6666 {
6667 $arrayToJs[1] = false;
6668 echo json_encode($arrayToJs); // RETURN ARRAY WITH ERROR
6669 }
6670 }
6671 }
6672 die();
6673 }
6674 function outputRegForm($fromwidget=false,$form_id = "0",$title="true",$description="true"){
6675 $form = new Registration_form_template();
6676 $success = '' ;
6677 $error = '' ;
6678 $option = get_option(OPTION_PIE_REGISTER);
6679 $registration_from_fields = '<div class="pieregformWrapper pieregWrapper">';
6680 $registration_from_fields .= '<div id="show_pie_register_error_js" class="piereg_entry-content"></div>';
6681
6682 $IsWidgetForm = "";
6683 if($fromwidget)
6684 $IsWidgetForm = "widget_";
6685
6686 $registration_from_fields .= '<div id="pie_register_reg_form">';
6687
6688 $registration_from_fields = apply_filters( 'pie_register_frontend_output_before', __($registration_from_fields,"pie-register") );
6689
6690 /* Anyone can register */
6691 if($this->is_anyone_can_register() || $this->is_pr_preview){
6692 if(false === $this->is_pr_preview):
6693 $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).'">';
6694 if( function_exists( 'wp_nonce_field' )):
6695 $registration_from_fields .= wp_nonce_field('piereg_wp_registration_form_nonce','piereg_registration_form_nonce', true, false);
6696 endif;
6697 else:
6698 $registration_from_fields .= '<form onsubmit="return false" class="prRegFormPreview" id="pie_'.esc_attr((trim($IsWidgetForm))).'regiser_form" data-form="'.esc_attr($form_id).'">';
6699 endif;
6700
6701
6702 $output = $form->printFields($fromwidget,$form_id,$title,$description);
6703 if($form->countPageBreaks() > 1){
6704 $registration_from_fields .= '<div class="piereg_progressbar"></div>';
6705 }
6706 $registration_from_fields .= $output;
6707 if(false === $this->is_pr_preview):
6708 $registration_from_fields .= '</form>';
6709 else:
6710 $registration_from_fields .= '</form>';
6711 endif;
6712
6713 }else{
6714 $registration_from_fields .= '<div class="alert alert-warning"><p class="piereg_warning">'.esc_html__("User registration is currently not allowed.","pie-register").'</p></div>';
6715 }
6716 $registration_from_fields = apply_filters( 'pie_register_frontend_output_after', __($registration_from_fields,"pie-register") );
6717
6718 $registration_from_fields .= '</div></div>';
6719
6720 $this->piereg_forms_per_page[ $form_id ] = $this->getCurrentFields($form_id);
6721
6722 return $registration_from_fields;
6723
6724 }
6725 function showForm($id="",$title="true",$description="true")
6726 {
6727 global $errors, $piereg_post_array;
6728 $option = get_option(OPTION_PIE_REGISTER);
6729 add_filter( 'wp_mail_content_type', array($this,'set_html_content_type' ));
6730 $classes_preset = array( 'piereg_container', 'pieregWrapper' );
6731
6732 $classes = apply_filters( 'pie_register_frontend_container_class', $classes_preset);
6733
6734 $classes = implode( ' ' , $classes );
6735
6736 $output = '<div class="'.esc_attr($classes).'">';
6737 if( empty($this->pie_post_array) )
6738 {
6739 $this->pie_post_array = $piereg_post_array;
6740 }
6741
6742 if( isset($_GET['action'],$_GET['key']) && $_GET['action'] == 'pie-ic' && !empty($_GET['key']) ) {
6743 $invite_code = sanitize_text_field(base64_decode(urldecode(trim($_GET['key']))));
6744 $invite_code = explode('|', $invite_code);
6745 $invite_code = ($invite_code[1]) ? $invite_code[1] : "";
6746 $allowed_invite_codes = [];
6747 $manage_settings = maybe_unserialize(get_option("pie_fields"));
6748 foreach($manage_settings as $managed_setting){
6749 if($managed_setting['type'] == 'invitation'){
6750 if(isset($managed_setting['allowed_codes'])){
6751 $allowed_invite_codes = $managed_setting['allowed_codes'];
6752
6753 if(!in_array($invite_code,$allowed_invite_codes)){
6754 $this->pie_post_array['error'] = apply_filters("piereg_invalid_invitaion_code",'<strong>'.ucwords(esc_html__('error','pie-register')).'</strong>: Invalid invitation code');
6755 }
6756 break;
6757 }
6758 }
6759 }
6760 }
6761
6762 if(isset($this->pie_post_array['success']) && $this->pie_post_array['success'] != "")
6763 $output .= '<p class="piereg_message">'.apply_filters('piereg_messages',$this->pie_post_array['success'],"pie-register").'</p>';
6764 if(isset($this->pie_post_array['error']) && $this->pie_post_array['error'] != "")
6765 $output .= '<p class="piereg_login_error">'.apply_filters('piereg_messages',$this->pie_post_array['error'],"pie-register").'</p>';
6766
6767 if(isset($this->pie_post_array['registration_success']) && $this->pie_post_array['registration_success'] != ""){
6768 $output .= '<p class="piereg_message">'.apply_filters('piereg_messages',$this->pie_post_array['registration_success'],"pie-register").'</p>';
6769 unset($_POST);
6770 }
6771 if(isset($errors->errors) && sizeof($errors->errors) > 0)
6772 {
6773 $error = "";
6774 foreach($errors->errors as $key=>$err)
6775 {
6776 if($key != "login-error")
6777 $error .= $err[0] . "<br />";
6778 }
6779 if(!empty($error))
6780 $output .= '<p class="piereg_login_error">'.apply_filters('piereg_messages',$error,"pie-register").'</p>';
6781 }
6782 $output .= $this->outputRegForm(FALSE,$id,$title,$description);
6783 $output .= '</div>';
6784 return $output;
6785 }
6786 function showLoginForm()
6787 {
6788 $this->piereg_ssl_template_redirect();
6789 global $errors,$pagenow;
6790 $option = $this->get_pr_global_options();
6791
6792 // For Form with Gutenberg or WPBakery Preview
6793 $this->is_pr_preview = ( (isset($_GET['context']) && $_GET['context'] == 'edit') || (isset($_GET['vc_editable']) && $_GET['vc_editable'] == 'true') ) ? true : $this->is_pr_preview;
6794
6795 if(isset($_GET['pr_renew_account']) && $_GET['pr_renew_account'] == true)
6796 {
6797 $this->pie_post_array['warning'] = (__("Please renew your account","pie-register"));
6798 if( file_exists(PIEREG_DIR_NAME . "/renew_account.php") )
6799 include_once("renew_account.php");
6800
6801 $is_renew_after_auth = false;
6802 $user_array = array();
6803
6804 if(isset($_GET['auth'], $_GET['auth_key']) && !empty($_GET['auth']) && !empty($_GET['auth_key']) )
6805 {
6806 $user_name = sanitize_text_field(urldecode($_GET['auth']));
6807 $auth_key = sanitize_text_field(urldecode($_GET['auth_key']));
6808
6809 $user_name = sanitize_user(urldecode(base64_decode($user_name)));
6810 $user = get_user_by("login",$user_name);
6811
6812 if(!empty($user))
6813 {
6814 $auth_key = sanitize_text_field($_GET['auth_key']);
6815 $auth_key_hash = get_user_meta($user->ID,"pr_renew_account_hash", true);
6816 if(!empty($auth_key_hash))
6817 {
6818 if(trim($auth_key) == trim($auth_key_hash))
6819 {
6820 $is_renew_after_auth = true;
6821 $user_array['username'] = $user->data->user_login;
6822 $user_array['email'] = $user->data->user_email;
6823 }
6824 }
6825 }
6826 }
6827
6828 $PR_show_renew_account = PR_show_renew_account($is_renew_after_auth,$user_array);
6829 return $PR_show_renew_account;
6830 }
6831 else{
6832 if (is_user_logged_in() && !$this->is_pr_preview && !is_admin()) {
6833 return apply_filters("pie_login_form_logged_in_msg",__("<p>You are already logged in.</p>","pie-register"));
6834 }
6835
6836 $this->set_pr_stats("login","view");
6837 if( file_exists(PIEREG_DIR_NAME . "/login_form.php") )
6838 include_once("login_form.php");
6839 $output = pieOutputLoginForm();
6840 return $output;
6841 }
6842 }
6843
6844 function showForgotPasswordForm()
6845 {
6846 $this->piereg_ssl_template_redirect();
6847 global $errors;
6848
6849 $option = get_option(OPTION_PIE_REGISTER);
6850 // For Form with Gutenberg Or WPBakery Preview
6851 $this->is_pr_preview = ( (isset($_GET['context']) && $_GET['context'] == 'edit') || (isset($_GET['vc_editable']) && $_GET['vc_editable'] == 'true') ) ? true : $this->is_pr_preview;
6852
6853 if(!is_admin() && is_user_logged_in() && !$this->is_pr_preview)
6854 {
6855 return apply_filters("pie_forgot_form_logged_in_msg",__("<p>You are already logged in.</p>","pie-register"));
6856 }
6857 else
6858 {
6859 $this->set_pr_stats("forgot","view");
6860
6861 if( file_exists(PIEREG_DIR_NAME . "/forgot_password.php") )
6862 include_once("forgot_password.php");
6863 $output = pieResetFormOutput();
6864 return $output;
6865 }
6866
6867 }
6868
6869 function showProfile()
6870 {
6871 $option = $this->get_pr_global_options();
6872 $this->piereg_ssl_template_redirect();
6873 global $current_user,$pie_success,$pie_error,$pie_error_msg,$pie_suucess_msg,$profile_updated;
6874 if ( is_user_logged_in() ){
6875
6876 global $current_user;
6877 wp_get_current_user();
6878 $form_id = get_user_meta($current_user->ID,"user_registered_form_id",true);
6879 if( isset($_GET['edit_user']) && $_GET['edit_user'] == "1" ){
6880 $form = new Edit_form($current_user,$form_id);
6881 if( isset($_POST['pie_submit_update'], $_POST['piereg_edit_profile_nonce']) && wp_verify_nonce($_POST['piereg_edit_profile_nonce'], 'piereg_wp_edit_profile_nonce') ) {
6882 $form->error = "";
6883 $errors = new WP_Error();
6884 $errors = $form->validateRegistration($errors);
6885 if(sizeof($errors->errors) > 0) {
6886 foreach($errors->errors as $err)
6887 {
6888 $form->error .= $err[0] . "<br />";
6889 }
6890 }
6891 else
6892 {
6893 $user_data = array('ID' => $current_user->ID);
6894 if(isset($_POST['url'])) {
6895 $user_data["user_url"] = esc_url_raw($_POST['url']);
6896 $form->pie_success = 1;
6897 }
6898
6899 if($current_user->data->user_email != $_POST['e_mail']) {
6900 $user_data["user_email"] = sanitize_email($_POST['e_mail']);
6901 $form->pie_success = 1;
6902 }
6903 if(isset($_POST['old_password']) && wp_check_password( $_POST['old_password'], $current_user->data->user_pass, $current_user->ID ) && $_POST['password'] != ''){
6904
6905 if(isset($_POST['confirm_password'])){
6906 if($_POST['password'] == $_POST['confirm_password']){
6907 $user_data["user_pass"] = trim($_POST['password']);
6908 $form->pie_success = 1;
6909 }
6910 }else{
6911 $user_data["user_pass"] = trim($_POST['password']);
6912 $form->pie_success = 1;
6913 }
6914 }
6915
6916 $this->pie_post_array = $this->piereg_sanitize_post_data_escape( ( (isset($_POST) && !empty($_POST)) ? $_POST : array() ) );
6917
6918 # newlyAddedHookFilter
6919 do_action( 'piereg_update_profile_event', $current_user->ID, $form_id, $this->pie_post_array );
6920
6921 $user = get_userdata( $current_user->ID );
6922
6923 $id = wp_update_user( $user_data );
6924 // $form->UpdateUser();
6925 if ( $form->UpdateUser() == 1 )
6926 {
6927 $profile_updated = 1;
6928 }
6929 $this->send_admin_notifications($option,$user,$user->data->user_pass);
6930 }
6931
6932 }
6933 $output = '';
6934 $output .= '<div class="piereg_container pieregWrapper">';
6935 if($form->pie_success)
6936 $output .= '<div class="alert alert-success"><p class="piereg_message">'.$form->pie_success_msg.'</p></div>';
6937
6938 elseif($form->error != "")
6939 $output .= '<div class="alert alert-danger"><p class="piereg_login_error">'.$form->error.'</p></div>';
6940
6941 if(isset($this->pie_post_array['success']) && $this->pie_post_array['success'] != "")
6942 $output .= '<p class="piereg_message">'.apply_filters('piereg_messages',__($this->pie_post_array['success'],"pie-register")).'</p>';
6943
6944 if(isset($this->pie_post_array['error']) && $this->pie_post_array['error'] != "")
6945 $output .= '<p class="piereg_login_error">'.apply_filters('piereg_messages',__($this->pie_post_array['error'],"pie-register")).'</p>';
6946
6947 if( isset($_GET['pr_msg'], $_GET['type']) && !empty($_GET['pr_msg']) && $_GET['type'] == "success" )
6948 $output .= '<p class="piereg_message">'.apply_filters('piereg_messages',sanitize_text_field(base64_decode($_GET['pr_msg']))).'</p>';
6949 elseif( isset($_GET['pr_msg'], $_GET['type']) && !empty($_GET['pr_msg']) && $_GET['type'] == "error" )
6950 $output .= '<p class="piereg_login_error">'.apply_filters('piereg_messages',sanitize_text_field(base64_decode($_GET['pr_msg']))).'</p>';
6951
6952 if( file_exists(PIEREG_DIR_NAME."/edit_form.php") )
6953 require_once(PIEREG_DIR_NAME."/edit_form.php");
6954
6955 $output.= pie_edit_userdata($form_id);
6956 $output .= '</div>';
6957 return $output;
6958 }
6959 else
6960 {
6961 $form_id = get_user_meta($current_user->ID,"user_registered_form_id",true);
6962 if( $form_id == "" ) {
6963 $form_free_id = $this->regFormForFreeVers();
6964 update_user_meta($current_user->ID, 'user_registered_form_id', $form_free_id);
6965 $form_id = $form_free_id;
6966 }
6967
6968 $profile_front = new Profile_front($current_user,$form_id);
6969 // Newly added hook to make changes to the profile content
6970 $profile_form_data = apply_filters('piereg_after_profile_printed', __($profile_front->print_user_profile($form_id),'pie-register'));
6971 return $profile_form_data;
6972 }
6973 }
6974 else
6975 {
6976 $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');
6977
6978 $notloggedinmsg = apply_filters('piereg_profile_if_not_loggedin',$notloggedinmsg); # newlyAddedHookFilter
6979
6980 return $notloggedinmsg;
6981 }
6982 }
6983
6984
6985 /* GDPR - Personal Data Exporter */
6986 /*
6987 function my_plugin_exporter( $email_address, $page = 1 ) {
6988
6989 $export_items = array();
6990 $user = get_user_by('email', $email_address);
6991 $user_ID = $user->ID;
6992
6993 $data = array(
6994 array(
6995 'name' => __( 'Commenter Latitude' ),
6996 'value' => 'ABC'
6997 ),
6998 array(
6999 'name' => __( 'Commenter Longitude' ),
7000 'value' => 'XYZ'
7001 )
7002 );
7003 $export_items[] = array(
7004 'group_id' => 167,
7005 'group_label' => "Comments",
7006 'item_id' => 265,
7007 'data' => $data,
7008 );
7009
7010 */
7011 /*
7012 $comments = get_comments(
7013 array(
7014 'author_email' => $email_address,
7015 'number' => $number,
7016 'paged' => $page,
7017 'order_by' => 'comment_ID',
7018 'order' => 'ASC',
7019 )
7020 );
7021
7022 foreach ( (array) $comments as $comment ) {
7023 $latitude = get_comment_meta( $comment->comment_ID, 'latitude', true );
7024 $longitude = get_comment_meta( $comment->comment_ID, 'longitude', true );
7025
7026 // Only add location data to the export if it is not empty
7027 if ( ! empty( $latitude ) ) {
7028 // Most item IDs should look like postType-postID
7029 // If you don't have a post, comment or other ID to work with,
7030 // use a unique value to avoid having this item's export
7031 // combined in the final report with other items of the same id
7032 $item_id = "comment-{$comment->comment_ID}";
7033
7034 // Core group IDs include 'comments', 'posts', etc.
7035 // But you can add your own group IDs as needed
7036 $group_id = 'comments';
7037
7038 // Optional group label. Core provides these for core groups.
7039 // If you define your own group, the first exporter to
7040 // include a label will be used as the group label in the
7041 // final exported report
7042 $group_label = __( 'Comments' );
7043
7044 // Plugins can add as many items in the item data array as they want
7045 $data = array(
7046 array(
7047 'name' => __( 'Commenter Latitude' ),
7048 'value' => $latitude
7049 ),
7050 array(
7051 'name' => __( 'Commenter Longitude' ),
7052 'value' => $longitude
7053 )
7054 );
7055
7056 $export_items[] = array(
7057 'group_id' => $group_id,
7058 'group_label' => $group_label,
7059 'item_id' => $item_id,
7060 'data' => $data,
7061 );
7062 }
7063 }
7064
7065 // Tell core if we have more comments to work on still
7066 $done = count( $comments ) < $number;
7067
7068 */
7069 /*
7070 return array(
7071 'data' => $export_items,
7072 'done' => true,
7073 );
7074
7075 }
7076 function register_my_plugin_exporter( $exporters ) {
7077 $exporters['pie-register'] = array(
7078 'exporter_friendly_name' => __( 'Pie Register - Custom Fields' ),
7079 'callback' => array($this, 'my_plugin_exporter'),
7080 );
7081
7082 return $exporters;
7083 }
7084 */
7085
7086 /* GDPR - Personal Data Exporter */
7087
7088
7089 function show_renew_account()
7090 {
7091 $this->piereg_ssl_template_redirect();
7092 if( file_exists(PIEREG_DIR_NAME . "/renew_account.php") )
7093 include_once("renew_account.php");
7094
7095 $show_renew_account = PR_show_renew_account();
7096 return $show_renew_account;
7097 }
7098
7099 function afterLoginPage()
7100 {
7101 global $wpdb,$current_user;
7102 $option = $this->get_pr_global_options();
7103 /*
7104 Get after Logged in url by current user role
7105 */
7106
7107 $redirecturi = $this->ifRedirectUrlSet($current_user);
7108 if($redirecturi) {
7109 $this->pie_after_login_page_redirect_url = $redirecturi;
7110 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url,$option['social_site_popup_setting'],true);
7111 exit;
7112 }
7113
7114 $logged_in_url = "";
7115 $logged_in_page = "";
7116
7117 if( !isset($option['social_site_popup_setting']) )
7118 {
7119 $option['social_site_popup_setting'] = 0;
7120 }
7121
7122 if(!empty($logged_in_url) && ($logged_in_page == 0 || $logged_in_page == "")){
7123 $this->pie_after_login_page_redirect_url = $logged_in_url;
7124 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url,$option['social_site_popup_setting'],false);
7125 exit;
7126 }elseif(!empty($logged_in_page) && $logged_in_page > 0){
7127 $this->pie_after_login_page_redirect_url = get_permalink($logged_in_page);
7128 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url,$option['social_site_popup_setting'],true);
7129 exit;
7130 }
7131 elseif( $option['after_login'] == 'url' && !empty($option['alternate_login_url']) ){
7132 $this->pie_after_login_page_redirect_url = $option['alternate_login_url'];
7133 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url,$option['social_site_popup_setting'],false);
7134 exit;
7135 }
7136 elseif( $option['after_login'] > 0 ){
7137 if($option['after_login'] != 'url'){
7138 $this->pie_after_login_page_redirect_url = get_permalink($option['after_login']);
7139 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url,$option['social_site_popup_setting'],true);
7140 exit;
7141 }
7142 }
7143 elseif( isset($_GET['redirect_to']) && $_GET['redirect_to'] != "" && !current_user_can( 'administrator' ) ){
7144 // When account login with activation link and not any login page assigned
7145 if( (isset($_GET['action']) && $_GET['action'] == "activate") && (isset($_GET['activation_key']) && $_GET['activation_key'] != "") ) {
7146 $this->pie_after_login_page_redirect_url = site_url();
7147 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url,$option['social_site_popup_setting'],false);
7148 } else {
7149 $this->pie_after_login_page_redirect_url = esc_url_raw($_GET['redirect_to']);
7150 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url,$option['social_site_popup_setting'],false);
7151 }
7152 exit;
7153 }else{
7154 $this->pie_after_login_page_redirect_url = site_url();
7155 $this->afterLoginPageRedirect($this->pie_after_login_page_redirect_url,$option['social_site_popup_setting'],false);
7156 exit;
7157 }
7158 exit;
7159 }
7160
7161 function ifRedirectUrlSet($user)
7162 {
7163 if ( isset( $_REQUEST['redirect_to'] ) ) {
7164 $redirect_to = esc_url_raw($_REQUEST['redirect_to']);
7165 // Redirect to https if user wants ssl
7166 if ( ( (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') && false) !== strpos($redirect_to, 'wp-admin') )
7167 $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to);
7168 } else {
7169 $redirect_to = admin_url();
7170 }
7171
7172 $requested_redirect_to = isset( $_REQUEST['redirect_to'] ) ? esc_url_raw($_REQUEST['redirect_to']) : '';
7173 $redirect_to = apply_filters( 'login_redirect', $redirect_to, $requested_redirect_to, $user );
7174 $last_segment = basename($redirect_to);
7175
7176 if( $last_segment == 'wp-admin' || $redirect_to == admin_url() )
7177 {
7178 return false;
7179 }
7180
7181 return $redirect_to;
7182 }
7183
7184 function afterLoginPageRedirect($url,$social_site_popup_setting = 0,$safe = true){
7185 if(
7186 $social_site_popup_setting == 1 and
7187 $_POST['social_site'] == "true"
7188 )
7189 {
7190 //Redirect thru JS File
7191 }
7192 else{
7193 if($safe)
7194 wp_safe_redirect($url);
7195 else
7196 wp_redirect(esc_url_raw(html_entity_decode($url)));
7197 }
7198 exit;
7199 }
7200
7201 function add_ob_start(){
7202 ob_start();
7203 }
7204
7205 function get_paypalstandard($value, $payment_gateways=array())
7206 {
7207 $data = "";
7208 $check_payment = get_option(OPTION_PIE_REGISTER);
7209
7210 if($check_payment["enable_paypal"] == 1 && !(empty($check_payment['paypal_butt_id'])) && in_array( "PaypalStandard", $payment_gateways ))
7211 {
7212 $data .= '<img src="'.esc_url(PIEREG_PLUGIN_URL.'assets/images/paypal_std_btn.png').'">';
7213 $data .= '<p class="desc">'.esc_html__('Paypal (Standard) payment method applied.','pie-register').'</p>';
7214 $data .= '<input type="hidden" name="select_payment_method" value="'.esc_attr($payment_gateways[0]).'" />';
7215 }
7216
7217 return $data.$value;
7218 }
7219
7220 function Add_payment_option($send_data,$paymeny_gatways) // Only For Paypal
7221 {
7222 $check_payment = get_option(OPTION_PIE_REGISTER);
7223 if($check_payment["enable_paypal"] == 1 && !(empty($check_payment['paypal_butt_id'])) && in_array('PaypalStandard', $paymeny_gatways))
7224 {
7225 $string = 'Paypal (Standard)';
7226 if( strpos($send_data, $string) == false )
7227 {
7228 $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>';
7229 }
7230 }
7231
7232 return $send_data;
7233 }
7234
7235 function add_payment_method_script() // Only For Paypal Standard
7236 {
7237 $check_payment = get_option(OPTION_PIE_REGISTER);
7238 if($check_payment["enable_paypal"] == 1 && !(empty($check_payment['paypal_butt_id'])) )
7239 {
7240 //Add jQuery for payment Method
7241 ?>
7242 if(jQuery(this).val() == "PaypalStandard")
7243 {
7244 payment = '<div class="payment-method-img desc"><img src="'+jQuery('option:selected',jQuery(this)).attr('data-img')+'" /></div><div class="desc">Paypal (Standard) payment method applied.</div>';
7245 <!-- image = '<img src="'+jQuery('option:selected',jQuery(this)).attr('data-img')+'" />'; -->
7246 }
7247 <?php
7248 }
7249 }
7250
7251 function add_select_payment_script(){
7252 ?>
7253 <script type="text/javascript">
7254 var piereg = jQuery.noConflict();
7255 piereg(document).ready(function(){
7256 piereg("#select_payment_method").change(function(){
7257 if(piereg(this).val() != "")
7258 {
7259
7260 var payment = "", image = "";
7261 <?php do_action('add_payment_method_script'); ?>
7262 piereg("#show_payment_method").html(payment);
7263 // piereg("#show_payment_method_image").html(image);
7264 }
7265 else
7266 {
7267 piereg("#show_payment_method").html("");
7268 // piereg("#show_payment_method_image").html("");
7269 }
7270 });
7271 });
7272 </script>
7273 <?php
7274 }
7275 function get_payment_content_area()
7276 {
7277 $data = '<div class="fieldset">';
7278 //$data .= '<label for="select_payment_method"> </label>';
7279 // $data .= '<div id="show_payment_method_image"></div>';
7280 $data .= '<div id="show_payment_method"></div>';
7281 $data .= '</div>';
7282 return $data;
7283 }
7284 function show_icon_payment_gateway() // for paypal
7285 {
7286
7287 $button = get_option(OPTION_PIE_REGISTER);
7288 if(
7289 (!(empty($button['paypal_butt_id'])) && $button['enable_paypal']==1)
7290 )
7291 {
7292 ?>
7293 <div class="fields_options submit_field">
7294 <img style="width:100%;" src="<?php echo esc_url(plugins_url('/assets/images/btn_buynowCC_LG.gif',__FILE__)); ?>" />
7295 </div>
7296 <?php
7297 }
7298 }
7299
7300 function renew_account()
7301 {
7302 global $errors;
7303 $errors = new WP_Error();
7304
7305 if( isset($_POST['piereg_renew_account_nonce']) && wp_verify_nonce( $_POST['piereg_renew_account_nonce'], 'piereg_wp_renew_account_nonce' ) )
7306 {
7307
7308 if( isset($_POST['select_payment_method']) and trim($_POST['select_payment_method']) != "" )
7309 {
7310 if(isset($_GET['auth'], $_GET['auth_key']) && !empty($_GET['auth']) && !empty($_GET['auth_key']) )
7311 {
7312 $user_name = sanitize_text_field(urldecode($_GET['auth']));
7313 $auth_key = sanitize_text_field(urldecode($_GET['auth_key']));
7314 $user_name = sanitize_user(urldecode(base64_decode($user_name)));
7315 $user = get_user_by("login",$user_name);
7316
7317 if(!empty($user))
7318 {
7319 $auth_key = sanitize_text_field($_GET['auth_key']);
7320 $auth_key_hash = get_user_meta($user->ID,"pr_renew_account_hash", true);
7321 if(!empty($auth_key_hash))
7322 {
7323 if(trim($auth_key) == trim($auth_key_hash))
7324 {
7325 if(isset($user->ID)){
7326 /*
7327 * Check Pricing
7328 */
7329 $user_id = $user->ID;
7330
7331 $pricing_key_number = get_user_meta( $user_id , "piereg_pricing_key_number" , true );
7332 $piereg_user_registered_form_id = get_user_meta( $user_id, "user_registered_form_id", true );
7333 $piereg_use_starting_period = get_user_meta( $user_id , "use_starting_period" , true );
7334 $piereg_form_pricing_fields = get_option("piereg_form_pricing_fields");
7335 $piereg_pricing_fields = "";
7336 $user_array = (array) $user;
7337 if(isset($piereg_form_pricing_fields['form_id_'.(intval($piereg_user_registered_form_id))])){
7338 $piereg_pricing_fields = $piereg_form_pricing_fields['form_id_'.(intval($piereg_user_registered_form_id))];
7339 $user_array['piereg_pricing']['pricing_key_user_role'] = $piereg_pricing_fields['role'][$pricing_key_number];
7340 if(empty($piereg_use_starting_period)){
7341 $user_array['piereg_pricing']['pricing_payment_amount'] = $piereg_pricing_fields['starting_price'][$pricing_key_number];
7342 }else{
7343 $user_array['piereg_pricing']['pricing_payment_amount'] = $piereg_pricing_fields['then_price'][$pricing_key_number];
7344 }
7345 }
7346 $user = (object) $user_array;
7347 }
7348 }
7349 else
7350 {
7351 $user = new WP_Error("invalid_hash","User hash mismatch");
7352 }
7353 }
7354 else{
7355 $user = new WP_Error("piereg_invalid_auth_keys_hash",apply_filters("piereg_invalid_auth_keys_hash",esc_html__("Invalid auth keys hash","pie-register")));
7356 }
7357 }
7358 else{
7359 $user = new WP_Error("piereg_invalid_auth_keys",apply_filters("piereg_invalid_auth_keys",esc_html__("Invalid User","pie-register")));
7360 }
7361 }
7362 else{
7363 $user = $this->piereg_user_login(sanitize_user($_POST['user_name']),$_POST['u_pass']);
7364 wp_logout();
7365 }
7366
7367 $piereg = $this->get_pr_global_options();
7368
7369 if ( is_wp_error($user))
7370 {
7371 $user_login_error = $user->get_error_message();
7372 if(strpos(strip_tags($user_login_error),'Invalid username',5) > 6){
7373 $user_login_error = '<b>'.ucwords(esc_html__("error","pie-register")).'</b>: '.esc_html__("Invalid username or password","pie-register");
7374 }
7375 else if(strpos(strip_tags($user_login_error),'password you entered',9) > 10){
7376 $user_login_error = '<strong>'.ucwords(esc_html__("error","pie-register")).'</strong>: '.esc_html__("Invalid username or password","pie-register");
7377 }
7378 $errors->add('renew-account-error',apply_filters("piereg_renew_account_error",$user_login_error));
7379 }
7380 elseif($user->ID != 0 or $user->ID != ""){
7381 $user_meta = get_user_meta($user->ID);
7382 if($user_meta['active'][0] == 0){
7383 if(isset($_POST['select_payment_method']) and $_POST['select_payment_method'] != "" )//Goto payment method Like check_payment_method_paypal
7384 {
7385 $_POST['user_id'] = $user->data->ID;
7386 $_POST['e_mail'] = $user->data->user_email;
7387 $_POST['username'] = $user->data->user_login;
7388 $_POST['renew_account_msg'] = apply_filters("piereg_Renew_Account",esc_html__("Renew Account","pie-register"));
7389 $_POST['renew_account'] = "Renew Account";
7390 do_action("piereg_before_renew_account_hook",$user);
7391 do_action("check_payment_method_".sanitize_text_field($_POST['select_payment_method']),$user);
7392 }
7393 }else{
7394 $this->pie_post_array['success'] = apply_filters("you_are_already_active",esc_html__($piereg['payment_already_activate_msg'],"pie-register"));
7395 }
7396 }
7397 else{
7398 $this->pie_post_array['error'] = apply_filters("piereg_Invalid_Username_or_Password",esc_html__("Invalid Username or Password","pie-register"));
7399 }
7400 }
7401 else{
7402 $this->pie_post_array['error'] = apply_filters("piereg_Please_Select_any_payment_method",esc_html__("Please select a payment method","pie-register"));
7403 }
7404 } else {
7405 $this->pie_post_array['error'] = 'Invalid nonce.';
7406 }
7407 }
7408
7409 function piereg_user_login($username,$password,$remember = false){
7410 $result = array();
7411 if($username != "" && $password != ""){
7412 $creds = array();
7413 $creds['user_login'] = trim($username);
7414 $creds['user_password'] = trim($password);
7415 $creds['remember'] = ((!empty($remember))?true:false);
7416 $piereg_secure_cookie = $this->PR_IS_SSL();
7417 if($this->piereg_authentication($_POST['log'],trim($_POST['pwd']))){
7418 $user = wp_signon( $creds, $piereg_secure_cookie);
7419 if ( !is_wp_error($user) ){
7420 $this->piereg_delete_authentication();
7421 }
7422 }else{
7423 $user = new WP_Error('piereg_authentication_failed', esc_html__("IP address blocked due to too many failed login attempts.","pie-register"));
7424 }
7425
7426 if(isset($user->ID)){
7427 /*
7428 * Check Pricing
7429 */
7430 $user_id = $user->ID;
7431
7432 $pricing_key_number = get_user_meta( $user_id, "piereg_pricing_key_number", true );
7433 $piereg_user_registered_form_id = get_user_meta( $user_id, "user_registered_form_id", true );
7434 $piereg_use_starting_period = get_user_meta( $user_id, "use_starting_period" , true );
7435 $piereg_form_pricing_fields = get_option("piereg_form_pricing_fields");
7436 $piereg_pricing_fields = "";
7437 $user_array = (array) $user;
7438 if(isset($piereg_form_pricing_fields['form_id_'.(intval($piereg_user_registered_form_id))])){
7439 $piereg_pricing_fields = $piereg_form_pricing_fields['form_id_'.(intval($piereg_user_registered_form_id))];
7440 $user_array['piereg_pricing']['pricing_key_user_role'] = $piereg_pricing_fields['role'][$pricing_key_number];
7441 if(empty($piereg_use_starting_period)){
7442 $user_array['piereg_pricing']['pricing_payment_amount'] = $piereg_pricing_fields['starting_price'][$pricing_key_number];
7443 }else{
7444 $user_array['piereg_pricing']['pricing_payment_amount'] = $piereg_pricing_fields['then_price'][$pricing_key_number];
7445 }
7446 }
7447 $user = (object) $user_array;
7448
7449 /***** End Pricing *****/
7450 }
7451 $result = $user;
7452 }
7453 else{
7454 $result['error'] = apply_filters('piereg_Invalid_Fields', esc_html__("Invalid Field(s)",'pie-register')); # newlyAddedHookFilter
7455 }
7456 return $result;
7457 }
7458 function wp_mail_send($to_email = "",$key = "",$additional_msg = "",$msg = "",$email_variable = array())
7459 {
7460 global $errors;
7461 $errors = new WP_Error();
7462 if(trim($to_email) != "" and trim($key) != "" )
7463 {
7464 $email_types = get_option(OPTION_PIE_REGISTER);
7465
7466 $message_temp = "";
7467 if($email_types['user_formate_email_'.$key] == "0"){
7468 $message_temp = nl2br(strip_tags($email_types['user_message_email_'.$key]));
7469 }else{
7470 $message_temp = $email_types['user_message_email_'.$key];
7471 }
7472
7473 $message = $this->filterEmail($message_temp,$to_email,"","",$email_variable);
7474 $to = $to_email;
7475 $from_name = $email_types['user_from_name_'.$key];
7476 $from_email = $email_types['user_from_email_'.$key];
7477 $reply_to_email = $email_types['user_to_email_'.$key];
7478 $subject = html_entity_decode($email_types['user_subject_email_'.$key],ENT_COMPAT,"UTF-8");
7479 $subject = $this->filterSubject($to_email,$subject);
7480
7481 if(!filter_var($to,FILTER_VALIDATE_EMAIL))//if not valid email address then use wordpress default admin
7482 {
7483 $to = get_option('admin_email');
7484 }
7485 //Headers
7486 $headers = 'MIME-Version: 1.0' . "\r\n";
7487 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
7488
7489 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL))//Validating From
7490 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
7491
7492 if(!empty($reply_to_email) && filter_var($reply_to_email,FILTER_VALIDATE_EMAIL))//Validating Reply To
7493 $headers .= 'Reply-To: <'.$reply_to_email.'> \r\n';
7494 if($reply_to_email){
7495 $headers .= "Return-Path: {$reply_to_email}\r\n";
7496 }else{
7497 $headers .= "Return-Path: {$from_email}\r\n";
7498 }
7499
7500 if(!wp_mail($to,$subject,$message,$headers))
7501 {
7502 $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')));
7503 }
7504 else{
7505 if(trim($msg) != "")
7506 {
7507 $this->pie_post_array['success'] = __($msg,"pie-register");
7508 }
7509 }
7510 }
7511 }
7512
7513 function delete_invitation_codes($ids="0")
7514 {
7515 global $wpdb;
7516 $prefix=$wpdb->prefix."pieregister_";
7517 $codetable=$prefix."code";
7518
7519 $array_ids = explode(',', $ids);
7520 $count_ids = count($array_ids);
7521 $placeholders = array_fill(0, $count_ids, '%d');
7522 $format = implode(', ', $placeholders);
7523
7524 $sql = "DELETE FROM `$codetable` WHERE `id` IN($format)";
7525 if(!$wpdb->query( $wpdb->prepare($sql, $array_ids) )){
7526 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
7527 }
7528 else{
7529 $this->pie_post_array['notice'] = esc_html__("Invitation code deleted.","pie-register");
7530 }
7531 }
7532 function active_or_unactive_invitation_codes($ids="0",$status="1")
7533 {
7534 global $wpdb;
7535 $prefix=$wpdb->prefix."pieregister_";
7536 $codetable=$prefix."code";
7537
7538 $array_ids = explode(',', $ids);
7539 $count_ids = count($array_ids);
7540 $placeholders = array_fill(0, $count_ids, '%d');
7541 $format = implode(', ', $placeholders);
7542
7543 $sql = "UPDATE `".$codetable."` SET `status`= %s WHERE `id` IN($format)";
7544 $args[] = $status;
7545 $args = array_merge($args, $array_ids);
7546
7547 if(!$wpdb->query( $wpdb->prepare($sql, $args) ) ){
7548 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
7549 }
7550 else{
7551 $this->pie_post_array['notice'] = esc_html__("Status has been changed","pie-register");
7552 }
7553 }
7554 function pireg_update_invitation_code_cb_url()
7555 {
7556 // Run a security check.
7557 if ( ! check_ajax_referer( 'pieregister_front_admin', 'nonce', false ) ) {
7558 wp_send_json_error( esc_html__( 'Your session expired. Please reload the page.', 'pie-register' ) );
7559 }
7560
7561 global $wpdb;
7562 $prefix=$wpdb->prefix."pieregister_";
7563 $codetable=$prefix."code";
7564 $inv_code_id = intval($_POST['data']['id']);
7565 if( isset($_POST['data']))
7566 {
7567 if(trim($_POST['data']['id']) != "" and trim($_POST['data']['value']) != "" and trim($_POST['data']['type']) != "")
7568 {
7569 global $wpdb;
7570 $sql ="";
7571 $_data_value = sanitize_text_field($_POST['data']['value']);
7572 if(trim($_POST['data']['type']) == "name")
7573 {
7574 $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)) );
7575 if(!$sql_res_sel)
7576 $sql = "UPDATE `{$codetable}` SET `name`=%s WHERE `id` = '{$inv_code_id}'";
7577 else{
7578 echo "duplicate";
7579 die();
7580 }
7581 }
7582 else if(trim($_POST['data']['type']) == "code_description")
7583 {
7584 if( $_POST['data']['value'] != '' ){
7585 $sql = "UPDATE `{$codetable}` SET `code_description`=%s WHERE `id` = ".((int)$_POST['data']['id'])."";
7586 }
7587 }
7588 else if(trim($_POST['data']['type']) == "code_usage")
7589 {
7590 if(is_numeric($_data_value) && $_data_value >= 0 && trim($_data_value) != ''){
7591 $sql = "SELECT `code_usage`,`count` FROM `{$codetable}` WHERE `id` = ".((int)$_POST['data']['id'])."";
7592 $usage_count = $wpdb->get_results( $sql );
7593 if($_data_value >= $usage_count[0]->count){
7594 $sql = "UPDATE `{$codetable}` SET `code_usage`=%s WHERE `id` = ".((int)$_POST['data']['id'])."";
7595 }else{
7596 echo "invalid usage";
7597 die();
7598 }
7599 }
7600 }
7601 $result = $wpdb->query( $wpdb->prepare($sql, $_data_value) );
7602
7603 if(isset($wpdb->last_error) && !empty($wpdb->last_error)){
7604 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
7605 }
7606 if($result)
7607 {
7608 echo "done";
7609 }
7610 else{
7611 echo "error";
7612 }
7613 }
7614 }
7615 die();
7616 }
7617
7618 function delete_custom_roles($ids="0")
7619 {
7620 global $wpdb;
7621 $custom_role_table_name = $wpdb->prefix."pieregister_custom_user_roles";
7622
7623 $array_ids = explode(',', $ids);
7624 $count_ids = count($array_ids);
7625 $placeholders = array_fill(0, $count_ids, '%d');
7626 $format = implode(', ', $placeholders);
7627
7628 $sql_data = "SELECT `role_key` FROM `$custom_role_table_name` WHERE `id` IN($format)";
7629 $role_keys = $wpdb->get_results($wpdb->prepare($sql_data, $array_ids));
7630
7631
7632 $sql = "DELETE FROM `$custom_role_table_name` WHERE `id` IN($format)";
7633 if(!$wpdb->query( $wpdb->prepare($sql, $array_ids) )){
7634 $this->pr_error_log($wpdb->last_error.($this->get_error_log_info(__FUNCTION__,__LINE__,__FILE__)));
7635 }else{
7636 $this->pie_post_array['notice'] = esc_html__("The User Role(s) has been deleted","pie-register");
7637
7638 foreach($role_keys as $role_key){
7639 remove_role( $role_key->role_key);
7640 }
7641 }
7642 }
7643
7644 function checkUserAllowedPassReset($val,$userid){
7645 if(!$userid) return false;
7646 //Check if the user is active or not
7647 //if active true, or false
7648 global $piereg_global_options;
7649
7650 if(
7651 (isset($piereg_global_options['verification']) && ($piereg_global_options['verification'] == "2" || $piereg_global_options['verification'] == "1")) ||
7652 ((!empty($piereg_global_options['paypal_butt_id'])) && $piereg_global_options['enable_paypal'] == "1" )
7653 ){
7654 $user_active_status = get_user_meta($userid,"active",true);
7655 //If employee register from wp-register the active meta is not saved
7656 if($user_active_status == "")
7657 return true;
7658 //If employee register from wp-register the active meta is not saved
7659 return (($user_active_status == 1)?true:false);
7660 }
7661 return true;
7662 }
7663
7664 function piereg_password_reset_not_allowed_text_function($text)
7665 {
7666 return $text;
7667 }
7668
7669 /*
7670 * Pie Register log file download
7671 */
7672 function pr_logfile_download_or_view(){
7673 if(isset($_POST['piereg_download_log_file']) && $_POST['piereg_download_log_file'] != ""){
7674 $this->piereg_get_wp_plugable_file(true); // require_once pluggable.php
7675 if(isset($_POST['piereg_download_log_file_nonce']) && wp_verify_nonce( $_POST['piereg_download_log_file_nonce'], 'piereg_wp_download_log_file_nonce' ))
7676 {
7677 if (file_exists(PIE_LOG_FILE."/piereg_log.log")) {
7678 header('Content-Description: File Transfer');
7679 header('Content-Type: application/octet-stream');
7680 header('Content-Disposition: attachment; filename='.("PieRegister_logfile_".date_i18n("Y-m-d-H-i-s").".log"));
7681 header('Expires: 0');
7682 header('Cache-Control: must-revalidate');
7683 header('Pragma: public');
7684 header('Content-Length: ' . filesize(PIE_LOG_FILE."/piereg_log.log"));
7685 readfile(PIE_LOG_FILE."/piereg_log.log");
7686 exit;
7687 }
7688 }else{
7689 $this->pie_post_array['error_message'] = esc_html__("Invalid nonce.","pie-register");
7690 }
7691 }
7692 }
7693 /*
7694 * Pie Register Log File View
7695 */
7696 function piereg_get_log_file(){
7697 //Log File Dir
7698 $file_dir = PIE_LOG_FILE."/piereg_log.log";
7699 $result = "";
7700 $logFileData = $this->read_upload_file($file_dir);
7701 $result = htmlentities($logFileData);
7702 return $result;
7703 }
7704
7705 function check_json_file_db_version($array_json_file){
7706 if(isset($array_json_file['piereg_plugin_db_version']) && !empty($array_json_file['piereg_plugin_db_version'])){
7707 $import_file_db_version = $array_json_file['piereg_plugin_db_version'];
7708 $pie_plugin_db_version = get_option('piereg_plugin_db_version');
7709 if($pie_plugin_db_version === $import_file_db_version)
7710 return true;
7711 else
7712 return false;
7713 }else
7714 return false;
7715 }
7716 function set_json_header($file_name){
7717 header('Content-disposition: attachment; filename='.($file_name).'.json');
7718 header('Content-type: application/json');
7719 }
7720
7721
7722 function piereg_plugin_row_meta( $links, $file ) {
7723 if ( $file == PIEREG_PLUGIN_BASENAME ) {
7724 $row_meta = array(
7725 '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>',
7726 '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>',
7727 );
7728
7729 return array_merge( $links, $row_meta );
7730 }
7731
7732 return (array) $links;
7733 }
7734
7735 function activate_addon_license_key(){
7736
7737 if( isset($_POST['piereg_activate_addon_license_key'], $_POST['save_addon_license_key_settings']) )
7738 {
7739 if(isset($_POST['piereg_addon_license_key_nonce']))
7740 {
7741 if(wp_verify_nonce( $_POST['piereg_addon_license_key_nonce'], 'piereg_wp_addon_license_key_nonce' )){
7742
7743 $piereg_pro_not_activated = ( isset($_POST['piereg_pro_not_activated']) ) ? true: false;
7744 $LK_options = array();
7745
7746 if( $piereg_pro_not_activated )
7747 {
7748 $LK_options['api_key'] = sanitize_text_field($_POST['piereg_addon_license_key']);
7749 $LK_options['activation_email'] = sanitize_email($_POST['piereg_addon_license_email']);
7750 }
7751 else {
7752 $LK_options = get_option( PIEREG_LICENSE_KEY_OPTION );
7753 }
7754
7755 $piereg_api_manager_menu = new Piereg_API_Manager_Example_MENU();
7756 $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 ) );
7757
7758 }
7759 else{
7760 $this->pie_post_array['error'] = esc_html__("Invalid nonce.","pie-register");
7761 }
7762 }
7763 }
7764 }
7765 public function plugin_url() {
7766 if ( isset( $this->piereg_plugin_url ) ) return $this->piereg_plugin_url;
7767 return $this->piereg_plugin_url = plugins_url( '/', __FILE__ );
7768 }
7769
7770 function pie_user_avatar( $avatar, $id_or_email, $size, $default, $alt ) {
7771 $user = false;
7772 $profile_pic = "";
7773
7774 if( !is_admin() )
7775 {
7776 $current_user = wp_get_current_user();
7777
7778 if( is_object($id_or_email) )
7779 $id_or_email = $id_or_email->user_id;
7780
7781 if( !is_numeric( $id_or_email ) ) {
7782 $user = get_user_by('email', $id_or_email);
7783 $id_or_email = $user->ID;
7784 }
7785
7786 if( is_numeric( $id_or_email ) && $id_or_email != $current_user->ID )
7787 {
7788 $current_user = get_userdata($id_or_email);
7789 }
7790
7791 $profile_pic_array = get_user_meta($current_user->ID);
7792
7793 if( is_array($profile_pic_array) )
7794 {
7795 foreach($profile_pic_array as $key => $val) {
7796 if(strpos($key,'profile_pic') !== false) {
7797 $profile_pic = trim($val[0]);
7798 }
7799 }
7800 }
7801 }
7802
7803 if(!empty( $profile_pic ))
7804 {
7805 $profile_pic = apply_filters("piereg_profile_image_url",$profile_pic,$current_user);
7806 if ( is_numeric( $id_or_email ) ) {
7807
7808 $id = (int) $id_or_email;
7809 $user = get_user_by( 'id' , $id );
7810
7811 } elseif ( is_object( $id_or_email ) ) {
7812
7813 if ( ! empty( $id_or_email->user_id ) ) {
7814 $id = (int) $id_or_email->user_id;
7815 $user = get_user_by( 'id' , $id );
7816 }
7817
7818 } else {
7819 $user = get_user_by( 'email', $id_or_email );
7820 }
7821
7822 if ( $user && is_object( $user ) ) {
7823
7824 //if ( $user->data->ID == get_current_user_id() ) {
7825 $avatar = $profile_pic;
7826 $avatar = "<img alt='{$alt}' src='{$avatar}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' />";
7827 //}
7828
7829 }
7830
7831 }
7832
7833 return $avatar;
7834 }
7835
7836 function is_anyone_can_register(){
7837 return get_option("users_can_register");
7838 }
7839 function piereg_ssl_template_redirect(){
7840 if ( !is_admin() && ( (defined("FORCE_SSL_ADMIN") && FORCE_SSL_ADMIN == true) && !is_ssl() ) ) { #checkbyM
7841 if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') {
7842 wp_safe_redirect( preg_replace('|^http://|', 'https://', $this->piereg_get_current_url()) );
7843 exit;
7844 }
7845 }
7846 }
7847 function edit_email_verification(){
7848 if(isset($_GET['action']) && ($_GET['action'] == "current_email_verify" || $_GET['action'] == "email_edit")){
7849 $username = sanitize_user($_GET['login']);
7850 $email_verify_key = sanitize_text_field($_GET['key']);
7851 $user_data_temp = get_user_by('login', $username);
7852 global $errors, $piereg_global_options;
7853 $errors = new WP_Error();
7854 $global_options = $piereg_global_options;
7855 $success_message = "";
7856 $type = "success";
7857 if( ($_GET['action'] == "current_email_verify" ) && (isset($_GET['key']) && !empty($_GET['key']) ) && (isset($_GET['login']) && !empty($_GET['login']) ))
7858 {
7859 $email_verify_orignal_key = get_user_meta($user_data_temp->data->ID,"new_email_address_hashed",true);
7860
7861 if($email_verify_orignal_key == $email_verify_key)
7862 {
7863 $new_email_address = get_user_meta($user_data_temp->data->ID,"new_email_address",true);
7864 $email_key = md5(uniqid("piereg_").time());
7865 $keys_array = array("reset_email_key"=>$email_key);
7866
7867 /*
7868 * Email send snipt
7869 */
7870 $subject = html_entity_decode($global_options["user_subject_email_email_edit_verification"],ENT_COMPAT,"UTF-8");
7871 $subject = $this->filterSubject($user_data_temp,$subject);
7872 $message_temp = "";
7873
7874 $message_temp = $global_options["user_message_email_email_edit_verification"];
7875 $message = $this->filterEmail($message_temp,$user_data_temp, "",false,$keys_array );
7876 $from_name = $global_options["user_from_name_email_edit_verification"];
7877 $from_email = $global_options["user_from_email_email_edit_verification"];
7878 $reply_email = $global_options["user_to_email_email_edit_verification"];
7879
7880 //Headers
7881 $headers = "MIME-Version: 1.0" . "\r\n";
7882 $headers .= "Content-type: text/html; charset=UTF-8" . "\r\n";
7883
7884 if(!empty($from_email) && filter_var($from_email,FILTER_VALIDATE_EMAIL))//Validating From
7885 $headers .= "From: ".$from_name." <".$from_email."> \r\n";
7886
7887 if($reply_email){
7888 $headers .= "Reply-To: {$reply_email}\r\n";
7889 $headers .= "Return-Path: {$reply_email}\r\n";
7890 }else{
7891 $headers .= "Reply-To: {$from_email}\r\n";
7892 $headers .= "Return-Path: {$from_email}\r\n";
7893 }
7894
7895 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))
7896 {
7897 $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__)));
7898 $print_message = esc_html__("There was a problem sending the email.",'pie-register');
7899 $type = "0";
7900 }
7901
7902 /*
7903 * Update Email Hash Key
7904 */
7905 update_user_meta($user_data_temp->data->ID,"new_email_address_hashed",$email_key);
7906 if(empty($print_message)){
7907 $print_message = esc_html__("Use the link sent to your email to verify and apply the change.","pie-register");
7908 $type="success";
7909 }
7910 }else{
7911 $print_message = esc_html__('Verification link has expired or is invalid.','pie-register' );
7912 $type = "error";
7913 }
7914 }
7915 elseif( ($_GET['action'] == "email_edit" ) && (isset($_GET['key']) && !empty($_GET['key']) ) && (isset($_GET['login']) && !empty($_GET['login']) ))
7916 {
7917 $email_verify_orignal_key = get_user_meta($user_data_temp->data->ID,"new_email_address_hashed",true);
7918 $old_email = get_user_meta($user_data_temp->data->ID,"new_email_address",true);
7919 if($email_verify_orignal_key == $email_verify_key)
7920 {
7921 $user_id_temp = wp_update_user( array( 'ID' => $user_data_temp->data->ID, 'user_email' => $old_email ) );
7922 if ( is_wp_error( $user_id_temp ) ) {
7923 $print_message = esc_html__('There was a problem updating the new Email address, try again.','pie-register' );
7924 $type = "error";
7925 }
7926 else{
7927 delete_user_meta($user_data_temp->data->ID,"new_email_address_hashed");
7928 delete_user_meta($user_data_temp->data->ID,"new_email_address");
7929 $print_message = esc_html__("New email address has been verified. Account email address has been changed.","pie-register");
7930 $type = "success";
7931 }
7932 }
7933 else{
7934 $print_message = esc_html__('Verification link has expired or is invalid.','pie-register' );
7935 $type = "error";
7936 }
7937 }
7938
7939 if( is_user_logged_in() ){
7940 $print_message = base64_encode($print_message);
7941 wp_safe_redirect($this->get_page_uri($global_options["alternate_profilepage"],"edit_user=1&pr_msg={$print_message}&type={$type}"));
7942 exit;
7943 }else{
7944 $_POST[$type] = $print_message;
7945 }
7946 }
7947 }
7948 /*
7949 * PR Rated
7950 */
7951 public function pieregister_rated(){
7952 // Run a security check.
7953 if ( ! check_ajax_referer( 'pie_rated_nonce', 'nonce', false ) ) {
7954 wp_send_json_error( esc_html__( 'Something went wrong.', 'pie-register' ) );
7955 }
7956
7957 update_option( 'pie_admin_footer_text_rated', 1 );
7958 wp_send_json_success();
7959 }
7960
7961 /*
7962 * Payment log file Download & Delete
7963 * Payment Log section to download all Payment information
7964 */
7965 function piereg_payment_log_file_action(){
7966 if( !is_admin() || !current_user_can('manage_options') )
7967 return false;
7968
7969 if( isset($_POST['piereg_download_payment_log_file']) && isset($_POST['piereg_payment_log']) && wp_verify_nonce( $_POST['piereg_payment_log'], 'piereg_wp_payment_log' ) ){
7970 $this->piereg_get_wp_plugable_file();
7971 // Get file contents
7972 $read_log_file = $this->read_upload_file(PIE_LOG_FILE."/payment-log.log");
7973 if( !empty($read_log_file) ){
7974 // Send file headers
7975 header('Content-disposition: attachment; filename=payment-log-'.date_i18n("d-m-y-H-i-s").'.log');
7976 header('Content-type: application/text');
7977 // Send the file contents, write them in the file
7978 echo $read_log_file;
7979 exit;
7980 }else{
7981 $this->pie_post_array['error'] = esc_html__("Empty Payment Log File","pie-register");
7982 }
7983 }elseif( isset($_POST['piereg_delete_payment_log_file']) && isset($_POST['piereg_payment_log']) && wp_verify_nonce( $_POST['piereg_payment_log'], 'piereg_wp_payment_log' ) ){
7984 $this->piereg_get_wp_plugable_file();
7985 update_option( "piereg_payment_log_option", array() );
7986 $this->pie_post_array['notice'] = esc_html__("Payment log successfully removed.","pie-register");
7987
7988 }
7989 else if( isset($_POST['piereg_download_payment_log_file']) || isset($_POST['piereg_delete_payment_log_file']) ) {
7990 $this->pie_post_array['error'] = esc_html__("Invalid nonce.","pie-register");
7991 }
7992 }
7993 }
7994 }
7995
7996 if( class_exists('PieRegister') ){
7997 $pie_register = new PieRegister();
7998 $GLOBALS['piereg_api_manager'] = $pie_register;
7999 if(isset($pie_register)){
8000 register_activation_hook( __FILE__, array( &$pie_register, 'install_settings' ) );
8001 register_deactivation_hook( __FILE__, array( &$pie_register, 'deactivation_settings' ) );
8002
8003 if (!function_exists("pie_registration_url"))
8004 {
8005 function pie_registration_url($url=false)
8006 {
8007 return PieRegister::static_pie_registration_url($url);
8008 }
8009 }
8010
8011 if (!function_exists("pie_login_url"))
8012 {
8013 function pie_login_url($url=false)
8014 {
8015 return PieRegister::static_pie_login_url($url);
8016 }
8017 }
8018
8019 if (!function_exists("pie_lostpassword_url"))
8020 {
8021 function pie_lostpassword_url($url=false)
8022 {
8023 return PieRegister::static_pie_lostpassword_url($url);
8024 }
8025 }
8026
8027 if (!function_exists("piereg_logout_url"))
8028 {
8029 function piereg_logout_url($url=false)
8030 {
8031 return PieRegister::static_piereg_logout_url($url);
8032 }
8033 }
8034
8035 if (!function_exists("pie_modify_custom_url"))
8036 {
8037 function pie_modify_custom_url($url,$query_string=false)
8038 {
8039 return PieRegister::static_pie_modify_custom_url($url,$query_string);
8040 }
8041 }
8042
8043 if (!function_exists("set_pr_stats"))
8044 {
8045 function set_pr_stats($stats,$type)
8046 {
8047 return PieRegister::static_set_pr_stats($stats,$type);
8048 }
8049 }
8050 }
8051
8052 if (!function_exists("uninstall_pr_ff"))
8053 {
8054 function uninstall_pr_ff() {
8055 global $pie_register;
8056 if(!is_object($pie_register)) {
8057 $pie_register = new PieRegister();
8058 }
8059 $pie_register->uninstall_settings();
8060 }
8061 }
8062 register_uninstall_hook( __FILE__, 'uninstall_pr_ff' );
8063 }