public static function getTmpDir()
    {
      $_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config");
      $tmpDir = $_config->getTempDirectory();
      if ( $tmpDir )
      {
        return $tmpDir;
      }
      if ( !function_exists('sys_get_temp_dir')) {
        function sys_get_temp_dir() {
          if( $temp=getenv('TMP') ){
            return $temp;
          }
          if( $temp=getenv('TEMP') ) {
            return $temp;
          }
          if( $temp=getenv('TMPDIR') ) {
            return $temp;
          }
          $temp = tempnam(__FILE__,'');
          if ( file_exists($temp) ){
            unlink($temp);
            return dirname($temp);
          }
          return null;
        }
      }
      return sys_get_temp_dir();
    }