framework/Mvc/Extensions/Ckfinder/lib/core/connector/php/php5/Core/ResourceTypeConfig.php
public function checkExtension(&$fileName, $renameIfRequired = true)
    {
        if (strpos($fileName, '.') === false) {
            return true;
        }

        if (is_null($this->_config)) {
            $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
        }

        if ($this->_config->getCheckDoubleExtension()) {
            $pieces = explode('.', $fileName);

            // First, check the last extension (ex. in file.php.jpg, the "jpg").
            if ( !$this->checkSingleExtension( $pieces[sizeof($pieces)-1] ) ) {
                return false;
            }

            if ($renameIfRequired) {
                // Check the other extensions, rebuilding the file name. If an extension is
                // not allowed, replace the dot with an underscore.
                $fileName = $pieces[0] ;
                for ($i=1; $i<sizeof($pieces)-1; $i++) {
                    $fileName .= $this->checkSingleExtension( $pieces[$i] ) ? '.' : '_' ;
                    $fileName .= $pieces[$i];
                }

                // Add the last extension to the final name.
                $fileName .= '.' . $pieces[sizeof($pieces)-1] ;
            }
        }
        else {
            // Check only the last extension (ex. in file.php.jpg, only "jpg").
            return $this->checkSingleExtension( substr($fileName, strrpos($fileName,'.')+1) );
        }

        return true;
    }
public function checkExtension(&$fileName, $renameIfRequired = true)
    {
        if (strpos($fileName, '.') === false) {
            return true;
        }

        if (is_null($this->_config)) {
            $this->_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
        }

        if ($this->_config->getCheckDoubleExtension()) {
            $pieces = explode('.', $fileName);

            // First, check the last extension (ex. in file.php.jpg, the "jpg").
            if ( !$this->checkSingleExtension( $pieces[sizeof($pieces)-1] ) ) {
                return false;
            }

            if ($renameIfRequired) {
                // Check the other extensions, rebuilding the file name. If an extension is
                // not allowed, replace the dot with an underscore.
                $fileName = $pieces[0] ;
                for ($i=1; $i<sizeof($pieces)-1; $i++) {
                    $fileName .= $this->checkSingleExtension( $pieces[$i] ) ? '.' : '_' ;
                    $fileName .= $pieces[$i];
                }

                // Add the last extension to the final name.
                $fileName .= '.' . $pieces[sizeof($pieces)-1] ;
            }
        }
        else {
            // Check only the last extension (ex. in file.php.jpg, only "jpg").
            return $this->checkSingleExtension( substr($fileName, strrpos($fileName,'.')+1) );
        }

        return true;
    }
public function checkExtension ( & $ fileName , $ renameIfRequired = true ) { if ( strpos ( $ fileName , '.' ) === false ) { return true ; } if ( is_null ( $ this -> _config ) ) { $ this -> _config = & CKFinder_Connector_Core_Factory :: getInstance ( "Core_Config" ) ; } if ( $ this -> _config -> getCheckDoubleExtension ( ) ) { $ pieces = explode ( '.' , $ fileName ) ; // First, check the last extension (ex. in file.php.jpg, the "jpg"). if ( ! $ this -> checkSingleExtension ( $ pieces [ sizeof ( $ pieces ) - 1 ] ) ) { return false ; } if ( $ renameIfRequired ) { // Check the other extensions, rebuilding the file name. If an extension is // not allowed, replace the dot with an underscore. $ fileName = $ pieces [ 0 ] ; for ( $ i = 1 ; $ i < sizeof ( $ pieces ) - 1 ; $ i ++ ) { $ fileName .= $ this -> checkSingleExtension ( $ pieces [ $ i ] ) ? '.' : '_' ; $ fileName .= $ pieces [ $ i ] ; } // Add the last extension to the final name. $ fileName .= '.' . $ pieces [ sizeof ( $ pieces ) - 1 ] ; } } else { // Check only the last extension (ex. in file.php.jpg, only "jpg"). return $ this -> checkSingleExtension ( substr ( $ fileName , strrpos ( $ fileName , '.' ) + 1 ) ) ; } return true ; }
Check extension, return true if file name is valid.
Return false if extension is on denied list.
If allowed extensions are defined, return false if extension isn't on allowed list.

@access public
@param string $extension extension
@param boolean $renameIfRequired whether try to rename file or not
@return boolean
Check extension return true if file name is valid . Return false if extension is on denied list . If allowed extensions are defined return false if extension isn t on allowed list .