#!/usr/bin/perl -w
###########################################
# SCRIPT NAME : coreservice.cgi
# 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;
my %COREINFO;
$COREINFO{core_template} = HTML::Template->new(filename => 'tmpl/coreservice.tmpl');
$COREINFO{corenumber} = $cgi->param('corenumber');
&core(\%COREINFO);
1;
sub core {
my ($params_hashref) = @_;
my %params_hash = %{ $params_hashref };
my $core_template = $params_hash{core_template};
my $corenumber = $params_hash{corenumber};
##############################################
#### Coreservice Name don't change!
my %hashcore;
$hashcore{1} = "Corporate Branding";
$hashcore{2} = "Name Development";
$hashcore{3} = "Advertising";
$hashcore{4} = "Interactive Media";
$hashcore{5} = "Marketing Research";
$hashcore{6} = "Marketing Communications";
$hashcore{7} = "Environmental Design";
my %prjtype;
$prjtype{$hashcore{1}} = "portfolio_CB";
$prjtype{$hashcore{2}} = "portfolio_ND";
$prjtype{$hashcore{3}} = "portfolio_AD";
$prjtype{$hashcore{4}} = "portfolio_IM";
$prjtype{$hashcore{5}} = "portfolio_MR";
$prjtype{$hashcore{6}} = "portfolio_MC";
$prjtype{$hashcore{7}} = "portfolio_ED";
##############################################
my ($corecontent,$coreimage);
my $sql = "SELECT count(*)";
$sql .= " From cmiContents";
$sql .= " Where cmiContentType = 'coreservices'";
$sql .= " And Active = '1'";
my $result = $dbh->selectrow_array($sql);
if ( $result ) {
$sql = "SELECT cmiContentText";
$sql .= " ,cmiImageName";
$sql .= " From cmiContents C";
$sql .= " Left Join cmiImages I";
$sql .= " On I.cmiContentID = C.cmiContentID";
$sql .= " And I.cmiImageType = 'main'";
$sql .= " And I.Active = '1'";
$sql .= " Where cmiContentTitle = '$hashcore{$corenumber}'";
$sql .= " And C.Active = '1'";
($corecontent,$coreimage) = $dbh->selectrow_array($sql);
unless ( $coreimage ) { $coreimage = qq{no-photo.jpg}; }
} else {
$coreimage = qq{no-photo.jpg};
}
$Log_Config{MESSAGE} = "SQL : $sql\n";
&cmiModule::EasyLog(\%Log_Config);
my $result_size = &check_size($corecontent);
my ($startremark,$endremark);
unless ( $result_size ) {
$startremark = qq{};
}
$core_template->param(startremark => $startremark);
$core_template->param(endremark => $endremark);
my $coretitle = $hashcore{$corenumber};
$core_template->param(coretitle => $coretitle);
$core_template->param(corecontent => $corecontent);
$core_template->param(coreimage => $coreimage);
my $corescroll = &select_coretype();
$core_template->param(corescroll => $corescroll);
my $goport = $prjtype{$hashcore{$corenumber}};
$core_template->param(goport => $goport);
print "Content-type:text/html\n\n";
print $core_template->output;
}
sub check_size {
my ($text) = @_;
my $chars = length( $text );
$Log_Config{MESSAGE} = "CHARS : $chars\n";
&cmiModule::EasyLog(\%Log_Config);
my $result;
if ( $chars > 1500 ) {
$result = "SCROLL_SHOW";
}
return $result;
}
sub select_coretype {
my ($coretype) = @_;
my %ctype;
$ctype{1} = "Corporate Branding";
$ctype{2} = "Name Developmant";
$ctype{3} = "Advertising";
$ctype{4} = "Interactive Media";
$ctype{5} = "Marketing Research";
$ctype{6} = "Marketing Communications";
$ctype{7} = "Environmental Design";
my $out;
$out = qq{};
return $out;
}