Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # nginx config
- server {
- listen 80;
- server_name home.cars10k.de;
- root /var/www/home/;
- index index.php;
- # location / {
- # rewrite ^ /dyndns.php;
- # }
- location ~ \.php {
- fastcgi_split_path_info ^(.+\.php)(/.*)$;
- include fastcgi_params;
- fastcgi_pass unix:/var/run/php/php7.0-fpm-home.sock;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- fastcgi_param PATH_INFO $fastcgi_path_info;
- fastcgi_param front_controller_active true;
- fastcgi_intercept_errors on;
- fastcgi_request_buffering off;
- }
- }
- # script dyndns.php
- <h1>If you are seeing this than something went wrong.</h1>
- <?php
- // Set a secure password
- $password = 'NmU3ZjMyMTU2ZWQ4N2I0';
- // Variables
- $ip_file = "saved_ip.txt";
- $sent_password = $_GET["password"];
- $ip = $_GET["ip"];
- $secure = $_GET["s"];
- $port = $_GET["p"];
- if (file_exists($ip_file)) {
- // if a password and an ip address where sent we assume it's an update from the router, so save that
- if (isset($sent_password) && isset($ip)) {
- if ($sent_password == $password) {
- $file_handle = fopen("$ip_file", "w");
- fwrite($file_handle, $ip);
- fclose($file_handle);
- header( "HTTP/1.1 200 OK" );
- } else {
- header("HTTP/1.1 401 Unauthorized");
- exit;
- }
- } else {
- // normal request: we want to redirect
- $file_handle = fopen("$ip_file", "r+");
- $saved_ip = trim(fread($file_handle, filesize($ip_file)));
- fclose($file_handle);
- if (isset($port)) {
- $url = $saved_ip . ":" . $port;
- } else {
- $url = $saved_ip;
- }
- if (isset($secure)) {
- $url_with_protocol = "https://" . $url;
- } else {
- $url_with_protocol = "http://" . $url;
- }
- header("Location: $url_with_protocol");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement