ok.. i have a question for everyone.. has anyone ever gotten this script to work?? cause i just read through the code and all it is going to do is return a blank template with no link information on it..
ok.. here is a rewrite.. it will work with templates and non templates..
sotd.cgi Code:
#!/usr/local/bin/perl
$txtfile = '/path/to/sotd.txt';
# Required Librariers
# --------------------------------------------------------
eval {
($0 =~ m,(.*)/[^/]+,) && unshift (@INC, "$1"); # Get the script location: UNIX /
($0 =~ m,(.*)\\[^\\]+,) && unshift (@INC, "$1"); # Get the script location: Windows \
require "admin/links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
$build_use_templates ?
require "$db_lib_path/site_html_templates.pl" :
require "$db_lib_path/site_html.pl";
};
if ($@) {
print "Content-type: text/plain\n\n";
print "Error including libraries: $@\n";
print "Make sure they exist, permissions are set properly, and paths are set correctly.";
exit;
}
# ========================================================
eval { &main; }; # Trap any fatal errors so the program hopefully
if ($@) { &cgierr("fatal error: $@"); } # never produces that nasty 500 server error page.
exit; # There are only two exit calls in the script, here and in in &cgierr.
sub main {
# --------------------------------------------------------
open (DB, "<$db_file_name") or &cgierr ("Can't Open DB: $db_file_name");
my @links = <DB>;
close DB;
my %rec = &array_to_hash (0, &split_decode ($links[int rand $#links]));
open (SOTD, ">$txtfile") or &cgierr ("Can't Open FILE: $txtfile. Reason: $!");
print SOTD &site_html_sotd (%rec);
close SOTD;
$ENV{'REQUEST_METHOD'} and print "Content-type: text/plain\n\n";
print "ID: $rec{$db_key} Title: $rec{'Title'}\n";
}
site_html.pl Code:
sub site_html_sotd {
# --------------------------------------------------------
# This routine determines how the sotd link will look like.
#
my %rec = @_;
my ($output);
$output = qq~
<a href="$rec{'URL'}">$rec{'Title'}</a><br>
~;
return $output;
}
site_html_templates.pl Code:
sub site_html_sotd {
# --------------------------------------------------------
# This routine determines how the sotd link will look like.
#
my %rec = @_;
# Set new and pop to either 1 or 0 for templates.
($rec{'isNew'} eq 'Yes') ? ($rec{'isNew'} = 1) : (delete $rec{'isNew'});
($rec{'isPopular'} eq 'Yes') ? ($rec{'isPopular'} = 1) : (delete $rec{'isPopular'});
return &load_template ('sotd.html', {
%rec,
%globals
});
}
sotd.html Code:
<a href="<%URL%>"><%Title%></a><br>
then you can run this via cron..
read
www.gossamer-threads.com/scripts/resources/Detailed/244.html for help
and then using SSI.. you can attach it to a page..
Code:
<!--#include virtual="sotd.txt"-->
jerry
[This message has been edited by widgetz (edited January 17, 2000).]