/** * &factory() * * @access public * @param mixed $mUserAgent string | null * @return mixed BlockenMobile | PEAR_Error */ function &factory($mUserAgent = null) { if (is_null($mUserAgent)) { $mUserAgent = $_SERVER['HTTP_USER_AGENT']; } $sDriver = 'NonMobile'; if (BlockenMobile::isDoCoMo($mUserAgent)) { $sDriver = 'DoCoMo'; } else { if (BlockenMobile::isEZweb($mUserAgent)) { $sDriver = 'EZweb'; } else { if (BlockenMobile::isSoftBank($mUserAgent)) { $sDriver = 'SoftBank'; } } } foreach ($_SERVER as $sKey => $sValue) { if (preg_match('/^HTTP_X_EMULATOR_/', $sKey)) { $sTmp = str_replace('EMULATOR', 'JPHONE', $sKey); $_SERVER[$sTmp] = $sValue; } } $sClass = "BlockenMobile_{$sDriver}"; if (!class_exists($sClass)) { $sFile = str_replace('_', '/', $sClass) . '.php'; if (!(include_once $sFile)) { return PEAR::raiseError(null, NET_USERAGENT_MOBILE_ERROR_NOT_FOUND, null, null, "Unable to include the {$sFile} file", 'Net_UserAgent_Mobile_Error', true); } } $objInstance =& new $sClass($mUserAgent); $objError =& $objInstance->isError(); if (BlockenMobile::isError($objError)) { if ($GLOBALS['_NET_USERAGENT_MOBILE_FALLBACK_ON_NOMATCH'] && NET_USERAGENT_MOBILE_ERROR_NOMATCH == $objError->getCode()) { $objInstance =& BlockenMobile::factory('Net_UserAgent_Mobile_Fallback_On_NoMatch'); return $objInstance; } $objInstance =& $objError; } return $objInstance; }