+ // If they like the WAP 2.0 mimetype, serve them MP
+ if (strstr('application/vnd.wap.xhtml+xml', $type) !== false) {
+ $this->serveMobile = true;
+ }
+ else {
+ // If they are a mobile device that supports WAP 2.0,
+ // serve them MP
+
+ // XXX: Browser sniffing sucks
+
+ // I really don't like going through this every page,
+ // find a better way
+
+ // May be better to categorize the devices in terms of
+ // low,mid,high-end
+
+ // Or, detect the mobile devices based on their support for
+ // MP 1.0, 1.1, or 1.2 may be ideal. Possible?
+
+ $this->mobiledevices =
+ array('alcatel', 'android', 'audiovox', 'au-mic,',
+ 'avantgo', 'blackberry', 'blazer', 'cldc-', 'danger',
+ 'epoc', 'ericsson', 'ericy', 'ipone', 'ipaq', 'j2me',
+ 'lg', 'midp-', 'mobile', 'mot', 'netfront', 'nitro',
+ 'nokia', 'opera mini', 'palm', 'palmsource',
+ 'panasonic', 'philips', 'pocketpc', 'portalmmm',
+ 'rover', 'samsung', 'sanyo', 'series60', 'sharp',
+ 'sie-', 'smartphone', 'sony', 'symbian',
+ 'up.browser', 'up.link', 'up.link', 'vodafone',
+ 'wap1', 'wap2', 'windows ce');
+
+ $httpuseragent = strtolower($_SERVER['HTTP_USER_AGENT']);
+
+ foreach($this->mobiledevices as $md) {
+ if (strstr($httpuseragent, $md) !== false) {
+ $this->serveMobile = true;
+ break;
+ }
+ }
+ }
+
+ // If they are okay with MP, and the site has a mobile server,
+ // redirect there
+ if ($this->serveMobile &&
+ common_config('site', 'mobileserver') !== false &&
+ (common_config('site', 'mobileserver') !=
+ common_config('site', 'server'))) {
+
+ // FIXME: Redirect to equivalent page on mobile site instead
+ header("Location: ".$this->_common_path(''));
+ exit();
+ }
+ }
+
+ if (!$this->serveMobile) {