From 71c6714f447542ad2e765be3458e3aa3b3e456bb Mon Sep 17 00:00:00 2001 From: Doug Freed Date: Fri, 18 Dec 2015 12:13:16 +0400 Subject: Make web scripts load DB configuration from ASM --- cgi-bin/query.pl | 8 +++++++- cgi-bin/secret/investigate.pl | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cgi-bin/query.pl b/cgi-bin/query.pl index 4a9ed26..35c2455 100755 --- a/cgi-bin/query.pl +++ b/cgi-bin/query.pl @@ -7,7 +7,13 @@ use DBI; use CGI_Lite; -my $dbh = DBI->connect("DBI:mysql:database=asm_main;host=localhost;port=3306", 'USER', 'PASSWORD'); +use XML::Simple qw(:strict); +my $xs1 = XML::Simple->new( KeyAttr => ['id'], Cache => [ qw/memcopy/ ]); +my $sqlconf = $xs1->XMLin( "/home/icxcnika/AntiSpamMeta/config-main/mysql.xml", + ForceArray => ['ident', 'geco'], + 'GroupTags' => { ignoredidents => 'ident', ignoredgecos => 'geco' }); + +my $dbh = DBI->connect("DBI:mysql:database=" . $sqlconf->{db} . ";host=" . $sqlconf->{host} . ";port=" . $sqlconf->{port}, $sqlconf->{user}, $sqlconf->{pass}); my $debug = 0; diff --git a/cgi-bin/secret/investigate.pl b/cgi-bin/secret/investigate.pl index 0716480..23a5945 100755 --- a/cgi-bin/secret/investigate.pl +++ b/cgi-bin/secret/investigate.pl @@ -6,8 +6,13 @@ use strict; use DBI; use CGI_Lite; +use XML::Simple qw(:strict); +my $xs1 = XML::Simple->new( KeyAttr => ['id'], Cache => [ qw/memcopy/ ]); +my $sqlconf = $xs1->XMLin( "/home/icxcnika/AntiSpamMeta/config-main/mysql.xml", + ForceArray => ['ident', 'geco'], + 'GroupTags' => { ignoredidents => 'ident', ignoredgecos => 'geco' }); -my $dbh = DBI->connect("DBI:mysql:database=asm_main;host=localhost;port=3306", 'USER', 'PASSWORD'); +my $dbh = DBI->connect("DBI:mysql:database=" . $sqlconf->{db} . ";host=" . $sqlconf->{host} . ";port=" . $sqlconf->{port}, $sqlconf->{user}, $sqlconf->{pass}); my $debug = 0; @@ -99,7 +104,7 @@ HTML ##Queryable items: ## nick, user, host, realip, gecos, account -my $qry = 'SELECT * FROM actionlog WHERE '; +my $qry = 'SELECT * FROM ' . $sqlconf->{actiontable} . ' WHERE '; if (defined($data{nick}) && ($data{nick} ne "*") && ($data{nick} ne "")) { $qry .= " nick like " . esc($data{nick}) . ' or '; -- cgit v1.2.3