mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-17 03:51:06 +01:00
Migliorata validazione indirizzi email con API
This commit is contained in:
parent
4fa16eff1d
commit
3d142953b1
@ -38,18 +38,38 @@ switch (post('op')) {
|
|||||||
$_SESSION['infos'][] = tr('Informazioni salvate correttamente!');
|
$_SESSION['infos'][] = tr('Informazioni salvate correttamente!');
|
||||||
|
|
||||||
// Validazione indirizzo email mittente
|
// Validazione indirizzo email mittente
|
||||||
$check_email = Validate::isValidEmail($post['from_address'], 1, 1);
|
$check_email = Validate::isValidEmail($post['from_address'], 1, 0);
|
||||||
|
|
||||||
// Se $check_email non è null e la riposta è negativa --> mostro il messaggio di avviso.
|
// Se $check_email non è null e la riposta è negativa --> mostro il messaggio di avviso.
|
||||||
if ((!is_null($check_email)) && (!$check_email->smtp_check)) {
|
if (!is_null($check_email)){
|
||||||
if (!empty($check_email->error->info)) {
|
|
||||||
$_SESSION['errors'][] = $check_email->error->info;
|
if ($check_email->format_valid) {
|
||||||
} else {
|
$_SESSION['infos'][] = tr('Sintassi email verificata.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
$_SESSION['errors'][] = tr("Attenzione: l'indirizzo email _EMAIL_ sembra non essere valido", [
|
$_SESSION['errors'][] = tr("Attenzione: l'indirizzo email _EMAIL_ sembra non essere valido", [
|
||||||
'_EMAIL_' => $post['from_address'],
|
'_EMAIL_' => $check_email->email,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($check_email->smtp) {
|
||||||
|
if ($check_email->smtp_check) {
|
||||||
|
$_SESSION['infos'][] = tr('SMTP email verificato.');
|
||||||
|
}
|
||||||
|
elseif (!$check_email->smtp_check) {
|
||||||
|
$_SESSION['warnings'][] = tr('SMTP email non verificato.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$_SESSION['errors'][] = tr("Attenzione: l'SMTP email _EMAIL_ sembra non essere valido", [
|
||||||
|
'_EMAIL_' => $check_email->email,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($check_email->error->info)) {
|
||||||
|
$_SESSION['errors'][] = $check_email->error->info;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
|
@ -68,20 +68,38 @@ class Validate
|
|||||||
];*/
|
];*/
|
||||||
|
|
||||||
if ((!empty($email)) && (!empty($access_key))) {
|
if ((!empty($email)) && (!empty($access_key))) {
|
||||||
$ch = curl_init();
|
|
||||||
|
if(!function_exists("curl_init")) die("cURL extension is not installed");
|
||||||
|
|
||||||
$qs = '&email='.urlencode($email);
|
$qs = '&email='.urlencode($email);
|
||||||
$qs .= "&smtp=$smtp";
|
$qs .= "&smtp=$smtp";
|
||||||
$qs .= "&format=$format";
|
$qs .= "&format=$format";
|
||||||
|
$qs .= "&resource=check_email";
|
||||||
|
|
||||||
$url = "http://apilayer.net/api/check?access_key=$access_key".$qs;
|
$url = "https://services.osmcloud.it/api/?token=$access_key".$qs;
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
|
||||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
||||||
|
|
||||||
$data = json_decode(curl_exec($ch));
|
$curl_options = array(
|
||||||
|
CURLOPT_URL => $url,
|
||||||
|
CURLOPT_HEADER => 0,
|
||||||
|
CURLOPT_RETURNTRANSFER => TRUE,
|
||||||
|
CURLOPT_TIMEOUT => 0,
|
||||||
|
CURLOPT_SSL_VERIFYPEER => 0,
|
||||||
|
CURLOPT_FOLLOWLOCATION => TRUE,
|
||||||
|
CURLOPT_ENCODING => 'gzip,deflate',
|
||||||
|
);
|
||||||
|
|
||||||
|
$ch = curl_init();
|
||||||
|
curl_setopt_array( $ch, $curl_options );
|
||||||
|
$output = curl_exec( $ch );
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
|
$data = json_decode($output,false);
|
||||||
|
|
||||||
|
//var_dump ($data);
|
||||||
|
//echo "format_valid: ".$data->format_valid;
|
||||||
|
//echo $url;
|
||||||
|
//exit;
|
||||||
|
|
||||||
/*se la riposta è null verficando il formato, il record mx o il server smtp imposto la relativa proprietà dell'oggetto a 0*/
|
/*se la riposta è null verficando il formato, il record mx o il server smtp imposto la relativa proprietà dell'oggetto a 0*/
|
||||||
if (($data->format_valid == null) && ($format)) {
|
if (($data->format_valid == null) && ($format)) {
|
||||||
$data->format_valid = 0;
|
$data->format_valid = 0;
|
||||||
@ -103,11 +121,13 @@ class Validate
|
|||||||
$data->mx_found = 0;
|
$data->mx_found = 0;
|
||||||
*/
|
*/
|
||||||
/* --- */
|
/* --- */
|
||||||
|
$data->smtp = $smtp;
|
||||||
|
|
||||||
$data->json_last_error = json_last_error();
|
$data->json_last_error = json_last_error();
|
||||||
$data->json_last_error_msg = json_last_error_msg();
|
$data->json_last_error_msg = json_last_error_msg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user