#!/usr/bin/perl
use DBI;
use Astro::Time;
use Date::DayOfWeek;
use HTML::Template;
use Image::Size 'imgsize';
use LWP::Simple;
require '/home/radish/www/lib/common_sections.pm';
require '/home/radish/www/lib/increment.pm';
require '/home/radish/www/lib/display_ads_rad6.pm';
require '/home/radish/www/lib/stories.pm';
require '/home/radish/www/lib/stdin.pm';
require '/home/radish/www/lib/globalsearch.pm';
require "/home/radish/www/lib/menus.pm";
print "Content-type:text/html\n\n";
#$ENV{'QUERY_STRING'} = "prcss=display&id=512483";
#$ENV{'QUERY_STRING'} = "section=met&prcss=day_list";
%data = &c::get_stdin_old;
@keys = keys %data;
#+++++++++++++++++++++++++++++++++
#definition of variables
$db="archives";
$host="64.4.170.130";
$user="radish";
$password="goodforyou";
#connect to remote MySQL database
my $dbh = DBI->connect ("DBI:mysql:database=$db:host=$host",$user,$password);
#+++++++++++++++++++++++++++++++++
if($data{'prcss'} eq "day_list"){
&day_list;
}
elsif($data{'prcss'} eq "display"){
&display;
}
else{
print "please select a section";
}
#+++++++++++++++++++++++++++++++++
$dbh->disconnect;
#+++++++++++++++++++++++++++++++++
#################
sub day_list {
$jday = &c::get_cjd;
$i=0;
@basket = ();
$section = $data{'section'};
$pastwk = $jday - ($c::sect{$section}[1] + 1);
#$pastwk = $jday - 60;
#determine which ad zone to display
if(($data{'section'} eq 'iow') || ($data{'section'} eq 'ill')){
$hzone = 48;
$vzone = 49;
}
else{
$hzone = 44;
$vzone = 45;
}
if($data{'section'} eq "cut"){
print qq();
}
else{
$sql = "select headline,section,id,jd,body from qco where jd>? and section=? order by jd desc, id desc";
@execs = ($pastwk,$section);
if($section eq "met"){
$sql = "select headline,section,id,jd,body from qco where jd>? and (section=? or section=? or section=? or section=? or section=? or section=? or section=?) order by jd desc, id desc";
@execs = ($pastwk,$section,'was','spr','rel','me','kuw','flk');
}
elsif($section eq "rec"){
$sql = "select headline,section,id,jd,body from qco where jd>? and (section=? or section=? or section=? or section=? or section=? or section=? or section=?) order by jd desc, id desc";
@execs = ($pastwk,$section,'ded','bir','crt','mad','sch','ret');
}
elsif($section eq "lif"){
$sql = "select headline,section,id,jd,body from qco where" .
" jd>? and (section=? or section=? or section=? or section=? or section=? or section=? or section=? or section=?)" .
" order by jd desc, id desc";
@execs = ($pastwk,$section,'ent','mrx','fud','cen','tra','soc','lbf');
}
elsif($section eq 'spt'){
$sql = "select headline,section,id,jd,body from qco where" .
" jd>? and (section=? or section=? or section=? or section=?)" .
" order by jd desc, id desc";
@execs = ($pastwk,$section,'pro','hss','col');
}
#+++++++++++++++++++++++++++++++++
my $sth = $dbh->prepare($sql);
$sth->execute(@execs);
while(@data = $sth->fetchrow_array) {
$basket[$i][0] = $data[0];
$basket[$i][1] = $data[1];
$basket[$i][2] = $data[2];
$basket[$i][3] = $data[3];
$basket[$i][4] = $data[4];
if(($basket[$i][4] !~ m~
/ /g; $body =~ s// /g; $story{'section'} = $data[1]; $story{'jd'} = $data[2]; $story{'id'} = $data[3]; } $sth->finish; #+++++++++++++++++++++++++++++++++ for(@c::columns){ ($a,$story{$_},$b) = ($body =~ m/(<$_>)(.*)(<\/$_>)/); } ($a,$story{'photo_id'},$b) = ($body =~ m/( //; $hcolor = "#333E79"; $hfontcolor = "#ffffff"; #highlight query in content @query_words = &c::get_query_words($data{'query'}); for(@query_words){ $story{'body'} = &c::highlight_content($_,$story{'body'}); } #$output = qq( $date
$story{'copyright'} ); if($story{'section'} eq "obi"){ $obi_dir = &c::get_obi_dir($story{'jd'}); $output =~ s^This story is available to non-subscribers for a limited time. For instant access to all published stories, including The Dispatch and Rock Island Argus archives, click here.); #} #$print_link = qq(Printer-friendly Page); if($data{'print'}){ $Template_file = "/home/radish/www/htdocs/stories/tpl_qco_print_stories.html"; } else{ $Template_file = "/home/radish/www/htdocs/stories/tpl_stories.html"; } $tpl = HTML::Template->new( type => 'filename', source => $Template_file, die_on_bad_params => 0, ); $tpl->param( print_link => $print_link, menu => '', skyscraper => '', story => $output, date => $story{'date'}, headline => $story{'head'}, byline => $story{'byline'}, related_stories => &get_related_stories, display_ad_bot => $ads{'bot_ad'}, storyid => $disp_id, comments => 1, comment_sub => ($data{'comment_sub'}?"&comment_sub=".$data{'comment_sub'}:""), ); print $tpl->output; ###### c::increment_clicks($disp_id,'clicks_open'); } ########## sub assign_photo_info{ my @loop; if($story{'photo_id'}){ $story{'photo_id'} =~ s/\,/ /g; @photoids = split(" ",$story{'photo_id'}); foreach $photoid(@photoids){ $sql = qq(select pic_name,folder,photographer,cutline,public,keywords from photog where id=$photoid); my $sth = $dbh->prepare($sql); $sth->execute; while(@data = $sth->fetchrow_array) { my %rows; $rows{'photo'} = $data[0]; $rows{'photofolder'} = $data[1]; $rows{'photocredit'} = $data[2]; $rows{'photocaption'} = $data[3]; $rows{'public'} = $data[4]; $rows{'keywords'} = $data[5]; if($rows{'keywords'} =~ /GRAPHIC/){ $rows{'graphic'} = 1; } %rows = &assign_photo_vars(%rows); push (@loop,\%rows); } } $phot = 1; } else{ $story{'photo'} = "$story{'photo'}.jpg"; $story{'photo'} =~ s/ //g; $story{'photofolder'} =~ s/ //g; if(($story{'photo'} ne ".jpg")&&($story{'photo'} ne ".gif")){ $phot = 1; #we have to see if public can see subfolder pics $subfoldyr = "%$story{'photofolder'}%"; $imgnyme = $story{'photo'}; $imgnyme = substr($imgnyme, 0, -4); $imgnyme = "%$imgnyme%"; my $sth = $dbh->prepare('select public,keywords from photog where (folder like ?) and (pic_name like ?)'); $sth->execute($subfoldyr,$imgnyme); while(@data = $sth->fetchrow_array) { $story{'public'} = $data[0]; $story{'keywords'} = $data[1]; } $sth->finish; } $rows{'photo'} = $story{'photo'}; $rows{'photofolder'} = $story{'photofolder'}; $rows{'photocredit'} = $story{'photocredit'}; $rows{'photocaption'} = $story{'photocaption'}; $rows{'public'} = $story{'public'}; $rows{'keywords'} = $story{'keywords'}; %rows = &assign_photo_vars(%rows); push(@loop,\%rows); } return @loop; } ############ sub format_photo{ %story = @_; if($story{'section'} eq "soc"){ $output .= qq( More Quad Citians in Kuwait Photos); my @fldr_stuff; @fldr_stuff = &c::get_week_dir($rows{'photofolder'}); $rows{'weekdir'} = $fldr_stuff[0]; if($fldr_stuff[1]){ if($rows{'public'} eq "a"){ if($rows{'photofolder'} !~ m/gulf/){ $rows{'mor_link'} = qq(More photos from this shoot); } else{ $rows{'mor_link'} = qq( More Quad Citians in Kuwait Photos); } } else{ $rows{'mor_link'} = qq(); } } else{ $rows{'mor_link'} = qq() unless($story{'section'} eq "flk"); } $rows{'photo_gif'} = $rows{'photo'}; $rows{'photo_gif'} =~ s/.jpg/.gif/i unless $rows{'keywords'} =~ /GRAPHIC/; $img_call = get("http://photos.qconline.com/mednails/$fldr_stuff[0]/$rows{'photofolder'}/$rows{'photo_gif'}"); my @img_dims; @img_dims = &c::img_siz($img_call,200); %ads = &c::get_ads($img_dims[1]); unless($rows{'public'} eq "x"){$rows{'photo_link'} = 1} return %rows; } ########## sub get_related_stories { if($story{'related_stories'}){ $story{'related_stories'} =~ s/\,/ /g; @related_ids = split(" ",$story{'related_stories'}); my @loop; for(@related_ids){ $sql = qq(select headline,date from qco where id=$_); my $sth = $dbh->prepare($sql); $sth->execute; while(@data = $sth->fetchrow_array){ my %rows; $rows{'headline'} = $data[0]; $rows{'date'} = $data[1]; $rows{'id'} = $_; push (@loop,\%rows); } } $rTemplate = "/home/radish/www/htdocs/stories/related_stories.tpl"; $rtpl = HTML::Template->new( type => 'filename', source => $rTemplate, die_on_bad_params => 0, ); $rtpl->param( headlines => \@loop, ); return $rtpl->output; } } |