Version Description
(August 2016) =
- User logins using e-mail are now logged correctly. Previously the user would be logged in successfully but the log said that they failed.
- Now only users with
list_users
capability can view the users filter and use the autocomplete api for users. - Add labels to search filters. (I do really hate label-less forms so it's kinda very strange that this was not in place before.)
- Misc other internal fixes
Download this release
Release Info
Developer | eskapism |
Plugin | Simple History |
Version | 2.7.5 |
Comparing to | |
See all releases |
Code changes from version 2.7.4 to 2.7.5
- dropins/SimpleHistoryFilterDropin.css +31 -0
- dropins/SimpleHistoryFilterDropin.php +68 -35
- dropins/SimpleHistoryNewRowsNotifier.php +10 -8
- inc/SimpleHistory.php +5 -0
- index.php +2 -2
- loggers/SimpleThemeLogger.php +4 -4
- loggers/SimpleUserLogger.php +22 -16
- readme.txt +9 -2
dropins/SimpleHistoryFilterDropin.css
CHANGED
@@ -30,6 +30,37 @@
|
|
30 |
width: 310px;
|
31 |
}
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
/* set height on date input or it will "jump" during page load */
|
34 |
.wp-admin select[multiple].SimpleHistory__filters__filter--date {
|
35 |
height: 2.2em;
|
30 |
width: 310px;
|
31 |
}
|
32 |
|
33 |
+
.SimpleHistory__filters__filterLabel {
|
34 |
+
display: inline-block;
|
35 |
+
width: 150px;
|
36 |
+
}
|
37 |
+
|
38 |
+
.SimpleHistory__filters__filterSubmitWrap {
|
39 |
+
margin-left: 150px; /* same width as the label */
|
40 |
+
}
|
41 |
+
|
42 |
+
@media (max-width: 600px) {
|
43 |
+
|
44 |
+
.SimpleHistory__filters__filterLabel {
|
45 |
+
display: block;
|
46 |
+
width: auto;
|
47 |
+
}
|
48 |
+
|
49 |
+
.SimpleHistory__filters__filterSubmitWrap {
|
50 |
+
margin-left: 0;
|
51 |
+
}
|
52 |
+
|
53 |
+
}
|
54 |
+
|
55 |
+
/* always label as blocks on dashboard because we don't know the width beacuse of columns */
|
56 |
+
.postbox .SimpleHistory__filters__filterLabel {
|
57 |
+
display: block;
|
58 |
+
width: auto;
|
59 |
+
}
|
60 |
+
.postbox .SimpleHistory__filters__filterSubmitWrap {
|
61 |
+
margin-left: 0;
|
62 |
+
}
|
63 |
+
|
64 |
/* set height on date input or it will "jump" during page load */
|
65 |
.wp-admin select[multiple].SimpleHistory__filters__filter--date {
|
66 |
height: 2.2em;
|
dropins/SimpleHistoryFilterDropin.php
CHANGED
@@ -71,7 +71,7 @@ class SimpleHistoryFilterDropin {
|
|
71 |
$result_months = get_transient( $cache_key );
|
72 |
|
73 |
if ( false === $result_months ) {
|
74 |
-
|
75 |
$sql_dates = sprintf('
|
76 |
SELECT DISTINCT ( date_format(DATE, "%%Y-%%m") ) AS yearMonth
|
77 |
FROM %s
|
@@ -91,7 +91,7 @@ class SimpleHistoryFilterDropin {
|
|
91 |
|
92 |
// Default month = current month
|
93 |
// Mainly for performance reasons, since often
|
94 |
-
// it's not the users intention to view all events,
|
95 |
// but just the latest
|
96 |
$this_month = date("Y-m");
|
97 |
|
@@ -124,7 +124,7 @@ class SimpleHistoryFilterDropin {
|
|
124 |
);
|
125 |
|
126 |
if ( $numPages < 20 ) {
|
127 |
-
|
128 |
// Not that many things the last 7 days. Let's try to expand to 14 days instead.
|
129 |
$daysToShow = 14;
|
130 |
$numEvents = $this->sh->get_unique_events_for_days($daysToShow);
|
@@ -162,7 +162,11 @@ class SimpleHistoryFilterDropin {
|
|
162 |
}
|
163 |
|
164 |
?>
|
|
|
165 |
<p data-debug-daysAndPages='<?php echo json_encode( $arr_days_and_pages ) ?>'>
|
|
|
|
|
|
|
166 |
<select class="SimpleHistory__filters__filter SimpleHistory__filters__filter--date"
|
167 |
name="dates"
|
168 |
placeholder="<?php echo _e("All dates", "simple-history") ?>" multiple>
|
@@ -204,20 +208,21 @@ class SimpleHistoryFilterDropin {
|
|
204 |
_x("Last 60 days", "Filter dropin: filter week", "simple-history"), // 2 text
|
205 |
selected( $daysToShow, 60, 0 )
|
206 |
);
|
207 |
-
|
208 |
// Months
|
209 |
foreach ( $result_months as $row ) {
|
210 |
-
|
211 |
printf(
|
212 |
'<option value="%1$s" %3$s>%2$s</option>',
|
213 |
"month:" . $row->yearMonth,
|
214 |
date_i18n( "F Y", strtotime($row->yearMonth) ),
|
215 |
"" // selected( $this_month, $row->yearMonth, false )
|
216 |
);
|
217 |
-
|
218 |
}
|
219 |
?>
|
220 |
</select>
|
|
|
221 |
</p><!-- end months -->
|
222 |
|
223 |
<?php
|
@@ -230,20 +235,24 @@ class SimpleHistoryFilterDropin {
|
|
230 |
*/
|
231 |
$default_search_string = apply_filters("SimpleHistoryFilterDropin/filter_default_search_string" , "");
|
232 |
?>
|
|
|
233 |
<p>
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
|
|
|
|
|
|
238 |
name="search"
|
239 |
value="<?php echo esc_attr($default_search_string); ?>"
|
240 |
>
|
|
|
241 |
</p>
|
242 |
|
243 |
-
<p>
|
244 |
<button class="button SimpleHistoryFilterDropin-doFilterButton SimpleHistoryFilterDropin-doFilterButton--first js-SimpleHistoryFilterDropin-doFilter"><?php _e("Search events", "simple-history") ?></button>
|
245 |
-
|
246 |
-
<button type="button" class="SimpleHistoryFilterDropin-showMoreFilters SimpleHistoryFilterDropin-showMoreFilters--first js-SimpleHistoryFilterDropin-showMoreFilters"><?php _ex("Show options", "Filter dropin: button to show more search options", "simple-history") ?></button>
|
247 |
</p>
|
248 |
|
249 |
<?php
|
@@ -259,6 +268,9 @@ class SimpleHistoryFilterDropin {
|
|
259 |
<div class="SimpleHistory__filters__moreFilters js-SimpleHistory__filters__moreFilters">
|
260 |
|
261 |
<p>
|
|
|
|
|
|
|
262 |
<select name="loglevels" class="SimpleHistory__filters__filter SimpleHistory__filters__filter--loglevel" style="width: 300px" placeholder="<?php _e("All log levels", "simple-history") ?>" multiple>
|
263 |
<option <?php selected(in_array("debug", $arr_default_loglevels)) ?> value="debug" data-color="#CEF6D8"><?php echo $this->sh->getLogLevelTranslated("Debug") ?></option>
|
264 |
<option <?php selected(in_array("info", $arr_default_loglevels)) ?> value="info" data-color="white"><?php echo $this->sh->getLogLevelTranslated("Info") ?></option>
|
@@ -269,9 +281,11 @@ class SimpleHistoryFilterDropin {
|
|
269 |
<option <?php selected(in_array("alert", $arr_default_loglevels)) ?> value="alert" data-color="rgb(199, 69, 69)"><?php echo $this->sh->getLogLevelTranslated("Alert") ?></option>
|
270 |
<option <?php selected(in_array("emergency", $arr_default_loglevels)) ?> value="emergency" data-color="#DF0101"><?php echo $this->sh->getLogLevelTranslated("Emergency") ?></option>
|
271 |
</select>
|
|
|
272 |
</p>
|
273 |
|
274 |
<?php
|
|
|
275 |
/**
|
276 |
* Todo: Filter to control what the default messages to filter/search.
|
277 |
* Message in in format: LoggerSlug:MessageKey
|
@@ -286,6 +300,9 @@ class SimpleHistoryFilterDropin {
|
|
286 |
// $arr_default_messages = apply_filters("SimpleHistoryFilterDropin/filter_default_messages", array());
|
287 |
?>
|
288 |
<p>
|
|
|
|
|
|
|
289 |
<select name="messages" class="SimpleHistory__filters__filter SimpleHistory__filters__filter--logger" style="width: 300px"
|
290 |
placeholder="<?php _e("All messages", "simple-history") ?>" multiple>
|
291 |
<?php
|
@@ -324,7 +341,7 @@ class SimpleHistoryFilterDropin {
|
|
324 |
|
325 |
$str_option_messages = implode(",", $option_messages);
|
326 |
printf(
|
327 |
-
'<option value="%2$s">%1$s</option>',
|
328 |
esc_attr( $option_key ), // 1
|
329 |
esc_attr( $str_option_messages ) // 2
|
330 |
);
|
@@ -341,6 +358,7 @@ class SimpleHistoryFilterDropin {
|
|
341 |
</p>
|
342 |
|
343 |
<?php
|
|
|
344 |
/**
|
345 |
* Filter what users to search for by default
|
346 |
*
|
@@ -354,9 +372,9 @@ class SimpleHistoryFilterDropin {
|
|
354 |
*/
|
355 |
|
356 |
/*
|
357 |
-
add_filter("SimpleHistoryFilterDropin/filter_default_user_ids", function($arr) {
|
358 |
$arr = array(
|
359 |
-
1,
|
360 |
4
|
361 |
);
|
362 |
return $arr;
|
@@ -369,25 +387,32 @@ class SimpleHistoryFilterDropin {
|
|
369 |
foreach ($default_user_ids as $user_id) {
|
370 |
$arr_default_user_data[] = $this->get_data_for_user($user_id);
|
371 |
}
|
372 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
?>
|
374 |
-
<p>
|
375 |
-
<input type="text"
|
376 |
-
name = "users"
|
377 |
-
class="SimpleHistory__filters__filter SimpleHistory__filters__filter--user"
|
378 |
-
style="width: 300px"
|
379 |
-
placeholder="<?php _e("All users", "simple-history") ?>"
|
380 |
-
value="<?php echo esc_attr(implode(",",$default_user_ids)) ?>"
|
381 |
-
data-default-user-data="<?php echo esc_attr( json_encode($arr_default_user_data) ) ?>"
|
382 |
-
/>
|
383 |
-
</p>
|
384 |
|
385 |
-
<p>
|
386 |
<button class="button SimpleHistoryFilterDropin-doFilterButton SimpleHistoryFilterDropin-doFilterButton--second js-SimpleHistoryFilterDropin-doFilter"><?php _e("Search events", "simple-history") ?></button>
|
387 |
-
<button type="button" class="SimpleHistoryFilterDropin-showMoreFilters SimpleHistoryFilterDropin-showMoreFilters--second js-SimpleHistoryFilterDropin-showMoreFilters"><?php _ex("Hide options", "Filter dropin: button to hide more search options", "simple-history") ?></button>
|
388 |
</p>
|
389 |
|
390 |
-
|
391 |
</div><!-- // more filters -->
|
392 |
|
393 |
<!--
|
@@ -403,7 +428,7 @@ class SimpleHistoryFilterDropin {
|
|
403 |
|
404 |
} // function
|
405 |
|
406 |
-
|
407 |
/**
|
408 |
* Return format used for select2 for a single user id
|
409 |
*
|
@@ -411,7 +436,7 @@ class SimpleHistoryFilterDropin {
|
|
411 |
* @return array Array with each user as an object
|
412 |
*/
|
413 |
public function get_data_for_user($userID) {
|
414 |
-
|
415 |
if ( ! $userID || ! is_numeric($userID) ) {
|
416 |
return false;
|
417 |
}
|
@@ -421,7 +446,7 @@ class SimpleHistoryFilterDropin {
|
|
421 |
if ( false == $user ) {
|
422 |
return false;
|
423 |
}
|
424 |
-
|
425 |
$userdata = (object) array(
|
426 |
"id" => $user->ID,
|
427 |
"user_email" => $user->user_email,
|
@@ -443,8 +468,14 @@ class SimpleHistoryFilterDropin {
|
|
443 |
$q = isset( $_GET["q"] ) ? $_GET["q"] : "";
|
444 |
$page_limit = isset( $_GET["page_limit"] ) ? (int) $_GET["page_limit"] : "";
|
445 |
|
|
|
446 |
if ( ! $q || ! $page_limit ) {
|
447 |
-
|
|
|
|
|
|
|
|
|
|
|
448 |
}
|
449 |
|
450 |
// Search both current users and all logged rows,
|
@@ -473,6 +504,7 @@ class SimpleHistoryFilterDropin {
|
|
473 |
OR user_nicename LIKE "%%%2$s%%"
|
474 |
OR user_email LIKE "%%%2$s%%"
|
475 |
OR display_name LIKE "%%%2$s%%"
|
|
|
476 |
',
|
477 |
$wpdb->users,
|
478 |
$str_like
|
@@ -487,7 +519,8 @@ class SimpleHistoryFilterDropin {
|
|
487 |
"results" => array(
|
488 |
),
|
489 |
"more" => false,
|
490 |
-
"context" => array()
|
|
|
491 |
);
|
492 |
|
493 |
$data["results"] = array_merge( $data["results"], $results_user );
|
71 |
$result_months = get_transient( $cache_key );
|
72 |
|
73 |
if ( false === $result_months ) {
|
74 |
+
|
75 |
$sql_dates = sprintf('
|
76 |
SELECT DISTINCT ( date_format(DATE, "%%Y-%%m") ) AS yearMonth
|
77 |
FROM %s
|
91 |
|
92 |
// Default month = current month
|
93 |
// Mainly for performance reasons, since often
|
94 |
+
// it's not the users intention to view all events,
|
95 |
// but just the latest
|
96 |
$this_month = date("Y-m");
|
97 |
|
124 |
);
|
125 |
|
126 |
if ( $numPages < 20 ) {
|
127 |
+
|
128 |
// Not that many things the last 7 days. Let's try to expand to 14 days instead.
|
129 |
$daysToShow = 14;
|
130 |
$numEvents = $this->sh->get_unique_events_for_days($daysToShow);
|
162 |
}
|
163 |
|
164 |
?>
|
165 |
+
|
166 |
<p data-debug-daysAndPages='<?php echo json_encode( $arr_days_and_pages ) ?>'>
|
167 |
+
|
168 |
+
<label class="SimpleHistory__filters__filterLabel"><?php _ex("Dates:", "Filter label", "simple-history") ?></label>
|
169 |
+
|
170 |
<select class="SimpleHistory__filters__filter SimpleHistory__filters__filter--date"
|
171 |
name="dates"
|
172 |
placeholder="<?php echo _e("All dates", "simple-history") ?>" multiple>
|
208 |
_x("Last 60 days", "Filter dropin: filter week", "simple-history"), // 2 text
|
209 |
selected( $daysToShow, 60, 0 )
|
210 |
);
|
211 |
+
|
212 |
// Months
|
213 |
foreach ( $result_months as $row ) {
|
214 |
+
|
215 |
printf(
|
216 |
'<option value="%1$s" %3$s>%2$s</option>',
|
217 |
"month:" . $row->yearMonth,
|
218 |
date_i18n( "F Y", strtotime($row->yearMonth) ),
|
219 |
"" // selected( $this_month, $row->yearMonth, false )
|
220 |
);
|
221 |
+
|
222 |
}
|
223 |
?>
|
224 |
</select>
|
225 |
+
|
226 |
</p><!-- end months -->
|
227 |
|
228 |
<?php
|
235 |
*/
|
236 |
$default_search_string = apply_filters("SimpleHistoryFilterDropin/filter_default_search_string" , "");
|
237 |
?>
|
238 |
+
|
239 |
<p>
|
240 |
+
|
241 |
+
<label class="SimpleHistory__filters__filterLabel"><?php _ex("Containing words:", "Filter label", "simple-history") ?></label>
|
242 |
+
|
243 |
+
<input
|
244 |
+
type="search"
|
245 |
+
class="SimpleHistoryFilterDropin-searchInput"
|
246 |
+
placeholder="<?php /* _e("Containing words", "simple-history"); */ ?>"
|
247 |
name="search"
|
248 |
value="<?php echo esc_attr($default_search_string); ?>"
|
249 |
>
|
250 |
+
|
251 |
</p>
|
252 |
|
253 |
+
<p class="SimpleHistory__filters__filterSubmitWrap">
|
254 |
<button class="button SimpleHistoryFilterDropin-doFilterButton SimpleHistoryFilterDropin-doFilterButton--first js-SimpleHistoryFilterDropin-doFilter"><?php _e("Search events", "simple-history") ?></button>
|
255 |
+
<button type="button" class="SimpleHistoryFilterDropin-showMoreFilters SimpleHistoryFilterDropin-showMoreFilters--first js-SimpleHistoryFilterDropin-showMoreFilters"><?php _ex("Show search options", "Filter dropin: button to show more search options", "simple-history") ?></button>
|
|
|
256 |
</p>
|
257 |
|
258 |
<?php
|
268 |
<div class="SimpleHistory__filters__moreFilters js-SimpleHistory__filters__moreFilters">
|
269 |
|
270 |
<p>
|
271 |
+
|
272 |
+
<label class="SimpleHistory__filters__filterLabel"><?php _ex("Log levels:", "Filter label", "simple-history") ?></label>
|
273 |
+
|
274 |
<select name="loglevels" class="SimpleHistory__filters__filter SimpleHistory__filters__filter--loglevel" style="width: 300px" placeholder="<?php _e("All log levels", "simple-history") ?>" multiple>
|
275 |
<option <?php selected(in_array("debug", $arr_default_loglevels)) ?> value="debug" data-color="#CEF6D8"><?php echo $this->sh->getLogLevelTranslated("Debug") ?></option>
|
276 |
<option <?php selected(in_array("info", $arr_default_loglevels)) ?> value="info" data-color="white"><?php echo $this->sh->getLogLevelTranslated("Info") ?></option>
|
281 |
<option <?php selected(in_array("alert", $arr_default_loglevels)) ?> value="alert" data-color="rgb(199, 69, 69)"><?php echo $this->sh->getLogLevelTranslated("Alert") ?></option>
|
282 |
<option <?php selected(in_array("emergency", $arr_default_loglevels)) ?> value="emergency" data-color="#DF0101"><?php echo $this->sh->getLogLevelTranslated("Emergency") ?></option>
|
283 |
</select>
|
284 |
+
|
285 |
</p>
|
286 |
|
287 |
<?php
|
288 |
+
|
289 |
/**
|
290 |
* Todo: Filter to control what the default messages to filter/search.
|
291 |
* Message in in format: LoggerSlug:MessageKey
|
300 |
// $arr_default_messages = apply_filters("SimpleHistoryFilterDropin/filter_default_messages", array());
|
301 |
?>
|
302 |
<p>
|
303 |
+
|
304 |
+
<label class="SimpleHistory__filters__filterLabel"><?php _ex("Message types:", "Filter label", "simple-history") ?></label>
|
305 |
+
|
306 |
<select name="messages" class="SimpleHistory__filters__filter SimpleHistory__filters__filter--logger" style="width: 300px"
|
307 |
placeholder="<?php _e("All messages", "simple-history") ?>" multiple>
|
308 |
<?php
|
341 |
|
342 |
$str_option_messages = implode(",", $option_messages);
|
343 |
printf(
|
344 |
+
'<option value="%2$s">%1$s</option>',
|
345 |
esc_attr( $option_key ), // 1
|
346 |
esc_attr( $str_option_messages ) // 2
|
347 |
);
|
358 |
</p>
|
359 |
|
360 |
<?php
|
361 |
+
|
362 |
/**
|
363 |
* Filter what users to search for by default
|
364 |
*
|
372 |
*/
|
373 |
|
374 |
/*
|
375 |
+
add_filter("SimpleHistoryFilterDropin/filter_default_user_ids", function($arr) {
|
376 |
$arr = array(
|
377 |
+
1,
|
378 |
4
|
379 |
);
|
380 |
return $arr;
|
387 |
foreach ($default_user_ids as $user_id) {
|
388 |
$arr_default_user_data[] = $this->get_data_for_user($user_id);
|
389 |
}
|
390 |
+
|
391 |
+
if ( current_user_can("list_users") ) {
|
392 |
+
?>
|
393 |
+
<p>
|
394 |
+
|
395 |
+
<label class="SimpleHistory__filters__filterLabel"><?php _ex("Users:", "Filter label", "simple-history") ?></label>
|
396 |
+
|
397 |
+
<input type="text"
|
398 |
+
name = "users"
|
399 |
+
class="SimpleHistory__filters__filter SimpleHistory__filters__filter--user"
|
400 |
+
style="width: 300px"
|
401 |
+
placeholder="<?php _e("All users", "simple-history") ?>"
|
402 |
+
value="<?php echo esc_attr(implode(",",$default_user_ids)) ?>"
|
403 |
+
data-default-user-data="<?php echo esc_attr( json_encode($arr_default_user_data) ) ?>"
|
404 |
+
/>
|
405 |
+
|
406 |
+
</p>
|
407 |
+
<?php
|
408 |
+
}
|
409 |
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
|
411 |
+
<p class="SimpleHistory__filters__filterSubmitWrap">
|
412 |
<button class="button SimpleHistoryFilterDropin-doFilterButton SimpleHistoryFilterDropin-doFilterButton--second js-SimpleHistoryFilterDropin-doFilter"><?php _e("Search events", "simple-history") ?></button>
|
413 |
+
<button type="button" class="SimpleHistoryFilterDropin-showMoreFilters SimpleHistoryFilterDropin-showMoreFilters--second js-SimpleHistoryFilterDropin-showMoreFilters"><?php _ex("Hide search options", "Filter dropin: button to hide more search options", "simple-history") ?></button>
|
414 |
</p>
|
415 |
|
|
|
416 |
</div><!-- // more filters -->
|
417 |
|
418 |
<!--
|
428 |
|
429 |
} // function
|
430 |
|
431 |
+
|
432 |
/**
|
433 |
* Return format used for select2 for a single user id
|
434 |
*
|
436 |
* @return array Array with each user as an object
|
437 |
*/
|
438 |
public function get_data_for_user($userID) {
|
439 |
+
|
440 |
if ( ! $userID || ! is_numeric($userID) ) {
|
441 |
return false;
|
442 |
}
|
446 |
if ( false == $user ) {
|
447 |
return false;
|
448 |
}
|
449 |
+
|
450 |
$userdata = (object) array(
|
451 |
"id" => $user->ID,
|
452 |
"user_email" => $user->user_email,
|
468 |
$q = isset( $_GET["q"] ) ? $_GET["q"] : "";
|
469 |
$page_limit = isset( $_GET["page_limit"] ) ? (int) $_GET["page_limit"] : "";
|
470 |
|
471 |
+
// query and page limit must be set
|
472 |
if ( ! $q || ! $page_limit ) {
|
473 |
+
wp_send_json_error();
|
474 |
+
}
|
475 |
+
|
476 |
+
// user must have list_users capability (default super admin + administrators have this)
|
477 |
+
if ( ! current_user_can("list_users") ) {
|
478 |
+
wp_send_json_error();;
|
479 |
}
|
480 |
|
481 |
// Search both current users and all logged rows,
|
504 |
OR user_nicename LIKE "%%%2$s%%"
|
505 |
OR user_email LIKE "%%%2$s%%"
|
506 |
OR display_name LIKE "%%%2$s%%"
|
507 |
+
LIMIT 20
|
508 |
',
|
509 |
$wpdb->users,
|
510 |
$str_like
|
519 |
"results" => array(
|
520 |
),
|
521 |
"more" => false,
|
522 |
+
"context" => array(),
|
523 |
+
"count" => sizeof( $results_user )
|
524 |
);
|
525 |
|
526 |
$data["results"] = array_merge( $data["results"], $results_user );
|
dropins/SimpleHistoryNewRowsNotifier.php
CHANGED
@@ -18,9 +18,9 @@ class SimpleHistoryNewRowsNotifier {
|
|
18 |
private $interval = 10000;
|
19 |
|
20 |
function __construct($sh) {
|
21 |
-
|
22 |
$this->sh = $sh;
|
23 |
-
|
24 |
// How often the script checks for new rows
|
25 |
$this->interval = (int) apply_filters("SimpleHistoryNewRowsNotifier/interval", $this->interval);
|
26 |
|
@@ -52,12 +52,15 @@ class SimpleHistoryNewRowsNotifier {
|
|
52 |
|
53 |
if ( ! $apiArgs ) {
|
54 |
wp_send_json_error( array("error" => "MISSING_APIARGS") );
|
55 |
-
exit;
|
56 |
}
|
57 |
|
58 |
if ( empty( $apiArgs["since_id"] ) || ! is_numeric( $apiArgs["since_id"] ) ) {
|
59 |
wp_send_json_error( array("error" => "MISSING_SINCE_ID") );
|
60 |
-
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
// $since_id = isset( $_GET["since_id"] ) ? absint($_GET["since_id"]) : null;
|
@@ -67,15 +70,15 @@ class SimpleHistoryNewRowsNotifier {
|
|
67 |
$logQuery = new SimpleHistoryLogQuery();
|
68 |
$answer = $logQuery->query( $logQueryArgs );
|
69 |
|
70 |
-
// Use our own
|
71 |
$json_data = array();
|
72 |
-
|
73 |
$numNewRows = isset( $answer["total_row_count"] ) ? $answer["total_row_count"] : 0;
|
74 |
$json_data["num_new_rows"] = $numNewRows;
|
75 |
$json_data["num_mysql_queries"] = get_num_queries();
|
76 |
|
77 |
if ($numNewRows) {
|
78 |
-
|
79 |
// We have new rows
|
80 |
|
81 |
// Append strings
|
@@ -91,4 +94,3 @@ class SimpleHistoryNewRowsNotifier {
|
|
91 |
}
|
92 |
|
93 |
} // class
|
94 |
-
|
18 |
private $interval = 10000;
|
19 |
|
20 |
function __construct($sh) {
|
21 |
+
|
22 |
$this->sh = $sh;
|
23 |
+
|
24 |
// How often the script checks for new rows
|
25 |
$this->interval = (int) apply_filters("SimpleHistoryNewRowsNotifier/interval", $this->interval);
|
26 |
|
52 |
|
53 |
if ( ! $apiArgs ) {
|
54 |
wp_send_json_error( array("error" => "MISSING_APIARGS") );
|
|
|
55 |
}
|
56 |
|
57 |
if ( empty( $apiArgs["since_id"] ) || ! is_numeric( $apiArgs["since_id"] ) ) {
|
58 |
wp_send_json_error( array("error" => "MISSING_SINCE_ID") );
|
59 |
+
}
|
60 |
+
|
61 |
+
// User must have capability to view the history page
|
62 |
+
if ( ! current_user_can( $this->sh->get_view_history_capability() ) ) {
|
63 |
+
wp_send_json_error( array("error" => "CAPABILITY_ERROR") );
|
64 |
}
|
65 |
|
66 |
// $since_id = isset( $_GET["since_id"] ) ? absint($_GET["since_id"]) : null;
|
70 |
$logQuery = new SimpleHistoryLogQuery();
|
71 |
$answer = $logQuery->query( $logQueryArgs );
|
72 |
|
73 |
+
// Use our own response array instead of $answer to keep size down
|
74 |
$json_data = array();
|
75 |
+
|
76 |
$numNewRows = isset( $answer["total_row_count"] ) ? $answer["total_row_count"] : 0;
|
77 |
$json_data["num_new_rows"] = $numNewRows;
|
78 |
$json_data["num_mysql_queries"] = get_num_queries();
|
79 |
|
80 |
if ($numNewRows) {
|
81 |
+
|
82 |
// We have new rows
|
83 |
|
84 |
// Append strings
|
94 |
}
|
95 |
|
96 |
} // class
|
|
inc/SimpleHistory.php
CHANGED
@@ -585,6 +585,11 @@ class SimpleHistory {
|
|
585 |
|
586 |
}
|
587 |
|
|
|
|
|
|
|
|
|
|
|
588 |
if ( isset( $args["id"] ) ) {
|
589 |
$args["post__in"] = array(
|
590 |
$args["id"],
|
585 |
|
586 |
}
|
587 |
|
588 |
+
// User must have capability to view the history page
|
589 |
+
if ( ! current_user_can( $this->get_view_history_capability() ) ) {
|
590 |
+
wp_send_json_error( array("error" => "CAPABILITY_ERROR") );
|
591 |
+
}
|
592 |
+
|
593 |
if ( isset( $args["id"] ) ) {
|
594 |
$args["post__in"] = array(
|
595 |
$args["id"],
|
index.php
CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://simple-history.com
|
|
5 |
Text Domain: simple-history
|
6 |
Domain Path: /languages
|
7 |
Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
|
8 |
-
Version: 2.7.
|
9 |
Author: Pär Thernström
|
10 |
Author URI: http://simple-history.com/
|
11 |
License: GPL2
|
@@ -42,7 +42,7 @@ if ( version_compare( phpversion(), "5.3", ">=") ) {
|
|
42 |
// register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
|
43 |
|
44 |
if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
|
45 |
-
define( 'SIMPLE_HISTORY_VERSION', '2.7.
|
46 |
}
|
47 |
|
48 |
if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
|
5 |
Text Domain: simple-history
|
6 |
Domain Path: /languages
|
7 |
Description: Plugin that logs various things that occur in WordPress and then presents those events in a very nice GUI.
|
8 |
+
Version: 2.7.5
|
9 |
Author: Pär Thernström
|
10 |
Author URI: http://simple-history.com/
|
11 |
License: GPL2
|
42 |
// register_activation_hook( trailingslashit(WP_PLUGIN_DIR) . trailingslashit( plugin_basename(__DIR__) ) . "index.php" , array("SimpleHistory", "on_plugin_activate" ) );
|
43 |
|
44 |
if ( ! defined( 'SIMPLE_HISTORY_VERSION' ) ) {
|
45 |
+
define( 'SIMPLE_HISTORY_VERSION', '2.7.5' );
|
46 |
}
|
47 |
|
48 |
if ( ! defined( 'SIMPLE_HISTORY_PATH' ) ) {
|
loggers/SimpleThemeLogger.php
CHANGED
@@ -82,7 +82,7 @@ class SimpleThemeLogger extends SimpleLogger {
|
|
82 |
|
83 |
add_action("sidebar_admin_setup", array( $this, "on_action_sidebar_admin_setup__detect_widget_delete") );
|
84 |
add_action("sidebar_admin_setup", array( $this, "on_action_sidebar_admin_setup__detect_widget_add") );
|
85 |
-
add_action("wp_ajax_widgets-order", array( $this, "on_action_sidebar_admin_setup__detect_widget_order_change"), 1 );
|
86 |
//add_action("sidebar_admin_setup", array( $this, "on_action_sidebar_admin_setup__detect_widget_edit") );
|
87 |
|
88 |
add_filter( 'widget_update_callback', array( $this, "on_widget_update_callback" ), 10, 4 );
|
@@ -636,7 +636,7 @@ return;
|
|
636 |
|
637 |
// Fallback to default/parent output if nothing was added to output
|
638 |
if ( ! $output ) {
|
639 |
-
|
640 |
$output .= parent::getLogRowPlainTextOutput($row);
|
641 |
|
642 |
}
|
@@ -791,9 +791,9 @@ return;
|
|
791 |
* to many log entries with changed, just confusing.
|
792 |
* need to rethink this
|
793 |
*/
|
|
|
794 |
function on_action_sidebar_admin_setup__detect_widget_order_change() {
|
795 |
|
796 |
-
/*
|
797 |
if ( isset( $_REQUEST["action"] ) && ( $_REQUEST["action"] == "widgets-order" ) ) {
|
798 |
|
799 |
$context = array();
|
@@ -820,9 +820,9 @@ return;
|
|
820 |
);
|
821 |
|
822 |
}
|
823 |
-
*/
|
824 |
|
825 |
}
|
|
|
826 |
|
827 |
/**
|
828 |
* Widget added
|
82 |
|
83 |
add_action("sidebar_admin_setup", array( $this, "on_action_sidebar_admin_setup__detect_widget_delete") );
|
84 |
add_action("sidebar_admin_setup", array( $this, "on_action_sidebar_admin_setup__detect_widget_add") );
|
85 |
+
//add_action("wp_ajax_widgets-order", array( $this, "on_action_sidebar_admin_setup__detect_widget_order_change"), 1 );
|
86 |
//add_action("sidebar_admin_setup", array( $this, "on_action_sidebar_admin_setup__detect_widget_edit") );
|
87 |
|
88 |
add_filter( 'widget_update_callback', array( $this, "on_widget_update_callback" ), 10, 4 );
|
636 |
|
637 |
// Fallback to default/parent output if nothing was added to output
|
638 |
if ( ! $output ) {
|
639 |
+
|
640 |
$output .= parent::getLogRowPlainTextOutput($row);
|
641 |
|
642 |
}
|
791 |
* to many log entries with changed, just confusing.
|
792 |
* need to rethink this
|
793 |
*/
|
794 |
+
/*
|
795 |
function on_action_sidebar_admin_setup__detect_widget_order_change() {
|
796 |
|
|
|
797 |
if ( isset( $_REQUEST["action"] ) && ( $_REQUEST["action"] == "widgets-order" ) ) {
|
798 |
|
799 |
$context = array();
|
820 |
);
|
821 |
|
822 |
}
|
|
|
823 |
|
824 |
}
|
825 |
+
*/
|
826 |
|
827 |
/**
|
828 |
* Widget added
|
loggers/SimpleUserLogger.php
CHANGED
@@ -103,7 +103,9 @@ class SimpleUserLogger extends SimpleLogger {
|
|
103 |
add_action("wp_authenticate_user", array($this, "on_wp_authenticate_user"), 10, 2);
|
104 |
|
105 |
// Failed to login to user that did not exist (perhaps brute force)
|
106 |
-
|
|
|
|
|
107 |
|
108 |
// User is changed
|
109 |
#add_action("profile_update", array($this, "on_profile_update"), 10, 2);
|
@@ -731,31 +733,35 @@ class SimpleUserLogger extends SimpleLogger {
|
|
731 |
/**
|
732 |
* Attempt to login to user that does not exist
|
733 |
*
|
734 |
-
* @param $user (null or WP_User or WP_Error) (required)
|
735 |
-
*
|
|
|
|
|
|
|
736 |
* @param $password The user's password (encrypted)
|
737 |
*/
|
738 |
-
function on_authenticate($user, $username, $password) {
|
739 |
|
740 |
// Don't log empty usernames
|
741 |
-
if ( ! trim($username) ) {
|
742 |
return $user;
|
743 |
}
|
744 |
|
745 |
-
// If
|
746 |
-
if (
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
} else {
|
751 |
-
|
752 |
-
// If username is not a user in the system then this
|
753 |
-
// is consideraded a failed login attempt
|
754 |
-
$wp_user = get_user_by("login", $username);
|
755 |
|
|
|
|
|
|
|
756 |
}
|
757 |
|
758 |
-
|
|
|
|
|
|
|
|
|
759 |
|
760 |
$context = array(
|
761 |
"_initiator" => SimpleLoggerLogInitiators::WEB_USER,
|
103 |
add_action("wp_authenticate_user", array($this, "on_wp_authenticate_user"), 10, 2);
|
104 |
|
105 |
// Failed to login to user that did not exist (perhaps brute force)
|
106 |
+
// run this later than 10 because wordpress own email login check is done with prio 20
|
107 |
+
// so if we run at 10 we just get null
|
108 |
+
add_filter('authenticate', array($this, "on_authenticate"), 30, 3);
|
109 |
|
110 |
// User is changed
|
111 |
#add_action("profile_update", array($this, "on_profile_update"), 10, 2);
|
733 |
/**
|
734 |
* Attempt to login to user that does not exist
|
735 |
*
|
736 |
+
* @param $user (null or WP_User or WP_Error) (required)
|
737 |
+
* null indicates no process has authenticated the user yet.
|
738 |
+
* A WP_Error object indicates another process has failed the authentication.
|
739 |
+
* A WP_User object indicates another process has authenticated the user.
|
740 |
+
* @param $username The user's username. since 4.5.0 `$username` now accepts an email address.
|
741 |
* @param $password The user's password (encrypted)
|
742 |
*/
|
743 |
+
function on_authenticate( $user, $username, $password ) {
|
744 |
|
745 |
// Don't log empty usernames
|
746 |
+
if ( ! trim( $username ) ) {
|
747 |
return $user;
|
748 |
}
|
749 |
|
750 |
+
// If null then no auth done yet. Wierd. But what can we do.
|
751 |
+
if ( is_null( $user ) ) {
|
752 |
+
return $user;
|
753 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
754 |
|
755 |
+
// If auth ok then $user is a wp_user object
|
756 |
+
if ( is_a( $user, 'WP_User' ) ) {
|
757 |
+
return $user;
|
758 |
}
|
759 |
|
760 |
+
// If user is a WP_Error object then auth failed
|
761 |
+
// Error codes can be:
|
762 |
+
// "incorrect_password" | "empty_password" | "invalid_email" | "invalid_username"
|
763 |
+
// We only act on invalid emails and invalid usernames
|
764 |
+
if ( is_a( $user, 'WP_Error' ) && ( $user->get_error_code() == "invalid_username" || $user->get_error_code() == "invalid_email" ) ) {
|
765 |
|
766 |
$context = array(
|
767 |
"_initiator" => SimpleLoggerLogInitiators::WEB_USER,
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://eskapism.se/sida/donate/
|
|
4 |
Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, dashboard, admin, syslog, feed, activity, stream, audit trail, brute-force
|
5 |
Requires at least: 4.5.1
|
6 |
Tested up to: 4.5.2
|
7 |
-
Stable tag: 2.7.
|
8 |
|
9 |
View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
|
10 |
|
@@ -147,7 +147,14 @@ A simple way to see any uncommon activity, for example an increased number of lo
|
|
147 |
|
148 |
## Changelog
|
149 |
|
150 |
-
= 2.7.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
- Log a warning message if a plugin gets disabled automatically by WordPress because of any of these errors: "Plugin file does not exist.", "Invalid plugin path.", "The plugin does not have a valid header."
|
153 |
- Fix warning error if `on_wp_login()` was called without second argument.
|
4 |
Tags: history, log, changes, changelog, audit, trail, pages, attachments, users, dashboard, admin, syslog, feed, activity, stream, audit trail, brute-force
|
5 |
Requires at least: 4.5.1
|
6 |
Tested up to: 4.5.2
|
7 |
+
Stable tag: 2.7.5
|
8 |
|
9 |
View changes made by users within WordPress. See who created a page, uploaded an attachment or approved an comment, and more.
|
10 |
|
147 |
|
148 |
## Changelog
|
149 |
|
150 |
+
= 2.7.5 (August 2016) =
|
151 |
+
|
152 |
+
- User logins using e-mail are now logged correctly. Previously the user would be logged in successfully but the log said that they failed.
|
153 |
+
- Now only users with [`list_users`](https://codex.wordpress.org/Roles_and_Capabilities#list_users) capability can view the users filter and use the autocomplete api for users.
|
154 |
+
- Add labels to search filters. (I do really hate label-less forms so it's kinda very strange that this was not in place before.)
|
155 |
+
- Misc other internal fixes
|
156 |
+
|
157 |
+
= 2.7.4 (July 2016) =
|
158 |
|
159 |
- Log a warning message if a plugin gets disabled automatically by WordPress because of any of these errors: "Plugin file does not exist.", "Invalid plugin path.", "The plugin does not have a valid header."
|
160 |
- Fix warning error if `on_wp_login()` was called without second argument.
|