PluginProbe
Loginizer / 1.8.2
Loginizer v1.8.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 / settings / checksum.php

checksum.php in Loginizer 1.8.2, at main/settings/checksum.php

386 lines 11.7 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
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 wp_enqueue_script('jquery-clockpicker', LOGINIZER_URL.'/assets/js/jquery-clockpicker.min.js', array('jquery'), '0.0.7');
136 wp_enqueue_style('jquery-clockpicker', LOGINIZER_URL.'/assets/css/jquery-clockpicker.min.css', array(), '0.0.7');
137
138 // Saved ?
139 if(!empty($GLOBALS['lz_saved'])){
140 echo '<div id="message" class="updated"><p>'. __('The settings were saved successfully', 'loginizer'). '</p></div><br />';
141 }
142
143 // Did we just run the checksums
144 if(isset($_REQUEST['lz_run_checksum'])){
145 echo '<div id="message" class="updated"><p>'. __('The Checksum process was executed successfully', 'loginizer'). '</p></div><br />';
146 }
147
148 // Any errors ?
149 if(!empty($lz_error)){
150 lz_report_error($lz_error);echo '<br />';
151 }
152
153 ?>
154
155 <style>
156 input[type="text"], textarea, select {
157 width: 70%;
158 }
159
160 .form-table label{
161 font-weight:bold;
162 }
163
164 .exp{
165 font-size:12px;
166 }
167 </style>
168
169 <script>
170 function lz_apply_status(ele, the_class){
171
172 var status = ele.checked;
173 jQuery(the_class).each(function(){
174 this.checked = status;
175 });
176
177 }
178 </script>
179
180 <div id="" class="postbox">
181 <div class="postbox-header">
182 <h2 class="hndle ui-sortable-handle">
183 <span><?php echo __('Checksum Settings', 'loginizer'); ?></span>
184 </h2>
185 </div>
186 <div class="inside">
187
188 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
189 <?php wp_nonce_field('loginizer-options'); ?>
190 <table class="form-table">
191 <tr>
192 <td scope="row" valign="top" style="width:400px !important">
193 <label><?php echo __('Disable Checksum of WP Core', 'loginizer'); ?></label><br>
194 <span class="exp"><?php echo __('If disabled, Loginizer will not check your sites core files against the WordPress checksum list.', 'loginizer'); ?></span>
195 </td>
196 <td valign="top">
197 <input type="checkbox" value="1" name="disable_checksum" <?php echo lz_POSTchecked('disable_checksum', (empty($loginizer['disable_checksum']) ? false : true)); ?> />
198 </td>
199 </tr>
200 <tr>
201 <td scope="row" valign="top" style="width:400px !important">
202 <label><?php echo __('Disable Email of Checksum Results', 'loginizer'); ?></label><br>
203 <span class="exp"><?php echo __('If checked, Loginizer will not email you the checksum results.', 'loginizer'); ?></span>
204 </td>
205 <td valign="top">
206 <input type="checkbox" value="1" name="no_checksum_email" <?php echo lz_POSTchecked('no_checksum_email', (empty($loginizer['no_checksum_email']) ? false : true)); ?> />
207 </td>
208 </tr>
209 <tr>
210 <td scope="row" valign="top" style="width:400px !important">
211 <label><?php echo __('Checksum Frequency', 'loginizer'); ?></label><br>
212 <span class="exp"><?php echo __('If Checksum is enabled, at what frequency should the checksums be performed.', 'loginizer'); ?></span>
213 </td>
214 <td valign="top">
215 <select name="checksum_frequency">
216 <?php
217 foreach($lz_env['csum_freq'] as $k => $v){
218 echo '<option '.lz_POSTselect('checksum_frequency', $k, ($loginizer['checksum_frequency'] == $k ? true : false)).' value="'.$k.'">'.$v.'</value>';
219 }
220 ?>
221 </select>
222 </td>
223 </tr>
224 <tr id="lz_checksum_time">
225 <td scope="row" valign="top" style="width:400px !important">
226 <label><?php echo __('Time of Day', 'loginizer'); ?></label><br>
227 <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>
228 </td>
229 <td valign="top">
230 <div class="input-group clockpicker" data-autoclose="true">
231 <input type="text" name="checksum_time" class="form-control" value="<?php echo (empty($loginizer['checksum_time']) ? '00:00' : $loginizer['checksum_time']);?>">
232 <span class="input-group-addon">
233 <span class="glyphicon glyphicon-time"></span>
234 </span>
235 </div>
236 <script type="text/javascript">
237 jQuery(document).ready(function(){
238 (function($) {
239 $('.clockpicker').clockpicker({donetext: 'Done'});
240 })(jQuery);
241 });
242 </script>
243 </td>
244 </tr>
245 <tr>
246 <td colspan="2">
247 <?php echo __('If disabled, Loginizer will not check your sites core files against the WordPress checksum list.', 'loginizer'); ?>
248 </td>
249 </tr>
250 </table><br />
251 <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>
252 </form>
253
254 </div>
255 </div>
256
257 <div id="" class="postbox">
258
259 <div class="postbox-header">
260 <h2 class="hndle ui-sortable-handle">
261 <span><?php echo __('Mismatching Files', 'loginizer'); ?></span>
262 </h2>
263 </div>
264
265 <div class="inside">
266
267 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
268 <?php wp_nonce_field('loginizer-options'); ?>
269 <table class="wp-list-table fixed striped users" border="0" width="100%" cellpadding="10" align="center">
270 <?php
271
272 $files = $lz_env['files'];
273
274 // Avoid undefined notice for $files
275 if(!empty($files)){
276 foreach($files as $k => $v){
277 if(!empty($lz_env['ignores'][$k])){
278 unset($files[$k]);
279 }
280 }
281 }
282
283 echo '
284 <tr>
285 <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
286 <th style="width:240px; background:#EFEFEF;">'.__('Found', 'loginizer').'</th>
287 <th style="width:240px; background:#EFEFEF;">'.__('Should be', 'loginizer').'</th>
288 <th style="width:10px; background:#EFEFEF;"><input type="checkbox" onchange="lz_apply_status(this, \'.csum_add_ig\');" /></th>
289 </tr>';
290
291 if(is_array($files) && count($files) > 0){
292
293 foreach($files as $k => $v){
294
295 echo '
296 <tr>
297 <td>'.$k.'</td>
298 <td>'.$v['cur_md5'].'</td>
299 <td>'.$v['md5'].'</td>
300 <td><input type="checkbox" name="checksum_add_ignore[]" class="csum_add_ig" value="'.$k.'" /></td>
301 </tr>';
302
303 }
304
305 }else{
306
307 echo '
308 <tr>
309 <td colspan="4" align="center">'.__('This is great ! No file with any wrong checksum has been found.','loginizer').'</td>
310 </tr>';
311
312 }
313
314 ?>
315 </table><br />
316 <center><input name="save_lz_csum_ig" class="button button-primary action" value="<?php echo __('Add Selected to Ignore List', 'loginizer'); ?>" type="submit" /></center>
317 </form>
318 </div>
319
320 </div>
321 <br />
322
323 <div id="" class="postbox">
324
325 <div class="postbox-header">
326 <h2 class="hndle ui-sortable-handle">
327 <span><?php echo __('Ignore List', 'loginizer'); ?></span>
328 </h2>
329 </div>
330
331 <div class="inside">
332
333 <form action="" method="post" enctype="multipart/form-data" loginizer-premium-only="1">
334 <?php wp_nonce_field('loginizer-options'); ?>
335 <table class="wp-list-table fixed striped users" border="0" width="100%" cellpadding="10" align="center">
336 <?php
337
338 $ignores = $lz_env['ignores'];
339
340 echo '
341 <tr>
342 <th style="background:#EFEFEF;">'.__('Relative Path', 'loginizer').'</th>
343 <th style="width:240px; background:#EFEFEF;">'.__('Found', 'loginizer').'</th>
344 <th style="width:240px; background:#EFEFEF;">'.__('Should be', 'loginizer').'</th>
345 <th style="width:10px; background:#EFEFEF;"><input type="checkbox" onchange="lz_apply_status(this, \'.csum_del_ig\');" /></th>
346 </tr>';
347
348 // Load any mismatched files
349 $files = $ignores;
350
351 if(is_array($files) && count($files) > 0){
352
353 foreach($files as $k => $v){
354
355 echo '
356 <tr>
357 <td>'.$k.'</td>
358 <td>'.$v['cur_md5'].'</td>
359 <td>'.$v['md5'].'</td>
360 <td><input type="checkbox" name="checksum_del_ignore[]" class="csum_del_ig" value="'.$k.'" /></td>
361 </tr>';
362
363 }
364
365 }else{
366
367 echo '
368 <tr>
369 <td colspan="4" align="center">'.__('No files have been added to the ignore list','loginizer').'</td>
370 </tr>';
371
372 }
373
374 ?>
375 </table><br />
376 <center><input name="save_lz_csum_ig" class="button button-primary action" value="<?php echo __('Remove Selected from Ignore List', 'loginizer'); ?>" type="submit" /></center>
377 </form>
378 </div>
379
380 </div>
381 <br />
382
383 <?php
384 loginizer_page_footer();
385
386 }