Results 1 to 1 of 1

Thread: Device Detection using Andy Moores Script

  1. #1
    Mobility Regular texasgamer's Avatar
    Join Date
    Jun 2007
    Location
    Corpus Christi Texas
    Posts
    276

    Thumbs up Device Detection using Andy Moores Script

    After lots of headbanging, spitting and cussing, this is what I did to get device detection working on my one of my sites (namebook.mobi).
    This tutorial is really basic and its geared towards beginners. There may be better ways, but this is what worked for me:

    Please take all the standard precautions, like backing up your files ect...

    Download Andy Moores script here:

    http://www.andymoore.info/php-to-detect-mobile-phones/

    Unzip the file (theres only one) and its called php-to-detect-mobile-phones.php
    After you have unzipped this file, you can open it with a regular text editor such as windows notepad.
    Edit the script with your site information. Its towards the bottom of the script. I have used my site namebook.mobi as an example.

    // example 1 - detect and redirect mobile browsers
    if(detect_mobile_device()){
    header('Location: http://namebook.mobi/mobile/');
    exit;
    }

    // example 2 - detect and redirect desktop browsers
    if(!detect_mobile_device()){
    header('Location: http://namebook.mobi/pc/');
    exit;

    Save the edited file and then rename it to: index.php
    You then need to access your server with an FTP program (I use Smart ftp).
    Navigate to the site directory that you want to have device detection on (for example: namebook.mobi).

    In this directory create two new folders. Name one of the folders mobile and the other one call it pc.
    You will need to copy all your site directory files into the mobile folder and then also copy them into the pc folder.

    Next, delete your main site files (because you just copied them into the two other folders).
    You do not need to delete robots.txt, .htaccess, cgi-bin, or .ftpquota. Just the unnecessary site files. If you are not sure - ask!

    Next upload Andy Moores device detection script (index.php) to your site directory.
    For instance: I uploaded it to my namebook directory.
    Here is whats in my namebook directory now:
    a folder called mobile (contains all my mobile site files)
    a folder called pc (contains all my pc site files)
    a file called index.php (the device dectection script)
    a file called cgi-bin
    a file called .ftpquota
    a file called .htaccess
    a file called robots.txt

    Now comes the fun part. You can go into your mobile folder and edit your site for proper mobile viewing and then open your pc folder and edit its site files for proper pc viewing. This may include editing your .css files and adsense code which is beyond the scope of this tut.

    If you have done everything properly it should work!

Similar Threads

  1. Hello from Bango Andy
    By Bango Andy in forum Introductions
    Replies: 6
    Last Post: 04-10-2008, 12:44 AM
  2. US Lottery Script
    By developmy.mobi in forum .mobi's For Sale - Offers Wanted
    Replies: 2
    Last Post: 12-19-2007, 06:46 PM
  3. FREE SCRIPT OF THE DAY - September 17, 2007 - Mobile Horoscope Script
    By mykel241 in forum .mobi's For Sale - Offers Wanted
    Replies: 0
    Last Post: 09-17-2007, 03:29 PM
  4. FREE SCRIPT OF THE DAY - September 16, 2007 - Mobile Forum Script/dnBoard.mobi clone
    By mykel241 in forum .mobi's For Sale - Offers Wanted
    Replies: 0
    Last Post: 09-16-2007, 04:38 PM
  5. FREE SCRIPT OF THE DAY - September 15, 2007 - Mobile Search/Directory Script
    By mykel241 in forum .mobi's For Sale - Offers Wanted
    Replies: 2
    Last Post: 09-16-2007, 07:24 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
A Yup.mobi Mobile Site
Mobile Dating