Skip to content

Commit b3c1caa

Browse files
committed
Fixed a few php warnings in the log module which appeared when no log data is available.
1 parent 7f702ab commit b3c1caa

File tree

3 files changed

+120
-80
lines changed

3 files changed

+120
-80
lines changed

interface/web/monitor/lib/lang/en.lng

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,11 @@ $wb['Messages'] = 'Messages';
1818
$wb['Freshclam'] = 'Freshclam';
1919
$wb['Clamav'] = 'Clamav';
2020
$wb['ISPConfig'] = 'ISPConfig';
21+
$wb['no_data_serverload_txt'] = 'No data about the server load available at the moment. Please check again later.';
22+
$wb['no_data_memusage_txt'] = 'No data about the memory usage available at the moment. Please check again later.';
23+
$wb['no_data_diskusage_txt'] = 'No data about the disk usage available at the moment. Please check again later.';
24+
$wb['no_data_cpuinfo_txt'] = 'No data about the CPU available at the moment. Please check again later.';
25+
$wb['no_data_services_txt'] = 'No data about the services available at the moment. Please check again later.';
26+
$wb['no_logdata_txt'] = 'No log data available at the moment. Please check again later.';
2127

2228
?>

interface/web/monitor/show_data.php

Lines changed: 104 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,14 @@ function showServerLoad(){
114114

115115
/* fetch the Data from the DB */
116116
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'server_load' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc");
117-
$data = unserialize($record['data']);
118117

119-
/*
120-
Format the data
121-
*/
122-
$html .=
118+
if(isset($record['data'])) {
119+
$data = unserialize($record['data']);
120+
121+
/*
122+
Format the data
123+
*/
124+
$html .=
123125
'<table id="system_load">
124126
<tr>
125127
<td>' . $app->lng("Server online since").':</td>
@@ -142,6 +144,10 @@ function showServerLoad(){
142144
<td>' . $data['load_15'] . '</td>
143145
</tr>
144146
</table>';
147+
} else {
148+
$html = '<p>'.$app->lng("no_data_serverload_txt").'</p>';
149+
}
150+
145151
return $html;
146152
}
147153

@@ -150,20 +156,26 @@ function showDiskUsage () {
150156

151157
/* fetch the Data from the DB */
152158
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'disk_usage' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc");
153-
$data = unserialize($record['data']);
154159

155-
/*
156-
Format the data
157-
*/
158-
$html .= '<table id="system_disk">';
159-
foreach($data as $line) {
160-
$html .= '<tr>';
161-
foreach ($line as $item) {
162-
$html .= '<td>' . $item . '</td>';
160+
if(isset($record['data'])) {
161+
$data = unserialize($record['data']);
162+
163+
/*
164+
Format the data
165+
*/
166+
$html .= '<table id="system_disk">';
167+
foreach($data as $line) {
168+
$html .= '<tr>';
169+
foreach ($line as $item) {
170+
$html .= '<td>' . $item . '</td>';
171+
}
172+
$html .= '</tr>';
163173
}
164-
$html .= '</tr>';
174+
$html .= '</table>';
175+
} else {
176+
$html = '<p>'.$app->lng("no_data_diskusage_txt").'</p>';
165177
}
166-
$html .= '</table>';
178+
167179

168180
return $html;
169181
}
@@ -175,22 +187,28 @@ function showMemUsage ()
175187

176188
/* fetch the Data from the DB */
177189
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'mem_usage' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc");
178-
$data = unserialize($record['data']);
179190

180-
/*
181-
Format the data
182-
*/
183-
$html .= '<table id="system_memusage">';
191+
if(isset($record['data'])) {
192+
$data = unserialize($record['data']);
184193

185-
foreach($data as $key => $value){
186-
if ($key != '') {
187-
$html .= '<tr>
194+
/*
195+
Format the data
196+
*/
197+
$html .= '<table id="system_memusage">';
198+
199+
foreach($data as $key => $value){
200+
if ($key != '') {
201+
$html .= '<tr>
188202
<td>' . $key . ':</td>
189203
<td>' . $value . '</td>
190204
</tr>';
205+
}
191206
}
207+
$html .= '</table>';
208+
} else {
209+
$html = '<p>'.$app->lng("no_data_memusage_txt").'</p>';
192210
}
193-
$html .= '</table>';
211+
194212
return $html;
195213
}
196214

@@ -200,21 +218,26 @@ function showCpuInfo ()
200218

201219
/* fetch the Data from the DB */
202220
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'cpu_info' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc");
203-
$data = unserialize($record['data']);
204221

205-
/*
206-
Format the data
207-
*/
208-
$html .= '<table id="system_cpu">';
209-
foreach($data as $key => $value){
210-
if ($key != '') {
211-
$html .= '<tr>
222+
if(isset($record['data'])) {
223+
$data = unserialize($record['data']);
224+
225+
/*
226+
Format the data
227+
*/
228+
$html .= '<table id="system_cpu">';
229+
foreach($data as $key => $value){
230+
if ($key != '') {
231+
$html .= '<tr>
212232
<td>' . $key . ':</td>
213233
<td>' . $value . '</td>
214234
</tr>';
235+
}
215236
}
237+
$html .= '</table>';
238+
} else {
239+
$html = '<p>'.$app->lng("no_data_cpuinfo_txt").'</p>';
216240
}
217-
$html .= '</table>';
218241

219242
return $html;
220243
}
@@ -225,76 +248,81 @@ function showServices ()
225248

226249
/* fetch the Data from the DB */
227250
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = 'services' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc");
228-
$data = unserialize($record['data']);
229251

230-
/*
231-
Format the data
232-
*/
233-
$html .= '<table id="system_services">';
252+
if(isset($record['data'])) {
253+
$data = unserialize($record['data']);
234254

235-
if($data['webserver'] == true) {
236-
$status = '<span class="online">Online</span>';
237-
} else {
238-
$status = '<span class="offline">Offline</span>';
239-
}
240-
$html .= '<tr>
255+
/*
256+
Format the data
257+
*/
258+
$html .= '<table id="system_services">';
259+
260+
if($data['webserver'] == true) {
261+
$status = '<span class="online">Online</span>';
262+
} else {
263+
$status = '<span class="offline">Offline</span>';
264+
}
265+
$html .= '<tr>
241266
<td>Web-Server:</td>
242267
<td>'.$status.'</td>
243268
</tr>';
244269

245270

246-
if($data['ftpserver'] == true) {
247-
$status = '<span class="online">Online</span>';
248-
} else {
249-
$status = '<span class="offline">Offline</span>';
250-
}
251-
$html .= '<tr>
271+
if($data['ftpserver'] == true) {
272+
$status = '<span class="online">Online</span>';
273+
} else {
274+
$status = '<span class="offline">Offline</span>';
275+
}
276+
$html .= '<tr>
252277
<td>FTP-Server:</td>
253278
<td>'.$status.'</td>
254279
</tr>';
255280

256-
if($data['smtpserver'] == true) {
257-
$status = '<span class="online">Online</span>';
258-
} else {
259-
$status = '<span class="offline">Offline</span>';
260-
}
261-
$html .= '<tr>
281+
if($data['smtpserver'] == true) {
282+
$status = '<span class="online">Online</span>';
283+
} else {
284+
$status = '<span class="offline">Offline</span>';
285+
}
286+
$html .= '<tr>
262287
<td>SMTP-Server:</td>
263288
<td>'.$status.'</td>
264289
</tr>';
265290

266-
if($data['pop3server'] == true) {
267-
$status = '<span class="online">Online</span>';
268-
} else {
269-
$status = '<span class="offline">Offline</span>';
270-
}
271-
$html .= '<tr>
291+
if($data['pop3server'] == true) {
292+
$status = '<span class="online">Online</span>';
293+
} else {
294+
$status = '<span class="offline">Offline</span>';
295+
}
296+
$html .= '<tr>
272297
<td>POP3-Server:</td>
273298
<td>'.$status.'</td>
274299
</tr>';
275300

276-
if($data['bindserver'] == true) {
277-
$status = '<span class="online">Online</span>';
278-
} else {
279-
$status = '<span class="offline">Offline</span>';
280-
}
281-
$html .= '<tr>
301+
if($data['bindserver'] == true) {
302+
$status = '<span class="online">Online</span>';
303+
} else {
304+
$status = '<span class="offline">Offline</span>';
305+
}
306+
$html .= '<tr>
282307
<td>DNS-Server:</td>
283308
<td>'.$status.'</td>
284309
</tr>';
285310

286-
if($data['mysqlserver'] == true) {
287-
$status = '<span class="online">Online</span>';
288-
} else {
289-
$status = '<span class="offline">Offline</span>';
290-
}
291-
$html .= '<tr>
311+
if($data['mysqlserver'] == true) {
312+
$status = '<span class="online">Online</span>';
313+
} else {
314+
$status = '<span class="offline">Offline</span>';
315+
}
316+
$html .= '<tr>
292317
<td>mySQL-Server:</td>
293318
<td>'.$status.'</td>
294319
</tr>';
295320

296321

297-
$html .= '</table></div>';
322+
$html .= '</table></div>';
323+
} else {
324+
$html = '<p>'.$app->lng("no_data_services_txt").'</p>';
325+
}
298326

299327

300328
return $html;

interface/web/monitor/show_log.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
$app->tpl->setInclude('content_tpl','templates/show_log.htm');
4141

4242
// Importing the GET values
43-
$refresh = intval($_GET["refresh"]);
43+
$refresh = (isset($_GET["refresh"]))?intval($_GET["refresh"]):0;
4444
$logParam = $_GET["log"];
4545

4646

@@ -102,11 +102,17 @@
102102

103103
/* fetch the Data from the DB */
104104
$record = $app->db->queryOneRecord("SELECT data, state FROM monitor_data WHERE type = '" . $app->db->quote($logId) . "' and server_id = " . $_SESSION['monitor']['server_id'] . " order by created desc");
105-
$data = unserialize($record['data']);
106105

107-
$logData = nl2br($data);
106+
if(isset($record['data'])) {
107+
$data = unserialize($record['data']);
108+
109+
$logData = nl2br($data);
110+
111+
$app->tpl->setVar("log_data", $logData);
112+
} else {
113+
$app->tpl->setVar("log_data", $app->lng("no_logdata_txt"));
114+
}
108115

109-
$app->tpl->setVar("log_data", $logData);
110116
$app->tpl->setVar("title", $title);
111117
$app->tpl->setVar("log_id",$logId);
112118

0 commit comments

Comments
 (0)