Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Deleting Old Links

Quote Reply
Deleting Old Links
Is there a way to delete links/sites that are older than a certain age, like 365 days or older gets deleted?
Post deleted by MJB In reply to
Quote Reply
Re: [Spacemanspiff] Deleting Old Links In reply to
If you want to automate it, you'll have to write some code to do it. If you just want to do it as a one time deal, you can search for the links using the database editor (Database => Editor (on the left sidebar) => Links, Delete => and enter the Add_Date (Less than) for the search.

Adrian

Last edited by:

brewt: May 19, 2006, 6:47 PM
Quote Reply
Re: [brewt] Deleting Old Links In reply to
I had originally thought I'd automate it, but an occasional manual delete will work just as well.

Thanks
Quote Reply
Re: [brewt] Deleting Old Links In reply to
In Reply To:
If you just want to do it as a one time deal, you can search for the links using the database editor (Database => Editor (on the left sidebar) => Links, Delete => and enter the Add_Date (Less than) for the search.

Re my deleted post above. I tried this and it returned nearly all my links.

Links / Delete / Add Date: 2005-05-19 / Less Than, Greater Than.

Unsure
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!
Quote Reply
Re: [Andy] Deleting Old Links In reply to
That's awesome, Andy. Thanks. I'll let you know how it works out.