PluginProbe
Loginizer / 2.0.8
Loginizer v2.0.8
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.0.8, at main/admin.php

1,014 lines 37.3 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 .lz_button {
621 background-color: #4CAF50; /* Green */
622 border: none;
623 color: white;
624 padding: 8px 16px;
625 text-align: center;
626 text-decoration: none;
627 display: inline-block;
628 font-size: 16px;
629 margin: 4px 2px;
630 -webkit-transition-duration: 0.4s; /* Safari */
631 transition-duration: 0.4s;
632 cursor: pointer;
633 }
634
635 .lz_button:focus{
636 border: none;
637 color: white;
638 }
639
640 .lz_button1 {
641 color: white;
642 background-color: #4CAF50;
643 border:3px solid #4CAF50;
644 }
645
646 .lz_button1:hover {
647 box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
648 color: white;
649 border:3px solid #4CAF50;
650 }
651
652 .lz_button2 {
653 color: white;
654 background-color: #0085ba;
655 }
656
657 .lz_button2:hover {
658 box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
659 color: white;
660 }
661
662 .lz_button3 {
663 color: white;
664 background-color: #365899;
665 }
666
667 .lz_button3:hover {
668 box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
669 color: white;
670 }
671
672 .lz_button4 {
673 color: white;
674 background-color: rgb(66, 184, 221);
675 }
676
677 .lz_button4:hover {
678 box-shadow: 0 6px 8px 0 rgba(0,0,0,0.24), 0 9px 25px 0 rgba(0,0,0,0.19);
679 color: white;
680 }
681
682 .loginizer_promo-close{
683 float:right;
684 text-decoration:none;
685 margin: 5px 10px 0px 0px;
686 }
687
688 .loginizer_promo-close:hover{
689 color: red;
690 }
691 </style>
692
693 <script>
694 jQuery(document).ready( function() {
695 (function($) {
696 $("#loginizer_promo .loginizer_promo-close").click(function(){
697 var data;
698
699 // Hide it
700 $("#loginizer_promo").hide();
701
702 // Save this preference
703 $.post("'.admin_url('?loginizer_promo=0').'", data, function(response) {
704 //alert(response);
705 });
706 });
707 })(jQuery);
708 });
709 </script>
710
711 <div class="notice notice-success" id="loginizer_promo" style="min-height:120px">
712 <a class="loginizer_promo-close" href="javascript:" aria-label="Dismiss this Notice">
713 <span class="dashicons dashicons-dismiss"></span> Dismiss
714 </a>
715 <img src="'.LOGINIZER_URL.'/assets/images/loginizer-200.png" style="float:left; margin:10px 20px 10px 10px" width="100" />
716 <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>
717 <p>
718 <a class="lz_button lz_button1" target="_blank" href="https://loginizer.com/features">Upgrade to Pro</a>
719 <a class="lz_button lz_button2" target="_blank" href="https://wordpress.org/support/view/plugin-reviews/loginizer">Rate it 5�
720 \'s</a>
721 <a class="lz_button lz_button3" target="_blank" href="https://www.facebook.com/Loginizer-815504798591884/">Like Us on Facebook</a>
722 <a class="lz_button lz_button4" target="_blank" href="https://twitter.com/home?status='.rawurlencode('I use @loginizer to secure my #WordPress site - https://loginizer.com').'">Tweet about Loginizer</a>
723 </p>
724 </div>';
725
726 }
727
728
729 function loginizer_recaptcha_settings(){
730 include_once LOGINIZER_DIR . '/main/settings/recaptcha.php';
731 loginizer_page_recaptcha();
732 }
733
734 function loginizer_2fa_settings(){
735 include_once LOGINIZER_DIR . '/main/settings/2fa.php';
736 loginizer_page_2fa();
737 }
738
739 function loginizer_passwordless_settings(){
740 include_once LOGINIZER_DIR . '/main/settings/passwordless.php';
741 loginizer_page_passwordless();
742 }
743
744 function loginizer_security_settings(){
745 include_once LOGINIZER_DIR . '/main/settings/security.php';
746 loginizer_page_security();
747 }
748
749 function loginizer_brute_force_settings(){
750 include_once LOGINIZER_DIR . '/main/settings/brute-force.php';
751 loginizer_page_brute_force();
752 }
753
754 function loginizer_checksums_settings(){
755 include_once LOGINIZER_DIR . '/main/settings/checksum.php';
756 loginizer_page_checksums();
757 }
758
759 function loginizer_dashboard(){
760 include_once LOGINIZER_DIR . '/main/settings/dashboard.php';
761 loginizer_page_dashboard();
762 }
763
764 function loginizer_sso_settings(){
765 include_once LOGINIZER_DIR . '/main/settings/sso.php';
766
767 loginizer_sso();
768 }
769
770 function loginizer_social_login_settings(){
771 include_once LOGINIZER_DIR . '/main/settings/social_login.php';
772
773 loginizer_social_login();
774 }
775
776 function loginizer_firewall_settings(){
777 include_once LOGINIZER_PRO_DIR . 'main/settings/waf.php';
778 loginizer_pro_firewall();
779 }
780
781 // Hides the interim login poup after successful login.
782 function loginizer_social_interim_js(){
783
784 if(isset($_GET['interim_login']) && $_GET['interim_login'] === 'lz' && is_user_logged_in()){
785 echo '<script>
786 document.addEventListener("DOMContentLoaded", () => {
787 parent.document.querySelector("#wp-auth-check-wrap")?.classList.add("hidden");
788 });
789 </script>';
790 }
791 }
792
793 // Show alert when the login url gets changes from when the Loginizer social settings were setup.
794 function loginizer_social_login_url_alert(){
795
796 // We want to show this error to user which has sufficient privilage
797 if(!current_user_can('activate_plugins')){
798 return;
799 }
800
801 $set_login_url = get_option('loginizer_social_login_url', '');
802 if(empty($set_login_url) || $set_login_url === wp_login_url()){
803 return;
804 }
805
806 $provider_settings = get_option('loginizer_provider_settings', []);
807
808 // If we dont have any settings then it dosent matter what URL is set.
809 // As it will be updated once user saves the settings.
810 if(empty($provider_settings)){
811 return;
812 }
813
814 $has_enabled = false;
815 $has_non_login_auth = false;
816 foreach($provider_settings as $provider){
817 if(empty($provider['loginizer_social_key']) && !empty($provider['enabled'])){
818 $has_non_login_auth = true;
819 }
820
821 if(!empty($provider['enabled'])){
822 $has_enabled = true;
823 }
824 }
825
826 // We will only show this error if the user is using key based config
827 if(empty($has_non_login_auth)){
828 return;
829 }
830
831 // If we have no Provider enabled then just show the warning on the social login page.
832 if(empty($has_enabled) && (empty($_GET['page']) || $_GET['page'] !== 'loginizer_social_login')){
833 return;
834 }
835
836 echo '<div class="notice notice-error">
837 <h4>'.esc_html__('You changed login slug!', 'loginizer').'</h4>
838 <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>
839
840 <h4>'.esc_html__('How to fix:', 'loginizer').'</h4>
841 <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/>
842 You just need to update the <code>/wp-login.php</code> to the new slug you have.</p>
843 <p><button class="button button-primary" id="loginizer-social-login-alert">'.esc_html__('I have fixed this issue', 'loginizer').'</button></p>
844 </div>';
845
846
847 wp_register_script('loginizer_social_alert', '', ['jquery'], LOGINIZER_VERSION, true);
848 wp_enqueue_script('loginizer_social_alert');
849 wp_add_inline_script('loginizer_social_alert', '
850 jQuery("#loginizer-social-login-alert").on("click", function(){
851 jQuery(this).closest(".notice").slideToggle();
852
853 var data = new Object();
854 data["action"] = "loginizer_dismiss_social_alert";
855 data["nonce"] = "'.wp_create_nonce('loginizer_admin_ajax').'";
856
857 var admin_url = "'.admin_url().'"+"admin-ajax.php";
858 jQuery.post(admin_url, data, function(response){
859 });
860 });');
861 }
862
863 function loginizer_softwp_upgrader_notice(){
864
865 // We want to show this error to user which has sufficient privilage
866 if(!current_user_can('activate_plugins')){
867 return;
868 }
869
870 /*$notice_end_time = strtotime('31 March 2025');
871 if(!empty($notice_end_time) && time() > $notice_end_time){
872 return;
873 }*/
874
875 $softwp_upgrade = get_option('loginizer_softwp_upgrade', 0);
876
877 if(empty($softwp_upgrade) || $softwp_upgrade < 0){
878 return;
879 }
880
881 if(empty($_GET['page']) || !preg_match('/loginizer/is', $_GET['page'])){
882 return;
883 }
884
885 echo '<style>.loginizer_promo-close{float:right;text-decoration:none;margin: 5px 10px 0px 0px;}.loginizer_promo-close:hover{color: red;}</style>
886 <div class="notice notice-warning" id="loginizer_softwp_notice">
887 <a class="loginizer_promo-close" id="loginizer-softwp-promo-close" href="javascript:" aria-label="Dismiss Forever">
888 <span class="dashicons dashicons-dismiss"></span> '.esc_html__('Dismiss Forever', 'loginizer').'
889 </a>
890 <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').'
891 <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>
892 </div>';
893
894 wp_register_script('loginizer_softwp_alert', '', ['jquery'], LOGINIZER_VERSION, true);
895 wp_enqueue_script('loginizer_softwp_alert');
896 wp_add_inline_script('loginizer_softwp_alert', '
897 jQuery("#loginizer-softwp-promo-close").on("click", function(){
898 jQuery(this).closest("#loginizer_softwp_notice").slideToggle();
899
900 var data = new Object();
901 data["action"] = "loginizer_dismiss_softwp_alert";
902 data["security"] = "'.wp_create_nonce('loginizer_softwp_notice').'";
903
904 var admin_url = "'.admin_url().'"+"admin-ajax.php";
905 jQuery.post(admin_url, data, function(response){
906 });
907 });');
908 }
909
910 function loginizer_check_expires(){
911 global $loginizer;
912
913 // We do not want to show the expiry notice if the license is by SoftWP.
914 if(!empty($loginizer['license']) && !empty($loginizer['license']['has_plid'])){
915 return;
916 }
917
918 $current_timestamp = time();
919 $expiration_timestamp = strtotime($loginizer['license']['expires']);
920 $time_diff = $expiration_timestamp - $current_timestamp;
921
922 // Renew link
923 $loginizer_user_license = $loginizer['license']['license'];
924 $loginizer_user_plan = $loginizer['license']['plan'];
925 $loginizer_renew_url = 'https://www.softaculous.com/clients?ca=loginizer_buy&plan=' . $loginizer_user_plan . '&license=' . $loginizer_user_license;
926
927 if($time_diff > 0 && $time_diff <= WEEK_IN_SECONDS){
928 $human_time = human_time_diff($current_timestamp, $expiration_timestamp);
929
930 echo '<style>.loginizer_promo-close{float:right;text-decoration:none;margin: 5px 10px 0px 0px;}.loginizer_promo-close:hover{color: red;}</style>
931 <div class="notice notice-error" id="loginizer_license_notice">
932 <a class="loginizer_promo-close" id="loginizer-license-promo-close" href="javascript:" aria-label="Dismiss this Notice">
933 <span class="dashicons dashicons-dismiss"></span> '.esc_html__('Dismiss for 60 days', 'loginizer').'
934 </a>
935 <p>' . sprintf(esc_html__('Alert : Your Loginizer Premium license will expire in %s. Renew to keep getting updates!', 'loginizer'), esc_html($human_time)).'
936 <a href="' . esc_url($loginizer_renew_url) . '" target="_blank">' . esc_html__('Click here to renew', 'loginizer') . '</a>
937 </p>
938 </div>';
939
940 } else if($time_diff <= 0){
941 echo '<style>.loginizer_promo-close{float:right;text-decoration:none;margin: 5px 10px 0px 0px;}.loginizer_promo-close:hover{color: red;}</style>
942 <div class="notice notice-error" id="loginizer_license_notice">
943 <a class="loginizer_promo-close" id="loginizer-license-promo-close" href="javascript:" aria-label="Dismiss this Notice">
944 <span class="dashicons dashicons-dismiss"></span> '.esc_html__('Dismiss for 60 days', 'loginizer').'
945 </a>
946 <p>' . esc_html__('Alert: Your Loginizer Premium license has expired. Please renew immediately to keep getting updates ', 'loginizer').'
947 <a href="' . esc_url($loginizer_renew_url) . '" target="_blank">' . esc_html__('Click here to renew', 'loginizer') . '</a></p>
948 </div>';
949 }
950
951 wp_register_script('loginizer_license_alert', '', ['jquery'], LOGINIZER_VERSION, true);
952 wp_enqueue_script('loginizer_license_alert');
953 wp_add_inline_script('loginizer_license_alert', '
954 jQuery("#loginizer-license-promo-close").on("click", function(){
955 jQuery(this).closest("#loginizer_license_notice").slideToggle();
956
957 var data = new Object();
958 data["action"] = "loginizer_dismiss_license_alert";
959 data["security"] = "'.wp_create_nonce('loginizer_license_notice').'";
960
961 var admin_url = "'.admin_url().'"+"admin-ajax.php";
962 jQuery.post(admin_url, data, function(response){
963 });
964 });');
965 }
966
967 function loginizer_update_notice_filter($plugins = []){
968 $plugins['loginizer/loginizer.php'] = 'Loginizer';
969
970 return $plugins;
971 }
972
973 function loginizer_plugin_update_notice(){
974 if(defined('SOFTACULOUS_PLUGIN_UPDATE_NOTICE')){
975 return;
976 }
977
978 $to_update_plugins = apply_filters('softaculous_plugin_update_notice', []);
979
980 if(empty($to_update_plugins)){
981 return;
982 }
983
984 /* 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 */
985 $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>';
986
987 define('SOFTACULOUS_PLUGIN_UPDATE_NOTICE', true); // To make sure other plugins don't return a Notice
988 echo '<div class="notice notice-info is-dismissible" id="loginizer-plugin-update-notice">
989 <p>'.$msg. '</p>
990 </div>';
991
992 wp_register_script('loginizer-update-notice', '', ['jquery'], '', true);
993 wp_enqueue_script('loginizer-update-notice');
994 wp_add_inline_script('loginizer-update-notice', 'jQuery("#loginizer-plugin-update-notice").on("click", function(e){
995 let target = jQuery(e.target);
996
997 if(!target.hasClass("notice-dismiss")){
998 return;
999 }
1000
1001 var data;
1002
1003 // Hide it
1004 jQuery("#loginizer-plugin-update-notice").hide();
1005
1006 // Save this preference
1007 jQuery.post("'.admin_url('admin-ajax.php?action=loginizer_close_update_notice').'&security='.wp_create_nonce('loginizer_promo_nonce').'", data, function(response) {
1008 //alert(response);
1009 });
1010 });');
1011 }
1012
1013 loginizer_admin_hooks();
1014