summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Brill <egore911@gmail.com>2017-08-22 21:57:11 +0200
committerChristoph Brill <egore911@gmail.com>2017-08-22 22:23:18 +0200
commitd03339897ef70346d29377951c105ff2ad24d6d1 (patch)
tree713e87a1fb184f3f90b20dfbd9a657275126d7af
parent3ec4c7d8be4a6f0787003e1b0e3ba122e93c5b56 (diff)
Improve username detection to capture pipe symbols
-rw-r--r--common.inc.php2
-rw-r--r--details.php4
-rwxr-xr-xindex.php4
-rw-r--r--js/script.js13
4 files changed, 12 insertions, 11 deletions
diff --git a/common.inc.php b/common.inc.php
index e8eb4fa..ba0c0ba 100644
--- a/common.inc.php
+++ b/common.inc.php
@@ -120,7 +120,7 @@ function filterJoin($line)
function getUser($line)
{
$result = array();
- if (preg_match('=(<.|\* )[a-zA-Z0-9_`\]\[\^-]+(>| )=', $line, $result)) {
+ if (preg_match('=(<.|\* )[a-zA-Z0-9\|_`\]\[\^-]+(>| )=', $line, $result)) {
return $result[0];
}
return '';
diff --git a/details.php b/details.php
index 5919fc8..11e277f 100644
--- a/details.php
+++ b/details.php
@@ -47,7 +47,7 @@ foreach ($lines as $line_num => $line) {
$anything_displayed = true;
$user = htmlentities($user, ENT_QUOTES);
$time = getTime($line);
- echo '<span class="user_'.$user_clean.'">';
+ echo '<span class="user_'.str_replace('|', '_', $user_clean).'">';
$line = htmlentities($line, ENT_QUOTES);
if ($show_html == 'true') {
$line = preg_replace($pattern, "\\1<a target=\"_blank\" href=\"\\2\\3\">\\2\\3</a>\\4", $line);
@@ -74,4 +74,4 @@ foreach ($lines as $line_num => $line) {
if (!$anything_displayed) {
echo 'No logs found';
-} \ No newline at end of file
+}
diff --git a/index.php b/index.php
index 3a7a02a..17478d9 100755
--- a/index.php
+++ b/index.php
@@ -93,7 +93,7 @@ if (isset($date)) {
if (count($users) > 0) {
echo ' <style type="text/css">'.PHP_EOL;
foreach ($users as $user) {
- echo ' span.user_'.$user.' { '.get_color($user).'; }'.PHP_EOL;
+ echo ' span.user_'.str_replace('|', '_', $user).' { '.get_color($user).'; }'.PHP_EOL;
}
echo ' </style>'.PHP_EOL;
}
@@ -145,7 +145,7 @@ if (isset($date)) {
<span class="caret"></span></a>
<ul class="dropdown-menu" id="usernames">'.PHP_EOL;
foreach ($users as $user) {
- echo ' <li id="user_'.$user.'"><span class="checkbox user_'.$user.'"><a href="javascript:addUser(\''.$user.'\');">'.$user.'</a></span></li>'.PHP_EOL;
+ echo ' <li id="user_'.$user.'"><span class="checkbox user_'.str_replace('|', '_', $user).'"><a href="javascript:addUser(\''.$user.'\');">'.$user.'</a></span></li>'.PHP_EOL;
}
echo ' </ul>
</li>
diff --git a/js/script.js b/js/script.js
index 37786dc..7cb80aa 100644
--- a/js/script.js
+++ b/js/script.js
@@ -1,6 +1,7 @@
function addUser(username) {
var colorlist = document.getElementById('usernames');
+ var username_clean = username.replace('|', '_')
// The user was already in the list
if (document.mainform.highlight_names.value.indexOf(username) >= 0) {
@@ -17,14 +18,14 @@ function addUser(username) {
for (var k = 0; k < document.styleSheets.length; k++) {
var rules = document.styleSheets[k].cssRules || document.styleSheets[k].rules;
for (var x = 0; x < rules.length; x++) {
- if (rules[x].selectorText == ('span.user_' + username)) {
+ if (rules[x].selectorText == ('span.user_' + username_clean)) {
rules[x].style.color = '';
}
}
}
// Now drop the username from the colorlist
- colorlist.removeChild(document.getElementById('user_' + username));
+ colorlist.removeChild(document.getElementById('user_' + username_clean));
} else {
@@ -38,18 +39,18 @@ function addUser(username) {
var color = CryptoJS.SHA1(username).toString().substr(0, 6);
var styleSheet = document.styleSheets[0];
if (styleSheet.addRule) {
- styleSheet.addRule('span.user_' + username , 'color: #' + color, 0);
+ styleSheet.addRule('span.user_' + username_clean, 'color: #' + color, 0);
} else if (styleSheet.insertRule) {
- styleSheet.insertRule('span.user_' + username + ' { color: #' + color + '; }', 0);
+ styleSheet.insertRule('span.user_' + username_clean + ' { color: #' + color + '; }', 0);
} else {
document.mainform.submit();
}
// Now add the username to the colorlist
var listelement = document.createElement('li');
- listelement.setAttribute('id', 'user_' + username);
+ listelement.setAttribute('id', 'user_' + username_clean);
var spanelement = document.createElement('span');
- spanelement.setAttribute('class', 'checkbox user_' + username);
+ spanelement.setAttribute('class', 'checkbox user_' + username_clean);
listelement.appendChild(spanelement);
spanelement.innerHTML = '<a href="javascript:addUser(\'' + username + '\');">' + username + '</a>';
colorlist.appendChild(listelement);