|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| 11/05/2009 at 12:54AM PST, ID: 24873730 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: |
#!/usr/bin/perl -w
use strict;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use CGI;
my $q = new CGI;
my $log="/tmp/yyy.txt";
my $command;
my $name;
showForm();
exit;
#############################
sub showForm {
my $html;
#$log = "/var/log/httpd/access_log";
#$log = "/tmp/access_log";
# print search form
print header( ), start_html("Query Users"), h1("Search");
print start_form( ), p("Which user?", textfield("WHO")); submit( ), end_form( );
# print results of the query if we have someone to look for
$name = param("WHO");
if ($name) {
print h1("Results for [$name]");
#$command="cp /dev/null $log; grep $name /var/log/httpd/access_log* | grep Members | grep GET >> $log";
#print p("command= [$command]") if ( $command );
#$html = `echo system($command)`;
#print pre($html);
#print p("$log exists") if ( -f $log );
#print p("$log is readable") if ( -r $log );
#print p("$log DOES NOT EXIST!!") if (! -f $log );
#$html = `ls -l $log`;
#print pre($html);
#open(LOGFILE, "<", "$log") or die "can't open $log: $! \n";
#print p("open log file: [$log]");
#while (<LOGFILE>) {
#print pre($_) if (/$name/);
#}
#close(LOGFILE)
searchLog();
}
print end_html( );
}
#############################
sub searchLog {
my %AccessedGuestSite = ();
my %AccessedMemberSite = ();
my %downloaded = ();
my %hosts = ();
my %FilesDownloaded = ();
my $index;
my ($filename, $host, $ident_user, $auth_user, $date, $time, $time_zone, $method, $url, $protocol, $status, $bytes, $referer, $agent, $rest);
#open (LOGFILE, "<$log") || die("ERROR: cannot read $log!");
open (LOGFILE, "`grep $name /var/log/httpd/access_log* | grep Members | grep GET` | ") || die("ERROR: cannot read pipe!");
#print $q->header;
while (<LOGFILE>) {
chomp();
my $num = $_ =~ tr / / /; # hack to get the number of spaces on the line
if ($num == 9) {
($host, $ident_user, $auth_user, $date, $time, $time_zone, $method, $url, $protocol, $status, $bytes) =
/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] \"(\S+) (.+?) (\S+)\" (\S+) (\S+)$/
#or next;
} elsif ($num == 10) {
($host, $ident_user, $auth_user, $date, $time, $time_zone, $method, $url, $protocol, $status, $bytes, $referer, $agent) =
/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] \"(\S+) (.+?) (\S+)\" (\S+) (\S+) \"([^\"]+)\" \"([^\"]+)\"$/
#or next;
} elsif ($num == 11) {
($host, $ident_user, $auth_user, $date, $time, $time_zone, $method, $url, $protocol, $status, $bytes, $referer, $agent, $rest) =
/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] \"(\S+) (.+?) (\S+)\" (\S+) (\S+) \"([^\"]+)\" \"([^\"]+)\" (.*)$/
#or next;
} elsif ($num > 11) {
($host, $ident_user, $auth_user, $date, $time, $time_zone, $method, $url, $protocol, $status, $bytes, $referer, $rest) =
/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] \"(\S+) (.+?) (\S+)\" (\S+) (\S+) \"([^\"]+)\" (.*)$/
#or next;
} else {
die "unrecognized log format -- space equals '$num' \n\tline[$_]";
}
($filename, $host) = split(/:/,$host);
++$hosts{$host};
++$AccessedMemberSite{$date} if (( $url =~ /originalimages/i ) || ( $url =~ /html/i ));
#++$AccessedMemberSite{$date} if ( $url =~ /Members/i );
++$AccessedGuestSite{$date} if ( $url =~ /Guests/i );
#if ((( $url =~ /originalimages/i ) || ( $url =~ /images/i ) || ( $url =~ /zip/i )) && ( ! $url =~ /gif/i )) {
if (( $url =~ /originalimages/i ) || ( $url =~ /zip/i )) {
++$downloaded{$date};
#if ( exists $downloaded{$date} ) { $downloaded{$date}++; } else { $downloaded{$date} = 1; }
++$FilesDownloaded{$url};
}
#print $q->br("*** host[$host], ident[$ident_user], auth[$auth_user], date[$date], time[$time], tz[$time_zone], method[$method], url[$url], protocol[$protocol], status[$status], bytes[$bytes], referer[$referer], agent[$agent]");
#print $q->br("--- rest[$rest]");
#print $q->hr();
}
print $q->h2("Usage report");
print $q->h3("-- for user: '$auth_user' from hosts: ");
### %hosts
foreach (keys %hosts) {
### $_
print ("$_ x ($hosts{$_}) times ") if (exists $hosts{$_});
}
### %AccessedGuestSite
foreach (keys %AccessedGuestSite) {
### $_
print $q->p("Accessed GUEST site on $_, $AccessedGuestSite{$_} times, and downloaded $downloaded{$_} bytes") if (exists $AccessedGuestSite{$_});
}
### %AccessedMemberSite
foreach (keys %AccessedMemberSite) {
### $_
print $q->p("Accessed Members Pages on $_, $AccessedMemberSite{$_} times, and downloaded $downloaded{$_} bytes") if (exists $AccessedMemberSite{$_});
}
print $q->p("Downloaded the following files:");
foreach (keys %FilesDownloaded) {
### $_
print $q->p("Downloaded $_ x ($FilesDownloaded{$_}) times") if (exists $FilesDownloaded{$_});
}
print $q->p("***** EOF ************");
close("LOGFILE");
}
__END__
|
Advertisement