Argh..this is really annoying me! I'm using the following code;
# -------------------------------------------------------------------
# This subroutine will get called whenever the user clicks
# on 'Redo Checks' in the admin menu. Remember, you need to print
# your own content-type headers; you should use
#
print $IN->header();
my $opts = Links::Plugins->get_plugin_user_cfg('Recip_Link');
my ($db_con, $error_show, $exists, $html_page, $got);
# grab the URL that we need to find in the page...
my $user_url = $opts->{'URL_To_Check_For'};
my $table = $DB->table('Links');
$table->select_options ('ORDER BY ID DESC');
my $sth = $table->select;
while (my $hit = $sth->fetchrow_hashref) {
# do the checks for each link here!
my @page = get($hit->{URL});
# see if @page holds anything...if not, then we didnt get the page
foreach (@page) {
$got = 1; last;
}
# if $got is nul, then we didn't get the page! So report this...
if (!$got) { print "Could not connect to $hit->{URL} <BR>"; next; }
# gulp the whole page from the array...
foreach (@page) { $html_page .= $_; }
unless ($html_page =~ /$user_url/)
{
my $report = "yes";
# set their recip status to 'no', if no link was found....
my $table = $DB->table ('Links');
my $result = $table->update ( { Has_Priority => "0"}, { URL => $hit->{'URL'} }) or die $GT::SQL::error;
# show an error if the page could not be reached...
print "$report - <font color=blue>$hit->{URL}</font> - Could not find a reciprical link on this page. Setting to NULL in database...<BR>";
} else {
# update the database if a recip link exists...
my $table = $DB->table ('Links');
my $result = $table->update ( { Has_Priority => "1"}, { URL => $hit->{'URL'} }) or die $GT::SQL::error;
# show them a message...
print "<font color=red>$hit->{URL}</font> - Link was found...setting database to 'yes'<BR>";
}
} # end the while....
print "<BR><BR> <font color=red>COMPLETE!</font>";
}
The idea of this code, is that it will go through the entire database, grab the links URL, stick all the HTML in a variable, and then check if that variable exists on the page. The URL to check for is grabbed by $opts. The problem I am having, is that it seems to be verifying almost everything as a recip link page, although, when visiting it, this is not true. I'm completly stumped as to why this is happening
At first I thought it was the fact that the URL to check for was non-existant, but I tried printing it at the beginning of the sub, and it shows fine
Any ideas?
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!
Code:
sub redo_checks { # -------------------------------------------------------------------
# This subroutine will get called whenever the user clicks
# on 'Redo Checks' in the admin menu. Remember, you need to print
# your own content-type headers; you should use
#
print $IN->header();
my $opts = Links::Plugins->get_plugin_user_cfg('Recip_Link');
my ($db_con, $error_show, $exists, $html_page, $got);
# grab the URL that we need to find in the page...
my $user_url = $opts->{'URL_To_Check_For'};
my $table = $DB->table('Links');
$table->select_options ('ORDER BY ID DESC');
my $sth = $table->select;
while (my $hit = $sth->fetchrow_hashref) {
# do the checks for each link here!
my @page = get($hit->{URL});
# see if @page holds anything...if not, then we didnt get the page
foreach (@page) {
$got = 1; last;
}
# if $got is nul, then we didn't get the page! So report this...
if (!$got) { print "Could not connect to $hit->{URL} <BR>"; next; }
# gulp the whole page from the array...
foreach (@page) { $html_page .= $_; }
unless ($html_page =~ /$user_url/)
{
my $report = "yes";
# set their recip status to 'no', if no link was found....
my $table = $DB->table ('Links');
my $result = $table->update ( { Has_Priority => "0"}, { URL => $hit->{'URL'} }) or die $GT::SQL::error;
# show an error if the page could not be reached...
print "$report - <font color=blue>$hit->{URL}</font> - Could not find a reciprical link on this page. Setting to NULL in database...<BR>";
} else {
# update the database if a recip link exists...
my $table = $DB->table ('Links');
my $result = $table->update ( { Has_Priority => "1"}, { URL => $hit->{'URL'} }) or die $GT::SQL::error;
# show them a message...
print "<font color=red>$hit->{URL}</font> - Link was found...setting database to 'yes'<BR>";
}
} # end the while....
print "<BR><BR> <font color=red>COMPLETE!</font>";
}
The idea of this code, is that it will go through the entire database, grab the links URL, stick all the HTML in a variable, and then check if that variable exists on the page. The URL to check for is grabbed by $opts. The problem I am having, is that it seems to be verifying almost everything as a recip link page, although, when visiting it, this is not true. I'm completly stumped as to why this is happening

At first I thought it was the fact that the URL to check for was non-existant, but I tried printing it at the beginning of the sub, and it shows fine

Any ideas?
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!