Marius Burkard
2016-04-20 4569cae57f127afd093794310ccd290d2d9fdf36
commit | author | age
b7489f 1 <?php
V 2
3 /*
4 Copyright (c) 2007-2008, Till Brehm, projektfarm Gmbh and Oliver Vogel www.muv.com
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9
10     * Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright notice,
13       this list of conditions and the following disclaimer in the documentation
14       and/or other materials provided with the distribution.
15     * Neither the name of ISPConfig nor the names of its contributors
16       may be used to endorse or promote products derived from this software without
17       specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
b1a6a5 31 require_once '../../lib/config.inc.php';
MC 32 require_once '../../lib/app.inc.php';
b7489f 33
V 34 //* Check permissions for module
35 $app->auth->check_module_permissions('monitor');
31f6ce 36
M 37 $app->uses('tools_monitor');
b7489f 38
V 39 // Loading the template
40 $app->uses('tpl');
41 $app->tpl->newTemplate("form.tpl.htm");
b1a6a5 42 $app->tpl->setInclude('content_tpl', 'templates/show_log.htm');
b7489f 43
V 44 // Importing the GET values
65ea2e 45 $refresh = (isset($_GET["refresh"]))?$app->functions->intval($_GET["refresh"]):0;
b7489f 46 $logParam = $_GET["log"];
V 47
55eb00 48 /* Get some translations */
A 49 $monTransDate = $app->lng("monitor_settings_datafromdate_txt");
50 $monTransSrv = $app->lng("monitor_settings_server_txt");
51 $monTransRefreshsq = $app->lng("monitor_settings_refreshsq_txt");
52
b7489f 53 /*
V 54  Setting the db-type and the caption
55  */
56 switch($logParam) {
b1a6a5 57 case 'log_mail':
MC 58     $logId = 'log_mail';
59     $title = $app->lng("monitor_logs_mail_txt").' ('. $monTransSrv .' : ' . $_SESSION['monitor']['server_name'] . ')';
60     $description = '';
61     break;
62 case 'log_mail_warn':
63     $logId = 'log_mail_warn';
64     $title = $app->lng("monitor_logs_mailwarn_txt").' ('. $monTransSrv .' : ' . $_SESSION['monitor']['server_name'] . ')';
65     $description = '';
66     break;
67 case 'log_mail_err':
68     $logId = 'log_mail_err';
69     $title = $app->lng("monitor_logs_mailerr_txt").' ('. $monTransSrv .' : ' . $_SESSION['monitor']['server_name'] . ')';
70     $description = '';
71     break;
72 case 'log_messages':
73     $logId = 'log_messages';
74     $title = $app->lng("monitor_logs_messages_txt").' ('. $monTransSrv .' : ' . $_SESSION['monitor']['server_name'] . ')';
75     $description = '';
76     break;
77 case 'log_ispc_cron':
78     $logId = 'log_ispc_cron';
79     $title = $app->lng("monitor_logs_ispccron_txt").' ('. $monTransSrv .' : ' . $_SESSION['monitor']['server_name'] . ')';
80     $description = '';
81     break;
82 case 'log_freshclam':
83     $logId = 'log_freshclam';
84     $title = $app->lng("monitor_logs_freshclam_txt").' ('. $monTransSrv .' : ' . $_SESSION['monitor']['server_name'] . ')';
85     $description = '';
86     break;
87 case 'log_clamav':
88     $logId = 'log_clamav';
89     $title = $app->lng("monitor_logs_clamav_txt").' ('. $monTransSrv .' : ' . $_SESSION['monitor']['server_name'] . ')';
90     $description = '';
91     break;
92 case 'log_ispconfig':
93     $logId = 'log_ispconfig';
94     $title = $app->lng("monitor_logs_ispc_txt").' ('. $monTransSrv .' : ' . $_SESSION['monitor']['server_name'] . ')';
95     $description = '';
96     break;
97 default:
98     $logId = '???';
99     $title = '???';
100     $description = '';
101     break;
b7489f 102 }
V 103
104
105 /*
106  Creating the array with the refresh intervals
2c3939 107  Attention: the core-moule ist triggered every 5 minutes,
b7489f 108             so reload every 2 minutes is impossible!
V 109 */
b1a6a5 110 $refresh_values = array('0' => '- '.$app->lng("No Refresh").' -', '5' => '5 '.$app->lng("minutes"), '10' => '10 '.$app->lng("minutes"), '15' => '15 '.$app->lng("minutes"), '30' => '30 '.$app->lng("minutes"), '60' => '60 '.$app->lng("minutes"));
b7489f 111 $tmp = '';
V 112 foreach($refresh_values as $key => $val) {
113     if($key == $refresh) {
114         $tmp .= "<option value='$key' SELECTED>$val</option>";
115     } else {
116         $tmp .= "<option value='$key'>$val</option>";
117     }
118 }
b1a6a5 119 $app->tpl->setVar("refresh", $tmp);
b7489f 120
V 121
122 /* fetch the Data from the DB */
cc7a82 123 $record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = ? and server_id = ? order by created desc", $logId, $_SESSION['monitor']['server_id']);
b7489f 124
b3c1ca 125 if(isset($record['data'])) {
T 126     $data = unserialize($record['data']);
b7489f 127
b1a6a5 128     $logData = explode("\n", htmlspecialchars($data));
MC 129     $logDataHtml = '';
a8177a 130     
b1a6a5 131     /* set css class for each line of log, depending on key words in each line */
a8177a 132     foreach($logData as $line => $val) {
b1a6a5 133         if (strpos($val, 'ERROR') !== FALSE) {
MC 134             $logDataHtml .= "<div class='logerror'>$val</div>";
135         } elseif (strpos($val, 'WARN') !== FALSE) {
136             $logDataHtml .= "<div class='logwarn'>$val</div>";
137         } elseif (strpos($val, 'INFO') !== FALSE) {
138             $logDataHtml .= "<div class='loginfo'>$val</div>";
139         } else {
140             $logDataHtml .= "<div class='log'>$val</div>";
141         }
142     }
2a4acd 143
a8177a 144     $app->tpl->setVar("log_data", $logDataHtml);
b3c1ca 145 } else {
T 146     $app->tpl->setVar("log_data", $app->lng("no_logdata_txt"));
147 }
148
2c3939 149 $app->tpl->setVar("list_head_txt", $title);
b1a6a5 150 $app->tpl->setVar("log_id", $logId);
2c3939 151 $app->tpl->setVar("list_desc_txt", $description);
31f6ce 152 $app->tpl->setVar("time", $app->tools_monitor->getDataTime($logId));
55eb00 153 $app->tpl->setVar("monTransDate", $monTransDate);
A 154 $app->tpl->setVar("monTransRefreshsq", $monTransRefreshsq);
b7489f 155
V 156 $app->tpl_defaults();
157 $app->tpl->pparse();
88134f 158 ?>