-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathindex.php
More file actions
134 lines (118 loc) · 3.96 KB
/
index.php
File metadata and controls
134 lines (118 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
function delTree($dir) {
$files = array_diff(scandir($dir), array('.','..'));
foreach ($files as $file) {
if (is_dir("$dir/$file")) {
delTree("$dir/$file");
} else {
unlink("$dir/$file");
}
}
return rmdir($dir);
}
if (isset($_GET["delink"])) {
$unlink = $_GET["delink"];
delTree( __DIR__ . "/$unlink" );
$path = getcwd();
$zip = $path . '/' . $unlink . '.zip';
if (file_exists($zip)) {
unlink($zip);
}
header("location: index.php");
die();
}
if (isset($_GET["unlink"])) {
$unlink = $_GET["unlink"];
delTree( __DIR__ . "/$unlink" );
header("location: index.php");
die();
} ?><!doctype html>
<html>
<head>
<style>
* {
font-family: sans-serif;
}
th {
text-align: left;
}
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #eee;
padding: 10px;
}
tbody tr:nth-of-type(odd) td {
background-color: #eee;
}
th:first-of-type {
width: 50%;
}
</style>
</head>
<body>
<h1>Course Scorm Debug</h1>
<table>
<thead><tr><th>Folder</th><th>Scorm 1.2</th><th>Scorm 2004</th><th>Remove?</th></tr></thead>
<tbody>
<?php
$target = '.';
// extract all zip files
$path = getcwd();
$filelist = glob("$path/*.zip");
foreach($filelist as $file) {
$fold = $path . "/" . basename($file, ".zip");
if (!file_exists($fold)) {
$zipArchive = new ZipArchive();
$result = $zipArchive->open($file);
if ($result === TRUE) {
$zipArchive->extractTo($path . "/" . basename($file, ".zip"));
$zipArchive->close();
// unlink($file);
}
}
}
// list all packages that have scorm
//TODO: fix - read manifest to get start page
$directories = array_diff(scandir($target), array('..', '.', '.git','2012','2013','2014','2015','2016','2017','2018','2019','2020')); // cheaty but works
natcasesort($directories);
foreach ($directories as $value) {
if (is_dir($target . '/' . $value)) {
$t = preg_replace("/[^a-zA-Z]/", "", $value);
if (file_exists("$value/imsmanifest.xml")) {
$manifest = file_get_contents("$value/imsmanifest.xml");
$manifest = str_replace("adlcp:", "", $manifest); // imscp packages may have un-namespaced prefixes
$xmlDoc = simplexml_load_string ($manifest);
$i = $value . "/" . $xmlDoc->resources[0]->resource[0]->attributes()->href;
// $xmlDoc = new SimpleXmlElement($manifest);
// foreach($xmlDoc->getDocNamespaces() as $strPrefix => $strNamespace) {
// if(strlen($strPrefix)==0) {
// $strPrefix="a"; //Assign an arbitrary namespace prefix.
// }
// $xmlDoc->registerXPathNamespace($strPrefix,$strNamespace);
// }
} else {
if (file_exists($value . "/SCO1/index.html")) {
$i = $value . "/SCO1/index.html";
} else if (file_exists($value . "/SCO1/en-us/Content.html")) {
$i = $value . "/SCO1/en-us/Content.html";
} else if (file_exists($value . "/index.html")) {
$i = $value . "/index.html";
} else if (file_exists($value . "/launch.html")) {
$i = $value . "/launch.html";
} else {
$i = $value . "/";
}
}
echo "<tr><td>$value</td>";
echo "<td><a href='12.php?$i' target='sco12$t'>Launch</a></td>";
echo "<td><a href='2004.html?&sco=$i' target='sco2004$t'>Launch</a></td>";
echo "<td><a href='index.php?unlink=" . urlencode($value) . "'>Delete</a> (<a href='index.php?delink=" . urlencode($value) . "'>+ Zip</a>)</td>";
echo "</tr>";
}
}
?>
</tbody></table>
</body></html>