original_string: public static function detect_format($tempdir) {
          global $CFG;
  
          $tempdirpath = make_backup_temp_directory($tempdir, false);
          $filepath = $tempdirpath . '/moodle.xml';
          if (file_exists($filepath)) {
              // looks promising, lets load some information
              $handle = fopen($filepath, 'r');
              $first_chars = fread($handle, 200);
              fclose($handle);
  
              // check if it has the required strings
              if (strpos($first_chars,'<?xml version="1.0" encoding="UTF-8"?>') !== false and
                  strpos($first_chars,'<MOODLE_BACKUP>') !== false and
                  strpos($first_chars,'<INFO>') !== false) {
  
                  return backup::FORMAT_MOODLE1;
              }
          }
  
          return null;
      }
code: public static function detect_format($tempdir) {
          global $CFG;
  
          $tempdirpath = make_backup_temp_directory($tempdir, false);
          $filepath = $tempdirpath . '/moodle.xml';
          if (file_exists($filepath)) {
              // looks promising, lets load some information
              $handle = fopen($filepath, 'r');
              $first_chars = fread($handle, 200);
              fclose($handle);
  
              // check if it has the required strings
              if (strpos($first_chars,'<?xml version="1.0" encoding="UTF-8"?>') !== false and
                  strpos($first_chars,'<MOODLE_BACKUP>') !== false and
                  strpos($first_chars,'<INFO>') !== false) {
  
                  return backup::FORMAT_MOODLE1;
              }
          }
  
          return null;
      }
code_tokens: public static function detect_format ( $ tempdir ) { global $ CFG ; $ tempdirpath = make_backup_temp_directory ( $ tempdir , false ) ; $ filepath = $ tempdirpath . '/moodle.xml' ; if ( file_exists ( $ filepath ) ) { // looks promising, lets load some information $ handle = fopen ( $ filepath , 'r' ) ; $ first_chars = fread ( $ handle , 200 ) ; fclose ( $ handle ) ; // check if it has the required strings if ( strpos ( $ first_chars , '<?xml version="1.0" encoding="UTF-8"?>' ) !== false and strpos ( $ first_chars , '<MOODLE_BACKUP>' ) !== false and strpos ( $ first_chars , '<INFO>' ) !== false ) { return backup :: FORMAT_MOODLE1 ; } } return null ; }
docstring: Detects the Moodle 1.9 format of the backup directory
  
  @param string $tempdir the name of the backup directory
  @return null|string backup::FORMAT_MOODLE1 if the Moodle 1.9 is detected, null otherwise
docstring_tokens: Detects the Moodle 1 . 9 format of the backup directory