Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Re: [Spacemanspiff] Deleting Old Links

Quote Reply
Re: [Spacemanspiff] Deleting Old Links In reply to
Hi,

Totally untested, but *should* work =)

Make a new script, in your /admin folder. Call it something like delete_old.cgi. Put the following in it;

Code:
#!/usr/bin/perl -w

use strict;
use lib '/full/path/to/your/admin';
use GT::Base;
use Links qw/$CFG $IN $DB/;
use CGI::Carp qw(fatalsToBrowser);
use Data::Dumper;
use GT::Date;

local $SIG{__DIE__} = \&Links::fatal;

Links::init('/full/path/to/your/admin');
Links::init_user();


my $days_diff = 365;




my $current = GT::Date::date_get();
my $date_to_del_from = GT::Date::date_sub($current,$days_diff);

for (my $i = 0; $i < 7; $i++) {
my $date_to_del = GT::Date::date_sub($date_to_del_from,$i);
print "DELETING Link with Add_Date on $date_to_del \n":
#$DB->table('Links')->delete( { Add_Date => $date_to_del } ) || die $GT::SQL::error;
}

BE SURE TO EDIT THE "/full/path/to/your/admin" part, so it reflects you admin folder ;))

Then, run via SSH/Telnet, with;

cd /path/to/your/admin
perl delete_old.cgi

You'll notice, that I've commented out this line;

#$DB->table('Links')->delete( { Add_Date => $date_to_del } ) || die $GT::SQL::error;

Once you are happy its getting the dates you want to delete, then you can uncomment this, and they should then get deleted the next time you run it =)

Hope that helps

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Subject Author Views Date
Thread Deleting Old Links Spacemanspiff 2870 May 19, 2006, 3:15 PM
Post Post deleted by MJB
MJB 2739 May 19, 2006, 5:10 PM
Thread Re: [Spacemanspiff] Deleting Old Links
brewt 2758 May 19, 2006, 6:47 PM
Post Re: [brewt] Deleting Old Links
Spacemanspiff 2763 May 20, 2006, 3:31 AM
Post Re: [brewt] Deleting Old Links
MJB 2755 May 20, 2006, 5:01 AM
Thread Re: [Spacemanspiff] Deleting Old Links
Andy 2736 May 20, 2006, 8:18 AM
Post Re: [Andy] Deleting Old Links
Spacemanspiff 2718 May 23, 2006, 4:52 AM