Apache2-ApacheMobileFilter

 view release on metacpan or  search on metacpan

lib/Apache2/AMFCommonLib.pm  view on Meta::CPAN

	}
	#print "$ua----------\n";
	my $version='nc';
	my $os='nc';
	if (index($ua,'android') > -1 ) {
	       #my $string_to_parse=substr($ua,index($ua,'(') + 1,index($ua,')'));
	       my @param=split(/\;/,$ua);
	       #my ($dummy1,$dummy2,$vers,$lan,$dummy5)=split(/\;/,$string_to_parse);
	       my $element=scalar @param;
	       my $count=0;
	       my $count_add=0;
	       my @param_ua;
	       if ($element > 0) {
	       while ($count<$element) {
		  if (index($param[$count],'-')>-1 && length($param[$count])==6) {
		  } elsif (length($param[$count])==2) {
		  } elsif (index($param[$count],'android')>-1) {
			  ($os,$version)=split(/ /,$param[$count]);
			  if ($version) {
			    if (index($version,'.') > -1) {
			      $version =~ s/\.//g;
			    }
			  }
			  $param_ua[$count_add]="android xx";
			  $count_add++;
		  } else {
		     $param_ua[$count_add]=$param[$count];
		     $count_add++;
		  }
		  $count++;
	      }
	       	$count=0;
		$element=scalar @param_ua;
		$ua = "";
		while ($count < $element) {
		  $ua=$ua." ".$param_ua[$count];
		  $count++;
		}
		$ua=substr($ua,1);
               }
              #print $ua."\n";
	}
	return ($ua,$version);

}
sub botDetection {
	my $self = shift;
	my $ua="";
	my @arrayBot = ('googlebot','google web preview','msnbot','google.com/bot','ia_archiver','yahoo!','webalta crawler','flickysearchbot','yanga worldsearch','stackrambler','mail.ru','yandex');
	if (@_) {
	    $ua = shift;
	}
	foreach my $pair (@arrayBot) {
	  if (index($ua,$pair) > -1 ) {
	    $ua='It is a bot';
	  }
	}
	return $ua;

}
sub readCookie {
    my $self = shift;
    my $cookie_search;
	if (@_) {
		    $cookie_search = shift;
	}
    my $param_tofound;
    my $string_tofound;
    my $value="";
    my $id_return="";
    my @pairs = split(/;/, $cookie_search);
    my $name;
    foreach $param_tofound (@pairs) {
       ($string_tofound,$value)=split(/=/, $param_tofound);
       if ($string_tofound =~ "amfID") {
           $id_return=$value;
       }
    }   
    return $id_return;
}
sub readCookie_fullB {
    my $self = shift;
    my $cookie_search;
	if (@_) {
		    $cookie_search = shift;
	}
    my $param_tofound;
    my $string_tofound;
    my $value="";
    my $id_return="";
    my @pairs = split(/;/, $cookie_search);
    my $name;
    foreach $param_tofound (@pairs) {
       ($string_tofound,$value)=split(/=/, $param_tofound);
       if ($string_tofound =~ "amfFull") {
           $id_return=$value;
       }
    }   
    return $id_return;
}

1;


=head1 NAME

Apache2::AMFCommonLib - Common Library That AMF uses.

=head1 DESCRIPTION

Is a simple Common Library for AMF

=head1 AMF PROJECT SITE

http://www.apachemobilefilter.org

=head1 DOCUMENTATION

http://wiki.apachemobilefilter.org

=head1 AUTHOR

Idel Fuschini (idel.fuschini [at] gmail [dot] com)

=head1 COPYRIGHT

You may distribute under the terms of either the GNU General Public
License or the Artistic License, as specified in the Perl README file.

=cut



( run in 1.132 second using v1.01-cache-2.11-cpan-9581c071862 )