/*
start of Stop Forum Spam code for xmb forum
updates will be on this topic: https://forums.xmbforum2.com/viewthread.php?tid=776782
based on code examples: https://www.stopforumspam.com/forum/viewtopic.php?id=1973
if email address OR ip exist on stopforumspam website, user registration stops, option to reject on username too
*/
$spammer = '';
function objectsIntoArray($arrObjData, $arrSkipIndices = array())
{
$arrData = array();
// if input is object, convert into array
if (is_object($arrObjData)) {
$arrObjData = get_object_vars($arrObjData);
}
if (is_array($arrObjData)) {
foreach ($arrObjData as $index => $value) {
if (is_object($value) || is_array($value)) {
$value = objectsIntoArray($value, $arrSkipIndices);
}
if (in_array($index, $arrSkipIndices)) {
continue;
}
$arrData[$index] = $value;
}
}
return $arrData;
}
$xmlUrl = "http://api.stopforumspam.org/api?username=$username&ip=$onlineip&email=$email&f=xmldom";
$xmlStr = file_get_contents($xmlUrl);
$xmlObj = simplexml_load_string($xmlStr);
$arrXml = objectsIntoArray($xmlObj);
$checkemail = $arrXml[email][appears];
$checkip = $arrXml[ip][appears];
// you can reject on username too, to do so
// uncomment the two lines below, comment out the third line below
// $checkuser = $arrXml[username][appears];
// if ($checkemail > 0 || $checkip > 0 || $checkuser > 0) {
if ($checkemail > 0 || $checkip > 0) {
// change email address below [recommended to see how often spam registrations are attempted]
// or comment out two lines below if you don't want notifications
$spammer = 'ip address: '.$onlineip.', email address: '.$email.' with attempted username registration of: '.$username;
mail("stopforumspam@mailinator.com","New Spammer Registration Attempt: ", $spammer);
// choose Location redirection or msg to spammer by uncommenting one of the 2 lines below
// header('Location: https://www.xmbforum2.com/'); // web address redirection
error('Spammer go away'); // msg to spammer [recommended]
//exit;
}
// end of inserted StopForumSpam code
|