4545use function ob_end_clean ;
4646use function ob_start ;
4747use function parse_url ;
48- use function preg_match ;
4948use function realpath ;
5049use function rtrim ;
5150use function setcookie ;
@@ -162,7 +161,6 @@ public function loadAndCheck(string|null $source = null): void
162161 public function checkSystem (): void
163162 {
164163 $ this ->checkGd2 ();
165- $ this ->checkClient ();
166164 $ this ->checkUpload ();
167165 $ this ->checkUploadSize ();
168166 $ this ->checkOutputCompression ();
@@ -187,97 +185,6 @@ public function checkOutputCompression(): void
187185 $ this ->set ('OBGzip ' , true );
188186 }
189187
190- /**
191- * Sets the client platform based on user agent
192- *
193- * @param string $userAgent the user agent
194- */
195- private function setClientPlatform (string $ userAgent ): void
196- {
197- if (str_contains ($ userAgent , 'Win ' )) {
198- $ this ->set ('PMA_USR_OS ' , 'Win ' );
199- } elseif (str_contains ($ userAgent , 'Mac ' )) {
200- $ this ->set ('PMA_USR_OS ' , 'Mac ' );
201- } elseif (str_contains ($ userAgent , 'Linux ' )) {
202- $ this ->set ('PMA_USR_OS ' , 'Linux ' );
203- } elseif (str_contains ($ userAgent , 'Unix ' )) {
204- $ this ->set ('PMA_USR_OS ' , 'Unix ' );
205- } elseif (str_contains ($ userAgent , 'OS/2 ' )) {
206- $ this ->set ('PMA_USR_OS ' , 'OS/2 ' );
207- } else {
208- $ this ->set ('PMA_USR_OS ' , 'Other ' );
209- }
210- }
211-
212- /**
213- * Determines platform (OS), browser and version of the user
214- * Based on a phpBuilder article:
215- *
216- * @see http://www.phpbuilder.net/columns/tim20000821.php
217- */
218- public function checkClient (): void
219- {
220- $ httpUserAgent = '' ;
221- if (Core::getEnv ('HTTP_USER_AGENT ' ) !== '' ) {
222- $ httpUserAgent = Core::getEnv ('HTTP_USER_AGENT ' );
223- }
224-
225- // 1. Platform
226- $ this ->setClientPlatform ($ httpUserAgent );
227-
228- // 2. browser and version
229- // (must check everything else before Mozilla)
230-
231- $ isMozilla = preg_match ('@Mozilla/([0-9]\.[0-9]{1,2})@ ' , $ httpUserAgent , $ mozillaVersion ) === 1 ;
232-
233- if (preg_match ('@Opera(/| )([0-9]\.[0-9]{1,2})@ ' , $ httpUserAgent , $ logVersion ) === 1 ) {
234- $ this ->set ('PMA_USR_BROWSER_VER ' , $ logVersion [2 ]);
235- $ this ->set ('PMA_USR_BROWSER_AGENT ' , 'OPERA ' );
236- } elseif (preg_match ('@(MS)?IE ([0-9]{1,2}\.[0-9]{1,2})@ ' , $ httpUserAgent , $ logVersion ) === 1 ) {
237- $ this ->set ('PMA_USR_BROWSER_VER ' , $ logVersion [2 ]);
238- $ this ->set ('PMA_USR_BROWSER_AGENT ' , 'IE ' );
239- } elseif (preg_match ('@Trident/(7)\.0@ ' , $ httpUserAgent , $ logVersion ) === 1 ) {
240- $ this ->set ('PMA_USR_BROWSER_VER ' , (string ) ((int ) $ logVersion [1 ] + 4 ));
241- $ this ->set ('PMA_USR_BROWSER_AGENT ' , 'IE ' );
242- } elseif (preg_match ('@OmniWeb/([0-9]{1,3})@ ' , $ httpUserAgent , $ logVersion ) === 1 ) {
243- $ this ->set ('PMA_USR_BROWSER_VER ' , $ logVersion [1 ]);
244- $ this ->set ('PMA_USR_BROWSER_AGENT ' , 'OMNIWEB ' );
245- // Konqueror 2.2.2 says Konqueror/2.2.2
246- // Konqueror 3.0.3 says Konqueror/3
247- } elseif (preg_match ('@(Konqueror/)(.*)(;)@ ' , $ httpUserAgent , $ logVersion ) === 1 ) {
248- $ this ->set ('PMA_USR_BROWSER_VER ' , $ logVersion [2 ]);
249- $ this ->set ('PMA_USR_BROWSER_AGENT ' , 'KONQUEROR ' );
250- // must check Chrome before Safari
251- } elseif ($ isMozilla && preg_match ('@Chrome/([0-9.]*)@ ' , $ httpUserAgent , $ logVersion ) === 1 ) {
252- $ this ->set ('PMA_USR_BROWSER_VER ' , $ logVersion [1 ]);
253- $ this ->set ('PMA_USR_BROWSER_AGENT ' , 'CHROME ' );
254- // newer Safari
255- } elseif ($ isMozilla && preg_match ('@Version/(.*) Safari@ ' , $ httpUserAgent , $ logVersion ) === 1 ) {
256- $ this ->set ('PMA_USR_BROWSER_VER ' , $ logVersion [1 ]);
257- $ this ->set ('PMA_USR_BROWSER_AGENT ' , 'SAFARI ' );
258- // older Safari
259- } elseif ($ isMozilla && preg_match ('@Safari/([0-9]*)@ ' , $ httpUserAgent , $ logVersion ) === 1 ) {
260- $ this ->set ('PMA_USR_BROWSER_VER ' , $ mozillaVersion [1 ] . '. ' . $ logVersion [1 ]);
261- $ this ->set ('PMA_USR_BROWSER_AGENT ' , 'SAFARI ' );
262- // Firefox
263- } elseif (
264- ! str_contains ($ httpUserAgent , 'compatible ' )
265- && preg_match ('@Firefox/([\w.]+)@ ' , $ httpUserAgent , $ logVersion ) === 1
266- ) {
267- $ this ->set ('PMA_USR_BROWSER_VER ' , $ logVersion [1 ]);
268- $ this ->set ('PMA_USR_BROWSER_AGENT ' , 'FIREFOX ' );
269- } elseif (preg_match ('@rv:1\.9(.*)Gecko@ ' , $ httpUserAgent ) === 1 ) {
270- $ this ->set ('PMA_USR_BROWSER_VER ' , '1.9 ' );
271- $ this ->set ('PMA_USR_BROWSER_AGENT ' , 'GECKO ' );
272- } elseif ($ isMozilla ) {
273- $ this ->set ('PMA_USR_BROWSER_VER ' , $ mozillaVersion [1 ]);
274- $ this ->set ('PMA_USR_BROWSER_AGENT ' , 'MOZILLA ' );
275- } else {
276- $ this ->set ('PMA_USR_BROWSER_VER ' , 0 );
277- $ this ->set ('PMA_USR_BROWSER_AGENT ' , 'OTHER ' );
278- }
279- }
280-
281188 /**
282189 * Whether GD2 is present
283190 */
0 commit comments