It is currently Wed Mar 20, 2019 4:28 pm

Site Updates

Mobile Theme

Site updates, forum rules, notices

Mobile Theme

Postby Lankin » Tue Jun 12, 2012 11:03 pm

With the gracious help of Benjamin, I set up a mobile theme for the forum now.


There are several reasons why I chose to do it. First, the regular theme requires a lot of zooming and shoving the page around on your mobile, which is a major nuisance.

More importantly yet, on older phones, there is no reply button, which of course is unacceptable. This circumstance alone cut me off from the Bunny the last two days!

If you want to do nifty things, like quoting and using BBCode, you still have to switch, I guess -- you can easily do so on the main page -- uploading attachments works though.

However, there is one remaining issue to fix yet:

PHP-Geeks, Read On

In common speech, I would need a query as following:

Forum: "Who are you?
iPhone: "Hey, I'm an Android/iPhone"
Forum: "ty" *redirecting from to, skipping the portal.

So, it would be something like this, and it usually goes into the header:

header('HTTP/1.1 301 Moved Permanently');
header('Location: /index.php');
header('Connection: close');

Obviously, if put in the header, which means it gets read before everything else, it gets universally applied, and that's exactly what I don't want. I want it sensitive concerning the user agent (the device and browser used). So, obviously, the query "Who are you?" has to come before.

My closest suspect concerning where to add the optional redirect would be the file includes/session.php. (That's where I added the query for the user agent.)

// MOD start: Mobile/SEO style
* Check for mobile/seo, get style
function check_mobile($sql, $style)
$browser = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
if (empty($this->data['is_bot']) && strpos($browser, 'Mobile') === false && strpos($browser, 'Symbian') === false && strpos($browser, 'Opera M') === false && strpos($browser, 'Android') === false && stripos($browser, 'HTC_') === false && strpos($browser, 'Fennec/') === false && stripos($browser, 'Blackberry') === false && strpos($browser, 'Windows Phone') === false && strpos($browser, 'WP7') === false && strpos($browser, 'WP8') === false)
return true;
define('MOBILE_DEVICE', true);
define('MOBILE_DEVICE_OFF', true);
return true;

Code via

If someone would have any significant skill or instinct in wording this in PHP -- suggestions are welcome. *)

*Yes, I am looking at you, lankinforcedme, and your soulmate. ;)
User avatar
Posts: 800
Joined: Sun Jan 01, 2012 9:08 pm

Return to Site Updates

Who is online

Users browsing this forum: No registered users and 1 guest