Corporate Spam and Virus Statistics


Hourly Spam Statistics over last 24 hours

Hourly Virus Statistics over last 24 hours

 
 
 
 

'); print ('Statistics database not found'); print (''); return; } //print ('get data virus_log'); flock($fd, 1); // get a shared lock $linecount = 0; while (!feof($fd)) { $line = fgets($fd); if ($line) { // printf("line = %s\n",$line); // $keys = split ("\|", $line) ; $keys = preg_split("/\|/", $line); $list = array(); foreach ($keys as $item) { // $key = split ("\=", $item); $key = preg_split("/\=/", $item); // printf("key = %s\n",$key); if ($key[0] == 'SCANNED') { $scanned = $key[1]; } if ($key[0] == 'BAD') { $bad = $key[1]; } if ($key[0] == 'NAME') { $name = $key[1]; } elseif ($key[0] == 'COUNT') { $count = $key[1]; $list['count'] = $count; } elseif ($key[0] == 'LATEST') { $latest = $key[1]; $list['latest'] = $latest; } } if ($name) { $list = array( 'name' => $name, 'count' => $count, 'latest' => $latest ); $print_list[$linecount++] = $list; } } } flock($fd, 3); // release the lock fclose($fd); // Now print out results if they exist if (isset($print_list)) { $sorted_list = msort($print_list, "count", false); } // print_r($sorted_list); print (''); // This will always be table - used to have 'oldstyle' if ($style == 'table') { print (''); print (''); print (''); print (''); print (''); print (''); print (''); } if (isset($sorted_list)) { // This will print emails if there are any if ($linecount > 0) { $linecount = 0; print ('

'); print (''); print (''); print (''); print (''); foreach ($sorted_list as $item) { print (''); print (''); print (''); $linecount++; // Only show top 10... if ($linecount >= 10) { break; } } } } // End isset print ('
'); print ('

'); printf("Virus Threats last %s ", $text); print ('

'); printf("Emails Scanned for Virus"); print ('

'); printf("%s", number_format($scanned, 0, 0, '.')); print ('

'); printf("Infected with Virus"); print ('

'); if ($scanned > 0) printf("%s (%.2f %%)", number_format($bad, 0, 2, '.') , number_format(($bad / $scanned) * 100, 2, '.', '')); print ('

'); print ('

'); // Always table ?? if ($style == 'table') { print ('Top Blocked Virus Threats'); } else { printf("Top Spammed Emails last %s", $text); } print ('

'); // Always table ?? if ($style == 'table') { print ('Name'); } else { print ('Email address'); } print ('
'); print ('Count'); print ('
'); printf("%s", $item['name']); print ('
'); printf("%s", $item['count']); print ('
'); return; } function read_and_print_spam_log($log_filename, $text, $style) { if (!file_exists($log_filename) || !is_readable($log_filename) || !$fd = fopen($log_filename, "r")) { print ('

'); print ('Statistics database not found'); print (''); return; } //print ('get data spam_log'); flock($fd, 1); // get a shared lock $linecount = 0; while (!feof($fd)) { $line = fgets($fd); if ($line) { // printf("line = %s\n",$line); // $keys = split ("\|", $line) ; $keys = preg_split("/\|/", $line); $list = array(); foreach ($keys as $item) { // $key = split ("\=", $item); $key = preg_split("/\=/", $item); // printf("key = %s\n",$key); if ($key[0] == 'SCANNED') { $scanned = $key[1]; } if ($key[0] == 'REJECT') { $reject = $key[1]; } if ($key[0] == 'TAGGED') { $tagged = $key[1]; } } } } flock($fd, 3); // release the lock fclose($fd); //if ($style == 'oldstyle') { // print(''); // // print(''); // print(''); // print(''); // // print(''); // print(''); // print(''); // // // print(''); // print(''); // // print(''); // print(''); // print('
'); // print('

'); // printf("Scanned for Spam"); // print('

'); // printf("%s",number_format($scanned,0,0,'.')); // print('

'); // printf("Good"); // print('

'); // $good_emails = $scanned-($reject+$tagged); // printf("%s (%.2d %%)",number_format($good_emails,0,0,'.'),($good_emails/$scanned)*100); // print('

