| 1 |
<?php |
| 2 |
|
| 3 |
if(!defined('ABSPATH')){ |
| 4 |
die('Hacking Attempt!'); |
| 5 |
} |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
// Loginizer - Checksum load data |
| 10 |
function loginizer_page_checksums_L(&$files, &$_ignores){ |
| 11 |
|
| 12 |
global $loginizer, $lz_error, $lz_env; |
| 13 |
|
| 14 |
// Load any mismatched files and ignores |
| 15 |
$files = get_option('loginizer_checksums_diff'); |
| 16 |
$_ignores = get_option('loginizer_checksums_ignore'); |
| 17 |
$_ignores = is_array($_ignores) ? $_ignores : array(); // SHOULD ALWAYS BE PURE |
| 18 |
$ignores = array(); |
| 19 |
|
| 20 |
foreach($_ignores as $ik => $iv){ |
| 21 |
$ignores[$iv] = array(); |
| 22 |
if(!empty($files[$iv])){ |
| 23 |
$ignores[$iv] = $files[$iv]; |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
$lz_env['files'] = $files; |
| 28 |
$lz_env['ignores'] = $ignores; |
| 29 |
|
| 30 |
} |
| 31 |
|
| 32 |
// Loginizer - PasswordLess Page |
| 33 |
function loginizer_page_checksums(){ |
| 34 |
|
| 35 |
global $loginizer, $lz_error, $lz_env; |
| 36 |
|
| 37 |
if(!current_user_can('manage_options')){ |
| 38 |
wp_die('Sorry, but you do not have permissions to change settings.'); |
| 39 |
} |
| 40 |
|
| 41 |
if(!loginizer_is_premium() && count($_POST) > 0){ |
| 42 |
$lz_error['not_in_free'] = __('This feature is not available in the Free version. <a href="'.LOGINIZER_PRICING_URL.'" target="_blank" style="text-decoration:none; color:green;"><b>Upgrade to Pro</b></a>', 'loginizer'); |
| 43 |
return loginizer_page_checksums_T(); |
| 44 |
} |
| 45 |
|
| 46 |
/* Make sure post was from this page */ |
| 47 |
if(count($_POST) > 0){ |
| 48 |
check_admin_referer('loginizer-options'); |
| 49 |
} |
| 50 |
|
| 51 |
// Are we to run it ? |
| 52 |
if(isset($_REQUEST['lz_run_checksum'])){ |
| 53 |
loginizer_checksums(); |
| 54 |
} |
| 55 |
|
| 56 |
loginizer_page_checksums_L($files, $_ignores); |
| 57 |
|
| 58 |
$lz_env['csum_freq'][1] = __('Once a Day', 'loginizer'); |
| 59 |
$lz_env['csum_freq'][7] = __('Once a Week', 'loginizer'); |
| 60 |
$lz_env['csum_freq'][30] = __('Once a Month', 'loginizer'); |
| 61 |
|
| 62 |
if(isset($_POST['save_lz'])){ |
| 63 |
|
| 64 |
// In the future there can be more settings |
| 65 |
$option['disable_checksum'] = (int) lz_optpost('disable_checksum'); |
| 66 |
$option['no_checksum_email'] = (int) lz_optpost('no_checksum_email'); |
| 67 |
$option['checksum_frequency'] = (int) lz_optpost('checksum_frequency'); |
| 68 |
$option['checksum_time'] = lz_optpost('checksum_time'); |
| 69 |
|
| 70 |
// Is there an error ? |
| 71 |
if(!empty($lz_error)){ |
| 72 |
return loginizer_page_checksums_T(); |
| 73 |
} |
| 74 |
|
| 75 |
// Save the options |
| 76 |
update_option('loginizer_checksums', $option); |
| 77 |
|
| 78 |
// Mark as saved |
| 79 |
$GLOBALS['lz_saved'] = true; |
| 80 |
|
| 81 |
} |
| 82 |
|
| 83 |
// Add or remove from ignore list |
| 84 |
if(isset($_POST['save_lz_csum_ig'])){ |
| 85 |
|
| 86 |
if(@is_array($_POST['checksum_del_ignore'])){ |
| 87 |
|
| 88 |
foreach($_POST['checksum_del_ignore'] as $k => $v){ |
| 89 |
$key = array_search($v, $_ignores); |
| 90 |
if($key !== false){ |
| 91 |
unset($_ignores[$key]); |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
// Save it |
| 96 |
update_option('loginizer_checksums_ignore', $_ignores); |
| 97 |
|
| 98 |
} |
| 99 |
|
| 100 |
if(@is_array($_POST['checksum_add_ignore'])){ |
| 101 |
|
| 102 |
foreach($_POST['checksum_add_ignore'] as $k => $v){ |
| 103 |
if(!empty($files[$v])){ |
| 104 |
$_ignores[] = $v; |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
// Save it |
| 109 |
update_option('loginizer_checksums_ignore', $_ignores); |
| 110 |
|
| 111 |
} |
| 112 |
|
| 113 |
// Reload |
| 114 |
loginizer_page_checksums_L($files, $_ignores); |
| 115 |
|
| 116 |
// Mark as saved |
| 117 |
$GLOBALS['lz_saved'] = true; |
| 118 |
|
| 119 |
} |
| 120 |
|
| 121 |
// Call theme |
| 122 |
loginizer_page_checksums_T(); |
| 123 |
} |
| 124 |
|
| 125 |
// Loginizer - PasswordLess Page Theme |
| 126 |
function loginizer_page_checksums_T(){ |
| 127 |
|
| 128 |
global $loginizer, $lz_error, $lz_env; |
| 129 |
|
| 130 |
// Universal header |
| 131 |
loginizer_page_header('File Checksum Settings'); |
| 132 |
|
| 133 |
loginizer_feature_available('File Checksum'); |
| 134 |
|
| 135 |
if(defined('LOGINIZER_PRO_DIR_URL')){ |
| 136 |
wp_enqueue_script('jquery-clockpicker', LOGINIZER_PRO_DIR_URL.'/assets/js/jquery-clockpicker.min.js', array('jquery'), '0.0.7'); |
| 137 |
wp_enqueue_style('jquery-clockpicker', LOGINIZER_PRO_DIR_URL.'/assets/css/jquery-clockpicker.min.css', array(), '0.0.7'); |
| 138 |
} |
| 139 |
|
| 140 |
// Saved ? |
| 141 |
if(!empty($GLOBALS['lz_saved'])){ |
| 142 |
echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />'; |
| 143 |
} |
| 144 |
|
| 145 |
// Did we just run the checksums |
| 146 |
if(isset($_REQUEST['lz_run_checksum'])){ |
| 147 |
echo '<div id="message" class="updated"><p>'. __('The Checksum process was executed successfully', 'loginizer'). '</p></div><br />'; |
| 148 |
} |
| 149 |
|
| 150 |
// Any errors ? |
| 151 |
if(!empty($lz_error)){ |
| 152 |
lz_report_error($lz_error);echo '<br />'; |
| 153 |
} |
| 154 |
|
| 155 |
?> |
| 156 |
|
| 157 |
<style> |
| 158 |
input[type="text"], textarea, select { |
| 159 |
width: 70%; |
| 160 |
} |
| 161 |
|
| 162 |
.form-table label{ |
| 163 |
font-weight:bold; |
| 164 |
} |
| 165 |
|
| 166 |
.exp{ |
| 167 |
font-size:12px; |
| 168 |
} |
| 169 |
</style> |
| 170 |
|
| 171 |
<script> |
| 172 |
function lz_apply_status(ele, the_class){ |
| 173 |
|
| 174 |
var status = ele.checked; |
| 175 |
jQuery(the_class).each(function(){ |
| 176 |
this.checked = status; |
| 177 |
}); |
| 178 |
|
| 179 |
} |
| 180 |
</script> |
| 181 |
|
| 182 |
<div id="" class="postbox"> |
| 183 |
<div class="postbox-header"> |
| 184 |
<h2 class="hndle ui-sortable-handle"> |
| 185 |
<span><?php echo __('Checksum Settings', 'loginizer'); ?></span> |
| 186 |
</h2> |
| 187 |
</div> |
| 188 |
<div class="inside"> |
| 189 |
|
| 190 |
<form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1"> |
| 191 |
<?php wp_nonce_field('loginizer-options'); ?> |
| 192 |
<table class="form-table"> |
| 193 |
<tr> |
| 194 |
<td scope="row" valign="top" style="width:400px !important"> |
| 195 |
<label><?php echo __('Disable Checksum of WP Core', 'loginizer'); ?></label><br> |
| 196 |
<span class="exp"><?php echo __('If disabled, Loginizer will not check your sites core files against the WordPress checksum list.', 'loginizer'); ?></span> |
| 197 |
</td> |
| 198 |
<td valign="top"> |
| 199 |
<input type="checkbox" value="1" name="disable_checksum" <?php echo lz_POSTchecked('disable_checksum', (empty($loginizer['disable_checksum']) ? false : true)); ?> /> |
| 200 |
</td> |
| 201 |
</tr> |
| 202 |
<tr> |
| 203 |
<td scope="row" valign="top" style="width:400px !important"> |
| 204 |
<label><?php echo __('Disable Email of Checksum Results', 'loginizer'); ?></label><br> |
| 205 |
<span class="exp"><?php echo __('If checked, Loginizer will not email you the checksum results.', 'loginizer'); ?></span> |
| 206 |
</td> |
| 207 |
<td valign="top"> |
| 208 |
<input type="checkbox" value="1" name="no_checksum_email" <?php echo lz_POSTchecked('no_checksum_email', (empty($loginizer['no_checksum_email']) ? false : true)); ?> /> |
| 209 |
</td> |
| 210 |
</tr> |
| 211 |
<tr> |
| 212 |
<td scope="row" valign="top" style="width:400px !important"> |
| 213 |
<label><?php echo __('Checksum Frequency', 'loginizer'); ?></label><br> |
| 214 |
<span class="exp"><?php echo __('If Checksum is enabled, at what frequency should the checksums be performed.', 'loginizer'); ?></span> |
| 215 |
</td> |
| 216 |
<td valign="top"> |
| 217 |
<select name="checksum_frequency"> |
| 218 |
<?php |
| 219 |
foreach($lz_env['csum_freq'] as $k => $v){ |
| 220 |
echo '<option '.lz_POSTselect('checksum_frequency', $k, ((!empty($loginizer['checksum_frequency']) && $loginizer['checksum_frequency'] == $k) ? true : false)).' value="'.$k.'">'.$v.'</value>'; |
| 221 |
} |
| 222 |
?> |
| 223 |
</select> |
| 224 |
</td> |
| 225 |
</tr> |
| 226 |
<tr id="lz_checksum_time"> |
| 227 |
<td scope="row" valign="top" style="width:400px !important"> |
| 228 |
<label><?php echo __('Time of Day', 'loginizer'); ?></label><br> |
| 229 |
<span class="exp"><?php echo __('If Checksum is enabled, what time of day should Loginizer do the check. Note : The check will be done on or after this time has elapsed as per the accesses being made.', 'loginizer'); ?></span> |
| 230 |
</td> |
| 231 |
<td valign="top"> |
| 232 |
<div class="input-group clockpicker" data-autoclose="true"> |
| 233 |
<input type="text" name="checksum_time" class="form-control" value="<?php echo (empty($loginizer['checksum_time']) ? '00:00' : $loginizer['checksum_time']);?>"> |
| 234 |
<span class="input-group-addon"> |
| 235 |
<span class="glyphicon glyphicon-time"></span> |
| 236 |
</span> |
| 237 |
</div> |
| 238 |
<script type="text/javascript"> |
| 239 |
jQuery(document).ready(function(){ |
| 240 |
(function($) { |
| 241 |
$('.clockpicker').clockpicker({donetext: 'Done'}); |
| 242 |
})(jQuery); |
| 243 |
}); |
| 244 |
</script> |
| 245 |
</td> |
| 246 |
</tr> |
| 247 |
<tr> |
| 248 |
<td colspan="2"> |
| 249 |
<?php echo __('If disabled, Loginizer will not check your sites core files against the WordPress checksum list.', 'loginizer'); ?> |
| 250 |
</td> |
| 251 |
</tr> |
| 252 |
</table><br /> |
| 253 |
<center><input name="save_lz" class="button button-primary action" value="<?php echo __('Save Settings', 'loginizer'); ?>" type="submit" /><input name="lz_run_checksum" style="float:right; background: #5cb85c; color:white; border:#5cb85c" class="button button-secondary" value="<?php echo __('Do a Checksum Now', 'loginizer'); ?>" type="submit" /></center> |
| 254 |
</form> |
| 255 |
|
| 256 |
</div> |
| 257 |
</div> |
| 258 |
|
| 259 |
<div id="" class="postbox"> |
| 260 |
|
| 261 |
<div class="postbox-header"> |
| 262 |
<h2 class="hndle ui-sortable-handle"> |
| 263 |
<span><?php echo __('Mismatching Files', 'loginizer'); ?></span> |
| 264 |
</h2> |
| 265 |
</div> |
| 266 |
|
| 267 |
<div class="inside"> |
| 268 |
|
| 269 |
<form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1"> |
| 270 |
<?php wp_nonce_field('loginizer-options'); ?> |
| 271 |
<table class="wp-list-table fixed striped users" border="0" width="100%" cellpadding="10" align="center"> |
| 272 |
<?php |
| 273 |
|
| 274 |
$files = $lz_env['files']; |
| 275 |
|
| 276 |
// Avoid undefined notice for $files |
| 277 |
if(!empty($files)){ |
| 278 |
foreach($files as $k => $v){ |
| 279 |
if(!empty($lz_env['ignores'][$k])){ |
| 280 |
unset($files[$k]); |
| 281 |
} |
| 282 |
} |
| 283 |
} |
| 284 |
|
| 285 |
echo ' |
| 286 |
<tr> |
| 287 |
<th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th> |
| 288 |
<th style="width:240px; background:#EFEFEF;">'.__('Found', 'loginizer').'</th> |
| 289 |
<th style="width:240px; background:#EFEFEF;">'.__('Should be', 'loginizer').'</th> |
| 290 |
<th style="width:10px; background:#EFEFEF;"><input type="checkbox" onchange="lz_apply_status(this, \'.csum_add_ig\');" /></th> |
| 291 |
</tr>'; |
| 292 |
|
| 293 |
if(is_array($files) && count($files) > 0){ |
| 294 |
|
| 295 |
foreach($files as $k => $v){ |
| 296 |
|
| 297 |
echo ' |
| 298 |
<tr> |
| 299 |
<td>'.$k.'</td> |
| 300 |
<td>'.$v['cur_md5'].'</td> |
| 301 |
<td>'.$v['md5'].'</td> |
| 302 |
<td><input type="checkbox" name="checksum_add_ignore[]" class="csum_add_ig" value="'.$k.'" /></td> |
| 303 |
</tr>'; |
| 304 |
|
| 305 |
} |
| 306 |
|
| 307 |
}else{ |
| 308 |
|
| 309 |
echo ' |
| 310 |
<tr> |
| 311 |
<td colspan="4" align="center">'.__('This is great ! No file with any wrong checksum has been found.','loginizer').'</td> |
| 312 |
</tr>'; |
| 313 |
|
| 314 |
} |
| 315 |
|
| 316 |
?> |
| 317 |
</table><br /> |
| 318 |
<center><input name="save_lz_csum_ig" class="button button-primary action" value="<?php echo __('Add Selected to Ignore List', 'loginizer'); ?>" type="submit" /></center> |
| 319 |
</form> |
| 320 |
</div> |
| 321 |
|
| 322 |
</div> |
| 323 |
<br /> |
| 324 |
|
| 325 |
<div id="" class="postbox"> |
| 326 |
|
| 327 |
<div class="postbox-header"> |
| 328 |
<h2 class="hndle ui-sortable-handle"> |
| 329 |
<span><?php echo __('Ignore List', 'loginizer'); ?></span> |
| 330 |
</h2> |
| 331 |
</div> |
| 332 |
|
| 333 |
<div class="inside"> |
| 334 |
|
| 335 |
<form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1"> |
| 336 |
<?php wp_nonce_field('loginizer-options'); ?> |
| 337 |
<table class="wp-list-table fixed striped users" border="0" width="100%" cellpadding="10" align="center"> |
| 338 |
<?php |
| 339 |
|
| 340 |
$ignores = $lz_env['ignores']; |
| 341 |
|
| 342 |
echo ' |
| 343 |
<tr> |
| 344 |
<th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th> |
| 345 |
<th style="width:240px; background:#EFEFEF;">'.__('Found', 'loginizer').'</th> |
| 346 |
<th style="width:240px; background:#EFEFEF;">'.__('Should be', 'loginizer').'</th> |
| 347 |
<th style="width:10px; background:#EFEFEF;"><input type="checkbox" onchange="lz_apply_status(this, \'.csum_del_ig\');" /></th> |
| 348 |
</tr>'; |
| 349 |
|
| 350 |
// Load any mismatched files |
| 351 |
$files = $ignores; |
| 352 |
|
| 353 |
if(is_array($files) && count($files) > 0){ |
| 354 |
|
| 355 |
foreach($files as $k => $v){ |
| 356 |
|
| 357 |
echo ' |
| 358 |
<tr> |
| 359 |
<td>'.$k.'</td> |
| 360 |
<td>'.$v['cur_md5'].'</td> |
| 361 |
<td>'.$v['md5'].'</td> |
| 362 |
<td><input type="checkbox" name="checksum_del_ignore[]" class="csum_del_ig" value="'.$k.'" /></td> |
| 363 |
</tr>'; |
| 364 |
|
| 365 |
} |
| 366 |
|
| 367 |
}else{ |
| 368 |
|
| 369 |
echo ' |
| 370 |
<tr> |
| 371 |
<td colspan="4" align="center">'.__('No files have been added to the ignore list','loginizer').'</td> |
| 372 |
</tr>'; |
| 373 |
|
| 374 |
} |
| 375 |
|
| 376 |
?> |
| 377 |
</table><br /> |
| 378 |
<center><input name="save_lz_csum_ig" class="button button-primary action" value="<?php echo __('Remove Selected from Ignore List', 'loginizer'); ?>" type="submit" /></center> |
| 379 |
</form> |
| 380 |
</div> |
| 381 |
|
| 382 |
</div> |
| 383 |
<br /> |
| 384 |
|
| 385 |
<?php |
| 386 |
loginizer_page_footer(); |
| 387 |
|
| 388 |
} |