PluginProbe
Loginizer / 2.1.0
Loginizer v2.1.0
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
loginizer / main / admin.php

admin.php in Loginizer 2.1.0, at main/admin.php

1,006 lines 37.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if(!defined('ABSPATH')){
4 die('Hacking Attempt!');
5 }
6
7 function loginizer_admin_hooks(){
8 add_action('admin_menu', 'loginizer_admin_menu');
9 add_action('admin_notices', 'loginizer_social_login_url_alert');
10 add_action('admin_footer', 'loginizer_social_interim_js');
11 add_action('admin_init', 'loginizer_admin_actions');
12 // add_filter("plugin_action_links_plugin_loginizer", 'loginizer_plugin_action_links');
13
14 loginizer_admin_promo_hooks();
15 }
16
17 function loginizer_admin_promo_hooks(){
18 global $loginizer;
19
20 if(!current_user_can('activate_plugins') || defined('SITEPAD')){
21 return;
22 }
23
24 // Is the premium features there ?
25 if(!defined('LOGINIZER_PREMIUM')){
26 // The promo time
27 $loginizer['promo_time'] = get_option('loginizer_promo_time');
28 if(empty($loginizer['promo_time'])){
29 $loginizer['promo_time'] = time();
30 update_option('loginizer_promo_time', $loginizer['promo_time']);
31 }
32
33 // Are we to show the loginizer promo
34 if(!empty($loginizer['promo_time']) && $loginizer['promo_time'] > 0 && $loginizer['promo_time'] < (time() - (30*24*3600))){
35 add_action('admin_notices', 'loginizer_promo');
36 }
37
38 if(!empty($loginizer['csrf_promo']) && $loginizer['csrf_promo'] > 0 && $loginizer['csrf_promo'] < (time() - 86400)){
39 add_action('admin_notices', 'loginizer_csrf_promo');
40 }
41
42 // Are we to disable the promo
43 if(isset($_GET['loginizer_promo']) && (int)$_GET['loginizer_promo'] == 0){
44 update_option('loginizer_promo_time', (0 - time()) );
45 die('DONE');
46 }
47
48 $loginizer['backuply_promo'] = get_option('loginizer_backuply_promo_time');
49 if(empty($loginizer['backuply_promo'])){
50 $loginizer['backuply_promo'] = abs($loginizer['promo_time']);
51 update_option('loginizer_backuply_promo_time', $loginizer['backuply_promo']);
52 }
53
54 // Setting CSRF Promo time
55 $loginizer['csrf_promo'] = get_option('loginizer_csrf_promo_time');
56
57 if(empty($loginizer['csrf_promo'])){
58 $loginizer['csrf_promo'] = abs($loginizer['promo_time']);
59 update_option('loginizer_csrf_promo_time', $loginizer['csrf_promo']);
60 }
61 }
62
63 // === Plugin Update Notice === //
64 $plugin_update_notice = get_option('softaculous_plugin_update_notice', []);
65 $available_update_list = get_site_transient('update_plugins');
66
67 if(
68 !empty($available_update_list) &&
69 is_object($available_update_list) &&
70 !empty($available_update_list->response) &&
71 !empty($available_update_list->response['loginizer/loginizer.php']) &&
72 (empty($plugin_update_notice) || empty($plugin_update_notice['loginizer/loginizer.php']) || (!empty($plugin_update_notice['loginizer/loginizer.php']) &&
73 version_compare($plugin_update_notice['loginizer/loginizer.php'], $available_update_list->response['loginizer/loginizer.php']->new_version, '<')))
74 ){
75 add_action('admin_notices', 'loginizer_plugin_update_notice');
76 add_filter('softaculous_plugin_update_notice', 'loginizer_update_notice_filter');
77 }
78 // === Plugin Update Notice === //
79 }
80
81 function loginizer_admin_actions(){
82 global $loginizer;
83
84 if(defined('LOGINIZER_PREMIUM') && !defined('SITEPAD') && current_user_can('activate_plugins') && isset($_GET['page']) && strpos($_GET['page'], 'loginizer') !== FALSE){
85
86 $license_notice = get_option('loginizer_license_notice', 0);
87 if(empty($license_notice)){
88 $license_notice = time();
89 update_option('loginizer_license_notice', $license_notice);
90 }
91
92 $license = get_option('loginizer_license', []);
93
94 // Here we are making sure that we have a license and it has expiry time and has not been dismissed for 2 months
95 if(!empty($license) && !empty($license['expires']) && ($license_notice > 0 || (abs($license_notice) + MONTH_IN_SECONDS * 2) < time())){
96 $current_timestamp = time();
97 $expiration_timestamp = strtotime($license['expires']);
98 $timediff = $expiration_timestamp - $current_timestamp;
99
100 if($timediff <= WEEK_IN_SECONDS){
101 add_action('admin_notices', 'loginizer_check_expires');
102 }
103 }
104 }
105
106 // Notice to let user know about SoftWP.
107 if(
108 !defined('LOGINIZER_PREMIUM') &&
109 !defined('BACKUPLY_PRO') &&
110 !defined('SPEEDYCACHE_PRO') &&
111 !defined('PAGELAYER_PREMIUM') &&
112 !defined('GOSMTP_PREMIUM') &&
113 !defined('SITESEO_PREMIUM')
114 ){
115 add_action('admin_notices', 'loginizer_softwp_upgrader_notice');
116 }
117 }
118
119
120
121 // Add settings link on plugin page
122 function loginizer_plugin_action_links($links) {
123
124 if(!defined('LOGINIZER_PREMIUM')){
125 $links[] = '<a href="'.LOGINIZER_PRO_URL.'" style="color:#3db634;" target="_blank">'._x('Upgrade', 'Plugin action link label.', 'loginizer').'</a>';
126 }
127
128 $settings_link = '<a href="admin.php?page=loginizer">Settings</a>';
129 array_unshift($links, $settings_link);
130
131 return $links;
132 }
133
134 function loginizer_newsletter_subscribe(){
135
136 $newsletter_dismiss = get_option('loginizer_dismiss_newsletter');
137
138 if(!empty($newsletter_dismiss)){
139 return;
140 }
141
142 $env['url'] = 'https://loginizer.com/';
143
144 echo '
145 <style>
146 .newsletter_container{
147 color: #000000;
148 background: #FFFFFF;
149 text-align:center;
150 }
151 .subscribe_form_row{
152 color: #000000;
153 padding-bottom:0px !important;
154 }
155 .subscribe_heading{
156 font-size:22px;
157 }
158 </style>
159
160 <div class="notice my-loginizer-dismiss-notice is-dismissible" style="background:#FFF;padding:15px; border: 1px solid #ccd0d4; width:80%;margin-left:0px;margin:auto;">
161 <div class="container">
162 <div class="col-md-6 col-md-offset-3 text-center newsletter_container">
163 <h2 style="font-weight:100; margin-bottom:20px; margin-top:5px;" class="subscribe_heading">Subscribe to our Newsletter</h2>
164 <form class="form-inline" action="" method="POST">
165 <div class="row subscribe_form_row">
166 <div class="col-md-12">
167 <input type="email" name="email" size="40" id="subscribe_email" class="" placeholder="email@example.com" value="">&nbsp;
168 <input type="button" name="subscribe" id="subscribe_button" class="button button-primary" value="Subscribe" onclick="loginizer_email_subscribe();" style="margin-top:0px;">
169 </div>
170 <div class="col-md-3">
171 </div>
172 </div>
173 </form>
174 <p><b>Note :</b> If a Loginizer account does not exist it will be created.</p>
175 </div>
176 </div>
177 </div><br />
178
179 <script type="text/javascript">
180 function loginizer_dismiss_newsletter(){
181
182 var data = new Object();
183 data["action"] = "loginizer_dismiss_newsletter";
184 data["nonce"] = "'.wp_create_nonce('loginizer_admin_ajax').'";
185
186 var admin_url = "'.admin_url().'"+"admin-ajax.php";
187 jQuery.post(admin_url, data, function(response){
188
189 });
190
191 }
192
193 function loginizer_email_subscribe(){
194 var subs_location = "'.$env['url'].'?email="+encodeURIComponent(jQuery("#subscribe_email").val());
195 window.open(subs_location, "_blank");
196 }
197 jQuery(document).on("click", ".my-loginizer-dismiss-notice .notice-dismiss", loginizer_dismiss_newsletter);
198 </script>';
199
200 return true;
201 }
202
203 function loginizer_backuply_promo(){
204
205 $plugins = get_plugins();
206
207 // Dont show Backuply Promo if its already installed
208 if(array_key_exists('backuply-pro/backuply-pro.php', $plugins) || array_key_exists('backuply/backuply.php', $plugins)){
209 return;
210 }
211
212 if(isset($_REQUEST['install_backuply'])){
213 if(!wp_verify_nonce($_REQUEST['security'], 'loginizer_install_backuply') || !current_user_can('activate_plugins')){
214 die('Only Admin can access it');
215 }
216
217 loginizer_backuply_install();
218 return;
219 }
220
221 echo '<div class="notice is-dismissible lz-welcome-panel lz-backuply-dismissible" style="padding:20px; margin:0;">
222 <table>
223 <tr>
224 <th width="25%">
225 <img src="'.LOGINIZER_URL.'\assets\images\backuply-square.png" height="150px" width="150px"/>
226 </th>
227 <td width="75%">
228 <div class="inside" style="margin-left: 20px;">
229 <strong><i>'.__('Backups are the best form of security. Secure your WordPress site by creating backups with Backuply','loginizer').'</i>:</strong><br>
230 <ul class="lz-right-ul">
231 <li>'.__('Backup to remote locations like FTP, FTPS, SFTP, WebDAV, Google Drive, OneDrive, Dropbox, Amazon S3','loginizer').'</li>
232 <li>'.__('Auto Backups','loginizer').'</li>
233 <li>'.__('Easy One-Click restores','loginizer').'</li>
234 <li>'.__('Stress Free Migrations','loginizer').'</li>
235 </ul>
236 <a class="button button-primary" href="'.esc_url(admin_url('admin.php?page=loginizer&install_backuply=1&security='.wp_create_nonce('loginizer_install_backuply'))).'">'.__('Install Backuply', 'loginizer').'</a>&nbsp;&nbsp;<a class="button button-secondary" target="_blank" href="https://wordpress.org/plugins/backuply/">'.__('Visit Backuply','loginizer').'</a>
237 </div>
238 </td>
239 </tr>
240 </table>
241 </div><br />
242 <script type="text/javascript">
243 function loginizer_dismiss_backuply(){
244
245 var data = new Object();
246 data["action"] = "loginizer_dismiss_backuply";
247 data["nonce"] = "'.wp_create_nonce('loginizer_admin_ajax').'";
248
249 var admin_url = "'.admin_url().'"+"admin-ajax.php";
250 jQuery.post(admin_url, data, function(response){
251
252 });
253
254 }
255
256 jQuery(document).on("click", ".lz-backuply-dismissible .notice-dismiss", loginizer_dismiss_backuply);
257 </script>';
258
259 return true;
260 }
261
262 function loginizer_csrf_promo(){
263
264 echo '<div class="notice notice-success is-dismissible lz-csrf-dismissible"><p>Secure your WordPress site from CSRF attacks with our new feature <strong>CSRF Protection</strong> <a href="https://loginizer.com/docs/configuration-and-settings/how-to-enable-csrf-protection/" target="_blank" class="button button-primary">Read More</a></p></div>';
265
266 echo'<script type="text/javascript">
267 function loginizer_dismiss_csrf(){
268
269 var data = new Object();
270 data["action"] = "loginizer_dismiss_csrf";
271 data["nonce"] = "'.wp_create_nonce('loginizer_admin_ajax').'";
272
273 var admin_url = "'.admin_url().'"+"admin-ajax.php";
274 jQuery.post(admin_url, data, function(response){
275
276 });
277
278 }
279
280 jQuery(document).on("click", ".lz-csrf-dismissible", loginizer_dismiss_csrf);
281 </script>';
282 }
283
284 // Install Backuply
285 function loginizer_backuply_install(){
286
287 // Include the necessary stuff
288 include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
289
290 // Includes necessary for Plugin_Upgrader and Plugin_Installer_Skin
291 include_once( ABSPATH . 'wp-admin/includes/file.php' );
292 include_once( ABSPATH . 'wp-admin/includes/misc.php' );
293 include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
294
295 // Filter to prevent the activate text
296 add_filter('install_plugin_complete_actions', 'loginizer_backuply_install_complete_actions', 10, 3);
297
298 $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin() );
299 $installed = $upgrader->install('https://downloads.wordpress.org/plugin/backuply.zip');
300
301 if ( !is_wp_error( $installed ) && $installed ) {
302 echo 'Activating Backuply !';
303 $activate = activate_plugin('backuply/backuply.php');
304
305 if ( is_null($activate) ) {
306 echo '<div id="message" class="updated"><p>'. esc_html__('Done! Backuply is now installed and activated.', 'loginizer'). '</p></div><br /><br><br><b>'. esc_html__('Done! Backuply is now installed and activated.', 'loginizer').'</b>';
307 }
308 }
309
310 return $installed;
311 }
312
313 // Prevent pro activate text for installer
314 function loginizer_backuply_install_complete_actions($install_actions, $api, $plugin_file){
315
316 if($plugin_file == 'backuply/backuply.php'){
317 return array();
318 }
319
320 return $install_actions;
321 }
322
323 // The Loginizer Theme footer
324 function loginizer_page_footer(){
325
326 if(!loginizer_is_premium()){
327 echo '<script>
328 jQuery("[loginizer-premium-only]").each(function(index) {
329 jQuery(this).find( "input, textarea, select" ).attr("disabled", true);
330 });
331 </script>';
332 }
333
334 echo '</td>
335 <td width="200" valign="top" id="loginizer-right-bar">';
336
337 if(!defined('SITEPAD')){
338
339 if(!defined('LOGINIZER_PREMIUM')){
340
341 echo '
342 <div class="postbox" style="min-width:0px !important;">
343 <div class="postbox-header">
344 <h2 class="hndle ui-sortable-handle">
345 <span>'.__('Premium Version','loginizer').'</span>
346 </h2>
347 </div>
348
349 <div class="inside">
350 <i>'.__('Upgrade to the premium version and get the following features','loginizer').' </i>:<br>
351 <ul class="lz-right-ul">
352 <li>'.__('PasswordLess Login','loginizer').'</li>
353 <li>'.__('Two Factor Auth - Email','loginizer').'</li>
354 <li>'.__('Two Factor Auth - App','loginizer').'</li>
355 <li>'.__('Login Challenge Question','loginizer').'</li>
356 <li>'.__('reCAPTCHA','loginizer').'</li>
357 <li>'.__('Rename Login Page','loginizer').'</li>
358 <li>'.__('Disable XML-RPC','loginizer').'</li>
359 <li>'.__('And many more ...','loginizer').'</li>
360 </ul>
361 <center><a class="button button-primary" target="_blank" href="'.LOGINIZER_PRICING_URL.'">Upgrade</a></center>
362 </div>
363 </div>';
364
365 }else{
366
367 echo '
368 <div class="postbox" style="min-width:0px !important;">
369 <div class="postbox-header">
370 <h2 class="hndle ui-sortable-handle">
371 <span>'.__('Recommendations','loginizer').'</span>
372 </h2>
373 </div>
374 <div class="inside">
375 <i>'.__('We recommed that you enable atleast one of the following security features','loginizer').'</i>:<br>
376 <ul class="lz-right-ul">
377 <li>'.__('Rename Login Page','loginizer').'</li>
378 <li>'.__('Login Challenge Question','loginizer').'</li>
379 <li>'.__('reCAPTCHA','loginizer').'</li>
380 <li>'.__('Two Factor Auth - Email','loginizer').'</li>
381 <li>'.__('Two Factor Auth - App','loginizer').'</li>
382 <li>'.__('Change \'admin\' Username','loginizer').'</li>
383 </ul>
384 </div>
385 </div>';
386 }
387
388 echo '
389 <div class="postbox" style="min-width:0px !important;">
390 <div class="postbox-header">
391 <h2 class="hndle ui-sortable-handle">
392 <span><a target="_blank" href="https://backuply.com/?from=loginizer-plugin"><img src="'.LOGINIZER_URL.'/assets/images/backuply-black.png" width="100%" /></a></span>
393 </h2>
394 </div>
395 <div class="inside">
396 <i>'.__('Secure your WordPress site by creating backups with Backuply', 'loginizer').'</i>:<br>
397 <ul class="lz-right-ul">
398 <li>'.__('Remote Backup to 8 location','loginizer').'</li>
399 <li>'.__('Auto Backups', 'loginizer').'</li>
400 <li>'.__('Backup Rotation', 'loginizer').'</li>
401 <li>'.__('One-Click Restore', 'loginizer').'</li>
402 <li>'.__('Stress-free Migration', 'loginizer').'</li>
403 <li>'.__('Backup to Google Drive', 'loginizer').'</li>
404 <li>'.__('Backup to Amazon S3', 'loginizer').'</li>
405 <li>'.__('Backup to Dropbox', 'loginizer').'</li>
406 <li>'.__('Backup to FTP,FTPS and many more ...','loginizer').'</li>
407 </ul>
408 <center><a class="button button-primary" target="_blank" href="https://wordpress.org/plugins/backuply/">'.__('Visit Backuply','loginizer').'</a></center>
409 </div>
410 </div>';
411
412 echo '
413 <div class="postbox" style="min-width:0px !important;">
414 <div class="postbox-header">
415 <h2 class="hndle ui-sortable-handle">
416 <span><a target="_blank" href="https://pagelayer.com/?from=loginizer-plugin"><img src="'.LOGINIZER_URL.'/assets/images/pagelayer_product.png" width="100%" /></a></span>
417 </h2>
418 </div>
419 <div class="inside">
420 <i>'.__('Easily manage and make professional pages and content with our Pagelayer builder','loginizer').'</i>:<br>
421 <ul class="lz-right-ul">
422 <li>'.__('30+ Free Widgets','loginizer').'</li>
423 <li>'.__('60+ Premium Widgets','loginizer').'</li>
424 <li>'.__('400+ Premium Sections','loginizer').'</li>
425 <li>'.__('Theme Builder','loginizer').'</li>
426 <li>'.__('WooCommerce Builder','loginizer').'</li>
427 <li>'.__('Theme Creator and Exporter','loginizer').'</li>
428 <li>'.__('Form Builder','loginizer').'</li>
429 <li>'.__('Popup Builder','loginizer').'</li>
430 <li>'.__('And many more ...','loginizer').'</li>
431 </ul>
432 <center><a class="button button-primary" target="_blank" href="https://wordpress.org/plugins/pagelayer/">'.__('Visit Pagelayer','loginizer').'</a></center>
433 </div>
434 </div>';
435
436 }
437
438 echo '</td>
439 </tr>
440 </table>';
441
442 if(!defined('SITEPAD')){
443
444 echo '<br />
445 <div style="width:45%;background:#FFF;padding:15px; margin:auto">
446 <b>'.__('Let your friends know that you have secured your website :','loginizer').'</b>
447 <form method="get" action="https://twitter.com/intent/tweet" id="tweet" onsubmit="return dotweet(this);">
448 <textarea name="text" cols="45" row="3" style="resize:none;">'.__('I just secured my @WordPress site against #bruteforce using @loginizer','loginizer').'</textarea>
449 &nbsp; &nbsp; <input type="submit" value="Tweet!" class="button button-primary" onsubmit="return false;" id="twitter-btn" style="margin-top:20px;"/>
450 </form>
451
452 </div>
453 <br />
454
455 <script>
456 function dotweet(ele){
457 window.open(jQuery("#"+ele.id).attr("action")+"?"+jQuery("#"+ele.id).serialize(), "_blank", "scrollbars=no, menubar=no, height=400, width=500, resizable=yes, toolbar=no, status=no");
458 return false;
459 }
460 </script>
461
462 <hr />
463 <a href="http://loginizer.com" target="_blank">Loginizer</a> v'.LOGINIZER_VERSION.'. '.__('You can report any bugs ','loginizer').'<a href="http://wordpress.org/support/plugin/loginizer" target="_blank">'.__('here','loginizer').'</a>.';
464
465 }
466
467 echo '
468 </div>
469 </div>
470 </div>
471 </div>';
472
473 }
474
475 // The Loginizer Admin Options Page
476 function loginizer_page_header($title = 'Loginizer'){
477
478 global $loginizer;
479
480 ?>
481 <style>
482 .lz-right-ul{
483 padding-left: 10px !important;
484 }
485
486 .lz-right-ul li{
487 list-style: circle !important;
488 }
489 </style>
490 <?php
491
492 echo '<div style="margin: 10px 20px 0 2px;">
493 <div class="metabox-holder columns-2">
494 <div class="postbox-container">
495 <div id="top-sortables" class="meta-box-sortables ui-sortable">
496
497 <table cellpadding="2" cellspacing="1" width="100%" class="fixed" border="0">
498 <tr>
499 <td valign="top"><h3>'.$loginizer['prefix'].$title.'</h3></td>';
500
501 if(!defined('SITEPAD')){
502
503 echo '<td align="right"><a href="https://www.softaculous.com/clients?ca=affiliate" class="button button-primary" target="_blank">'. __('Refer and Earn', 'loginizer'). '</a> <a target="_blank" class="button button-primary" href="https://wordpress.org/support/view/plugin-reviews/loginizer">'.__('Review Loginizer', 'loginizer').'</a></td>
504 <td align="right" width="40"><a target="_blank" href="https://twitter.com/loginizer"><img src="'.LOGINIZER_URL.'/assets/images/twitter.png" /></a></td>
505 <td align="right" width="40"><a target="_blank" href="https://www.facebook.com/Loginizer-815504798591884"><img src="'.LOGINIZER_URL.'/assets/images/facebook.png" /></a></td>';
506
507 }
508
509 echo '
510 </tr>
511 </table>
512 <hr />
513
514 <!--Main Table-->
515 <table cellpadding="8" cellspacing="1" width="100%" class="fixed">
516 <tr>
517 <td valign="top">';
518
519 if(defined('LOGINIZER_PREMIUM') && !empty($loginizer['enable_csrf_protection']) && !loginizer_is_csrf_prot_mod_set()){
520
521 $lz_error['csrf_mod'] = esc_html__('You have enabled CSRF protection but the .htaccess file has not been updated', 'loginizer');
522
523 if(!empty($lz_error)){
524 lz_report_error($lz_error);echo '<br />';
525 }
526 }
527
528 }
529
530 // Shows the admin menu of Loginizer
531 function loginizer_admin_menu() {
532
533 global $wp_version, $loginizer;
534
535 if(!defined('SITEPAD')){
536
537 // Add the menu page
538 add_menu_page(__('Loginizer Dashboard', 'loginizer'), __('Loginizer Security', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_dashboard');
539
540 // Dashboard
541 add_submenu_page('loginizer', __('Loginizer Dashboard', 'loginizer'), __('Dashboard', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_dashboard');
542
543 }else{
544
545 // Add the menu page
546 add_menu_page(__('Security', 'loginizer'), __('Security', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_security_settings', 'dashicons-shield', 85);
547
548 // Rename Login
549 add_submenu_page('loginizer', __('Security Settings', 'loginizer'), __('Rename Login', 'loginizer'), 'activate_plugins', 'loginizer', 'loginizer_security_settings');
550
551 }
552
553 // Brute Force
554 add_submenu_page('loginizer', __('Brute Force Settings', 'loginizer'), __('Brute Force', 'loginizer'), 'activate_plugins', 'loginizer_brute_force', 'loginizer_brute_force_settings');
555
556 if(defined('LOGINIZER_PREMIUM')){
557 // WAF Security Firewall
558 $expiry_date = strtotime('2026-03-01');
559 $tag_new = time() < $expiry_date ? '<span style="display: inline-block; margin-left: 10px; padding: 0px 5px; color: #fff; background-color: #d63638; border-radius: 2px;">'.__('New', 'loginizer').'</span>' : '';
560
561 add_submenu_page('loginizer', __('Country Block', 'loginizer'), __('Country Block', 'loginizer').' '.$tag_new, 'activate_plugins', 'loginizer_firewall', 'loginizer_firewall_settings');
562 }
563
564 // PasswordLess
565 add_submenu_page('loginizer', __($loginizer['prefix'].'PasswordLess Settings', 'loginizer'), __('PasswordLess', 'loginizer'), 'activate_plugins', 'loginizer_passwordless', 'loginizer_passwordless_settings');
566
567 // Security Settings
568 if(!defined('SITEPAD')){
569
570 // Two Factor Auth
571 add_submenu_page('loginizer', __($loginizer['prefix'].' Two Factor Authentication', 'loginizer'), __('Two Factor Auth', 'loginizer'), 'activate_plugins', 'loginizer_2fa', 'loginizer_2fa_settings');
572
573 }
574
575 // reCaptcha
576 add_submenu_page('loginizer', $loginizer['prefix'].__('reCAPTCHA Settings', 'loginizer'), __('reCAPTCHA', 'loginizer'), 'activate_plugins', 'loginizer_recaptcha', 'loginizer_recaptcha_settings');
577
578 // Temporary Login
579 add_submenu_page('loginizer', $loginizer['prefix'].__('SSO', 'loginizer'), __('Single Sign On', 'loginizer'). ((time() < strtotime('30 November 2023')) ? ' <span style="color:yellow;">Update</span>' : ''), 'activate_plugins', 'loginizer_sso', 'loginizer_sso_settings');
580
581 // Social Login
582 $hook_name = add_submenu_page('loginizer', $loginizer['prefix']. __('Social Login', 'loginizer'), __('Social Login', 'loginizer') . (defined('LOGINIZER_PREMIUM') && (time() < strtotime('30 June 2025')) ? ' <span style="color:yellow;font-size:12px;">Updated</span>' : ''), 'activate_plugins', 'loginizer_social_login', 'loginizer_social_login_settings');
583
584 // Security Settings
585 if(!defined('SITEPAD')){
586
587 // Security Settings
588 add_submenu_page('loginizer', $loginizer['prefix'].__('Security Settings', 'loginizer'), __('Security Settings', 'loginizer'), 'activate_plugins', 'loginizer_security', 'loginizer_security_settings');
589
590 // File Checksums
591 add_submenu_page('loginizer', __('Loginizer File Checksums', 'loginizer'), __('File Checksums', 'loginizer'), 'activate_plugins', 'loginizer_checksums', 'loginizer_checksums_settings');
592
593 }
594
595 if(!defined('LOGINIZER_PREMIUM') && !empty($loginizer['ins_time']) && $loginizer['ins_time'] < (time() - (30*24*3600))){
596
597 // Go Pro link
598 add_submenu_page('loginizer', __('Loginizer Go Pro', 'loginizer'), __('Go Pro', 'loginizer'), 'activate_plugins', LOGINIZER_PRO_URL);
599
600 }
601
602 // NOTE: This hook is just for Social Login for now,
603 // will need to change if we make different CSS files for every Menu page
604 // INFO:: Using this action helps is loading the CSS beforehand preventing any layout change on load.
605 add_action('load-'.$hook_name, 'loginizer_load_admin_assets');
606
607 }
608
609 // Loads assets like CSS and JS for admin Pages.
610 function loginizer_load_admin_assets(){
611 wp_enqueue_style('loginizer_social_style', LOGINIZER_URL . '/assets/css/social-admin.css', [], LOGINIZER_VERSION);
612 wp_enqueue_script('loginizer_social_script', LOGINIZER_URL . '/assets/js/social-admin.js', ['jquery', 'jquery-ui-sortable'], LOGINIZER_VERSION, true);
613 }
614
615 // Show the promo
616 function loginizer_promo(){
617
618 echo '
619 <style>
620 .wp-core-ui .lz_button1 {
621 background-color: #4CAF50;
622 border-color: transparent;
623 border-radius: 2px;
624 color: #fff;
625 }
626
627 .wp-core-ui .lz_button1:hover {
628 background-color:#3b963f;
629 border-color: transparent;
630 border-radius: 2px;
631 color: #fff;
632 }
633
634 .wp-core-ui .lz_button2 {
635 background-color: #0085ba;
636 border-color: transparent;
637 border-radius: 2px;
638 color: #fff;
639 }
640
641 .wp-core-ui .lz_button2:hover {
642 background-color: #0175a3;
643 border-color: transparent;
644 border-radius: 2px;
645 color: #fff;
646 }
647
648 .wp-core-ui .lz_button3 {
649 background-color: #365899;
650 border-color: transparent;
651 border-radius: 2px;
652 color: #fff;
653 }
654
655 .wp-core-ui .lz_button3:hover {
656 border-color: transparent;
657 background-color: #274785;
658 color:#fff;
659 }
660
661 .wp-core-ui .lz_button4 {
662 background-color: #14171A;
663 border-color: transparent;
664 border-radius: 2px;
665 color: #fff;
666 }
667
668 .wp-core-ui .lz_button4:hover {
669 background-color: #24292E;
670 color: #fff;
671 border-color: transparent;
672 }
673
674 .loginizer_promo-close{
675 float:right;
676 text-decoration:none;
677 margin: 5px 10px 0px 0px;
678 }
679
680 .loginizer_promo-close:hover{
681 color: red;
682 }
683 </style>
684
685 <script>
686 jQuery(document).ready( function() {
687 (function($) {
688 $("#loginizer_promo .loginizer_promo-close").click(function(){
689 var data;
690
691 // Hide it
692 $("#loginizer_promo").hide();
693
694 // Save this preference
695 $.post("'.admin_url('?loginizer_promo=0').'", data, function(response) {
696 //alert(response);
697 });
698 });
699 })(jQuery);
700 });
701 </script>
702
703 <div class="notice notice-success" id="loginizer_promo" style="min-height:120px">
704 <a class="loginizer_promo-close" href="javascript:" aria-label="Dismiss this Notice">
705 <span class="dashicons dashicons-dismiss"></span> Dismiss
706 </a>
707 <img src="'.LOGINIZER_URL.'/assets/images/loginizer-200.png" style="float:left; margin:10px 20px 10px 10px" width="100" />
708 <p style="font-size:16px">We are glad you like Loginizer and have been using it since the past few days. It is time to take the next step </p>
709 <p>
710 <a class="button lz_button1" target="_blank" href="https://loginizer.com/features">'.esc_html__('Upgrade to Pro', 'loginizer').'</a>
711 <a class="button lz_button2" target="_blank" href="https://wordpress.org/support/view/plugin-reviews/loginizer">Rate it 5�
712 \'s</a>
713 <a class="button lz_button3" target="_blank" href="https://www.facebook.com/Loginizer-815504798591884/">'.esc_html__('Like Us on Facebook', 'loginizer').'</a>
714 <a class="button lz_button4" target="_blank" href="https://x.com/intent/tweet?text='.rawurlencode('I use @loginizer to secure my #WordPress site - https://loginizer.com').'">'.esc_html__('Post on X about Loginizer', 'loginizer').'</a>
715 </p>
716 </div>';
717
718 }
719
720
721 function loginizer_recaptcha_settings(){
722 include_once LOGINIZER_DIR . '/main/settings/recaptcha.php';
723 loginizer_page_recaptcha();
724 }
725
726 function loginizer_2fa_settings(){
727 include_once LOGINIZER_DIR . '/main/settings/2fa.php';
728 loginizer_page_2fa();
729 }
730
731 function loginizer_passwordless_settings(){
732 include_once LOGINIZER_DIR . '/main/settings/passwordless.php';
733 loginizer_page_passwordless();
734 }
735
736 function loginizer_security_settings(){
737 include_once LOGINIZER_DIR . '/main/settings/security.php';
738 loginizer_page_security();
739 }
740
741 function loginizer_brute_force_settings(){
742 include_once LOGINIZER_DIR . '/main/settings/brute-force.php';
743 loginizer_page_brute_force();
744 }
745
746 function loginizer_checksums_settings(){
747 include_once LOGINIZER_DIR . '/main/settings/checksum.php';
748 loginizer_page_checksums();
749 }
750
751 function loginizer_dashboard(){
752 include_once LOGINIZER_DIR . '/main/settings/dashboard.php';
753 loginizer_page_dashboard();
754 }
755
756 function loginizer_sso_settings(){
757 include_once LOGINIZER_DIR . '/main/settings/sso.php';
758
759 loginizer_sso();
760 }
761
762 function loginizer_social_login_settings(){
763 include_once LOGINIZER_DIR . '/main/settings/social_login.php';
764
765 loginizer_social_login();
766 }
767
768 function loginizer_firewall_settings(){
769 include_once LOGINIZER_PRO_DIR . 'main/settings/waf.php';
770 loginizer_pro_firewall();
771 }
772
773 // Hides the interim login poup after successful login.
774 function loginizer_social_interim_js(){
775
776 if(isset($_GET['interim_login']) && $_GET['interim_login'] === 'lz' && is_user_logged_in()){
777 echo '<script>
778 document.addEventListener("DOMContentLoaded", () => {
779 parent.document.querySelector("#wp-auth-check-wrap")?.classList.add("hidden");
780 });
781 </script>';
782 }
783 }
784
785 // Show alert when the login url gets changes from when the Loginizer social settings were setup.
786 function loginizer_social_login_url_alert(){
787
788 // We want to show this error to user which has sufficient privilage
789 if(!current_user_can('activate_plugins')){
790 return;
791 }
792
793 $set_login_url = get_option('loginizer_social_login_url', '');
794 if(empty($set_login_url) || $set_login_url === wp_login_url()){
795 return;
796 }
797
798 $provider_settings = get_option('loginizer_provider_settings', []);
799
800 // If we dont have any settings then it dosent matter what URL is set.
801 // As it will be updated once user saves the settings.
802 if(empty($provider_settings)){
803 return;
804 }
805
806 $has_enabled = false;
807 $has_non_login_auth = false;
808 foreach($provider_settings as $provider){
809 if(empty($provider['loginizer_social_key']) && !empty($provider['enabled'])){
810 $has_non_login_auth = true;
811 }
812
813 if(!empty($provider['enabled'])){
814 $has_enabled = true;
815 }
816 }
817
818 // We will only show this error if the user is using key based config
819 if(empty($has_non_login_auth)){
820 return;
821 }
822
823 // If we have no Provider enabled then just show the warning on the social login page.
824 if(empty($has_enabled) && (empty($_GET['page']) || $_GET['page'] !== 'loginizer_social_login')){
825 return;
826 }
827
828 echo '<div class="notice notice-error">
829 <h4>'.esc_html__('You changed login slug!', 'loginizer').'</h4>
830 <p>'.esc_html__('You changed the login slug and have some social login apps enabled. These social login apps use the login URL as the redirect URI. This means that since the login URL has changed, the social login will now break.', 'loginizer').'</p>
831
832 <h4>'.esc_html__('How to fix:', 'loginizer').'</h4>
833 <p>'.esc_html__('When you created secret keys for the social apps, you also provided a Redirect URI. To fix this issue, you need to update that Redirect URI.', 'loginizer').'<br/>
834 You just need to update the <code>/wp-login.php</code> to the new slug you have.</p>
835 <p><button class="button button-primary" id="loginizer-social-login-alert">'.esc_html__('I have fixed this issue', 'loginizer').'</button></p>
836 </div>';
837
838
839 wp_register_script('loginizer_social_alert', '', ['jquery'], LOGINIZER_VERSION, true);
840 wp_enqueue_script('loginizer_social_alert');
841 wp_add_inline_script('loginizer_social_alert', '
842 jQuery("#loginizer-social-login-alert").on("click", function(){
843 jQuery(this).closest(".notice").slideToggle();
844
845 var data = new Object();
846 data["action"] = "loginizer_dismiss_social_alert";
847 data["nonce"] = "'.wp_create_nonce('loginizer_admin_ajax').'";
848
849 var admin_url = "'.admin_url().'"+"admin-ajax.php";
850 jQuery.post(admin_url, data, function(response){
851 });
852 });');
853 }
854
855 function loginizer_softwp_upgrader_notice(){
856
857 // We want to show this error to user which has sufficient privilage
858 if(!current_user_can('activate_plugins')){
859 return;
860 }
861
862 /*$notice_end_time = strtotime('31 March 2025');
863 if(!empty($notice_end_time) && time() > $notice_end_time){
864 return;
865 }*/
866
867 $softwp_upgrade = get_option('loginizer_softwp_upgrade', 0);
868
869 if(empty($softwp_upgrade) || $softwp_upgrade < 0){
870 return;
871 }
872
873 if(empty($_GET['page']) || !preg_match('/loginizer/is', $_GET['page'])){
874 return;
875 }
876
877 echo '<style>.loginizer_promo-close{float:right;text-decoration:none;margin: 5px 10px 0px 0px;}.loginizer_promo-close:hover{color: red;}</style>
878 <div class="notice notice-warning" id="loginizer_softwp_notice">
879 <a class="loginizer_promo-close" id="loginizer-softwp-promo-close" href="javascript:" aria-label="Dismiss Forever">
880 <span class="dashicons dashicons-dismiss"></span> '.esc_html__('Dismiss Forever', 'loginizer').'
881 </a>
882 <p>' . esc_html__('Hey, you might be eligible to access Premium plugins provided by Softaculous for Free ! Please refer to these documents for details on how to avail them.', 'loginizer').'
883 <a href="https://softwp.net/docs/admin/generate-softwp-license" target="_blank">' . esc_html__('Generate SoftWP License', 'loginizer') . '</a> | <a href="https://softwp.net/docs/admin/installing-plugins" target="_blank">' . esc_html__('How to Install the Pro plugins', 'loginizer') . '</a></p>
884 </div>';
885
886 wp_register_script('loginizer_softwp_alert', '', ['jquery'], LOGINIZER_VERSION, true);
887 wp_enqueue_script('loginizer_softwp_alert');
888 wp_add_inline_script('loginizer_softwp_alert', '
889 jQuery("#loginizer-softwp-promo-close").on("click", function(){
890 jQuery(this).closest("#loginizer_softwp_notice").slideToggle();
891
892 var data = new Object();
893 data["action"] = "loginizer_dismiss_softwp_alert";
894 data["security"] = "'.wp_create_nonce('loginizer_softwp_notice').'";
895
896 var admin_url = "'.admin_url().'"+"admin-ajax.php";
897 jQuery.post(admin_url, data, function(response){
898 });
899 });');
900 }
901
902 function loginizer_check_expires(){
903 global $loginizer;
904
905 // We do not want to show the expiry notice if the license is by SoftWP.
906 if(!empty($loginizer['license']) && !empty($loginizer['license']['has_plid'])){
907 return;
908 }
909
910 $current_timestamp = time();
911 $expiration_timestamp = strtotime($loginizer['license']['expires']);
912 $time_diff = $expiration_timestamp - $current_timestamp;
913
914 // Renew link
915 $loginizer_user_license = $loginizer['license']['license'];
916 $loginizer_user_plan = $loginizer['license']['plan'];
917 $loginizer_renew_url = 'https://www.softaculous.com/clients?ca=loginizer_buy&plan=' . $loginizer_user_plan . '&license=' . $loginizer_user_license;
918
919 if($time_diff > 0 && $time_diff <= WEEK_IN_SECONDS){
920 $human_time = human_time_diff($current_timestamp, $expiration_timestamp);
921
922 echo '<style>.loginizer_promo-close{float:right;text-decoration:none;margin: 5px 10px 0px 0px;}.loginizer_promo-close:hover{color: red;}</style>
923 <div class="notice notice-error" id="loginizer_license_notice">
924 <a class="loginizer_promo-close" id="loginizer-license-promo-close" href="javascript:" aria-label="Dismiss this Notice">
925 <span class="dashicons dashicons-dismiss"></span> '.esc_html__('Dismiss for 60 days', 'loginizer').'
926 </a>
927 <p>' . sprintf(esc_html__('Alert : Your Loginizer Premium license will expire in %s. Renew to keep getting updates!', 'loginizer'), esc_html($human_time)).'
928 <a href="' . esc_url($loginizer_renew_url) . '" target="_blank">' . esc_html__('Click here to renew', 'loginizer') . '</a>
929 </p>
930 </div>';
931
932 } else if($time_diff <= 0){
933 echo '<style>.loginizer_promo-close{float:right;text-decoration:none;margin: 5px 10px 0px 0px;}.loginizer_promo-close:hover{color: red;}</style>
934 <div class="notice notice-error" id="loginizer_license_notice">
935 <a class="loginizer_promo-close" id="loginizer-license-promo-close" href="javascript:" aria-label="Dismiss this Notice">
936 <span class="dashicons dashicons-dismiss"></span> '.esc_html__('Dismiss for 60 days', 'loginizer').'
937 </a>
938 <p>' . esc_html__('Alert: Your Loginizer Premium license has expired. Please renew immediately to keep getting updates ', 'loginizer').'
939 <a href="' . esc_url($loginizer_renew_url) . '" target="_blank">' . esc_html__('Click here to renew', 'loginizer') . '</a></p>
940 </div>';
941 }
942
943 wp_register_script('loginizer_license_alert', '', ['jquery'], LOGINIZER_VERSION, true);
944 wp_enqueue_script('loginizer_license_alert');
945 wp_add_inline_script('loginizer_license_alert', '
946 jQuery("#loginizer-license-promo-close").on("click", function(){
947 jQuery(this).closest("#loginizer_license_notice").slideToggle();
948
949 var data = new Object();
950 data["action"] = "loginizer_dismiss_license_alert";
951 data["security"] = "'.wp_create_nonce('loginizer_license_notice').'";
952
953 var admin_url = "'.admin_url().'"+"admin-ajax.php";
954 jQuery.post(admin_url, data, function(response){
955 });
956 });');
957 }
958
959 function loginizer_update_notice_filter($plugins = []){
960 $plugins['loginizer/loginizer.php'] = 'Loginizer';
961
962 return $plugins;
963 }
964
965 function loginizer_plugin_update_notice(){
966 if(defined('SOFTACULOUS_PLUGIN_UPDATE_NOTICE')){
967 return;
968 }
969
970 $to_update_plugins = apply_filters('softaculous_plugin_update_notice', []);
971
972 if(empty($to_update_plugins)){
973 return;
974 }
975
976 /* translators: %1$s is replaced with a "string" of name of plugins, and %2$s is replaced with "string" which can be "is" or "are" based on the count of the plugin */
977 $msg = sprintf(__('New versions of %1$s %2$s available. Updating ensures better performance, security, and access to the latest features.', 'loginizer'), '<b>'.esc_html(implode(', ', $to_update_plugins)).'</b>', (count($to_update_plugins) > 1 ? 'are' : 'is')) . ' <a class="button button-primary" href='.esc_url(admin_url('plugins.php?plugin_status=upgrade')).'>Update Now</a>';
978
979 define('SOFTACULOUS_PLUGIN_UPDATE_NOTICE', true); // To make sure other plugins don't return a Notice
980 echo '<div class="notice notice-info is-dismissible" id="loginizer-plugin-update-notice">
981 <p>'.$msg. '</p>
982 </div>';
983
984 wp_register_script('loginizer-update-notice', '', ['jquery'], '', true);
985 wp_enqueue_script('loginizer-update-notice');
986 wp_add_inline_script('loginizer-update-notice', 'jQuery("#loginizer-plugin-update-notice").on("click", function(e){
987 let target = jQuery(e.target);
988
989 if(!target.hasClass("notice-dismiss")){
990 return;
991 }
992
993 var data;
994
995 // Hide it
996 jQuery("#loginizer-plugin-update-notice").hide();
997
998 // Save this preference
999 jQuery.post("'.admin_url('admin-ajax.php?action=loginizer_close_update_notice').'&security='.wp_create_nonce('loginizer_promo_nonce').'", data, function(response) {
1000 //alert(response);
1001 });
1002 });');
1003 }
1004
1005 loginizer_admin_hooks();
1006