<?php
/**
* Created on 20-okt-2007 -- 15:23:40
*
* Antispam -- functions_lev.php
*
* @author Ramon Fincken, Phpbbinstallers.net, RamonFincken.com, WebsiteFreelancers.nl
*
* V 1.3.2 (Make sure you update this file on regular basis)
*/
if ( !defined('IN_PHPBB') )
{
die('Hacking attempt');
}
if ( !defined('IN_ANTISPAM') )
{
die('Hacking attempt');
}
function go_lev_validate($email)
{
global $board_config, $lang, $phpEx;
$system = @ preg_match("/Microsoft|Win32|IIS|WebSTAR|Xitami/", $_SERVER['SERVER_SOFTWARE']) ? $result = check_smtp_addr_win($email) : $result = check_smtp_addr_unix($email);
return $result;
}
// +MOD: Live Email Validate (LEV)
//
// test SMTP mail delivery
function probe_smtp_mailbox($email, $hostname) {
global $board_config, $lang, $phpEx;
@ set_time_limit(30);
$smtp_ports = array (
25,
2525
);
// Base case
$result['error'] = false;
$done = false;
foreach ($smtp_ports as $port) {
if (!$done) {
if ($connect = @ fsockopen($hostname, $port, $errno, $errstr, 15)) {
$done = true;
usleep(888);
$out = fgetss($connect, 1024);
if (ereg('^220', $out)) {
fputs($connect, "HELO " . $board_config['server_name'] . "\r\n");
while (ereg('^220', $out)) {
$out = fgetss($connect, 1024);
}
fputs($connect, "VRFY <" . $email . ">\r\n");
$verify = fgetss($connect, 1024);
fputs($connect, "MAIL FROM: <" . $board_config['board_email'] . ">\r\n");
$From = fgetss($connect, 1024);
fputs($connect, "RCPT TO: <" . $email . ">\r\n");
$To = fgetss($connect, 1024);
fputs($connect, "QUIT\r\n");
fclose($connect);
if (ereg('^250', $From) && ereg('^250', $To) && !ereg('^550', $verify)) {
$result = array (
'error' => false,
'error_msg' => ''
);
} else {
$result = array (
'error' => true,
'error_msg' => sprintf($lang['Email_unverified'],
'<a href="' . append_sid('faq.' . $phpEx
) . '">' . $lang['FAQ'] . '</a>') . ((DEBUG == TRUE) ? "<br />Server: $hostname | From: $From| To: " . str_replace('-"', ' ', $To) : ' '));
}
}
@ fclose($connect);
} // End connect
} // End done
} // End for each
if (!$done) {
$result = array (
'error' => true,
'error_msg' => sprintf($lang['No_connection'],
'<a href="' . append_sid('faq.' . $phpEx
) . '">' . $lang['FAQ'] . '</a>') . ((DEBUG == TRUE) ? "<br />$hostname : no route to this domain, host unavailable" : ' '));
}
return $result;
}
// Try to find an MX record that matches the hostname - Unix
function check_smtp_addr_unix($email) {
// Base case
$result['error'] = false;
list ($username, $domain) = explode('@', $email);
if (@checkdnsrr($domain, 'MX')) {
@getmxrr($domain, $mxhosts);
$result = probe_smtp_mailbox($email, $mxhosts[0]);
if ($result['error'] == false) {
return $result;
}
for ($i = 1; $i < count($mxhosts); $i++) {
$result = probe_smtp_mailbox($email, $mxhosts[$i]);
if ($result['error'] == false) {
return $result;
}
}
return $result;
} else {
return (probe_smtp_mailbox($email, $domain));
}
}
// Try to find an MX record that matches the hostname - Win32
function check_smtp_addr_win($email) {
list ($username, $domain) = explode('@', $email);
@exec("nslookup -type=MX $domain", $outputs);
foreach ($outputs as $hostname) {
if (@ strpos($domain, $hostname)) {
$result = probe_smtp_mailbox($email, $domain);
if ($result['error'] == false) {
return $result;
}
}
}
if (isset ($result)) {
return $result;
} else {
return (probe_smtp_mailbox($email, $domain));
}
}
//
// -MOD: Live Email Validate (LEV)
?>