This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
pie-register.php
3757 lines (3376 loc) · 145 KB
/
pie-register.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
Plugin Name: Pie Register
Plugin URI: http://pieregister.genetechsolutions.com/
Description: <strong>WordPress 3.5 + ONLY.</strong> Enhance your Registration form, Custom logo, Password field, Invitation codes, Paypal, Captcha validation, Email verification and more.
Author: Genetech Solutions
Version: 2.0.17
Author URI: http://www.genetechsolutions.com/
CHANGELOG
See readme.txt
*/
$piereg_dir_path = dirname(__FILE__);
define('PIEREG_DIR_NAME',$piereg_dir_path);
if(!defined('PIEREG_DB_VERSION'))
define('PIEREG_DB_VERSION','2.0.13');
if(!defined('PIEREG_PLUGIN_BASENAME'))
define('PIEREG_PLUGIN_BASENAME',plugin_basename( __FILE__ ));
define('LOG_FILE', '.ipn_results.log');
define('SSL_P_URL', 'https://www.paypal.com/cgi-bin/webscr');
define('SSL_SAND_URL','https://www.sandbox.paypal.com/cgi-bin/webscr');
global $pie_success,$pie_error,$pie_error_msg,$pie_suucess_msg, $pagenow,$action,$profile,$errors;
global $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;
$piereg_math_captcha_register = false;
$piereg_math_captcha_register_widget = false;
$piereg_math_captcha_login = false;
$piereg_math_captcha_login_widget = false;
$piereg_math_captcha_forgot_pass = false;
$piereg_math_captcha_forgot_pass_widget = false;
require_once(PIEREG_DIR_NAME.'/dash_widget.php');
require_once(PIEREG_DIR_NAME.'/classes/base.php');
require_once(PIEREG_DIR_NAME.'/classes/profile_admin.php');
require_once(PIEREG_DIR_NAME.'/classes/profile_front.php');
require_once(PIEREG_DIR_NAME.'/classes/registration_form.php');
require_once(PIEREG_DIR_NAME.'/classes/edit_form.php');
require_once(PIEREG_DIR_NAME.'/widget.php');
if( !class_exists('PieRegister') ){
class PieRegister extends PieReg_Base{
//public static $instance;
public static $pieinstance;
var $pie_success;
var $pie_error;
var $pie_error_msg;
var $pie_success_msg;
private $ipn_status;
public $txn_id;
public $ipn_log;
private $ipn_response;
public $ipn_data = array();
public $postvars;
private $ipn_debug;
/*
* Add since 2.0.13
*/
private $piereg_jquery_enable = false;
function __construct()
{
$this->ipn_status = '';
$this->txn_id = null;
$this->ipn_log = true;
$this->ipn_response = '';
$this->ipn_debug = false;
self::$pieinstance = $this;
/***********************/
parent::__construct();
global $pagenow,$wp_version,$profile;
$errors = new WP_Error();
add_action('wp_ajax_get_meta_by_field', array($this,'getMeta'));
add_action('wp_ajax_check_username', array($this,'unique_user' ));
add_action('wp_ajax_nopriv_check_username', array($this,'unique_user' ));
add_action( 'admin_init', array($this,'piereg_register_scripts') );
#Adding Menus
add_action( 'admin_menu', array($this,'AddPanel') );
#plugin page links
add_filter( 'plugin_action_links' , array($this,'add_action_links'),10,2 );
//Add paypal payment method
add_action("check_payment_method_paypal", array($this, "check_payment_method_paypal"));
//Adding "embed form" button
add_action('media_buttons_context', array($this, 'add_pie_form_button'));
if(in_array(basename($_SERVER['PHP_SELF']), array('post.php', 'page.php', 'page-new.php', 'post-new.php'))){
add_action('admin_footer', array($this, 'add_pie_form_popup'));
}
#Adding Short Code Functionality
add_shortcode( 'pie_register_login', array($this,'showLoginForm') );
add_shortcode( 'pie_register_form', array($this,'showForm') );
add_shortcode( 'pie_register_profile', array($this,'showProfile') );
add_shortcode( 'pie_register_forgot_password', array($this,'showForgotPasswordForm') );
add_shortcode( 'pie_register_renew_account', array($this,'show_renew_account') );
#Genrate Warnings
add_action('admin_notices', array($this, 'warnings'),20);
add_action( 'init', array($this,'pie_main') );
$profile = new Profile_admin();
add_action('show_user_profile',array($profile,"edit_user_profile"));
add_action('personal_options_update',array($profile,"updateMyProfile"));
add_action('edit_user_profile',array($profile,"edit_user_profile"));
add_action('edit_user_profile_update', array($profile,'updateProfile'));
add_action( 'widgets_init', array($this,'initPieWidget'));
add_action('get_header', array($this,'add_ob_start'));
//It will redirect the User to the home page if the curren tpage is a alternate login page
add_filter('get_header', array($this,'checkLoginPage'));
add_action('payment_validation_paypal', array($this, 'payment_validation_paypal'));
add_action("Add_payment_option", array($this,"Add_payment_option"));
add_action("add_payment_method_script", array($this,"add_payment_method_script"));
add_action("add_select_payment_script", array($this,"add_select_payment_script"));
add_action("get_payment_content_area", array($this,"get_payment_content_area"));
add_action("show_icon_payment_gateway", array($this,"show_icon_payment_gateway"));
add_filter("piereg_messages",array($this,"modify_all_notices"));
/*update update_invitation_code form ajax*/
add_action( 'wp_ajax_pireg_update_invitation_code', array($this,'pireg_update_invitation_code_cb_url' ));
add_action( 'wp_ajax_nopriv_pireg_update_invitation_code', array($this,'pireg_update_invitation_code_cb_url' ));
//add_action( 'admin_enqueue_scripts' ,array($this,'pie_admin_menu_style_enqueu') );
////FRONT END SCRIPTS
add_action('wp_head',array($this,'pie_frontend_ajaxurl'));
add_action('wp_enqueue_scripts',array($this,'pie_frontend_enqueu_scripts'));
/*
* Add sub links in wp plugin's page
*/
add_filter( 'plugin_row_meta', array( $this, 'piereg_plugin_row_meta' ), 10, 2 );
}
function pie_admin_menu_style_enqueu(){
wp_register_style( 'pie_menu_style_css', plugins_url("/css/piereg_menu_style.css",__FILE__),false,'2.0', "all" );
wp_enqueue_style( 'pie_menu_style_css' );
}
function piereg_register_scripts(){
wp_register_script('pie_calendarcontrol_js',plugins_url("/js/CalendarControl.js",__FILE__),'jquery','2.0',false);
wp_register_script('pie_datepicker_js',plugins_url("/js/datepicker.js",__FILE__),'jquery','2.0',false);
wp_register_script('pie_drag_js',plugins_url("/js/drag.js",__FILE__),'jquery','2.0',false);
wp_register_script('pie_mCustomScrollbar_js',plugins_url("/js/jquery.mCustomScrollbar.min.js",__FILE__),'jquery','2.0',false);
wp_register_script('pie_mousewheel_js',plugins_url("/js/jquery.mousewheel.min.js",__FILE__),'jquery','2.0',false);
wp_register_script('pie_sidr_js',plugins_url("/js/jquery.sidr.min.js",__FILE__),'jquery','2.0',false);
wp_register_script('pie_phpjs_js',plugins_url("/js/phpjs.js",__FILE__),'jquery','2.0',false);
wp_register_script('pie_registermain_js',plugins_url("/js/pie-register-main.js",__FILE__),'jquery','2.0',false);
wp_register_script('pie_regs_js',plugins_url("/js/pie_regs.js",__FILE__),'jquery','2.0',false);
wp_register_script('pie_tooltip_js',plugins_url("/js/tooltip.js",__FILE__),'jquery','2.0',false);
wp_register_script('pie_validation_js',plugins_url("/js/piereg_validation.js",__FILE__),'jquery','2.0',false);
wp_register_script('pie_password_checker',plugins_url("/js/pie_password_checker.js",__FILE__),'jquery','2.0',false);
/////////////////////////////////////////////////
wp_register_style( 'pie_jqueryui_css', plugins_url("/css/jquery-ui.css",__FILE__),false,'2.0', "all" );
wp_register_style( 'pie_front_css', plugins_url("/css/front.css",__FILE__),false,'2.0', "all" );
wp_register_style( 'pie_mCustomScrollbar_css', plugins_url("/css/jquery.mCustomScrollbar.css",__FILE__),false,'2.0', "all" );
wp_register_style( 'pie_style_css', plugins_url("/css/style.css",__FILE__),false,'2.0', "all" );
wp_register_style( 'pie_tooltip_css', plugins_url("/css/tooltip.css",__FILE__),false,'2.0', "all" );
wp_register_style( 'pie_validation_css', plugins_url("/css/validation.css",__FILE__),false,'2.0', "all" );
}
function print_multi_lang_script_vars(){
global $piereg_global_options;
$options = $piereg_global_options;
?>
<script type="text/javascript">
var piereg_pass_str_meter_string = new Array(
'<?php echo (($options['pass_strength_indicator_label'])?__($options['pass_strength_indicator_label'],"piereg"):"");?>',
'<?php echo (($options['pass_very_weak_label'])?__($options['pass_very_weak_label'],"piereg"):"");?>',
'<?php echo (($options['pass_weak_label'])?__($options['pass_weak_label'],"piereg"):"");?>',
'<?php echo (($options['pass_medium_label'])?__($options['pass_medium_label'],"piereg"):"");?>',
'<?php echo (($options['pass_strong_label'])?__($options['pass_strong_label'],"piereg"):"");?>',
'<?php echo (($options['pass_mismatch_label'])?__($options['pass_mismatch_label'],"piereg"):"");?>'
);
var piereg_validation_engn = new Array(
'<?php _e("none","piereg");?>',
'<?php _e("* This field is required","piereg");?>',
'<?php _e("* Please select an option","piereg");?>',
'<?php _e("* This checkbox is required","piereg");?>',
'<?php _e("* Both date range fields are required","piereg");?>',
'<?php _e("* Field must equal test","piereg");?>',
'<?php _e("* Invalid ","piereg");?>',
'<?php _e("Date Range","piereg");?>',
'<?php _e("Date Time Range","piereg");?>',
'<?php _e("* Minimum ","piereg");?>',
'<?php _e(" characters required","piereg");?>',
'<?php _e("* Maximum ","piereg");?>',
'<?php _e(" characters allowed","piereg");?>',
'<?php _e("* You must fill one of the following fields","piereg");?>',
'<?php _e("* Minimum value is ","piereg");?>',
'<?php _e("* Date prior to ","piereg");?>',
'<?php _e("* Date past ","piereg");?>',
'<?php _e(" options allowed","piereg");?>',
'<?php _e("* Please select ","piereg");?>',
'<?php _e(" options","piereg");?>',
'<?php _e("* Fields do not match","piereg");?>',
'<?php _e("* Invalid credit card number","piereg");?>',
'<?php _e("* Invalid phone number","piereg");?>',
'<?php _e("* Allowed Format (xxx) xxx-xxxx","piereg");?>',
'<?php _e("* Minimum 10 Digits starting with Country Code","piereg");?>',
'<?php _e("* Invalid email address","piereg");?>',
'<?php _e("* Not a valid integer","piereg");?>',
'<?php _e("* Invalid number","piereg");?>',
'<?php _e("* Invalid month","piereg");?>',
'<?php _e("* Invalid day","piereg");?>',
'<?php _e("* Invalid year","piereg");?>',
'<?php _e("* Invalid file extension","piereg");?>',
'<?php _e("* Invalid date, must be in YYYY-MM-DD format","piereg");?>',
'<?php _e("* Invalid IP address","piereg");?>',
'<?php _e("* Invalid URL","piereg");?>',
'<?php _e("* Numbers only","piereg");?>',
'<?php _e("* Letters only","piereg");?>',
'<?php _e("* No special characters allowed","piereg");?>',
'<?php _e("* This user is already taken","piereg");?>',
'<?php _e("* Validating, please wait","piereg");?>',
'<?php _e("* This username is available","piereg");?>',
'<?php _e("* This user is already taken","piereg");?>',
'<?php _e("* Validating, please wait","piereg");?>',
'<?php _e("* This name is already taken","piereg");?>',
'<?php _e("* This name is available","piereg");?>',
'<?php _e("* Validating, please wait","piereg");?>',
'<?php _e("* This name is already taken","piereg");?>',
'<?php _e("* Please input HELLO","piereg");?>',
'<?php _e("* Invalid Date","piereg");?>',
'<?php _e("* Invalid Date or Date Format","piereg");?>',
'<?php _e("Expected Format: ","piereg");?>',
'<?php _e("mm/dd/yyyy hh:mm:ss AM|PM or ","piereg");?>',
'<?php _e("yyyy-mm-dd hh:mm:ss AM|PM","piereg");?>',
'<?php _e("* Invalid Username","piereg");?>',
'<?php _e("* Invalid File","piereg");?>',
'<?php _e("* Maximum value is ","piereg");?>',
'<?php _e("* Alphabetic Letters only","piereg");?>'
);
</script>
<?php
}
function pie_frontend_enqueu_scripts(){
global $piereg_global_options;
$this->print_multi_lang_script_vars();
?>
<script type="text/javascript">
var piereg_current_date = '<?php echo date("Y"); ?>';
var piereg_startingDate = '<?php echo $piereg_global_options['piereg_startingDate']; ?>';
var piereg_endingDate = '<?php echo $piereg_global_options['piereg_endingDate']; ?>';
</script>
<?php
if(isset($piereg_global_options['outputcss']) && $piereg_global_options['outputcss'] == 1)
{
wp_enqueue_style('pie_front_css');
wp_enqueue_style('pie_validation_css');
}
////////////////////////////////////////////
if(isset($piereg_global_options['outputjquery_ui']) && $piereg_global_options['outputjquery_ui'] == 1)
{
wp_deregister_script('jquery-ui-core');
wp_register_script('jquery-ui-core', '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js',array('jquery'),'1.10.4',false);
wp_enqueue_script('jquery-ui-core');
//wp_enqueue_script('jquery-ui-datepicker');
}
wp_enqueue_script("pie_datepicker_js");
wp_enqueue_script("pie_validation_js");
wp_enqueue_script('zxcvbn-async');
wp_enqueue_script('password-strength-meter');
wp_enqueue_script('pie_password_checker');
}
function pie_frontend_ajaxurl(){
?>
<script type="text/javascript">
var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
</script>
<?php
}
function pie_admin_enqueu_scripts(){
?>
<script type="text/javascript">
var piereg_wp_comtent_url = '<?php echo content_url(); ?>';
var piereg_wp_home_url = '<?php echo home_url(); ?>';
var piereg_wp_site_url = '<?php echo site_url(); ?>';
var piereg_wp_admin_url = '<?php echo admin_url(); ?>';
var piereg_wp_includes_url = '<?php echo includes_url(); ?>';
var piereg_wp_plugins_url = '<?php echo plugins_url(); ?>';
var piereg_wp_pie_register_url = '<?php echo plugins_url("pie-register"); ?>';
</script>
<?php
global $piereg_global_options;
$this->print_multi_lang_script_vars();
?>
<script type="text/javascript">
var piereg_current_date = '<?php echo date("Y"); ?>';
var piereg_startingDate = '<?php echo $piereg_global_options['piereg_startingDate']; ?>';
var piereg_endingDate = '<?php echo $piereg_global_options['piereg_endingDate']; ?>';
</script>
<?php
wp_enqueue_style('pie_jqueryui_css');
wp_enqueue_style( 'pie_mCustomScrollbar_css' );
wp_enqueue_style( 'pie_style_css' );
wp_enqueue_style('pie_tooltip_css');
wp_enqueue_style('pie_validation_css');
////////////////////////////////////////////
/*
* Add Since 2.0.13
*/
if($this->piereg_jquery_enable){
wp_deregister_script('jquery');
wp_register_script('jquery', (plugins_url("/js/jquery.js",__FILE__)),"",'2.0.0',false);
wp_enqueue_script( 'jquery' );
}
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script('pie_calendarcontrol_js');
wp_enqueue_script("pie_datepicker_js");
wp_enqueue_script("pie_drag_js");
wp_enqueue_script("pie_mCustomScrollbar_js");
wp_enqueue_script("pie_mousewheel_js" );
wp_enqueue_script( 'pie_sidr_js' );
wp_enqueue_script("pie_phpjs_js");
wp_enqueue_script("pie_registermain_js");
wp_enqueue_script("pie_regs_js" );
wp_enqueue_script("pie_tooltip_js" );
wp_enqueue_script("pie_validation_js" );
}
function modify_all_notices($notice)
{
$Start_notice = "";/*Write your message*/
$End_notice = "";/*Write your message*/
return $Start_notice.$notice.$End_notice;
}
function initPieWidget()
{
register_widget( 'Pie_Register_Widget' );
register_widget( 'Pie_Login_Widget' );
register_widget( 'Pie_Forgot_Widget' );
}
//Plugin Menu Link
function add_action_links( $links, $file )
{
if ( $file != plugin_basename( __FILE__ ))
return $links;
$links[] = '<a href="'. get_admin_url(null, 'admin.php?page=pie-general-settings') .'">'.(__("General Settings","piereg")).'</a>';
return $links;
}
function pie_main()
{
//LOCALIZATION
load_plugin_textdomain( 'piereg', false, dirname(plugin_basename(__FILE__)) . '/lang/');
$pie_plugin_db_version = get_option('piereg_plugin_db_version');
if($pie_plugin_db_version != PIEREG_DB_VERSION){
$this->install_settings();
}
//$option = get_option( 'pie_register_2' );
global $piereg_global_options;
$option = $piereg_global_options;
/*********************************************/
/////////////// PIEREG LOGOUT ////////////////
if( (isset($_GET['piereg_logout_url']) and isset($_GET['redirect_to'])) and ($_GET['piereg_logout_url'] == "true") ){
$redirect_to = (!empty($_GET['redirect_to']))? urldecode($_GET['redirect_to']) : home_url();
wp_logout();
wp_redirect($redirect_to);
exit;
}
/*********************************************/
/////////// Register Scripts ////////////
$this->piereg_register_scripts();
////////////////////////////////////////
if(isset($_REQUEST['action']) && $_REQUEST['action'] == "check_username")
return;
global $pagenow;
if($option['custom_css'] != "")
add_action('wp_head', array($this,'addCustomCSS'));
if( $option['tracking_code'] != "")
add_action('wp_footer', array($this,'addCustomScripts'));
// check to prevent php "notice: undefined index" msg
$theaction ='';
if(isset($_GET['pr_preview']) && $_GET['pr_preview']==1)
{
global $errors;
$form = new Registration_form();
$success = '' ;
include_once($this->plugin_dir."/register_form_preview.php");
exit;
}elseif((isset($_GET['show_dash_widget']) && $_GET['show_dash_widget']==1) and (isset($_GET['invitaion_code']) && $_GET['invitaion_code']!=""))
{
$this->show_invitaion_code_user();
}
if(isset($_GET['action']))
$theaction = $_GET['action'];
//PAYPAL VALIDATION
$this->ValidPUser();
#Save Settings
if( isset($_POST['action']) && $_POST['action'] == 'pie_reg_update' )
{$this->SaveSettings();}
if(isset($_POST['Remove_license_x']) and ((int)$_POST['Remove_license_x']) != "0" and isset($_POST['Remove_license_y']))
{$this->Remove_license_Key();}
add_filter('allow_password_reset',array($this,'checkUserAllowedPassReset'),20,2);
#Reset Settings to default
if( isset($_POST['piereg_default_settings']) )
{
$this->piereg_default_settings();
}
#Admin Verify Users
if( isset($_POST['verifyit']) ){
$this->verifyUsers();
}
#Admin Send Payment Link
if( isset($_POST['paymentl']) && !(empty($option['paypal_butt_id'])) && $option['enable_paypal']==1)
$this->PaymentLink();
#Admin Resend VerificatioN Email
if( isset($_POST['emailverifyit']) )
$this->AdminEmailValidate() ;
#Admin Delete Unverified User
if( isset($_POST['vdeleteit']))
$this->AdminDeleteUnvalidated();
/*
* Add since 2.0.13
* Modefy Since 2.0.15
* Change email after verify
*/
$this->edit_email_verification();
//Blocking wp admin for registered users
/*
* Modefy this code since 2.0.15
* If User Verification On then Block WP Pages
*/
if(
($pagenow == 'wp-login.php' && ( $option['block_wp_login'] == 1 || !empty($option['verification']) ) ) &&
($theaction != 'logout' && !isset($_REQUEST['interim-login']) )
)
{
switch($theaction){
case "register":
wp_redirect($this->get_redirect_url_pie(get_permalink($option['alternate_register'])));
exit;
break;
case "lostpassword":
wp_redirect($this->get_redirect_url_pie(get_permalink($option['alternate_forgotpass'])));
exit;
break;
default:
if(!empty($option['alternate_login'])){
wp_redirect($this->get_redirect_url_pie(get_permalink($option['alternate_login'])));
exit;
}
break;
}
}
//Blocking access of users to default pages if redirect is on
//Patched since 2.0.11
//Password protected pages bug
//Resolved by adding postpass
if($theaction != 'logout' && $theaction != 'postpass' )
{
if((is_user_logged_in() && $pagenow == 'wp-login.php') && ($option['redirect_user']==1 && $theaction != 'logout'))
{
if(!isset($_REQUEST['interim-login'])){
$this->afterLoginPage();
}
}
}
//
if(trim($pagenow) == "profile.php" && $option['block_WP_profile']==1 )
{
$current_user = wp_get_current_user();
if(trim($current_user->roles[0]) == "subscriber")
{
//$profile_page = get_option("Profile_page_id");
$profile_page = $option['alternate_profilepage'];
wp_redirect($this->get_redirect_url_pie(get_permalink($profile_page)));
}
}
if(isset($_POST['log']) && isset($_POST['pwd'])){
$this->checkLogin();
}
else if(isset($_POST['pie_submit']))
$this->check_register_form();
else if(isset($_POST['pie_renew']))
{
$this->renew_account();
}
// if the user is on the login page, then let the game begin
if($theaction != 'logout' && $theaction != 'postpass' )
{
if ($pagenow == 'wp-login.php' && $theaction != 'logout'){
add_action('login_init',array($this,'pieregister_login'),1);
}
}
//OImport Export Section
if(isset($_POST['pie_fields_csv']) || isset($_POST['pie_meta_csv'])){
$this->generateCSV();
}
else if(isset($_FILES['csvfile']['name'])){
$this->importUsers();
}
if(isset($_POST['pie_form']))
{
/*
* Modefy since 2.0.15
*/
//This will make sure no one tempers the field from the client side
/*$required = array("form","username","email","password","submit");*/
$required = array("form","email","password","submit");
$length = 0;
foreach($_POST['field'] as $field)
{
if(in_array($field['type'],$required))
$length++;
}
if($length==sizeof($required))
{
$this->saveFields();
}
}
if(
isset($_POST['invitaion_code_bulk_option']) 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'] != ""
)
{
if(trim($_POST['invitaion_code_bulk_option']) == "delete")
{
$this->delete_invitation_codes($_POST['select_invitaion_code_bulk_option']);
}
else if(trim($_POST['invitaion_code_bulk_option']) == "active")
{
$this->active_or_unactive_invitation_codes($_POST['select_invitaion_code_bulk_option'],"1");
}
else if(trim($_POST['invitaion_code_bulk_option']) == "unactive")
{
$this->active_or_unactive_invitation_codes($_POST['select_invitaion_code_bulk_option'],"0");
}
}
if(isset($_POST['invitation_code_per_page_items']) and $_POST['invitation_code_per_page_items'] != "")
{
$opt = get_option("pie_register_2");
$val = ((int)($_POST['invitation_code_per_page_items']) != 0)? ((int)$_POST['invitation_code_per_page_items']) : "10";
$opt['invitaion_codes_pagination_number'] = $val;
update_option("pie_register_2",$opt);
global $piereg_global_options;
$piereg_global_options = $opt;
unset($opt);
}
/*if($option['modify_avatars'])
{
add_filter('get_avatar',array($this,'add_custom_avatars'),88888);
}*/
if($option['show_admin_bar'] == "0")
{
$this->subscriber_show_admin_bar();// show/hide admin bar
}
if( $option['block_wp_login'] ){
add_filter( 'login_url', array($this,'pie_login_url'),88888,1);
add_filter( 'lostpassword_url', array($this,'pie_lostpassword_url'),88888,1);
add_filter( 'register_url', array($this,'pie_registration_url'),88888,1);
add_filter( 'logout_url', array($this,'piereg_logout_url'),88888,2);
}
add_filter( 'piereg_password_reset_not_allowed_text', array($this,'piereg_password_reset_not_allowed_text_function'),20,1);
if(isset($_POST['import_email_template_from_version_1']) and $_POST['old_version_emport'] == "yes")
{
$old_options = get_option("pie_register");
$new_options = get_option("pie_register_2");
$new_options['user_message_email_admin_verification'] = nl2br($old_options['adminvmsg']);
$new_options['user_message_email_email_verification'] = nl2br($old_options['emailvmsg']);
$new_options['user_message_email_default_template'] = nl2br($old_options['msg']);
update_option("pie_register_2",$new_options);
global $piereg_global_options;
$piereg_global_options = $new_options;
}
if($option['show_custom_logo'] == 1){
if(trim($option['custom_logo_url']) != ""){
add_action('login_enqueue_scripts', array($this,'piereg_login_logo'));
}
add_filter( 'login_headertitle', array($this,'piereg_login_logo_url_title' ));
add_filter( 'login_headerurl', array($this,'piereg_login_logo_url' ));
}
add_action( 'wp_footer', array($this,'print_in_footer' ));
}
function print_in_footer(){
echo '<div class="pieregWrapper" style="display:none;">';
echo "<iframe id='CalendarControlIFrame' src='javascript:false;' frameBorder='0' scrolling='no'></iframe>";
echo "<div id='CalendarControl'></div>";
echo "</div>";
}
private function show_invitaion_code_user(){
global $errors,$wpdb;
$prefix=$wpdb->prefix."pieregister_";
$inv_code = base64_decode($_GET['invitaion_code']);
$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 ) );
?>
<style type="text/css">
table.invitaion-code-table thead td,table.invitaion-code-table tfoot td{
background:#333;
font-size:16px;
font-weight:bold;
color:#FFF;
}
table.invitaion-code-table tr:nth-child(even){background:#E8E8E8;}
table.invitaion-code-table tr:hover{background:#666;color:#FFF;}
</style>
<div style="width:100%">
<h2><?php _e("Activation Code","piereg");echo " : ".$inv_code; ?></h2>
<table class="invitaion-code-table" width="100%" cellpadding="10" cellspacing="0">
<thead>
<tr>
<td><?php _e("User Name","piereg"); ?></td>
<td><?php _e("User E-mail","piereg"); ?></td>
</tr>
</thead>
<tfoot>
<tr>
<td><?php _e("User Name","piereg"); ?></td>
<td><?php _e("User E-mail","piereg"); ?></td>
</tr>
</tfoot>
<?php
foreach($invitaion_code_users as $row){
echo '<tr>';
echo '<td>'.$row->user_login.'</td>';
echo '<td>'.$row->user_email.'</td>';
echo '</tr>';
}
?>
</table>
</div>
<?php
exit;
}
function piereg_login_logo() {
$option = get_option( 'pie_register_2' );
$logo_data = @getimagesize($option['custom_logo_url']);
?>
<style type="text/css">
body.login div#login h1 a {
background-image: url('<?php echo $option['custom_logo_url']; ?>');
background-size:<?php echo $logo_data[0]."px ".$logo_data[1]."px"; ?>;
width:<?php echo $logo_data[0]."px "; ?>;
height:<?php echo $logo_data[1]."px "; ?>;
}
</style>
<?php
unset($option);
}
function piereg_login_logo_url_title() {
$option = get_option( 'pie_register_2' );
return $option['custom_logo_tooltip'];
unset($option);
}
function piereg_login_logo_url() {
$option = get_option( 'pie_register_2' );
return $option['custom_logo_link'];
unset($option);
}
function payment_success_cancel_after_register($query_string){
global $wpdb;
$option = get_option( 'pie_register_2' );
$fields = maybe_unserialize(get_option("pie_fields"));
$confirmation_type = $fields['submit']['confirmation'];
if($confirmation_type == "page"){
wp_safe_redirect(get_permalink($fields['submit']['page']));
exit;
}elseif($confirmation_type == "redirect"){
wp_redirect($fields['submit']['redirect_url']);
exit;
}elseif($confirmation_type == "text" ){
wp_safe_redirect($this->pie_modify_custom_url(get_permalink($option['alternate_login']),$query_string));
exit;
}
}
function get_redirect_url_pie($get_url){
$get_url = trim($get_url);
if(!$get_url) return false;
if($_SERVER['QUERY_STRING']){
if(strpos($get_url,"?"))
$url = $get_url."&".$_SERVER['QUERY_STRING'];
else
$url = $get_url."?".$_SERVER['QUERY_STRING'];
}
else{
$url = $get_url;
}
return $url;
}
function subscriber_show_admin_bar()
{
global $current_user;
$current_user->caps = array_keys($current_user->caps);
$ncaps = count($current_user->caps);
$role = $current_user->caps[$ncaps - 1];
if( trim(strtolower($role)) == "subscriber" )
{
show_admin_bar( false );
}
unset($current_user);
}
//"Insert Form" button to the post/page edit screen
function add_pie_form_button($context)
{
$is_post_edit_page = in_array(basename($_SERVER['PHP_SELF']), array('post.php', 'page.php', 'page-new.php', 'post-new.php'));
if(!$is_post_edit_page)
return $context;
//$out = '<a href="#TB_inline?width=480&inlineId=select_pie_form" class="thickbox" id="add_pie_form" title="' . __("Add Pie Register Form", 'piereg') . '"><img src="'.plugins_url('pie-register').'/images/form-icon.png" alt="' . __("Add Pie Register Form", 'piereg') . '" /></a>';
$out = '<a href="#TB_inline?width=480&inlineId=select_pie_form" class="thickbox button" id="add_pie_form" title="' . __("Add Pie Register Form", 'piereg') . '" ><span style="background: url('.plugins_url('pie-register').'/images/form-icon.png); background-repeat: no-repeat; background-position: left bottom;" class="wp-media-buttons-icon"></span> '.__("Add Form","piereg").'</a>';
return $context . $out;
}
function checkLoginPage()
{
$option = get_option('pie_register_2');
$current_page = get_the_ID();
if($option['block_wp_login']==1 && $option['alternate_login'] > 0 && is_user_logged_in() && $current_page == $option['alternate_login'] )
{
$this->afterLoginPage();
}
}
function add_pie_form_popup()
{
?>
<script type="text/javascript">
function addForm(){
var form_id = jQuery("#pie_forms").val();
if(form_id == ""){
alert("<?php _e("Please select a form", "piereg") ?>");
return;
}
window.send_to_editor(form_id);
}
</script>
<div id="select_pie_form" style="display:none;">
<div >
<div>
<div style="padding:15px 15px 0 15px;">
<h3 style="color:#5A5A5A!important; font-family:Georgia,Times New Roman,Times,serif!important; font-size:1.8em!important; font-weight:normal!important;"><?php _e("Select A Form", "piereg"); ?></h3>
<span>
<?php _e("Select a form below to add it to your post or page.", "piereg"); ?>
</span>
</div>
<div style="padding:15px 15px 0 15px;">
<select id="pie_forms">
<option value="[pie_register_form]"><?php _e("Registration Form","piereg") ?></option>
<option value="[pie_register_login]"><?php _e("Login Form","piereg") ?></option>
<option value="[pie_register_forgot_password]"><?php _e("Forgot Password Form","piereg") ?></option>
<option value="[pie_register_profile]"><?php _e("Profile Page","piereg") ?></option>
</select> <br/>
</div>
<div style="padding:15px;">
<input type="button" class="button-primary" value="Insert Form" onclick="addForm();"/>
<a class="button" style="color:#bbb;" href="#" onclick="tb_remove(); return false;"><?php _e("Cancel", "piereg"); ?></a>
</div>
</div>
</div>
</div>
<?php
}
function getMeta()
{
$meta = get_option( 'pie_fields_meta');
$meta = $meta[$_POST['field_type']];
$meta = str_replace("%d%",$_POST['id'],$meta);
$meta .= '<input value = "'.$_POST['field_type'].'" type="hidden" class="input_fields" name="field['.$_POST['id'].'][type]" id="type_'.$_POST['id'].'">';
echo $meta;
die();
}
function process_login_form(){
get_header();
//ob_start();
include_once("login_form.php");
$output = pieOutputLoginForm();
echo $output;
//ob_end_flush();
//include_once("login_form.php");
get_footer();
exit;
}
function checkLogin()
{
global $errors, $wp_session;
$errors = new WP_Error();
$option = get_option('pie_register_2');
/*
* Sanitizing post data
*/
$this->piereg_sanitize_post_data( ( (isset($_POST) && !empty($_POST))?$_POST : array() ) );
if(empty($_POST['log']) || empty($_POST['pwd']))
{
$errors->add('login-error',apply_filters("piereg_Invalid_username_or_password",__('Invalid username or password.','piereg')));
}
else
{
$error_found = 0;
if($option['capthca_in_login'] == 1){
$settings = get_option("pie_register_2");
$privatekey = $settings['captcha_private'] ;
if($privatekey)
{
require_once(PIEREG_DIR_NAME.'/recaptchalib.php');
$resp = recaptcha_check_answer ($privatekey,$_SERVER["REMOTE_ADDR"],$_POST["recaptcha_challenge_field"],$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$errors->add('login-error',apply_filters("Invalid_Security_Code",__('Invalid Security Code','piereg')));
$error_found++;
}
}
}
elseif($option['capthca_in_login'] == 2){
if(isset($_POST['piereg_math_captcha_login']))//Login form in Page
{
$piereg_cookie_array = $_COOKIE['piereg_math_captcha_Login_form'];
/*$piereg_cookie_array = explode(",",$piereg_cookie_array);*/
$piereg_cookie_array = explode("|",$piereg_cookie_array);
$cookie_result1 = (intval(base64_decode($piereg_cookie_array[0])) - 12);
$cookie_result2 = (intval(base64_decode($piereg_cookie_array[1])) - 786);
$cookie_result3 = (intval(base64_decode($piereg_cookie_array[2])) + 5);
if( ($cookie_result1 == $cookie_result2) && ($cookie_result3 == $_POST['piereg_math_captcha_login'])){
}
else{
$errors->add('login-error',apply_filters("Invalid_Security_Code",__('Invalid Security Code','piereg')));
$error_found++;
}
}
elseif(isset($_POST['piereg_math_captcha_login_widget']))//Login form in widget
{
$piereg_cookie_array = $_COOKIE['piereg_math_captcha_Login_form_widget'];
/*$piereg_cookie_array = explode(",",$piereg_cookie_array);*/
$piereg_cookie_array = explode("|",$piereg_cookie_array);
$cookie_result1 = (intval(base64_decode($piereg_cookie_array[0])) - 12);
$cookie_result2 = (intval(base64_decode($piereg_cookie_array[1])) - 786);
$cookie_result3 = (intval(base64_decode($piereg_cookie_array[2])) + 5);
if( ($cookie_result1 == $cookie_result2) && ($cookie_result3 == $_POST['piereg_math_captcha_login_widget'])){
}
else{
$errors->add('login-error',apply_filters("Invalid_Security_Code",__('Invalid Security Code','piereg')));
$error_found++;
}
}else{
$errors->add('login-error',apply_filters("Invalid_Security_Code",__('Invalid Security Code','piereg')));
$error_found++;
}
}
if($error_found == 0){
$creds = array();
$creds['user_login'] = $_POST['log'];
$creds['user_password'] = $_POST['pwd'];
$creds['remember'] = isset($_POST['rememberme']);
$piereg_secure_cookie = false;
if ( (!empty($_POST['log']) && !empty($_POST['pwd'])) && (!force_ssl_admin() && is_ssl()) ) {
$piereg_secure_cookie = true;
force_ssl_admin(true);
}
$user = wp_signon( $creds, $piereg_secure_cookie);
if ( is_wp_error($user))
{
$user_login_error = $user->get_error_message();
if(strpos(strip_tags($user_login_error),'Invalid username',5) > 6)
{
$user_login_error = apply_filters('pie_invalid_username_password_msg_txt','<strong>'.ucwords(__("error","piereg")).'</strong>: '.__("Invalid username","piereg").'. <a href="'.$this->pie_lostpassword_url().'" title="'.__("Password Lost and Found","piereg").'">'.__("Lost your password?","piereg").'</a>');
}else if(strpos(strip_tags($user_login_error),'password you entered',9) > 10)
{
$user_login_error = apply_filters('pie_invalid_user_password_msg_txt','<strong>'.ucwords(__("error","piereg")).'</strong>: '.__("The password you entered for the username","piereg").' <strong>'.$_POST['log'].'</strong> '.__("is incorrect","piereg").'. <a href="'.$this->pie_lostpassword_url().'" title="'.__("Password Lost and Found","piereg").'">'.__("Lost your password?","piereg").'</a>');
}
$errors->add('login-error',apply_filters("piereg_login_error",$user_login_error));
}
else
{
if(in_array("administrator",(array)$user->roles)){
/*
* Add Since 2.0.13
*/
if( $user ) {
wp_set_current_user( $user->ID, $user->user_login );
wp_set_auth_cookie( $user->ID );
do_action( 'wp_login', $user->user_login, $user );
}
do_action("piereg_admin_login_before_redirect_hook",$user);
if(isset($_GET['redirect_to']) and $_GET['redirect_to'] != ""){
wp_redirect($_GET['redirect_to']);
exit;
}
wp_safe_redirect(admin_url());
exit;
}
else
{
$active = get_user_meta($user->ID,"active",true);
//Delete User after grace Period
if($active == "0")//If not active
{
$delete_user = true;
if($this->deleteUsers($user->ID,$user->user_email,$user->user_registered)){
$errors->add("login-error",apply_filters("piereg_your_account_has_no_longer_exist",__("Your account has no longer exist.")));
$delete_user = false;
}
if($delete_user){
wp_logout();
$errors->add('login-error',apply_filters("piereg_your_account_is_not_activated",__('Your account is not activated!.','piereg')));
}
}elseif(empty($active))
{
/*
* Add Since 2.0.13
*/
if( $user ) {
wp_set_current_user( $user->ID, $user->user_login );
wp_set_auth_cookie( $user->ID );
do_action( 'wp_login', $user->user_login, $user );
}
do_action("piereg_user_login_before_redirect_hook",$user);
$this->afterLoginPage();
exit;
}
else{
/*
* Add Since 2.0.13
*/
if( $user ) {
wp_set_current_user( $user->ID, $user->user_login );
wp_set_auth_cookie( $user->ID );
do_action( 'wp_login', $user->user_login, $user );
}
do_action("piereg_user_login_before_redirect_hook",$user);
$this->afterLoginPage();
exit;
}
}
}