#!/usr/bin/php -q
<?
/*
* Written by Paul Phillips, phillipsdata.com
* Distribute or modify freely, but please give me credit for this code in any
* derivative works. Please do not remove these comments.
*/
function dumpallspam() {
$domain = "yourdomain.com";
$cpaneluser = "yourcpaneluser";
$cpanelpass = "yourcpanelpass";
$cpaneltheme= "x"; // The cpanel theme used. in the url it appears after :2082/frontend/ <-- here
// First do a check if curl_init exists:
if (function_exists("curl_init")) {
$authstr = "$cpaneluser:$cpanelpass";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $domain . ":2082/frontend/" . $cpaneltheme . "/mail/clearspambox.html?");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERPWD, $authstr);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$cbsreturn = curl_exec($ch);
//echo "Result: " . $cbsreturn; // Returns all the html from cpanel, uncomment to view
//die;
if (strpos($cbsreturn, "spambox has been cleared")) {
return true;
} else {
return false;
}
// debug echo curl_error($ch);
curl_close($ch);
}
}
if (dumpallspam()) {
// dont echo anything if via cron cause we dont want emails! echo "Dumped spam ok";
} else {
echo "problem dumping spam, check the settings!";
}
?>