Use DNSPOD API to achieve dynamic resolution of domain names and build servers at home
Use domain names to directly access dial-up computers
- /**
- * @description: Use DNSPOD to dynamically change domain name pointing,
- can realize home dial-up Internet access and the computer can also be used as a WAN server
- * @author: sang.williams@gmail.com
- * @time: 2013-8-6
- *
- * @todo :
- * 1. Add error prompts, such as login errors, etc.
- **/
- header("Content-type:text/html;charset=utf8");
- require_once dirname(__file__).'/lib/conf. php';
- require_once dirname(__file__).'/lib/changeRecord.php';
- require_once dirname(__file__).'/lib/getDomainID.php';
- require_once dirname(__file__).'/lib/getRecordID.php' ;
- require_once dirname(__file__).'/lib/getRemoteIP.php';
- require_once dirname(__file__).'/lib/getRecordIP.php';
- //Get the domain name ID
- $domain_id = getDomainID(DOMAIN);
- if (!$domain_id) {
- echo "The domain name has not been added in DNSPOD, please add the domain name in DNSPOD.
n";
- exit();
- }
-
- //Get RECORD ID
- $record_id= getRecordID ($domain_id, RECORD);
- if (!$record_id) {
- echo "You have not yet created this record in DNSPOD. Please go to DNSPOD to add a record first
n";
- exit();
- }
-
- $record_ip = getRecordIP($domain_id, RECORD);
-
- //echo 'The current record ID is'.$record_id."
n";
- echo 'The current record IP is'.$record_ip."< br>n";
-
- //Get the current WAN IP address
- $ip = getRemoteIP();
-
- echo 'The current WAN IP is:'.$ip."
n";
-
- //If If the current WAN IP and DNSPOD registered IP are different, change it to the current WAN IP
- if ($ip != $record_ip) {
- echo "Change result
n".changeRecord( $domain_id, $record_id, $ip, RECORD)."n";
- }else{
- echo "nothing to do
n";
- }
-
- ?>
Copy code
|