WURFLFilter.pm untested

filter: Statementstmt 0.0% 0 / 471 Branchbran 0.0% 0 / 142 Conditioncond 0.0% 0 / 62 MC/DCmcdc 0.0% 0 / 31 Subroutinesub 0.0% 0 / 23 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 737 CC 66 SCAR 54.2
CC
66
Cov
0%
loadConfigFile
506.0
handler
272.0
parseWURFLFile
182.0
CRAP 225.5
1 #file:Apache2/WURFLFilter.pm;
2 #--------------------------------
3  
4 #
5 # Created by Idel Fuschini
6 # Date: 15/12/09
7 # Site: http://www.idelfuschini.it
8 # Mail: idel.fuschini@gmail.com
9  
10  
11 package Apache2::WURFLFilter;
12
13 use strict;
14 use warnings;
15 use Apache2::AMFCommonLib ();
16
17 use Apache2::RequestRec ();
18 use Apache2::RequestUtil ();
19 use Apache2::SubRequest ();
20 use Apache2::Log;
21 use Apache2::Filter ();
22 use APR::Table ();
23 use LWP::Simple;
24 use Apache2::Const -compile => qw(OK REDIRECT DECLINED);
25 use IO::Uncompress::Unzip qw(unzip $UnzipError) ;
26 use constant BUFF_LEN => 1024;
27 use Cache::FileBackend;
28  
29  
30 #
31 # Define the global environment
32 #
33  
34 use vars qw($VERSION);
35 $VERSION= "2.21";
36 my $CommonLib = new Apache2::AMFCommonLib ();
37
38 my %Capability;
39 my %Array_fb;
40 my %Array_id;
41 my %Array_fullua_id;
42 my %Array_DDRcapability;
43  
44 my %PatchArray_id;
45 my %MobileArray;
46 $MobileArray{'mobile'}='mobile';
47 $MobileArray{'symbian'}='mobile';
48 $MobileArray{'midp'}='mobile';
49 $MobileArray{'android'}='mobile';
50 $MobileArray{'iphone'}='mobile';
51 $MobileArray{'ipod'}='mobile';
52 $MobileArray{'google'}='mobile';
53 $MobileArray{'novarra'}='mobile';
54  
55  
56
57 my $mobileversionurl="none";
58 my $fullbrowserurl="none";
59 my $redirecttranscoder="true";
60 my $redirecttranscoderurl="none";
61 my $resizeimagedirectory="none";
62 my $wurflnetdownload="false";
63 my $downloadwurflurl="false";
64 my $loadwebpatch="false";
65 my $patchwurflnetdownload="false";
66 my $patchwurflurl="";
67 my $listall="false";
68 my $cookiecachesystem="false";
69 my $WURFLVersion="unknown";
70 my $cachedirectorystore="/tmp";
71 $CommonLib->printLog("---------------------------------------------------------------------------");
72 $CommonLib->printLog("------- APACHE MOBILE FILTER V$VERSION -------");
73 $CommonLib->printLog("---------------------------------------------------------------------------");
74 $CommonLib->printLog("WURFLFilter module Version $VERSION");
75 if ($ENV{ResizeImageDirectory}) {
76 $Capability{'max_image_width'}="max_image_width";
77 $Capability{'max_image_height'}="max_image_width";
78 $resizeimagedirectory=$ENV{ResizeImageDirectory};
79 }
80 if (($ENV{FullBrowserUrl}) || ($ENV{MobileVersionUrl})) {
81 $Capability{'device_claims_web_support'}="device_claims_web_support";
82 $Capability{'is_wireless_device'}="is_wireless_device";
83 $fullbrowserurl=$ENV{FullBrowserUrl}
84 }
85 if ($ENV{RedirectTranscoderUrl}) {
86 $Capability{'is_transcoder'}="is_transcoder";
87 $redirecttranscoderurl=$ENV{RedirectTranscoderUrl};
88 }
89  
90 #
91 # Check if MOBILE_HOME and CacheDirectoryStore is setting in apache httpd.conf file for example:
92 # PerlSetEnv MOBILE_HOME <apache_directory>/MobileFilter
93 #
94 if ($ENV{CacheDirectoryStore}) {
95 $cachedirectorystore=$ENV{CacheDirectoryStore};
96 $CommonLib->printLog("CacheDirectoryStore is: $cachedirectorystore");
97 } else {
98 $CommonLib->printLog("CacheDirectoryStore not exist. Please set the variable CacheDirectoryStore into httpd.conf, (the directory must be writeable)");
99 ModPerl::Util::exit();
100 }
101 #
102 # Define the cache system directory
103 #
104 my $cacheSystem = new Cache::FileBackend( $cachedirectorystore, 3, 000 );
105 $cacheSystem->store( 'wurfl-id', 'device_not_found', "id=device_not_found&device=false&device_claims_web_support=true&is_wireless_device=false");
106 if ($cacheSystem->restore('wurfl-conf','ver')) {
107 } else {
108 $CommonLib->printLog('Create new wurf-con store');
109 $cacheSystem->store('wurfl-conf', 'ver', 'null');
110 $cacheSystem->store('wurfl-conf', 'caplist', 'null');
111 $cacheSystem->store('wurfl-conf', 'listall', 'null');
112 $cacheSystem->store('wurfl-conf', 'RedirectTranscoderUrl','null');
113 $cacheSystem->store('wurfl-conf', 'MobileVersionUrl','null');
114 $cacheSystem->store('wurfl-conf', 'FullBrowserUrl','null');
115 $cacheSystem->store('wurfl-conf', 'ResizeImageDirectory','null');
116 }
117 if ($ENV{MOBILE_HOME}) {
118 &loadConfigFile("$ENV{MOBILE_HOME}/wurfl.xml");
119 } else {
120 $CommonLib->printLog("MOBILE_HOME not exist. Please set the variable MOBILE_HOME into httpd.conf");
121 ModPerl::Util::exit();
122 }
123
124  
125 sub loadConfigFile {
126 my ($fileWurfl) = @_;
127 my $null="";
128 my $null2="";
129 my $null3="";
130 my $val;
131 my $capability;
132 my $r_id;
133 my $dummy;
134 #The filter
135 $CommonLib->printLog("Start read configuration from httpd.conf");
136
137 if ($ENV{WurflNetDownload}) {
138 $wurflnetdownload=$ENV{WurflNetDownload};
139 $CommonLib->printLog("WurflNetDownload is: $wurflnetdownload");
140 }
141 if ($ENV{DownloadWurflURL}) {
142 $downloadwurflurl=$ENV{DownloadWurflURL};
143 $CommonLib->printLog("DownloadWurflURL is: $downloadwurflurl");
144 }
145 if ($ENV{CapabilityList}) {
146 my @dummycapability = split(/,/, $ENV{CapabilityList});
147 foreach $dummy (@dummycapability) {
148 if ($dummy eq "all") {
149 $listall="true";
150 }
151 $Capability{$dummy}=$dummy;
152 $CommonLib->printLog("CapabilityList is: $dummy");
153 }
154 }
155
156 if ($ENV{LoadWebPatch}) {
157 $loadwebpatch=$ENV{LoadWebPatch};
158 $CommonLib->printLog("LoadWebPatch is: $loadwebpatch");
159 }
160 if ($ENV{PatchWurflNetDownload}) {
161 $patchwurflnetdownload=$ENV{PatchWurflNetDownload};
162 $CommonLib->printLog("PatchWurflNetDownload is: $patchwurflnetdownload");
163 }
164 if ($ENV{PatchWurflUrl}) {
165 $patchwurflurl=$ENV{PatchWurflUrl};
166 $CommonLib->printLog("PatchWurflUrl is: $patchwurflurl");
167 }
168  
169 if ($ENV{CookieCacheSystem}) {
170 $cookiecachesystem=$ENV{CookieCacheSystem};
171 $CommonLib->printLog("CookieCacheSystem is: $cookiecachesystem");
172 }
173
174  
175 $CommonLib->printLog("Finish loading parameter");
176 $CommonLib->printLog("---------------------------------------------------------------------------");
177 if ($wurflnetdownload eq "true") {
178 $CommonLib->printLog("Start process downloading WURFL.xml from $downloadwurflurl");
179 $CommonLib->printLog ("Test the URL");
180 my ($content_type, $document_length, $modified_time, $expires, $server) = head($downloadwurflurl);
181 if ($content_type eq "") {
182 $CommonLib->printLog("Couldn't get $downloadwurflurl.");
183 ModPerl::Util::exit();
184 } else {
185 $CommonLib->printLog("The URL is correct");
186 $CommonLib->printLog("The size of document wurf file: $document_length bytes");
187 }
188
189 if ($content_type eq 'application/zip') {
190 $CommonLib->printLog("The file is a zip file.");
191 $CommonLib->printLog ("Start downloading");
192 my @dummypairs = split(/\//, $downloadwurflurl);
193 my ($ext_zip) = $downloadwurflurl =~ /\.(\w+)$/;
194 my $filezip=$dummypairs[-1];
195 my $tmp_dir=$ENV{MOBILE_HOME};
196 $filezip="$tmp_dir/$filezip";
197 my $status = getstore ($downloadwurflurl,$filezip);
198 my $output="$tmp_dir/tmp_wurfl.xml";
199 unzip $filezip => $output
200 or die "unzip failed: $UnzipError\n";
201 #
202 # call parseWURFLFile
203 #
204 callparseWURFLFile($output);
205  
206 } else {
207 $CommonLib->printLog("The file is a xml file.");
208 my $content = get ($downloadwurflurl);
209 my @rows = split(/\n/, $content);
210 my $row;
211 my $count=0;
212 foreach $row (@rows){
213 $r_id=parseWURFLFile($row,$r_id);
214 }
215 }
216 $CommonLib->printLog("Finish downloading WURFL from $downloadwurflurl");
217  
218 } else {
219 if (-e "$fileWurfl") {
220 $CommonLib->printLog("Start loading WURFL.xml");
221 if (open (IN,"$fileWurfl")) {
222 while (<IN>) {
223 $r_id=parseWURFLFile($_,$r_id);
224
225 }
226 close IN;
227 } else {
228 $CommonLib->printLog("Error open file:$fileWurfl");
229 ModPerl::Util::exit();
230 }
231 } else {
232 $CommonLib->printLog("File $fileWurfl not found");
233 ModPerl::Util::exit();
234 }
235 }
236 close IN;
237 #
238 # Start for web_patch_wurfl (full browser)
239 #
240 if ($loadwebpatch eq 'true') {
241 if ($patchwurflnetdownload eq "true") {
242 $CommonLib->printLog("Start downloading patch WURFL from $patchwurflurl");
243 my ($content_type, $document_length, $modified_time, $expires, $server) = head($patchwurflurl);
244 if ($content_type eq "") {
245 $CommonLib->printLog("Couldn't get $patchwurflurl.");
246 ModPerl::Util::exit();
247 } else {
248 $CommonLib->printLog("The URL for download patch WURFL is correct");
249 $CommonLib->printLog("The size of document is: $document_length bytes");
250 }
251 my $content = get ($patchwurflurl);
252 $CommonLib->printLog("Finish downloading WURFL.xml");
253 if ($content eq "") {
254 $CommonLib->printLog("Couldn't get patch $patchwurflurl.");
255 ModPerl::Util::exit();
256 }
257 my @rows = split(/\n/, $content);
258 my $row;
259 my $count=0;
260 foreach $row (@rows){
261 $r_id=parsePatchFile($row,$r_id);
262 }
263 } else {
264 my $filePatch="$ENV{MOBILE_HOME}/web_browsers_patch.xml";
265 if (-e "$filePatch") {
266 $CommonLib->printLog("Start loading Web Patch File of WURFL");
267 if (open (IN,"$filePatch")) {
268 while (<IN>) {
269 $r_id=parsePatchFile($_,$r_id);
270
271 }
272 close IN;
273 } else {
274 $CommonLib->printLog("Error open file:$filePatch");
275 ModPerl::Util::exit();
276 }
277 } else {
278 $CommonLib->printLog("File patch $filePatch not found");
279 ModPerl::Util::exit();
280 }
281 }
282 }
283 my $arrLen = scalar %Array_fb;
284 ($arrLen,$dummy)= split(/\//, $arrLen);
285 if ($arrLen == 0) {
286 $CommonLib->printLog("Error the file probably is not a wurfl file, control the url or path");
287 $CommonLib->printLog("Control also if the file is compress file, and DownloadZipFile parameter is seted false");
288 ModPerl::Util::exit();
289 }
290 $CommonLib->printLog("WURFL version: $WURFLVersion");
291 if ($cacheSystem->restore('wurfl-conf', 'ResizeImageDirectory') ne $resizeimagedirectory||$cacheSystem->restore('wurfl-conf', 'DownloadWurflURL') ne $downloadwurflurl||$cacheSystem->restore('wurfl-conf', 'FullBrowserUrl') ne $fullbrowserurl||$cacheSystem->restore('wurfl-conf', 'RedirectTranscoderUrl') ne $redirecttranscoderurl || $cacheSystem->restore('wurfl-conf', 'ver') ne $WURFLVersion || $cacheSystem->restore('wurfl-conf', 'caplist') ne $ENV{CapabilityList}||$cacheSystem->restore('wurfl-conf', 'listall') ne $listall) {
292 $CommonLib->printLog("********************************************************************************************************");
293 $CommonLib->printLog("* This is a new version of WURFL or you change some parameter value, now the old cache must be deleted *");
294 $CommonLib->printLog("********************************************************************************************************");
295 $cacheSystem->store('wurfl-conf', 'ver', $WURFLVersion);
296 $cacheSystem->store('wurfl-conf', 'caplist', $ENV{CapabilityList});
297 $cacheSystem->store('wurfl-conf', 'listall', $listall);
298 $cacheSystem->store('wurfl-conf', 'RedirectTranscoderUrl', $redirecttranscoderurl);
299 $cacheSystem->store('wurfl-conf', 'FullBrowserUrl', $fullbrowserurl);
300 $cacheSystem->store('wurfl-conf', 'DownloadWurflURL', $downloadwurflurl);
301 $cacheSystem->store('wurfl-conf', 'ResizeImageDirectory', $resizeimagedirectory);
302
303 $cacheSystem->delete_namespace( 'WURFL-id' );
304 $cacheSystem->delete_namespace( 'WURFL-ua' );
305 }
306 $CommonLib->printLog("This version of WURFL has $arrLen UserAgent");
307 $CommonLib->printLog("End loading WURFL.xml");
308 }
309 sub callparseWURFLFile {
310 my ($output) = @_;
311 my $r_id;
312 if (open (IN,"$output")) {
313 while (<IN>) {
314 $r_id=parseWURFLFile($_,$r_id);
315 }
316 close IN;
317 } else {
318 $CommonLib->printLog("Error open file:$output");
319 ModPerl::Util::exit();
320 }
321 }
322 sub parseWURFLFile {
323 my ($record,$val) = @_;
324 my $null="";
325 my $null2="";
326 my $null3="";
327 my $ua="";
328 my $fb="";
329 my $value="";
330 my $id;
331 my $name="";
332 if ($val) {
333 $id="$val";
334 }
335 if ($record =~ /\<device/o) {
336 if (index($record,'user_agent') > 0 ) {
337 $ua=substr($record,index($record,'user_agent') + 12,index($record,'"',index($record,'user_agent')+ 13)- index($record,'user_agent') - 12);
338 if (index($ua,'BlackBerry') >0 ) {
339 $ua=substr($ua,index($ua,'BlackBerry'));
340 }
341 }
342 if (index($record,'id') > 0 ) {
343 $id=substr($record,index($record,'id') + 4,index($record,'"',index($record,'id')+ 5)- index($record,'id') - 4);
344 }
345 if (index($record,'fall_back') > 0 ) {
346 $fb=substr($record,index($record,'fall_back') + 11,index($record,'"',index($record,'fall_back')+ 12)- index($record,'fall_back') - 11);
347 }
348 if (($fb) && ($id)) {
349 $Array_fb{"$id"}=$fb;
350 }
351 if (($ua) && ($id)) {
352 my %ParseUA=$CommonLib->GetMultipleUa($ua);
353 my $pair;
354 my $arrUaLen = scalar %ParseUA;
355 my $contaUA=0;
356 my $Array_fullua_id=$ua;
357 foreach $pair (reverse sort { $a <=> $b } keys %ParseUA) {
358 my $dummy=$ParseUA{$pair};
359 $Array_id{$dummy}=$id;
360 $contaUA=$contaUA-1;
361 }
362 }
363
364 }
365 if ($record =~ /\<capability/o) {
366 ($null,$name,$null2,$value,$null3,$fb)=split(/\"/, $record);
367 if ($listall eq "true") {
368 $Capability{$name}=$name;
369 }
370 if (($id) && ($Capability{$name}) && ($name) && ($value)) {
371 $Array_DDRcapability{"$val|$name"}=$value;
372 }
373 }
374 if ($record =~ /\<ver/o) {
375 $WURFLVersion=$CommonLib->extValueTag("ver",$record);
376 }
377 return $id;
378  
379 }
380 sub parsePatchFile {
381 my ($record,$val) = @_;
382 my $null="";
383 my $null2="";
384 my $null3="";
385 my $ua="";
386 my $fb="";
387 my $value="";
388 my $id;
389 my $name="";
390 if ($val) {
391 $id="$val";
392 }
393 if ($record =~ /\<device/o) {
394 if (index($record,'user_agent') > 0 ) {
395 $ua=substr($record,index($record,'user_agent') + 12,index($record,'"',index($record,'user_agent')+ 13)- index($record,'user_agent') - 12);
396 if (index($ua,'BlackBerry') >0 ) {
397 $ua=substr($ua,index($ua,'BlackBerry'));
398 }
399 }
400 if (index($record,'id') > 0 ) {
401 $id=substr($record,index($record,'id') + 4,index($record,'"',index($record,'id')+ 5)- index($record,'id') - 4);
402 }
403 if (index($record,'fall_back') > 0 ) {
404 $fb=substr($record,index($record,'fall_back') + 11,index($record,'"',index($record,'fall_back')+ 12)- index($record,'fall_back') - 11);
405 }
406 if (($fb) && ($id)) {
407 $Array_fb{"$id"}=$fb;
408 }
409 if (($ua) && ($id)) {
410 #if (index($id,'_') > 0) {
411 $PatchArray_id{$ua}=$id;
412 #}
413 $Array_id{$ua}=$id;
414 }
415 }
416 if ($record =~ /\<capability/o) {
417 ($null,$name,$null2,$value,$null3,$fb)=split(/\"/, $record);
418 if ($listall eq "true") {
419 $Capability{$name}=$name;
420 }
421 if (($id) && ($Capability{$name}) && ($name) && ($value)) {
422 $Array_DDRcapability{"$val|$name"}=$value;
423 }
424 }
425 return $id;
426  
427 }
428  
429 sub FallBack {
430 my ($idToFind) = @_;
431 my $dummy_id;
432 my $dummy;
433 my $dummy2;
434 my $LOOP;
435 my %ArrayCapFoundToPass;
436 my $capability;
437 foreach $capability (sort keys %Capability) {
438 $dummy_id=$idToFind;
439 $LOOP=0;
440 while ($LOOP==0) {
441 $dummy="$dummy_id|$capability";
442 if ($Array_DDRcapability{$dummy}) {
443 $LOOP=1;
444 $dummy2="$dummy_id|$capability";
445 $ArrayCapFoundToPass{$capability}=$Array_DDRcapability{$dummy2};
446 } else {
447 $dummy_id=$Array_fb{$dummy_id};
448 if ($dummy_id eq "root" || $dummy_id eq "generic") {
449 $LOOP=1;
450 }
451 }
452 }
453
454 }
455 return %ArrayCapFoundToPass;
456 }
457 sub IdentifyUAMethod {
458 my ($UserAgent) = @_;
459 my $ind=0;
460 my %ArrayPM;
461 my $pair;
462 my $pair2;
463 my $id_find="";
464 my $dummy;
465 my $ua_toMatch;
466 my $near_toFind=100;
467 my $near_toMatch;
468 my %ArrayUAType=$CommonLib->GetMultipleUa($UserAgent);
469 foreach $pair (reverse sort { $a <=> $b } keys %ArrayUAType)
470 {
471 my $dummy=$ArrayUAType{$pair};
472 if ($Array_id{$dummy}) {
473 if ($id_find) {
474 my $dummy2="";
475 } else {
476 $id_find=$Array_id{$dummy};
477 }
478 }
479 }
480 return $id_find;
481 }
482 sub IdentifyPCUAMethod {
483 my ($UserAgent) = @_;
484 my $ind=0;
485 my $id_find="";
486 my $pair;
487 foreach $pair (%PatchArray_id)
488 {
489 if (index($UserAgent,$pair) > 0) {
490 $id_find=$PatchArray_id{$pair};
491 }
492 }
493 return $id_find;
494 }
495  
496  
497 sub handler {
498 my $f = shift;
499 my $capability2;
500 my $variabile="";
501 my $user_agent=$f->headers_in->{'User-Agent'}|| '';
502 my $x_user_agent=$f->headers_in->{'X-Device-User-Agent'}|| '';
503 my $query_string=$f->args;
504 my $docroot = $f->document_root();
505 my $id="";
506 my $location="none";
507 my $width_toSearch;
508 my $type_redirect="internal";
509 my $return_value;
510 my $dummy="";
511 my $variabile2="";
512 my %ArrayCapFound;
513 my $controlCookie;
514 my $query_img="";
515 $ArrayCapFound{is_transcoder}='false';
516 my %ArrayQuery;
517 my $var;
518 my $mobile=0;
519  
520 if ($x_user_agent) {
521 $f->log->warn("Warn probably transcoder: $x_user_agent");
522 $user_agent=$x_user_agent;
523 }
524 if ($user_agent =~ m/Blackberry/i) {
525 $user_agent=substr($user_agent,index($user_agent,'BlackBerry'));
526 $mobile=1;
527 }
528 if ($user_agent =~ m/UP.link/i ) {
529 $user_agent=substr($user_agent,0,index($user_agent,'UP.Link') - 1);
530 $mobile=1;
531 }
532 my $cookie = $f->headers_in->{Cookie} || '';
533 $id=$CommonLib->readCookie($cookie);
534 if ($cacheSystem->restore( 'wurfl-ua', $user_agent )) {
535 #
536 # cookie is not empty so I try to read in memory cache on my httpd cache
537 #
538 $id=$cacheSystem->restore( 'wurfl-ua', $user_agent );
539 if ($cacheSystem->restore( 'wurfl-id', $id )) {
540 #
541 # I'm here only for old device
542 #
543 my @pairs = split(/&/, $cacheSystem->restore( 'wurfl-id', $id ));
544 my $param_tofound;
545 my $string_tofound;
546 foreach $param_tofound (@pairs) {
547 ($string_tofound,$dummy)=split(/=/, $param_tofound);
548 $ArrayCapFound{$string_tofound}=$dummy;
549 my $upper2=uc($string_tofound);
550 $f->subprocess_env("AMF_$upper2" => $ArrayCapFound{$string_tofound});
551 }
552 $f->pnotes('max_image_height' => $ArrayCapFound{max_image_height});
553 $f->pnotes('max_image_width' => $ArrayCapFound{max_image_width});
554 $f->pnotes('device_claims_web_support' => $ArrayCapFound{device_claims_web_support});
555 $f->pnotes('is_wireless_device' => $ArrayCapFound{is_wireless_device});
556 $f->pnotes('is_transcoder' => $ArrayCapFound{is_transcoder});
557 $id=$ArrayCapFound{id};
558 }
559 } else {
560 if ($id eq "") {
561 if ($user_agent) {
562 my $pair;
563 my $lcuser_agent=lc($user_agent);
564 if ($mobile==0) {
565 foreach $pair (%MobileArray) {
566 if ($user_agent =~ m/$pair/i) {
567 $mobile=1;
568 }
569 }
570 if ($mobile==0) {
571 $id=IdentifyPCUAMethod($user_agent);
572 }
573 }
574 if ($id eq "") {
575 $id=IdentifyUAMethod($user_agent);
576 }
577 $cacheSystem->store( 'wurfl-ua', $user_agent, $id);
578 }
579 }
580 if ($id ne "") {
581 #
582 # device detected
583 #
584 if ($cacheSystem->restore( 'wurfl-id', $id )) {
585 #
586 # I'm here only for old device looking in cache
587 #
588 my @pairs = split(/&/, $cacheSystem->restore( 'wurfl-id', $id ));
589 my $param_tofound;
590 my $string_tofound;
591 foreach $param_tofound (@pairs) {
592 ($string_tofound,$dummy)=split(/=/, $param_tofound);
593 $ArrayCapFound{$string_tofound}=$dummy;
594 my $upper2=uc($string_tofound);
595 $f->subprocess_env("AMF_$upper2" => $ArrayCapFound{$string_tofound});
596 }
597 $id=$ArrayCapFound{id};
598 } else {
599 %ArrayCapFound=FallBack($id);
600 foreach $capability2 (sort keys %ArrayCapFound) {
601 $variabile2="$variabile2$capability2=$ArrayCapFound{$capability2}&";
602 my $upper=uc($capability2);
603 $f->subprocess_env("AMF_$upper" => $ArrayCapFound{$capability2});
604 }
605 $variabile2="id=$id&$variabile2";
606 $f->subprocess_env("AMF_ID" => $id);
607 $cacheSystem->store( 'wurfl-id', $id, $variabile2 );
608 $cacheSystem->store( 'wurfl-ua', $user_agent, $id);
609 if ($cookiecachesystem eq "true") {
610 $f->err_headers_out->set('Set-Cookie' => "amf=$id; path=/;");
611 }
612 }
613 $f->pnotes('width' => $ArrayCapFound{max_image_width});
614 $f->pnotes('height' => $ArrayCapFound{max_image_height});
615 $f->pnotes('device_claims_web_support' => $ArrayCapFound{device_claims_web_support});
616 $f->pnotes('is_wireless_device' => $ArrayCapFound{is_wireless_device});
617 $f->pnotes('is_transcoder' => $ArrayCapFound{is_transcoder});
618 } else {
619 #
620 # unknown device
621 #
622 $cacheSystem->store( 'wurfl-ua', $user_agent, "device_not_found");
623 if ($cookiecachesystem eq "true") {
624 $f->err_headers_out->set('Set-Cookie' => "amf=device_not_found; path=/;");
625 }
626 }
627 }
628 $f->subprocess_env("AMF_VER" => $VERSION);
629 $f->subprocess_env("AMF_WURFLVER" => $WURFLVersion);
630 return Apache2::Const::DECLINED;
631 }
632 1;
633 __END__