#!/usr/bin/perl -w # # ip.cgi # John Simpson 2008-03-30 # # show the client what their IP address is # if a name and key were sent, pass them along to a dyndns service # ############################################################################### # # Copyright (C) 2008 John Simpson. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 or version 3 of the # license, at your option. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # ############################################################################### require 5.003 ; use strict ; use CGI qw ( :standard ) ; my $pipe = "/tmp/update-dyndns" ; my ( $ip , $name , $key , $msg ) ; ############################################################################### ############################################################################### ############################################################################### $ip = ( $ENV{"REMOTE_ADDR"} || "0.0.0.0" ) ; $name = ( param("name") || "" ) ; $key = ( param("key" ) || "" ) ; $msg = "" ; if ( $pipe && $name && $key ) { if ( open ( O , ">$pipe" ) ) { print O "$name $ip $key\n" ; close O ; $msg = " updating $name" ; } else { $msg = " ERROR cannot update $name" ; } } print <