Dragonfly CMS logo Server sponsored and hosted by
DedicatedNOW
CVS logo  
.:: Home :: Dev. Resources :: Forums ::.
Dragonfly CMS CVS Repository
 Location: / cvs / html / includes / data / ua.inc
This is a web interface to the Dragonfly CMS CVS tree. You can browse the file hierarchy by picking directories. If you pick a file, you will see the revision history for that file.
Selecting a revision number will show that revision of the file. There are links at each revision to display diffs, annotate and download.
Note: Info about CVS and our commits can be found at our CVS Info Forum
File name: html/includes/data/ua.inc
Revision : 1.10 (5 years 8 months 3 weeks 10 hours 7 minutes 57 seconds ago) by nanocaiordo
Changed : +3 -3 lines
Comment: fixed http://dragonflycms.org/Projects/bugs/id=1063/


# Author Rev Line
1 nanocaio 1.1 <?php
2 nanocaio 1.1 /*********************************************
3 nanocaio 1.1 MOO CMS, Copyright (c) 2007 The MOO Dev. Group. All rights reserved.
4 nanocaio 1.1  
5 nanocaio 1.1 This source file is free software; you can redistribute it and/or
6 nanocaio 1.1 modify it under the terms of the MOO Public License as published
7 nanocaio 1.1 by the MOO Development Group; either version 1 of the License, or
8 nanocaio 1.1 (at your option) any later version.
9 nanocaio 1.1  
10 nanocaio 1.1 $Source: /cvs/html/includes/data/ua.inc,v $
11 nanocaio 1.10 $Revision: 1.9 $
12 phoenix 1.9 $Author: phoenix $
13 nanocaio 1.10 $Date: 2008/06/17 14:28:03 $
14 nanocaio 1.1 **********************************************/
15 nanocaio 1.1 if (!defined('CPG_NUKE')) exit();
16 nanocaio 1.1  
17 nanocaio 1.1 function ua_set_data($ua, $os, $engine, $extra, &$agent)
18 nanocaio 1.1 {
19 nanocaio 1.1 if (!empty($ua)) {
20 nanocaio 1.1 $agent = array(
21 nanocaio 1.1 'ua' => $ua,
22 nanocaio 1.1 'os' => $os,
23 nanocaio 1.1 'engine' => empty($engine) ? $ua : $engine,
24 nanocaio 1.1 'ext' => $extra
25 nanocaio 1.1 );
26 nanocaio 1.1 }
27 nanocaio 1.1 }
28 nanocaio 1.1  
29 nanocaio 1.1 $ua_pattern = array(
30 nanocaio 1.1 # Netscape
31 nanocaio 1.1 '#^Mozilla/[34]\.[0-8]{1,2}( \[[a-zA-Z\-]{2,5}\])? \(([a-zA-Z0-9]+); [UI]#e',
32 nanocaio 1.1 # Gecko family: Netscape, Firefox, Thunderbird, Camino, Galeon, Epiphany, Linspire, MultiZilla, K-Meleon, WebWasher, Mozilla
33 nanocaio 1.4 '#^Mozilla/5\.0 \(([a-zA-Z0-9]+); U; (.*[^;])(; [a-zA-Z\-]{2,5})?; rv:[0-9\.]+.*?\) Gecko/[0-9]{8,10}.*(Firefox|Minefield).*#e',
34 nanocaio 1.1 '#^Mozilla/5\.0 \(([a-zA-Z0-9]+); U; (.*[^;])(; [a-zA-Z\-]{2,5})?; rv:[0-9\.]+.*?\) Gecko/[0-9]{8}( \(No IDN\))? ([a-zA-Z6\-]+)[/|\s]+[0-9\.]+.*#e',
35 nanocaio 1.1 '#^Mozilla/5\.0 \(([a-zA-Z0-9]+); U; (.*[^;])(; [a-zA-Z\-]{2,5})?; rv:[0-9\.]+.*?\) Gecko/[0-9]{8}( \(No IDN\))?$#e',
36 nanocaio 1.1 # Galeon
37 nanocaio 1.1 '#^Mozilla/5\.0 (Galeon)/[0-9\.]+ \(([a-zA-Z0-9]+); (.*[^;]); U\)#e',
38 nanocaio 1.1 # Konqueror
39 nanocaio 1.1 '#^Mozilla/5\.0 \(compatible; (Konqueror)/[0-9\.\-rc]+[;)] (i686 )?(Linux|FreeBSD|KHTML).*#e',
40 nanocaio 1.1 # Lynx
41 nanocaio 1.1 '#^(Lynx)/2\.[0-9\.]+(rel|dev)[0-9\.]+ libwww-FM/.*#e',
42 nanocaio 1.1 # Safari family: Safari, OmniWeb, Shiira, DEVONtech
43 phoenix 1.8 '#^Mozilla/5\.0 \(Macintosh; U; (PPC|Intel) Mac OS X[0-9_\ ]+?; [a-zA-Z\-]{2,5}\) AppleWebKit/.*? \(KHTML, like Gecko.*?\) ([a-zA-Z]+)/.*#e',
44 nanocaio 1.1 '#^Mozilla/5\.0 \(Windows; U; Windows NT [0-9\.]{3}; [a-zA-Z\-]{2,5}\) AppleWebKit/.*? \(KHTML, like Gecko.*?\) Version/.* ([a-zA-Z]+)/.*#e',
45 nanocaio 1.1 # w3m
46 nanocaio 1.1 '#^(w3m)/[0-9\.]+#e',
47 nanocaio 1.1 # Links
48 nanocaio 1.1 '#^(Links) \([0-9]\.[a-z0-9]+; ([a-zA-Z]+) #e',
49 nanocaio 1.1 # ELinks
50 nanocaio 1.1 '#^(ELinks)/0\.[0-9\.]+ \([a-z]+; ([\w]+); #e',
51 nanocaio 1.1 # Voyager
52 nanocaio 1.1 '#^Mozilla/4\.0 \(compatible; (Voyager); (AmigaOS).*#e',
53 nanocaio 1.1 # Opera
54 nanocaio 1.1 '#^(Opera)/[67]\.[0-9]{1,2} \(([\w]+).*[^;]; U\)[\ ]{1,2}\[[a-zA-Z\-]{2,5}\]#e', # Opera 6-7
55 nanocaio 1.1 '#^(Opera)/[89]\.[0-9]{1,2} \(([\w]+).*[^;]; U; [a-zA-Z\-]{2,5}\)#e', # Opera 8-9
56 nanocaio 1.1 '#^Mozilla/[45]\.0 \(compatible; MSIE [56]\.0; (.*?)\) (Opera) [567]\.[0-9]{1,2} \[[a-zA-Z\-]{2,5}\]#e', # Opera 6-7 faking IE
57 nanocaio 1.1 '#^Mozilla/5\.0 \((.*?); U\) (Opera) [67]\.[0-9]{1,2} \[[a-zA-Z\-]{2,5}\]#e', # Opera 6-7 faking Gecko
58 nanocaio 1.1 '#^Mozilla/4\.0 \(compatible; MSIE 6\.0; (.*?); [a-zA-Z\-]{2,5}\) (Opera) [89]\.[0-9]{1,2}#e', # Opera 8-9 faking IE
59 nanocaio 1.1 '#^Mozilla/5\.0 \((.*?); U; [a-zA-Z\-]{2,5}\) (Opera) [89]\.[0-9]{1,2}#e', # Opera 8-9 faking Gecko
60 nanocaio 1.1 '#^Mozilla/5\.0 \(([\w]*).*[^;]; U; [a-zA-Z\-]{2,5}; rv:.*[^;]\) Gecko/.* Firefox/.* (Opera) 9\.[0-9]{1,2}#e', # Opera 9.2 faking Gecko
61 nanocaio 1.1 # IE
62 nanocaio 1.4 '#^Mozilla/4\.0 \([a-z]+; MSIE ([45678]\.0|5\.5)[b1]?(; .*[^;])?; (Windows) [A-Z0-9\ \.]+[;)](.*[^)])?#e',
63 nanocaio 1.1 '#^Mozilla/2\.0 \(compatible; MSIE ([34]\.0)[1]?(; .*[^;])?; (Windows) [A-Z0-9\ \.]+[;)](.*)?#e',
64 nanocaio 1.1 '#^Mozilla/4\.0 \(compatible; MSIE 5\.[1-2][1-7]; Mac_PowerPC\)#e', # 5.: 13, 16, 17, 21, 22, 23
65 nanocaio 1.1 # Dillo/0.8.5-i18n-misc
66 nanocaio 1.1 '#^Dillo/[0-9\.]+.*#e',
67 nanocaio 1.1 # mobile phones
68 nanocaio 1.1 '#^KWC-[a-zA-Z0-9]+/[0-9\.]+ UP\.Browser/[0-9\.]+#e',
69 nanocaio 1.1 '#^LG-[A-Z0-9]+ (.*?)Profile/MIDP-[12]#e',
70 phoenix 1.9 '#^(Mozilla/5\.0 \(SymbianOS/.*; U; Series60/.*\s)?Nokia[0-9iBGN_]+/[0-9\.]+[0-9\ \.\();]+ (.*?)Profile/MIDP-[012\.]+(\sConfiguration/CLDC-[12\.]+\) AppleWebKit/.* \(KHTML, like Gecko\) Safari/.*)?#e',
71 phoenix 1.9 '#^Mozilla/4\.0 \(compatible; MSIE 6\.0; Symbian OS; Series 60/[0-9\.]+; [0-9]+\) Opera 8(.*?) \[[a-zA-Z\-]{2,5}\]#e',
72 nanocaio 1.1 '#^SAMSUNG-[A-Z0-9\-]+/[A-Z0-9]+ UP\.Browser/[0-9\.]+#e',
73 nanocaio 1.1 '#^SonyEricsson[a-zA-Z0-9]+/[A-Z0-9]+ (.*?)Profile/MIDP-[12]#e',
74 nanocaio 1.6 '#^Mozilla/5\.0 \([d-oP]{3,6}; U; CPU like Mac OS X; [a-zA-Z\-]{2,5}\) AppleWebKit/[0-9\.\+]+ \(KHTML, like Gecko\) Version/.* Mobile/.* Safari/.*#e',
75 phoenix 1.9 '#^HTC_TyTN_II Mozilla/4\.0 \(compatible; MSIE 6\.0; Windows CE; (IEMobile 7\.6)\)#e',
76 nanocaio 1.1 # PlayStation
77 nanocaio 1.1 '#^Mozilla/4\.0 \(PSP \(PlayStation Portable\); 2\.00\)#e',
78 nanocaio 1.1 );
79 nanocaio 1.1 $ua_replacement = array(
80 nanocaio 1.1 # Netscape
81 nanocaio 1.1 'ua_set_data(\'Netscape\', \'\\1\', \'Gecko\', \'\', $agent)',
82 nanocaio 1.1 # Gecko family
83 nanocaio 1.1 'ua_set_data(\'\\4\', \'\\2\', \'Gecko\', \'\', $agent)',
84 nanocaio 1.1 'ua_set_data(\'\\5\', \'\\2\', \'Gecko\', \'\', $agent)',
85 nanocaio 1.1 'ua_set_data(\'Mozilla\', \'\\1\', \'Gecko\', \'\', $agent)',
86 nanocaio 1.1 # Galeon
87 nanocaio 1.1 'ua_set_data(\'\\1\', \'\\3\', \'\', \'\', $agent)',
88 nanocaio 1.1 # Konqueror
89 nanocaio 1.1 'ua_set_data(\'\\1\', \'\\3\', \'KHTML\', \'\', $agent)',
90 nanocaio 1.1 # Lynx
91 nanocaio 1.1 'ua_set_data(\'\\1\', \'\', \'\', \'\', $agent)',
92 nanocaio 1.1 # Safari family
93 nanocaio 1.1 'ua_set_data(\'\\2\', \'Mac\', \'Safari\', \'\', $agent)',
94 nanocaio 1.1 'ua_set_data(\'\\1\', \'Windows\', \'Safari\', \'\', $agent)',
95 nanocaio 1.1 # w3m
96 nanocaio 1.1 'ua_set_data(\'\\1\', \'\', \'\', \'\', $agent)',
97 nanocaio 1.1 # Links
98 nanocaio 1.1 'ua_set_data(\'\\1\', \'\\2\', \'\', \'\', $agent)',
99 nanocaio 1.1 # ELinks
100 nanocaio 1.1 'ua_set_data(\'\\1\', \'\\2\', \'\', \'\', $agent)',
101 nanocaio 1.1 # Voyager
102 nanocaio 1.1 'ua_set_data(\'\\1\', \'\\2\', \'\', \'\', $agent)',
103 nanocaio 1.1 # Opera
104 nanocaio 1.1 'ua_set_data(\'\\1\', \'\\2\', \'\', \'\', $agent)',
105 nanocaio 1.1 'ua_set_data(\'\\1\', \'\\2\', \'\', \'\', $agent)',
106 nanocaio 1.1 'ua_set_data(\'\\2\', \'\\1\', \'\', \'\', $agent)',
107 nanocaio 1.1 'ua_set_data(\'\\1\', \'\\2\', \'\', \'\', $agent)',
108 nanocaio 1.1 'ua_set_data(\'\\2\', \'\\1\', \'\', \'\', $agent)',
109 nanocaio 1.1 'ua_set_data(\'\\2\', \'\\1\', \'\', \'\', $agent)',
110 nanocaio 1.1 'ua_set_data(\'\\2\', \'\\1\', \'\', \'\', $agent)',
111 nanocaio 1.1 # IE
112 nanocaio 1.1 'ua_set_data(\'MSIE\', \'\\3\', \'\', \'\\4\', $agent)',
113 nanocaio 1.1 'ua_set_data(\'MSIE\', \'\\3\', \'\', \'\\4\', $agent)',
114 nanocaio 1.1 'ua_set_data(\'MSIE\', \'Mac\', \'\', \'\\4\', $agent)',
115 nanocaio 1.1 # Dillo
116 nanocaio 1.1 'ua_set_data(\'Dillo\', \'Linux\', \'\', \'\', $agent)',
117 nanocaio 1.1 # mobile phones
118 nanocaio 1.1 'ua_set_data(\'WAP\', \'\', \'\', \'KWC\', $agent)',
119 nanocaio 1.1 'ua_set_data(\'WAP\', \'\', \'\', \'LG\', $agent)',
120 nanocaio 1.1 'ua_set_data(\'WAP\', \'\', \'\', \'Nokia\', $agent)',
121 phoenix 1.9 'ua_set_data(\'WAP\', \'\', \'Opera\', \'Nokia\', $agent)',
122 nanocaio 1.1 'ua_set_data(\'WAP\', \'\', \'\', \'SAMSUNG\', $agent)',
123 nanocaio 1.1 'ua_set_data(\'WAP\', \'\', \'\', \'SonyEricsson\', $agent)',
124 nanocaio 1.7 'ua_set_data(\'WAP\', \'Mac\', \'\', \'iPhone\', $agent)',
125 phoenix 1.9 'ua_set_data(\'WAP\', \'Windows\', \'MSIE\', \'HTC_TyTN \\1\', $agent)',
126 nanocaio 1.1 # PlayStation
127 nanocaio 1.1 'ua_set_data(\'PlayStation\', \'\', \'\', \'Sony\', $agent)',
128 nanocaio 1.1 );
129 nanocaio 1.1 preg_replace($ua_pattern, $ua_replacement, $_SERVER['HTTP_USER_AGENT']);
130 nanocaio 1.1 $ua_pattern = $ua_replacement = null;
131 nanocaio 1.1 # If we didn't detect a valid browser check for a bot
132 nanocaio 1.10 if (!isset($agent['ua'])) { $agent = Security::detectBot(); return;}
133 nanocaio 1.1 # Detect IE based browsers
134 nanocaio 1.1 else if ($agent['ua'] == 'MSIE') {
135 nanocaio 1.1 preg_match_all('#(iRider|Crazy Browser|NetCaptor|Maxthon|Avant Browser)#s', $agent['ext'], $regs);
136 nanocaio 1.1 if (!empty($regs[0])) {
137 nanocaio 1.1 $agent['ua'] = str_replace(' Browser','',$regs[0][count($regs[0])-1]);
138 nanocaio 1.1 $agent['ext'] = '';
139 nanocaio 1.1 }
140 nanocaio 1.1 }
141 nanocaio 1.7 preg_match('#(Win|Mac|Linux|FreeBSD|SunOS|IRIX|BeOS|OS/2|AIX|Amiga)#is', $agent['os'], $regs);
142 nanocaio 1.1 $agent['os'] = $regs[0];
143 nanocaio 1.1 if ($agent['os'] == 'Win') $agent['os'] = 'Windows';
144 nanocaio 1.1 return $agent;


Code Credits - Privacy Policy