Notice: Undefined index: HTTP_ACCEPT in /var/local/cache/midgard/midgard/31-100-217-0.php(66) : eval()'d code on line 11

Blog: category "mobile"

Mobilephone browser detecting from PHP

Posted on 2009-04-17 10:07:34 EEST to .

While ago friend of me asked for a script to detect if site is browsed with mobile device.
There are lot of these around on the net and here is my contribution to that list.

Hopefully someone else find this usefull also:

 

public function is_mobile($include_iphone_and_ipod=true)
{
$mobile_browser = 0;
$user_agent = $this->get_value('_SERVER', 'HTTP_USER_AGENT');

if (preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone)/i', strtolower($user_agent))) {
$mobile_browser++;
}

if (! $include_iphone_and_ipod) {
if (preg_match('/(iphone|ipod)/i', strtolower($user_agent))) {
$mobile_browser--;
}
}

if ( (strpos(strtolower($this->get_value('_SERVER', 'HTTP_ACCEPT')),'application/vnd.wap.xhtml+xml')>0)
|| (( $this->has_value('_SERVER', 'HTTP_X_WAP_PROFILE')
|| $this->has_value('_SERVER', 'HTTP_PROFILE'))))
{
$mobile_browser++;
}

$mobile_ua = strtolower(substr($user_agent, 0, 4));
$mobile_agents = array(
'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac',
'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-',
'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',
'newt','noki','oper','palm','pana','pant','phil','play','port','prox',
'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',
'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-',
'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
'wapr','webc','winw','winw','xda','xda-'
);

if (in_array($mobile_ua, $mobile_agents)) {
$mobile_browser++;
}
if ( $this->has_value('_SERVER', 'ALL_HTTP')
&& strpos(strtolower($this->get_value('_SERVER', 'ALL_HTTP')), 'OperaMini') > 0)
{
$mobile_browser++;
}

if (strpos(strtolower($user_agent), 'windows') > 0) {
$mobile_browser = 0;
}

if ($mobile_browser > 0) {
return true;
}

return false;
}

Just added first version of mobile css

Posted on 2008-07-28 13:56:03 EEST to .

If one is to browse this website through phone browser they should see this page fitted on the phone screen.
This is currently tested on Nokia S60 series phones only. Widescreens doesn't show it right yet, but that will be done also after I get test machine for them.

Interesting taxi company

Posted on 2008-02-21 19:13:35 EET to .

Today when I was leaving from home to Helsinki I decided to take a taxi from my house to the train station.
For my supprise the Riihimäki taxi operator was a bit more enhanced than I could have imagined.
This is the call I made

Machine answers: Hello, finding your position now...
[After few seconds]
Machine: Calling nearest available taxi, please wait...
Taxi driver: I will be there in two minutes.
Me: Thank you.


I could believe this in Helsinki but not in Riihimäki which is really small town...
We are going to the right direction....

Finally got them working

Posted on 2008-01-23 21:35:49 EET to .

Today I got the complete stack working on my N800 device!

  • Erlang
  • ICU
  • CouchDB
  • Ajatus

They are far from perfect yet but I'm sure it'll get better little by little.
Currently I'm

  • preparing the packages for releasing them through maemo extras repository.
  • trying to compile the latest erlang R12.b.0 (now the package is R11.b.1)
  • adding dependencies to couchdb package
  • packaging Ajatus also

After first releases there are some possible tweaking to do... I still get some Segfaults at some points while using couchdb.

If someone would like to give this a try the hard way:
All the current packages can be found here http://protoblogr.net/downloads/erlang/

  1. Download and install erlang-base_11.b.1-1_armel.deb to the device (after download: dpkg -i  erlang-base_11.b.1-1_armel.deb)
  2. Download and install libicu36_3.6-2_armel.deb
  3. Download and install couchdb_0.7.2-1_armel.deb
  4. Get the latest release of Ajatus and follow it's installation instructions

There might be some dependencies which have to be manually installed. (Will be fixed later)
Currently the CouchDb installs itself to /usr and the databases are located at /usr/var/lib/couchdb.
I changed the DB path in /usr/etc/couchdb/couch.ini to point to my other memorycard (/media/mmc2/couchdb_db) which had some more space left.

Hopefully I get to release these as soon as possible for easier use.

Great thanks to the folks at #couchdb channel (nslater, jan,...)
And to Piotras

Finally got my N800

Posted on 2007-02-22 00:10:55 EET to .

Today it arrived...

Arrival

Thought I share the view...

Unpacking

Giving it some lifejuice...

First charge

 

Now I can start building and testing the Maemo Roadwarrior in a real machine instead of the scratchbox. I'll get some dev screenshots and sneak preview of the RoadWarrior on weekend... Till then, code in peace