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"-->
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"-->