Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Links Regenerator

Quote Reply
Links Regenerator
Hiya,
My link site has multiple id's and I heard that the regenerator can fix this...
However I cant find the url as the old link tothe regenerator gets a page not found ??

Quote Reply
Re: Links Regenerator In reply to
If I understand right, you simply want to reset the link numbers? If so, this should suffice:
Code:
#!/usr/local/bin/perl
require "links.cfg";
my ($i, $new);
open (OLD, "$db_lib_path/data/links.db") or die "Reason: $!";
while () {
my ($line, $id, $jumk);
chomp ($line = <OLD>);
last if !$line;
$i++;
($id, $junk) = split /\|/, $line, 2;
$new .= "$i|$junk\n";
}
close (OLD);
open (NEW, ">$db_lib_path/data/new.db") or die "Reason: $!";
print NEW $new;
close (NEW);
open (ID, ">$db_lib_path/data/linksid.txt") or die "Reason: $!";
print ID $i;
close (ID);
print "Content-type: text/plain\n\n";
print "New database saved as new.db and linksid.txt has been updated.";
You could update urls.db with this script to, but since Links regenerates this file on each rebuild, it's not necesary.

Happy Coding,

--Drew
http://www.FindingHim.com
Quote Reply
Re: Links Regenerator In reply to
Sorry But what do I do with that code??

Quote Reply
Re: Links Regenerator In reply to
1) Copy the codes...
2) Paste them into your TEXT editor.
3) Change the configuration variables and codes (e.g., require "links.cfg";).
4) Save the file as regenerator.cgi.
5) Upload the script to your /cgi-bin/links/ folder in your server.
6) Change the permission of the file to 755.
7) Type in the following command:

Code:

perl regenerator.cgi


Basically, junko WROTE you a CGI script! use it!

Regards,

Eliot Lee
Quote Reply
Re: Links Regenerator In reply to
Thank you both sooooo much.. Its all fixed :)


Quote Reply
Re: Links Regenerator In reply to
Hello to All,
If I understand good, then this little CGI-script renumbers The links.db starting with Nr. 1 ...upto ... the last Link.
Would it also be possible to start with another value than the Number 1 for the first link ??????
Let's say I want all my Links ID to have 4 digits
So I would like to start Re-numbering with 1000
Is this possible ?????
Regards and Thank You
Sanuk

Quote Reply
Re: Links Regenerator In reply to
Why would you want to do that?....

Paul Wilson.
Installations:
http://www.wiredon.net/gt/
Quote Reply
Re: Links Regenerator In reply to
You have a typo I think Junko.....

my ($line, $id, $jumk);

Paul Wilson.
Installations:
http://www.wiredon.net/gt/
Quote Reply
Re: Links Regenerator In reply to
oops... glad I don't use strict! ...annoying sob if you ask me. Smile.

If you want to start at a different ID number, just add:
Code:
$i = "1000"; #number to start at
before the while() loop.

--Drew
Quote Reply
Re: Links Regenerator In reply to
strict is actually more efficient in terms of cycles (data processing and CPU usage).

Regards,

Eliot Lee
Quote Reply
Re: Links Regenerator In reply to
Maybe my problem is that it doesn't make complete sense to me.

Let's say I have a subroutine main(). Some bad input creates an error so I send the error to sub error(). Why can't I use 'my' in error(), like this?
Code:
my $error = shift;
Why must I predefine $error in main()?

How does strict make the script more efficient, specificly?

--Drew
Quote Reply
Re: Links Regenerator In reply to
Hi Drew:

You don't. You just have to define the scope of the $error variable when it is first used. For example:

sub main {

if (something) {
&error ("message");
}
}

sub error {

my $error = shift;
print $error;
}

I believe the main idea behind using strict is that it forces you to define the scope of variables which can prevent aliasing, and having variables cause unexpected and unintentional changes in other (similar named) variables in other subs or required files. My() is the better choice in almost all situations because it enforces local scope and limits side effects from function to inside the functions.


Dan Cool

LotusLand
Vancouver, BC, Canada
Top Ranked City in World for Quality of Life
Quote Reply
Re: Links Regenerator In reply to
Mad I wonder what I was doing last night that wouldn't let me do that?!!!

