PluginProbe
Loginizer / 2.0.3
Loginizer v2.0.3
2.1.0 2.0.9 2.0.8 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 trunk 1.0 1.0.1 1.0.2 1.1.0 1.1.1 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 All 74 releases
← All changes | functions.php +110 -27 trunk2.0.3 View file →
@@ -4,10 +4,60 @@
4 4 die('HACKING ATTEMPT!');
5 5 }
6 6
7 7 include_once(LOGINIZER_DIR.'/lib/IPv6/IPv6.php');
8 -include_once(LOGINIZER_DIR .'/common.php');
9 8
9 +// Get the client IP
10 +function _lz_getip(){
11 + if(isset($_SERVER["REMOTE_ADDR"])){
12 + return $_SERVER["REMOTE_ADDR"];
13 + }elseif(isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
14 + return $_SERVER["HTTP_X_FORWARDED_FOR"];
15 + }elseif(isset($_SERVER["HTTP_CLIENT_IP"])){
16 + return $_SERVER["HTTP_CLIENT_IP"];
17 + }
18 +}
19 +
20 +// Get the client IP
21 +function lz_getip(){
22 +
23 + global $loginizer;
24 +
25 + // Just so that we have something
26 + $ip = _lz_getip();
27 +
28 + $loginizer['ip_method'] = (int) @$loginizer['ip_method'];
29 +
30 + if(isset($_SERVER["REMOTE_ADDR"])){
31 + $ip = $_SERVER["REMOTE_ADDR"];
32 + }
33 +
34 + if(isset($_SERVER["HTTP_X_FORWARDED_FOR"]) && @$loginizer['ip_method'] == 1){
35 + if(strpos($_SERVER["HTTP_X_FORWARDED_FOR"], ',')){
36 + $temp_ip = explode(',', $_SERVER["HTTP_X_FORWARDED_FOR"]);
37 + $ip = trim($temp_ip[0]);
38 + }else{
39 + $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
40 + }
41 + }
42 +
43 + if(isset($_SERVER["HTTP_CLIENT_IP"]) && @$loginizer['ip_method'] == 2){
44 + $ip = $_SERVER["HTTP_CLIENT_IP"];
45 + }
46 +
47 + if(@$loginizer['ip_method'] == 3 && isset($_SERVER[@$loginizer['custom_ip_method']])){
48 + $ip = $_SERVER[@$loginizer['custom_ip_method']];
49 + }
50 +
51 + // Hacking fix for X-Forwarded-For
52 + if(!lz_valid_ip($ip)){
53 + return '';
54 + }
55 +
56 + return $ip;
57 +
58 +}
59 +
10 60 // Execute a select query and return an array
11 61 function lz_selectquery($query, $array = 0){
12 62 global $wpdb;
13 63
@@ -19,8 +69,58 @@
19 69 return $result;
20 70 }
21 71 }
22 72
73 +// Check if an IP is valid
74 +function lz_valid_ip($ip){
75 +
76 + if(empty($ip)){
77 + return false;
78 + }
79 +
80 + // IPv6
81 + if(lz_valid_ipv6($ip)){
82 + return true;
83 + }
84 +
85 + // IPv4
86 + if(!ip2long($ip) || !lz_valid_ipv4($ip)){
87 + return false;
88 + }
89 +
90 + return true;
91 +}
92 +
93 +function lz_valid_ipv4($ip){
94 + if(!preg_match('/^(\d){1,3}\.(\d){1,3}\.(\d){1,3}\.(\d){1,3}$/is', $ip) || substr_count($ip, '.') != 3){
95 + return false;
96 + }
97 +
98 + $r = explode('.', $ip);
99 +
100 + foreach($r as $v){
101 + $v = (int) $v;
102 + if($v > 255 || $v < 0){
103 + return false;
104 + }
105 + }
106 +
107 + return true;
108 +
109 +}
110 +
111 +function lz_valid_ipv6($ip){
112 +
113 + $pattern = '/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/';
114 +
115 + if(!preg_match($pattern, $ip)){
116 + return false;
117 + }
118 +
119 + return true;
120 +
121 +}
122 +
23 123 // Check if a field is posted via POST else return default value
24 124 function lz_optpost($name, $default = ''){
25 125
26 126 if(!empty($_POST[$name])){
@@ -144,9 +244,9 @@
144 244 if(empty($error)){
145 245 return true;
146 246 }
147 247
148 - $error_string = '<b>'.__('Please fix the below error(s)', 'loginizer').' :</b> <br />';
248 + $error_string = '<b>Please fix the below error(s) :</b> <br />';
149 249
150 250 foreach($error as $ek => $ev){
151 251 $error_string .= '* '.$ev.'<br />';
152 252 }
@@ -151,9 +251,9 @@
151 251 $error_string .= '* '.$ev.'<br />';
152 252 }
153 253
154 254 echo '<div id="message" class="error"><p>'
155 - . $error_string
255 + . __($error_string, 'loginizer')
156 256 . '</p></div>';
157 257 }
158 258
159 259 // Report a notice
@@ -171,9 +271,9 @@
171 271 }else{
172 272 $notice_class = 'updated';
173 273 }
174 274
175 - $notice_string = '<b>'.__('Please check the below notice(s)', 'loginizer').' :</b> <br />';
275 + $notice_string = '<b>Please check the below notice(s) :</b> <br />';
176 276
177 277 foreach($notice as $ek => $ev){
178 278 $notice_string .= '* '.$ev.'<br />';
179 279 }
@@ -178,9 +278,9 @@
178 278 $notice_string .= '* '.$ev.'<br />';
179 279 }
180 280
181 281 echo '<div id="message" class="'.$notice_class.'"><p>'
182 - . $notice_string
282 + . __($notice_string, 'loginizer')
183 283 . '</p></div>';
184 284 }
185 285
186 286 // Convert an objext to array
@@ -457,21 +557,14 @@
457 557 ];
458 558
459 559 $social_buttons = '<div id="lz-social-login-btns" class="'.($style == 'icon' ? 'lz-social-login-btns-icon' : 'lz-social-login-btns-full').' '.($position == 'above' || $position == 'below' ? 'lz-social-'.$padding[$position].'-padding' : '').'" style="justify-self:'.esc_attr($container_alignment).'; justify-content:'.esc_attr($button_alignment).';">';
460 560
461 - /* translators: %s: This OR is used as a separator for Either login through username OR use social login */
462 - $or_translated = __('OR', 'loginizer');
463 -
464 561 // HTML of the divider in case the buttons are below the login fields
465 562 if(!empty($divider_pos) && $divider_pos == 'above'){
466 - $social_buttons .= '<div class="loginizer-social-divider">'.esc_html($or_translated).'</div><br>';
563 + $social_buttons .= '<div class="loginizer-social-divider">OR</div><br>';
467 564 }
468 565
469 566 include_once LOGINIZER_DIR . '/main/login-providers.php';
470 -
471 - // This is used to decide weather we will use Login with or Register with
472 - $current_hook = current_action();
473 - $register_hooks = ['register_form', 'woocommerce_register_form'];
474 567
475 568 foreach($providers as $provider => $settings){
476 569 if(empty($settings['enabled']) || empty($settings['tested'])){
477 570 continue;
@@ -503,20 +596,12 @@
503 596 $social_buttons .= '<div class="loginizer-social-button '.($style == 'icon' ? 'lz-social-button-icon' : 'lz-social-button-btn').' '.($shape == 'circle' ? 'lz-social-button-icon-circle' : 'lz-social-button-icon-square').'" onclick="loginizer_auth_popup(\''.esc_js($provider).'\', '.esc_js(!empty($settings['loginizer_social_key']) ? true : 0).')" style="'.((!empty($loginizer_login_providers[$provider]['styles']) && !empty($loginizer_login_providers[$provider]['styles'][$btn_style])) ? esc_attr($loginizer_login_providers[$provider]['styles'][$btn_style]) : esc_attr('background-color:'. esc_attr($color)). '; color:#FFF;') .'">
504 597 <div class="loginizer-social-btn-logo">
505 598 <img src="'.esc_url($img_url).'" height="24" alt="'.esc_attr($name).' Icon"/>
506 599 </div>';
507 -
508 - if(in_array($current_hook, $register_hooks)){
509 - /* translators: %s: This is for social login so the complete text would be Register With [Brand Name], eg Register With Google */
510 - $button_text = esc_html__('Register With', 'loginizer');
511 - } else {
512 - /* translators: %s: This is for social login so the complete text would be Login With [Brand Name], eg Login With Google */
513 - $button_text = esc_html__('Login With', 'loginizer');
514 - }
515 600
516 601 // Button text in case of full button
517 602 if(!empty($loginizer['social_settings']) && $style === 'full'){
518 - $social_buttons .= '<div class="loginizer-social-btn-text">'.esc_html($button_text).' <strong>'.esc_html($name).'</strong>
603 + $social_buttons .= '<div class="loginizer-social-btn-text">'.esc_html__('Login With', 'loginizer').' <strong>'.esc_html($name).'</strong>
519 604 </div>';
520 605 }
521 606
522 607 $social_buttons .= '</div>';
@@ -527,9 +612,9 @@
527 612 }
528 613
529 614 // HTML of the divider in case the buttons are above the login fields
530 615 if(!empty($divider_pos) && $divider_pos == 'below'){
531 - $social_buttons .= '<br><div class="loginizer-social-divider">'.esc_html($or_translated).'</div>';
616 + $social_buttons .= '<br><div class="loginizer-social-divider">OR</div>';
532 617 }
533 618
534 619 $social_buttons .= '</div>';
535 620 loginizer_add_social_js($page_type);
@@ -655,11 +740,9 @@
655 740
656 741 }
657 742
658 743 function loginizer_social_btn_login($return = false, $id = ''){
659 - if(!loginizer_is_blacklisted()){
660 - loginizer_social_btn($return, 'login');
661 - }
744 + loginizer_social_btn($return, 'login');
662 745 }
663 746
664 747 function loginizer_get_social_error(){
665 748 global $loginizer;
@@ -686,5 +769,5 @@
686 769
687 770 // Cleaning the error data
688 771 delete_site_transient($error_identifier); // Deleting the data
689 772 //setcookie('lz_social_error', '', time() - 300, COOKIEPATH, COOKIE_DOMAIN, is_ssl(), true); // have to delete
690 -}
773 +}