#!/usr/bin/perl # ------------------------------------------- ## this mod from http://gossamer-threads.com/perl/gforum/gforum.cgi?do=ubb&ubb=001090:Forum3 #You must EDIT YOUR links.def script BEFORE entering these variable and running this script! $field_default = "No"; #Put the default value of the new field here. Leave Blank for no default. $new_field = "16"; #Put the new field number here. $total_fields = "20"; #Put the last field number here. #Change these value to match your settings--FULL PATH! require "/.../cgi-bin/links/admin/db_utils.pl"; require "/.../cgi-bin/links/admin/links.def"; #You shouldn't have to edit below this line #------------------------------------------ $nfm1 = $new_field - 1; $ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n"); open (DB, "links2.db") or print "Unable to open output database. Make sure data dir is chmod 777 temporarily. Reason: $!" and exit; print "\n\n\tProcessing records\n"; while ( ) { (/^#/) and next LINE; # Skip comment Lines. (/^\s*$/) and next LINE; # Skip blank lines. chomp; # Remove trailing new line. @rec_in = &split_decode($_); # Copy ID, Title, URL, Date and Category for $i (0 .. $nfm1) { $rec_out[$i] = $rec_in[$i]; } # Add New Field $rec_out[$new_field] = "$field_default"; # Copy the rest of old links.db to new links2.db for $i ($new_field .. $total_fields) { $rec_out[$i + 1] = $rec_in[$i]; } print DBOUT &join_encode(&array_to_hash(0, @rec_out)); } print "\tDone.\n\n"; close DB; close DBOUT; 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.\n\n";