-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.php
More file actions
executable file
·96 lines (78 loc) · 1.93 KB
/
publish.php
File metadata and controls
executable file
·96 lines (78 loc) · 1.93 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
<?php
$date = "";
$text = "";
$dopublish = false;
if (isset($_POST["date"])) {
$date = $_POST["date"]; $text = $_POST["text"];
$dopublish = true;
}
function scan_dir($dir) {
$ignored = array('.', '..', '.svn', '.htaccess', '.php', '.html');
$files = array();
foreach (scandir($dir) as $file) {
if (in_array($file, $ignored)) continue;
$files[$file] = filemtime($dir . '/' . $file);
}
arsort($files);
$files = array_keys($files);
return ($files) ? $files : false;
}
//$dir = getcwd();
$dir = "bulletin/";
if ($dopublish) {
$files = scan_dir($dir);
$filenames = array();
for ($i = 0; $i < count($files); $i++) {
if (strpos($files[$i], 'txt')) array_push($filenames, basename($files[$i], ".txt"));
}
rsort($filenames);
$nextfile = intval($filenames[0]) + 1;
file_put_contents($dir.$nextfile.".txt", "<h3>".$date."</h3>\n<p>".$text."</p>");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="/style.css">
<title>ARFNET</title>
<style>
.title {
font-size: 36px;
}
header *{
display: inline-block;
}
* {
vertical-align: middle;
max-width: 100%;
}
.text {
width: 500px;
height: 200px;
}
.form {
margin: 20px;
padding: 20px;
//border: solid 1px;
}
</style>
</head>
<body>
<header>
<img src="/arfnet_logo.png" width="64">
<span class="title"><strong>ARFNET</strong></span>
</header>
<hr>
<a class="home" href="/">Home</a><br>
<h2>ARFNET Bulletin Publish Form</h2>
<hr>
<form class="form" method="POST" action="publish.php">
<label>Date</label><br>
<input type="text" name="date"></input><br>
<label>Message</label><br>
<textarea class="text" name="text"></textarea><br><br>
<input type="submit" value="Submit"></input>
</form>
</body>
</html>