-
Notifications
You must be signed in to change notification settings - Fork 18
/
ddns.php
51 lines (42 loc) · 1.38 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
<?php
define('DS', DIRECTORY_SEPARATOR);
define('BASE_DIR', __DIR__ . DS);
define('CACHE_DIR', BASE_DIR . 'cache' . DS);
require_once(BASE_DIR . 'function.php');
require_once(BASE_DIR . 'vendor' . DS . 'autoload.php');
require_once(BASE_DIR . 'service' . DS . 'aliyun.php');
require_once(BASE_DIR . 'service' . DS . 'dnspod.php');
try {
$serviceType = filterInputPostGet('service');
$accessID = filterInputPostGet('access_id');
$accessSecret = filterInputPostGet('access_secret');
$domain = filterInputPostGet('domain');
if (empty($serviceType)) {
throw new Exception('service type is empty');
}
if (empty($accessID)) {
throw new Exception('access id is empty');
}
if (empty($accessSecret)) {
throw new Exception('access secret is empty');
}
if (empty($domain)) {
throw new Exception('domain is empty');
}
$accessIP = getIP();
switch ($serviceType) {
case 'aliyun':
$ddnsService = new Aliyun($accessID, $accessSecret);
echo $ddnsService->ddns($domain, $accessIP);
break;
case 'dnspod':
$ddnsService = new Dnspod($accessID, $accessSecret);
echo $ddnsService->ddns($domain, $accessIP);
break;
default:
throw new Exception('Unknown service type');
}
}
catch (Exception $e) {
echo $e->getMessage();
}