forked from appwrite/appwrite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCNAME.php
More file actions
54 lines (45 loc) 路 993 Bytes
/
Copy pathCNAME.php
File metadata and controls
54 lines (45 loc) 路 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Network\Validators;
use Utopia\Validator;
class CNAME extends Validator
{
/**
* @var int
*/
protected $target;
/**
* @param string $target
*/
public function __construct($target)
{
$this->target = $target;
}
public function getDescription()
{
return 'Inavlid CNAME record';
}
/**
* Check if CNAME record target value matches selected target
*
* @param string $domain
*
* @return bool
*/
public function isValid($domain)
{
try {
$records = dns_get_record($domain, DNS_CNAME);
} catch (\Throwable $th) {
return false;
}
if(!$records || !is_array($records)) {
return false;
}
foreach($records as $record) {
if(isset($record['target']) && $record['target'] === $this->target) {
return true;
}
}
return false;
}
}