--Drew
Quote Reply
Re: Links Regenerator In reply to
Hi Paul,
I like 4 digits as an ID because it fits nicely in my Html page layout.
It would only be for Cosmetic page beauty reasons
Regards,
Sanuk

Quote Reply
Re: Links Regenerator In reply to
Hi Junko,
Thanks for your answer:
**** $i = "1000"; #number to start at ****
Works great
Thank You for Helping.
Regards,
Sanuk

Quote Reply
Re: Links Regenerator In reply to
In Reply To:
How does strict make the script more efficient, specificly?
Well, there are many reasons, but the most important is that if you use BAD codes in your Perl script, then the script will error out more gracefully rather than trying to execute and then probably crash your server.

Secondly, all variables are localized (via my and local), which is more efficient than using standard Perl variables. There are many more reasons...search http://www.perl.com for strict.

Regards,

Eliot Lee
Quote Reply
Re: Links Regenerator In reply to
Umm.. okay

All i need is something that will reset the Votes and hit counts for each ID... I am no perl expert here. so any help on this will be appreciated.. ugh!

And on WHY I need one some one or something (glitch or hacker) decided to jump 235 ID's to over 2300 votes. ugh...

It will only happen if you truly believe in it.
Quote Reply
Re: Links Regenerator In reply to
I was really hoping you'd make an honest attempt at this...
Code:
#!/usr/local/bin/perl
require "links.cfg";
require "links.def";
open (OLD, "$db_lib_path/data/links.db") or die "Reason: $!";
open (NEW, ">$db_lib_path/data/new.db") or die "Reason: $!";
while () {
my ($line, @data);
chomp ($line = <OLD>);
last if !$line;
@data = split /\|/, $line;
print "$line\n";
print, foreach @data;
$data[$db_hits] = 0;
print NEW join ('|', @data), "\n";
}
close (NEW);
close (OLD);
print "Content-type: text/plain\n\n";
print "New database saved as new.db. If new.db looks okay, you can safely rename it to links.db.";
--Drew
Quote Reply
Re: Links Regenerator In reply to
Yes i did try to work with the previous one you wrote.. but it didnt take... =op

It will only happen if you truly believe in it.
Quote Reply
Re: Links Regenerator In reply to
Thank you...

You just taught me alot.. it worked out.. but when i ran the script it errored with a DNS not found. even though the script did reset what i wanted it to reset.

Any input there? do i need to ad any end tags to it?

It will only happen if you truly believe in it.
Quote Reply
Re: Links Regenerator In reply to
Don't know how you'd get a DNS not found. More likely you got an internal server error (500) or the content-type was set incorrectly in the script.

(but I don't really know. I've only tested it from command line with a database with 3 fields and 5 records and slightly different code.)

--Drew
Quote Reply
Re: Links Regenerator In reply to
I figured it out... you're getting a "500" because of these two lines:
Code:
print "$line\n";
print, foreach @data;
I was using lots of print statements during testing to make sure everything was read in and modified properly. I forgot to remove those two lines. (had I put the content-type further up in the code, there wouldn't have been any errors)

--Drew
Free, hot camel soup for Links hackers...
http://www.camelsoup.com
Quote Reply
Re: [Heckler] Links Regenerator In reply to
In Reply To:
1) Copy the codes...
2) Paste them into your TEXT editor.
3) Change the configuration variables and codes (e.g., require "links.cfg";).
4) Save the file as regenerator.cgi.
5) Upload the script to your /cgi-bin/links/ folder in your server.
6) Change the permission of the file to 755.
7) Type in the following command:

Code:

perl regenerator.cgi


Basically, junko WROTE you a CGI script! use it!

Regards,

Eliot Lee
rexxx webmaster
Quote Reply
Re: [rexxx] Links Regenerator In reply to
I'm confused... what was the point of that post?

--Philip
Links 2.0 moderator
Quote Reply
Re: [King Junko II] Links Regenerator In reply to
It was late I was trying to state what I was wanting I will redo it.
rexxx webmaster