Based on David Schuster improvement patch.
For David:
- To send the output into an HTML file, there is no need to add a
paramater to this script, just redirect to a file:
check-url --html --host-prot=http://koha-pro.mylib.org \\
> /usr/local/koha/koha-tmpl/badurls.html
- If you want as a result a table with alternate rows, use CSS and
JavaScript. For example, with jQuery (found with google):
<style type="text/css">
table {width:400px; border:1px solid blue;}
.oddrow {background-color:#E5E5E5;}
</style>
<script type="text/javascript"
src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
$(function(){
$("table.tiger-stripe tr:even").addClass("oddrow");
});
Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
my $class = shift;
$self->{ user_agent } = new LWP::UserAgent;
my $class = shift;
$self->{ user_agent } = new LWP::UserAgent;
+ $self->{ bad_url } = { };
bless $self, $class;
return $self;
bless $self, $class;
return $self;
my $biblionumber = shift;
my $uagent = $self->{ user_agent };
my $host = $self->{ host_default };
my $biblionumber = shift;
my $uagent = $self->{ user_agent };
my $host = $self->{ host_default };
+ my $bad_url = $self->{ bad_url };
my $record = GetMarcBiblio( $biblionumber );
return unless $record->field('856');
my $record = GetMarcBiblio( $biblionumber );
return unless $record->field('856');
next unless $url;
$url = "$host/$url" unless $url =~ /^http/;
my $check = { url => $url };
next unless $url;
$url = "$host/$url" unless $url =~ /^http/;
my $check = { url => $url };
- my $req = HTTP::Request->new( GET => $url );
- my $res = $uagent->request( $req, sub { die }, 1 );
- if ( $res->is_success ) {
+ if ( $bad_url->{ $url } ) {
$check->{ is_success } = 1;
$check->{ is_success } = 1;
- $check->{ status } = 'ok';
+ $check->{ status } = '500 Site already checked';
- $check->{ is_success } = 0;
- $check->{ status } = $res->status_line;
+ my $req = HTTP::Request->new( GET => $url );
+ my $res = $uagent->request( $req, sub { die }, 1 );
+ if ( $res->is_success ) {
+ $check->{ is_success } = 1;
+ $check->{ status } = 'ok';
+ }
+ else {
+ $check->{ is_success } = 0;
+ $check->{ status } = $res->status_line;
+ $bad_url->{ $url } = 1;
+ }
my $sth = $dbh->prepare(
"SELECT biblionumber FROM biblioitems WHERE url <> ''" );
$sth->execute;
my $sth = $dbh->prepare(
"SELECT biblionumber FROM biblioitems WHERE url <> ''" );
$sth->execute;
- print "<html>\n<body>\n<table>\n" if $html;
+ if ( $html ) {
+ print <<EOS;
+<html>
+<body>
+<table>
+EOS
+ }
while ( my ($biblionumber) = $sth->fetchrow ) {
my $result = $checker->check_biblio( $biblionumber );
next unless $result; # No URL
while ( my ($biblionumber) = $sth->fetchrow ) {
my $result = $checker->check_biblio( $biblionumber );
next unless $result; # No URL