Skip to content

Instantly share code, notes, and snippets.

@vakata
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save vakata/c3f38eae37061faa5e68 to your computer and use it in GitHub Desktop.

Select an option

Save vakata/c3f38eae37061faa5e68 to your computer and use it in GitHub Desktop.
Проверка в КЗП на мейл / масив от мейли
<?php
function kzp($emails) {
if(!is_array($emails)) { $emails = [ (string)$emails ]; }
if(false === ($hashes = @file('http://www.kzp.bg/download.php?mode=fileDownload&p_attached_file_id=4956'))) {
throw new Exception('Could not load KZP hashes');
}
array_walk($hashes, function (&$hash) { $hash = substr(strtoupper(trim($hash)),0,32); });
return array_filter(array_unique($emails), function ($mail) use ($hashes) {
$mail = mb_strtolower(trim($mail),'utf-8');
return filter_var($mail, FILTER_VALIDATE_EMAIL) && !in_array(strtoupper(md5(explode('@', $mail)[1])), $hashes) && !in_array(strtoupper(md5($mail)), $hashes);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment