|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Getripay\GetripayVerifyFakeEmails; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Collection; |
|
6
|
|
|
use Illuminate\Support\Facades\Storage; |
|
7
|
|
|
use Illuminate\Support\LazyCollection; |
|
8
|
|
|
|
|
9
|
|
|
class GetripayVerifyFakeEmails |
|
10
|
|
|
{ |
|
11
|
|
|
public $path_to_file = '/vendor/wesbos/burner-email-providers/emails.txt'; |
|
12
|
|
|
// Build your next great package. |
|
13
|
|
|
public function validate ($attribute, $value, $parameters, $validator) { |
|
|
|
|
|
|
14
|
|
|
$email_domain = explode('@', $value)[1]; |
|
15
|
|
|
logger("Email Domain => ".$email_domain); |
|
16
|
|
|
$collection = $this->searchFileForDomain($email_domain); |
|
17
|
|
|
$validator->setCustomMessages(['email.not_fake_email' => config('getripay_verify_fake_emails.validation_message')]); |
|
18
|
|
|
return !empty($collection) ? false : true; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
protected function searchFileForDomain($searchfor){ |
|
22
|
|
|
// get the file contents, assuming the file to be readable (and exist) |
|
23
|
|
|
$contents = file_get_contents(base_path().$this->path_to_file); |
|
24
|
|
|
// escape special characters in the query |
|
25
|
|
|
$pattern = preg_quote($searchfor, '/'); |
|
26
|
|
|
// finalise the regular expression, matching the whole line |
|
27
|
|
|
$pattern = "/^.*$pattern.*\$/m"; |
|
28
|
|
|
// search, and store all matching occurences in $matches |
|
29
|
|
|
if(preg_match_all($pattern, $contents, $matches)){ |
|
30
|
|
|
//logger("Found matches:\n". implode("\n", $matches[0])); |
|
31
|
|
|
return $matches; |
|
32
|
|
|
} |
|
33
|
|
|
else{ |
|
34
|
|
|
//echo "No matches found"; |
|
35
|
|
|
return false; |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
} |
|
39
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.