![]() |
||||
|
|
||||
|
|
|
#!/usr/bin/perl
## this script generates the list of archive links
## for beauty & truth lab
## it is called as an SSI
require("/home/zenpride/freewillastrology.com/cgi-bin/globals.pl");
require("/home/zenpride/freewillastrology.com/cgi-bin/db_libs.pl");
use DBI;
use CGI;
print "content-type: text/html\n\n";
my $q = new CGI;
my $table = $q->param("table");
my $dbh = &db_connect();
my $dir = $beauty_dir;
opendir(DIR, "$dir") or die "Failed to open directory $dir because $!";
my @files = grep { !/^\./ && -f "$beauty_dir/$_" } readdir(DIR);
closedir(DIR);
my $match;
my $field;
if ($table eq "menstrual_hut") {
$match = "menstrual";
$field = "hut_date";
} elsif ($table eq "pagan_holidays") {
$match = "pagan";
$field = "holiday_headline";
} elsif ($table eq "saints_fools") {
$match = "saints";
$field = "saints_headline";
} elsif ($table eq "pronoia_news") {
$match = "pronoia";
$field = "news_date";
}
foreach my $file (@files) {
if ($file =~ /$match\d+.shtml/) {
my $parsefile = $file;
my $filename = $table . "_file";
my $tmpl_filename = $$filename;
$parsefile =~ s/$beauty_dir//g;
$parsefile =~ m/(\d+)/;
my $id = $1;
if ( (defined($id)) && ($id ne "") ) {
my $sql = qq{SELECT * FROM $table WHERE id=$id};
my $sth = $dbh->prepare($sql);
$sth->execute or die "Failed to execute $sql because $DBI::errstr";
my $url_name = $table . "_url";
my $url_link = $$url_name;
$url_link =~ s/\.shtml/$id\.shtml/g;
my $hash_ref = $sth->fetchrow_hashref;
if ( (defined($url_link)) && (defined($hash_ref->{"$field"})) ) {
print qq{$hash_ref->{$field} \n}; } } } } $dbh->disconnect();
|
The Muse Teases
|
|||
|
© 1995-2013 -- Rob Brezsny. All rights reserved |
||||