PluginProbe
Loginizer / 1.9.2
Loginizer v1.9.2
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.2, at main/admin.php

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