WebClient.object
上传用户:xiao730204
上传日期:2007-01-04
资源大小:141k
文件大小:2k
- <?php
- class WebClient extends BaseObject {
- Function WebClient() {
- $this->BaseObject( 'WebClient' );
- }
- Function Detect() {
- global $HTTP_USER_AGENT;
- /* $USER_AGENT */
- /* echo( 'USER AGENT : ' . $HTTP_USER_AGENT . "n" ); */
- if ( ereg(
- '(MSIE|Internet Explorer/)([0-9]).([0-9])+',
- $HTTP_USER_AGENT,
- $version ) ) {
- $major_version = (int)$version[ 2 ];
- $ie_browser = new WebClientBrowser();
- switch( $major_version ) {
- case 5:
- $ie_browser = new WebClient_Ie_5();
- break;
- case 4:
- $ie_browser = new WebClient_Ie_4();
- break;
- case 3:
- $ie_browser = new WebClient_Ie_3();
- break;
- default:
- $ie_browser = new WebClient_Ie_3();
- break;
- }
- $ie_browser->version = $major_version;
- return $ie_browser;
- }
- if ( ereg( 'Mozilla/([0-9]+)', $HTTP_USER_AGENT, $results ) ) {
- $major_version = (int)$results[ 1 ];
- $ns_browser = new WebClientBrowser();
- switch( $major_version ) {
- case 5:
- $ns_browser = new WebClient_Netscape_5();
- break;
- case 4:
- $ns_browser = new WebClient_Netscape_4();
- break;
- case 3:
- $ns_browser = new WebClient_Netscape_3();
- break;
- default:
- $ns_browser = new WebClient_Netscape_3();
- }
- $ns_browser->version = $major_version ;
- return $ns_browser;
- }
- if ( ereg( 'Lynx/([0-9]+)', $HTTP_USER_AGENT, $results ) ) {
- $major_version = (int)$results[ 1 ];
- $lynx_browser = new WebClient_Lynx();
- $lynx_browser->version = $major_version;
- return $lynx_browser;
- }
- /* Guess we could not figure out the client */
- return new WebClientBrowser();
- }
- }
- ?>