Gossamer Forum
Home : Products : Links 2.0 : Customization :

Help! Upgrade Megalinks to Links V2?

Quote Reply
Help! Upgrade Megalinks to Links V2?
I originally installed Megalinks because I needed the rating system and since I knew very little about Links, cgi, etc I opted for Megalinks. Now I want to upgrade to Links V2. None of the other mods of Megalinks were ever used other than rating and I would like to keep those stats if posible. Can anyone give me a step-by-step to do this upgrade with as few heartaches as possible? If I can't maintain the ratings, no prob. Thanks.
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
If all you added to the fields in links.db was the votes and ratings, you do not have much of a problem when upgrading. The only real problem is that, in the original Rate-It mod for Links v1.1 (which Megalinks used), the votes and ratings are in the database in the opposite order that they are in Links v2.0. That is, in Links v2, the fields are Rating followed by Votes, where in Megalinks (v1 Rate It mod), the order is Votes followed by Rating.

To correct this problem, just change the order in the Links v2 links.def file. In the %db_def variable, change:

Quote:
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],

to read:

Quote:
Votes => [11, 'numer', 10, 10, 1, 0, '^\d+$'],
Rating => [12, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],

Also change:

Quote:
$db_votes = 12; $db_rating = 11;

to read:

Quote:
$db_votes = 11; $db_rating = 12;

After uploading your scripts and copying your version 1 links.db to the version 2 admin/data directory, DO NOT run the upgrade.pl script. That script is designed to add 3 fields to the database, two of which you already have.

Instead, run the upgrade_beta.pl script. It will add the "ReceiveMail" field used by Links v2. Just copy it to your data directory, chmod the data directory to 777, and then execute the script. A file, links2.db, will be created by the script in your data directory. Rename links.db to links1.db (or a similar name), and then rename links2.db to links.db. If everything went well, Links v2 should now use the new links.db just fine.

Next, edit your categories.db file to remove any occurance of the word NULL (if any are in there). Don't remove any of the field separators, just the word NULL.

Make sure you also copied your linksid.txt and categoryid.txt files from your version 1 to version 2 data directories.

I hope this helps.

[This message has been edited by Bobsie (edited March 27, 1999).]
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
Mmmmm... a bit confused... what I meant was that all I used was the rating part, everthing else was left intact. I didn't add or delete any fields, just installed Megalinks "outta da box". Here is one entry from my links db (changed the actual info for field names):

16|TITLE|URL|DATE|CATEGORY|DESCRIPTION|NAME|EMAIL|117|No|No|1|10|No|NULL|NULL|No

Just confirming if the instructions above will work with my links.db data?

Thanks again,
Ted Monk
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
In that case, here is a script you can use to convert your Megalinks links.db to the format needed for Links v2.0. Just change the path at the top to point to perl on your system and then put it in your data directory and chmod it to 755. If your data directory is not chmod 777, you should make it so before running this script.

Code:
#!/usr/local/bin/perl
# -------------------------------------------
$ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n");
print "This script will convert a MagaLinks database to the format\n"
print "used by Links Version 2.0.\n\n";
print "\tOpening links.db for input . . .\n";
open (DB, "<links.db") or
print "Unable to open links database 'links.db'. Reason: $!" and exit;
print "\tOpening output file . . .\n";
open (DBOUT, ">links2.db") or
print "Unable to open output database.
Make sure data dir is chmod 777 temporarily.
Reason: $!" and exit;
print "\tProcessing records\n";
while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
s/NULL//g; # Remove 'NULL'
@rec_in = &split_decode($_);
for $i (0 .. 10) {
$rec_out[$i] = $rec_in[$i];
}
$rec_out[11] = $rec_in[12]; # Rating
$rec_out[12] = $rec_in[11]; # Votes
$rec_out[13] = "Yes"; # ReceiveMail
print DBOUT &join_encode(&array_to_hash(0, @rec_out));
}
print "\tDone.\n\n";
close DB;
close DBOUT;
print "Converted MegaLinks database to Links v2.0 format.\n";
print "Database saved it as links2.db.\n";
print "Change permissions back to 755 on the data directory.\n\n";
print "You must rename 'links2.db' to 'links.db before using with Links v2.\n";
print "It is recommend you save the original 'links.db' before renaming.";

