Ignore:
Timestamp:
2007/10/29 12:06:29 (19 years ago)
Author:
nanasess
Message:

ライセンス表記変更

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/feature-module-update/data/class/SC_MobileUserAgent.php

    r16329 r16582  
    11<?php 
    2 /** 
    3  *  
     2/* 
     3 * This file is part of EC-CUBE 
     4 * 
    45 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved. 
    56 * 
    67 * http://www.lockon.co.jp/ 
    7  *  
     8 * 
     9 * This program is free software; you can redistribute it and/or 
     10 * modify it under the terms of the GNU General Public License 
     11 * as published by the Free Software Foundation; either version 2 
     12 * of the License, or (at your option) any later version. 
     13 * 
     14 * This program is distributed in the hope that it will be useful, 
     15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     17 * GNU General Public License for more details. 
     18 * 
     19 * You should have received a copy of the GNU General Public License 
     20 * along with this program; if not, write to the Free Software 
     21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
    822 */ 
    923require_once(dirname(__FILE__) . '/../module/Net/UserAgent/Mobile.php'); 
     
    1630 */ 
    1731class SC_MobileUserAgent { 
    18     /** 
    19     * 携帯端末のキャリアを表す文字列を取得する。 
    20     * 
    21     * 文字列は docomo, ezweb, softbank のいずれか。 
    22     * 
    23     * @return string|false 携帯端末のキャリアを表す文字列を返す。 
    24     *                      携帯端末ではない場合は false を返す。 
    25     */ 
    26     function getCarrier() { 
    27         $objAgent =& Net_UserAgent_Mobile::singleton(); 
    28         if (Net_UserAgent_Mobile::isError($objAgent)) { 
    29             return false; 
    30         } 
     32    /** 
     33    * 携帯端末のキャリアを表す文字列を取得する。 
     34    * 
     35    * 文字列は docomo, ezweb, softbank のいずれか。 
     36    * 
     37    * @return string|false 携帯端末のキャリアを表す文字列を返す。 
     38    *                      携帯端末ではない場合は false を返す。 
     39    */ 
     40    function getCarrier() { 
     41        $objAgent =& Net_UserAgent_Mobile::singleton(); 
     42        if (Net_UserAgent_Mobile::isError($objAgent)) { 
     43            return false; 
     44        } 
    3145 
    32         switch ($objAgent->getCarrierShortName()) { 
    33         case 'I': 
    34             return 'docomo'; 
    35         case 'E': 
    36             return 'ezweb'; 
    37         case 'V': 
    38             return 'softbank'; 
    39         default: 
    40             return false; 
    41         } 
    42     } 
     46        switch ($objAgent->getCarrierShortName()) { 
     47        case 'I': 
     48            return 'docomo'; 
     49        case 'E': 
     50            return 'ezweb'; 
     51        case 'V': 
     52            return 'softbank'; 
     53        default: 
     54            return false; 
     55        } 
     56    } 
    4357 
    44     /** 
    45     * 勝手サイトで利用可能な携帯端末/利用者のIDを取得する。 
    46     * 
    47     * 各キャリアで使用するIDの種類: 
    48     * + docomo   ... UTN 
    49     * + ezweb    ... EZ番号 
    50     * + softbank ... 端末シリアル番号 
    51     * 
    52     * @return string|false 取得したIDを返す。取得できなかった場合は false を返す。 
    53     */ 
    54     function getId() { 
    55         $objAgent =& Net_UserAgent_Mobile::singleton(); 
    56         if (Net_UserAgent_Mobile::isError($objAgent)) { 
    57             return false; 
    58         } elseif ($objAgent->isDoCoMo() || $objAgent->isVodafone()) { 
    59             $id = $objAgent->getSerialNumber(); 
    60         } elseif ($objAgent->isEZweb()) { 
    61             $id = @$_SERVER['HTTP_X_UP_SUBNO']; 
    62         } 
    63         return isset($id) ? $id : false; 
    64     } 
     58    /** 
     59    * 勝手サイトで利用可能な携帯端末/利用者のIDを取得する。 
     60    * 
     61    * 各キャリアで使用するIDの種類: 
     62    * + docomo   ... UTN 
     63    * + ezweb    ... EZ番号 
     64    * + softbank ... 端末シリアル番号 
     65    * 
     66    * @return string|false 取得したIDを返す。取得できなかった場合は false を返す。 
     67    */ 
     68    function getId() { 
     69        $objAgent =& Net_UserAgent_Mobile::singleton(); 
     70        if (Net_UserAgent_Mobile::isError($objAgent)) { 
     71            return false; 
     72        } elseif ($objAgent->isDoCoMo() || $objAgent->isVodafone()) { 
     73            $id = $objAgent->getSerialNumber(); 
     74        } elseif ($objAgent->isEZweb()) { 
     75            $id = @$_SERVER['HTTP_X_UP_SUBNO']; 
     76        } 
     77        return isset($id) ? $id : false; 
     78    } 
    6579 
    66     /** 
    67     * 携帯端末の機種を表す文字列を取得する。 
    68     * 携帯端末ではない場合はユーザーエージェントの名前を取得する。(例: "Mozilla") 
    69     * 
    70     * @return string 携帯端末のモデルを表す文字列を返す。 
    71     */ 
    72     function getModel() { 
    73         $objAgent =& Net_UserAgent_Mobile::singleton(); 
    74         if (Net_UserAgent_Mobile::isError($objAgent)) { 
    75             return 'Unknown'; 
    76         } elseif ($objAgent->isNonMobile()) { 
    77             return $objAgent->getName(); 
    78         } else { 
    79             return $objAgent->getModel(); 
    80         } 
    81     } 
     80    /** 
     81    * 携帯端末の機種を表す文字列を取得する。 
     82    * 携帯端末ではない場合はユーザーエージェントの名前を取得する。(例: "Mozilla") 
     83    * 
     84    * @return string 携帯端末のモデルを表す文字列を返す。 
     85    */ 
     86    function getModel() { 
     87        $objAgent =& Net_UserAgent_Mobile::singleton(); 
     88        if (Net_UserAgent_Mobile::isError($objAgent)) { 
     89            return 'Unknown'; 
     90        } elseif ($objAgent->isNonMobile()) { 
     91            return $objAgent->getName(); 
     92        } else { 
     93            return $objAgent->getModel(); 
     94        } 
     95    } 
    8296 
    83     /** 
    84     * EC-CUBE がサポートする携帯キャリアかどうかを判別する。 
    85     * 
    86     * @return boolean サポートしている場合は true、それ以外の場合は false を返す。 
    87     */ 
    88     function isMobile() { 
    89         $objAgent =& Net_UserAgent_Mobile::singleton(); 
    90         if (Net_UserAgent_Mobile::isError($objAgent)) { 
    91             return false; 
    92         } else { 
    93             return $objAgent->isDoCoMo() || $objAgent->isEZweb() || $objAgent->isVodafone(); 
    94         } 
    95     } 
     97    /** 
     98    * EC-CUBE がサポートする携帯キャリアかどうかを判別する。 
     99    * 
     100    * @return boolean サポートしている場合は true、それ以外の場合は false を返す。 
     101    */ 
     102    function isMobile() { 
     103        $objAgent =& Net_UserAgent_Mobile::singleton(); 
     104        if (Net_UserAgent_Mobile::isError($objAgent)) { 
     105            return false; 
     106        } else { 
     107            return $objAgent->isDoCoMo() || $objAgent->isEZweb() || $objAgent->isVodafone(); 
     108        } 
     109    } 
    96110 
    97     /** 
    98     * EC-CUBE がサポートする携帯キャリアかどうかを判別する。 
    99     * 
    100     * @return boolean 携帯端末ではない場合は true、それ以外の場合は false を返す。 
    101     */ 
    102     function isNonMobile() { 
    103         return !SC_MobileUserAgent::isMobile(); 
    104     } 
     111    /** 
     112    * EC-CUBE がサポートする携帯キャリアかどうかを判別する。 
     113    * 
     114    * @return boolean 携帯端末ではない場合は true、それ以外の場合は false を返す。 
     115    */ 
     116    function isNonMobile() { 
     117        return !SC_MobileUserAgent::isMobile(); 
     118    } 
    105119 
    106     /** 
    107     * EC-CUBE がサポートする携帯端末かどうかを判別する。 
    108     * 
    109     * @return boolean サポートしている場合は true、それ以外の場合は false を返す。 
    110     */ 
    111     function isSupported() { 
    112         $objAgent =& Net_UserAgent_Mobile::singleton(); 
     120    /** 
     121    * EC-CUBE がサポートする携帯端末かどうかを判別する。 
     122    * 
     123    * @return boolean サポートしている場合は true、それ以外の場合は false を返す。 
     124    */ 
     125    function isSupported() { 
     126        $objAgent =& Net_UserAgent_Mobile::singleton(); 
    113127 
    114         // 携帯端末だと認識されたが、User-Agent の形式が未知の場合 
    115         if (Net_UserAgent_Mobile::isError($objAgent)) { 
    116             gfPrintLog($objAgent->toString()); 
    117             return false; 
    118         } 
     128        // 携帯端末だと認識されたが、User-Agent の形式が未知の場合 
     129        if (Net_UserAgent_Mobile::isError($objAgent)) { 
     130            gfPrintLog($objAgent->toString()); 
     131            return false; 
     132        } 
    119133 
    120         if ($objAgent->isDoCoMo()) { 
    121             $arrUnsupportedSeries = array('501i', '502i', '209i', '210i'); 
    122             $arrUnsupportedModels = array('SH821i', 'N821i', 'P821i ', 'P651ps', 'R691i', 'F671i', 'SH251i', 'SH251iS'); 
    123             return !in_array($objAgent->getSeries(), $arrUnsupportedSeries) && !in_array($objAgent->getModel(), $arrUnsupportedModels); 
    124         } elseif ($objAgent->isEZweb()) { 
    125             return $objAgent->isWAP2(); 
    126         } elseif ($objAgent->isVodafone()) { 
    127             return $objAgent->isPacketCompliant(); 
    128         } else { 
    129             // 携帯端末ではない場合はサポートしていることにする。 
    130             return true; 
    131         } 
    132     } 
     134        if ($objAgent->isDoCoMo()) { 
     135            $arrUnsupportedSeries = array('501i', '502i', '209i', '210i'); 
     136            $arrUnsupportedModels = array('SH821i', 'N821i', 'P821i ', 'P651ps', 'R691i', 'F671i', 'SH251i', 'SH251iS'); 
     137            return !in_array($objAgent->getSeries(), $arrUnsupportedSeries) && !in_array($objAgent->getModel(), $arrUnsupportedModels); 
     138        } elseif ($objAgent->isEZweb()) { 
     139            return $objAgent->isWAP2(); 
     140        } elseif ($objAgent->isVodafone()) { 
     141            return $objAgent->isPacketCompliant(); 
     142        } else { 
     143            // 携帯端末ではない場合はサポートしていることにする。 
     144            return true; 
     145        } 
     146    } 
    133147} 
    134148?> 
Note: See TracChangeset for help on using the changeset viewer.