A phpBB 3 iPhone Style Theme With Option to Disable

phpBB iPhone theme styleA forum that I am an adminstrator for has been clamoring for an iPhone theme (style) for a long time now. In the past, I hadn’t seen any usable iPhone template for phpBB3, until now.

The theme is hosted on Google code and is named phpbb-iphone-style. It is downloadable here and was last updated June 18th, as of today.

The theme works wonderfully on the iPhone. However, the issue that I ran into is automatically displaying it for mobile browsers, such as the iPhone, Android and other platforms.

Fortunately there is a modification you can make to the phpbb code which is effectively a theme switcher for mobile browsers. The how to is located within the download file for the theme above.

What if a user wants to turn off the mobile style?

I modified the code to allow a user to set an option on their profile to permentently disable the theme when logged in on a mobile browser.

First, install the style as described above. As part of the switcher, you need to find out the theme ID. You can do so, after installing the style, by hovering over the ‘Detail’ tab in the ACP (Administrator Control Panel) and looking for the ‘id’ variable. In the example below it is ’6′.

Once the theme is installed, move over to the “Users and Groups” tab, and then the “Custom Profile Fields” area. At the bottom of this page there is a box to add a new profile field. Type ‘disable_mobile’ as the name, and Boolean (Yes/No) as the type and click add.

For the options, I selected:

  • Publicly display profile field: No
  • Display in user control panel: Checked
  • Display on registration screen: Unchecked
  • Display on viewtopic screen: Unchecked
  • Required field: Unchecked
  • Hide profile field: Unchecked
  • Field name/title presented to the user: Disable Mobile Browser
  • Field description: When viewing on a mobile device (iPhone, Android, etc), clicking ‘yes’ will disable the mobile browser.
  • Entries: First option: Yes, Second option: No

On the second screen select the following items:

  • Field type: Radio Buttons
  • Default value: no

Save your custom profile field.

It will end up looking like this in the profile control panel of the end user:

phpbb iphone style disabler

Now the fun part, adding the code to your install to select which mobile browser to use automatically.

Back up, then open install dir/includes/session.php

