forked from pavpanchekha/BCAMathTournament
/
master.php
42 lines (42 loc) · 1.06 KB
/
master.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
<?php
$a = str_ireplace("\n", "", trim(htmlspecialchars($_POST["space"])));
if(strlen($a) != 0)
file_put_contents("probs.txt", "[prob]".$a."[/prob]\n", FILE_APPEND);
?>
<html>
<head>
<title>PHP Test</title>
<style type="text/css">
@import 's.css';
</style>
<script type="text/javascript">
function changeBg(a) {
document.submission.space.style.background = ((a)?'#FFFFE0':'white');
}
</script>
</head>
<body>
<h2>BCA Math Competition Problem Submission Site</h2>
<?php
$contents = explode("\n", file_get_contents("probs.txt"));
for($i = 0; $i < count($contents); $i++) {
if(substr($contents[$i], 0, 6) == "[prob]") {
$tmp = substr($contents[$i], 6, strlen($contents[$i])-13);
printf("<p class=\"".(($i%2==0)?"light":"dark")."\">Problem ".($i+1).": ".$tmp."</p>\n");
}
}
?>
<form name="submission" method="post" action="<?php echo $PHP_SELF; ?>">
<h3>Enter a Problem:</h3>
<textarea rows="5"
cols="80"
wrap="soft"
name="space"
onclick="changeBg(1)"
onBlur="changeBg(0)">
</textarea>
<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>