| 1 | #file:Apache2/AMFTrace.pm; | ||
| 2 | #-------------------------------- | ||
| 3 | |||
| 4 | # | ||
| 5 | # Created by Idel Fuschini | ||
| 6 | # Date: 01/08/10 | ||
| 7 | # Site: http://www.apachemobilefilter.org | ||
| 8 | # Mail: idel.fuschini@gmail.com | ||
| 9 | |||
| 10 | |||
| 11 | |||
| 12 | package Apache2::AMFTrace; | ||
| 13 | |||
| 14 | use strict; | ||
| 15 | use warnings; | ||
| 16 | use Apache2::AMFCommonLib (); | ||
| 17 | |||
| 18 | use Apache2::RequestRec (); | ||
| 19 | use Apache2::RequestUtil (); | ||
| 20 | use Apache2::SubRequest (); | ||
| 21 | use Apache2::Log; | ||
| 22 | use Apache2::Filter (); | ||
| 23 | use Apache2::Connection (); | ||
| 24 | use APR::Table (); | ||
| 25 | use Apache2::Const -compile => qw(OK REDIRECT DECLINED); | ||
| 26 | use IO::Uncompress::Unzip qw(unzip $UnzipError) ; | ||
| 27 | use constant BUFF_LEN => 1024; | ||
| 28 | use vars qw($VERSION); | ||
| 29 | $VERSION= "4.33";;; | ||
| 30 | # | ||
| 31 | # Define the global environment | ||
| 32 | # | ||
| 33 | my $CommonLib = new Apache2::AMFCommonLib (); | ||
| 34 | my $TraceDebug='false'; | ||
| 35 | my @TraceCapability; | ||
| 36 | my $TraceFS="\|"; | ||
| 37 | |||
| 38 | $CommonLib->printLog("---------------------------------------------------------------------------"); | ||
| 39 | $CommonLib->printLog("AMFTrace Version $VERSION"); | ||
| 40 | if ($ENV{AMFTraceDebug}) { | ||
| 41 | $TraceDebug=$ENV{AMFTraceDebug}; | ||
| 42 | } | ||
| 43 | if ($ENV{AMFTraceFS}) { | ||
| 44 | $TraceFS=$ENV{AMFTraceFS}; | ||
| 45 | } | ||
| 46 | if ($ENV{AMFTraceCapability}) { | ||
| 47 | #$TraceCapability=$ENV{AMFTraceCapability}; | ||
| 48 | @TraceCapability = split(/,/, $ENV{AMFTraceCapability}); | ||
| 49 | $CommonLib->printLog("TraceCapabilityList is: $ENV{AMFTraceCapability}"); | ||
| 50 | } else { | ||
| 51 | $CommonLib->printLog("AMFTraceCapability is not setted, the default value is: id"); | ||
| 52 | $TraceCapability[0]='id'; | ||
| 53 | } | ||
| 54 | $CommonLib->printLog("AMFTraceDebug is: $TraceDebug"); | ||
| 55 | sub handler { | ||
| 56 | my $f = shift; | ||
| 57 | my $user_agent=$f->headers_in->{'User-Agent'}|| ''; | ||
| 58 | my $x_user_agent=$f->headers_in->{'X-Device-User-Agent'}|| ''; | ||
| 59 | if ($x_user_agent) { | ||
| 60 | $f->log->warn("Warn probably transcoder: $x_user_agent"); | ||
| 61 | $user_agent=$x_user_agent; | ||
| 62 | } | ||
| 63 | if ($TraceDebug eq 'false') { | ||
| 64 | if ($f->pnotes('id')) { | ||
| 65 | if ($f->pnotes('id') eq 'device_not_found') { | ||
| 66 | $f->log->warn("AMFTrace device_not_found - User_Agent:$user_agent"); | ||
| 67 | } | ||
| 68 | } else { | ||
| 69 | $f->log->warn("AMFTrace device_not_found - User_Agent:$user_agent"); | ||
| 70 | } | ||
| 71 | } else { | ||
| 72 | my $msg=""; | ||
| 73 | foreach my $key ( @TraceCapability) { | ||
| 74 | if ($f->pnotes("$key")) { | ||
| 75 | $msg=$msg.$key."=".$f->pnotes("$key").$TraceFS; | ||
| 76 | } else { | ||
| 77 | if ($key eq 'id') { | ||
| 78 | $msg=$msg."id=device_not_found".$TraceFS; | ||
| 79 | } | ||
| 80 | } | ||
| 81 | } | ||
| 82 | $f->log->warn("AMFTrace - $msg User_Agent:$user_agent"); | ||
| 83 | } | ||
| 84 | return Apache2::Const::DECLINED; | ||
| 85 | } | ||
| 86 | |||
| 87 | 1; | ||
| 88 | |||
| 89 | |||
| 90 | =head1 NAME | ||
| 91 | |||
| 92 | Apache2::AMFTrace - This module has the scope to trace the not detected devices and to statistic or debugging scope. | ||
| 93 | |||
| 94 | =head1 DESCRIPTION | ||
| 95 | |||
| 96 | This module has the scope to trace info for debug. | ||
| 97 | |||
| 98 | =head1 AMF PROJECT SITE | ||
| 99 | |||
| 100 | http://www.apachemobilefilter.org | ||
| 101 | |||
| 102 | =head1 DOCUMENTATION | ||
| 103 | |||
| 104 | http://wiki.apachemobilefilter.org | ||
| 105 | |||
| 106 | Perl Module Documentation: http://wiki.apachemobilefilter.org/index.php/AMFTrace | ||
| 107 | |||
| 108 | =head1 AUTHOR | ||
| 109 | |||
| 110 | Idel Fuschini (idel.fuschini [at] gmail [dot] com) | ||
| 111 | |||
| 112 | =head1 COPYRIGHT | ||
| 113 | |||
| 114 | You may distribute under the terms of either the GNU General Public | ||
| 115 | License or the Artistic License, as specified in the Perl README file. | ||
| 116 | |||
| 117 | =cut |