#!/usr/bin/perl # ------------------------------------------- require "/path_to/cgi-bin/links/admin/default.cfg"; # Change this to the path to your default.cfg require "/path_to/db.cgi"; $ENV{'REQUEST_METHOD'} and (print "Content-type: text/plain\n\n"); $db_links_name = "/path_to/default.db"; # PATH to default database. open (DB, "$db_links_name") or print "Unable to open links database 'default.db'. Reason: $!" and exit; open (DBOUT, ">$db_links_name.bak") or print "Unable to open output database. Reason: $!" and exit; LINE: while ( ) { /^#/ and next LINE; # Skip comment Lines. /^\s*$/ and next LINE; # Skip blank lines. chomp; # Remove trailing new line. @RecOut = &split_decode($_); # change the 10 to the appropriate field number in db_def section of # the default.cfg file. $RecOut[10]++; # # print DBOUT &join_encode(&array_to_hash(0, @RecOut)); } close DB; close DBOUT; print "\nLinks database now has reviews field has been reset.\n\n"; if (-s "$db_links_name.bak" > 0) { if (! rename ("$db_links_name.bak", $db_links_name)) { print "\tCouldn't rename! Had to copy. Strange: $!\n"; open (DBTMP, ">$db_links_name") or &cgierr ("unable to open links database: $db_links_name. Reason: $!"); open (DB, "$db_links_name.bak") or &cgierr ("unable to open temp links database: $db_links_name.bak. Reason: $!"); while () { print DBTMP; } close DB; close DBTMP; } } else { &cgierr ("Error building! default database is 0 bytes!"); }