-
Notifications
You must be signed in to change notification settings - Fork 0
AMF51DegreesFilter
Overview
The AMF51DegreesFilter and AMF51DegreesFilterMemcached are the modules of the suite they have the job to detect the device take the information from 51Degrees (http://www.51Degrees.mobi) and pass the capabilities to the other AMF modules and as environment variables. The different between the first (AMF51DegreesFilter) and the second (AMF51DegreesFilterMemcached) is the cache system.
Both modules does this two steps:
*load AMF parameters from httpd.conf *load data from 51Degrees.xml *and waiting for a useragent
AMF51DegreesFilter
The first step is to define the AMFMobileHome this is important for AMF because in this directory the AMF store the 51Degrees.xml and the patch file (the patch file is an xml where are store the PC browser). The patch file is recommended to use.
In httpd.conf of Apache you define this parameter:
PerlSetEnv AMFMobileHome /home/AMF
where AMFMobileHome must be writeable. In the AMFMobileHome directory must be store the 51Degrees.xml .
Settings for production environment
51Degrees for each mobile devices has more the 400 capabilities and normally for each mobile project don’t need all of them, so is suggested on the live web server to specify which capability you want to manage, the directive CapabilityList (default is set all):
PerlSetEnv CapabilityList brand_name,model_name,max_image_width
In this case you ask to AMF to manage only three capability, the list of all capability ask support at 51Degrees site (http://www.51Degrees.com)
To increase performance on DeviceDetection is suggested to use the directive AMFProductionMode (default is false). In this mode the device has been detected only the first time that access on web server. In this mode the performance will be higher. The syntax is:
PerlSetEnv AMFProductionMode true
Pass User Agent on query string
This directive must be setted if you want to pass the user agent in query string, the syntax is to set RestMode (default is false):
PerlSetEnv RestMode true
In this mode it’s possible to pass the useragent on query string using the amf the sintax is:
?amf=
for example:
http://www.apachemobilefilter.org/searchEngine.php?amf=Nokia3650
Virtual Host If you have multiple virtual hosts and you need different configuration of AMF for each host remember to set this configuration in httpd.conf:
PerlOptions +Parent
so in httpd.conf the syntax is:
PerlOptions +Parent ServerName default UseCanonicalName Off DocumentRoot /var/www/vhosts/default/htdocs ScriptAlias /cgi-bin/ "/var/www/vhosts/default/cgi-bin/" SSLEngine off # # AMF configuration # PerlSetEnv AMFMobileHome /root/AMF_home PerlSetEnv CacheDirectoryStore /tmp PerlSetEnv ResizeImageDirectory /tmp PerlTransHandler +Apache2::AMF51DegreesFilter SetHandler modperl PerlOutputFilterHandler Apache2::AMFImageRendering php_admin_flag engine on php_admin_flag safe_mode on php_admin_value open_basedir "/var/www/vhosts/default/htdocs:/tmp" php_admin_flag engine on php_admin_flag safe_mode on php_admin_value open_basedir "/var/www/vhosts/default/htdocs:/tmp"
Choose the cache system
AMF has two advanced cash system based on:
- FileSystem
- Memcached
File System
f you choose to adopted the file system caching you only need to configure the CacheDirectoryStore parameter, this directory must be writable we suggest to not use the /tmp directory in production servers. The syntax is:
PerlSetEnv CacheDirectoryStore /tmp PerlTransHandler +Apache2::AMF51DegreesFilter
The last directive load the module.
Memcached
For memcached it’s need to configure ServerMemCached the syntax is:
PerlSetEnv ServerMemCached address:port,address2:port,....,addressn:port
for example:
PerlSetEnv ServerMemCached localhost:11211,10.10.10:11233 PerlTransHandler +Apache2::AMF51DegreesFilterMemcached
The last directive load the module.
File:AMF51DegreesFIlterMemcached.jpg
How can I retrieve the values of the capabilities of 51Degrees ?
Retrieve the 51Degrees capabilities value is very simple, all the informations are setting into the Apache Environment as AMF_<uppercase 51Degrees capabilities name> for example:
To read the 51Degrees capabilities ScreenPixelHeight you must read the environment value AMF_SCREENPIXELSHEIGHT.
How to read environment in PHP ?File:php.jpg
The php code is:
$_SERVER['AMF_SCREENPIXELSHEIGHT'];
a test page in php is downloadable:
How to read the value in JSP (for Tomcat)? File:Tomcat.jpg
Before in the httpd.conf file where you have configure mod_jk you muse add this:
JkEnvVar AMF_SCREENPIXELSHEIGHT undefined
The Java code is:
request.getAttribute("AMF_SCREENPIXELSHEIGHT")
How to read the value in PERL? File:Cpan2.png
print $ENV('AMF_MAX_IMAGE_HEIGHT');
Tutorial