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.
Mar 27, 1999, 8:17 AM
Veteran / Moderator (3111 posts)
Mar 27, 1999, 8:17 AM
Post #2 of 18
Views: 3642
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:
Votes => [12, 'numer', 10, 10, 1, 0, '^\d+$'],
to read:
Rating => [12, 'numer', 10, 10, 1, 0, '^[\d\.]+$'],
Also change:
to read:
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).]
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).]
Mar 27, 1999, 8:46 AM
User (117 posts)
Mar 27, 1999, 8:46 AM
Post #3 of 18
Views: 3652
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
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
Mar 27, 1999, 1:12 PM
Veteran / Moderator (3111 posts)
Mar 27, 1999, 1:12 PM
Post #4 of 18
Views: 3622
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.
# -------------------------------------------
$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.
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.
Jun 17, 1999, 9:50 PM
User (117 posts)
Jun 17, 1999, 9:50 PM
Post #5 of 18
Views: 3622
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
Jun 19, 1999, 11:52 AM
Veteran / Moderator (3111 posts)
Jun 19, 1999, 11:52 AM
Post #6 of 18
Views: 3614
Try adding this to the top of the script just before the $ENV{'REQUEST_METHOD'} line:
require "$db_lib_path/db_utils.pl";
require "$db_lib_path/links.def";
I hope this helps.
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.
Jun 19, 1999, 1:52 PM
User (117 posts)
Jun 19, 1999, 1:52 PM
Post #7 of 18
Views: 3657
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
_____________________________________
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
Jun 19, 1999, 2:12 PM
Veteran / Moderator (3111 posts)
Jun 19, 1999, 2:12 PM
Post #8 of 18
Views: 3614
Jun 19, 1999, 3:37 PM
Veteran / Moderator (3111 posts)
Jun 19, 1999, 3:37 PM
Post #10 of 18
Views: 3642
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.
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.
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
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
Jul 11, 1999, 8:43 PM
User (318 posts)
Jul 11, 1999, 8:43 PM
Post #13 of 18
Views: 3633
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??
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??
Jul 11, 1999, 9:20 PM
Veteran / Moderator (3111 posts)
Jul 11, 1999, 9:20 PM
Post #14 of 18
Views: 3615
Does the top line of the script point to the correct path for perl on your system?
Also,
That should be:
I hope this helps.
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.
Feb 2, 2000, 11:48 PM
User (318 posts)
Feb 2, 2000, 11:48 PM
Post #15 of 18
Views: 3666
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
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
Feb 2, 2000, 11:54 PM
User (318 posts)
Feb 2, 2000, 11:54 PM
Post #16 of 18
Views: 3653
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
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