<commit_before><?php
  /**********************************************************
  /* Stores the OLAT .zip that was uploaded previously, 
	/* unzips it in a temporary folder with a random integer,
	/* (so that there can't be any overwrites).
	/* Then it reads out runstructure.xml and gets out
	/* the important parts and shows them on the page.
	/**********************************************************
	/* <NAME>
	/*********************************************************/
	if(isset($_FILES["file"])) {
		if($_FILES["file"]) {
		
			// PHP has difficulties with .'s, so they're all put in their
			// own variables.
			$st = "org.olat.course.nodes.STCourseNode";				// Structure
			$en = "org.olat.course.nodes.ENCourseNode";				// Enrollment
			$sp = "org.olat.course.nodes.SPCourseNode";				// Course pages
			$iq = "org.olat.course.nodes.IQTESTCourseNode";		// Tests
			$fo = "org.olat.course.nodes.FOCourseNode";				// Forums
			
			// Random integer for storing unzips, so that there will be no overwrites.
			$num = "";
			for ($i = 0; $i < 9; $i++) {
				$num .= strval(mt_rand(0, 9));
			}
			
			$path = $_FILES["file"]["tmp_name"];
			
			$zip = new ZipArchive;
			if ($zip->open($path)) {
				$expath = getcwd() . "/tmp/" . $num . "/";
				$zip->extractTo($expath);
				$zip->close();
				
				if($olat = simplexml_load_file($expath . "runstructure.xml")) {}
				else {
					echo "<p>Error reading XML.</p><br>";
					echo "<a href='index.php'>Go back</a>";
				}
			}
			else {
				echo "<p>Error parsing file.</p><br>";
				echo "<a href='index.php'>Go back</a>";
			}
		}
	}
	else {
		echo "<p>No file found, did you land on this page by accident?</p><br>";
		echo "<a href='index.php'>Go back</a>";
	}
?>
<!DOCTYPE html>
<html>
<head>
	<title>OLAT2Moodle</title>
	<meta charset="utf-8">
</head>
<body>
	<h1><?php echo $olat->rootNode->longTitle; ?></h1>
	<h2><?php echo $olat->rootNode->shortTitle; ?></h2>
	<h3>Type of course: <?php echo $olat->rootNode->attributes(); ?></h3>
	<?php foreach ($olat->rootNode->children->children() as $child) {
		echo $child->getName() . "<br>";
		if ($child->children->count() > 0) {
			foreach ($child->children->children() as $child2) {
				echo "> " . $child2->getName() . "<br>";
				if ($child2->children->count() > 0) {
					foreach ($child2->children->children() as $child3) {
						echo ">> " . $child3->getName() . "<br>";
						if ($child3->children->count() > 0) {
							foreach ($child3->children->children() as $child4) {
								echo ">>> " . $child4->getName() . "<br>";
							}
						}
					}
				}
			}
		}
		echo "<br>";
	} ?>
	<p><?php echo $olat->rootNode->children->$st->children->$st->children->$sp->longTitle; ?></p>
	<?php foreach ($olat->rootNode->children->$st->children->$st->children->$sp->moduleConfiguration->config->entry as $strng) {
		if($strng->string == "file") { ?>
			<p><?php echo (file_get_contents($expath . "coursefolder" . $strng->string[1])); ?></p>
		<?php } } ?>
