/[smecontribs]/rpms/smeserver-unjunkmgr/contribs10/smeserver-unjunkmgr-cleanup-index-php.patch
ViewVC logotype

Contents of /rpms/smeserver-unjunkmgr/contribs10/smeserver-unjunkmgr-cleanup-index-php.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Tue Nov 24 14:53:14 2020 UTC (4 years ago) by jcrisp
Branch: MAIN
CVS Tags: smeserver-unjunkmgr-3_1-4_el7_sme, smeserver-unjunkmgr-3_1-2_el7_sme, smeserver-unjunkmgr-3_1-5_el7_sme, smeserver-unjunkmgr-3_1-3_el7_sme, smeserver-unjunkmgr-3_1-6_el7_sme, HEAD
* Tue Nov 24 2020 John Crisp <jcrisp@safeandsoundit.co.uk> 3.1-2.sme
- Add cleaned up and fixed index.php that I forgot

1 diff -ruN smeserver-unjunkmgr-3.1.old/root/usr/local/unjunkmgr/index.php smeserver-unjunkmgr-3.1/root/usr/local/unjunkmgr/index.php
2 --- smeserver-unjunkmgr-3.1.old/root/usr/local/unjunkmgr/index.php 2020-11-24 15:45:31.103248270 +0100
3 +++ smeserver-unjunkmgr-3.1/root/usr/local/unjunkmgr/index.php 2020-11-24 15:49:14.054768923 +0100
4 @@ -1,419 +1,443 @@
5 -<?
6 +<?php
7 include ("jpgraph/jpgraph.php");
8 include ("jpgraph/jpgraph_pie.php");
9
10 +// These are called from the HTML further down due to the way Jpgraph renders
11 +// Check for a type. This is not called on the first run through
12 $parm1 = $_GET['type'];
13 -# printf("TYPE=%s - %s\n",$type,$parm1);
14 +
15 +// For tests
16 +// printf("TYPE=%s - %s\n",$type,$parm1);
17 +// So we only run these if we are called with a type. Which is what happens in the html further down.
18 if ($parm1 == 'spamhour') {
19 - read_and_print_spam_log('/usr/local/unjunkmgr/spamfilterstats.spam.hour','last hour','graph');
20 + read_and_print_spam_log('/usr/local/unjunkmgr/spamfilterstats.spam.hour', 'last hour', 'graph');
21 } elseif ($parm1 == 'spamday') {
22 - read_and_print_spam_log('/usr/local/unjunkmgr/spamfilterstats.spam.day','last 24 hours','graph');
23 + read_and_print_spam_log('/usr/local/unjunkmgr/spamfilterstats.spam.day', 'last 24 hours', 'graph');
24 }
25 ?>
26
27 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
28 -<HTML>
29 -<HEAD>
30 - <TITLE>Corporate Virus and Spam Statistics</TITLE>
31 - <META HTTP-EQUIV="Refresh" CONTENT="300">
32 - <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
33 - <META HTTP-EQUIV="Expires" CONTENT="Mon, 19 Aug 2002 07:47:20 GMT">
34 +
35 +<html>
36 +<head>
37 + <title>Corporate Virus and Spam Statistics</title>
38 + <meta http-equiv="Refresh" content="300">
39 + <meta http-equiv="Pragma" content="no-cache">
40 + <meta http-equiv="Expires" content="Mon, 19 Aug 2002 07:47:20 GMT">
41 <link rel="stylesheet" type="text/css" href="unjunkmgr.css">
42 -</HEAD>
43 +</head>
44
45 -<center>
46 +<body>
47 + <center>
48 + <table border="3" width="940">
49 + <tr>
50 + <td align="center">
51 + <h1>Corporate Spam and Virus Statistics</h1><br>
52 + </td>
53 + </tr>
54 +
55 + <tr>
56 + <td>
57 + <table border="0" width="920" align="center">
58 + <tr>
59 + <!-- Top row 24 hours Spam & Virus stats -->
60 + <td width="25%" align="center">
61 + <h2 style="word-spacing: 0; margin-top: 0; margin-bottom: 0" align="center">Hourly Spam Statistics over last 24 hours</h2>
62 + <h2 style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><a href="spam.html"><img border="1" src="spam-day.png" width="450" height="121"></a></h2>
63 + </td>
64 + <td width="25%" align="center">
65 + <h2 style="word-spacing: 0; margin-top: 0; margin-bottom: 0" align="center">Hourly Virus Statistics over last 24 hours</h2>
66 + <h2 style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><a href="virus.html"><img border="1" src="virus-day.png" width="450" height="121"></a></h2>
67 + </td>
68 + </tr>
69 + <tr><td colspan="2">&nbsp;</td></tr>
70 + <tr>
71 + <!-- Second row last hour/24 hours Spam Pie charts-->
72 + <!-- this is where we call the script again to draw the Pie Charts-->
73 + <td align="center"><img src="index.php?type=spamhour"></td>
74 + <td align="center"><img src="index.php?type=spamday"></td>
75 +
76 + </tr>
77 + <tr><td colspan=2>&nbsp;</td></tr>
78 + <!-- This does the Virus stats charts -->
79 + <tr>
80 + <td align="center">
81 + <?php
82 +read_and_print_virus_log('/usr/local/unjunkmgr/spamfilterstats.virus.hour', 'hour', 'table'); ?>
83 + </td>
84 + <td align="center">
85 + <?php
86 +read_and_print_virus_log('/usr/local/unjunkmgr/spamfilterstats.virus.day', '24 hours', 'table'); ?>
87 + </td>
88 + </tr>
89 + <tr><td colspan=2>&nbsp;</td></tr>
90 + <!-- This does the Spam pie charts -->
91 + <tr>
92 + <td align="center">
93 + <?php //read_and_print_spam_log('/usr/local/unjunkmgr/spamfilterstats.spam.hour', 'hour', 'table');
94
95 -<table border="3" width="940">
96 -<tr><td align="center">
97 -<H1>Corporate Spam and Virus Statistics</H1><br>
98 -</td>
99 -<tr><td>
100 -<table border="0" width="920" align="center">
101 -<tr>
102 -<td width="25%" align="center">
103 -<h2 style="word-spacing: 0; margin-top: 0; margin-bottom: 0" align="center">Hourly Spam Statistics over last 24 hours</h2>
104 -<h2 style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><a href="spam.html"><img border="1" src="spam-day.png" width="450" height="121"></a></h2>
105 -</td>
106 -<td width="25%" align="center">
107 -<h2 style="word-spacing: 0; margin-top: 0; margin-bottom: 0" align="center">Hourly Virus Statistics over last 24 hours</h2>
108 -<h2 style="word-spacing: 0; margin-top: 0; margin-bottom: 0"><a HREF="virus.html"><IMG BORDER=1 SRC="virus-day.png" width="450" height="121"></a></h2>
109 -</td>
110 -</tr>
111 -<tr><td colspan=2>&nbsp;</td></tr>
112 -
113 -<tr>
114 -<td align="center">
115 -<img src="index.php?type=spamhour">
116 -</td>
117 -<td align="center">
118 -<?
119 -read_and_print_virus_log('/usr/local/unjunkmgr/spamfilterstats.virus.hour','hour','table');
120 ?>
121 -</td>
122 -</tr>
123 -
124 -<tr><td colspan=2>&nbsp;</td></tr>
125 + </td>
126 + <td align="center">
127 + <?php //read_and_print_virus_log('/usr/local/unjunkmgr/spamfilterstats.spam.day', '24 hours', 'table');
128
129 -<tr>
130 -<td align="center">
131 -<img src="index.php?type=spamday">
132 -</td>
133 -<td align="center">
134 -<?
135 -read_and_print_virus_log('/usr/local/unjunkmgr/spamfilterstats.virus.day','24 hours','table');
136 ?>
137 -</td>
138 -</tr>
139 -<tr><td colspan=2>&nbsp;</td></tr>
140 -
141 -<tr>
142 -<td align="center">
143 -<?
144 -read_and_print_virus_log('/usr/local/unjunkmgr/spamfilterstats.spam.day','24 hours','email');
145 -?>
146 -</td>
147 -<td align="center">
148 -</td>
149 -</tr>
150 -
151 -<tr><td colspan=2>&nbsp;</td></tr>
152 -
153 -</table>
154 -</HTML>
155 -
156 -<?
157 -function read_and_print_virus_log ($log_filename,$text,$style) {
158 -
159 - if(!file_exists($log_filename) || !is_readable($log_filename) || !$fd = fopen($log_filename, "r")) {
160 - print('<td width="10%" align="left"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2" colspan=2>');
161 - print('Statistics database not found');
162 - print('</td>');
163 - return;
164 - }
165 -
166 - flock($fd, 1); // get a shared lock
167 - $linecount = 0;
168 - while (!feof($fd)) {
169 - $line = fgets($fd);
170 - if ($line) {
171 -
172 - # printf("line = %s\n",$line);
173 - # $keys = split ("\|", $line) ;
174 - $keys = preg_split ("/\|/", $line) ;
175 -
176 - $list = array();
177 - foreach ($keys as $item) {
178 - # $key = split ("\=", $item);
179 - $key = preg_split ("/\=/", $item);
180 - # printf("key = %s\n",$key);
181 - if ($key[0] == 'SCANNED') {
182 - $scanned = $key[1];
183 - }
184 - if ($key[0] == 'BAD') {
185 - $bad = $key[1];
186 - }
187 - if ($key[0] == 'NAME') {
188 - $name = $key[1];
189 - } elseif ($key[0] == 'COUNT') {
190 - $count = $key[1];
191 - $list['count'] = $count;
192 - } elseif ($key[0] == 'LATEST') {
193 - $latest = $key[1];
194 - $list['latest'] = $latest;
195 + </td>
196 + </tr>
197 + <tr><td colspan=2>&nbsp;</td></tr>
198 + </table>
199 + </td>
200 + </tr>
201 + </table>
202 + </center>
203 +</body>
204 +</html>
205 +
206 +<?php
207 +function read_and_print_virus_log($log_filename, $text, $style)
208 +{
209 +
210 + if (!file_exists($log_filename) || !is_readable($log_filename) || !$fd = fopen($log_filename, "r")) {
211 + print ('<td width="10%" align="left"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2" colspan=2>');
212 + print ('Statistics database not found');
213 + print ('</td>');
214 + return;
215 + }
216 + //print ('get data virus_log');
217 + flock($fd, 1); // get a shared lock
218 + $linecount = 0;
219 + while (!feof($fd)) {
220 + $line = fgets($fd);
221 + if ($line) {
222 +
223 + // printf("line = %s\n",$line);
224 + // $keys = split ("\|", $line) ;
225 + $keys = preg_split("/\|/", $line);
226 +
227 + $list = array();
228 + foreach ($keys as $item) {
229 + // $key = split ("\=", $item);
230 + $key = preg_split("/\=/", $item);
231 + // printf("key = %s\n",$key);
232 + if ($key[0] == 'SCANNED') {
233 + $scanned = $key[1];
234 + }
235 + if ($key[0] == 'BAD') {
236 + $bad = $key[1];
237 + }
238 + if ($key[0] == 'NAME') {
239 + $name = $key[1];
240 + } elseif ($key[0] == 'COUNT') {
241 + $count = $key[1];
242 + $list['count'] = $count;
243 + } elseif ($key[0] == 'LATEST') {
244 + $latest = $key[1];
245 + $list['latest'] = $latest;
246 + }
247 + }
248 +
249 + if ($name) {
250 + $list = array(
251 + 'name' => $name,
252 + 'count' => $count,
253 + 'latest' => $latest
254 + );
255 + $print_list[$linecount++] = $list;
256 + }
257 }
258 - }
259 -
260 - if ($name) {
261 - $list = array('name' => $name,
262 - 'count' => $count,
263 - 'latest' => $latest
264 - );
265 - $print_list[$linecount++] = $list;
266 - }
267 }
268 - }
269 -
270 - flock($fd, 3); // release the lock
271 - fclose($fd);
272
273 - # Now print out results
274 + flock($fd, 3); // release the lock
275 + fclose($fd);
276
277 - $sorted_list = msort($print_list,"count",false);
278 -
279 - # print_r($sorted_list);
280 -
281 - print('<table border="2" align="center"width="98%">');
282 - if ($style == 'table') {
283 - print('<tr><td width="100%" align="center" valign="top" colspan=2 bgcolor=#888888>');
284 - print('<H2 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
285 -
286 - printf("Virus Threats last %s ",$text);
287 - print('</td>');
288 - print('<tr><td width="70%" align="left" valign="top"><H3 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
289 - printf("Emails Scanned for Virus");
290 - print('</td>');
291 - print('<td align="right"><H3 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
292 - printf("%s",number_format($scanned,0,0,'.'));
293 - print('</td>');
294 - print('</tr>');
295 - print('<tr><td width="50%" align="left"><H3 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
296 - printf("Infected with Virus");
297 - print('</td>');
298 - print('<td align="right"><H3 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
299 - if ($scanned>0) printf("%s (%.2f %%)",number_format($bad,0,2,'.'), number_format(($bad/$scanned)*100,2,'.',''));
300 - print('</td>');
301 - print('</tr>');
302 - }
303 -
304 - if ($linecount > 0) {
305 - $linecount = 0;
306 -
307 - print('<tr><H3><td width="100%" align="left" valign="top" colspan=2 bgcolor=#888888>');
308 - print('<H4 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
309 - if ($style == 'table') {
310 - print('Top Blocked Virus Threats');
311 - } else {
312 - printf("Top Spammed Emails last %s",$text);
313 + // Now print out results if they exist
314 + if (isset($print_list)) {
315 + $sorted_list = msort($print_list, "count", false);
316 }
317 - print('</td>');
318 - print('</tr>');
319 - print('<tr><td width="70%" align="left" bgcolor=#BBBBBB><H5 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
320 - if ($style == 'table') {
321 - print('Name');
322 - } else {
323 - print('Email address');
324 - }
325 - print('</td>');
326 - print('<td align="right" bgcolor=#BBBBBB><H5 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
327 - print('Count');
328 - print('</td>');
329 - print('</tr>');
330 -
331 - foreach ($sorted_list as $item) {
332 -
333 - print('<tr><td width="70%" align="left"><H5 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
334 - printf("%s",$item['name']);
335 - print('</td>');
336 - print('<td align="right"><H5 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
337 - printf("%s",$item['count']);
338 - print('</td>');
339 - print('</tr>');
340 -
341 - $linecount++;
342 -
343 - # Only show top 10...
344 - if ($linecount >= 10) {
345 - break;
346 - }
347 - }
348 - }
349
350 - print('</table>');
351 - return;
352 -}
353 + // print_r($sorted_list);
354 + print ('<table border="2" align="center"width="98%">');
355 + // This will always be table - used to have 'oldstyle'
356 + if ($style == 'table') {
357 + print ('<tr><td width="100%" align="center" valign="top" colspan=2 bgcolor=#888888>');
358 + print ('<H2 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
359
360 -function read_and_print_spam_log ($log_filename,$text,$style) {
361 + printf("Virus Threats last %s ", $text);
362 + print ('</td>');
363 + print ('<tr><td width="70%" align="left" valign="top"><H3 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
364 + printf("Emails Scanned for Virus");
365 + print ('</td>');
366 + print ('<td align="right"><H3 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
367 + printf("%s", number_format($scanned, 0, 0, '.'));
368 + print ('</td>');
369 + print ('</tr>');
370 + print ('<tr><td width="50%" align="left"><H3 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
371 + printf("Infected with Virus");
372 + print ('</td>');
373 + print ('<td align="right"><H3 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
374 + if ($scanned > 0) printf("%s (%.2f %%)", number_format($bad, 0, 2, '.') , number_format(($bad / $scanned) * 100, 2, '.', ''));
375 + print ('</td>');
376 + print ('</tr>');
377 + }
378
379 - if(!file_exists($log_filename) || !is_readable($log_filename) || !$fd = fopen($log_filename, "r")) {
380 - print('<td width="10%" align="left"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2" colspan=2>');
381 - print('Statistics database not found');
382 - print('</td>');
383 + if (isset($sorted_list)) {
384 + // This will print emails if there are any
385 + if ($linecount > 0) {
386 + $linecount = 0;
387 +
388 + print ('<tr><H3><td width="100%" align="left" valign="top" colspan=2 bgcolor=#888888>');
389 + print ('<H4 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
390 + // Always table ??
391 + if ($style == 'table') {
392 + print ('Top Blocked Virus Threats');
393 + } else {
394 + printf("Top Spammed Emails last %s", $text);
395 + }
396 + print ('</td>');
397 + print ('</tr>');
398 + print ('<tr><td width="70%" align="left" bgcolor=#BBBBBB><H5 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
399 + // Always table ??
400 + if ($style == 'table') {
401 + print ('Name');
402 + } else {
403 + print ('Email address');
404 + }
405 + print ('</td>');
406 + print ('<td align="right" bgcolor=#BBBBBB><H5 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
407 + print ('Count');
408 + print ('</td>');
409 + print ('</tr>');
410 +
411 + foreach ($sorted_list as $item) {
412 +
413 + print ('<tr><td width="70%" align="left"><H5 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
414 + printf("%s", $item['name']);
415 + print ('</td>');
416 + print ('<td align="right"><H5 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
417 + printf("%s", $item['count']);
418 + print ('</td>');
419 + print ('</tr>');
420 +
421 + $linecount++;
422 +
423 + // Only show top 10...
424 + if ($linecount >= 10) {
425 + break;
426 + }
427 + }
428 + }
429 + } // End isset
430 + print ('</table>');
431 return;
432 - }
433 +}
434
435 - flock($fd, 1); // get a shared lock
436 - $linecount = 0;
437 - while (!feof($fd)) {
438 - $line = fgets($fd);
439 - if ($line) {
440 - # printf("line = %s\n",$line);
441 - # $keys = split ("\|", $line) ;
442 - $keys = preg_split ("/\|/", $line) ;
443 -
444 - $list = array();
445 - foreach ($keys as $item) {
446 - # $key = split ("\=", $item);
447 - $key = preg_split ("/\=/", $item);
448 - # printf("key = %s\n",$key);
449 +function read_and_print_spam_log($log_filename, $text, $style)
450 +{
451
452 - if ($key[0] == 'SCANNED') {
453 - $scanned = $key[1];
454 - }
455 - if ($key[0] == 'REJECT') {
456 - $reject = $key[1];
457 - }
458 - if ($key[0] == 'TAGGED') {
459 - $tagged = $key[1];
460 + if (!file_exists($log_filename) || !is_readable($log_filename) || !$fd = fopen($log_filename, "r")) {
461 + print ('<td width="10%" align="left"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2" colspan=2>');
462 + print ('Statistics database not found');
463 + print ('</td>');
464 + return;
465 + }
466 + //print ('get data spam_log');
467 + flock($fd, 1); // get a shared lock
468 + $linecount = 0;
469 + while (!feof($fd)) {
470 + $line = fgets($fd);
471 + if ($line) {
472 + // printf("line = %s\n",$line);
473 + // $keys = split ("\|", $line) ;
474 + $keys = preg_split("/\|/", $line);
475 + $list = array();
476 + foreach ($keys as $item) {
477 + // $key = split ("\=", $item);
478 + $key = preg_split("/\=/", $item);
479 + // printf("key = %s\n",$key);
480 + if ($key[0] == 'SCANNED') {
481 + $scanned = $key[1];
482 + }
483 + if ($key[0] == 'REJECT') {
484 + $reject = $key[1];
485 + }
486 + if ($key[0] == 'TAGGED') {
487 + $tagged = $key[1];
488 + }
489 + }
490 }
491 -
492 - }
493 }
494 - }
495 -
496 - flock($fd, 3); // release the lock
497 - fclose($fd);
498 -
499 - if ($style == 'oldstyle') {
500 - print('<table border="2" align="center" width="98%">');
501
502 - print('<tr><td width="70%" align="left"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
503 - printf("Scanned for Spam");
504 - print('</td>');
505 - print('<td align="right"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
506 - printf("%s",number_format($scanned,0,0,'.'));
507 - print('</td>');
508 - print('</tr>');
509 -
510 - print('<tr><td width="70%" align="left" valign="top"><H3 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
511 - printf("Good");
512 - print('</td>');
513 - print('<td align="right"><H3 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
514 - $good_emails = $scanned-($reject+$tagged);
515 - printf("%s (%.2d %%)",number_format($good_emails,0,0,'.'),($good_emails/$scanned)*100);
516 - print('</td>');
517 - print('</tr>');
518 -
519 -
520 - print('<tr><td width="50%" align="left"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
521 - printf("Rejected as Spam");
522 - print('<td align="right"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
523 - printf("%s (%.2d %%)",number_format($reject,0,0,'.'),($reject/$scanned)*100);
524 - print('</td>');
525 - print('</tr>');
526 -
527 - print('<tr><td width="50%" align="left"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
528 - printf("Accepted but Tagged as Spam");
529 - print('<td align="right"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
530 - printf("%s (%.2d %%)",number_format($tagged,0,0,'.'),($tagged/$scanned)*100);
531 - print('</td>');
532 - print('</tr>');
533 - print('<br>');
534 - print('</table>');
535 + flock($fd, 3); // release the lock
536 + fclose($fd);
537
538 - } else {
539 - $good_emails = $scanned-($reject+$tagged);
540 + //if ($style == 'oldstyle') {
541 + // print('<table border="2" align="center" width="98%">');
542 + //
543 + // print('<tr><td width="70%" align="left"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
544 + // printf("Scanned for Spam");
545 + // print('</td>');
546 + // print('<td align="right"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
547 + // printf("%s",number_format($scanned,0,0,'.'));
548 + // print('</td>');
549 + // print('</tr>');
550 + //
551 + // print('<tr><td width="70%" align="left" valign="top"><H3 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
552 + // printf("Good");
553 + // print('</td>');
554 + // print('<td align="right"><H3 style="word-spacing: 0; margin-top: 0; margin-bottom: 2; margin-left: 2">');
555 + // $good_emails = $scanned-($reject+$tagged);
556 + // printf("%s (%.2d %%)",number_format($good_emails,0,0,'.'),($good_emails/$scanned)*100);
557 + // print('</td>');
558 + // print('</tr>');
559 + //
560 + //
561 + // print('<tr><td width="50%" align="left"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
562 + // printf("Rejected as Spam");
563 + // print('<td align="right"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
564 + // printf("%s (%.2d %%)",number_format($reject,0,0,'.'),($reject/$scanned)*100);
565 + // print('</td>');
566 + // print('</tr>');
567 + //
568 + // print('<tr><td width="50%" align="left"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
569 + // printf("Accepted but Tagged as Spam");
570 + // print('<td align="right"><H3 style="word-spacing: 0; margin-top: 2; margin-bottom: 2; margin-left: 2">');
571 + // printf("%s (%.2d %%)",number_format($tagged,0,0,'.'),($tagged/$scanned)*100);
572 + // print('</td>');
573 + // print('</tr>');
574 + // print('<br>');
575 + // print('</table>');
576 + //
577 + //} else {
578 + $good_emails = $scanned - ($reject + $tagged);
579
580 - # what if no emails went through??
581 + // what if no emails went through??
582 if ($scanned == 0) {
583
584 - include "jpgraph/jpgraph_canvas.php";
585 - include "jpgraph/jpgraph_canvtools.php";
586 + include "jpgraph/jpgraph_canvas.php";
587 + include "jpgraph/jpgraph_canvtools.php";
588
589 + $g = new CanvasGraph(450, 260, 'auto');
590 + $scale = new CanvasScale($g);
591 + $scale->Set(0, 27, 0, 53);
592 + $g->SetMargin(1, 2, 1, 2);
593 + $g->SetColor('white');
594 + $g->SetMarginColor("black");
595 + $g->InitFrame();
596 +
597 + $t = new CanvasRectangleText();
598 +
599 + $t->SetFillColor('');
600 + $t->SetFontColor('black');
601 + $t->SetColor('');
602 + $t->SetShadow('');
603 + $t->SetFont(FF_ARIAL, FS_BOLD, 14);
604 + $t->Set('No emails scanned for spam last hour', 8, 1, 8);
605 + $t->Stroke($g->img, $scale);
606
607 - $g = new CanvasGraph(450,260,'auto');
608 - $scale = new CanvasScale($g);
609 - $scale->Set(0,27,0,53);
610 - $g->SetMargin(1,2,1,2);
611 - $g->SetColor('white');
612 - $g->SetMarginColor("black");
613 - $g->InitFrame();
614 -
615 - $t = new CanvasRectangleText();
616 -
617 - $t->SetFillColor('');
618 - $t->SetFontColor('black');
619 - $t->SetColor('');
620 - $t->SetShadow('');
621 - $t->SetFont(FF_ARIAL,FS_BOLD,14);
622 - $t->Set('No emails scanned for spam last hour',8,1,8);
623 - $t->Stroke($g->img,$scale);
624 -
625 -
626 - $g->Stroke();
627 - return;
628 + $g->Stroke();
629 + return;
630 }
631
632 // Some data
633 - $data = array($reject,$tagged,$good_emails);
634 + $data = array(
635 + $good_emails,
636 + $tagged,
637 + $reject
638 + );
639
640 // A new pie graph
641 - $graph = new PieGraph(450,260,'auto');
642 + $graph = new PieGraph(450, 260, 'auto');
643
644 // Setup title
645 $graph->title->Set("Spam Statistics " . $text);
646 - $graph->title->SetFont(FF_ARIAL,FS_BOLD,14);
647 + $graph->title->SetFont(FF_ARIAL, FS_BOLD, 14);
648 $graph->title->SetMargin(3); // Add a little bit more margin from the top
649 -
650 $graph->footer->center->Set("Generated " . date('l jS \of F Y h:i:s A'));
651
652 // Create the pie plot
653 $p1 = new PiePlotC($data);
654 - # $p1->value->SetColor("navy");
655 - $p1->SetCenter(0.35,0.50);
656 -
657 - $p1->SetLegends(array("Rejected (" . number_format($reject,0,0,'.') . ")" ,
658 - "Tagged (" . number_format($tagged,0,0,'.') . ")" ,
659 - "Good (" . number_format($good_emails,0,0,'.') . ")"
660 - ));
661 -
662 - $graph->legend->Pos(0.05,0.65);
663 -
664 - $p1->SetSliceColors(array("red","orange","green"));
665 -
666 - # Create the extra text box to show scanned emails number
667 - # $txt = new Text();
668 - # $txt->Set("Total scanned " . number_format($scanned,0,0,'.'));
669 - # $txt->ParagraphAlign('right');
670 - # $txt->Show();
671 - # $txt->SetFont(FF_VERDANA,FS_NORMAL,8);
672 - # $txt->Pos(0.82,0.5,'center','bottom');
673 - # $txt->SetBox('gray9','black','gray9',0,2);
674 - # $txt->SetShadow();
675 - # $graph->AddText($txt);
676 -
677 - # $p1->Explode(array(0,15,15,25,15));
678 + // $p1->value->SetColor("navy");
679 + $p1->SetCenter(0.35, 0.50);
680
681 + $p1->SetLegends(array(
682 + "Good (" . number_format($good_emails, 0, 0, '.') . ")",
683 + "Tagged (" . number_format($tagged, 0, 0, '.') . ")",
684 + "Rejected (" . number_format($reject, 0, 0, '.') . ")",
685 + ));
686 +
687 + $graph->legend->Pos(0.10, 0.30);
688 + $graph->legend->SetLayout(LEGEND_VERT);
689 +
690 + $p1->SetSliceColors(array(
691 + "green",
692 + "orange",
693 + "red"
694 + ));
695 +
696 + // Create the extra text box to show scanned emails number
697 + // $txt = new Text();
698 + // $txt->Set("Total scanned " . number_format($scanned,0,0,'.'));
699 + // $txt->ParagraphAlign('right');
700 + // $txt->Show();
701 + // $txt->SetFont(FF_VERDANA,FS_NORMAL,8);
702 + // $txt->Pos(0.82,0.5,'center','bottom');
703 + // $txt->SetBox('gray9','black','gray9',0,2);
704 + // $txt->SetShadow();
705 + // $graph->AddText($txt);
706 + // $p1->Explode(array(0,15,15,25,15));
707 // Set size of pie
708 $p1->SetSize(0.32);
709
710 // Label font and color setup
711 - $p1->value->SetFont(FF_VERDANA,FS_BOLD,10);
712 + $p1->value->SetFont(FF_VERDANA, FS_BOLD, 10);
713 $p1->value->SetColor('black');
714
715 // Setup the title on the center circle
716 - $p1->midtitle->Set("Total of\n" . number_format($scanned,0,0,'.') . "\nscanned");
717 - $p1->midtitle->SetFont(FF_VERDANA,FS_NORMAL,10);
718 + $p1->midtitle->Set("Total of\n" . number_format($scanned, 0, 0, '.') . "\nscanned");
719 + $p1->midtitle->SetFont(FF_VERDANA, FS_NORMAL, 10);
720
721 // Set color for mid circle
722 $p1->SetMidColor('yellow');
723
724 // Use percentage values in the legends values (This is also the default)
725 $p1->SetLabelType(PIE_VALUE_PER);
726 - # $p1->SetLabelPos(0.8);
727 + // $p1->SetLabelPos(0.8);
728 // Add plot to pie graph
729 $graph->Add($p1);
730
731 - // .. and send the image on it's marry way to the browser
732 + // .. and send the image on it's merry way to the browser
733 $graph->Stroke();
734
735 - }
736 - return;
737 + //}
738 + return;
739 }
740
741 -
742 -function msort($array, $id="id", $sort_ascending=true) {
743 - $temp_array = array();
744 - while(count($array)>0) {
745 - $lowest_id = 0;
746 - $index=0;
747 - foreach ($array as $item) {
748 - if (isset($item[$id])) {
749 - if ($array[$lowest_id][$id]) {
750 - if ($item[$id]<$array[$lowest_id][$id]) {
751 - $lowest_id = $index;
752 - }
753 +function msort($array, $id = "id", $sort_ascending = true)
754 +{
755 + $temp_array = array();
756 + while (count($array) > 0) {
757 + $lowest_id = 0;
758 + $index = 0;
759 + foreach ($array as $item) {
760 + if (isset($item[$id])) {
761 + if ($array[$lowest_id][$id]) {
762 + if ($item[$id] < $array[$lowest_id][$id]) {
763 + $lowest_id = $index;
764 + }
765 + }
766 + }
767 + $index++;
768 }
769 - }
770 - $index++;
771 + $temp_array[] = $array[$lowest_id];
772 + $array = array_merge(array_slice($array, 0, $lowest_id) , array_slice($array, $lowest_id + 1));
773 + }
774 + if ($sort_ascending) {
775 + return $temp_array;
776 + } else {
777 + return array_reverse($temp_array);
778 }
779 - $temp_array[] = $array[$lowest_id];
780 - $array = array_merge(array_slice($array, 0,$lowest_id), array_slice($array, $lowest_id+1));
781 - }
782 - if ($sort_ascending) {
783 - return $temp_array;
784 - } else {
785 - return array_reverse($temp_array);
786 - }
787 }
788
789 +?>
790 +
791

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed