summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dc32a93)
raw | patch | inline | side by side (parent: dc32a93)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 17 Jan 2008 08:23:21 +0000 (08:23 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 17 Jan 2008 08:23:21 +0000 (08:23 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8428 594d385d-05f5-0310-b6e9-bd551577e9d8
12 files changed:
diff --git a/gosa-core/plugins/addons/logview/class_gosa_logview.inc b/gosa-core/plugins/addons/logview/class_gosa_logview.inc
+++ /dev/null
@@ -1,400 +0,0 @@
-<?php
-
-class gosa_logview extends plugin
-{
- /* Definitions */
- var $plHeadline= "System logs";
- var $plDescription= "This does something";
-
- /* attribute list for save action */
- var $attributes = array();
- var $objectclasses = array();
-
- var $server = "";
- var $action = "modify";
- var $time = 2;
- var $regex = "*";
-
- var $start = 0;
- var $sort = 1;
-
- var $sort_direction = "down";
- var $fields = array("action","timestamp","user","objecttype","object","result","repeated");
- var $range = 25;
- var $view_logged = FALSE;
-
- var $timezone_offset = 0;
-
- var $uid_map = array();
-
-
- function gosa_logview (&$config, $dn= NULL)
- {
- /* Include config object */
- $this->config= &$config;
- $this->ui = get_userinfo();
-
- /* Restore last filter settings */
- $logview = session::get('logview');
- foreach(array("action","server","time","regex") as $attr){
- if(isset($logview['gosa_log'][$attr])){
- $this->$attr = $logview['gosa_log'][$attr];
- }
- }
-
- $tz = timezone::get_default_timezone();
- $this->timezone_offset = $tz['value'] * 60 * 60 ;
-
- $ldap = $this->config->get_ldap_link();
- $ldap->search("(&(objectClass=person)(uid=*))",array("uid","dn"));
- while($attrs = $ldap->fetch()){
- $this->uid_map[$attrs['dn']] = $attrs['uid'][0];
- }
- }
-
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Log view */
- if(!$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","logview/".get_class($this),$this->dn);
- }
-
- /* Time interval */
- $date_select = array(
- "0" => _("one hour"), "1" => _("6 hours"),
- "2" => _("12 hours"), "3" => _("24 hours"),
- "4" => _("2 days"), "5" => _("one week"),
- "6" => _("2 weeks"), "7" => _("one month"));
-
-
- $time = time();
- $date_select_ = array(
- "0" => $time - 3600,
- "1" => $time - 21600,
- "2" => $time - 43200,
- "3" => $time - 86400,
- "4" => $time - 172800,
- "5" => $time - 604800,
- "6" => $time - 1209600,
- "7" => $time - 2419200);
-
- $smarty= get_smarty();
- $smarty->assign("search_result", "");
- $smarty->assign("plug", "?plug=".validate($_GET['plug']));
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("time_image", get_template_path('images/time.png'));
- $smarty->assign("server_image", get_template_path('images/server.png'));
- $smarty->assign("log_image", get_template_path('images/log_warning.png'));
- $smarty->assign("ruleset_image", get_template_path('images/edit.png'));
- $smarty->assign("launchimage", get_template_path('images/launch.png'));
- $smarty->assign("date_select", $date_select);
- $smarty->assign("actions", array());
- $smarty->assign("direction", "up");
- $smarty->assign("mode0", "");
- $smarty->assign("mode1", "");
- $smarty->assign("mode2", "");
- $smarty->assign("mode3", "");
- $smarty->assign("mode4", "");
- $smarty->assign("mode5", "");
- $smarty->assign("mode6", "");
-
- /* Assign select option content */
- foreach( array("server", "action", "time", "regex") as $type){
- $smarty->assign("$type", $this->$type);
- }
-
- /****
- * Check if defined servers
- * and mysql extension
- ****/
- if (!isset($this->config->data['SERVERS']['LOGGING']) || !count($this->config->data['SERVERS']['LOGGING'])){
- msg_dialog::display(_("Warning"), sprintf(_("No %s servers defined!"), "GOsa log"), WARNING_DIALOG);
- return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
- }
-
- if(!is_callable("mysql_connect")){
- msg_dialog::display(_("Configuration error"), sprintf(_("Missing %s PHP extension!"), "mysql"), WARNING_DIALOG);
- return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
- }
-
- /****
- * Get Configurations
- ****/
- $list_of_servers = $this->config->data['SERVERS']['LOGGING'];
- $servers = array();
- foreach($list_of_servers as $servername => $data){
- $servers[$servername] = $servername;
- }
- $smarty->assign("servers", $servers);
-
- /* Set a default server, if there is currently no valid server selected */
- if(empty($this->server) || !in_array($this->server,$servers)){
- $this->server = key($servers);
- }
-
- /****
- * Connect to currently selected server
- ****/
- $cfg = $list_of_servers[$this->server];
- $link = @mysql_pconnect($this->server, $cfg['USER'], $cfg['PWD']);
- if ($link === FALSE){
- msg_dialog::display(_("Error"), sprintf(_("Cannot connect to %s database!"), "GOsa LOG"), ERROR_DIALOG);
- new log("debug","logview","",array(),@mysql_error());
- return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
- }
-
- /* check of log database is available */
- if (! @mysql_select_db($cfg['DB'])){
- msg_dialog::display(_("Error"), sprintf(_("Cannot select %s database!"), "GOsa LOG"), ERROR_DIALOG);
- new log("debug","logview","",array(),@mysql_error());
- return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
- }
-
-
- /****
- * Get all action types
- ****/
-
- $actions = array("!ALL" => _("All"));
- $query = "SELECT distinct(action) FROM gosa_log;";
- $res = @mysql_query($query);
- while($attrs = @mysql_fetch_assoc($res)){
- $actions[$attrs['action']] = $attrs['action'];
- }
-
-
- /****
- * Check Acls
- ****/
-
- $ui = get_userinfo();
- $dn = $list_of_servers[$this->server]['DN'];
- $acls = $ui->get_permissions($dn,"server/gosaLogServer","viewEntries");
-
- if(!preg_match("/r/",$acls)){
- $res = "<tr>
- <td colspan=".count($this->fields).">
- "._("You have insufficient permissions to view syslog entries.")."
- </td>
- </tr>";
-
- /* Show main page */
- $smarty->assign("range_selector", "");
- $smarty->assign("search_result", $res);
- return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
- }
-
-
- /****
- * Query stuff
- ****/
- $res= "";
- $cfg = $list_of_servers[$this->server];
- $link = @mysql_pconnect($this->server, $cfg['USER'], $cfg['PWD']);
-
- /* Test connection object && create up query string */
- if ($link === FALSE){
- msg_dialog::display(_("Error"), sprintf(_("Cannot connect to %s database!"), "GOsa LOG"), ERROR_DIALOG);
- new log("debug","logview","",array(),@mysql_error());
- } else {
-
- if (! @mysql_select_db($cfg['DB'])){
- msg_dialog::display(_("Error"), sprintf(_("Cannot select %s database!"), "GOsa LOG"), ERROR_DIALOG);
- new log("debug","logview","",array(),@mysql_error());
- } else {
-
- /* Prepare order setting */
- if ($this->sort_direction == "down"){
- $desc= "DESC";
- $sort_sign = "<img src='images/sort_down.png' alt='\/' class='center' title='down' border=0>";
- } else {
- $desc= "";
- $sort_sign = "<img src='images/sort_up.png' alt='/\' class='center' title='up' border=0>";
- }
-
- /* Get start time */
- $start = $date_select_[$this->time];
-
- /* Prepare search filter */
- $sql_regex =trim(preg_replace("/\*/","%",$this->regex));
- $sql_regex = "%".trim($sql_regex,"%")."%";
-
- /* Create search filter */
- $query_base= "FROM gosa_log WHERE timestamp >= $start ";
-
- /* Append action filter */
- if($this->action != "!ALL"){
- $query_base .=" AND action like '".$this->action."' ";
- }
-
- /* Append search filter */
- if($sql_regex != "%%"){
- $query_base .=" AND ( result like '".$sql_regex."' OR user like '".$sql_regex."') ";
- }
-
- /* Get number of entries */
- $query= "SELECT COUNT(`user`) ".$query_base.";";
- $result = mysql_query($query);
- if(!$result){
- new log("debug","logview","",array(),@mysql_error());
- }
- $line= mysql_fetch_array($result, MYSQL_ASSOC);
- $count= $line['COUNT(`user`)'];
- if ($count > 25){
- $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"EntriesPerPage"));
- } else {
- $smarty->assign("range_selector", "");
- }
-
- /* Query results that will be displayed */
- $query= "SELECT * ".$query_base." ORDER BY ".$this->fields[$this->sort]." ".$desc." LIMIT ".$this->start.",".$this->range.";";
- @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query");
- $result = @mysql_query($query);
- if(!$result){
- new log("debug","logview","",array(),@mysql_error());
- }
-
- /* Display results */
- $mod= 0;
-
- /* Add entries to result str */
- while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){
-
- /* Toggle background color */
- if ( ($mod++) & 1){
- $col= "background-color: #ECECEC;";
- } else {
- $col= "background-color: #F5F5F5;";
- }
-
- $base = ", ".substr($this->config->current['BASE'],0,5)."...";
-
- if(isset($this->uid_map[$line['user']])){
- $user = $this->uid_map[$line['user']];
- }else{
- $user = preg_replace("/,".normalizePreg($this->config->current['BASE'])."/",$base,$line['user']);
- }
- $object = preg_replace("/,".normalizePreg($this->config->current['BASE'])."/",$base,$line['object']);
-
- $res.=" <tr style=\"$col\">\n";
- $res.=" <td title='".$line['objecttype']."'>".$line['action']."</td>";
- $res.=" <td>".date("H:i:s d.m.Y",($line['timestamp'] + $this->timezone_offset))."</td>";
- $res.=" <td title='".$line['user']."'>".preg_replace("/,/",", ",$user)."</td>";
- $res.=" <td title='".$line['objecttype']."'>".$line['objecttype']."</td>";
- $res.=" <td title='".$line['object']."'>".preg_replace("/,/",", ",$object)."</td>";
- $res.=" <td>".$line['result']."</td>";
-# if($line['repeated'] == 1){
-# $res.=" <td>-</td>";
-# }else{
-# $res.=" <td>".($line['repeated']-1)."</td>";
-# }
- $res.=" </tr>\n";
- }
- mysql_close($link);
- $smarty->assign("mode".$this->sort, $sort_sign);
- $smarty->assign("search_result", $res);
- }
- }
-
- $smarty->assign("regex", $this->regex);
- $smarty->assign("server",$this->server);
- $smarty->assign("servers",$servers);
- $smarty->assign("action",$this->action);
- $smarty->assign("actions",$actions);
- $smarty->assign("date_select", $date_select);
-
- $smarty->assign("direction", $this->sort_direction);
-
- /* Show main page */
- return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
- }
-
-
- function save_object()
- {
- if(isset($_POST['gosa_log_contents_posted'])){
-
- /* Get submitted range */
- if(isset($_POST['EntriesPerPage'])){
- if(is_numeric($_POST['EntriesPerPage'])){
- $this->range = $_POST['EntriesPerPage'];
- }
- }
-
- /* Get actual select boxe values */
- $logfilter_changed = FALSE;
- foreach( array("server", "action","time","regex") as $type){
- if(isset($_POST[$type])){
- $this->$type = $_POST[$type];
- }
- }
-
- /* Filter regex values */
- if ($this->regex == ""){
- $this->regex= '*';
- } else {
- $new = preg_replace('/\*\**/', '*', $this->regex);
- $this->regex= $new;
- }
-
- /* Set start value */
- if (isset($_GET['start'])){
- $this->start= (int)$_GET['start'];
- }
-
- /* Reset page number if filter has changed */
- if ($logfilter_changed > 0){
- $this->start= 0;
- }
-
- /* Adapt sorting */
- if (isset($_GET['sort'])){
-
- if($_GET['direction'] == "up"){
- $this->sort_direction = "down";
- }else{
- $this->sort_direction = "up";
- }
-
- $this->sort= (int)$_GET['sort'];
- if ($this->sort < 0 || $this->sort > count($this->fields)){
- $this->sort= 0;
- }
- }
-
- /* Save attributes in Sessiob, so we are able to recontruct filter on plugin reload */
- $logview = session::get('logview');
- $logview['gosa_log'] = array();
- foreach(array("action","server","time","regex") as $attr){
- $logview['gosa_log'][$attr] = $this->$attr;
- }
- session::set('logview',$logview);
- }
- }
-
-
- /* Return plugin informations for acl handling
- #FIXME You can only read attributes within this report plugin
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Log view"),
- "plDescription" => _("Log view addon"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 0,
- "plSection" => array("addon"),
- "plCategory" => array("logview" => array("objectClass" => "none", "description" => _("System logs"))),
-
- "plProvidedAcls" => array()
- ));
- }
- */
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/addons/logview/class_logview.inc b/gosa-core/plugins/addons/logview/class_logview.inc
+++ /dev/null
@@ -1,415 +0,0 @@
-<?php
-
-class logview extends plugin
-{
- /* Definitions */
- var $plHeadline= "System logs";
- var $plDescription= "This does something";
-
- /* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
- var $start= 0;
- var $sort= 2;
- var $sort_direction= "down";
- var $hostlist= array();
- var $loglevellist= array();
- var $tilist= array();
- var $fields= array("log_level", "host", "time_stamp", "message");
- var $last= array("log_level", "host", "time", "regex");
- var $range = 25;
- var $view_logged = FALSE;
-
- function logview (&$config, $dn= NULL)
- {
- /* Include config object */
- $this->config= &$config;
-
- /* Get global filter config */
- if (!session::is_set("logfilter")){
- $logfilter= array(
- "time" => "1",
- "log_level" => "!All",
- "host" => "!All",
- "regex" => "*");
-
- session::set("logfilter", $logfilter);
- }
-
- $this->ui = get_userinfo();
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Log view */
- if(!$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","logview/".get_class($this),$this->dn);
- }
-
- $logfilter= session::get("logfilter");
- $smarty= get_smarty();
- $smarty->assign("search_result", "");
- $smarty->assign("plug", "?plug=".validate($_GET['plug']));
- $smarty->assign("search_image", get_template_path('images/search.png'));
- $smarty->assign("time_image", get_template_path('images/time.png'));
- $smarty->assign("server_image", get_template_path('images/server.png'));
- $smarty->assign("log_image", get_template_path('images/log_warning.png'));
- $smarty->assign("ruleset_image", get_template_path('images/edit.png'));
- $smarty->assign("launchimage", get_template_path('images/launch.png'));
- $smarty->assign("hostlist", $this->hostlist);
- $smarty->assign("loglevellist", $this->loglevellist);
- $smarty->assign("tilist", $this->tilist);
- $smarty->assign("mode0", "");
- $smarty->assign("mode1", "");
- $smarty->assign("mode2", "");
- $smarty->assign("mode3", "");
-
- /* Assign select option content */
- foreach( array("host", "log_level", "time", "regex") as $type){
- $smarty->assign("$type", $logfilter[$type]);
- }
-
- /* Test connection to log database */
- if (!isset($this->config->data['SERVERS']['LOG'])){
- msg_dialog::display(_("Warning"), sprintf(_("No %s servers defined!"), "syslog"), WARNING_DIALOG);
- return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
-
- }elseif(!is_callable("mysql_connect")){
- msg_dialog::display(_("Configuration error"), sprintf(_("Missing %s PHP extension!"), "mysql"), WARNING_DIALOG);
- return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
-
- }else{
-
- /* Cehck connection informations */
- $cfg= $this->config->data['SERVERS']['LOG'];
-
- /* Open link to database and check if it is valid */
- $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
- if ($link === FALSE){
- msg_dialog::display(_("Error"), sprintf(_("Cannot connect to %s database!"), "syslog"), ERROR_DIALOG);
- new log("debug","logview","",array(),@mysql_error());
- return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
- }
-
- /* check of log database is available */
- if (! @mysql_select_db("gomon")){
- msg_dialog::display(_("Error"), sprintf(_("Cannot select %s database!"), "syslog"), ERROR_DIALOG);
- new log("debug","logview","",array(),@mysql_error());
- return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
- }
-
- /* Get Host list, if still empty */
- if(count($this->hostlist) == 0){
-
- /* Query database and check results */
- $query= "SELECT DISTINCT host FROM golog LIMIT 200;";
- @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query");
- $result = @mysql_query($query);
- if ($result === false){
- msg_dialog::display(_("Error"), _("Cannot obtain host list from syslog database!"), ERROR_DIALOG);
- new log("debug","logview","",array(),@mysql_error());
- return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
- }
-
- /* Add hostnames to list */
- while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){
- $this->hostlist[$line['host']]= $line['host'];
- }
- $this->hostlist['!All']= _("All");
- ksort($this->hostlist);
- $smarty->assign("hostlist", $this->hostlist);
- }
-
- /* Get log level list */
- if(count($this->loglevellist) == 0){
-
- /* Try to get all used log level types */
- $query= "SELECT DISTINCT log_level FROM golog LIMIT 200;";
- @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query");
- $result = @mysql_query($query);
- if ($result === false){
- new log("debug","logview","",array(),@mysql_error());
- msg_dialog::display(_("Error"), _("Database query failed!"), ERROR_DIALOG);
- return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
- }
-
- /* Add each etry to log level list */
- while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){
- $this->loglevellist[$line['log_level']]= $line['log_level'];
- }
- $this->loglevellist['!All']= _("All");
- ksort($this->loglevellist);
- $smarty->assign("loglevellist", $this->loglevellist);
- }
- }
-
- /* Set list of available time sequences */
- if(count($this->tilist) == 0){
-
- /* Time interval */
- $this->tilist= array("0" => _("one hour"), "1" => _("6 hours"),
- "2" => _("12 hours"), "3" => _("24 hours"),
- "4" => _("2 days"), "5" => _("one week"),
- "6" => _("2 weeks"), "7" => _("one month"));
- $smarty->assign("tilist", $this->tilist);
- }
-
- $smarty->assign("regex", $logfilter['regex']);
-
-
- /* Get acls */
-
- $tmp_cat_bases = $this->ui->get_module_departments("logview");
- $all_acls = "";
- foreach($tmp_cat_bases as $acl_base){
- $all_acls .= $this->ui->get_permissions($acl_base,"logview/logview");
- }
- if(count($tmp_cat_bases) == 0 || !preg_match("/r/",$all_acls)){
- $res = "<tr>
- <td colspan=4>
- "._("You have insufficient permissions to view syslog entries.")."
- </td>
- </tr>";
-
- /* Show main page */
- $smarty->assign("range_selector", "");
- $smarty->assign("search_result", $res);
- return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
- }
-
- /* Query stuff */
- $res= "";
- $cfg = $this->config->data['SERVERS']['LOG'];
- $tmp = set_error_handler('dummy_error_handler');
- $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
- set_error_handler($tmp);
-
- /* Test connection object && create up query string */
- if ($link === FALSE){
- msg_dialog::display(_("Error"), sprintf(_("Cannot connect to %s database!"), "syslog"), ERROR_DIALOG);
- new log("debug","logview","",array(),@mysql_error());
- } else {
- if (! @mysql_select_db("gomon")){
- msg_dialog::display(_("Error"), sprintf(_("Cannot select %s database!"), "syslog"), ERROR_DIALOG);
- new log("debug","logview","",array(),@mysql_error());
- } else {
-
- /* Assemble time query */
- switch ($logfilter['time']){
- case '0':
- $start= date ("YmdHis", time() - 3600);
- break;
- ;;
- case '1':
- $start= date ("YmdHis", time() - 21600);
- break;
- ;;
- case '2':
- $start= date ("YmdHis", time() - 43200);
- break;
- ;;
- case '3':
- $start= date ("YmdHis", time() - 86400);
- break;
- ;;
- case '4':
- $start= date ("YmdHis", time() - 172800);
- break;
- ;;
- case '5':
- $start= date ("YmdHis", time() - 604800);
- break;
- ;;
- case '6':
- $start= date ("YmdHis", time() - 1209600);
- break;
- ;;
- case '7':
- $start= date ("YmdHis", time() - 2419200);
- break;
- ;;
- }
-
- /* Assemble log level query */
- if ($logfilter['log_level'] == '!All'){
- $ll= "";
- } else {
- $ll= "AND log_level='".$logfilter['log_level']."'";
- }
- if ($logfilter['host'] == '!All'){
- $hf= "";
- } else {
- $hf= "AND host='".$logfilter['host']."'";
- }
-
- /* Order setting */
- if ($this->sort_direction == "down"){
- $desc= "DESC";
- $sort_sign = "\\/";
- } else {
- $desc= "";
- $sort_sign="/\\";
- }
- $end= date ("YmdHis");
- $query_base= " FROM
- golog
- WHERE
- message like '".preg_replace("/\*/","%",$logfilter['regex'])."'
- $ll
- $hf
- AND
- time_stamp <= $end AND time_stamp >= $start";
-
- /* Get number of entries */
- $query= "SELECT COUNT(*)".$query_base.";";
- $result = @mysql_query($query);
- if(!$result){
- new log("debug","logview","",array(),@mysql_error());
- }
- $line= mysql_fetch_array($result, MYSQL_ASSOC);
- $count= $line['COUNT(*)'];
- if ($count > 25){
- $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"EntriesPerPage"));
- } else {
- $smarty->assign("range_selector", "");
- }
-
- /* Query results */
- $query= "SELECT *".$query_base." ORDER BY ".$this->fields[$this->sort]." $desc LIMIT ".$this->start.",".$this->range.";";
- @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query");
- $result = @mysql_query($query);
- if(!$result){
- new log("debug","logview","",array(),@mysql_error());
- }
- /* Display results */
- $mod= 0;
-
- /* Add entries to result str */
- while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){
-
- /* Toggle background color */
- if ( ($mod++) & 1){
- $col= "background-color: #ECECEC;";
- } else {
- $col= "background-color: #F5F5F5;";
- }
-
- $res.=" <tr style=\"$col\">\n";
- $res.=" <td style=\"text-align:center\">
- <img alt=\"".$line['log_level']."\"
- src=\"".get_template_path('images/log_'.strtolower($line['log_level'])).".png\"
- title=\"Log level is '".$line['log_level']."'\">
- </td>";
- $res.=" <td>".
- $line['host']."
- </td>";
- $res.=" <td>".
- $line['time_stamp']."
- </td>";
- $res .= "<td width=\"100%\">".
- $line['message']."
- </td>";
- $res.=" </tr>\n";
- }
- mysql_close($link);
- $smarty->assign("mode".$this->sort, $sort_sign);
- $smarty->assign("host", $logfilter['host']);
- $smarty->assign("log_level", $logfilter['log_level']);
-
- $smarty->assign("search_result", $res);
- }
- }
-
- /* Show main page */
- return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
- }
-
-
- function save_object()
- {
- /* Get submitted range */
- if(isset($_POST['EntriesPerPage'])){
- if(is_numeric($_POST['EntriesPerPage'])){
- $this->range = $_POST['EntriesPerPage'];
- }
- }
-
- /* Save data */
- $logfilter= session::get("logfilter");
-
- /* Get actual select boxe values */
- $logfilter_changed = 0;
- foreach( array("host", "time", "log_level", "regex") as $type){
-
- /* Set new value and test if value has changed */
- $last[$type] = $logfilter[$type];
- if (isset($_POST[$type])){
- $logfilter[$type]= $_POST[$type];
- }
-
- if ($last[$type] != $logfilter[$type]){
- $logfilter_changed = 1;
- }
- }
-
- /* Filter regex values */
- if ($logfilter['regex'] == ""){
- $logfilter['regex']= '%';
- } else {
- $new = preg_replace('/\*\**/', '*', $logfilter['regex']);
- $logfilter['regex']= $new;
- }
-
- /* Store filter values */
- session::set("logfilter", $logfilter);
-
- /* Set start value */
- if (isset($_GET['start'])){
- $this->start= (int)$_GET['start'];
- }
-
- /* Reset page number if filter has changed */
- if ($logfilter_changed > 0){
- $this->start= 0;
- }
-
- /* Adapt sorting */
- if (isset($_GET['sort'])){
- if ($this->sort == (int)$_GET['sort']){
- if ($this->sort_direction == "down"){
- $this->sort_direction= "up";
- } else {
- $this->sort_direction= "down";
- }
- }
- $this->sort= (int)$_GET['sort'];
- if ($this->sort < 0 || $this->sort > 3){
- $this->sort= 0;
- }
- }
- }
-
-
- /* Return plugin informations for acl handling
- #FIXME You can only read attributes within this report plugin */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Log view"),
- "plDescription" => _("Log view addon"),
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 0,
- "plSection" => array("addon"),
- "plCategory" => array("logview" => array("objectClass" => "none", "description" => _("System logs"))),
-
- "plProvidedAcls" => array()
- ));
- }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/addons/logview/contents.tpl b/gosa-core/plugins/addons/logview/contents.tpl
+++ /dev/null
@@ -1,105 +0,0 @@
-<div class="contentboxh">
- <p class="contentboxh"><img src="{$launchimage}" align="right" alt="[F]">{t}Filter{/t}</p>
-</div>
-<div class="contentboxb">
-
- <table summary="" width="100%" class="contentboxb" style="border-top:1px solid #B0B0B0; padding:0px;">
- <tr>
- <td width="33%">
- <table summary="">
- <tr>
- <td><img class="center" alt="" align="middle" border=0 src="{$server_image}"> <LABEL FOR="host">{t}Show hosts{/t}</LABEL></td>
- <td>
- <select id="host" name="host" size=1 onChange="mainform.submit()">
- {html_options options=$hostlist selected=$host}
- <option disabled> </option>
- </select>
- </td>
- </tr>
- <tr>
- <td><img class="center" alt="" align="middle" border=0 src="{$log_image}"> <LABEL for="log_level">{t}Log level{/t}</label></td>
- <td>
- <select id="log_level" name="log_level" size=1 onChange="mainform.submit()">
- {html_options options=$loglevellist selected=$log_level}
- <option disabled> </option>
- </select>
- </td>
- </tr>
- </table>
- </td>
-
- <td style="border-left:1px solid #A0A0A0">
-
- </td>
-
- <td width="33%">
- <table summary="">
- <tr>
- <td><img class="center" alt="" align="middle" border=0 src="{$time_image}"> <LABEL for="time" >{t}Time interval{/t}</LABEL></td>
- <td>
- <select id="time" name="time" size=1 onChange="mainform.submit()">
- {html_options options=$tilist selected=$time}
- <option disabled> </option>
- </select>
- </td>
- </tr>
- <tr>
- <td><img class="center" alt="" align="middle" border=0 src="{$search_image}"> <LABEL for="regex">{t}Search for{/t}</LABEL></td>
- <td><input id="regex" name="regex" size=25 maxlength=60 value="{$regex}" title="{t}Enter string to search for{/t}"></td>
- </tr>
- </table>
- </td>
-
- <td style="border-left:1px solid #A0A0A0">
-
- </td>
- <td>
- <table summary="" width="100%">
- <!--
- <tr>
- <td><img class="center" alt="" align="middle" border=0 src="{$ruleset_image}"> <LABEL for="edit_rules">{t}Ruleset{/t}</LABEL></td>
- <td width="100%">
- <input id="edit_rules" name="edit_rules" type="submit" value="{t}Edit{/t}" disabled>
- </td>
- </tr>
--->
- <tr>
- <td colspan=2 style="text-align:right;">
- <input name="search" type="submit" value="{t}Search{/t}">
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-</div>
-
-<br>
-
-{if $search_result ne ""}
- <table summary="" style="width:100%; vertical-align:top; text-align:left; border:1px solid #B0B0B0;" cellpadding=2 cellspacing=1 rules="cols">
- <tr style="background-color: #E8E8E8; height:26px; font-weight:bold">
- <td><a href=main.php{$plug}&sort=0>{t}Level{/t} {$mode0}</a></td>
- <td><a href=main.php{$plug}&sort=1>{t}Hostname{/t} {$mode1}</a></td>
- <td width=15%><a href=main.php{$plug}&sort=2>{t}Date{/t} {$mode2}</a></td>
- <td><a href=main.php{$plug}&sort=3>{t}Message{/t} {$mode3}</a></td>
- </tr>
- {$search_result}
- </table>
-
- <table summary="" style="width:100%; vertical-align:top; text-align:center;" cellpadding=4 cellspacing=0 border=0>
- <tr>
- <td>{$range_selector}</td>
- </tr>
- </table>
-
-{else}
- <b>{t}Search returned no results...{/t}</b>
-{/if}
-
-<!-- Place cursor -->
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('search_for');
- -->
-</script>
diff --git a/gosa-core/plugins/addons/logview/gosa_log_contents.tpl b/gosa-core/plugins/addons/logview/gosa_log_contents.tpl
+++ /dev/null
@@ -1,107 +0,0 @@
-<div class="contentboxh">
- <p class="contentboxh"><img src="{$launchimage}" align="right" alt="[F]">{t}Filter{/t}</p>
-</div>
-<div class="contentboxb">
-
- <table summary="" width="100%" class="contentboxb" style="border-top:1px solid #B0B0B0; padding:0px;" border=0>
- <tr>
- <td width="33%">
- <table summary="">
- <tr>
- <td><img class="center" alt="" align="middle" border=0 src="{$server_image}"> <LABEL FOR="server">{t}Show hosts{/t}</LABEL></td>
- <td>
- <select id="server" name="server" size=1 onChange="mainform.submit()">
- {html_options options=$servers selected=$server}
- <option disabled> </option>
- </select>
- </td>
- </tr>
- <tr>
- <td><img class="center" alt="" align="middle" border=0 src="{$log_image}"> <LABEL for="action">{t}Action{/t}</label></td>
- <td>
- <select id="action" name="action" size=1 onChange="mainform.submit()">
- {html_options options=$actions selected=$action}
- <option disabled> </option>
- </select>
- </td>
- </tr>
- </table>
- </td>
-
- <td style="border-left:1px solid #A0A0A0">
-
- </td>
-
- <td width="33%">
- <table summary="">
- <tr>
- <td><img class="center" alt="" align="middle" border=0 src="{$time_image}"> <LABEL for="time" >{t}Time interval{/t}</LABEL></td>
- <td>
- <select id="time" name="time" size=1 onChange="mainform.submit()">
- {html_options options=$date_select selected=$time}
- <option disabled> </option>
- </select>
- </td>
- </tr>
- <tr>
- <td><img class="center" alt="" align="middle" border=0 src="{$search_image}"> <LABEL for="regex">{t}Search for{/t}</LABEL></td>
- <td><input id="regex" name="regex" size=25 maxlength=60 value="{$regex}" title="{t}Enter string to search for{/t}"></td>
- </tr>
- </table>
- </td>
-
- <td style="border-left:1px solid #A0A0A0">
-
- </td>
- <td>
- <table summary="" width="100%">
- <!--
- <tr>
- <td><img class="center" alt="" align="middle" border=0 src="{$ruleset_image}"> <LABEL for="edit_rules">{t}Ruleset{/t}</LABEL></td>
- <td width="100%">
- <input id="edit_rules" name="edit_rules" type="submit" value="{t}Edit{/t}" disabled>
- </td>
- </tr>
--->
- <tr>
- <td colspan=2 style="text-align:right;">
- <input name="search" type="submit" value="{t}Search{/t}">
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
-</div>
-
-<br>
-
-{if $search_result ne ""}
- <table style="width:100%;background-color: #B0B0B0;" cellspacing=1 cellpadding=2>
- <tr style="background-color: #E8E8E8; height:26px; font-weight:bold">
- <td><a href="main.php{$plug}&sort=0&direction={$direction}">{t}Action{/t} {$mode0}</a></td>
- <td><a href="main.php{$plug}&sort=1&direction={$direction}">{t}Date{/t} {$mode1}</a></td>
- <td><a href="main.php{$plug}&sort=2&direction={$direction}">{t}User{/t} {$mode2}</a></td>
- <td><a href="main.php{$plug}&sort=3&direction={$direction}">{t}Object type{/t} {$mode3}</a></td>
- <td><a href="main.php{$plug}&sort=4&direction={$direction}">{t}Object{/t} {$mode4}</a></td>
- <td><a href="main.php{$plug}&sort=5&direction={$direction}">{t}Message{/t} {$mode5}</a></td>
- </tr>
- {$search_result}
- </table>
-
- <table summary="" style="width:100%; vertical-align:top; text-align:center;" cellpadding=4 cellspacing=0 border=0>
- <tr>
- <td>{$range_selector}</td>
- </tr>
- </table>
-
-{else}
- <b>{t}Search returned no results...{/t}</b>
-{/if}
-<input type='hidden' name='gosa_log_contents_posted' value='1'>
-<!-- Place cursor -->
-<script language="JavaScript" type="text/javascript">
- <!-- // First input field on page
- focus_field('regex');
- -->
-</script>
diff --git a/gosa-core/plugins/addons/logview/main.inc b/gosa-core/plugins/addons/logview/main.inc
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003 Cajus Pollmeier
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-if (!$remove_lock){
-
- /* Create logview object on demand */
- if (!session::is_set('log_tabs') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
- session::set('log_tabs',new log_tabs($config, $config->data['TABS']['LOGTABS'],""));
- }
- $log_tabs = session::get('log_tabs');
-
- /* Execute formular */
-# $display= $log_tabs->save_object();
- $display= $log_tabs->execute ();
- $display.= "<input type=\"hidden\" name=\"ignore\">\n";
-
- /* Page header*/
- $display= print_header(get_template_path('images/logview.png'), _("System log view")).$display;
-
- /* Store changes in session */
- session::set('log_tabs',$log_tabs);
-}
-?>
diff --git a/gosa-core/plugins/addons/logview/tabs_log.inc b/gosa-core/plugins/addons/logview/tabs_log.inc
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-class log_tabs extends tabs
-{
-
- function log_tabs($config, $data, $dn)
- {
- tabs::tabs($config, $data, $dn);
- }
-
- function save_object($save_current= FALSE)
- {
- tabs::save_object($save_current);
- }
-
-
- function save($ignore_account= FALSE)
- {
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-plugins/log/addons/logview/class_gosa_logview.inc b/gosa-plugins/log/addons/logview/class_gosa_logview.inc
--- /dev/null
@@ -0,0 +1,400 @@
+<?php
+
+class gosa_logview extends plugin
+{
+ /* Definitions */
+ var $plHeadline= "System logs";
+ var $plDescription= "This does something";
+
+ /* attribute list for save action */
+ var $attributes = array();
+ var $objectclasses = array();
+
+ var $server = "";
+ var $action = "modify";
+ var $time = 2;
+ var $regex = "*";
+
+ var $start = 0;
+ var $sort = 1;
+
+ var $sort_direction = "down";
+ var $fields = array("action","timestamp","user","objecttype","object","result","repeated");
+ var $range = 25;
+ var $view_logged = FALSE;
+
+ var $timezone_offset = 0;
+
+ var $uid_map = array();
+
+
+ function gosa_logview (&$config, $dn= NULL)
+ {
+ /* Include config object */
+ $this->config= &$config;
+ $this->ui = get_userinfo();
+
+ /* Restore last filter settings */
+ $logview = session::get('logview');
+ foreach(array("action","server","time","regex") as $attr){
+ if(isset($logview['gosa_log'][$attr])){
+ $this->$attr = $logview['gosa_log'][$attr];
+ }
+ }
+
+ $tz = timezone::get_default_timezone();
+ $this->timezone_offset = $tz['value'] * 60 * 60 ;
+
+ $ldap = $this->config->get_ldap_link();
+ $ldap->search("(&(objectClass=person)(uid=*))",array("uid","dn"));
+ while($attrs = $ldap->fetch()){
+ $this->uid_map[$attrs['dn']] = $attrs['uid'][0];
+ }
+ }
+
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Log view */
+ if(!$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","logview/".get_class($this),$this->dn);
+ }
+
+ /* Time interval */
+ $date_select = array(
+ "0" => _("one hour"), "1" => _("6 hours"),
+ "2" => _("12 hours"), "3" => _("24 hours"),
+ "4" => _("2 days"), "5" => _("one week"),
+ "6" => _("2 weeks"), "7" => _("one month"));
+
+
+ $time = time();
+ $date_select_ = array(
+ "0" => $time - 3600,
+ "1" => $time - 21600,
+ "2" => $time - 43200,
+ "3" => $time - 86400,
+ "4" => $time - 172800,
+ "5" => $time - 604800,
+ "6" => $time - 1209600,
+ "7" => $time - 2419200);
+
+ $smarty= get_smarty();
+ $smarty->assign("search_result", "");
+ $smarty->assign("plug", "?plug=".validate($_GET['plug']));
+ $smarty->assign("search_image", get_template_path('images/search.png'));
+ $smarty->assign("time_image", get_template_path('images/time.png'));
+ $smarty->assign("server_image", get_template_path('images/server.png'));
+ $smarty->assign("log_image", get_template_path('images/log_warning.png'));
+ $smarty->assign("ruleset_image", get_template_path('images/edit.png'));
+ $smarty->assign("launchimage", get_template_path('images/launch.png'));
+ $smarty->assign("date_select", $date_select);
+ $smarty->assign("actions", array());
+ $smarty->assign("direction", "up");
+ $smarty->assign("mode0", "");
+ $smarty->assign("mode1", "");
+ $smarty->assign("mode2", "");
+ $smarty->assign("mode3", "");
+ $smarty->assign("mode4", "");
+ $smarty->assign("mode5", "");
+ $smarty->assign("mode6", "");
+
+ /* Assign select option content */
+ foreach( array("server", "action", "time", "regex") as $type){
+ $smarty->assign("$type", $this->$type);
+ }
+
+ /****
+ * Check if defined servers
+ * and mysql extension
+ ****/
+ if (!isset($this->config->data['SERVERS']['LOGGING']) || !count($this->config->data['SERVERS']['LOGGING'])){
+ msg_dialog::display(_("Warning"), sprintf(_("No %s servers defined!"), "GOsa log"), WARNING_DIALOG);
+ return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
+ }
+
+ if(!is_callable("mysql_connect")){
+ msg_dialog::display(_("Configuration error"), sprintf(_("Missing %s PHP extension!"), "mysql"), WARNING_DIALOG);
+ return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
+ }
+
+ /****
+ * Get Configurations
+ ****/
+ $list_of_servers = $this->config->data['SERVERS']['LOGGING'];
+ $servers = array();
+ foreach($list_of_servers as $servername => $data){
+ $servers[$servername] = $servername;
+ }
+ $smarty->assign("servers", $servers);
+
+ /* Set a default server, if there is currently no valid server selected */
+ if(empty($this->server) || !in_array($this->server,$servers)){
+ $this->server = key($servers);
+ }
+
+ /****
+ * Connect to currently selected server
+ ****/
+ $cfg = $list_of_servers[$this->server];
+ $link = @mysql_pconnect($this->server, $cfg['USER'], $cfg['PWD']);
+ if ($link === FALSE){
+ msg_dialog::display(_("Error"), sprintf(_("Cannot connect to %s database!"), "GOsa LOG"), ERROR_DIALOG);
+ new log("debug","logview","",array(),@mysql_error());
+ return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
+ }
+
+ /* check of log database is available */
+ if (! @mysql_select_db($cfg['DB'])){
+ msg_dialog::display(_("Error"), sprintf(_("Cannot select %s database!"), "GOsa LOG"), ERROR_DIALOG);
+ new log("debug","logview","",array(),@mysql_error());
+ return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
+ }
+
+
+ /****
+ * Get all action types
+ ****/
+
+ $actions = array("!ALL" => _("All"));
+ $query = "SELECT distinct(action) FROM gosa_log;";
+ $res = @mysql_query($query);
+ while($attrs = @mysql_fetch_assoc($res)){
+ $actions[$attrs['action']] = $attrs['action'];
+ }
+
+
+ /****
+ * Check Acls
+ ****/
+
+ $ui = get_userinfo();
+ $dn = $list_of_servers[$this->server]['DN'];
+ $acls = $ui->get_permissions($dn,"server/gosaLogServer","viewEntries");
+
+ if(!preg_match("/r/",$acls)){
+ $res = "<tr>
+ <td colspan=".count($this->fields).">
+ "._("You have insufficient permissions to view syslog entries.")."
+ </td>
+ </tr>";
+
+ /* Show main page */
+ $smarty->assign("range_selector", "");
+ $smarty->assign("search_result", $res);
+ return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
+ }
+
+
+ /****
+ * Query stuff
+ ****/
+ $res= "";
+ $cfg = $list_of_servers[$this->server];
+ $link = @mysql_pconnect($this->server, $cfg['USER'], $cfg['PWD']);
+
+ /* Test connection object && create up query string */
+ if ($link === FALSE){
+ msg_dialog::display(_("Error"), sprintf(_("Cannot connect to %s database!"), "GOsa LOG"), ERROR_DIALOG);
+ new log("debug","logview","",array(),@mysql_error());
+ } else {
+
+ if (! @mysql_select_db($cfg['DB'])){
+ msg_dialog::display(_("Error"), sprintf(_("Cannot select %s database!"), "GOsa LOG"), ERROR_DIALOG);
+ new log("debug","logview","",array(),@mysql_error());
+ } else {
+
+ /* Prepare order setting */
+ if ($this->sort_direction == "down"){
+ $desc= "DESC";
+ $sort_sign = "<img src='images/sort_down.png' alt='\/' class='center' title='down' border=0>";
+ } else {
+ $desc= "";
+ $sort_sign = "<img src='images/sort_up.png' alt='/\' class='center' title='up' border=0>";
+ }
+
+ /* Get start time */
+ $start = $date_select_[$this->time];
+
+ /* Prepare search filter */
+ $sql_regex =trim(preg_replace("/\*/","%",$this->regex));
+ $sql_regex = "%".trim($sql_regex,"%")."%";
+
+ /* Create search filter */
+ $query_base= "FROM gosa_log WHERE timestamp >= $start ";
+
+ /* Append action filter */
+ if($this->action != "!ALL"){
+ $query_base .=" AND action like '".$this->action."' ";
+ }
+
+ /* Append search filter */
+ if($sql_regex != "%%"){
+ $query_base .=" AND ( result like '".$sql_regex."' OR user like '".$sql_regex."') ";
+ }
+
+ /* Get number of entries */
+ $query= "SELECT COUNT(`user`) ".$query_base.";";
+ $result = mysql_query($query);
+ if(!$result){
+ new log("debug","logview","",array(),@mysql_error());
+ }
+ $line= mysql_fetch_array($result, MYSQL_ASSOC);
+ $count= $line['COUNT(`user`)'];
+ if ($count > 25){
+ $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"EntriesPerPage"));
+ } else {
+ $smarty->assign("range_selector", "");
+ }
+
+ /* Query results that will be displayed */
+ $query= "SELECT * ".$query_base." ORDER BY ".$this->fields[$this->sort]." ".$desc." LIMIT ".$this->start.",".$this->range.";";
+ @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query");
+ $result = @mysql_query($query);
+ if(!$result){
+ new log("debug","logview","",array(),@mysql_error());
+ }
+
+ /* Display results */
+ $mod= 0;
+
+ /* Add entries to result str */
+ while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){
+
+ /* Toggle background color */
+ if ( ($mod++) & 1){
+ $col= "background-color: #ECECEC;";
+ } else {
+ $col= "background-color: #F5F5F5;";
+ }
+
+ $base = ", ".substr($this->config->current['BASE'],0,5)."...";
+
+ if(isset($this->uid_map[$line['user']])){
+ $user = $this->uid_map[$line['user']];
+ }else{
+ $user = preg_replace("/,".normalizePreg($this->config->current['BASE'])."/",$base,$line['user']);
+ }
+ $object = preg_replace("/,".normalizePreg($this->config->current['BASE'])."/",$base,$line['object']);
+
+ $res.=" <tr style=\"$col\">\n";
+ $res.=" <td title='".$line['objecttype']."'>".$line['action']."</td>";
+ $res.=" <td>".date("H:i:s d.m.Y",($line['timestamp'] + $this->timezone_offset))."</td>";
+ $res.=" <td title='".$line['user']."'>".preg_replace("/,/",", ",$user)."</td>";
+ $res.=" <td title='".$line['objecttype']."'>".$line['objecttype']."</td>";
+ $res.=" <td title='".$line['object']."'>".preg_replace("/,/",", ",$object)."</td>";
+ $res.=" <td>".$line['result']."</td>";
+# if($line['repeated'] == 1){
+# $res.=" <td>-</td>";
+# }else{
+# $res.=" <td>".($line['repeated']-1)."</td>";
+# }
+ $res.=" </tr>\n";
+ }
+ mysql_close($link);
+ $smarty->assign("mode".$this->sort, $sort_sign);
+ $smarty->assign("search_result", $res);
+ }
+ }
+
+ $smarty->assign("regex", $this->regex);
+ $smarty->assign("server",$this->server);
+ $smarty->assign("servers",$servers);
+ $smarty->assign("action",$this->action);
+ $smarty->assign("actions",$actions);
+ $smarty->assign("date_select", $date_select);
+
+ $smarty->assign("direction", $this->sort_direction);
+
+ /* Show main page */
+ return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
+ }
+
+
+ function save_object()
+ {
+ if(isset($_POST['gosa_log_contents_posted'])){
+
+ /* Get submitted range */
+ if(isset($_POST['EntriesPerPage'])){
+ if(is_numeric($_POST['EntriesPerPage'])){
+ $this->range = $_POST['EntriesPerPage'];
+ }
+ }
+
+ /* Get actual select boxe values */
+ $logfilter_changed = FALSE;
+ foreach( array("server", "action","time","regex") as $type){
+ if(isset($_POST[$type])){
+ $this->$type = $_POST[$type];
+ }
+ }
+
+ /* Filter regex values */
+ if ($this->regex == ""){
+ $this->regex= '*';
+ } else {
+ $new = preg_replace('/\*\**/', '*', $this->regex);
+ $this->regex= $new;
+ }
+
+ /* Set start value */
+ if (isset($_GET['start'])){
+ $this->start= (int)$_GET['start'];
+ }
+
+ /* Reset page number if filter has changed */
+ if ($logfilter_changed > 0){
+ $this->start= 0;
+ }
+
+ /* Adapt sorting */
+ if (isset($_GET['sort'])){
+
+ if($_GET['direction'] == "up"){
+ $this->sort_direction = "down";
+ }else{
+ $this->sort_direction = "up";
+ }
+
+ $this->sort= (int)$_GET['sort'];
+ if ($this->sort < 0 || $this->sort > count($this->fields)){
+ $this->sort= 0;
+ }
+ }
+
+ /* Save attributes in Sessiob, so we are able to recontruct filter on plugin reload */
+ $logview = session::get('logview');
+ $logview['gosa_log'] = array();
+ foreach(array("action","server","time","regex") as $attr){
+ $logview['gosa_log'][$attr] = $this->$attr;
+ }
+ session::set('logview',$logview);
+ }
+ }
+
+
+ /* Return plugin informations for acl handling
+ #FIXME You can only read attributes within this report plugin
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Log view"),
+ "plDescription" => _("Log view addon"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 0,
+ "plSection" => array("addon"),
+ "plCategory" => array("logview" => array("objectClass" => "none", "description" => _("System logs"))),
+
+ "plProvidedAcls" => array()
+ ));
+ }
+ */
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/log/addons/logview/class_logview.inc b/gosa-plugins/log/addons/logview/class_logview.inc
--- /dev/null
@@ -0,0 +1,415 @@
+<?php
+
+class logview extends plugin
+{
+ /* Definitions */
+ var $plHeadline= "System logs";
+ var $plDescription= "This does something";
+
+ /* attribute list for save action */
+ var $attributes= array();
+ var $objectclasses= array();
+ var $start= 0;
+ var $sort= 2;
+ var $sort_direction= "down";
+ var $hostlist= array();
+ var $loglevellist= array();
+ var $tilist= array();
+ var $fields= array("log_level", "host", "time_stamp", "message");
+ var $last= array("log_level", "host", "time", "regex");
+ var $range = 25;
+ var $view_logged = FALSE;
+
+ function logview (&$config, $dn= NULL)
+ {
+ /* Include config object */
+ $this->config= &$config;
+
+ /* Get global filter config */
+ if (!session::is_set("logfilter")){
+ $logfilter= array(
+ "time" => "1",
+ "log_level" => "!All",
+ "host" => "!All",
+ "regex" => "*");
+
+ session::set("logfilter", $logfilter);
+ }
+
+ $this->ui = get_userinfo();
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Log view */
+ if(!$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","logview/".get_class($this),$this->dn);
+ }
+
+ $logfilter= session::get("logfilter");
+ $smarty= get_smarty();
+ $smarty->assign("search_result", "");
+ $smarty->assign("plug", "?plug=".validate($_GET['plug']));
+ $smarty->assign("search_image", get_template_path('images/search.png'));
+ $smarty->assign("time_image", get_template_path('images/time.png'));
+ $smarty->assign("server_image", get_template_path('images/server.png'));
+ $smarty->assign("log_image", get_template_path('images/log_warning.png'));
+ $smarty->assign("ruleset_image", get_template_path('images/edit.png'));
+ $smarty->assign("launchimage", get_template_path('images/launch.png'));
+ $smarty->assign("hostlist", $this->hostlist);
+ $smarty->assign("loglevellist", $this->loglevellist);
+ $smarty->assign("tilist", $this->tilist);
+ $smarty->assign("mode0", "");
+ $smarty->assign("mode1", "");
+ $smarty->assign("mode2", "");
+ $smarty->assign("mode3", "");
+
+ /* Assign select option content */
+ foreach( array("host", "log_level", "time", "regex") as $type){
+ $smarty->assign("$type", $logfilter[$type]);
+ }
+
+ /* Test connection to log database */
+ if (!isset($this->config->data['SERVERS']['LOG'])){
+ msg_dialog::display(_("Warning"), sprintf(_("No %s servers defined!"), "syslog"), WARNING_DIALOG);
+ return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
+
+ }elseif(!is_callable("mysql_connect")){
+ msg_dialog::display(_("Configuration error"), sprintf(_("Missing %s PHP extension!"), "mysql"), WARNING_DIALOG);
+ return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
+
+ }else{
+
+ /* Cehck connection informations */
+ $cfg= $this->config->data['SERVERS']['LOG'];
+
+ /* Open link to database and check if it is valid */
+ $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
+ if ($link === FALSE){
+ msg_dialog::display(_("Error"), sprintf(_("Cannot connect to %s database!"), "syslog"), ERROR_DIALOG);
+ new log("debug","logview","",array(),@mysql_error());
+ return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
+ }
+
+ /* check of log database is available */
+ if (! @mysql_select_db("gomon")){
+ msg_dialog::display(_("Error"), sprintf(_("Cannot select %s database!"), "syslog"), ERROR_DIALOG);
+ new log("debug","logview","",array(),@mysql_error());
+ return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
+ }
+
+ /* Get Host list, if still empty */
+ if(count($this->hostlist) == 0){
+
+ /* Query database and check results */
+ $query= "SELECT DISTINCT host FROM golog LIMIT 200;";
+ @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query");
+ $result = @mysql_query($query);
+ if ($result === false){
+ msg_dialog::display(_("Error"), _("Cannot obtain host list from syslog database!"), ERROR_DIALOG);
+ new log("debug","logview","",array(),@mysql_error());
+ return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
+ }
+
+ /* Add hostnames to list */
+ while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){
+ $this->hostlist[$line['host']]= $line['host'];
+ }
+ $this->hostlist['!All']= _("All");
+ ksort($this->hostlist);
+ $smarty->assign("hostlist", $this->hostlist);
+ }
+
+ /* Get log level list */
+ if(count($this->loglevellist) == 0){
+
+ /* Try to get all used log level types */
+ $query= "SELECT DISTINCT log_level FROM golog LIMIT 200;";
+ @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query");
+ $result = @mysql_query($query);
+ if ($result === false){
+ new log("debug","logview","",array(),@mysql_error());
+ msg_dialog::display(_("Error"), _("Database query failed!"), ERROR_DIALOG);
+ return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
+ }
+
+ /* Add each etry to log level list */
+ while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){
+ $this->loglevellist[$line['log_level']]= $line['log_level'];
+ }
+ $this->loglevellist['!All']= _("All");
+ ksort($this->loglevellist);
+ $smarty->assign("loglevellist", $this->loglevellist);
+ }
+ }
+
+ /* Set list of available time sequences */
+ if(count($this->tilist) == 0){
+
+ /* Time interval */
+ $this->tilist= array("0" => _("one hour"), "1" => _("6 hours"),
+ "2" => _("12 hours"), "3" => _("24 hours"),
+ "4" => _("2 days"), "5" => _("one week"),
+ "6" => _("2 weeks"), "7" => _("one month"));
+ $smarty->assign("tilist", $this->tilist);
+ }
+
+ $smarty->assign("regex", $logfilter['regex']);
+
+
+ /* Get acls */
+
+ $tmp_cat_bases = $this->ui->get_module_departments("logview");
+ $all_acls = "";
+ foreach($tmp_cat_bases as $acl_base){
+ $all_acls .= $this->ui->get_permissions($acl_base,"logview/logview");
+ }
+ if(count($tmp_cat_bases) == 0 || !preg_match("/r/",$all_acls)){
+ $res = "<tr>
+ <td colspan=4>
+ "._("You have insufficient permissions to view syslog entries.")."
+ </td>
+ </tr>";
+
+ /* Show main page */
+ $smarty->assign("range_selector", "");
+ $smarty->assign("search_result", $res);
+ return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
+ }
+
+ /* Query stuff */
+ $res= "";
+ $cfg = $this->config->data['SERVERS']['LOG'];
+ $tmp = set_error_handler('dummy_error_handler');
+ $link = @mysql_pconnect($cfg['SERVER'], $cfg['LOGIN'], $cfg['PASSWORD']);
+ set_error_handler($tmp);
+
+ /* Test connection object && create up query string */
+ if ($link === FALSE){
+ msg_dialog::display(_("Error"), sprintf(_("Cannot connect to %s database!"), "syslog"), ERROR_DIALOG);
+ new log("debug","logview","",array(),@mysql_error());
+ } else {
+ if (! @mysql_select_db("gomon")){
+ msg_dialog::display(_("Error"), sprintf(_("Cannot select %s database!"), "syslog"), ERROR_DIALOG);
+ new log("debug","logview","",array(),@mysql_error());
+ } else {
+
+ /* Assemble time query */
+ switch ($logfilter['time']){
+ case '0':
+ $start= date ("YmdHis", time() - 3600);
+ break;
+ ;;
+ case '1':
+ $start= date ("YmdHis", time() - 21600);
+ break;
+ ;;
+ case '2':
+ $start= date ("YmdHis", time() - 43200);
+ break;
+ ;;
+ case '3':
+ $start= date ("YmdHis", time() - 86400);
+ break;
+ ;;
+ case '4':
+ $start= date ("YmdHis", time() - 172800);
+ break;
+ ;;
+ case '5':
+ $start= date ("YmdHis", time() - 604800);
+ break;
+ ;;
+ case '6':
+ $start= date ("YmdHis", time() - 1209600);
+ break;
+ ;;
+ case '7':
+ $start= date ("YmdHis", time() - 2419200);
+ break;
+ ;;
+ }
+
+ /* Assemble log level query */
+ if ($logfilter['log_level'] == '!All'){
+ $ll= "";
+ } else {
+ $ll= "AND log_level='".$logfilter['log_level']."'";
+ }
+ if ($logfilter['host'] == '!All'){
+ $hf= "";
+ } else {
+ $hf= "AND host='".$logfilter['host']."'";
+ }
+
+ /* Order setting */
+ if ($this->sort_direction == "down"){
+ $desc= "DESC";
+ $sort_sign = "\\/";
+ } else {
+ $desc= "";
+ $sort_sign="/\\";
+ }
+ $end= date ("YmdHis");
+ $query_base= " FROM
+ golog
+ WHERE
+ message like '".preg_replace("/\*/","%",$logfilter['regex'])."'
+ $ll
+ $hf
+ AND
+ time_stamp <= $end AND time_stamp >= $start";
+
+ /* Get number of entries */
+ $query= "SELECT COUNT(*)".$query_base.";";
+ $result = @mysql_query($query);
+ if(!$result){
+ new log("debug","logview","",array(),@mysql_error());
+ }
+ $line= mysql_fetch_array($result, MYSQL_ASSOC);
+ $count= $line['COUNT(*)'];
+ if ($count > 25){
+ $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"EntriesPerPage"));
+ } else {
+ $smarty->assign("range_selector", "");
+ }
+
+ /* Query results */
+ $query= "SELECT *".$query_base." ORDER BY ".$this->fields[$this->sort]." $desc LIMIT ".$this->start.",".$this->range.";";
+ @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__, $query, "Database query");
+ $result = @mysql_query($query);
+ if(!$result){
+ new log("debug","logview","",array(),@mysql_error());
+ }
+ /* Display results */
+ $mod= 0;
+
+ /* Add entries to result str */
+ while ($line = mysql_fetch_array($result, MYSQL_ASSOC)){
+
+ /* Toggle background color */
+ if ( ($mod++) & 1){
+ $col= "background-color: #ECECEC;";
+ } else {
+ $col= "background-color: #F5F5F5;";
+ }
+
+ $res.=" <tr style=\"$col\">\n";
+ $res.=" <td style=\"text-align:center\">
+ <img alt=\"".$line['log_level']."\"
+ src=\"".get_template_path('images/log_'.strtolower($line['log_level'])).".png\"
+ title=\"Log level is '".$line['log_level']."'\">
+ </td>";
+ $res.=" <td>".
+ $line['host']."
+ </td>";
+ $res.=" <td>".
+ $line['time_stamp']."
+ </td>";
+ $res .= "<td width=\"100%\">".
+ $line['message']."
+ </td>";
+ $res.=" </tr>\n";
+ }
+ mysql_close($link);
+ $smarty->assign("mode".$this->sort, $sort_sign);
+ $smarty->assign("host", $logfilter['host']);
+ $smarty->assign("log_level", $logfilter['log_level']);
+
+ $smarty->assign("search_result", $res);
+ }
+ }
+
+ /* Show main page */
+ return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
+ }
+
+
+ function save_object()
+ {
+ /* Get submitted range */
+ if(isset($_POST['EntriesPerPage'])){
+ if(is_numeric($_POST['EntriesPerPage'])){
+ $this->range = $_POST['EntriesPerPage'];
+ }
+ }
+
+ /* Save data */
+ $logfilter= session::get("logfilter");
+
+ /* Get actual select boxe values */
+ $logfilter_changed = 0;
+ foreach( array("host", "time", "log_level", "regex") as $type){
+
+ /* Set new value and test if value has changed */
+ $last[$type] = $logfilter[$type];
+ if (isset($_POST[$type])){
+ $logfilter[$type]= $_POST[$type];
+ }
+
+ if ($last[$type] != $logfilter[$type]){
+ $logfilter_changed = 1;
+ }
+ }
+
+ /* Filter regex values */
+ if ($logfilter['regex'] == ""){
+ $logfilter['regex']= '%';
+ } else {
+ $new = preg_replace('/\*\**/', '*', $logfilter['regex']);
+ $logfilter['regex']= $new;
+ }
+
+ /* Store filter values */
+ session::set("logfilter", $logfilter);
+
+ /* Set start value */
+ if (isset($_GET['start'])){
+ $this->start= (int)$_GET['start'];
+ }
+
+ /* Reset page number if filter has changed */
+ if ($logfilter_changed > 0){
+ $this->start= 0;
+ }
+
+ /* Adapt sorting */
+ if (isset($_GET['sort'])){
+ if ($this->sort == (int)$_GET['sort']){
+ if ($this->sort_direction == "down"){
+ $this->sort_direction= "up";
+ } else {
+ $this->sort_direction= "down";
+ }
+ }
+ $this->sort= (int)$_GET['sort'];
+ if ($this->sort < 0 || $this->sort > 3){
+ $this->sort= 0;
+ }
+ }
+ }
+
+
+ /* Return plugin informations for acl handling
+ #FIXME You can only read attributes within this report plugin */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Log view"),
+ "plDescription" => _("Log view addon"),
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 0,
+ "plSection" => array("addon"),
+ "plCategory" => array("logview" => array("objectClass" => "none", "description" => _("System logs"))),
+
+ "plProvidedAcls" => array()
+ ));
+ }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/log/addons/logview/contents.tpl b/gosa-plugins/log/addons/logview/contents.tpl
--- /dev/null
@@ -0,0 +1,105 @@
+<div class="contentboxh">
+ <p class="contentboxh"><img src="{$launchimage}" align="right" alt="[F]">{t}Filter{/t}</p>
+</div>
+<div class="contentboxb">
+
+ <table summary="" width="100%" class="contentboxb" style="border-top:1px solid #B0B0B0; padding:0px;">
+ <tr>
+ <td width="33%">
+ <table summary="">
+ <tr>
+ <td><img class="center" alt="" align="middle" border=0 src="{$server_image}"> <LABEL FOR="host">{t}Show hosts{/t}</LABEL></td>
+ <td>
+ <select id="host" name="host" size=1 onChange="mainform.submit()">
+ {html_options options=$hostlist selected=$host}
+ <option disabled> </option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td><img class="center" alt="" align="middle" border=0 src="{$log_image}"> <LABEL for="log_level">{t}Log level{/t}</label></td>
+ <td>
+ <select id="log_level" name="log_level" size=1 onChange="mainform.submit()">
+ {html_options options=$loglevellist selected=$log_level}
+ <option disabled> </option>
+ </select>
+ </td>
+ </tr>
+ </table>
+ </td>
+
+ <td style="border-left:1px solid #A0A0A0">
+
+ </td>
+
+ <td width="33%">
+ <table summary="">
+ <tr>
+ <td><img class="center" alt="" align="middle" border=0 src="{$time_image}"> <LABEL for="time" >{t}Time interval{/t}</LABEL></td>
+ <td>
+ <select id="time" name="time" size=1 onChange="mainform.submit()">
+ {html_options options=$tilist selected=$time}
+ <option disabled> </option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td><img class="center" alt="" align="middle" border=0 src="{$search_image}"> <LABEL for="regex">{t}Search for{/t}</LABEL></td>
+ <td><input id="regex" name="regex" size=25 maxlength=60 value="{$regex}" title="{t}Enter string to search for{/t}"></td>
+ </tr>
+ </table>
+ </td>
+
+ <td style="border-left:1px solid #A0A0A0">
+
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <!--
+ <tr>
+ <td><img class="center" alt="" align="middle" border=0 src="{$ruleset_image}"> <LABEL for="edit_rules">{t}Ruleset{/t}</LABEL></td>
+ <td width="100%">
+ <input id="edit_rules" name="edit_rules" type="submit" value="{t}Edit{/t}" disabled>
+ </td>
+ </tr>
+-->
+ <tr>
+ <td colspan=2 style="text-align:right;">
+ <input name="search" type="submit" value="{t}Search{/t}">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+</div>
+
+<br>
+
+{if $search_result ne ""}
+ <table summary="" style="width:100%; vertical-align:top; text-align:left; border:1px solid #B0B0B0;" cellpadding=2 cellspacing=1 rules="cols">
+ <tr style="background-color: #E8E8E8; height:26px; font-weight:bold">
+ <td><a href=main.php{$plug}&sort=0>{t}Level{/t} {$mode0}</a></td>
+ <td><a href=main.php{$plug}&sort=1>{t}Hostname{/t} {$mode1}</a></td>
+ <td width=15%><a href=main.php{$plug}&sort=2>{t}Date{/t} {$mode2}</a></td>
+ <td><a href=main.php{$plug}&sort=3>{t}Message{/t} {$mode3}</a></td>
+ </tr>
+ {$search_result}
+ </table>
+
+ <table summary="" style="width:100%; vertical-align:top; text-align:center;" cellpadding=4 cellspacing=0 border=0>
+ <tr>
+ <td>{$range_selector}</td>
+ </tr>
+ </table>
+
+{else}
+ <b>{t}Search returned no results...{/t}</b>
+{/if}
+
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('search_for');
+ -->
+</script>
diff --git a/gosa-plugins/log/addons/logview/gosa_log_contents.tpl b/gosa-plugins/log/addons/logview/gosa_log_contents.tpl
--- /dev/null
@@ -0,0 +1,107 @@
+<div class="contentboxh">
+ <p class="contentboxh"><img src="{$launchimage}" align="right" alt="[F]">{t}Filter{/t}</p>
+</div>
+<div class="contentboxb">
+
+ <table summary="" width="100%" class="contentboxb" style="border-top:1px solid #B0B0B0; padding:0px;" border=0>
+ <tr>
+ <td width="33%">
+ <table summary="">
+ <tr>
+ <td><img class="center" alt="" align="middle" border=0 src="{$server_image}"> <LABEL FOR="server">{t}Show hosts{/t}</LABEL></td>
+ <td>
+ <select id="server" name="server" size=1 onChange="mainform.submit()">
+ {html_options options=$servers selected=$server}
+ <option disabled> </option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td><img class="center" alt="" align="middle" border=0 src="{$log_image}"> <LABEL for="action">{t}Action{/t}</label></td>
+ <td>
+ <select id="action" name="action" size=1 onChange="mainform.submit()">
+ {html_options options=$actions selected=$action}
+ <option disabled> </option>
+ </select>
+ </td>
+ </tr>
+ </table>
+ </td>
+
+ <td style="border-left:1px solid #A0A0A0">
+
+ </td>
+
+ <td width="33%">
+ <table summary="">
+ <tr>
+ <td><img class="center" alt="" align="middle" border=0 src="{$time_image}"> <LABEL for="time" >{t}Time interval{/t}</LABEL></td>
+ <td>
+ <select id="time" name="time" size=1 onChange="mainform.submit()">
+ {html_options options=$date_select selected=$time}
+ <option disabled> </option>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td><img class="center" alt="" align="middle" border=0 src="{$search_image}"> <LABEL for="regex">{t}Search for{/t}</LABEL></td>
+ <td><input id="regex" name="regex" size=25 maxlength=60 value="{$regex}" title="{t}Enter string to search for{/t}"></td>
+ </tr>
+ </table>
+ </td>
+
+ <td style="border-left:1px solid #A0A0A0">
+
+ </td>
+ <td>
+ <table summary="" width="100%">
+ <!--
+ <tr>
+ <td><img class="center" alt="" align="middle" border=0 src="{$ruleset_image}"> <LABEL for="edit_rules">{t}Ruleset{/t}</LABEL></td>
+ <td width="100%">
+ <input id="edit_rules" name="edit_rules" type="submit" value="{t}Edit{/t}" disabled>
+ </td>
+ </tr>
+-->
+ <tr>
+ <td colspan=2 style="text-align:right;">
+ <input name="search" type="submit" value="{t}Search{/t}">
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+</div>
+
+<br>
+
+{if $search_result ne ""}
+ <table style="width:100%;background-color: #B0B0B0;" cellspacing=1 cellpadding=2>
+ <tr style="background-color: #E8E8E8; height:26px; font-weight:bold">
+ <td><a href="main.php{$plug}&sort=0&direction={$direction}">{t}Action{/t} {$mode0}</a></td>
+ <td><a href="main.php{$plug}&sort=1&direction={$direction}">{t}Date{/t} {$mode1}</a></td>
+ <td><a href="main.php{$plug}&sort=2&direction={$direction}">{t}User{/t} {$mode2}</a></td>
+ <td><a href="main.php{$plug}&sort=3&direction={$direction}">{t}Object type{/t} {$mode3}</a></td>
+ <td><a href="main.php{$plug}&sort=4&direction={$direction}">{t}Object{/t} {$mode4}</a></td>
+ <td><a href="main.php{$plug}&sort=5&direction={$direction}">{t}Message{/t} {$mode5}</a></td>
+ </tr>
+ {$search_result}
+ </table>
+
+ <table summary="" style="width:100%; vertical-align:top; text-align:center;" cellpadding=4 cellspacing=0 border=0>
+ <tr>
+ <td>{$range_selector}</td>
+ </tr>
+ </table>
+
+{else}
+ <b>{t}Search returned no results...{/t}</b>
+{/if}
+<input type='hidden' name='gosa_log_contents_posted' value='1'>
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ focus_field('regex');
+ -->
+</script>
diff --git a/gosa-plugins/log/addons/logview/main.inc b/gosa-plugins/log/addons/logview/main.inc
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+if (!$remove_lock){
+
+ /* Create logview object on demand */
+ if (!session::is_set('log_tabs') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+ session::set('log_tabs',new log_tabs($config, $config->data['TABS']['LOGTABS'],""));
+ }
+ $log_tabs = session::get('log_tabs');
+
+ /* Execute formular */
+# $display= $log_tabs->save_object();
+ $display= $log_tabs->execute ();
+ $display.= "<input type=\"hidden\" name=\"ignore\">\n";
+
+ /* Page header*/
+ $display= print_header(get_template_path('images/logview.png'), _("System log view")).$display;
+
+ /* Store changes in session */
+ session::set('log_tabs',$log_tabs);
+}
+?>
diff --git a/gosa-plugins/log/addons/logview/tabs_log.inc b/gosa-plugins/log/addons/logview/tabs_log.inc
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+class log_tabs extends tabs
+{
+
+ function log_tabs($config, $data, $dn)
+ {
+ tabs::tabs($config, $data, $dn);
+ }
+
+ function save_object($save_current= FALSE)
+ {
+ tabs::save_object($save_current);
+ }
+
+
+ function save($ignore_account= FALSE)
+ {
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>