Project

General

Profile

« Previous | Next » 

Revision 1828

Added by Luisehahne over 13 years ago

! Update Checks if a browser's user agent string is compatible with the FCKeditor.
! Set WebsiteBaker Module Version to 2.9.8

View differences:

fckeditor_php5.php
25 25
 * instances in PHP pages on server side.
26 26
 */
27 27

  
28

  
28 29
/**
29 30
 * Check if browser is compatible with FCKeditor.
30 31
 * Return true if is compatible.
......
33 34
 */
34 35
function FCKeditor_IsCompatibleBrowser()
35 36
{
36
	if ( isset( $_SERVER ) ) {
37
		$sAgent = $_SERVER['HTTP_USER_AGENT'] ;
38
	}
39
	else {
40
		global $HTTP_SERVER_VARS ;
41
		if ( isset( $HTTP_SERVER_VARS ) ) {
42
			$sAgent = $HTTP_SERVER_VARS['HTTP_USER_AGENT'] ;
43
		}
44
		else {
45
			global $HTTP_USER_AGENT ;
46
			$sAgent = $HTTP_USER_AGENT ;
47
		}
48
	}
37
    $sAgent = 'sorry';
38
    if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) {
39
        $sAgent = $_SERVER['HTTP_USER_AGENT'] ;
40
    } else {
41
        if( isset( $GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'] )) {
42
            $sAgent = $GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'] ;
43
        } else {
44
            if( isset( $GLOBALS['HTTP_USER_AGENT'] )) {
45
                $sAgent = $GLOBALS['HTTP_USER_AGENT'];
46
            }
47
        }
48
    }
49 49

  
50
	if ( strpos($sAgent, 'MSIE') !== false && strpos($sAgent, 'mac') === false && strpos($sAgent, 'Opera') === false )
51
	{
52
		$iVersion = (float)substr($sAgent, strpos($sAgent, 'MSIE') + 5, 3) ;
53
		return ($iVersion >= 5.5) ;
54
	}
55
	else if ( strpos($sAgent, 'Gecko/') !== false )
56
	{
57
		$iVersion = (int)substr($sAgent, strpos($sAgent, 'Gecko/') + 6, 8) ;
58
		return ($iVersion >= 3.5) ;
59
//		return ($iVersion >= 20030210) ;
60
	}
61
	else if ( strpos($sAgent, 'Opera/') !== false )
62
	{
63
		$fVersion = (float)substr($sAgent, strpos($sAgent, 'Opera/') + 6, 4) ;
64
		return ($fVersion >= 9.5) ;
65
	}
66
	else if ( preg_match( "|AppleWebKit/(\d+)|i", $sAgent, $matches ) )
67
	{
68
		$iVersion = $matches[1] ;
69
		return ( $matches[1] >= 522 ) ;
70
	}
71
	else
72
		return false ;
50
    // check for client agent
51
    $bRetval = false;
52
    if(preg_match('/ gecko\/([0-9.]+)/si', $sAgent, $aMatches)) {
53
        // [Gecko] Firefox, SeaMonkey and most Gecko based browsers
54
        if(strpos($aMatches[1], '.')) {
55
            // Versions from Gecko 17.0 up
56
            $bRetval = version_compare($aMatches[1], '4.0', '>=');
57
        } else {
58
            // versions before Gecko 17.0
59
            if((int)$aMatches[1] >= 20030210) { $bRetval = true; }
60
        }
61
    } elseif(preg_match('/ applewebkit\/([0-9.]+)/si', $sAgent, $aMatches)) {
62
        // [AppleWebKit] Crome, Safari
63
        $bRetval = version_compare($aMatches[1], '522', '>=');
64
    } elseif(preg_match('/^opera\/([0-9.]+)/si', $sAgent, $aMatches)) {
65
        // [Opera] Opera
66
        $bRetval = version_compare($aMatches[1], '9.5', '>=');
67
    } elseif(preg_match('/^mozilla\/[\d.]+\s\(.*?msie[^\)]*\(.*?\ msie\ ([0-9.]+);/si', $sAgent, $aMatches)) {
68
        // [MSIE] Internetexplorer compatibility mode
69
        $bRetval = version_compare($aMatches[1], '5.5', '>=');
70
    } elseif(preg_match('/^mozilla\/[\d.]+\s\(.*?\ msie\ ([0-9.]+);/si', $sAgent, $aMatches)) {
71
        // [MSIE] Internetexplorer
72
        $bRetval = version_compare($aMatches[1], '5.5', '>=');
73
    } else {
74
        // undefined client agent
75
        $bRetval = false;
76
    }
77
    return $bRetval;
73 78
}
74 79

  
75 80
class FCKeditor

Also available in: Unified diff