#!/usr/local/bin/perl -w use strict; use CGI::Carp qw(fatalsToBrowser); use CGI; use DBI; use Regexp::Common; my $cgi = CGI->new(); my $dbh = db_connect(); my $ip = $cgi->param('ip') || ''; print_header(); if($ip =~ /^$RE{net}{IPv4}$/) { update_meh($ip); print "OK - $ip"; # OK } else { # NOT OK print "NOPE - $ip"; } sub update_meh { my $ip = shift; # 10086 is the a record for meh.rasterburn.com id in rr $dbh->do('UPDATE rr SET data = ? WHERE id = ?', {}, $ip, 10086); return; } sub db_connect { my $dbh = DBI->connect('dbi:mysql:mydns:fury.netdojo.net', 'mydns', 'dnsfoo!', { RaiseError => 1, PrintError => 1, AutoCommit => 1 }) || die "$DBI::errstr"; return $dbh; } sub print_header { print "Content-Type: text/html\n\r\n\r"; }