I hope this helps.
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
Finally got around to looking at this - I've been down for a while with a few personal issues. Anyway, I changed the path to point to my perl and chmod 755 but am getting an error in telnet that says "aborted due to compilation errors", from the web I get a 505 error. Thanks
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
Try adding this to the top of the script just before the $ENV{'REQUEST_METHOD'} line:

Code:
require "../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";

I hope this helps.
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
Bob, I am now getting this error:
_____________________________________
syntax error at ./megaupgrade.cgi line 10, near "print"
Execution of ./megaupgrade.cgi aborted due to compilation errors.
______________________________________

Line 10 is now:

print "used by Links Version 2.0.\n\n";

Have changed the new first part to full path as you suggested.

Thanks,
Ted



Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
Oops, put a semi-colon ( ; ) at the end of the previous line.

Sorry about that.

[This message has been edited by Bobsie (edited June 19, 1999).]
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
Program can't find db_utils.pl. I can't find that file in either Megalinks or Links V1.1?

Thanks,Ted
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
This script is designed to run in the Links v2 database (admin/data) directory. Just copy your links.db from the Megalinks directory into it and make sure it is chmod 666. Then run the script.

So, if you haven't installed Links v2 yet, that is what needs to be done first since the idea here is to upgrade to Links v2 from Links v1/MagaLinks.
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
That's the ticket! All is working well! Thanks, Bob, you the man!
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
I am wondering if anyone has tried this with
the categories.db file. I am assuming that it will work, but I wanted to hear other people's experiences before trying it.

TIA

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
I am the one who use Megalink2.0,and want to upgrade to link2..I wasn't understand the way to success upgraded link.db to the link2.db..
This is the step I have done If there are any
mistake please tell me.
1.I set up new links that was contained link2 files and directory.
2.I replaced all files in data of item1 with
my old all files in megalink data dir.(this include;categories.db,categories.txt,links.db,linksid.txt,url.bd)
3.Then I upload the cgi called upgrade.cgi to
that data directory and chmod 755
upgrade.cgi as follow:
#!/usr/bin/perl
# -------------------------------------------
require "/links/admin/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";
$ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n");
print "This script will convert a MagaLinks database to the format\n";
print "used by Links Version 2.0.\n\n";
print "\tOpening links.db for input . . .\n";
open (DB, "<links.db") or
print "Unable to open links database 'links.db'. Reason: $!" and exit;
print "\tOpening output file . . .\n";
open (DBOUT, ">links2.db") or
print "Unable to open output database.
Make sure data dir is chmod 777 temporarily.
Reason: $!" and exit;
print "\tProcessing records\n";
while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
s/NULL//g; # Remove 'NULL'
@rec_in = &split_decode($_);
for $i (0 .. 10) {
$rec_out[$i] = $rec_in[$i];
}
$rec_out[11] = $rec_in[12]; # Rating
$rec_out[12] = $rec_in[11]; # Votes
$rec_out[13] = "Yes"; # ReceiveMail
print DBOUT &join_encode(&array_to_hash(0, @rec_out));
}
print "\tDone.\n\n";
close DB;
close DBOUT;
print "Converted MegaLinks database to Links v2.0 format.\n";
print "Database saved it as links2.db.\n";
print "Change permissions back to 755 on the data directory.\n\n";
print "You must rename 'links2.db' to 'links.db before using with Links v2.\n";
print "It is recommend you save the original 'links.db' before renaming.";

I called upgrade.cgi the error message said
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, you@your.address and inform them of the time the error occurred, and anything you might have done that may have
caused the error.

Additionally, a 404 File Not Found error was encountered while trying to use an ErrorDocument to handle the request.

What's wrong??
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
Does the top line of the script point to the correct path for perl on your system?

Also,

Quote:
require "/links/admin/links.cfg"; # Change this to full path to links.cfg if you have problems.

That should be:

Quote:
require "../links.cfg"; # Change this to full path to links.cfg if you have problems.

I hope this helps.
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
          I have success modified to link2.0 already.But This is another one of my Megalink2.1 db ,people directory,wanted to upgrade to link2.0.
I want some1 to see if any mistake on my upgrade.pl...
#!/usr/bin/perl
# -------------------------------------------
require "/home/htdocs/Whitepages/admin/links.cfg"; # Change this to full path to links.cfg if you have problems.
require "$db_lib_path/db_utils.pl";


