So that every user can have a different restriction filter,
using the same syntax of search filter, that can be set up
to let him see only the desired log messages.
---
src/admin/users.php | 18 +++++++++++++-----
src/classes/logstream.class.php | 3 +++
src/include/db_template.txt | 1 +
src/include/db_update_v11.txt | 6 ++++++
src/include/functions_users.php | 9 ++++++++-
src/lang/en/admin.php | 1 +
src/templates/admin/admin_users.html | 12 +++++++++---
7 files changed, 41 insertions(+), 9 deletions(-)
create mode 100644 src/include/db_update_v11.txt
diff --git a/src/admin/users.php b/src/admin/users.php
index a10fa15..d5aa690 100644
--- a/src/admin/users.php
+++ b/src/admin/users.php
@@ -175,6 +175,7 @@ if ( isset($_GET['op']) )
$content['USERNAME'] = "";
$content['PASSWORD1'] = "";
$content['PASSWORD2'] = "";
+ $content['RESTRICTION_FILTER'] = "";
}
else if ($_GET['op'] == "edit")
{
@@ -210,6 +211,8 @@ if ( isset($_GET['op']) )
$content['CHECKED_ISREADONLY'] =
"checked";
else
$content['CHECKED_ISREADONLY'] = "";
+
+ $content['RESTRICTION_FILTER'] =
$myuser['restriction_filter'];
}
else
{
@@ -291,6 +294,7 @@ if ( isset($_POST['op']) )
if ( isset ($_POST['password2']) ) { $content['PASSWORD2'] =
DB_RemoveBadChars($_POST['password2']); } else {$content['PASSWORD2'] = ""; }
if ( isset ($_POST['isadmin']) ) { $content['ISADMIN'] = 1; } else
{$content['ISADMIN'] = 0; }
if ( isset ($_POST['isreadonly']) ) { $content['ISREADONLY'] = 1; }
else {$content['ISREADONLY'] = 0; }
+ if ( isset ($_POST['restriction_filter']) ) {
$content['RESTRICTION_FILTER'] =
DB_RemoveBadChars($_POST['restriction_filter']); } else
{$content['RESTRICTION_FILTER'] = ""; }
// Check mandotary values
if ( $content['USERNAME'] == "" )
@@ -327,11 +331,12 @@ if ( isset($_POST['op']) )
$content['PASSWORDHASH'] = md5(
$content['PASSWORD1'] );
// Add new User now!
- $result = DB_Query("INSERT INTO " .
DB_USERS . " (username, password, is_admin, is_readonly)
+ $result = DB_Query("INSERT INTO " .
DB_USERS . " (username, password, is_admin, is_readonly, restriction_filter)
VALUES ('" . $content['USERNAME'] . "',
'" .
$content['PASSWORDHASH'] . "',
" . $content['ISADMIN']
. ",
- " .
$content['ISREADONLY'] . ")");
+ " .
$content['ISREADONLY'] . ",
+ '" .
$content['RESTRICTION_FILTER'] . "')");
DB_FreeQuery($result);
// Do the final redirect
@@ -370,7 +375,8 @@ if ( isset($_POST['op']) )
username = '" .
$content['USERNAME'] . "',
password = '" .
$content['PASSWORDHASH'] . "',
is_admin = " .
$content['ISADMIN'] . ",
- is_readonly = " .
$content['ISREADONLY'] . "
+ is_readonly = " .
$content['ISREADONLY'] . ",
+ restriction_filter = '"
. $content['RESTRICTION_FILTER'] . "'
WHERE ID = " .
$content['USERID']);
DB_FreeQuery($result);
}
@@ -381,7 +387,8 @@ if ( isset($_POST['op']) )
$result = DB_Query("UPDATE " . DB_USERS
. " SET
username = '" .
$content['USERNAME'] . "',
is_admin = " .
$content['ISADMIN'] . ",
- is_readonly = " .
$content['ISREADONLY'] . "
+ is_readonly = " .
$content['ISREADONLY'] . ",
+ restriction_filter = '" .
$content['RESTRICTION_FILTER'] . "'
WHERE ID = " .
$content['USERID']);
DB_FreeQuery($result);
}
@@ -408,7 +415,8 @@ if ( !isset($_POST['op']) && !isset($_GET['op']) )
$sqlquery = "SELECT ID, " .
" username, " .
" is_admin, " .
- " is_readonly " .
+ " is_readonly, " .
+ " restriction_filter " .
" FROM " . DB_USERS .
" ORDER BY ID ";
$result = DB_Query($sqlquery);
diff --git a/src/classes/logstream.class.php b/src/classes/logstream.class.php
index 73d2da7..72da200 100644
--- a/src/classes/logstream.class.php
+++ b/src/classes/logstream.class.php
@@ -334,6 +334,9 @@ abstract class LogStream {
*/
public function SetFilter($szFilters)
{
+ global $content;
+ $szFilters = $szFilters . " " .
$content['SESSION_RESTRICTION_FILTER'];
+
// prepend default Filters
if ( strlen($this->_logStreamConfigObj->_defaultfilter) > 0 )
$finalfilters =
$this->_logStreamConfigObj->_defaultfilter . " " . $szFilters;
diff --git a/src/include/db_template.txt b/src/include/db_template.txt
index 7d18128..bdf12dc 100644
--- a/src/include/db_template.txt
+++ b/src/include/db_template.txt
@@ -98,6 +98,7 @@ CREATE TABLE IF NOT EXISTS `logcon_users` (
`password` varchar(32) NOT NULL,
`is_admin` tinyint(1) NOT NULL default '0',
`is_readonly` tinyint(1) NOT NULL DEFAULT '0',
+ `restriction_filter` VARCHAR(1024) NOT NULL,
`last_login` int(4) NOT NULL,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Table for the phplogcon
users' AUTO_INCREMENT=1 ;
diff --git a/src/include/db_update_v11.txt b/src/include/db_update_v11.txt
new file mode 100644
index 0000000..57255e9
--- /dev/null
+++ b/src/include/db_update_v11.txt
@@ -0,0 +1,6 @@
+-- New Database Structure Updates
+ALTER TABLE `logcon_users` ADD `restriction_filter` VARCHAR( 1024 ) NOT NULL
AFTER `is_readonly` ;
+
+-- Insert data
+
+-- Updated Data
diff --git a/src/include/functions_users.php b/src/include/functions_users.php
index f2f4dc3..21cd7d1 100644
--- a/src/include/functions_users.php
+++ b/src/include/functions_users.php
@@ -82,6 +82,10 @@ function InitUserSession()
$content['SESSION_USERID'] =
$_SESSION['SESSION_USERID'];
$content['SESSION_ISADMIN'] =
$_SESSION['SESSION_ISADMIN'];
$content['SESSION_ISREADONLY'] =
$_SESSION['SESSION_ISREADONLY'];
+ if ( isset($_SESSION['SESSION_RESTRICTION_FILTER']) )
+ $content['SESSION_RESTRICTION_FILTER'] =
$_SESSION['SESSION_RESTRICTION_FILTER'];
+ else
+ $content['SESSION_RESTRICTION_FILTER'] = "";
if ( isset($_SESSION['SESSION_GROUPIDS']) )
$content['SESSION_GROUPIDS'] =
$_SESSION['SESSION_GROUPIDS'];
@@ -191,12 +195,14 @@ function CheckUserLogin( $username, $password )
$_SESSION['SESSION_ISREADONLY'] = $myrow['is_readonly'];
else
$_SESSION['SESSION_ISREADONLY'] = false;
+ $_SESSION['SESSION_RESTRICTION_FILTER'] =
$myrow['restriction_filter'];
$content['SESSION_LOGGEDIN'] = $_SESSION['SESSION_LOGGEDIN'];
$content['SESSION_USERNAME'] = $_SESSION['SESSION_USERNAME'];
$content['SESSION_USERID'] = $_SESSION['SESSION_USERID'];
$content['SESSION_ISADMIN'] = $_SESSION['SESSION_ISADMIN'];
$content['SESSION_ISREADONLY'] =
$_SESSION['SESSION_ISREADONLY'];
+ $content['SESSION_RESTRICTION_FILTER'] =
$_SESSION['SESSION_RESTRICTION_FILTER'];
// --- Read Groupmember ship for the user!
$sqlquery = "SELECT " .
@@ -395,7 +401,7 @@ function CheckLDAPUserLogin( $username, $password )
if (!isset($myrow['is_admin']) )
{
// Create User | use password to create MD5 Hash, so
technically the user could login without LDAP as well
- $sqlcmd = "INSERT INTO `" . DB_USERS . "` (username, password,
is_admin, is_readonly) VALUES ('" . $username . "', '" . $md5pass . "', 0, 1)";
+ $sqlcmd = "INSERT INTO `" . DB_USERS . "` (username, password,
is_admin, is_readonly, restriction_filter) VALUES ('" . $username . "', '" .
$md5pass . "', 0, 1, '')";
$result = DB_Query($sqlcmd);
DB_FreeQuery($result);
@@ -414,6 +420,7 @@ function CheckLDAPUserLogin( $username, $password )
$myrowfinal['ID'] = DB_ReturnLastInsertID(); // Get from
last insert!
$myrowfinal['is_admin'] = $myrow['is_admin'];
$myrowfinal['is_readonly'] = $myrow['is_readonly'];
+ $myrowfinal['restriction_filter'] = $restriction_filter;
$myrowfinal['last_login'] = $myrow['last_login'];
return $myrowfinal;
diff --git a/src/lang/en/admin.php b/src/lang/en/admin.php
index cd4421a..db9362c 100644
--- a/src/lang/en/admin.php
+++ b/src/lang/en/admin.php
@@ -126,6 +126,7 @@ $content['LN_USER_EDIT'] = "Edit User";
$content['LN_USER_DELETE'] = "Delete User";
$content['LN_USER_PASSWORD1'] = "Password";
$content['LN_USER_PASSWORD2'] = "Confirm Password";
+$content['LN_USER_RESTRICTION_FILTER'] = "Search Filter";
$content['LN_USER_ERROR_IDNOTFOUND'] = "Error, User with ID '%1' , was not
found";
$content['LN_USER_ERROR_DONOTDELURSLF'] = "Error, you can not DELETE
YOURSELF!";
$content['LN_USER_ERROR_DELUSER'] = "Deleting of the user with id '%1'
failed!";
diff --git a/src/templates/admin/admin_users.html
b/src/templates/admin/admin_users.html
index 7ab4061..76af1ba 100644
--- a/src/templates/admin/admin_users.html
+++ b/src/templates/admin/admin_users.html
@@ -25,9 +25,10 @@
<table border="0" cellpadding="2" cellspacing="1"
bgcolor="#DDDDDD" width="80%" class="with_border_alternate">
<tr>
<td align="center" width="10%"
class="cellmenu1"><b>{LN_USER_ID}</b></td>
- <td align="center" width="40%"
class="cellmenu1"><b>{LN_USER_NAME}</b></td>
- <td align="center" width="15%"
class="cellmenu1"><b>{LN_USER_ISADMIN}</b></td>
- <td align="center" width="15%"
class="cellmenu1"><b>{LN_USER_ISREADONLY}</b></td>
+ <td align="center" width="25%"
class="cellmenu1"><b>{LN_USER_NAME}</b></td>
+ <td align="center" width="10%"
class="cellmenu1"><b>{LN_USER_ISADMIN}</b></td>
+ <td align="center" width="10%"
class="cellmenu1"><b>{LN_USER_ISREADONLY}</b></td>
+ <td align="center" width="25%"
class="cellmenu1"><b>{LN_USER_RESTRICTION_FILTER}</b></td>
<td align="center" width="20%"
class="cellmenu1"><b>{LN_GEN_ACTIONS}</b></td>
</tr>
<!-- BEGIN USERS -->
@@ -36,6 +37,7 @@
<td align="center" class="{cssclass}"><a
href="{BASEPATH}admin/users.php?op=edit&id={ID}">{username}</a></td>
<td align="center" class="{cssclass}"><a
href="{BASEPATH}admin/users.php?miniop=setisadmin&id={ID}&newval={set_isadmin}"><img
src="{is_isadmin_string}" width="16" title="{LN_USER_SETISADMIN}"></a></td>
<td align="center" class="{cssclass}"><a
href="{BASEPATH}admin/users.php?miniop=setisreadonly&id={ID}&newval={set_isreadonly}"><img
src="{is_readonly_string}" width="16" title="{LN_USER_SETISREADONLY}"></a></td>
+ <td align="center" class="{cssclass}"><a
href="{BASEPATH}admin/users.php?op=edit&id={ID}">{restriction_filter}</a></td>
<td align="center" class="{cssclass}">
<a
href="{BASEPATH}admin/users.php?op=edit&id={ID}"><img src="{MENU_EDIT}"
width="16" title="{LN_USER_EDIT}"></a>
<a
href="{BASEPATH}admin/users.php?op=delete&id={ID}"><img src="{MENU_DELETE}"
width="16" title="{LN_USER_DELETE}"></a>
@@ -77,6 +79,10 @@
<td align="left" class="line1"><input
type="checkbox" name="isreadonly" value="yes" {CHECKED_ISREADONLY}></td>
</tr>
<tr>
+ <td align="left" class="cellmenu2" width="30%"
nowrap><b>{LN_USER_RESTRICTION_FILTER}</b></td>
+ <td align="left" class="line0"
width="70%"><input type="text" name="restriction_filter" size="40"
maxlength="1024" value="{RESTRICTION_FILTER}" class="maxwidth"></td>
+ </tr>
+ <tr>
<td align="center" colspan="2">
<input type="submit"
value="{USER_SENDBUTTON}">
<input type="hidden" name="op"
value="{USER_FORMACTION}">
--
2.1.0
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE
THAT.