-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.php
More file actions
73 lines (58 loc) · 2.43 KB
/
admin.php
File metadata and controls
73 lines (58 loc) · 2.43 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
<?php
/**
* Copyright (c) 2017 John Malandrakis
* This software is provided to St. John's University to be
* used, modified, and distributed at their discretion.
* All other rights reserved.
*/
require_once './php/initialize.php';
$page_style = "admin.css";
$page_title = "Administration";
/*
* On page submit, temporarily store uploaded file, and then send to populate database
*/
if (isset($_POST['submit'])) {
$uploadDir = ROOT_DIR . 'data/';
$uploadFile = $uploadDir . basename($_FILES['dataFile']['name']);
if (move_uploaded_file($_FILES['dataFile']['tmp_name'], $uploadFile)) {
DBHandler::populateDB($uploadFile);
$msg = "File successfully uploaded and validated!";
} else {
$msg = "File was unable to be uploaded or validated!";
}
}
?>
<html>
<?php include ROOT_DIR . 'php/template/head_template.php'; ?>
<body>
<?php include ROOT_DIR . 'php/template/navigation_template.php'; ?>
<main>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading text-center">
<span>Administration<span>
</div>
<div class="panel-body">
<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="50000000">
<div class="form-row">
<div class="form-group col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
<label for="dataFile">Select Data File</label>
<div>
<input class="form-control" type="file" name="dataFile">
</div>
</div>
<div class="form-group col-xs-10 col-xs-offset-1 col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
</div>
</div>
<input class="btn btn-primary col-xs-4 col-xs-offset-4 col-sm-4 col-sm-offset-4" type="submit" name="submit">
</form>
</div>
</div>
</div>
</main>
<?php include ROOT_DIR . 'php/template/footer_template.php'; ?>
<script type="text/javascript">
</script>
</body>
</html>