#!/usr/bin/php -q get_variable("CALLERID(num)"); if ($r["result"] == 0) { # Some sort of failure. $agi->set_variable("PHONESPAMFILTER", "0"); exit(0); } $cidnum = $r["data"]; if ($cidnum < 1000000000) # No valid callerid. { $agi->set_variable("PHONESPAMFILTER", "0"); exit(0); } # This program assumes curl is installed. wget could also be used. $score = `curl --silent --max-time $MAXTIME http://www.phonespamfilter.com/check.php?phone=$cidnum`; # Eliminate any whitespace. $score = trim($score); # Log the score in verbose mode. $agi->verbose("PSF Score: $score"); if ($score == "" || $score == "-1") # Timeout or other failure. { $agi->set_variable("PHONESPAMFILTER", "0"); } else if ($score < $PASS_SCORE) # pass { $agi->set_variable("PHONESPAMFILTER", "1"); } else # fail. { $agi->verbose("PSF Score too high. Call blocked."); $agi->set_variable("PHONESPAMFILTER", "2"); } ?>