'); // printf("Rejected as Spam"); // print('

'); // printf("%s (%.2d %%)",number_format($reject,0,0,'.'),($reject/$scanned)*100); // print('

'); // printf("Accepted but Tagged as Spam"); // print('

'); // printf("%s (%.2d %%)",number_format($tagged,0,0,'.'),($tagged/$scanned)*100); // print('

'); // //} else { $good_emails = $scanned - ($reject + $tagged); // what if no emails went through?? if ($scanned == 0) { include "jpgraph/jpgraph_canvas.php"; include "jpgraph/jpgraph_canvtools.php"; $g = new CanvasGraph(450, 260, 'auto'); $scale = new CanvasScale($g); $scale->Set(0, 27, 0, 53); $g->SetMargin(1, 2, 1, 2); $g->SetColor('white'); $g->SetMarginColor("black"); $g->InitFrame(); $t = new CanvasRectangleText(); $t->SetFillColor(''); $t->SetFontColor('black'); $t->SetColor(''); $t->SetShadow(''); $t->SetFont(FF_ARIAL, FS_BOLD, 14); $t->Set('No emails scanned for spam last hour', 8, 1, 8); $t->Stroke($g->img, $scale); $g->Stroke(); return; } // Some data $data = array( $good_emails, $tagged, $reject ); // A new pie graph $graph = new PieGraph(450, 260, 'auto'); // Setup title $graph->title->Set("Spam Statistics " . $text); $graph->title->SetFont(FF_ARIAL, FS_BOLD, 14); $graph->title->SetMargin(3); // Add a little bit more margin from the top $graph->footer->center->Set("Generated " . date('l jS \of F Y h:i:s A')); // Create the pie plot $p1 = new PiePlotC($data); // $p1->value->SetColor("navy"); $p1->SetCenter(0.35, 0.50); $p1->SetLegends(array( "Good (" . number_format($good_emails, 0, 0, '.') . ")", "Tagged (" . number_format($tagged, 0, 0, '.') . ")", "Rejected (" . number_format($reject, 0, 0, '.') . ")", )); $graph->legend->Pos(0.10, 0.30); $graph->legend->SetLayout(LEGEND_VERT); $p1->SetSliceColors(array( "green", "orange", "red" )); // Create the extra text box to show scanned emails number // $txt = new Text(); // $txt->Set("Total scanned " . number_format($scanned,0,0,'.')); // $txt->ParagraphAlign('right'); // $txt->Show(); // $txt->SetFont(FF_VERDANA,FS_NORMAL,8); // $txt->Pos(0.82,0.5,'center','bottom'); // $txt->SetBox('gray9','black','gray9',0,2); // $txt->SetShadow(); // $graph->AddText($txt); // $p1->Explode(array(0,15,15,25,15)); // Set size of pie $p1->SetSize(0.32); // Label font and color setup $p1->value->SetFont(FF_VERDANA, FS_BOLD, 10); $p1->value->SetColor('black'); // Setup the title on the center circle $p1->midtitle->Set("Total of\n" . number_format($scanned, 0, 0, '.') . "\nscanned"); $p1->midtitle->SetFont(FF_VERDANA, FS_NORMAL, 10); // Set color for mid circle $p1->SetMidColor('yellow'); // Use percentage values in the legends values (This is also the default) $p1->SetLabelType(PIE_VALUE_PER); // $p1->SetLabelPos(0.8); // Add plot to pie graph $graph->Add($p1); // .. and send the image on it's merry way to the browser $graph->Stroke(); //} return; } function msort($array, $id = "id", $sort_ascending = true) { $temp_array = array(); while (count($array) > 0) { $lowest_id = 0; $index = 0; foreach ($array as $item) { if (isset($item[$id])) { if ($array[$lowest_id][$id]) { if ($item[$id] < $array[$lowest_id][$id]) { $lowest_id = $index; } } } $index++; } $temp_array[] = $array[$lowest_id]; $array = array_merge(array_slice($array, 0, $lowest_id) , array_slice($array, $lowest_id + 1)); } if ($sort_ascending) { return $temp_array; } else { return array_reverse($temp_array); } } ?>