summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6960bab)
raw | patch | inline | side by side (parent: 6960bab)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 25 May 2007 12:31:18 +0000 (12:31 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 25 May 2007 12:31:18 +0000 (12:31 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6485 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/addons/logview/class_gosa_logview.inc | patch | blob | history | |
plugins/addons/logview/gosa_log_contents.tpl | patch | blob | history | |
plugins/addons/logview/main.inc | patch | blob | history |
diff --git a/plugins/addons/logview/class_gosa_logview.inc b/plugins/addons/logview/class_gosa_logview.inc
index 5ea39b5f7df686bea195fa7c9bcf10aa5c838736..2eafa4423803a82362a3125e135a877204c833ef 100644 (file)
var $objectclasses = array();
var $server = "";
-
-
-
-
+ var $action = "view";
+ var $time = 2;
+ var $regex = "*";
var $start = 0;
var $sort = 2;
var $sort_direction= "down";
- var $loglevellist= array();
- var $tilist= array();
- var $fields= array("objecttype", "host", "timestamp", "message");
- var $last= array("objecttype", "host", "time", "regex");
+ var $fields= array("action","timestamp","user","result");//"id","timestamp","user","action","objecttype","object","changes","result");
var $range = 25;
var $view_logged = FALSE;
{
/* Include config object */
$this->config= $config;
-
- /* Get global filter config */
- if (1==1 || !is_global("gosa_log_filter")){
- $gosa_log_filter= array(
- "time" => "1",
- "objecttype" => "!All",
- "host" => "!All",
- "regex" => "*");
-
- register_global("gosa_log_filter", $gosa_log_filter);
- }
-
$this->ui = get_userinfo();
+
+ $this->set_acl_category("logview");
}
function execute()
}
/* Time interval */
- $date_select = array("0" => _("one hour"), "1" => _("6 hours"),
+ $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"));
+ "4" => _("2 days"), "5" => _("one week"),
+ "6" => _("2 weeks"), "7" => _("one month"));
+
+ $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);
- $gosa_log_filter= get_global("gosa_log_filter");
$smarty= get_smarty();
$smarty->assign("search_result", "");
$smarty->assign("plug", "?plug=".validate($_GET['plug']));
$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("loglevellist", $this->loglevellist);
$smarty->assign("date_select", $date_select);
$smarty->assign("mode0", "");
$smarty->assign("mode1", "");
$smarty->assign("mode3", "");
/* Assign select option content */
- foreach( array("host", "objecttype", "time", "regex") as $type){
- $smarty->assign("$type", $gosa_log_filter[$type]);
+ foreach( array("server", "action", "time", "regex") as $type){
+ $smarty->assign("$type", $this->$type);
}
/****
return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
}
- $smarty->assign("regex", $gosa_log_filter['regex']);
- $smarty->assign("servers",$servers);
- $smarty->assign("server",$this->server);
- $smarty->assign("date_select", $date_select);
+
+ /****
+ * Get all action types
+ ****/
+
+ $actions = array();
+ $query = "SELECT distinct(action) FROM gosa_log;";
+ $res = @mysql_query($query);
+ while($attrs = @mysql_fetch_assoc($res)){
+ $actions[$attrs['action']] = $attrs['action'];
+ }
+
/****
* Check Acls
****/
$tmp_cat_bases = $this->ui->get_module_departments("logview");
$all_acls = "";
+ print_a($tmp_cat_bases);
foreach($tmp_cat_bases as $acl_base){
$all_acls .= $this->ui->get_permissions($acl_base,"logview/logview");
}
/* Show main page */
$smarty->assign("range_selector", "");
$smarty->assign("search_result", $res);
- return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
+# return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
}
new log("debug","logview","",array(),@mysql_error());
} else {
- /* Assemble time query */
- switch ($gosa_log_filter['time']){
- case '0':
- $start= time() - 3600;
- break;
- ;;
- case '1':
- $start= time() - 21600;
- break;
- ;;
- case '2':
- $start= time() - 43200;
- break;
- ;;
- case '3':
- $start= time() - 86400;
- break;
- ;;
- case '4':
- $start= time() - 172800;
- break;
- ;;
- case '5':
- $start= time() - 604800;
- break;
- ;;
- case '6':
- $start= time() - 1209600;
- break;
- ;;
- case '7':
- $start= time() - 2419200;
- break;
- ;;
- }
+
- /* Assemble log level query */
- if ($gosa_log_filter['object'] == '!All'){
- $ll= "";
- } else {
- $ll= "AND objecttype='".$gosa_log_filter['objecttype']."'";
- }
- if ($gosa_log_filter['host'] == '!All'){
- $hf= "";
- } else {
- $hf= "AND host='".$gosa_log_filter['host']."'";
- }
+ $start = $date_select_[$this->time];
/* Order setting */
if ($this->sort_direction == "down"){
$query_base= " FROM
gosa_log
WHERE
- result like '".preg_replace("/\*/","%",$gosa_log_filter['regex'])."'
- $ll
- $hf
- AND
+ result like '".preg_replace("/\*/","%",$this->regex)."'
+ AND
+ action like '".$this->action."'
+ AND
timestamp <= $end AND timestamp >= $start";
/* Get number of entries */
}
$res.=" <tr style=\"$col\">\n";
- $res.=" <td style=\"text-align:center\">
- <img alt=\"".$line['objecttype']."\"
- src=\"".get_template_path('images/log_'.strtolower($line['objecttype'])).".png\"
- title=\"Log level is '".$line['objecttype']."'\">
- </td>";
- $res.=" <td>".
- $line['host']."
- </td>";
- $res.=" <td>".
- $line['timestamp']."
- </td>";
- $res .= "<td width=\"100%\">".
- $line['message']."
- </td>";
+ $res.=" <td>".$line['action']."</td>";
+ $res.=" <td>".date("H:i:s d.m.Y",$line['timestamp'])."</td>";
+ $res.=" <td>".preg_replace("/,/",", ",$line['user'])."</td>";
+ $res.=" <td>".$line['result']."</td>";
$res.=" </tr>\n";
}
mysql_close($link);
$smarty->assign("mode".$this->sort, $sort_sign);
- $smarty->assign("host", $gosa_log_filter['host']);
- $smarty->assign("objecttype", $gosa_log_filter['objecttype']);
-
$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);
+
/* Show main page */
return ($smarty->fetch (get_template_path('gosa_log_contents.tpl', TRUE)));
}
}
}
- /* Save data */
- $gosa_log_filter= get_global("gosa_log_filter");
-
/* Get actual select boxe values */
$logfilter_changed = FALSE;
- foreach( array("host", "time", "objecttype", "regex") as $type){
-
- /* Set new value and test if value has changed */
- $last[$type] = $gosa_log_filter[$type];
- if (isset($_POST[$type])){
- $gosa_log_filter[$type]= $_POST[$type];
- }
-
- if ($last[$type] != $gosa_log_filter[$type]){
- $logfilter_changed = TRUE;
+ foreach( array("server", "action","time","regex") as $type){
+ if(isset($_POST[$type])){
+ $this->$type = $_POST[$type];
}
}
/* Filter regex values */
- if ($gosa_log_filter['regex'] == ""){
- $gosa_log_filter['regex']= '%';
+ if ($this->regex == ""){
+ $this->regex= '*';
} else {
- $new = preg_replace('/\*\**/', '*', $gosa_log_filter['regex']);
- $gosa_log_filter['regex']= $new;
+ $new = preg_replace('/\*\**/', '*', $this->regex);
+ $this->regex= $new;
}
- /* Store filter values */
- register_global("gosa_log_filter", $gosa_log_filter);
-
/* Set start value */
if (isset($_GET['start'])){
$this->start= (int)$_GET['start'];
/* Adapt sorting */
if (isset($_GET['sort'])){
if ($this->sort == (int)$_GET['sort']){
+ echo $this->sort_direction."<br>";
if ($this->sort_direction == "down"){
$this->sort_direction= "up";
} else {
diff --git a/plugins/addons/logview/gosa_log_contents.tpl b/plugins/addons/logview/gosa_log_contents.tpl
index d6afe0f89aa4fafe8cc8245eb003b889a2529f0f..c01f6b434f2ad615d038bf8391b17a03df1a68c5 100644 (file)
</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><img class="center" alt="" align="middle" border=0 src="{$log_image}"> <LABEL for="action">{t}Action{/t}</label></td>
<td>
- <select id="log_level" name="log_level" size=1 onChange="mainform.submit()">
- {html_options options=$loglevellist selected=$log_level}
+ <select id="action" name="action" size=1 onChange="mainform.submit()">
+ {html_options options=$actions selected=$action}
<option disabled> </option>
</select>
</td>
{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=0>{t}Action{/t} {$mode0}</a></td>
+ <td><a href=main.php{$plug}&sort=1>{t}Object{/t} {$mode1}</a></td>
+ <td><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}
index e06e034c0216e7c13b48d38aaa57946b9f024895..01304bc896bed67f37931856a8994380b0a49f00 100644 (file)
$log_tabs= $_SESSION['log_tabs'];
/* Execute formular */
- $display= $log_tabs->save_object();
+# $display= $log_tabs->save_object();
$display= $log_tabs->execute ();
$display.= "<input type=\"hidden\" name=\"ignore\">\n";