PluginProbe
Loginizer / 1.9.5
Loginizer v1.9.5
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 1.9.5, at main/admin.php

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