See your SpamCop stats

If you use SpamCop, like I do, you might want to brag about the amount of spam you get - or horrify people.

Because this is slow code to execute, this breaks into two: an additional HTML page, and an IFRAME call. You need IMAP support on your PHP installation for this to work.

Here comes the real meaty code. Call this 'spamcheck.php' and save it somewhere.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<TITLE> SpamCop stats </TITLE>
</HEAD>
<BODY leftmargin=0 topmargin=0 style='color:#000066; font: normal 80% Trebuchet MS,Verdana;'>
<P><B>My spam stats</b><BR>
<?
//Your Spamcop username and password here
$username="username@spamcop.net";
$password="yourpasswordgoeshere";

//Apparently, getting the IP address speeds things up.
$ipaddress = gethostbyname ("imap.spamcop.net");
$mbox = @imap_open ("{".$ipaddress.":143}INBOX.Held Mail", $username, $password) or die("My current spam stats are unavailable.");

for ($i = 1; $i <= imap_num_msg($mbox); $i++)
{
$header = imap_headerinfo($mbox, $i, 80, 80);
$mdate[$i]= $header->udate;
$subject[$i] = $header->subject;
}

$totaltime = ($mdate[imap_num_msg($mbox)]-$mdate[1]);

echo "My held mail box contains ".imap_num_msg($mbox)." mails that <a href='http://www.spamcop.net/' target=_top><B>SpamCop</b></a> has classified as spam.<BR>I last reported spam ".number_format(($totaltime/60)/60)." hours ago.<BR>I am currently getting ".number_format(((imap_num_msg($mbox)/$totaltime)*86400))." spams a day.</p>";

imap_close($mbox);
?>
</BODY>
</HTML>

...and here's the IFRAME call:

<iframe scrolling=no src=spamcheck.php style='width:530px;height:78px;border:0px;'></iframe>

Note: you might need to add this line at the top if it gives up on you.

//Allow this script to run for up to one hour. Gulp.
set_time_limit(3600);