Using DNSPOD API to implement dynamic domain name resolution

WBOY
Release: 2016-07-25 08:50:16
Original
1525 people have browsed it
Use DNSPOD API to achieve dynamic resolution of domain names and build servers at home

Use domain names to directly access dial-up computers
  1. /**
  2. * @description: Use DNSPOD to dynamically change domain name pointing,
  3. can realize home dial-up Internet access and the computer can also be used as a WAN server
  4. * @author: sang.williams@gmail.com
  5. * @time: 2013-8-6
  6. *
  7. * @todo :
  8. * 1. Add error prompts, such as login errors, etc.
  9. **/
  10. header("Content-type:text/html;charset=utf8");
  11. require_once dirname(__file__).'/lib/conf. php';
  12. require_once dirname(__file__).'/lib/changeRecord.php';
  13. require_once dirname(__file__).'/lib/getDomainID.php';
  14. require_once dirname(__file__).'/lib/getRecordID.php' ;
  15. require_once dirname(__file__).'/lib/getRemoteIP.php';
  16. require_once dirname(__file__).'/lib/getRecordIP.php';
  17. //Get the domain name ID
  18. $domain_id = getDomainID(DOMAIN);
  19. if (!$domain_id) {
  20. echo "The domain name has not been added in DNSPOD, please add the domain name in DNSPOD.
    n";
  21. exit();
  22. }
  23. //Get RECORD ID
  24. $record_id= getRecordID ($domain_id, RECORD);
  25. if (!$record_id) {
  26. echo "You have not yet created this record in DNSPOD. Please go to DNSPOD to add a record first
    n";
  27. exit();
  28. }
  29. $record_ip = getRecordIP($domain_id, RECORD);
  30. //echo 'The current record ID is'.$record_id."
    n";
  31. echo 'The current record IP is'.$record_ip."< br>n";
  32. //Get the current WAN IP address
  33. $ip = getRemoteIP();
  34. echo 'The current WAN IP is:'.$ip."
    n";
  35. //If If the current WAN IP and DNSPOD registered IP are different, change it to the current WAN IP
  36. if ($ip != $record_ip) {
  37. echo "Change result
    n".changeRecord( $domain_id, $record_id, $ip, RECORD)."n";
  38. }else{
  39. echo "nothing to do
    n";
  40. }
  41. ?>
Copy code


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template