Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Mirrors (jump.cgi) with Link2.0

Quote Reply
Mirrors (jump.cgi) with Link2.0
I have Linos2.0 configured it with up to 4 mirrors. I added fields Mirror_2, Mirro_3. Of course these fields do not use jump.cgi like the URL one. We don´t have our files hosted anymore on the mirrror configured in the URL field. So I would like to know if there is anyway to change jump.cgi code in order links can work with the Mirror_2 field insted of the URL one, so then Mirror_2 will be the default url used when I call jump.cgi?ID=xxxxxx

Thanks for your help.
Quote Reply
Re: [ArielS] Mirrors (jump.cgi) with Link2.0 In reply to
In jump.cgi, try copying the file (example jump2.cgi), and change;

Code:
while (<URL>) {
(/^$id$delim(.+)/o) or next;
chomp ($goto = $1);
last;
}

to something like;

Code:
while (<URL>) {
my @cut= split /$delim/, $_;
$goto = $cut[1];
last;
}

Change $cut[1] to whatever field the different URL is held in. For example, if your database looked like;

ID|URL|Title|Test|URL2|URL3

...you would use something like $cut[4] or $cut[5].

This mod is untested, and I havn't used Links 2 for a good few months, so I'm pretty rusty on it. May, or may not work Crazy

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Mirrors (jump.cgi) with Link2.0 In reply to
Thanks for your help Smile
I tried but it does not work.
Seems I have to rebuild my database.
Quote Reply
Re: [ArielS] Mirrors (jump.cgi) with Link2.0 In reply to
Andy forget to check the ID number, but other than that it should be okay.
Code:
while (<URL>) {
/^$id$delim/ or next;
my @cut = split /$delim/, $_;
$goto = $cut[1];
last;
}

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] Mirrors (jump.cgi) with Link2.0 In reply to
Thanks but seems not work for me. It gives me not link id found.
I´m sure ít´s a problem ralted with my database
Thanks for your help Smile
Quote Reply
Re: [ArielS] Mirrors (jump.cgi) with Link2.0 In reply to
This is probably too easy to work... could you go into links.def and change the name of the field you added, mirror_1 to URL? Then change the original URL to URL_old or something.

Like I said, I doubt it's that easy. There is a script for editing the db file, you could tell it to move field X (whatever your mirror_2 is) to field 2 (original URL field), or any good text editor (http://www.textpad.com) should make it easy.


Leonard
aka PerlFlunkie
Quote Reply
Re: [ArielS] Mirrors (jump.cgi) with Link2.0 In reply to
yeah, now that I think about it, you would have to change the way the url.db file is built in order for this to work. this is NOT tested, use at your own risk.

in nph_build.cgi, find:
Code:
sub build_url_index {
# --------------------------------------------------------
# This routine builds a quick URL lookup database so the script
# does not have to search the links.db for every hit.

my $time = time();
my @values = ();
my $count = 0;

open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name.\nReason: $!");
open (URL, ">$db_url_name") or &cgierr("unable to open url index: $db_url_name. Reason: $!");
if ($db_use_flock) { flock (URL, 2) or &cgierr ("unable to get exclusive lock. Reason: $!"); }
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
print URL "$values[$db_key_pos]$db_delim$values[$db_url]\n";
$count++;
}
close DB;
close URL;

# Build the count file used to do random links.
open (CNT, ">$db_hits_path/index.count") or &cgierr("unable to open count file: '$db_hits_path/index.count'. Reason: $!");
if ($db_use_flock) { flock (CNT, 2) or &cgierr ("unable to get exclusive lock on $db_hits_path/index.count. Reason: $!"); }
print CNT $count;
close CNT;
}

and replace it with:

Code:
sub build_url_index {
# --------------------------------------------------------
# This routine builds a quick URL lookup database so the script
# does not have to search the links.db for every hit.

my $time = time();
my @values = ();
my $count = 0;

open (DB, "<$db_file_name") or &cgierr("unable to open database: $db_file_name.\nReason: $!");
open (URL, ">$db_url_name") or &cgierr("unable to open url index: $db_url_name. Reason: $!");
if ($db_use_flock) { flock (URL, 2) or &cgierr ("unable to get exclusive lock. Reason: $!"); }
LINE: while (<DB>) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
@values = &split_decode($_);
print URL join ($db_delim, ($values[$db_key_pos], $values[$db_url], $values[$mirror_1], $values[$mirror_2])) . "\n";
$count++;
}
close DB;
close URL;

# Build the count file used to do random links.
open (CNT, ">$db_hits_path/index.count") or &cgierr("unable to open count file: '$db_hits_path/index.count'. Reason: $!");
if ($db_use_flock) { flock (CNT, 2) or &cgierr ("unable to get exclusive lock on $db_hits_path/index.count. Reason: $!"); }
print CNT $count;
close CNT;
}

where $mirror_1 and $mirror_2 are the field positions for the mirrors.

you could also use the same jump.cgi, just pass a parameter when you want to use one of the mirrors.

Code:
while (<URL>) {
/^$id$delim/ or next;
my @cut = split /$delim/, $_;
$goto = $cut[1 + ($in{mirror} =~ /^1|2$/ ? $in{mirror} : 0)];
last;
}

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] Mirrors (jump.cgi) with Link2.0 In reply to
Thanks for your help!!!! Smile
It works!!!!