public static function detect_moodle2_format($tempdir) {
        $dirpath = make_backup_temp_directory($tempdir, false);
        if (!is_dir($dirpath)) {
            throw new convert_helper_exception('tmp_backup_directory_not_found', $dirpath);
        }

        $filepath = $dirpath . '/moodle_backup.xml';
        if (!file_exists($filepath)) {
            return false;
        }

        $handle     = fopen($filepath, 'r');
        $firstchars = fread($handle, 200);
        $status     = fclose($handle);

        if (strpos($firstchars,'<?xml version="1.0" encoding="UTF-8"?>') !== false and
            strpos($firstchars,'<moodle_backup>') !== false and
            strpos($firstchars,'<information>') !== false) {
                return true;
        }

        return false;
    }
public static function detect_moodle2_format($tempdir) {
        $dirpath = make_backup_temp_directory($tempdir, false);
        if (!is_dir($dirpath)) {
            throw new convert_helper_exception('tmp_backup_directory_not_found', $dirpath);
        }

        $filepath = $dirpath . '/moodle_backup.xml';
        if (!file_exists($filepath)) {
            return false;
        }

        $handle     = fopen($filepath, 'r');
        $firstchars = fread($handle, 200);
        $status     = fclose($handle);

        if (strpos($firstchars,'<?xml version="1.0" encoding="UTF-8"?>') !== false and
            strpos($firstchars,'<moodle_backup>') !== false and
            strpos($firstchars,'<information>') !== false) {
                return true;
        }

        return false;
    }
public static function detect_moodle2_format ( $ tempdir ) { $ dirpath = make_backup_temp_directory ( $ tempdir , false ) ; if ( ! is_dir ( $ dirpath ) ) { throw new convert_helper_exception ( 'tmp_backup_directory_not_found' , $ dirpath ) ; } $ filepath = $ dirpath . '/moodle_backup.xml' ; if ( ! file_exists ( $ filepath ) ) { return false ; } $ handle = fopen ( $ filepath , 'r' ) ; $ firstchars = fread ( $ handle , 200 ) ; $ status = fclose ( $ handle ) ; if ( strpos ( $ firstchars , '<?xml version="1.0" encoding="UTF-8"?>' ) !== false and strpos ( $ firstchars , '<moodle_backup>' ) !== false and strpos ( $ firstchars , '<information>' ) !== false ) { return true ; } return false ; }
Detects if the given folder contains an unpacked moodle2 backup

@param string $tempdir the name of the backup directory
@return boolean true if moodle2 format detected, false otherwise
Detects if the given folder contains an unpacked moodle2 backup