-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathddns.php
67 lines (56 loc) · 1.29 KB
/
ddns.php
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
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
require_once("config.php");
require_once("ddnscommon.php");
if ( ($_SERVER['HTTPS'] === 'on') || ($_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') )
{
ProcessData($_REQUEST);
}
else
{
dd2res("badauth", "You must connect via HTTPS!");
return false;
}
function verify_zone($data)
{
if ( preg_match('/' . $GLOBALS['cfg']['zones'] . '/', $data) )
{
return true;
}
else
{
dd2res("notfqdn", "The host you specified has not an allowed valid fully-qualified domain name.");
return false;
}
}
function verify_key($data)
{
if ( preg_match('/([\da-fA-F]{2}:){5}[\da-fA-F]{2}/', $data) )
{
return true;
}
else
{
dd2res("badauth", "You must supply a valid MAC address e.g. 00:0b:96:d0:23:92.");
return false;
}
}
function verify_ip($data)
{
if ( preg_match('/((\d{1,3}\.){3}\d{1,3}|([\da-fA-F]{1,4}:){1,7}((:[\da-fA-F]{1,4}){1,6}|[\da-fA-F]{1,4}|:))/', $data) || empty($data) )
{
return true;
}
else
{
dd2res("nohost", "You must either enter a valid IP address or leave that field blank.");
return false;
}
}
function ProcessData($data)
{
if ( verify_zone(@$data['zone']) && verify_key(@$data['key']) && verify_ip(@$data['ip']) )
{
return khi_ddns_process_data($data, 'khi_ddns_keygen');
}
}
?>