Ejemplo n.º 1
0
 /**
  * Parses HTTP_USER_AGENT string.
  *
  * @param string $userAgent User-Agent string
  * @throws Net_UserAgent_Mobile_Error
  */
 function parse($userAgent)
 {
     @(list($main, $foma_or_comment) = explode(' ', $userAgent, 2));
     if ($foma_or_comment && preg_match('/^\\((.*)\\)$/', $foma_or_comment, $matches)) {
         // DoCoMo/1.0/P209is (Google CHTML Proxy/1.0)
         $this->_comment = $matches[1];
         $result = $this->_parseMain($main);
     } elseif ($foma_or_comment) {
         // DoCoMo/2.0 N2001(c10;ser0123456789abcde;icc01234567890123456789)
         $this->_isFOMA = true;
         list($this->name, $this->version) = explode('/', $main);
         $result = $this->_parseFOMA($foma_or_comment);
     } else {
         // DoCoMo/1.0/R692i/c10
         $result = $this->_parseMain($main);
     }
     if (Net_UserAgent_Mobile::isError($result)) {
         return $result;
     }
 }
Ejemplo n.º 2
0
 /**
  * Parses HTTP_USER_AGENT string.
  *
  * @param string $userAgent User-Agent string
  * @throws Net_UserAgent_Mobile_Error
  */
 function parse($userAgent)
 {
     $agent = explode(' ', $userAgent);
     preg_match('!^(?:(SoftBank|Semulator|Vodafone|Vemulator|J-PHONE|J-EMULATOR)/\\d\\.\\d|MOT-|MOTEMULATOR)!', $agent[0], $matches);
     if (count($matches) > 1) {
         $carrier = $matches[1];
     } else {
         $carrier = 'Motorola';
     }
     switch ($carrier) {
         case 'SoftBank':
         case 'Semulator':
         case 'Vodafone':
         case 'Vemulator':
             $result = $this->_parseVodafone($agent);
             break;
         case 'J-PHONE':
         case 'J-EMULATOR':
             $result = $this->_parseJphone($agent);
             break;
         case 'Motorola':
         case 'MOTEMULATOR':
             $result = $this->_parseMotorola($agent);
             break;
     }
     if (Net_UserAgent_Mobile::isError($result)) {
         return $result;
     }
     $this->_msname = $this->getHeader('X-JPHONE-MSNAME');
 }
Ejemplo n.º 3
0
 /**
  * return a textual error message for a Net_UserAgent_Mobile error code
  *
  * @param integer $value error code
  * @return string error message, or null if the error code was not recognized
  */
 function errorMessage($value)
 {
     static $errorMessages;
     if (!isset($errorMessages)) {
         $errorMessages = array(NET_USERAGENT_MOBILE_ERROR => 'unknown error', NET_USERAGENT_MOBILE_ERROR_NOMATCH => 'no match', NET_USERAGENT_MOBILE_ERROR_NOT_FOUND => 'not found', NET_USERAGENT_MOBILE_OK => 'no error');
     }
     if (Net_UserAgent_Mobile::isError($value)) {
         $value = $value->getCode();
     }
     return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[NET_USERAGENT_MOBILE_ERROR];
 }
Ejemplo n.º 4
0
 /**
  * EC-CUBE がサポートする携帯端末かどうかを判別する。
  *
  * @return boolean サポートしている場合は true、それ以外の場合は false を返す。
  */
 function isSupported()
 {
     $objAgent =& Net_UserAgent_Mobile::singleton();
     // 携帯端末だと認識されたが、User-Agent の形式が未知の場合
     if (Net_UserAgent_Mobile::isError($objAgent)) {
         GC_Utils_Ex::gfPrintLog($objAgent->toString());
         return false;
     }
     if ($objAgent->isDoCoMo()) {
         $arrUnsupportedSeries = array('501i', '502i', '209i', '210i');
         $arrUnsupportedModels = array('SH821i', 'N821i', 'P821i ', 'P651ps', 'R691i', 'F671i', 'SH251i', 'SH251iS');
         return !in_array($objAgent->getSeries(), $arrUnsupportedSeries) && !in_array($objAgent->getModel(), $arrUnsupportedModels);
     } elseif ($objAgent->isEZweb()) {
         return $objAgent->isWAP2();
     } elseif ($objAgent->isVodafone()) {
         return $objAgent->isPacketCompliant();
     } else {
         // 携帯端末ではない場合はサポートしていることにする。
         return true;
     }
 }
 /**
  * EC-CUBE がサポートする携帯キャリアかどうかを判別する。 
  * 
  * ※一部モジュールで使用。ただし、本メソッドは将来的に削除しますので新規ご利用は控えてください。
  * 
  * @return boolean サポートしている場合は true、それ以外の場合は false を返す。 
  */
 function isMobile()
 {
     $objAgent =& Net_UserAgent_Mobile::singleton();
     if (Net_UserAgent_Mobile::isError($objAgent)) {
         return false;
     } else {
         return $objAgent->isDoCoMo() || $objAgent->isEZweb() || $objAgent->isVodafone();
     }
 }
Ejemplo n.º 6
0
 /**
  * constructor
  *
  * @param string $userAgent User-Agent string
  */
 function Net_UserAgent_Mobile_Common($userAgent)
 {
     parent::PEAR('Net_UserAgent_Mobile_Error');
     $result = $this->parse($userAgent);
     if (Net_UserAgent_Mobile::isError($result)) {
         $this->isError($result);
     }
     $this->_userAgent = $userAgent;
 }