-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-problems.php
112 lines (107 loc) · 4.23 KB
/
post-problems.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
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
<?php
session_start();
if (!isset($_SESSION["user"]) || empty($_SESSION["user"]["officer"])) {
die("Sorry, you do not have permission to view this page.");
}
if (isset($_POST['pr']) && isset($_POST['title']) && isset($_POST['state'])) {
$prob = $_POST['pr'];
unset($_POST['pr']);
move_uploaded_file($_FILES['inputFile']['tmp_name'], 'test-data/' . $prob . '.in');
move_uploaded_file($_FILES['outputFile']['tmp_name'], 'test-data/' . $prob . '.out');
//move_uploaded_file($_FILES['inputFile']['tmp_name'], 'test-data2019/' . $prob . '.in');
//move_uploaded_file($_FILES['outputFile']['tmp_name'], 'test-data2019/' . $prob . '.out');
//move_uploaded_file($_FILES['inputFile']['tmp_name'], '/public_html/homesteadhacks/test-data2019/' . $prob . '.in');
//move_uploaded_file($_FILES['outputFile']['tmp_name'], '/public_html/homesteadhacks/test-data2019/' . $prob . '.out');
unset($_POST['inputFile']);
unset($_POST['outputFile']);
// Change this maybe!!!
foreach ($_POST as $key => $value) $_POST[$key] = $_POST[$key]; // str_replace("\r\n", "<br>", $_POST[$key]);
// $problems = json_decode(file_get_contents('content/problems2019.json'), true);
$problems = json_decode(file_get_contents('content/problems.json'), true);
//$problems = json_decode(file_get_contents('homesteadhacks/hackathonContent/problems.json'), true);
$problems = array($prob => $_POST) + $problems;
file_put_contents('content/problems.json', json_encode($problems, JSON_PRETTY_PRINT));
//file_put_contents('content/problems2019.json', json_encode($problems, JSON_PRETTY_PRINT));
// file_put_contents('homesteadhacks/hackathonContent/problems.json', json_encode($problems, JSON_PRETTY_PRINT));
header("Location: /problems");
}
$pagetitle = 'Post Problems';
$pagedescription = "you're welcome soham";
include('includes/header.php');
?>
<style>
.shorter {
height: 100px;
}
</style>
<form method="post" enctype="multipart/form-data">
<div class="box one-half">
<p>
<label for="pr">PR</label><br>
<input type="text" name="pr" placeholder="PRA8, PRB5, etc" required>
</p>
<p>
<label for="title">Title</label><br>
<input type="text" name="title" required>
</p>
<p>
<label for="type">Type</label><br>
<input type="radio" name="type" value="Beginner"> Beginner<br>
<input type="radio" name="type" value="Intermediate"> Intermediate<br>
<input type="radio" name="type" value="Advanced"> Advanced
</p>
<p>
<label for="state">State</label><br>
<input type="radio" name="state" value="up"> up<br>
<input type="radio" name="state" value="down"> down<br>
<input type="radio" name="state"> other: <input type="text">
<script>
document.currentScript.previousElementSibling
.addEventListener("blur", function () {
this.previousElementSibling.value = this.value;
});
</script>
</p>
<p>
<label for="blurb">Blurb</label><br>
<input type="text" name="blurb" required>
</p>
<p>
<label for="description">Description</label><br>
<textarea name="description" required></textarea>
</p>
<p>
<label for="hints">Hints (Leave blank for no hints)</label>
<textarea name="hints" class="shorter"></textarea>
</p>
</div>
<div class="box one-half last-child">
<p>
<label for="inputForm">Input format</label><br>
<textarea name="inputForm" class="shorter" required></textarea>
</p>
<p>
<label for="sampleInput">Sample input</label><br>
<textarea name="sampleInput" class="shorter" required></textarea>
</p>
<p>
<label for="outputForm">Output format</label><br>
<textarea name="outputForm" class="shorter" required></textarea>
</p>
<p>
<label for="sampleOutput">Sample output</label><br>
<textarea name="sampleOutput" class="shorter" required></textarea>
</p>
<p>
<label for="inputFile">Input test case (PRname.in)</label>
<input type="file" name="inputFile" required>
</p>
<p>
<label for="outputFile">Test case output (PRname.out)</label>
<input type="file" name="outputFile" required>
</p>
</div>
<!-- ohlook tis a center tag -->
<center><input type="submit" class="btn" value="Post"></center>
</form>
<?php include('includes/footer.php'); ?>