#!/usr/bin/perl # ipdb/cgi-bin/admin.cgi # Hack interface to make specific changes to IPDB that (for one reason # or another) can't be made through the main interface. # ### # SVN revision info # $Date: 2010-09-23 21:23:31 +0000 (Thu, 23 Sep 2010) $ # SVN revision $Rev: 488 $ # Last update by $Author: kdeugau $ ### # Copyright (C) 2004-2010 - Kris Deugau use strict; use warnings; use CGI::Carp qw(fatalsToBrowser); use CGI::Simple; use HTML::Template; use DBI; use CommonWeb qw(:ALL); use CustIDCK; #use POSIX qw(ceil); use NetAddr::IP; use Sys::Syslog; # don't remove! required for GNU/FHS-ish install from tarball ##uselib## use MyIPDB; openlog "IPDB-admin","pid","$IPDB::syslog_facility"; # Collect the username from HTTP auth. If undefined, we're in a test environment. my $authuser; if (!defined($ENV{'REMOTE_USER'})) { $authuser = '__temptest'; } else { $authuser = $ENV{'REMOTE_USER'}; } syslog "debug", "$authuser active"; # Why not a global DB handle? (And a global statement handle, as well...) # Use the connectDB function, otherwise we end up confusing ourselves my $ip_dbh; my $sth; my $errstr; ($ip_dbh,$errstr) = connectDB_My; if (!$ip_dbh) { printAndExit("Database error: $errstr\n"); } initIPDBGlobals($ip_dbh); # anyone got a better name? :P my $thingroot = $ENV{SCRIPT_FILENAME}; $thingroot =~ s|cgi-bin/admin.cgi||; # Set up some globals $ENV{HTML_TEMPLATE_ROOT} = $thingroot."templates"; if ($IPDBacl{$authuser} !~ /A/) { my $page = HTML::Template->new(filename => "admin/aclerr.tmpl"); ##fixme: need params for IPDB admin email and name $page->param(ipdbadmin_email => 'ipdbadmin@example.com'); $page->param(ipdbadmin_name => 'the IPDB administrator'); print "Content-Type: text/html\n\n".$page->output; exit; } # Set up the CGI object... my $q = new CGI::Simple; # ... and get query-string params as well as POST params if necessary $q->parse_query_string; # Convenience; saves changing all references to %webvar ##fixme: tweak for handling