</body>
</html><commit_msg>Each level has a different colour, and the pictures work thanks to jQuery -B<commit_after><?php
  /**********************************************************
  /* Stores the OLAT .zip that was uploaded previously, 
	/* unzips it in a temporary folder with a random integer,
	/* (so that there can't be any accidental overwrites).
	/* Then it reads out runstructure.xml and gets out
	/* the important parts and shows them on the page.
	/**********************************************************
	/* <NAME>
	/*********************************************************/
	
	require_once("functions.php");
	
	if(isset($_FILES["file"])) {
		if($_FILES["file"]) {
		
			// PHP has difficulties with .'s, so they're all put in their
			// own variables.
			$st = "org.olat.course.nodes.STCourseNode";				// Structure
			$en = "org.olat.course.nodes.ENCourseNode";				// Enrollment
			$sp = "org.olat.course.nodes.SPCourseNode";				// Course pages
			$iq = "org.olat.course.nodes.IQTESTCourseNode";		// Tests
			$fo = "org.olat.course.nodes.FOCourseNode";				// Forums
			
			// Random integer for storing unzips, so that there will be no overwrites.
			$num = "";
			for ($i = 0; $i < 9; $i++) {
				$num .= strval(mt_rand(0, 9));
			}
			
			$path = $_FILES["file"]["tmp_name"];
			
			// Extracts the .zip and puts it in its own folder
			// with randomly generated number for name.
			$zip = new ZipArchive;
			if ($zip->open($path)) {
				$expath = getcwd() . "/tmp/" . $num . "/";
				//$expath = getcwd() . "/tmp/";
				$zip->extractTo($expath);
				$zip->close();
				
				// $olat will be the root for the XML file.
				if($olat = simplexml_load_file($expath . "runstructure.xml")) {}
				else {
					echo "<p>Error reading XML.</p><br>";
					echo "<a href='index.php'>Go back</a>";
				}
			}
			else {
				echo "<p>Error parsing file.</p><br>";
				echo "<a href='index.php'>Go back</a>";
			}
		}
	}
	else {
		echo "<p>No file found, did you land on this page by accident?</p><br>";
		echo "<a href='index.php'>Go back</a>";
	}
	
?>
<!DOCTYPE html>
<html>
<head>
	<title>OLAT2Moodle</title>
	<meta charset="utf-8">
	<!--<link rel="stylesheet" type="text/css" href="css/reset.css">-->
	<link rel="stylesheet" type="text/css" href="css/style.css">
	<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script type="text/javascript">
		$(function() {
			$('img').each(function() {
				var $img = $(this);
				var oldimgsrc = $img.attr('src');
				
				var newimgsrc = "/olat2moodle/tmp/<?php echo $num ?>/coursefolder/" + oldimgsrc;
				
				$img.attr('src', newimgsrc);
			});
		});
	</script>
</head>
<body>
	<h1><?php echo $olat->rootNode->longTitle; ?></h1>
	<h2><?php echo $olat->rootNode->shortTitle; ?></h2>
	<h3>Type of course: <?php echo $olat->rootNode->attributes(); ?></h3>
	<?php foreach ($olat->rootNode->children->children() as $child) { 				// Reads out all children, and the children's children. ?>
		<div class="root">
		<?php echo $child->getName() . "<br>"; ?>
		</div>
		<?php if ($child->children->count() > 0) {
			foreach ($child->children->children() as $child2) { ?>
				<div class="rootc1">
				<?php echo "> " . $child2->getName() . "<br>";
				echo $child2->shortTitle . "<br>"; ?>
				</div>
				<?php if ($child2->children->count() > 0) {
					foreach ($child2->children->children() as $child3) { ?>
						<div class="rootc2">
						<?php echo ">> " . $child3->getName() . "<br>";
						echo $child3->shortTitle . "<br>";
						foreach ($child3->moduleConfiguration->config->entry as $strng) {
							if($strng->string == "file") {
								$url = $expath . "coursefolder" . $strng->string[1];
								echo "<p>" . (file_get_contents($url)) . "</p>";
							}
						} ?>
						</div>
					<?php }
				}
			}
		}
		echo "<br>";
	} ?>
</body>
</html>
{'fraction_non_alphanumeric': 0.2537773214023764, 'fraction_numerical': 0.007774680944697081, 'mean_word_length': 3.109704641350211, 'pattern_counts': {'":': 0, '<': 120, '<?xml version=': 0, '>': 210, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2797171', 'n_tokens_mistral': 2777, 'n_tokens_neox': 2336, 'n_words': 552}