File: 0.00.1a/core/BrowserDetect.php (View as HTML)

  1: <?php
  2: /* -------------------------------------------------------------
  3: This file is part of FreeDESK
  4: 
  5: FreeDESK is (C) Copyright 2012 David Cutting
  6: 
  7: FreeDESK is free software: you can redistribute it and/or modify
  8: it under the terms of the GNU General Public License as published by
  9: the Free Software Foundation, either version 3 of the License, or
 10: (at your option) any later version.
 11: 
 12: FreeDESK is distributed in the hope that it will be useful,
 13: but WITHOUT ANY WARRANTY; without even the implied warranty of
 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 15: GNU General Public License for more details.
 16: 
 17: You should have received a copy of the GNU General Public License
 18: along with FreeDESK.  If not, see www.gnu.org/licenses
 19: 
 20: For more information see www.purplepixie.org/freedesk/
 21: -------------------------------------------------------------- */
 22: 
 23: /**
 24:  * Browser detection
 25: **/
 26: class BrowserDetect
 27: {
 28: 	/**
 29: 	 * Check if the browser is mobile
 30: 	 * @return bool True if we think it is
 31: 	**/
 32: 	static function isMobile()
 33: 	{
 34: 		$mobAgents = array(
 35: 			"sony", "symbian", "nokia", "samsung", "mobile", "windows ce",
 36: 			"epoc", "opera mini", "nitro", "j2me", "midp-", "cldc-",
 37: 			"netfront", "mot", "up.browser", "up.link", "audiovox",
 38: 			"blackberry", "ericsson", "philips", "sanyo", "sharp",
 39: 			"series60", "palm", "pocketpc", "smartphone", "rover", "ipaq",
 40: 			"alcatel", "vodafone/", "wap1.", "wap2.", "android");
 41: 		$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
 42: 		foreach($mobAgents as $agent)
 43: 		{
 44: 			if (strpos(	$userAgent, $agent ) !== false)
 45: 				return true;
 46: 		}
 47: 		
 48: 		return false;
 49: 	}
 50: }
 51: ?>			
 52: