protected function extract_files($moss = null) { global $DB; if ($moss == null) { $moss = $this->moss; } $sizelimit = $this->get_config('maxfilesize'); $fs = get_file_storage(); $contexti = $DB->get_record('context', array('instanceid' => $moss->cmid, 'contextlevel' => '70')); //$files = $fs->get_area_files(get_system_context()->id, 'plagiarism_moss', 'files', $moss->cmid, 'sortorder', false); $files = $fs->get_area_files($contexti->id, 'mod_workshop', 'submission_attachment', false, 'sortorder', false); foreach ($files as $file) { if ($file->get_filesize() > $sizelimit) { continue; } $content = $this->get_clear_utf8_content($file); if (empty($content)) { continue; } $path = $this->tempdir . $file->get_filepath() . $file->get_userid() . '/'; mkdir($path); $fullpath = $path . $file->get_filename(); $fullpath2 = $path . 'oo.java'; if (!check_dir_exists($path)) { throw new moodle_exception('errorcreatingdirectory', '', '', $path); } file_put_contents($fullpath, $content); //LKQ $filen = $file->get_filename(); $file_type = strtolower(substr($filen, strlen($filen) - 4, 4)); if ($file_type == '.zip') { $zp = new zip_archive(); $zp->open($fullpath, file_archive::OPEN); $filecount = $zp->count(); $content2 = ""; for ($i = 0; $i < $filecount; $i++) { $filename2 = $zp->get_info($i)->original_pathname; if (strtolower(substr($filename2, strlen($filename2) - 5, 5)) == '.java') { $tempfile = $zp->get_stream($i); $content2 = $content2 . fread($tempfile, 2 * 1024 * 1024); } } mtrace("\tfile " . $filecount . ' ' . strlen($content2)); file_put_contents($fullpath2, $content2); } } }