Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. # nginx config
  2. server {
  3. listen 80;
  4. server_name home.cars10k.de;
  5.  
  6. root /var/www/home/;
  7. index index.php;
  8.  
  9. # location / {
  10. # rewrite ^ /dyndns.php;
  11. # }
  12.  
  13. location ~ \.php {
  14. fastcgi_split_path_info ^(.+\.php)(/.*)$;
  15. include fastcgi_params;
  16. fastcgi_pass unix:/var/run/php/php7.0-fpm-home.sock;
  17. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  18. fastcgi_param PATH_INFO $fastcgi_path_info;
  19. fastcgi_param front_controller_active true;
  20. fastcgi_intercept_errors on;
  21. fastcgi_request_buffering off;
  22.  
  23. }
  24. }
  25.  
  26.  
  27.  
  28.  
  29. # script dyndns.php
  30. <h1>If you are seeing this than something went wrong.</h1>
  31. <?php
  32. // Set a secure password
  33. $password = 'NmU3ZjMyMTU2ZWQ4N2I0';
  34. // Variables
  35. $ip_file = "saved_ip.txt";
  36. $sent_password = $_GET["password"];
  37. $ip = $_GET["ip"];
  38. $secure = $_GET["s"];
  39. $port = $_GET["p"];
  40.  
  41. if (file_exists($ip_file)) {
  42. // if a password and an ip address where sent we assume it's an update from the router, so save that
  43. if (isset($sent_password) && isset($ip)) {
  44. if ($sent_password == $password) {
  45. $file_handle = fopen("$ip_file", "w");
  46. fwrite($file_handle, $ip);
  47. fclose($file_handle);
  48. header( "HTTP/1.1 200 OK" );
  49. } else {
  50. header("HTTP/1.1 401 Unauthorized");
  51. exit;
  52. }
  53. } else {
  54. // normal request: we want to redirect
  55. $file_handle = fopen("$ip_file", "r+");
  56. $saved_ip = trim(fread($file_handle, filesize($ip_file)));
  57. fclose($file_handle);
  58.  
  59. if (isset($port)) {
  60. $url = $saved_ip . ":" . $port;
  61. } else {
  62. $url = $saved_ip;
  63. }
  64.  
  65. if (isset($secure)) {
  66. $url_with_protocol = "https://" . $url;
  67. } else {
  68. $url_with_protocol = "http://" . $url;
  69. }
  70. header("Location: $url_with_protocol");
  71. }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement