Hi,
Give this script a go (upload to your admin folder, via FTP - and then run via SSH/Telnet, via the commands I will provide);
Code:
#!/usr/local/bin/perl
use strict;
use lib './';
use GT::Base;
use GT::Plugins qw/STOP CONTINUE/;
use Links qw/$CFG $IN $DB/;
use CGI::Carp qw(fatalsToBrowser);
use Data::Dumper;
use GT::SQL::Condition;
Links::init('./');
my $sth = $DB->table('Links')->select( ['ID','URL'], GT::SQL::Condition->new('isValidated','=','Yes','URL','LIKE','http://%') ) || die $GT::SQL::error;
while (my $link = $sth->fetchrow_hashref) {
if (length($link->{URL}) <= 7) { next; } # not valid one
if ($link->{URL} !~ m/^http:\/\/www\.(.*?)/i) {
if (check_if_is_a_sub_domain($link->{URL}) > 0) {
print qq|--- $link->{URL} seems to be a subdomain - not doing ---- \n|;
} else {
$link->{URL} =~ s|\Qhttp://\E|http://www.$1|sig;
print "New URL: (ID: $link->{ID}) $link->{URL} \n";
# $DB->table('Links')->update( { URL => $link->{URL} }, { ID => $link->{ID} } ) || die $GT::SQL::error; }
}
}
sub check_if_is_a_sub_domain {
my $url = $_[0];
my @cut = split /\//, $url;
my $domain = $cut[2];
my @tmp2 = split /\./, $domain;
if ($#tmp2 > 1) {
#print qq|BLA BLA: $#tmp2 for $domain, $url \n|;
return 1;
}
return 0;
}
Uncomment the bit in
red when you are happy it will do what you want :)
Run via SSH/Telnet with;
cd /path/to/your/admin/
perl file.cgi
That should be it :)
Hope that helps.
Cheers
Andy (mod)
andy@ultranerds.co.uk
IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work! Want to give me something back for my help? Please see my
Amazon Wish List GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500) Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin |
Pre-Made Template Sets |
FREE GLinks Plugins! Compare our different Plugin packages *new* Free CSS Templates