I needed a simple script to pull data from links.db and this is what I came up with. It's short and sweet and can be modified to pull ANY fields from your links.db and output it via ssi any way you like. As it is here, you'll get a random linked title. Enjoy.
#!/usr/local/bin/perl
# Name: EZ Random Link by Kerouac
# Date: 6-05-01
# File Name: ezrand.cgi
#
# Required: Links 2, Perl, SSI enabled pages
#
# What it does:
# This is a very simple script that pulls a random link from your links.db via ssi
# and displays it. It doesn't "require" any links files - it just randomly selects a link
# from links.db and puts it wherever you want it to appear on your site via ssi.
#
# Directions:
#
# 1. Change perl path to match yours
# 2. Put your system path in the $rand_file variable
# 3. Put the url to your Links jump.cgi script in the $cgi_url variable
# 4. Put your preferred font size in $fsize and your preferred font face in $fface
# 5. Decide if you want a linked title or a linked title plus description.
# This script is setup to return a linked title only. If you also want a description,
# then just comment out the "linked title only" print line and uncomment the
# "linked title with description" print line.
# 6. Make sure the $links_field[x] variables match your links.def file's fields.
# This script assumes that your relevant links.def fields are:
# 0 = ID
# 1 = Title
# 5 = Description
# 7. Upload in ascii mode to the directory where your links jump.cgi script is
# 8. Chmod to 755
# 9 Call via ssi as
$rand_file = "/usr/home/path/to/your/links/bin/admin/data/links.db";
$cgi_url = "http://yourdomain.com/links/bin/jump.cgi";
$fsize = "1";
$fface = "verdana,arial,helventica";
open (DATABASE, "<$rand_file") || die print "Could not open Links database";
@line=<DATABASE>;
close (DATABASE);
srand;
$array = $line[int rand(@line)];
@links_field = split (/\|/, $array);
print "Content-type: text/html\n\n";
# LINKED TITLE ONLY : The following line outputs a linked title only
print "<P><b><font size=\"$fsize\" face=\"$fface\"><a href=\"$cgi_url?ID=$links_field[0]\">$links_field[1]</a></font></b></p> ";
# LINKED TITLE WITH DESCRIPTION : Uncomment the following line and comment the above print line if you want a linked title PLUS description
# print "<P><font size=\"$fsize\" face=\"$fface\"><b><a href=\"$cgi_url?ID=$links_field[0]\">$links_field[1]</a></b>: $links_field[5]</font></p> ";
#!/usr/local/bin/perl
# Name: EZ Random Link by Kerouac
# Date: 6-05-01
# File Name: ezrand.cgi
#
# Required: Links 2, Perl, SSI enabled pages
#
# What it does:
# This is a very simple script that pulls a random link from your links.db via ssi
# and displays it. It doesn't "require" any links files - it just randomly selects a link
# from links.db and puts it wherever you want it to appear on your site via ssi.
#
# Directions:
#
# 1. Change perl path to match yours
# 2. Put your system path in the $rand_file variable
# 3. Put the url to your Links jump.cgi script in the $cgi_url variable
# 4. Put your preferred font size in $fsize and your preferred font face in $fface
# 5. Decide if you want a linked title or a linked title plus description.
# This script is setup to return a linked title only. If you also want a description,
# then just comment out the "linked title only" print line and uncomment the
# "linked title with description" print line.
# 6. Make sure the $links_field[x] variables match your links.def file's fields.
# This script assumes that your relevant links.def fields are:
# 0 = ID
# 1 = Title
# 5 = Description
# 7. Upload in ascii mode to the directory where your links jump.cgi script is
# 8. Chmod to 755
# 9 Call via ssi as
$rand_file = "/usr/home/path/to/your/links/bin/admin/data/links.db";
$cgi_url = "http://yourdomain.com/links/bin/jump.cgi";
$fsize = "1";
$fface = "verdana,arial,helventica";
open (DATABASE, "<$rand_file") || die print "Could not open Links database";
@line=<DATABASE>;
close (DATABASE);
srand;
$array = $line[int rand(@line)];
@links_field = split (/\|/, $array);
print "Content-type: text/html\n\n";
# LINKED TITLE ONLY : The following line outputs a linked title only
print "<P><b><font size=\"$fsize\" face=\"$fface\"><a href=\"$cgi_url?ID=$links_field[0]\">$links_field[1]</a></font></b></p> ";
# LINKED TITLE WITH DESCRIPTION : Uncomment the following line and comment the above print line if you want a linked title PLUS description
# print "<P><font size=\"$fsize\" face=\"$fface\"><b><a href=\"$cgi_url?ID=$links_field[0]\">$links_field[1]</a></b>: $links_field[5]</font></p> ";