-
-
Save vakata/c3f38eae37061faa5e68 to your computer and use it in GitHub Desktop.
Проверка в КЗП на мейл / масив от мейли
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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