Around line 1468 in the function setup

        /**
        * Setup basic user-specific items (style, language, ...)
        */
        function setup($lang_set = false, $style = false)
        {

Replace

global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;

with

global $db, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache, $user;

//-----Begin phone detection & redirection code-----

                $user->get_profile_fields( $user->data['user_id'] );
                $user_fields = $user->profile_fields;

                if (!($user_fields['pf_disable_mobile'] == 1)) {  

                        //id of the iphone/mobile theme - SELECT THIS FROM YOUR STYLES
                        $mobilestyleid = 6;

                        //Fetch the users browser
                        $user_browser = strtolower($this->browser);

                        //List of mobile user-agent keywords
                        $browsers_array = array('240x320', '320x240','blackberry', 'iemobile', 'minimobile', 'mobile', 'opera mini', 'pda', 'phone', 'pocket', 'psp', 'symbian', 't-shark', 'wireless');

                        //Check for the user-agent in the list of mobile user-agents
                        foreach ($browsers_array as $ua_match) {
                                if (strpos($user_browser, $ua_match) !== false) {  //a match
                                        $style = $mobilestyleid;
                                        $this->data['is_mobile'] = true;
                                        break;
                                }
                        }

                }

                //-----End phone detection/redirection code-----

Make sure to replace $mobilestyleid = 6 with your style id number!

Save your file. Test out the modifications on your phone, you should be presented with the mobile version on reload (make sure to purge any cache if you don’t see it right away).

Finally go into your profile and select the ‘disable mobile browser’ option and make sure it reverts back to your regular default theme.

Let me know if you have any problems implementing this but it has worked great for this phpbb forum!

Walled Gardens and Currency

Walled Gardens are never very effective. They may work for a period of time to isolate a nation or organization, but they inevitably fail. On the short list that comes to mind: The Great Wall of China, U.S. Isolationism in the 19th Century and AOL in the 90′s.

Countries, by very definition, are walled gardens. Each has its own rules, laws and customs; and each defines and fights for their border. In the offline world, this may work. However, online and via the internet, these restrictions are reduced to almost nothing. Something that is legal in your country may be illegal in another, and through technology the internet may me accessed from anywhere on earth.

Currency is yet another walled garden. You have a way to pay for products or services, yet a certain type of money is only good in a certain area. To use multiple currencies you need to calculate an exchange rate, and convert that currency. This is an inefficient way to basically compensate someone for a service or physical item across borders.

I believe that the world is ripe for a global cross border currency. Countries are unable to issue such a cross-border product because they will always have their own interests at hand. Many times countries have vied to have ‘their’ currency become the standard one. The closest thing we have to that now is the Euro, which you might actually consider once of the first cross-border currencies and a precursor to the next big thing.

Companies on the other hand, specifically internet non-physical companies such as Google, Twitter and the like, do not have these physical restrictions. On the world-wide internet, such sites are generally accessible equally unless a country outright blocks them. A ‘Google’ or other online currency which is valid for online services only, could become a standard payment system across the internet. Google has been on a purchasing spree of companies dealing with just this topic.

Gaming systems already have these payment systems in place. Many MMORPGs have currency which is only valid in-game. Since money is created in-game and also spent in game it does not matter what country you are from and what your real currency situation is like. Cory Doctorow recently wrote about this very situation in his fictional book For The Win (it is downloadable for free).

An internet currency would work much the same way. Let’s say you are providing some service online, and you are paid with this online internet currency. You can then use the currency to pay other people for your services. The idea of an internet based currency is not new, but I think the idea has come around recently.

I think the world is ripe for such an online currency. Only a company with a sterling reputation can pull it off, because the stability of this internet currency is innately tied into whether an individual ‘buying into’ the system can rely on that money to be there in a year or 10 years. Only a few companies have that reputation, and Google is one of them. Otherwise you have problems such as the ones at the beginning of last decade with Flooz’s issues.

Was Flooz just ahead of its time? We will soon find out.

Another Bash One Liner To Delete Old Directories

We received a tip from blog readers Christian and Michael for alternatives to the command to delete all directories older than a certain period of time. These both work in bash and can be used in scripts to clean up old backup directories or any situation where you need to delete old directories from the command line.

From Christian:

find /home/backup/ -maxdepth 1 -type d -mtime +7 -exec rm -r {} \;

From Michael:

find /home/backup/ -maxdepth 1 -type d -mtime +7 -exec echo “Removing Directory => {}” \; -exec rm -rf “{}” \;

The first one works quietly, while the second one will display what is being deleted. These are probably faster than putting it into a for loop, so feel free to use whatever works best in your particular situation!

Thoughts On the Google TV Platform

Just watched the Google IO stream regarding the release of Google TV.  My thoughts:

Good:

  • The platform is open. This is the way to go, and will allow developers to go hog wild and develop things that even the Google engineers couldn’t envision.
  • TV/Web Integration. The Google TV platform appears to have great web and video integration, including live TV. The overlays look beautiful and web/TV switches effortlessly. But that basically makes it WebTV.
  • Working with hardware partners. This gives the platform a much better chance of seeing the light of day. It appears they are working with Sony, Dish, Logitech and other hardware companies.
  • The Android market. Integration with this means you already have tons of apps at your disposal on your system.
  • Search integration. Will make it easy to find both local and online content.

Bad:

  • Needing an existing cablebox to bring in live TV. This is an uncessessary step – you should be able to bring in Live TV streams using a CableCard. Could support for this be forthcoming?
  • Uses existing TV infrastructure. The future is in IP TV.

Questions:

  • How expensive will the box be and will it be available from cable/satellite providers? If available from television providers (at least Dish) then it will be available for a monthly ‘rental’ fee. If Google tries to sell this as a stand-alone product, ala Tivo, it will be a bigger up-front cost that many consumers are not used to paying. However, Google may be able to make this cheaper than we think, because they subsidize services from ad revenue. Advertisers are willing to pay for information such as what viewers are watching. Google will be sitting on a goldmine of data.
  • How will this impact other “Television” set tops such as Tivo, BeyondTV, Boxee, MythTV? It greatly depends on adoption rates, cost and utility.

Regarding the issue with the existing TV infrastructure, this product could be revolutionary. I’m not sure if this is because they are trying to avoid stepping on the big cable providers toes but with a device like this the existing cable network is unnecessary. Google owns a lot of fiber, and therefore a lot of bandwidth. They could offer their own live IPTV offering, and it could be available directly on the Google TV platform. This is probably where they are aiming to go in 2 or more years. Its prohibitive to many companies at a reasonable rate because the cost to stream high definition television to many homes is great.

YouTube essentially already has the infrastructure in place for IPTV. They already have the ability to stream any live video stream in fairly decent quality. I imagine what is holding them back if the agreements with the content providers (channels) like Discovery, MTV, NBC Universal, etc. If the old don’t get on board soon, they will be in 5-10 years where the newspaper industry is now.

I am looking forward to what the Google TV platform is going to offer. A bonus would be if you could run it on additional hardware other than hardware offered by Sony or other companies. Since it is open source, this is a distinct possibility and we could see a lot come from this, even if the hardware itself proves unsuccessful. There is one thing Google has a lot of — vision — and it would be great to see that on your television.

One Line Linux Command to Print Out Directory Tree Listing

My professor sent us this little one liner (ok, I had to format it to 2 lines to fit in this blog. You know what I mean) which prints out the current directory tree:

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' \
-e 's/^/ /' -e 's/-/|/'

What’s going on here?
Read More »