and this is in my link.def
# Database Definition: LINKS
# --------------------------------------------------------
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 0, '', ''],
URL => [2, 'alpha', 40, 75, 0, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
Password => [14, 'alpha', 10, 10, 1, '', ''],
Nickname => [15, 'alpha', 40, 75, 0, '', ''],
Icq => [16, 'numer', 5, 20, 0, '', ''],
Sex => [17, 'alpha', 0, 20, 0, '', ''],
Birth => [18, 'alpha', 5, 75, 0, '', ''],
School => [19, 'alpha', 5, 75, 0, '', ''],
Organisation => [20, 'alpha', 5, 75, 0, '', ''],
Hobbies => [21, 'alpha', 5, 75, 0, '', ''],
'Alt Email' => [22, 'alpha', 5, 75, 0, '', '']
);
# Database file to use -- defined in links.cfg.
$db_file_name = $db_links_name;
# Counter file to use -- defined in links.cfg.
$db_id_file_name = $db_links_id_file_name;
# The column name for the database key.
$db_key = 'ID';
# Database delimeter.
$db_delim = '|';
# Title used in admin output.
$html_title = '76 Database';
$html_object = 'People';

# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 8; $db_isnew = 9; $db_ispop = 10;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 12; $db_rating = 11; $db_mail = 13;
$db_password = 14; $db_nickname = 15;
$db_icq = 16; $db_sex = 17;
$db_birth = 18; $db_school = 19;
$db_organisation = 20; $db_hobbies = 21; $db_alt_email = 22;
require "$db_lib_path/links.def";
$ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n");
print "This script will convert a MagaLinks database to the format\n";
print "used by Links Version 2.0.\n\n";
print "\tOpening links.db for input . . .\n";
open (DB, "<links.db") or
print "Unable to open links database 'links.db'. Reason: $!" and exit;
print "\tOpening output file . . .\n";
open (DBOUT, ">links2.db") or
print "Unable to open output database.
Make sure data dir is chmod 777 temporarily.
Reason: $!" and exit;
print "\tProcessing records\n";
while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
s/NULL//g; # Remove 'NULL'
@rec_in = &split_decode($_);
for $i (0 .. 10) {
$rec_out[$i] = $rec_in[$i];
}
$rec_out[11] = $rec_in[12]; # Rating
$rec_out[12] = $rec_in[11]; # Votes
$rec_out[13] = "Yes"; # ReceiveMail
$rec_out[17] = $rec_in[14]; # pass
$rec_out[18] = $rec_in[15]; # nickname
$rec_out[19] = $rec_in[16]; #icq
$rec_out[20] = $rec_in[17]; # sex
$rec_out[21] = $rec_in[18]; # birth
$rec_out[22] = $rec_in[19]; # school
$rec_out[23] = $rec_in[20]; #organization
$rec_out[24] = $rec_in[21]; # hobby
$rec_out[25] = $rec_in[22]; # altemail
print DBOUT &join_encode(&array_to_hash(0, @rec_out));
}
print "\tDone.\n\n";
close DB;
close DBOUT;
print "Converted MegaLinks database to Links v2.0 format.\n";
print "Database saved it as links2.db.\n";
print "Change permissions back to 755 on the data directory.\n\n";
print "You must rename 'links2.db' to 'links.db before using with Links v2.\n";
print "It is recommend you save the original 'links.db' before renaming.";


------------------
okbee
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
 Sorry FOR MY POST ABOVE The cod eabove is incorrect..please see below.....

