This repository has been archived by the owner on Feb 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathbrowser_detection.inc
executable file
·1917 lines (1853 loc) · 88.1 KB
/
browser_detection.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
Script Name: Full Featured PHP Browser/OS detection
Author: Harald Hope, Website: http://techpatterns.com/
Script Source URI: http://techpatterns.com/downloads/php_browser_detection.php
Version: 5.8.0
Date: 2016-10-05
Copyright (C) 2003-2016
Special thanks to alanjstr for cleaning up the code, especially on function get_item_version(),
which he improved greatly. Also to Tapio Markula, for his initial inspiration of creating a
useable php browser detector. Also to silver Harloe for his ideas about using associative arrays
to both return and use as main return handler.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Get the full text of the GPL here: http://www.gnu.org/licenses/gpl.txt
Coding conventions:
http://cvs.sourceforge.net/viewcvs.py/phpbb/phpBB2/docs/codingstandards.htm?rev=1.3
Requires PHP verson 4.2 or newer.
******************************************
This is currently set to accept these primary parameters, although you can add as many as you want:
Note: all string data is returned as LOWER CASE, so make sure to keep that in mind when testing.
NOTE: as 5.3.0 some of these names have been changed to be more human readable. The old names will
still work, and it is noted where this change has happened like this: [deprecated: moz_version].
This change will will NOT break your existing programming or browser detection function calls.
[NUMBER] = full array numeric index key; ['array_key'] associative array key
******************************************
**************************
FULL ARRAY RETURN OPTIONS:
Note that mobile/moz/trident/webkit_data are arrays which could contain null data, so always test first
before assuming the mobile/moz/trident/webkit arrays contain any data, ie, if moz or if webkit, then do..
To get this return, you use the 'full' or 'full_assoc' value in the function call, like:
$a_browser_data = browser_detection('full')
$a_browser_data = browser_detection('full_assoc')
**************************
full - returns this array, listed by array index number:
[0] - $browser_working
[1] - $browser_number
[2] - $ie_version
[3] - $b_dom_browser
[4] - $b_safe_browser
[5] - $os_type
[6] - $os_number
[7] - $browser_name
[8] - $ua_type
[9] - $browser_math_number
[10] - $a_moz_data
[11] - $a_webkit_data
[12] - $mobile_test (null or string value)
[13] - $a_mobile_data (null or array of mobile data)
[14] - $true_ie_number
[15] - $run_time
[16] - $html_type
[17] - $a_engine_data
[18] - $a_trident_data
[19] - $a_blink_data
full_assoc - returns all relevant browser information in an associative array, same as above
only with string indexes instead of numeric.
['browser_working'] - $browser_working,
['browser_number'] - $browser_number,
['ie_version'] - $ie_version,
['dom'] - $b_dom_browser,
['safe'] - $b_safe_browser,
['os'] - $os_type,
['os_number'] - $os_number,
['browser_name'] - $browser_name,
['ua_type'] - $ua_type,
['browser_math_number'] - $browser_math_number,
['moz_data'] - $a_moz_data,
['webkit_data'] - $a_webkit_data,
['mobile_test'] - $mobile_test,
['mobile_data'] - $a_mobile_data,
['true_ie_number'] - $true_ie_number,
['run_time'] - $run_time,
['html_type'] - $html_type,
['engine_data'] - $a_engine_data,
['trident_data'] - $a_trident_data,
['blink_data'] - $a_blink_data
******************************************************************************
ALPHABETICAL DESCRIPTION OF DATA OPTIONS (With 'full' numeric index key first)
To get these you use either the full/full_assoc arrays with the keys, or you can get
any of these individually in the function call, like:
browser_detection('browser_math_number')
or, if using 'full_assoc':
$a_browser_data = browser_detection('full_assoc');
$a_browser_data['browser_math_number']
or, if using 'full':
$a_browser_data = browser_detection('full');
$a_browser_data[9]
******************************************************************************
[19] ['blink_data'] - returns array of blink (chrome > 28.0 engine) browser data.
Return Array listed by index number:
[0] - $blink_type [blink version name (Eg. vivaldi)]
[1] - $blink_type_number [blink version number (Eg. Vivaldi 1.0.194)]
[2] - $layout_engine_number [the actual blink version number (NOTE: no reliable way to get this)]
[3] - $browser_number [the actual browser version number (Eg. Vivaldi 1.0.194)]
[9] ['browser_math_number'] - [deprecated: 'math_number'] returns basic version number, for math
comparison, ie. 1.2rel2a becomes 1.2. If browser_number is null, browser_math_number = ''
[7] ['browser_name'] - returns the full browser name string, if available, otherwise returns ''
(information not available)
[1] ['browser_number'] - [deprecated: 'number'] returns the browser version number, if available,
otherwise returns '' (information not available)
[0] ['browser_working'] [deprecated: 'browser'] - returns the working shorthand browser name:
ie, op, moz, konq, saf, ns4, webkit, and some others. If not shorthand, it will probably just
return the full browser name, like lynx
[3] ['dom'] - returns true/false if it is a basic dom browser, ie >= 5, opera >= 5, all new mozillas,
safaris, konquerors
[17] ['engine_data'] - Returns array of layout engine data, if present. Opera>=10;MSIE>=7;Gecko;Webkit
[0] - Layout engine name, eg: Presto (Opera);Trident (MSIE);Gecko;Webkit
[1] - Layout engine full version string, like: 2.03beta4
[2] - Layout engine math number, like: 2.03
[16] ['html_type'] - returns following values, numeric rather than t/f, so you can use
math comparisons for html support, ie: if ( $browser('html_type') > 1 ) then...
NOTE - DO NOT RELY ON THIS FULLY, ALWAYS TEST FOR SUPPORT ON THE SPECIFIC BROWSER.
Browser support information here:
http://en.wikipedia.org/wiki/Comparison_of_layout_engines_%28HTML5%29
Currently these are the supported return values (as HTML advances, more numbers
will be added in thefuture):
1 - covers all HTMLs prior to HTML 5. All non html 5 supporting browsers / bots will return 1
2 - HTML 5 - Basic HTML 5 support. Canvas, Audio, Video, + some others. Test uses layout
engine version numbers to determine if it's html5 ready or not. The test does not
verify actual html 5 support, you will need to do that yourself with more complex html 5.
3 - Supports HTML 5 Forms reasonably well. along with basic HTML 5
[2] ['ie_version'] - tests to see what general IE it is.
Possible return values:
ie9x - all new msie 9 or greater - note that if in compat mode, 7,8,9 all show as 7
ie7x - all new msie 7 or greater
ie5x - msie 5 and 6, not mac
ieMac - msie 5.x mac release
ie4 - msie 4
old - pre msie 4
[12] ['mobile_test'] - returns a string of various mobile id methods, from device to os to browser.
If string is not null, should be a mobile. Also see 16, 'ua_type', which will be 'mobile'
if handheld.
[13] ['mobile_data'] - returns an array of data about mobiles. Note the browser/os number data is very
unreliable so don't count on that. No blackberry version handling done explicitly.
Make sure to test if this is an array because if it's not mobile it will be null, not an array
listed by array index number:
[0] - $mobile_device
[1] - $mobile_browser
[2] - $mobile_browser_number
[3] - $mobile_os
[4] - $mobile_os_number
[5] - $mobile_server
[6] - $mobile_server_number
[7] - $mobile_device_number (this was added so has to be end of list to not break existing code)
[8] - $mobile_tablet (test if not null rather than t/f, returns for example: ipad, android 3-4)
Note that this is barebones, but will catch ~98+% (varies year to year) of current
tablets at this point. This test will never be perfect due to very little info in tablet ua.
Note: $mobile_browser only returns if a specifically mobile browser is detected, like minimo.
Same for mobile os, with the exception of linux. Otherwise the standard script os/browser data
is used. $mobile_server is a handheld service like docomo, novarro-vision, etc. Sometimes the
string will contain no other usable data than this to determine if it's handheld or not.
[10] ['moz_data'] [deprecated: 'moz_version'] - returns array of mozilla / gecko information
Return Array listed by index number:
[0] - $moz_type [moz version - the specific brand name that is, eg: firefox)
[1] - $moz_type_number - the full version number of $moz_type (eg: for firefox: 3.6+2b)
[2] - $moz_rv - the Mozilla rv version number, math comparison version. This tells you what
gecko engine is running in the browser (eg rv: 1.8)
[3] - $moz_rv_full - rv number (for full rv, including alpha and beta versions: 1.8.1-b3)
[4] - $moz_release_date - release date of the browser
[5] ['os'] - returns which os is being used - win, nt, mac, OR iphone, blackberry, palmos, palmsource,
symbian, beos, os2, amiga, webtv, linux, unix.
[6] ['os_number'] - returns windows versions, 95, 98, ce, me, nt: 4; 5 [windows 2000];
5.1 [windows xp]; 5.2 [Server 2003]; 6.0 [Windows Vista], 6.1 [Windows 7].
Only win, nt, mac, iphone return os numbers (mac/iphone return 10 if OS X.)
OR returns linux distro/unix release name, otherwise returns null
[15] ['run_time'] - the time it takes this script to execute from start to point of returning value
Requires PHP 5 or greater. Returns time in seconds to 8 decimal places: 0.00245687
Run time does not count the time used by PHP to include/parse the file initially. That total
time is about 5-10x longer. Because subsequent script run throughs go VERY fast, you will see
the seconds go from something like 0.00115204 for first time, to something like 0.00004005
for second and more runs.
[4] ['safe'] - returns true/false, you can determine what makes the browser be safe lower down,
currently it's set for ns4 and pre version 1 mozillas not being safe, plus all older browsers
[18] ['trident_data'] - returns array of trident (msie engine) browser data.
Return Array listed by index number:
[0] - $trident_type [trident version name (Eg. ucbrowser)]
[1] - $trident_type_number [trident version number (Eg. UCBrowser 2.9.0.263)]
[2] - $layout_engine_number [the actual trident version number (Eg. Trident 5.0)]
[3] - $browser_number [the actual MSIE version number (Eg. MSIE: 9.0)]
[14] ['true_ie_number'] - [deprecated: true_msie_version] returns the true version of msie running,
ignoring the compat mode version.
Note that php will turn 7.0 to 8 when adding 1, so keep that in mind in your tests. 7.1
will become 8.1 as expected, however. This test currently only tests for 7.x -> 8.x
FYI: in PHP, 7.0 == 7 is true but 7.0 === 7 is NOT true.
If this is null but set, then it is NOT running in compatibility mode.
AS OF MSIE 11 this is not present or used, so all > 11 msie browsers will NOT show compat mode
[8] ['ua_type'] [deprecated: 'type'] - returns one of the following:
bot (web bot)
bro (normal browser)
bbro (simple browser)
mobile (handheld)
dow (downloading agent)
lib (http library)
[11] ['webkit_data'] - [deprecated: 'webkit_version'] returns array of webkit data.
Return Array listed by index number:
[0] - $webkit_type [webkit version name (Eg. chrome)]
[1] - $webkit_type_number [webkit version number (Eg. Chrome's: 1.2)]
[2] - $browser_number [the actual webkit version number (Eg. Webkit's: 436)]
******************************************
Optional second script parameter, to turn off features if not required. These would be the second
argument used in the function call if used, like: browser_detection( 'full', '1' );
Test Exclusions - switches to turn off various tests, useful if you want to optimize execution
and don't need the test data type excluded.
******************************************
1 - turn off os tests
2 - turn off mobile tests
3 - turn off mobile and os tests
******************************************
Optional third script parameter, pass the script externally derived UA strings, for testing/
processing purposes. Idea from Rui Teixeira
Note: include a blank second arg when you use the 3rd parameter if the second is not set:
example: browser_detection( 'full', '', $test_string_data )
Using third parameter sets $b_repeat to false in other words, if you use this parameter, the script
will do the full processing on the UA string, then switch $b_repeat back to true at the end.
However, be aware that all requests to the script after the last testing value is sent will
use the previous testing value, NOT the actual UA string, so make sure to handle that in your
programming if you require the true UA data to be processed after the final testing value is sent
by resetting that data with the true UA value.
*******************************************/
/**
main script, uses two other functions, get_os_data() and get_item_version() as needed
Optional $test_excludes is either null or one of the above values
**/
function browser_detection( $which_test, $test_excludes='', $external_ua_string='' )
{
/**
uncomment the global variable declaration if you want the variables to be available on
a global level throughout your php page, make sure that php is configured to support
the use of globals first!
Use of globals should be avoided however, and they are not necessary with this script
**/
/*
global $a_full_assoc_data, $a_mobile_data, $a_moz_data, $a_engine_data, $a_webkit_data,
$b_dom_browser, $b_repeat, $b_safe_browser, $browser_name, $browser_number, $browser_math_number,
$browser_user_agent, $browser_working, $html_type, $ie_version, $mobile_test, $moz_type_number,
$moz_rv, $moz_rv_full, $moz_release_date, $moz_type, $os_number, $os_type, $layout_engine,
$layout_engine_nu, $layout_engine_nu_full, $true_ie_number, $ua_type, $webkit_type, $webkit_type_number;
*/
script_time(); /** set script timer to start timing **/
static $a_full_assoc_data, $a_khtml_data, $a_mobile_data, $a_moz_data, $a_engine_data,
$a_blink_data, $a_trident_data, $a_webkit_data, $b_dom_browser, $b_repeat, $b_safe_browser,
$blink_type, $blink_type_number, $browser_name, $browser_number, $browser_math_number,
$browser_user_agent, $browser_working, $html_type, $ie_version, $khtml_type,
$khtml_type_number, $mobile_test, $moz_type_number, $moz_rv, $moz_rv_full, $moz_release_date,
$moz_type, $os_number, $os_type, $layout_engine, $layout_engine_nu, $layout_engine_nu_full,
$trident_type, $trident_type_number, $true_ie_number, $ua_type, $webkit_type, $webkit_type_number;
/** switch off the optimization for external ua string testing. **/
if ( $external_ua_string ) {
$b_repeat = false;
}
/**
this makes the test only run once no matter how many times you call it since
all the variables are filled on the first run through, it's only a matter of
returning the the right ones
**/
if ( !$b_repeat ) {
/** initialize all variables with default values to prevent error **/
$a_blink_data = '';
$a_browser_math_number = '';
$a_full_assoc_data = '';
$a_full_data = '';
$a_khtml_data = '';
$a_mobile_data = '';
$a_moz_data = '';
$a_os_data = '';
$a_trident_data = '';
$a_unhandled_browser = '';
$a_webkit_data = '';
$b_dom_browser = false;
$b_os_test = true;
$b_mobile_test = true;
$b_safe_browser = false;
/** boolean for if browser found in main test **/
$b_success = false;
$blink_type = '';
$blink_type_number = '';
$browser_math_number = '';
$browser_temp = '';
$browser_working = '';
$browser_number = '';
$html_type = '';
$html_type_browser_nu = '';
$ie_version = '';
$layout_engine = '';
$layout_engine_nu = '';
$layout_engine_nu_full = '';
$khtml_type = '';
$khtml_type_number = '';
$mobile_test = '';
$moz_release_date = '';
$moz_rv = '';
$moz_rv_full = '';
$moz_type = '';
$moz_type_number = '';
$os_number = '';
$os_type = '';
$run_time = '';
$trident_type = '';
$trident_type_number = '';
$true_ie_number = '';
/** default to bot since you never know with bots **/
$ua_type = 'bot';
$webkit_type = '';
$webkit_type_number = '';
/** set the excludes if required **/
if ( $test_excludes ) {
switch ( $test_excludes ) {
case '1':
$b_os_test = false;
break;
case '2':
$b_mobile_test = false;
break;
case '3':
$b_os_test = false;
$b_mobile_test = false;
break;
default:
die( 'Error: bad $test_excludes parameter 2 used: ' . $test_excludes );
break;
}
}
/**
make navigator user agent string lower case to make sure all versions get caught
isset protects against blank user agent failure. tolower also lets the script use
strstr instead of stristr, which drops overhead slightly.
**/
if ( $external_ua_string ) {
$browser_user_agent = strtolower( $external_ua_string );
}
elseif ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
$browser_user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
}
else {
$browser_user_agent = '';
}
/**
pack the browser type array, in this order
the order is important, because opera must be tested first, then omniweb [which has safari
data in string], same for konqueror, then safari, then gecko, since safari navigator user
agent id's with 'gecko' in string.
Note that $b_dom_browser is set for all modern dom browsers, this gives you a default to use.
array[0] = id string for useragent, array[1] is if dom capable, array[2] is working name
for browser, array[3] identifies navigator useragent type
Note: all browser strings are in lower case to match the strtolower output, this avoids
possible detection errors
Note: These are the navigator user agent types:
bro - modern, css supporting browser.
bbro - basic browser, text only, table only, defective css implementation
bot - search type spider
dow - known download agent
lib - standard http libraries
mobile - handheld or mobile browser, set using $mobile_test
**/
/** known browsers, list will be updated routinely, check back now and then **/
$a_browser_types = array(
/**
0. Because of search bots now often using regular user agents, this section should be first
in the list of useragents because these use various useragent strings that can contain 'real'
user agent data, which would then trigger as a real browser before this detector actually
reaches the bot section.
See file comment footer for examples of spoofed mobile etc user agents from these bots:
**/
array( '360spider', false, '360spider', 'bot' ),
array( 'adsbot-google', false, 'google-ads', 'bot' ),
array( 'applebot', false, 'applebot', 'bot' ),
array( 'baidu', false, 'baidu', 'bot' ),
array( 'bing', false, 'bing', 'bot' ),
array( 'daum', false, 'daum', 'bot' ),
array( 'ips-agent', false, 'ips-agent', 'bot' ),
array( 'msnbot', false, 'msn', 'bot' ),
array( 'exabot', false, 'exabot', 'bot' ),
array( 'googlebot', false, 'google', 'bot' ),
array( 'google web preview', false, 'googlewp', 'bot' ),
array( 'surdotlybot', false, 'surdotlybot', 'bot' ),
array( 'surveybot', false, 'surveybot', 'bot' ),
array( 'yandex', false, 'yandex', 'bot' ),
/** then start on ideally 'real' browsers **/
array( 'edge', true, 'edge', 'bro' ),
array( 'msie', true, 'ie', 'bro' ),
array( 'trident', true, 'ie', 'bro' ),
array( 'blink', true, 'blink', 'bro' ),
/** opera blink: OPR/<number>, no opera in ua **/
array( 'opr/', true, 'blink', 'bro' ),
array( 'vivaldi', true, 'blink', 'bro' ),
/**
webkit before gecko because some webkit ua strings say: like gecko
and before khtml because some still use khtml with webkit
**/
array( 'webkit', true, 'webkit', 'bro' ),
/** note: 2013 sees opera moving to webkit, so needs to go after webkit **/
array( 'opera', true, 'op', 'bro' ),
/** konq seems to be sticking with khtml still **/
array( 'khtml', true, 'khtml', 'bro' ),
/** covers Netscape 6-7, K-Meleon, Most linux versions, uses moz array below **/
array( 'gecko', true, 'moz', 'bro' ),
array( 'netpositive', false, 'netp', 'bbro' ),/** beos browser **/
array( 'lynx', false, 'lynx', 'bbro' ), /** command line browser **/
array( 'elinks ', false, 'elinks', 'bbro' ), /** new version of links **/
array( 'elinks', false, 'elinks', 'bbro' ), /** alternate id for it **/
array( 'links2', false, 'links2', 'bbro' ), /** alternate links version **/
array( 'links ', false, 'links', 'bbro' ), /** old name for links **/
array( 'links', false, 'links', 'bbro' ), /** alternate id for it **/
array( 'w3m', false, 'w3m', 'bbro' ), /** open source browser, more features than lynx/links **/
array( 'webtv', false, 'webtv', 'bbro' ),/** junk ms webtv **/
array( 'amaya', false, 'amaya', 'bbro' ),/** w3c browser **/
array( 'dillo', false, 'dillo', 'bbro' ),/** linux browser, basic table support **/
array( 'ibrowse', false, 'ibrowse', 'bbro' ),/** amiga browser **/
array( 'icab', false, 'icab', 'bro' ),/** mac browser **/
array( 'crazy browser', true, 'ie', 'bro' ),/** uses ie rendering engine **/
/**
Miscellaneous Bots. Always make sure that bots do not contain standard UA
syntax, if they do, move them up above to 0. bot section.
1: misc catchalls - use first to avoid extra looping. See comment footer for examples.
**/
array( 'aggregat', false, 'misc-bot', 'bot' ),
array( ' bot', false, 'misc-bot', 'bot' ),
array( 'bot ', false, 'misc-bot', 'bot' ),
array( '-bot', false, 'misc-bot', 'bot' ),
array( '_bot', false, 'misc-bot', 'bot' ),
array( 'bot/', false, 'misc-bot', 'bot' ),
array( 'bot:', false, 'misc-bot', 'bot' ),
array( 'check', false, 'misc-bot', 'bot' ),
array( 'crawl', false, 'misc-bot', 'bot' ),
array( 'download', false, 'misc-dow', 'dow' ),
array( 'fetch', false, 'misc-dow', 'dow' ),
array( 'link', false, 'misc-bot', 'bot' ),
array( 'robot', false, 'misc-bot', 'bot' ),
array( 'scanner', false, 'misc-bot', 'bot' ),
array( 'scrape', false, 'misc-bot', 'bot' ),
array( 'seobot', false, 'misc-bot', 'bot' ),
array( 'seo ', false, 'misc-bot', 'bot' ),
array( 'seo_', false, 'misc-bot', 'bot' ),
array( 'seo-', false, 'misc-bot', 'bot' ),
array( 'sitemap', false, 'misc-bot', 'bot' ),
array( 'spider', false, 'misc-bot', 'bot' ),
array( 'webbot', false, 'misc-bot', 'bot' ),
array( 'http client', false, 'httpclient', 'lib' ),
array( 'http-client', false, 'httpclient', 'lib' ),
array( 'http_client', false, 'httpclient', 'lib' ),
array( 'httpclient', false, 'httpclient', 'lib' ),
array( 'http_request', false, 'httprequest', 'lib' ),
array( 'http-request', false, 'httprequest', 'lib' ),
array( 'httprequest', false, 'httprequest', 'lib' ),
array( 'http_transport', false, 'httptransport', 'lib' ),
array( 'http-transport', false, 'httptransport', 'lib' ),
array( 'httptransport', false, 'httptransport', 'lib' ),
array( 'java', false, 'java', 'lib' ),
array( 'php-', false, 'php', 'lib' ),
array( 'perl', false, 'perl', 'lib' ),
array( 'python', false, 'python', 'lib' ),
array( 'ruby', false, 'ruby', 'lib' ),
/** 2. bots by unique id **/
array( '8leg', false, '8leg', 'bot' ),
array( 'ahrefsbot', false, 'ahrefsbot', 'bot' ),
array( 'alexa', false, 'alexa', 'bot' ),/** http://www.alexa.com/help/webmasters **/
array( 'almaden', false, 'ibm', 'bot' ),/** ibm almaden web crawler **/
array( 'answerbus', false, 'answerbus', 'bot' ),/** http://www.answerbus.com/, web questions **/
array( 'archive.org', false, 'archive.org', 'bot' ),/**archive.org **/
array( 'ask jeeves', false, 'ask', 'bot' ),/** jeeves/teoma **/
array( 'teoma', false, 'ask', 'bot' ),/** jeeves teoma - leave in this order **/
/** end teomo **/
array( 'betabot', false, 'betabot', 'bot' ),
array( 'blexbot', false, 'blexbot', 'bot' ),
array( 'bpimagewalker', false, 'bp-imagewalker', 'bot' ),/** bdbrandprotect.com **/
array( 'bhcbot', false, 'bhcbot', 'bot' ),/** ovh.com **/
array( 'boitho.com-dc', false, 'boitho', 'bot' ),/** norwegian search engine **/
array( 'catexplorador', false, 'catexplorador', 'bot' ),
array( 'checkmark', false, 'checkmark', 'bot' ),
array( 'clockwork data', false, 'clockwork-data', 'bot' ),/** Clockwork Data Vault **/
array( 'coccoc', false, 'coccoc', 'bot' ),/** vietnamese se: +http://help.coccoc.com/searchengine **/
array( 'docomo', false, 'docomo', 'bot' ),/** ua: DoCoMo/2.0 **/
array( 'domainreanimator', false, 'domainreanimator', 'bot' ),
array( 'domainstatsbot', false, 'domainstatsbot', 'bot' ),
array( 'dotbot', false, 'dotbot', 'bot' ),/** http://www.opensiteexplorer.org/dotbot **/
array( 'downnotifier', false, 'downnotifier', 'bot' ),/** downnotifier.com **/
array( 'ez publish', false, 'ez-publish', 'bot' ),/** ua: eZ Publish Link Validator **/
array( 'exabot', false, 'exabot', 'bot' ),/** dassault owned, french? search, exalead.com **/
array( 'experibot', false, 'experibot', 'bot' ),/** **/
array( 'ezooms', false, 'ezooms', 'bot' ),/** SEO Moz? alt for dotbot: http://www.opensiteexplorer.org/dotbot **/
array( 'facebookexternalhit', false, 'facebook', 'bot' ),
array( 'facebot', false, 'facebook', 'bot' ),
array( 'fatbot', false, 'fatbot', 'bot' ),/** http://www.thefind.com/crawler **/
array( 'findxbot', false, 'findxbook', 'bot' ),
array( 'gigabot', false, 'gigabot', 'bot' ),/** open source search engine: gigabot crawler **/
array( 'googledocs', false, 'google-docs', 'bot' ),/** http://docs.google.com **/
array( 'gozaikbot', false, 'gozaikbot', 'bot' ),/** joined with monster; www.gozaik.com/gozaikbot.html **/
array( 'grammarly', false, 'grammarly', 'bot' ),
array( 'guardcrwlr', false, 'guardcrwlr', 'bot' ),
array( 'headmasterseo', false, 'headmasterseo', 'bot' ),
array( 'heritrix', false, 'heritrix', 'bot' ),
array( 'hosttracker', false, 'hosttracker', 'bot' ),/** uptime checker, host-tracker.com **/
array( 'hubspot', false, 'hubspot', 'bot' ),/** HubSpot Links Crawler **/
array( 'hybridbot', false, 'hybridbot', 'bot' ),/** russian ad bot: hybrid.ru/about **/
array( 'ia_archiver', false, 'ia_archiver', 'bot' ),/** ia archiver **/
array( 'iltrovatore-setaccio', false, 'il-set', 'bot' ),
array( 'imagewalker', false, 'imagewalker', 'bot' ),/** bdbrandprotect.com **/
array( 'istellabot', false, 'istellabot', 'bot' ),/** italian search engine **/
array( 'kocmohabt', false, 'kocmohabt', 'bot' ),
array( 'lexxebotr', false, 'lexxebotr', 'bot' ),
array( 'ltx71', false, 'ltx71', 'bot' ),/** ltx71 - (http://ltx71.com/) **/
array( 'mail.ru_bot', false, 'mail.ru_bot', 'bot' ),/** brandwatch.net **/
array( 'mediapartners-google', false, 'adsense', 'bot' ),/** google adsense **/
array( 'mj12bot', false, 'mj12bot', 'bot' ),/** search bot: majestic12.co.uk **/
array( 'naverbot', false, 'naverbot', 'bot' ),/** naverbot crawler, bad bot, block **/
array( 'nutch', false, 'nutch', 'bot' ),/** apache: Nutch/2.2.1 **/
array( 'objectssearch', false, 'objectsearch', 'bot' ),/** open source search engine **/
array( 'omgilibot', false, 'omgilibot', 'bot' ),
array( 'openbot', false, 'openbot', 'bot' ),/** openbot, from taiwan **/
array( 'orangebot', false, 'orangebot', 'bot' ),
array( 'paperlibot', false, 'paperlibot', 'bot' ),/** http://support.paper.li **/
array( 'pingdom', false, 'pingdom', 'bot' ),
array( 'pinterest', false, 'pinterest', 'bot' ),/** www.pinterest.com **/
array( 'primalbot', false, 'primalbot', 'bot' ),/** https://www.primal.com **/
array( 'proximic', false, 'proximic', 'bot' ),/** http://www.proximic.com/info/spider.php **/
array( 'psbot', false, 'psbot', 'bot' ),/** psbot image crawler **/
array( 'pulsepoint', false, 'pulsepoint', 'bot' ),
array( 'qwantify', false, 'qwantify', 'bot' ),/** Qwantify/1.0 **/
array( 'rankvalbot', false, 'rankvalbot', 'bot' ),
array( 'redback', false, 'redback', 'bot' ),/** ruby spider: https://github.com/robmiller/redback **/
array( 'safednsbot', false, 'safednsbot', 'bot' ),/** safednsbot **/
array( 'salesintelligent', false, 'salesintelligent', 'bot' ),
array( 'scooter', false, 'scooter', 'bot' ),/** altavista **/
array( 'scoutjet', false, 'scoutjet', 'bot' ),
array( 'scrapy', false, 'scrapy', 'bot' ),
array( 'searchie', false, 'searchiet', 'bot' ),/** ua: Searchie/1.0 **/
array( 'semrushbot', false, 'semrushbot', 'bot' ),/** semrush.com/bot.html **/
array( 'seokicks', false, 'seokicks', 'bot' ),
array( 'seobilitybot', false, 'seobilitybot', 'bot' ),/** SeobilityBot (SEO-Check; **/
array( 'seznambot', false, 'seznambot', 'bot' ),/** http://napoveda.seznam.cz/en/seznambot-intro/ **/
array( 'slackbot', false, 'slackbot', 'bot' ),/** https://api.slack.com/robots **/
array( 'slack.com', false, 'slackbot', 'bot' ),/** https://api.slack.com/robots **/
array( 'sogou', false, 'sogou', 'bot' ),/** asian bot **/
array( 'socialrankiobot', false, 'socialrankiobot', 'bot' ),/** http://socialrank.io/about **/
array( 'sohu-search', false, 'sohu', 'bot' ),/** chinese media company, search component **/
array( 'spbot', false, 'spbot', 'bot' ),
array( 'telegrambot', false, 'telegrambot', 'bot' ),/** TelegramBot (like TwitterBot) **/
array( 'twitterbot', false, 'twitterbot', 'bot' ),/** Twitterbot/1.0 **/
array( 'vbseo', false, 'vbseo', 'bot' ),
array( 'xenu', false, 'xenu', 'bot' ),
array( 'youdaobot', false, 'youdaobot', 'bot' ),
/** leave the yahoo/slurp bots in this order to get right detections **/
array( 'yahoo link preview', false, 'yahoo-preview', 'bot' ),/** 2016 yahoo link preview bot **/
array( 'yahoo-verticalcrawler', false, 'yahoo', 'bot' ),/** old yahoo bot **/
array( 'yahoo! slurp', false, 'yahoo', 'bot' ),/** new yahoo bot **/
array( 'slurp', false, 'inktomi', 'bot' ), /** yahoo/inktomi bot **/
array( 'inktomi', false, 'inktomi', 'bot' ),/** inktomi bot **/
array( 'yahoo-mm', false, 'yahoomm', 'bot' ),/** gets Yahoo-MMCrawler and Yahoo-MMAudVid bots **/
array( 'zyborg', false, 'looksmart', 'bot' ),/** looksmart **/
/** 3. various http utility libaries **/
array( 'ahc', false, 'ahc', 'lib' ),/** ua: AHC/2.0 info: java http: Async Http Client **/
array( 'anyevent-http', false, 'anyevent-http', 'lib' ),/** perl AnyEvent-HTTP **/
array( 'go 1', false, 'go-http', 'lib' ),/** ua: Go 1.1 package http **/
array( 'w3c_validator', false, 'w3c', 'lib' ), /** uses libperl, make first **/
array( 'wdg_validator', false, 'wdg', 'lib' ),
array( 'google-http', false, 'google-http', 'lib' ),/** Google-HTTP-Java-Client **/
array( 'okhttp', false, 'okhttp', 'lib' ),/** ua: okhttp/3.4.1 **/
array( 'pcore', false, 'pcore-http', 'lib' ),/** perl: Pcore-HTTP/v0.24.5 **/
array( 'pear http', false, 'pear', 'lib' ),
array( 'winhttp', false, 'winhttp', 'lib' ),/** ua: WinHTTP **/
array( 'wordpress', false, 'winhttp', 'lib' ),/** ua: WordPress/4.6.1; **/
array( 'zgrab', false, 'zgrab', 'lib' ),/** Go lang lib: ua:Mozilla/5.0 zgrab/0.x **/
/** 4. download programs **/
array( 'curl', false, 'curl', 'dow' ),
array( 'guzzle', false, 'guzzle', 'dow' ),
array( 'getright', false, 'getright', 'dow' ),
array( 'pagefreezer', false, 'pagefreezer', 'dow' ),
array( 'wget', false, 'wget', 'dow' ),
array( 'zgrab', false, 'zgrab', 'dow' ),
/** netscape 4 and earlier tests, put last so spiders don't get caught **/
array( 'mozilla/4.', false, 'ns', 'bbro' ),
array( 'mozilla/3.', false, 'ns', 'bbro' ),
array( 'mozilla/2.', false, 'ns', 'bbro' )
);
/**
note: not using this because chrome < 28 = webkit, >=28 == blink, so can't do normal handling
for now doing a case by case for layout engine
**/
$a_blink_types = array('opr/', 'otter', 'qupzilla', 'slimjet', 'vivaldi', 'chromium',
'chrome', 'blink');
/**
moz types array
note the order, netscape6 must come before netscape, which is how netscape 7 id's itself.
rv comes last in case it is plain old mozilla. firefox/netscape/seamonkey need to be later
Thanks to: http://www.zytrax.com/tech/web/firefox-history.html
**/
$a_gecko_types = array( 'bonecho', 'camino', 'conkeror', 'epiphany', 'fennec', 'firebird',
'flock', 'galeon', 'iceape', 'icecat', 'k-meleon', 'minimo', 'multizilla', 'phoenix',
'skyfire', 'songbird', 'swiftfox', 'seamonkey', 'shadowfox', 'shiretoko', 'iceweasel',
'firefox', 'minefield', 'netscape6', 'netscape', 'rv' );
$a_khtml_types = array( 'konqueror', 'khtml' );
/**
note: trident only is up to msie 11, they have changed to edge with webkit though MSIE
browser remains present as an option but not default in windows 10
**/
$a_trident_types = array( 'ucbrowser', 'ucweb', 'msie' );
/**
webkit types, this is going to expand over time as webkit browsers spread
konqueror is probably going to move to webkit, so this is preparing for that
It will now default to khtml. gtklauncher is the temp id for epiphany, might
change. Defaults to applewebkit, and will all show the webkit number.
uc browsers are webkit need to be before safari; puffin before chrome
IMPORTANT: microsoft edge is webkit ua:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.<OS build number>
edge must come before chrome
**/
$a_webkit_types = array( 'arora', 'bolt', 'beamrise', 'chromium', 'puffin', 'chrome',
'crios', 'dooble', 'epiphany', 'gtklauncher', 'icab', 'konqueror', 'maxthon', 'midori',
'omniweb', 'opera', 'otter', 'qupzilla', 'rekonq', 'rocketmelt', 'samsungbrowser', 'silk', 'uzbl',
'ucbrowser', 'ucweb', 'shiira', 'sputnik', 'steel', 'teashark', 'safari', 'slimboat',
'applewebkit', 'webos', 'xxxterm','vivaldi', 'yabrowser', 'webkit' );
/**
run through the browser_types array, break if you hit a match, if no match, assume old browser
or non dom browser, assigns false value to $b_success.
**/
$i_count = count( $a_browser_types );
for ( $i = 0; $i < $i_count; $i++ ) {
/** unpacks browser array, assigns to variables, need to not assign til found in string **/
$browser_temp = $a_browser_types[$i][0];/** text string to id browser from array **/
if ( strstr( $browser_user_agent, $browser_temp ) ) {
/**
it defaults to true, will become false below if needed
this keeps it easier to keep track of what is safe, only
explicit false assignment will make it false.
**/
$b_safe_browser = true;
$browser_name = $browser_temp;/** text string to id browser from array **/
/** assign values based on match of user agent string **/
$b_dom_browser = $a_browser_types[$i][1];/** hardcoded dom support from array **/
$browser_working = $a_browser_types[$i][2];/** working name for browser **/
$ua_type = $a_browser_types[$i][3];/** sets whether bot or browser **/
switch ( $browser_working ) {
/**
this is modified quite a bit, now will return proper netscape version number
check your implementation to make sure it works
**/
case 'ns':
$b_safe_browser = false;
$browser_number = get_item_version( $browser_user_agent, 'mozilla' );
break;
/**
note: webkit returns always the webkit version number, not the specific user
agent version, ie, webkit 583, not chrome 0.3
**/
case 'blink':
/** to get full number **/
if ( $browser_name == 'opr/' ){
get_set_count( 'set', 0 );
}
$browser_number = get_item_version( $browser_user_agent, $browser_name );
/** assign rendering engine data **/
$layout_engine = 'blink';
if ( strstr($browser_user_agent, 'blink') ) {
$layout_engine_nu_full = get_item_version( $browser_user_agent, 'blink' );
}
else {
$layout_engine_nu_full = get_item_version( $browser_user_agent, 'webkit' );
}
$layout_engine_nu = get_item_math_number( $browser_number );
/** this is to pull out specific webkit versions, safari, google-chrome etc.. **/
$j_count = count( $a_blink_types );
for ( $j = 0; $j < $j_count; $j++ ) {
if ( strstr( $browser_user_agent, $a_blink_types[$j] ) ) {
$blink_type = $a_blink_types[$j];
if ( $browser_name == 'opr/' ){
get_set_count( 'set', 0 );
}
$blink_type_number = get_item_version( $browser_user_agent, $blink_type );
$browser_name = $a_blink_types[$j];
if ( $browser_name == 'opr/' ){
get_set_count( 'set', 0 );
}
$browser_number = get_item_version( $browser_user_agent, $browser_name );
break;
}
}
if ( $browser_name == 'opr/' ){
$browser_name = 'opera';
}
break;
case 'dillo':
$browser_number = get_item_version( $browser_user_agent, $browser_name );
/** assign rendering engine data **/
$layout_engine = 'dillo';
$layout_engine_nu = get_item_math_number( $browser_number );
$layout_engine_nu_full = $browser_number;
break;
case 'edge':
$browser_number = get_item_version( $browser_user_agent, $browser_name );
/** assign rendering engine data **/
$layout_engine = 'edgehtml';
$layout_engine_nu = get_item_math_number( $browser_number );
$layout_engine_nu_full = $browser_number;
break;
case 'khtml':
/** note that this is the KHTML version number **/
$browser_number = get_item_version( $browser_user_agent, $browser_name );
/** assign rendering engine data **/
$layout_engine = 'khtml';
$layout_engine_nu = get_item_math_number( $browser_number );
$layout_engine_nu_full = $browser_number;
/** this is to pull out specific khtml versions, konqueror **/
$j_count = count( $a_khtml_types );
for ( $j = 0; $j < $j_count; $j++ ) {
if ( strstr( $browser_user_agent, $a_khtml_types[$j] ) ) {
$khtml_type = $a_khtml_types[$j];
$khtml_type_number = get_item_version( $browser_user_agent, $khtml_type );
$browser_name = $a_khtml_types[$j];
$browser_number = get_item_version( $browser_user_agent, $browser_name );
break;
}
}
break;
case 'moz':
/**
note: The 'rv' test is not absolute since the rv number is very different on
different versions, for example Galean doesn't use the same rv version as Mozilla,
neither do later Netscapes, like 7.x. For more on this, read the full mozilla
numbering conventions here: http://www.mozilla.org/releases/cvstags.html
**/
/** this will return alpha and beta version numbers, if present **/
get_set_count( 'set', 0 );
$moz_rv_full = get_item_version( $browser_user_agent, 'rv:' );
/** this slices them back off for math comparisons **/
$moz_rv = floatval( $moz_rv_full );
/** this is to pull out specific mozilla versions, firebird, netscape etc.. **/
$j_count = count( $a_gecko_types );
for ( $j = 0; $j < $j_count; $j++ ) {
if ( strstr( $browser_user_agent, $a_gecko_types[$j] ) ) {
$moz_type = $a_gecko_types[$j];
$moz_type_number = get_item_version( $browser_user_agent, $moz_type );
break;
}
}
/**
this is necesary to protect against false id'ed moz'es and new moz'es.
this corrects for galeon, or any other moz browser without an rv number
**/
if ( !$moz_rv ) {
/** you can use this if you are running php >= 4.2 **/
$moz_rv = floatval( $moz_type_number );
$moz_rv_full = $moz_type_number;
}
/** this corrects the version name in case it went to the default 'rv' for the test **/
if ( $moz_type == 'rv' ) {
$moz_type = 'mozilla';
}
/** the moz version will be taken from the rv number, see notes above for rv problems **/
$browser_number = $moz_rv;
/** gets the actual release date, necessary if you need to do functionality tests **/
get_set_count( 'set', 0 );
$moz_release_date = get_item_version( $browser_user_agent, 'gecko/' );
/** assign rendering engine data **/
$layout_engine = 'gecko';
$layout_engine_nu = $moz_rv;
$layout_engine_nu_full = $moz_rv_full;
/**
Test for mozilla 0.9.x / netscape 6.x
test your javascript/CSS to see if it works in these mozilla releases, if it
does, just default it to: $b_safe_browser = true;
**/
if ( ( $moz_release_date < 20020400 ) || ( $moz_rv < 1 ) ) {
$b_safe_browser = false;
}
break;
case 'ie':
$b_gecko_ua = false;
/**
note we're adding in the trident/ search to return only first instance in case
of msie 8, and we're triggering the break last condition in the test, as well
as the test for a second search string, trident/
Sample: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/6.0)
Handle the new msie 11 ua syntax (search for rv:), sample:
Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko
so assign msie value back here
**/
if ( strstr($browser_user_agent, 'rv:' ) ) {
$browser_name = 'msie';
$b_gecko_ua = true;
get_set_count( 'set', 0 );
$browser_number = get_item_version( $browser_user_agent, 'rv:', '', '' );
}
else {
$browser_number = get_item_version( $browser_user_agent, $browser_name, true, 'trident/' );
}
get_set_count( 'set', 0 );
$layout_engine_nu_full = get_item_version( $browser_user_agent, 'trident/', '', '' );
/** construct the proper real number. For example, trident 4 is msie 8 **/
if ( $layout_engine_nu_full ) {
$layout_engine_nu = get_item_math_number( $layout_engine_nu_full );
$layout_engine = 'trident';
/**
in compat mode, browser shows as msie 7, for now, check in future msie
versions. Note that this isn't used in new gecko type ua, so no compat mode switch
**/
if ( strstr( $browser_number, '7.' ) && !$b_gecko_ua ) {
$true_ie_number = get_item_math_number( $browser_number ) + ( intval( $layout_engine_nu ) - 3 );
}
else {
$true_ie_number = $browser_number;
}
/** this is to pull out specific trident versions, ucbrowser, etc.. **/
$j_count = count( $a_trident_types );
for ( $j = 0; $j < $j_count; $j++ ) {
if ( strstr( $browser_user_agent, $a_trident_types[$j] ) ) {
$trident_type = $a_trident_types[$j];
$trident_type_number = get_item_version( $browser_user_agent, $trident_type );
break;
}
}
/** note the string msie does not appear in gecko type msie useragents **/
if ( !$trident_type && $b_gecko_ua ) {
$trident_type = 'msie';
$trident_type_number = $browser_number;
}
}
/**
note: trident is engine from ie 4 onwards, but only shows after ie 8
but msie 7 is trident 3.1, and no trident numbers are known for earlier
**/
elseif ( intval( $browser_number ) <= 7 && intval( $browser_number ) >= 4 ) {
$layout_engine = 'trident';
if ( intval( $browser_number ) == 7 ) {
$layout_engine_nu_full = '3.1';
$layout_engine_nu = '3.1';
}
}
/** the 9 series is finally standards compatible, html 5 etc, so worth a new id **/
if ( $browser_number >= 9 ) {
$ie_version = 'ie9x';
}
/** 7/8 were not yet quite to standards levels but getting there **/
elseif ( $browser_number >= 7 ) {
$ie_version = 'ie7x';
}
/** then test for IE 5x mac, that's the most problematic IE out there **/
elseif ( strstr( $browser_user_agent, 'mac') ) {
$ie_version = 'ieMac';
}
/** ie 5/6 are both very weak in standards compliance **/
elseif ( $browser_number >= 5 ) {
$ie_version = 'ie5x';
}
elseif ( ( $browser_number > 3 ) && ( $browser_number < 5 ) ) {
$b_dom_browser = false;
$ie_version = 'ie4';
/** this depends on what you're using the script for, make sure this fits your needs **/
$b_safe_browser = true;
}
else {
$ie_version = 'old';
$b_dom_browser = false;
$b_safe_browser = false;
}
break;
case 'op':
if ( $browser_name == 'opr/' ) {
$browser_name = 'opr';
}
$browser_number = get_item_version( $browser_user_agent, $browser_name );
/**
opera is leaving version at 9.80 (or xx) for 10.x - see this for explanation
http://dev.opera.com/articles/view/opera-ua-string-changes/
**/
if ( strstr( $browser_number, '9.' )
&& strstr( $browser_user_agent, 'version/' ) ) {
get_set_count( 'set', 0 );
$browser_number = get_item_version( $browser_user_agent, 'version/' );
}
get_set_count( 'set', 0 );
$layout_engine_nu_full = get_item_version( $browser_user_agent, 'presto/' );
if ( $layout_engine_nu_full ) {
$layout_engine = 'presto';
$layout_engine_nu = get_item_math_number( $layout_engine_nu_full );
}
if ( ! $layout_engine_nu_full && $browser_name == 'opr' ) {
if ( strstr($browser_user_agent, 'blink') ) {
$layout_engine_nu_full = get_item_version( $browser_user_agent, 'blink' );
}
else {
$layout_engine_nu_full = get_item_version( $browser_user_agent, 'webkit' );
}
$layout_engine_nu = get_item_math_number( $layout_engine_nu_full );
/** assign rendering engine data **/
$layout_engine = 'blink';
$browser_name = 'opera';
}
/** opera 4 wasn't very useable. **/
if ( $browser_number < 5 ) {
$b_safe_browser = false;
}
break;
/**
note: webkit returns always the webkit version number, not the specific user
agent version, ie, webkit 583, not chrome 0.3
**/
case 'webkit':
/** note that this is the Webkit version number **/
$browser_number = get_item_version( $browser_user_agent, $browser_name );
/** assign rendering engine data **/
$layout_engine = 'webkit';
$layout_engine_nu = get_item_math_number( $browser_number );
$layout_engine_nu_full = $browser_number;
/** this is to pull out specific webkit versions, safari, google-chrome etc.. **/
$j_count = count( $a_webkit_types );
for ( $j = 0; $j < $j_count; $j++ ) {
if ( strstr( $browser_user_agent, $a_webkit_types[$j] ) ) {
$webkit_type = $a_webkit_types[$j];
/**
fixes a glitch: new safaris uses version/x.x.x for the safari number
however because safari number is NOT the same as webkit number, going
to keep returning the safari number, not the version/ number.
**/
/*
if ( $a_webkit_types[$j] == 'safari'
&& strstr( $browser_user_agent, 'version/' ) ) {
get_set_count( 'set', 0 );
$webkit_type_number = get_item_version( $browser_user_agent, 'version/' );
}
else {
*/
/**
and this is the webkit type version number, like: chrome 1.2
if omni web, we want the count 2, not default 1
**/
if ( $webkit_type == 'omniweb' ) {
get_set_count( 'set', 2 );
}
$webkit_type_number = get_item_version( $browser_user_agent, $webkit_type );
// }
/** epiphany hack **/
if ( $a_webkit_types[$j] == 'gtklauncher' ) {
$browser_name = 'epiphany';
}
else {
$browser_name = $a_webkit_types[$j];
}
if ( ( $a_webkit_types[$j] == 'chrome' || $a_webkit_types[$j] == 'chromium' ) &&
get_item_math_number( $webkit_type_number ) >= 28 ) {
if ( strstr($browser_user_agent, 'blink') ) {
$layout_engine_nu_full = get_item_version( $browser_user_agent, 'blink' );
$layout_engine_nu = get_item_math_number( $layout_engine_nu_full );
}
/** assign rendering engine data **/
$layout_engine = 'blink';
}
$browser_number = get_item_version( $browser_user_agent, $browser_name );
break;
}
}
break;
default:
$browser_number = get_item_version( $browser_user_agent, $browser_name );
break;
}
/** the browser was id'ed **/
$b_success = true;
break;
}
}
/**assigns defaults if the browser was not found in the loop test **/