EPrints/Hit.pm

filter: Statementstmt 80.6% 133 / 165 Branchbran 44.2% 23 / 52 Conditioncond 34.4% 10 / 29 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 79.4% 31 / 39 Podpod 69.2% 9 / 13 totaltotal 65.1% 206 / 316 CC 36 SCAR 14.9
CC
36
Cov
67%
to_string
12.0
addr2institution
11.8
load_country_db
6.8
CRAP 4.5
« EPrints/Mapping/EPrints.pm ↑ Summary EPrints/Filter/Session.pm »
1 package Logfile::EPrints::Hit;
2  
3 =pod
4  
5 Logfile::EPrints::Hit - Generic 'hit' object
6  
7 =head1 DESCRIPTION
8  
9 This object represents a single entry in a log file and doesn't proscribe any particular schema.
10  
11 This uses the 'AUTOLOAD' mechanism to allow any variable to be defined as a method.
12  
13 'Hit' objects are passed between filters that may add additional functionality (e.g. by subclassing the hit object).
14  
15 =head1 SYNOPSIS
16  
17 use Logfile::EPrints::Hit;
18  
19 my $hit = Logfile::EPrints::Hit->new;
20 $hit->date( '2006-05-01 23:10:05' );
21  
22 print $hit->date;
23  
24 =head1 CLASS METHODS
25  
26 =over 4
27  
28 =item Logfile::EPrints::Hit::Combined::load_country_db( FILENAME [, FLAGS ] )
29  
30 Load the Maxmind country database located at FILENAME.
31  
32 =item Logfile::EPrints::Hit::Combined::load_org_db( FILENAME [, FLAGS ] )
33  
34 Load the Maxmind organisation database located at FILENAME.
35  
36 =cut
37  
38 =back
39  
40 =head1 METHODS
41  
42 =over 4
43  
44 =item address()
45  
46 IP address (or hostname if IP address could not be found).
47  
48 =item hostname()
49  
50 Hostname (undef if the address is an IP without a reverse DNS entry).
51  
52 =item date()
53  
54 Apache formatted date/time.
55  
56 =item datetime()
57  
58 Date/time formatted as yyyymmddHHMMSS.
59  
60 =item userid_identd()
61  
62 =item identd()
63  
64 =item request()
65  
66 Request string.
67  
68 =item code()
69  
70 HTTP server code.
71  
72 =item size()
73  
74 HTTP server response size.
75  
76 =item referrer()
77  
78 User agent referrer.
79  
80 =item agent()
81  
82 User agent string.
83  
84 =item method()
85  
86 Request method (GET, HEAD etc.).
87  
88 =item page()
89  
90 Requested page - probably won't include the virtual host!
91  
92 =item version()
93  
94 HTTP version requested (HTTP/1.1 etc).
95  
96 =item country()
97  
98 Country that the IP is probably in, must call load_country_db first.
99  
100 =item organisation()
101  
102 Organisation that the IP belongs to, must call load_org_db first.
103  
104 =item institution()
105  
106 Returns the title from the homepage()
107  
108 =item homepage()
109  
110 Returns the homepage for the user's network.
111  
112 =back
113  
114 =cut
115  
116 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
117  
118 6 ▶use POSIX qw/ strftime /;
Subroutine BEGIN: called CC=1 SCAR=0.0
119 6 ▶use Date::Parse;
Subroutine BEGIN: called CC=1 SCAR=0.0
120 6 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
121  
122 6 ▶use vars qw( $AUTOLOAD %INST_CACHE );
Subroutine BEGIN: called CC=1 SCAR=0.0
123  
124 6 ▶use vars qw( $GEO_IP_CLASS $ORG_DB $COUNTRY_DB );
Subroutine BEGIN: called CC=1 SCAR=0.0
125 6 for(qw( Geo::IP Geo::IP::PurePerl ))
126 {
127 0 ▶ eval "use $_";
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine BEGIN: called CC=1 SCAR=0.2
128 12 ▶ unless($@)
Branch: 1 branch
BranchTrueFalseTotal
unless ($@) 6 6 12
129 {
130 6 $GEO_IP_CLASS = $_;
131 6 last;
132 }
133 }
134  
135 6 ▶use vars qw( $UA );
Subroutine BEGIN: called CC=1 SCAR=0.0
136 6 require LWP::UserAgent;
137 6 $UA = LWP::UserAgent->new();
138 6 $UA->timeout(5);
139  
140 sub new
141 1 ▶{
Subroutine new: called CC=2 SCAR=8.1
Pod undocumented
142 1 my( $class, %args ) = @_;
143 1 ▶ return bless \%args, ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
144 }
145  
146 7636 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: called CC=3 SCAR=11.3
147 7636 $AUTOLOAD =~ s/.*:://;
148 7636 ▶ return if $AUTOLOAD =~ /^[A-Z]/;
Branch: 1 branch
BranchTrueFalseTotal
if $Logfile::EPrints::Hit::AUTOLOAD =~ /^[A-Z]/ 2260 5376 7636
149 5376 my $self = shift;
150 return ref($self->{$AUTOLOAD}) ?
151 0 &{$self->{$AUTOLOAD}}($self,@_) :
152 5376 ▶ $self->{$AUTOLOAD};
Branch: 1 branch
BranchTrueFalseTotal
ref $self->{$Logfile::EPrints::Hit::AUTOLOAD} ? : 0 5376 5376
153 }
154  
155 # should be to_string in Perl
156 6 *toString = \&to_string;
157 0 ▶sub to_string {
Subroutine to_string: not called CC=3 SCAR=24.8
Pod undocumented
158 0 my $self = shift;
159 0 my $str = "===Parsed Reference===\n";
160 0 ▶ while(my ($k,$v) = each %$self) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$self) 0 0 0
161 0 ▶ $str .= "$k=".($v||'n/a')."\n";
Condition0%0/2
$v || 'n/a'
l!l
00
MC/DC0%0/1
$v || 'n/a'
$v
Truth table0%0/2
A
A= $v
Aresult
11
00
162 }
163 0 $str;
164 }
165  
166 sub load_country_db
167 0 ▶{
Subroutine load_country_db: not called CC=3 SCAR=19.2
Pod documented
168 0 my( $filename, $flags ) = @_;
169  
170 0 ▶ Carp::croak "Requires Geo::IP or Geo::IP::PurePerl" unless $GEO_IP_CLASS;
Branch: 1 branch
BranchTrueFalseTotal
unless $Logfile::EPrints::Hit::GEO_IP_CLASS 0 0 0
171 0 ▶ Carp::croak "Missing filename argument" unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
172  
173 0 $COUNTRY_DB = $GEO_IP_CLASS->open( @_ );
174  
175 6 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
176 0 *country = \&_country;
177 }
178  
179 sub load_org_db
180 0 ▶{
Subroutine load_org_db: not called CC=3 SCAR=19.2
Pod documented
181 0 my( $filename, $flags ) = @_;
182  
183 0 ▶ Carp::croak "Requires Geo::IP or Geo::IP::PurePerl" unless $GEO_IP_CLASS;
Branch: 1 branch
BranchTrueFalseTotal
unless $Logfile::EPrints::Hit::GEO_IP_CLASS 0 0 0
184 0 ▶ Carp::croak "Missing filename argument" unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
185  
186 0 $ORG_DB = $GEO_IP_CLASS->open( @_ );
187  
188 6 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
189 0 *organisation = \&_organisation;
190 }
191  
192 sub _getipbyname
193 1 ▶{
Subroutine _getipbyname: called CC=2 SCAR=7.2
194 1 my( $name, $aliases, $addrtype, $length, @addrs ) = gethostbyname($_[0]);
195 1 ▶ return defined($addrs[0]) ? inet_ntoa($addrs[0]) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $addrs[0] ? : 1 0 1
196 }
197  
198 sub address
199 1203 ▶{
Subroutine address: called CC=3 SCAR=13.1
Pod documented
200 1203 ▶ $_[0]->{address} ||= _getipbyname( $_[0]->{hostname} ) || $_[0]->{hostname};
Condition50%3/6
$_[0]{"address"} ||= _getipbyname($_[0]{"hostname"}) || $_[0]{"hostname"}
l!l&&r!l&&!r
120210
_getipbyname($_[0]{'hostname'}) || $_[0]{'hostname'}
l!l&&r!l&&!r
100
MC/DC0%0/3
$_[0]{"address"} ||= _getipbyname($_[0]{"hostname"}) || $_[0]{"hostname"}
$_[0]{"address"} _getipbyname($_[0]{'hostname'}) $_[0]{'hostname'}
Truth table0%0/4
A ||= B || C
A= $_[0]{"address"}B= _getipbyname($_[0]{'hostname'})C= $_[0]{'hostname'}
ABCresult
1XX1
01X1
0011
0000
201 }
202  
203 sub country
204 0 ▶{
Subroutine country: not called CC=1 SCAR=6.9
Pod documented
205 0 Carp::croak "You must call ".__PACKAGE__."::load_country_db first";
206 }
207  
208 sub _country
209 0 ▶{
Subroutine _country: not called CC=2 SCAR=17.9
210 0 ▶ $_[0]->{country} ||= $COUNTRY_DB->country_code_by_addr($_[0]->address);
Condition0%0/3
$_[0]{"country"} ||= $Logfile::EPrints::Hit::COUNTRY_DB->country_code_by_addr($_[0]->address)
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0]{"country"} ||= $Logfile::EPrints::Hit::COUNTRY_DB->country_code_by_addr($_[0]->address)
$_[0]{"country"} $Logfile::EPrints::Hit::COUNTRY_DB->country_code_by_addr($_[0]->address)
Truth table0%0/3
A ||= B
A= $_[0]{"country"}B= $Logfile::EPrints::Hit::COUNTRY_DB->country_code_by_addr($_[0]->address)
ABresult
1X1
011
000
211 }
212  
213 sub organisation
214 0 ▶{
Subroutine organisation: not called CC=1 SCAR=6.9
Pod documented
215 0 Carp::croak "You must call ".__PACKAGE__."::load_org_db first";
216 }
217  
218 sub _organisation
219 0 ▶{
Subroutine _organisation: not called CC=2 SCAR=17.9
220 0 ▶ $_[0]->{organisation} ||= Encode::decode('iso-8859-1', $ORG_DB->org_by_name($_[0]->address));
Condition0%0/3
$_[0]{"organisation"} ||= &Encode::decode("iso-8859-1", $Logfile::EPrints::Hit::ORG_DB->org_by_name($_[0]->address))
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[0]{"organisation"} ||= &Encode::decode("iso-8859-1", $Logfile::EPrints::Hit::ORG_DB->org_by_name($_[0]->address))
$_[0]{"organisation"} &Encode::decode("iso-8859-1", $Logfile::EPrints::Hit::ORG_DB->org_by_name($_[0]->address))
Truth table0%0/3
A ||= B
A= $_[0]{"organisation"}B= &Encode::decode("iso-8859-1", $Logfile::EPrints::Hit::ORG_DB->org_by_name($_[0]->address))
ABresult
1X1
011
000
221 }
222  
223 sub hostname
224 4 ▶{
Subroutine hostname: called CC=2 SCAR=7.2
Pod documented
225 4 ▶ $_[0]->{hostname} ||= gethostbyaddr(inet_aton($_[0]->address), AF_INET);
Condition66%2/3
$_[0]{"hostname"} ||= gethostbyaddr(inet_aton($_[0]->address), 2)
l!l&&r!l&&!r
310
MC/DC0%0/2
$_[0]{"hostname"} ||= gethostbyaddr(inet_aton($_[0]->address), 2)
$_[0]{"hostname"} gethostbyaddr(inet_aton($_[0]->address), 2)
Truth table66%2/3
A ||= B
A= $_[0]{"hostname"}B= gethostbyaddr(inet_aton($_[0]->address), 2)
ABresult
1X1
011
000
226 }
227  
228 sub utime
229 124 ▶{
Subroutine utime: called CC=3 SCAR=12.0
Pod undocumented
230 $_[0]->{'utime'} ||= Date::Parse::str2time($_[0]->{date})
231 124 ▶ or Carp::croak "Unrecognised or invalid date: $_[0]->{date}";
Branch: 1 branch
BranchTrueFalseTotal
$_[0]{"utime"} ||= Date::Parse::str2time($_[0]{"date"}) or Carp::croak(qq[Unrecognised or invalid date: $_[0]{"date"}]) 124 0 124
Condition66%2/3
$_[0]{"utime"} ||= Date::Parse::str2time($_[0]{"date"})
l!l&&r!l&&!r
52720
MC/DC0%0/2
$_[0]{"utime"} ||= Date::Parse::str2time($_[0]{"date"})
$_[0]{"utime"} Date::Parse::str2time($_[0]{"date"})
Truth table66%2/3
A ||= B
A= $_[0]{"utime"}B= Date::Parse::str2time($_[0]{"date"})
ABresult
1X1
011
000
232 }
233  
234 sub datetime
235 2 ▶{
Subroutine datetime: called CC=2 SCAR=9.2
Pod documented
236 2 ▶ $_[0]->{datetime} ||= _time2datetime($_[0]->utime);
Condition33%1/3
$_[0]{"datetime"} ||= _time2datetime($_[0]->utime)
l!l&&r!l&&!r
020
MC/DC0%0/2
$_[0]{"datetime"} ||= _time2datetime($_[0]->utime)
$_[0]{"datetime"} _time2datetime($_[0]->utime)
Truth table33%1/3
A ||= B
A= $_[0]{"datetime"}B= _time2datetime($_[0]->utime)
ABresult
1X1
011
000
237 }
238  
239 2 ▶sub _time2datetime {
Subroutine _time2datetime: called CC=1 SCAR=0.0
240 2 strftime("%Y%m%d%H%M%S",gmtime($_[0]));
241 }
242  
243 sub institution
244 0 ▶{
Subroutine institution: not called CC=2 SCAR=17.9
Pod documented
245 0 my( $self ) = @_;
246 0 ▶ return $self->{_institution} if exists($self->{_institution});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"_institution"} 0 0 0
247 0 @$self{qw(_institution _homepage)} = addr2institution($self->hostname);
248 0 $self->{_institution};
249 }
250  
251 sub homepage
252 1 ▶{
Subroutine homepage: called CC=2 SCAR=7.0
Pod documented
253 1 my( $self ) = @_;
254 1 ▶ return $self->{_homepage} if exists($self->{_homepage});
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"_homepage"} 0 1 1
255 1 @$self{qw(_institution _homepage)} = addr2institution($self->hostname);
256 1 $self->{_homepage};
257 }
258  
259 sub addr2institution
260 1 ▶{
Subroutine addr2institution: called CC=9 SCAR=24.6
Pod undocumented
261 1 my( $addr ) = @_;
262  
263 # Can't do anything unless the address is defined
264 1 ▶ return () unless defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 1 1
265  
266 # Get the domain name
267 1 ▶ return () unless $addr =~ /([^\.]+)\.([^\.]+)\.([^\.]+)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $addr =~ /([^\.]+)\.([^\.]+)\.([^\.]+)$/ 0 1 1
268 1 ▶ my $uri = 'http://www.' . ((length($3) > 2 || length($2) > 3) ?
Branch: 1 branch
BranchTrueFalseTotal
length $3 > 2 || length $2 > 3 ? : 0 1 1
Condition33%1/3
length $3 > 2 or length $2 > 3
l!l&&r!l&&!r
001
MC/DC0%0/2
length $3 > 2 or length $2 > 3
length $3 > 2 length $2 > 3
Truth table33%1/3
A or B
A= length $3 > 2B= length $2 > 3
ABresult
1X1
011
000
269 join('.', $2, $3) :
270 join('.', $1, $2, $3));
271 1 $uri .= '/';
272 1 ▶ return ($INST_CACHE{$uri},$uri) if defined $INST_CACHE{$uri};
Branch: 1 branch
BranchTrueFalseTotal
if defined $Logfile::EPrints::Hit::INST_CACHE{$uri} 0 1 1
273 1 ▶ return () if exists($INST_CACHE{$uri});
Branch: 1 branch
BranchTrueFalseTotal
if exists $Logfile::EPrints::Hit::INST_CACHE{$uri} 0 1 1
274  
275 # Retrieve the home page
276 1 $UA->max_size( 2048 );
277 1 my $r = $UA->get($uri);
278 1 $UA->max_size( undef );
279 1 ▶ if( $r->is_error )
Branch: 1 branch
BranchTrueFalseTotal
if ($r->is_error) 0 1 1
280 {
281 0 warn "Error retrieving homepage ($uri): " . $r->message;
282 0 $INST_CACHE{$uri} = undef;
283 0 return ();
284 }
285  
286 1 ▶ return () unless $r->content =~ /<\s*title[^>]*>([^<]+)<\s*\/\s*title\s*>/is;
Branch: 1 branch
BranchTrueFalseTotal
unless $r->content =~ m[<\s*title[^>]*>([^<]+)<\s*/\s*title\s*>]is 0 1 1
287 1 my $title = $1;
288 1 $title =~ s/\r\n/ /sg;
289 1 $title =~ s/^\s+//;
290 1 $title =~ s/(?:\-)?\s+$//;
291 1 return ($INST_CACHE{$uri} = $title,$uri);
292 }
293  
294 package Logfile::EPrints::Hit::Combined;
295  
296 # Log file format is:
297 # ADDRESS IDENTD_USERID USER_ID [DATE TIMEZONE] "request" HTTP_CODE RESPONSE_SIZE "referrer" "agent"
298  
299 =pod
300  
301 =head1 NAME
302  
303 Logfile::EPrints::Hit::Combined - Parse combined format logs like those generated from Apache
304  
305 =head1 SYNOPSIS
306  
307 use Logfile::EPrints::Hit;
308  
309 my $hit = Logfile::EPrints::Hit::Combined->new($line);
310  
311 printf("%s requested %s\n",
312 $hit->hostname,
313 $hit->page);
314  
315 =head1 AUTHOR
316  
317 Tim Brody - <tdb01r@ecs.soton.ac.uk>
318  
319 =cut
320  
321 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
322  
323 6 ▶use vars qw( @ISA );
Subroutine BEGIN: called CC=1 SCAR=0.0
324 6 @ISA = qw( Logfile::EPrints::Hit );
325  
326 6 ▶use vars qw( $AUTOLOAD $LINE_PARSER @FIELDS );
Subroutine BEGIN: called CC=1 SCAR=0.0
327  
328 6 ▶use Text::CSV_XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
329 6 $LINE_PARSER = Text::CSV_XS->new({
330 escape_char => '\\',
331 sep_char => ' ',
332 });
333  
334 # Fields in a single log line (as split by Text::CSV)
335 # !!! date is handled separately !!!
336 6 @FIELDS = qw(
337 address userid_identd userid
338 request code size referrer agent
339 );
340  
341 sub new($$)
342 2255 ▶{
Subroutine new: called CC=4 SCAR=14.3
343 2255 my %self = ('raw'=>$_[1]);
344  
345 # The date is contained in square-brackets
346 2255 ▶ if( $_[1] =~ s/\[([^\]]+)\]\s// ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[1] =~ s/\[([^\]]+)\]\s//) 2255 0 2255
347 2255 $self{date} = $1;
348 }
349 # Change apache escaping back to URI escaping
350 2255 $_[1] =~ s/\\x/\%/g;
351
352 # Split the log file fields
353 2255 ▶ if($LINE_PARSER->parse($_[1])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Logfile::EPrints::Hit::Combined::LINE_PARSER->parse($_[1])) { } 2255 0 2255
354 2255 @self{@FIELDS} = $LINE_PARSER->fields;
355 } else {
356 0 warn "Text::CSV_XS couldn't parse: " . $LINE_PARSER->error_input;
357 0 return;
358 }
359  
360 # Split the request
361 2255 @self{qw(method page version)} = split / /, $self{'request'};
362 # Look up the IP if the log file contains hostnames
363 2255 ▶ if( $self{'address'} !~ /\d$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self{"address"} =~ /\d$/) 1 2254 2255
364 1 $self{'hostname'} = delete $self{'address'};
365 }
366
367 2255 return bless \%self, $_[0];
368 }
369  
370 package Logfile::EPrints::Hit::arXiv;
371  
372 # Log file format is:
373 # ADDRESS IDENTD_USERID USER_ID [DATE TIMEZONE] "request" HTTP_CODE RESPONSE_SIZE "referrer" "agent"
374 # But can have unescaped quotes in the request or agent field (might be just uk mirror oddity)
375  
376 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
377  
378 6 ▶use vars qw( @ISA );
Subroutine BEGIN: called CC=1 SCAR=0.0
379 6 @ISA = qw( Logfile::EPrints::Hit::Combined );
380  
381 1 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
382 1 my ($class,$hit) = @_;
383 1 my (%self, $rest);
384 1 $self{raw} = $hit;
385 1 (@self{qw(address userid_identd userid)},$rest) = split / /, $hit, 4;
386 1 $rest =~ s/^\[([^\]]+)\] //;
387 1 $self{date} = $1;
388 1 $rest =~ s/ (\d+) (\d+|-)(?= )//; # Chop code & size out of the middle
389 1 @self{qw(code size)} = ($1,$2);
390 1 $rest =~ s/^\"([A-Z]+) ([^ ]+) (HTTP\/1\.[01])\" //;
391 1 @self{qw(method page version)} = ($1,$2,$3);
392
393 # Apache replaces the % in URIs with \x
394 1 $self{page} =~ s/\\x/\%/g;
395 1 ▶ chop($self{page}) if substr($self{page},-1) eq '"';
Branch: 1 branch
BranchTrueFalseTotal
if substr($self{"page"}, -1) eq "\"" 1 0 1
396
397 1 $rest =~ s/^\"([^\"]+)\" \"(.+)\"$//;
398 1 @self{qw(referrer agent)} = ($1,$2);
399
400 # Look up the IP if the log file contains hostnames
401 1 ▶ if( $self{'address'} !~ /\d$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self{"address"} =~ /\d$/) 1 0 1
402 1 $self{'hostname'} = delete $self{'address'};
403 }
404  
405 1 bless \%self, $class;
406 }
407  
408 package Logfile::EPrints::Hit::Bracket;
409  
410 # Logfile format is:
411 #
412 # host ident user_id [dd/mmm/yyyy:hh:mm:ss +zone] [User Agent|email?|?|referrer] "page" code size
413  
414 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
415  
416 6 our @ISA = qw( Logfile::EPrints::Hit::Combined );
417  
418 3 ▶sub new {
Subroutine new: called CC=3 SCAR=11.8
419 3 my( $class, $hit ) = @_;
420 3 my %self = (raw => $hit);
421  
422 3 ▶ @self{qw(
Branch: 1 branch
BranchTrueFalseTotal
@self{"hostname", "userid_identd", "userid", "date", "agent", "from", "process_time", "referrer", "method", "page", "version", "code", "size"} = $hit =~ m(([^ ]+) ([^ ]+) ([^ ]+) \[(.{26})\] \[(.+)\|([^\|]+)\|([^\|]+)\|([^\|]+)\] "([A-Z]+) ([^ ]+) (HTTP/1\.[01])" (\d+) (\d+|-)) or return undef 3 0 3
423 hostname
424 userid_identd
425 userid
426 date
427 agent
428 from
429 process_time
430 referrer
431 method
432 page
433 version
434 code
435 size
436 )} = $hit =~ /([^ ]+) ([^ ]+) ([^ ]+) \[(.{26})\] \[(.+)\|([^\|]+)\|([^\|]+)\|([^\|]+)\] "([A-Z]+) ([^ ]+) (HTTP\/1\.[01])" (\d+) (\d+|-)/
437 or return undef;
438  
439 # Is an IP address rather than hostname
440 3 ▶ if( $self{'hostname'} =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self{"hostname"} =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) 0 3 3
441 0 $self{'address'} = delete $self{'hostname'};
442 }
443  
444 3 return bless \%self, $class;
445 }
446  
447 6 1;
« EPrints/Mapping/EPrints.pm ↑ Summary EPrints/Filter/Session.pm »