#!/usr/bin/perl -w
###########################################
# SCRIPT NAME : servicecgi
# DATE: Sep 2004
# VERSION: 1.0
# AUTHOR: Sarun Chinskul
# EMAIL: schinskul@crystalmckenzieinc.com
###########################################
use lib "/home/httpd/vhosts/cminyc.com/httpdocs/admin";
chdir "/home/httpd/vhosts/cminyc.com/httpdocs/";
use CGI;
use DBI;
use HTML::Template;
use cmiModule;
use strict;
$|++;
########################
# Read Config.conf file
########################
my @info = &cmiModule::ReadConfig("config.conf");
########################
# Logfile config setup
########################
my %Log_Config;
# Setting EasyLog is ON or OFF in config.conf file
$Log_Config{SWITCH} = $info[0];
$Log_Config{FILENAME} = $info[1];
$Log_Config{MESSAGE} = "-------STARTED LOG [".$0."]-------";
&cmiModule::EasyLog(\%Log_Config);
########################
# Database config setup
########################
my %DB;
$DB{DATABASE} = $info[2];
$DB{ACCOUNT} = $info[3];
$DB{PASSWORD} = $info[4];
my $dbh;
unless( $dbh = &cmiModule::ConnectToMySQL(\%DB) ) {
$Log_Config{"MESSAGE"} = "Bad DBH from ConnectToMySQL.";
&cmiModule::EasyLog(\%Log_Config);
print "Content-type:text/html\n\n";
print "Bad DBH from ConnectToMySQL.";
exit;
}
###### End config ######
my $cgi = new CGI;
##########################################################
# Service text
##########################################################
my $text = qq{Services
};
$text .= qq{CMI is a full-service communications };
$text .= qq{agency, offering
complete in-house };
$text .= qq{facilities for all activities required to
};
$text .= qq{support client marketing, media and public };
$text .= qq{information
service. Some clients use every };
$text .= qq{service others choose to
use only those };
$text .= qq{services that complement existing internal
};
$text .= qq{and external resources.};
##########################################################
my %SERVICEINFO;
$SERVICEINFO{service_template} = HTML::Template->new(filename => 'tmpl/service.tmpl');
$SERVICEINFO{servicetext} = $text;
$SERVICEINFO{servicetype} = $cgi->param('servicetype');
&service(\%SERVICEINFO);
1;
sub service {
my ($params_hashref) = @_;
my %params_hash = %{ $params_hashref };
my $service_template = $params_hash{service_template};
my $servicetext = $params_hash{servicetext};
my $servicetype = $params_hash{servicetype};
$service_template->param(servicetext => $servicetext);
my $showservicetype = &ShowServiceTypeName();
$service_template->param(showservicetype => $showservicetype);
unless ( $servicetype ) { $servicetype = "Collateral";}
my $sql = "SELECT cmiServiceName";
$sql .= " From cmiServices";
$sql .= " Where cmiServiceType = '$servicetype'";
my $rec = $dbh->prepare($sql);
$rec->execute;
my (@fld,$servicename);
$servicetype =~ s/[A-Z]/ $&/g;
$servicename = "$servicetype
";
while(@fld = $rec->fetchrow) {
$servicename .= " -$fld[0]
";
} $servicename .= "";
$rec->finish;
$service_template->param(showservicename => $servicename);
print "Content-type:text/html\n\n";
print $service_template->output;
}
sub ShowServiceTypeName {
my $sql = "SHOW FIELDS FROM cmiServices LIKE 'cmiServiceType'";
my $rec = $dbh->prepare($sql);
$rec->execute;
my @fld = $rec->fetchrow;
my $list = $fld[1];
$list =~ s/enum\(\'//ig;
$list =~ s/\'\,\'/ /ig;
$list =~ s/\'\)//ig;
my @array_tmp = split(/ /,$list);
my $out = qq{};
return $out;
}