-
Notifications
You must be signed in to change notification settings - Fork 0
AMFDetectRightFilterMemcached
Overview
The AMFDetectRightFilter and AMFDetectRightFilterMemcached are the modules of the suite they have the job to detect the device take the information from DetectRight (http://www.detectright.com) and pass the capabilities to the other AMF modules and as environment variables. The different between the first (AMFDetectRightFIlter) and the second (AMFDetectRightFilterMemcached) is the cache system.
Both modules does this two steps:
*load AMF parameters from httpd.conf *load data from DetectRightAMF.xml *and waiting for a useragent
AMFDetectRightFilter
The first step is to define the AMFMobileHome this is important for AMF because in this directory the AMF store the DetectRight.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 DetectRight.xml .
Settings for production environment
DetectRight 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 DetectRight site (http://www.detectright.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::AMFDetectRightFilter
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
- [http://www.memcached.org- 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::AMFDetectRightFilter
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::AMFDetectRightFilterMemcached
The last directive load the module.
File:AMFDetectRightFIlterMemcached.jpg
How can I retrieve the values of the capabilities of DetectRight ?
Retrieve the DetectRight capabilities value is very simple, all the informations are setting into the Apache Environment as AMF_ for example:
To read the DetectRight capabilities max_image_height you must read the environment value AMF_MAX_IMAGE_HEIGHT.
How to read environment in PHP ?File:php.jpg
The php code is:
$_SERVER['AMF_MAX_IMAGE_HEIGHT'];
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 to configure mod_jk you muse add this:
JkEnvVar AMF_MAX_IMAGE_HEIGHT undefined
The Java code is:
request.getAttribute("AMF_MAX_IMAGE_HEIGHT")
How to read the value in PERL? File:Cpan2.png
print $ENV('AMF_MAX_IMAGE_HEIGHT');
Tutorial