#!/usr/bin/perl
use strict;
use warnings;

BEGIN { require("../config.cgi"); }



if ($#ARGV != 0) {
   print "Usage: $0 <domain name>\n";
   print "   ie: $0 cpanel.net\n";
   exit;
}


if (!eval("use HTML::Template; 1;")) {
   print "HTML::Template not found.\n";
   exit;
}
if (!eval("use GD::SecurityImage; 1;")) {
   print "GD::SecurityImage not found\n";
   exit;
}
if (!eval("use cpSupport; 1;")) {
   print "cpSupport not found. Possible INC problem ?\n";
   exit;
}
if (!eval("use cpSupport::User; 1;")) {
   print "cpSupport::User not found. Possible INC problem ?\n";
   exit;
}

if (!eval("use cpSupport::Config; 1;")) {
   print "cpSupport::Config not found. Possible INC problem?\n";
   exit;
}
if (!eval("use cpSupport::Profile; 1;")) {
   print "cpSupport::Profile not found. Possible INC problem?\n";
   exit;
}

if (!cpSupport::loadConfig($ARGV[0])) {
   print "Unable to load configuration for ".$ARGV[0]."\n";
   print "Reasons should be above.\n";
   exit;
}

my $dbh = cpSupport::connectToDb();

if (!defined($dbh)) {
   print "I was unable to connect to the database for this domain.\n";
   exit;
}

my $config = new cpSupport::Config($dbh);

my $theme = (defined($config->get("theme"))) ? $config->get("theme"):"default";

print "Current Config:\n";
print "   Domain: ".$config->get("domain")."\n";
print " Base URL: ".$config->get("baseurl")."\n";
print "  Contact: ".$config->get("contact")."\n";
print "Email Support: ".$config->get("emailsupport")."\n\n";
