aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engine/lib/system_log.php21
-rw-r--r--engine/lib/upgrades/2012012000-1.8.3-ip_in_syslog-87fe0f068cf62428.php12
-rw-r--r--mod/logbrowser/languages/en.php1
-rw-r--r--mod/logbrowser/views/default/admin/administer_utilities/logbrowser.php13
-rw-r--r--mod/logbrowser/views/default/forms/logbrowser/refine.php11
-rw-r--r--mod/logbrowser/views/default/logbrowser/table.php10
-rw-r--r--version.php2
7 files changed, 57 insertions, 13 deletions
diff --git a/engine/lib/system_log.php b/engine/lib/system_log.php
index fd5644135..28d90be56 100644
--- a/engine/lib/system_log.php
+++ b/engine/lib/system_log.php
@@ -11,6 +11,7 @@
* Retrieve the system log based on a number of parameters.
*
* @param int|array $by_user The guid(s) of the user(s) who initiated the event.
+ * Use 0 for unowned entries. Anything else falsey means anyone.
* @param string $event The event you are searching on.
* @param string $class The class of object it effects.
* @param string $type The type
@@ -21,11 +22,12 @@
* @param int $timebefore Lower time limit
* @param int $timeafter Upper time limit
* @param int $object_id GUID of an object
- *
+ * @param str $ip_address The IP address.
* @return mixed
*/
function get_system_log($by_user = "", $event = "", $class = "", $type = "", $subtype = "",
-$limit = 10, $offset = 0, $count = false, $timebefore = 0, $timeafter = 0, $object_id = 0) {
+$limit = 10, $offset = 0, $count = false, $timebefore = 0, $timeafter = 0, $object_id = 0,
+$ip_address = false) {
global $CONFIG;
@@ -37,16 +39,18 @@ $limit = 10, $offset = 0, $count = false, $timebefore = 0, $timeafter = 0, $obje
} else {
$by_user = (int)$by_user;
}
+
$event = sanitise_string($event);
$class = sanitise_string($class);
$type = sanitise_string($type);
$subtype = sanitise_string($subtype);
+ $ip_address = sanitise_string($ip_address);
$limit = (int)$limit;
$offset = (int)$offset;
$where = array();
- if ($by_user_orig !== "") {
+ if ($by_user_orig !== "" && $by_user_orig !== false && $by_user_orig !== null) {
if (is_int($by_user)) {
$where[] = "performed_by_guid=$by_user";
} else if (is_array($by_user)) {
@@ -75,6 +79,9 @@ $limit = 10, $offset = 0, $count = false, $timebefore = 0, $timeafter = 0, $obje
if ($object_id) {
$where[] = "object_id = " . ((int) $object_id);
}
+ if ($ip_address) {
+ $where[] = "ip_address = '$ip_address'";
+ }
$select = "*";
if ($count) {
@@ -91,7 +98,8 @@ $limit = 10, $offset = 0, $count = false, $timebefore = 0, $timeafter = 0, $obje
}
if ($count) {
- if ($numrows = get_data_row($query)) {
+ $numrows = get_data_row($query);
+ if ($numrows) {
return $numrows->count;
}
} else {
@@ -171,6 +179,7 @@ function system_log($object, $event) {
$object_subtype = $object->getSubtype();
$event = sanitise_string($event);
$time = time();
+ $ip_address = sanitise_string($_SERVER['REMOTE_ADDR']);
$performed_by = elgg_get_logged_in_user_guid();
if (isset($object->access_id)) {
@@ -194,10 +203,10 @@ function system_log($object, $event) {
if (!isset($log_cache[$time][$object_id][$event])) {
$query = "INSERT DELAYED into {$CONFIG->dbprefix}system_log
(object_id, object_class, object_type, object_subtype, event,
- performed_by_guid, owner_guid, access_id, enabled, time_created)
+ performed_by_guid, owner_guid, access_id, enabled, time_created, ip_address)
VALUES
('$object_id','$object_class','$object_type', '$object_subtype', '$event',
- $performed_by, $owner_guid, $access_id, '$enabled', '$time')";
+ $performed_by, $owner_guid, $access_id, '$enabled', '$time', '$ip_address')";
insert_data($query);
diff --git a/engine/lib/upgrades/2012012000-1.8.3-ip_in_syslog-87fe0f068cf62428.php b/engine/lib/upgrades/2012012000-1.8.3-ip_in_syslog-87fe0f068cf62428.php
new file mode 100644
index 000000000..b9514e156
--- /dev/null
+++ b/engine/lib/upgrades/2012012000-1.8.3-ip_in_syslog-87fe0f068cf62428.php
@@ -0,0 +1,12 @@
+<?php
+/**
+ * Elgg 1.8.3 upgrade 2012012000
+ * ip_in_syslog
+ *
+ * Adds a field for an IP address in the system log table
+ */
+
+$db_prefix = elgg_get_config('dbprefix');
+$q = "ALTER TABLE {$db_prefix}system_log ADD ip_address VARCHAR(15) NOT NULL AFTER time_created";
+
+update_data($q); \ No newline at end of file
diff --git a/mod/logbrowser/languages/en.php b/mod/logbrowser/languages/en.php
index 3b6ead272..f36b4bc6b 100644
--- a/mod/logbrowser/languages/en.php
+++ b/mod/logbrowser/languages/en.php
@@ -17,6 +17,7 @@ $english = array(
'logbrowser:explore' => 'Explore log',
'logbrowser:date' => 'Date and time',
+ 'logbrowser:ip_address' => 'IP address',
'logbrowser:user:name' => 'User',
'logbrowser:user:guid' => 'User GUID',
'logbrowser:object' => 'Object type',
diff --git a/mod/logbrowser/views/default/admin/administer_utilities/logbrowser.php b/mod/logbrowser/views/default/admin/administer_utilities/logbrowser.php
index a04ef686a..89894e3d2 100644
--- a/mod/logbrowser/views/default/admin/administer_utilities/logbrowser.php
+++ b/mod/logbrowser/views/default/admin/administer_utilities/logbrowser.php
@@ -12,11 +12,12 @@ $offset = get_input('offset');
$search_username = get_input('search_username');
if ($search_username) {
- if ($user = get_user_by_username($search_username)) {
+ $user = get_user_by_username($search_username);
+ if ($user) {
$user_guid = $user->guid;
}
} else {
- $user_guid = get_input('user_guid',0);
+ $user_guid = get_input('user_guid', null);
if ($user_guid) {
$user_guid = (int) $user_guid;
} else {
@@ -34,6 +35,8 @@ if ($timeupper) {
$timeupper = strtotime($timeupper);
}
+$ip_address = get_input('ip_address');
+
$refine = elgg_view('logbrowser/refine', array(
'user_guid' => $user_guid,
'timeupper' => $timeupper,
@@ -41,8 +44,10 @@ $refine = elgg_view('logbrowser/refine', array(
));
// Get log entries
-$log = get_system_log($user_guid, "", "", "","", $limit, $offset, false, $timeupper, $timelower);
-$count = get_system_log($user_guid, "", "", "","", $limit, $offset, true, $timeupper, $timelower);
+$log = get_system_log($user_guid, "", "", "","", $limit, $offset, false, $timeupper, $timelower,
+ 0, $ip_address);
+$count = get_system_log($user_guid, "", "", "","", $limit, $offset, true, $timeupper, $timelower,
+ 0, $ip_address);
$table = elgg_view('logbrowser/table', array('log_entries' => $log));
diff --git a/mod/logbrowser/views/default/forms/logbrowser/refine.php b/mod/logbrowser/views/default/forms/logbrowser/refine.php
index ff3f48b03..6ec5907b6 100644
--- a/mod/logbrowser/views/default/forms/logbrowser/refine.php
+++ b/mod/logbrowser/views/default/forms/logbrowser/refine.php
@@ -19,13 +19,14 @@ if (isset($vars['timeupper'])) {
$upperval = "";
}
if (isset($vars['user_guid'])) {
- if ($user = get_entity($vars['user_guid'])) {
+ $user = get_entity($vars['user_guid']);
+ if ($user) {
$userval = $user->username;
}
} else {
$userval = "";
}
-
+$ip_address = elgg_extract('ip_address', '');
$form = "<div>" . elgg_echo('logbrowser:user');
$form .= elgg_view('input/text', array(
@@ -33,6 +34,12 @@ $form .= elgg_view('input/text', array(
'value' => $userval,
)) . "</div>";
+$form .= "<div>" . elgg_echo('logbrowser:ip_address');
+$form .= elgg_view('input/text', array(
+ 'name' => 'ip_address',
+ 'value' => $ip_address,
+)) . "</div>";
+
$form .= "<div>" . elgg_echo('logbrowser:starttime');
$form .= elgg_view('input/text', array(
'name' => 'timelower',
diff --git a/mod/logbrowser/views/default/logbrowser/table.php b/mod/logbrowser/views/default/logbrowser/table.php
index b7f6a1f20..9a867e080 100644
--- a/mod/logbrowser/views/default/logbrowser/table.php
+++ b/mod/logbrowser/views/default/logbrowser/table.php
@@ -11,6 +11,7 @@ $log_entries = $vars['log_entries'];
<table class="elgg-table">
<tr>
<th><?php echo elgg_echo('logbrowser:date'); ?></th>
+ <th><?php echo elgg_echo('logbrowser:ip_address'); ?></th>
<th><?php echo elgg_echo('logbrowser:user:name'); ?></th>
<th><?php echo elgg_echo('logbrowser:user:guid'); ?></th>
<th><?php echo elgg_echo('logbrowser:object'); ?></th>
@@ -20,6 +21,12 @@ $log_entries = $vars['log_entries'];
<?php
$alt = '';
foreach ($log_entries as $entry) {
+ if ($entry->ip_address) {
+ $ip_address = $entry->ip_address;
+ } else {
+ $ip_address = '&nbsp;';
+ }
+
$user = get_entity($entry->performed_by_guid);
if ($user) {
$user_link = elgg_view('output/url', array(
@@ -51,6 +58,9 @@ $log_entries = $vars['log_entries'];
<td class="log-entry-time">
<?php echo date('r', $entry->time_created); ?>
</td>
+ <td class="log-entry-ip-address">
+ <?php echo $ip_address; ?>
+ </td>
<td class="log-entry-user">
<?php echo $user_link; ?>
</td>
diff --git a/version.php b/version.php
index c491e06ce..540fecac6 100644
--- a/version.php
+++ b/version.php
@@ -11,7 +11,7 @@
// YYYYMMDD = Elgg Date
// XX = Interim incrementer
-$version = 2011123101;
+$version = 2012012000;
// Human-friendly version name
$release = '1.8.3';