Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Lastlink SSI

Quote Reply
Lastlink SSI
Hello all,

The mod below is the way how to create the Lastlink and call the file using the SSI, but its for Links 2.0, how can i make it with Links SQL 2.1.0 ? Please help.

1. =====lastlink.cgi=====
#!/usr/bin/perl
$txtfile1 = '/path/to/1.txt';
$txtfile2 = '/path/to/2.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 "/path/to/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 {
# --------------------------------------------------------
my $LASTX1 = 9;
my $LASTX2 = 9;
open (DB, "<$db_file_name") or &cgierr("unable to open database:$db_file_name.\nReason: $!");
$find = 0; $rand = int (rand ($count + 0.5)); ($rand == $count) and ($rand--);
my @lines = <DB>;
close DB;
for ($i=$#lines; $i>=$#lines - $LASTX1; $i--) {
chomp $lines[$i];
@tmp = &split_decode ($lines[$i]);
%tmp = &array_to_hash (0, @tmp);
$tmp{Title} =~ s/^(.{20}).*$/$1.../;
$lastlink .= &site_html_last_link1 (%tmp);
}
open (LASTLINK1, ">$txtfile1") or &cgierr ("Can't Open FILE: $txtfile1. Reason: $!");
print LASTLINK1 &site_html_last_link2;
close LASTLINK1;

for ($i=$#lines; $i>=$#lines - $LASTX2; $i--) {
chomp $lines[$i];
@tmp2 = &split_decode ($lines[$i]);
%tmp2 = &array_to_hash (0, @tmp2);
$tmp2{Title} =~ s/^(.{20}).*$/$1.../;
$lastlink2 .= &site_html_last_link1 (%tmp2);
}
open (LASTLINK2, ">$txtfile2") or &cgierr ("Can't Open FILE: $txtfile2. Reason: $!");
print LASTLINK2 &site_html_last_link2;
close LASTLINK2;
}

2. Add the following sub-routines in your site_html_templates.pl file:

sub site_html_last_link1 {
# --------------------------------------------------------
# This routine will build a home page. It is not meant to have any
# links on it, only subcategories.

my %rec = @_;
return &load_template ('lastlink1.html', {
%rec,
%globals
});
}

sub site_html_last_link2 {
# --------------------------------------------------------
# This routine will build a home page. It is not meant to have any
# links on it, only subcategories.
return &load_template ('lastlink2.html', {
lastlink => $lastlink,
%globals
});
}

3. Create the following template files:

a) lastlink1.html
b) lastlink2.html

The first template file should include the tags that you want to print, like the following:
<a href="<%db_cgi_url%>/jump.cgi?ID=<%ID%>"><%Title%></a> (Added: <%Date%> )

The second template file should ONLY include the following tag:
<%lastlink%>

4. Upload a blank file called 1.txt and 2.txt to your $txtfile1 and $txtfile2 directory. Change the permission of this file to 777 (rwxrwxrwx).

5. Then add the following codes to your non-links pages (Make sure that these files allow SSI calls)

<!--#include virtual="/lastlink/1.txt"-->
and
<!--#include virtual="/lastlink/2.txt"-->
Subject Author Views Date
Thread Lastlink SSI reenee 10469 Mar 10, 2002, 7:08 PM
Thread Re: [reenee] Lastlink SSI
reenee 10130 Mar 12, 2002, 12:06 AM
Thread Re: [reenee] Lastlink SSI
Beck 10136 Mar 12, 2002, 1:50 AM
Thread Re: [Beck] Lastlink SSI
reenee 10104 Mar 12, 2002, 2:07 AM
Post Re: [reenee] Lastlink SSI
Beck 10089 Mar 12, 2002, 2:33 AM
Thread Re: [reenee] Lastlink SSI
Paul 10094 Mar 12, 2002, 2:40 AM
Thread Re: [RedRum] Lastlink SSI
DogTags 10037 Mar 12, 2002, 4:46 AM
Thread Re: [DogTags] Lastlink SSI
reenee 10069 Mar 12, 2002, 5:01 AM
Thread Re: [reenee] Lastlink SSI
Paul 10054 Mar 12, 2002, 5:27 AM
Post Re: [RedRum] Lastlink SSI
reenee 10041 Mar 12, 2002, 5:41 AM
Thread Re: [reenee] Lastlink SSI
Paul 10187 Mar 12, 2002, 5:50 AM
Thread Re: [RedRum] Lastlink SSI
reenee 10085 Mar 12, 2002, 6:13 AM
Thread Re: [reenee] Lastlink SSI
Paul 10074 Mar 12, 2002, 6:31 AM
Thread Re: [RedRum] Lastlink SSI
reenee 10034 Mar 12, 2002, 6:35 AM
Thread Re: [reenee] Lastlink SSI
Paul 10026 Mar 12, 2002, 7:01 AM
Thread Re: [RedRum] Lastlink SSI
reenee 10046 Mar 12, 2002, 7:15 AM
Thread Re: [reenee] Lastlink SSI
Paul 10057 Mar 12, 2002, 7:18 AM
Thread Re: [RedRum] Lastlink SSI
reenee 10105 Mar 12, 2002, 7:28 AM
Thread Re: [reenee] Lastlink SSI
reenee 10034 Mar 12, 2002, 7:39 AM
Thread Re: [reenee] Lastlink SSI
Paul 10059 Mar 12, 2002, 7:48 AM
Thread Re: [RedRum] Lastlink SSI
reenee 10035 Mar 12, 2002, 7:58 AM
Thread Re: [reenee] Lastlink SSI
Paul 10039 Mar 12, 2002, 8:00 AM
Thread Re: [RedRum] Lastlink SSI
reenee 10048 Mar 12, 2002, 8:09 AM
Thread Re: [reenee] Lastlink SSI
Paul 9970 Mar 12, 2002, 8:12 AM
Thread Re: [RedRum] Lastlink SSI
reenee 9970 Mar 12, 2002, 8:23 AM
Thread Re: [reenee] Lastlink SSI
reenee 4929 Mar 12, 2002, 12:20 PM
Thread Re: [reenee] Lastlink SSI
Paul 4980 Mar 12, 2002, 12:28 PM
Thread Re: [RedRum] Lastlink SSI
reenee 4933 Mar 12, 2002, 12:34 PM
Thread Re: [reenee] Lastlink SSI
Paul 4951 Mar 12, 2002, 12:54 PM
Thread Re: [RedRum] Lastlink SSI
reenee 4934 Mar 13, 2002, 2:58 AM
Thread Re: [reenee] Lastlink SSI
Paul 4926 Mar 13, 2002, 3:00 AM
Thread Re: [RedRum] Lastlink SSI
reenee 5084 Mar 13, 2002, 3:07 AM
Post Re: [reenee] Lastlink SSI
Paul 4889 Mar 13, 2002, 3:15 AM
Thread Re: [reenee] Lastlink SSI
Alex 4947 Mar 13, 2002, 12:48 PM
Post Re: [Alex] Lastlink SSI
Nomada 4760 Aug 9, 2003, 4:09 AM
Thread Re: [Paul] Lastlink SSI
eddie123 4800 Jul 28, 2003, 4:49 PM
Post Re: [eddie123] Lastlink SSI
afinlr 4813 Jul 29, 2003, 11:08 AM