citrus.ua /livehelp/_lib/functions.global.browser.inc.php

Language PHP Lines 213
MD5 Hash a30a9503a3fec3bfdbbc8ac8fc5e14ff Estimated Cost $4,959 (why?)
Repository https://bitbucket.org/spivovartsev/citrus.ua View Raw File View Project SPDX
  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
<?php

/****************************************************************************************
* LiveZilla functions.global.inc.php
* 
* Improper changes in this file may cause critical errors. It is strongly 
* recommended to desist from editing this file directly.
* 
***************************************************************************************/ 

if(!defined("IN_LIVEZILLA"))
	die();
	
function getWebBrowser()
{
	$currentBrowser = Array();
	$currentBrowser['platform'] = "Unknown";
	$currentBrowser['browser'] = "Unknown";
	$currentBrowser['version'] = "Unknown";
	$currentBrowser['allowed'] = true;
	$currentBrowser['agent'] = (isset($_SERVER['HTTP_USER_AGENT'])) ? $_SERVER['HTTP_USER_AGENT'] : ""; 

	if($currentBrowser['agent'] != "")
	{
		if(eregi("chrome", $currentBrowser['agent']))
		{
		    $currentBrowser['browser']="Chrome";
		}
		elseif(eregi("safari", $currentBrowser['agent']))
		{
		    $currentBrowser['browser']="Safari";
		}
		elseif(eregi("seamonkey", $currentBrowser['agent']))
		{
		    $currentBrowser['browser']="SeaMonkey";
		}
		elseif(eregi("firefox", $currentBrowser['agent']))
		{
			$currentBrowser['allowed'] = true;
		    $currentBrowser['browser']="Firefox";
		    $contents = stristr($currentBrowser['agent'], "Firefox");
		    $contents = explode("/",$contents);
		    $currentBrowser['version'] = (isset($contents[1])) ? $contents[1] : "unknown";
		}
		elseif(eregi("opera",$currentBrowser['agent']))
		{
		    $contents = stristr($currentBrowser['agent'], "opera");
			if (eregi("/", $contents))
			{
		        $contents = explode("/",$contents);
		        $currentBrowser['browser'] = $contents[0];
		        $contents = explode(" ",$contents[1]);
		        $currentBrowser['version'] = $contents[0];
		    }
			else
			{
	        	$contents = explode(" ",stristr($contents,"opera"));
	        	$currentBrowser['browser'] = $contents[0];
	        	$currentBrowser['version'] = $contents[1];
	    	}
			$currentBrowser['allowed'] = ($currentBrowser['version'] >= 8);
		}
		elseif(eregi("msie",$currentBrowser['agent']) && !eregi("opera",$currentBrowser['agent']))
		{
		    $contents = explode(" ",stristr($currentBrowser['agent'],"msie"));
			$currentBrowser['browser'] = "MSIE";
		    $currentBrowser['browser'] = $contents[0];
			if(isset($contents[1]))
		   		$currentBrowser['version'] = $contents[1];
			$currentBrowser['allowed'] = ($currentBrowser['version'] >= 5.5);
		}
		elseif(eregi("webtv",$currentBrowser['agent']))
		{
			$currentBrowser['allowed'] = false;
		    $contents = explode("/",stristr($currentBrowser['agent'],"webtv"));
		    $currentBrowser['browser'] = $contents[0];
		    $currentBrowser['version'] = $contents[1];
		}
		elseif(eregi("netpositive", $currentBrowser['agent']))
		{
			$currentBrowser['allowed'] = false;
		    $contents = explode("/",stristr($currentBrowser['agent'],"NetPositive"));
		    $currentBrowser['platform'] = "BeOS";
		    $currentBrowser['browser'] = $contents[0];
		    $currentBrowser['version'] = $contents[1];
		}
		elseif(eregi("omniweb",$currentBrowser['agent']))
		{
			$currentBrowser['allowed'] = false;
		    $contents = explode("/",stristr($currentBrowser['agent'],"omniweb"));
		    $currentBrowser['browser'] = $contents[0];
		    $currentBrowser['version'] = $contents[1];
		}
		elseif(eregi("microsoft internet explorer", $currentBrowser['agent']))
		{
			$currentBrowser['allowed'] = false;
		    $currentBrowser['browser'] = "MSIE";
		    $currentBrowser['version'] = "1.0";
		    $var = stristr($currentBrowser['agent'], "/");
		    if (ereg("308|425|426|474|0b1", $var))
		        $currentBrowser['version'] = "1.5";
		}
		elseif(eregi("galeon",$currentBrowser['agent']))
		{
			$currentBrowser['allowed'] = false;
		    $contents = explode(" ",stristr($currentBrowser['agent'],"galeon"));
		    $contents = explode("/",$contents[0]);
		    $currentBrowser['browser'] = $contents[0];
		    $currentBrowser['version'] = $contents[1];
		}
	
		elseif(eregi("mspie",$currentBrowser['agent']) || eregi('pocket', $currentBrowser['agent']))
		{
			$currentBrowser['allowed'] = false;
		    $contents = explode(" ",stristr($currentBrowser['agent'],"mspie"));
		    $currentBrowser['browser'] = "MSPIE";
		    $currentBrowser['platform'] = "WindowsCE";
		    if (eregi("mspie", $currentBrowser['agent']))
		        $currentBrowser['version'] = $contents[1];
		    else
			{
		        $contents = explode("/",$currentBrowser['agent']);
		        $currentBrowser['version'] = $contents[1];
		    }
		}
		elseif(eregi("konqueror",$currentBrowser['agent']))
		{
		    $contents = explode(" ",stristr($currentBrowser['agent'],"Konqueror"));
		    $contents = explode("/",$contents[0]);
		    $currentBrowser['browser'] = $contents[0];
		    $currentBrowser['version'] = $contents[1];
			$currentBrowser['allowed'] = ($currentBrowser['version'] >= 3.5);
		}
		elseif(eregi("icab",$currentBrowser['agent']))
		{
			$currentBrowser['allowed'] = false;
		    $contents = explode(" ",stristr($currentBrowser['agent'],"icab"));
		    $currentBrowser['browser'] = $contents[0];
		    $currentBrowser['version'] = $contents[1];
		}
		elseif(eregi("phoenix", $currentBrowser['agent']))
		{
			$currentBrowser['allowed'] = true;
		    $currentBrowser['browser'] = "Phoenix";
		    $contents = explode("/", stristr($currentBrowser['agent'],"Phoenix/"));
		    $currentBrowser['version'] = $contents[1];
		}
		elseif(eregi("firebird", $currentBrowser['agent']))
		{
			$currentBrowser['allowed'] = true;
		    $currentBrowser['browser']="Firebird";
		    $contents = stristr($currentBrowser['agent'], "Firebird");
		    $contents = explode("/",$contents);
		    $currentBrowser['version'] = $contents[1];
		}
		elseif(eregi("mozilla",$currentBrowser['agent']) && eregi("rv:[0-9].[0-9][a-b]",$currentBrowser['agent']) && !eregi("netscape",$currentBrowser['agent']))
		{
		    $currentBrowser['browser'] = "Mozilla";
		    $contents = explode(" ",stristr($currentBrowser['agent'],"rv:"));
		    eregi("rv:[0-9].[0-9][a-b]",$currentBrowser['agent'],$contents);
		    $currentBrowser['version'] = str_replace("rv:","",$contents[0]);
			$currentBrowser['allowed'] = ($currentBrowser['version'] >= 1.7);
		}
		elseif(eregi("mozilla",$currentBrowser['agent']) && eregi("rv:[0-9]\.[0-9]",$currentBrowser['agent']) && !eregi("netscape",$currentBrowser['agent']))
		{
		    $currentBrowser['browser'] = "Mozilla";
		    $contents = explode(" ",stristr($currentBrowser['agent'],"rv:"));
		    eregi("rv:[0-9]\.[0-9]\.[0-9]",$currentBrowser['agent'],$contents);
		    $currentBrowser['version'] = str_replace("rv:","",$contents[0]);
			$currentBrowser['allowed'] = ($currentBrowser['version'] >= 1.7);
		}
		elseif(eregi("libwww", $currentBrowser['agent']))
		{
			$currentBrowser['allowed'] = false;
		    if (eregi("amaya", $currentBrowser['agent']))
			{
		        $contents = explode("/",stristr($currentBrowser['agent'],"amaya"));
		        $currentBrowser['browser'] = "Amaya";
		        $contents = explode(" ", $contents[1]);
		        $currentBrowser['version'] = $contents[0];
		    }
			else
			{
		        $contents = explode("/",$currentBrowser['agent']);
		        $currentBrowser['browser'] = "Lynx";
		        $currentBrowser['version'] = $contents[1];
		    }
		}
		elseif(eregi("netscape",$currentBrowser['agent']))
		{
		    $contents = explode(" ",stristr($currentBrowser['agent'],"netscape"));
		    $contents = explode("/",$contents[0]);
		    $currentBrowser['browser'] = $contents[0];
		    $currentBrowser['version'] = $contents[1];
			$currentBrowser['allowed'] = ($currentBrowser['version'] >= 7);
		}
		elseif(eregi("mozilla",$currentBrowser['agent']) && !eregi("rv:[0-9]\.[0-9]\.[0-9]",$currentBrowser['agent']))
		{
		    $contents = explode(" ",stristr($currentBrowser['agent'],"mozilla"));
		    $contents = explode("/",$contents[0]);
			if(count($contents) > 1)
			{
		   		$currentBrowser['browser'] = "Netscape";
		    	$currentBrowser['version'] = $contents[1];
				$currentBrowser['allowed'] = ($currentBrowser['version'] >= 7);
			}
			else
				$currentBrowser['allowed'] = false;
		}
	}
	return $currentBrowser;
}
?>
Back to Top