I have success modified to link2.0 already.But This is another one of my Megalink2.1 db ,people directory,wanted to upgrade to link2.0.
I want some1 to see if any mistake on my upgrade.pl...
#!/usr/bin/perl
# -------------------------------------------
require "/home/htdocs/Whitepages/admin/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";
$ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n");
print "This script will convert a MagaLinks database to the format\n";
print "used by Links Version 2.0.\n\n";
print "\tOpening links.db for input . . .\n";
open (DB, "<links.db") or
print "Unable to open links database 'links.db'. Reason: $!" and exit;
print "\tOpening output file . . .\n";
open (DBOUT, ">links2.db") or
print "Unable to open output database.
Make sure data dir is chmod 777 temporarily.
Reason: $!" and exit;
print "\tProcessing records\n";
while (<DB> ) {
/^#/ and next LINE; # Skip comment Lines.
/^\s*$/ and next LINE; # Skip blank lines.
chomp; # Remove trailing new line.
s/NULL//g; # Remove 'NULL'
@rec_in = &split_decode($_);
for $i (0 .. 10) {
$rec_out[$i] = $rec_in[$i];
}
$rec_out[11] = $rec_in[12]; # Rating
$rec_out[12] = $rec_in[11]; # Votes
$rec_out[13] = "Yes"; # ReceiveMail
$rec_out[17] = $rec_in[14]; # pass
$rec_out[18] = $rec_in[15]; # nickname
$rec_out[19] = $rec_in[16]; #icq
$rec_out[20] = $rec_in[17]; # sex
$rec_out[21] = $rec_in[18]; # birth
$rec_out[22] = $rec_in[19]; # school
$rec_out[23] = $rec_in[20]; #organization
$rec_out[24] = $rec_in[21]; # hobby
$rec_out[25] = $rec_in[22]; # altemail
print DBOUT &join_encode(&array_to_hash(0, @rec_out));
}
print "\tDone.\n\n";
close DB;
close DBOUT;
print "Converted MegaLinks database to Links v2.0 format.\n";
print "Database saved it as links2.db.\n";
print "Change permissions back to 755 on the data directory.\n\n";
print "You must rename 'links2.db' to 'links.db before using with Links v2.\n";
print "It is recommend you save the original 'links.db' before renaming.";



and this is in my link.def
# Database Definition: LINKS
# --------------------------------------------------------
# Definition of your database file.
%db_def = (
ID => [0, 'numer', 5, 8, 1, '', ''],
Title => [1, 'alpha', 40, 75, 0, '', ''],
URL => [2, 'alpha', 40, 75, 0, 'http://', '^http|news|mailto|ftp'],
Date => [3, 'date', 15, 15, 1, \&get_date, ''],
Category => [4, 'alpha', 0, 150, 1, '', ''],
Description => [5, 'alpha', '40x3', 500, 0, '', ''],
'Contact Name' => [6, 'alpha', 40, 75, 1, '', ''],
'Contact Email' => [7, 'alpha', 40, 75, 1, '', '.+@.+\..+'],
Hits => [8, 'numer', 10, 10, 1, '0', '\d+'],
isNew => [9, 'alpha', 0, 5, 0, 'No', ''],
isPopular => [10, 'alpha', 0, 5, 0, 'No', ''],
Rating => [11, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
ReceiveMail => [13, 'alpha', 10, 10, 1, 'Yes', 'No|Yes'],
Password => [14, 'alpha', 10, 10, 1, '', ''],
Nickname => [15, 'alpha', 40, 75, 0, '', ''],
Icq => [16, 'numer', 5, 20, 0, '', ''],
Sex => [17, 'alpha', 0, 20, 0, '', ''],
Birth => [18, 'alpha', 5, 75, 0, '', ''],
School => [19, 'alpha', 5, 75, 0, '', ''],
Organisation => [20, 'alpha', 5, 75, 0, '', ''],
Hobbies => [21, 'alpha', 5, 75, 0, '', ''],
'Alt Email' => [22, 'alpha', 5, 75, 0, '', '']
);
# Database file to use -- defined in links.cfg.
$db_file_name = $db_links_name;
# Counter file to use -- defined in links.cfg.
$db_id_file_name = $db_links_id_file_name;
# The column name for the database key.
$db_key = 'ID';
# Database delimeter.
$db_delim = '|';
# Title used in admin output.
$html_title = '76 Database';
$html_object = 'People';

# Field Number of some important fields. The number is from %db_def above
# where the first field equals 0.
$db_category = 4; $db_modified = 3; $db_url = 2;
$db_hits = 8; $db_isnew = 9; $db_ispop = 10;
$db_contact_name = 6; $db_contact_email = 7; $db_title = 1;
$db_votes = 12; $db_rating = 11; $db_mail = 13;
$db_password = 14; $db_nickname = 15;
$db_icq = 16; $db_sex = 17;
$db_birth = 18; $db_school = 19;
$db_organisation = 20; $db_hobbies = 21; $db_alt_email = 22;



------------------
okbee
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
you can use the EDIT function to fix your post rather than wasting space by posting the same stuff twice... Smile
Quote Reply
Re: Help! Upgrade Megalinks to Links V2? In reply to
Really sorry ,I dont know how to edit ..