Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // đây là file có đuôi là: .php
- // Sửa dòng nhập token của Duckdns của bạn ở dòng: $tokenduckdns
- //Và Domain của bạn ở dòng: $domainduckdns
- // Máy Chủ của bạn phải được cài php và webserver(apache2) để chạy được file php này
- //Code By Vũ Tuyển
- /* COde Trong File configuration.yaml Home assistant:
- sensor:
- - platform: rest
- name: DuckDns Upload ip
- resource: "http://192.168.99.17/duckdns/uploadip.php"
- scan_interval:
- minutes: 5
- */
- @error_reporting(0);
- @ini_set('output_buffering',0);
- @ini_set('display_errors', 0);
- @set_time_limit(0);
- date_default_timezone_set('Asia/Ho_Chi_Minh');
- $date = date('h:i:s a', time());
- $tokenduckdns = "NHẬP TOKEN DUCKDNS";
- $domainduckdns = "DOMAIN.duckdns.org";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "http://whatismyip.akamai.com/");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_HEADER, FALSE);
- $response = curl_exec($ch);
- curl_close($ch);
- //$character = json_decode($response);
- //$ip = $response->ip;
- $ip = $response;
- //echo $ip;
- $ch1 = curl_init();
- curl_setopt($ch1, CURLOPT_URL, "https://www.duckdns.org/update?domains=$domainduckdns&token=$tokenduckdns&$ip&verbose=true");
- curl_setopt($ch1, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch1, CURLOPT_HEADER, FALSE);
- $response1 = curl_exec($ch1);
- curl_close($ch1);
- echo "$response1 - Thời Gian: $date";
- //echo "$response1";
- $tokenduckdns = "3N";<?php
- @error_reporting(0);
- @ini_set('output_buffering',0);
- @ini_set('display_errors', 0);
- @set_time_limit(0);
- date_default_timezone_set('Asia/Ho_Chi_Minh');
- $date = date('h:i:s a', time());
- $tokenduckdns = "NHẬP TOKEN DUCKDNS VÀO ĐÂY";
- $domainduckdns = "DOMAIN.duckdns.org";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, "http://whatismyip.akamai.com/");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_HEADER, FALSE);
- $response = curl_exec($ch);
- curl_close($ch);
- //$character = json_decode($response);
- //$ip = $response->ip;
- $ip = $response;
- //echo $ip;
- $ch1 = curl_init();
- curl_setopt($ch1, CURLOPT_URL, "https://www.duckdns.org/update?domains=$domainduckdns&token=$tokenduckdns&$ip&verbose=true");
- curl_setopt($ch1, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch1, CURLOPT_HEADER, FALSE);
- $response1 = curl_exec($ch1);
- curl_close($ch1);
- echo "$response1 - Thời Gian: $date";
- //echo "$response1";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment