forked from dbwebb-se/lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
71 lines (54 loc) · 1.52 KB
/
index.php
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
<?php
/**
* Frontend to create new labs or get existing ones from the key.
* Pagecontroller
*/
include __DIR__ . "/config.php";
include __DIR__ . "/functions.php";
/**
* Check that database exists and open it
*/
if (!is_writable(__DIR__)) {
echo "<p>You must make this directory writable. Then click <a href='?init'>this link to generate the database tables</a>.</p>";
exit;
}
/**
* Init the database, create table
*/
if (isset($_GET['init'])) {
init();
}
/**
* Get lab from existing key
*/
$doKey = isset($_GET['doKey']);
$key = isset($_GET['key']) ? $_GET['key'] : null;
/**
* Generate a lab
*/
$doGenerate = isset($_GET['doGenerate']);
$action = isset($_GET['action']) ? $_GET['action'] : null;
$acronym = isset($_GET['acronym']) ? $_GET['acronym'] : null;
$course = isset($_GET['course']) ? $_GET['course'] : null;
$lab = isset($_GET['lab']) ? $_GET['lab'] : null;
$created = date('Y-m-d H:i:s');
$gen_key = null;
if ($doGenerate) {
$gen_key = generateKey($acronym, $course, $lab, $created);
if ($action == "only-key") {
die($gen_key);
}
}
// Generate bundle och lab content
if ($action == "bundle") {
$key = isset($key) ? $key : $gen_key;
include "view/generate/bundle_tpl.php";
die();
}
$title = "Lab generation";
include "view/gui/header_tpl.php";
include "view/gui/lab-utility-menu_tpl.php";
include "view/gui/create-lab_tpl.php";
$fullMenu = true;
include "view/gui/details-existing-lab_tpl.php";
include "view/gui/footer_tpl.php";