Validare Email
Scris: 15-Sep-2014, 21:39:24
Numele MODificării: Validare Email Live (LEV)
Clasificare: User-CP (Înregistrare Ulilizatori)
Versiunea MODificării: 1.0.1
Autor: Wulf_9
Descrierea MODificării: Când un utilizator se înregistrează ori îşi editează adresele de email ori când un admin corectează un e-mail invalid, acest MOD încearcă să-l verifice via registrelor DNS MX un test al sesiunii SMTP, trimiţând "true" ori "false" ca valoare după rezultat.
Versiuni phpBB compatibile: phpBB3
Stiluri compatibile: oricare
Timp necesar instalării: 5 minute
Cerere Mod: https://www.phpbb.com/community/viewtop ... #p13730916
Template:
Clasificare: User-CP (Înregistrare Ulilizatori)
Versiunea MODificării: 1.0.1
Autor: Wulf_9
Descrierea MODificării: Când un utilizator se înregistrează ori îşi editează adresele de email ori când un admin corectează un e-mail invalid, acest MOD încearcă să-l verifice via registrelor DNS MX un test al sesiunii SMTP, trimiţând "true" ori "false" ca valoare după rezultat.
Versiuni phpBB compatibile: phpBB3
Stiluri compatibile: oricare
Timp necesar instalării: 5 minute
Cerere Mod: https://www.phpbb.com/community/viewtop ... #p13730916
Template:
Cod: Selectaţi tot
##############################################################
## MOD Title: Live Email Validate (LEV)
## MOD Author: Wulf_9 < webmaster@zodiac-infosystems.co.uk > (Wulf) http://www.zodiac-infosystems.co.uk
## MOD Description: When a user signs up or edits their email address, this MOD will
## attempt to verify it via the DNS MX records and a test SMTP session,
## returning true or false as appropriate.
##
## MOD Version: 1.0.1
##
## Installation Level: Easy
## Installation Time: 10 Minutes
##
## Files To Edit: 1
##
## includes/functions_user.php
##
## Included Files: 0
##
##
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##
## This does a live test of a user's mailbox, using the MX
## record for the supplied domain (the part after the @).
## If there is a network issue or all the hosts are down or
## don't respond, it will return 'false', meaning that
## the supplied email address won't be able to be checked
## until the connection works. If this will be a problem,
## this MOD can be enabled/disabled via the ACP. The default
## setting is 'off' after installation. As usual, you are
## advised to check your board config after installing any
## MODs which alter your settings or database.
##
## If not installing via EasyMOD or you won't/can't do the SQL,
## you MUST run the setup script from your forum root before
## attempting to enable the LEV feature via the ACP.
##
## If you use EM to do the install, it will run the SQL for you so
## delete the update script from your forum root without running it.
##
## The Q/A entries in the FAQ page will only be displayed
## if LEV is enabled, allowing for contextual feedback.
##
## Works on unix and windows boxes, since it will auto-detect
## the OS platform and call the relevant function.
##
## Thanks to Alejandro Gervasio at devshed.com for some handy php tips.
##
## ACP option coded by The Defpom http://www.radiomods.co.nz/forum/ have a look for my other forum MODS.
##
## Update for non-RFC-compliant mailservers with thanks to Markus Petrux ( http://www.phpmix.com )
##############################################################
## MOD History:
##
## 2005-08-26 - Version 1.0.1
## - Modified sender name in HELO message for 'awkward' mailhosts
## - MOD now enabled by default after installation
##
## 2005-04-11 - Version 1.0.0
## - Added SQL query for manual/EasyMOD use
##
## 2005-04-04 - Version 0.8.5 beta
## - Changed some regex functions for PCRE ones to speed up
## execution time
## - Code tidying for phpBB standards compliance
##
## 2005-04-02 - Version 0.8.1 beta
## - Faster loop checks (minimises number of SMTP transactions)
## - Improved error reporting (SMTP replies) for failed connections
## - Settings-dependant FAQ section, only shows entries if enabled
## - Corrected grammatical errors in files and database entries
##
## 2005-04-01 - Version 0.7.5 beta
## - Improved loop checking
## - Added SQL setup script for easier install
##
## 2005-03-31 - Version 0.6.5 beta
## - Added ACP enable/disable switch (thanks to The Defpom, see notes above)
## - Loop-checks all returned mailhosts to increase chances of success
## - Error message linked to FAQ page
##
## 2005-03-29 - Version 0.5.0 beta
## - 'Rough and ready' test version, only checks the first server it finds
## - No ACP option setting
## - Simple one-line error message
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################
#
#-----[ OPEN ]------------------------------------------
#
includes/functions_user.php
#
#-----[ FIND ]------------------------------------------
#
/**
* Check to see if email address is banned or already present in the DB
*
* @param string $email The email to check
* @param string $allowed_email An allowed email, default being $user->data['user_email']
*
* @return mixed Either false if validation succeeded or a string which will be used as the error message (with the variable name appended)
*/
#
#-----[ BEFORE, ADD ]------------------------------------------
#
/* +MOD: Live Email Validate (LEV)
*
* test SMTP mail delivery
*/
function probe_smtp_mailbox($email, $hostname)
{
global $config, $user, $phpEx;
@set_time_limit(30);
if ($connect = fsockopen($hostname, 25, $errno, $errstr, 15))
{
usleep(888);
$out = fgetss($connect, 1024);
if (preg_match('#^220#', $out))
{
fputs($connect, "HELO " . $config['server_name'] . "\r\n");
while (preg_match('#^220#', $out))
{
$out = fgetss($connect, 1024);
}
fputs($connect, "VRFY <" . $email . ">\r\n");
$verify = fgetss($connect, 1024);
fputs($connect, "MAIL FROM: <" . $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);
//$user->lang['Email_unverified'] = "Unverified E-Mail Adress";
//$user->lang['No_connection'] = "No Connection";
if (preg_match('#^250#', $from) && preg_match('#^250#', $to) && !preg_match('#^550#', $verify))
{
$result = false;
}
else
{
$result = "Unverified E-Mail Adress";
}
}
@fclose($connect);
}
else
{
$result = "No Connection";
}
return $result;
}
// Try to find an MX record that matches the hostname - Unix
function check_smtp_addr_unix($email)
{
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)
*/
#
#-----[ FIND ]------------------------------------------
#
// Check MX record.
// The idea for this is from reading the UseBB blog/announcement. :)
if ($config['email_check_mx'])
{
list(, $domain) = explode('@', $email);
if (phpbb_checkdnsrr($domain, 'A') === false && phpbb_checkdnsrr($domain, 'MX') === false)
{
return 'DOMAIN_NO_MX_RECORD';
}
#
#-----[ AFTER, ADD ]------------------------------------
#
/* +MOD: Live Email Validate (LEV)
*
*/
global $_SERVER;
$system = preg_match("/Microsoft|Win32|IIS|WebSTAR|Xitami/", $_SERVER['SERVER_SOFTWARE']) ? $result = check_smtp_addr_win($email) : $result = check_smtp_addr_unix($email);
if ($result == true)
{
return $result;
}
/*
* -MOD: Live Email Validate (LEV)
*/
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM