blob: 282e9dcd08e9712d8a503efd47be744e12a0d045 (
plain)
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
|
<?php
if(!defined('ROOT')) die('Don\'t call this directly.');
if(!$config['logged_in']) {
// wrong data, kick user to login page
header('HTTP/1.0 401 Unauthorized');
header('Location: '.$config['url'].'/login');
die();
}
$message = array();
if(!empty($_POST['content'])) {
$id = db_insert($_POST['content'], NOW);
if($id > 0) {
$message = array(
'status' => 'success',
'message' => 'Successfully posted status #'.$id
);
// handle files
if(!empty($_FILES['attachments'])) {
attach_uploaded_files($_FILES['attachments'], $id);
}
header('Location: '.$config['url']);
die();
}
}
$title_suffix = 'new post';
require(ROOT.DS.'snippets'.DS.'header.snippet.php');
?><body ontouchstart="">
<div class="wrap">
<?php require(ROOT.DS.'snippets'.DS.'nav.snippet.php'); ?>
<?php if(isset($message['status']) && isset($message['message'])): ?>
<p class="message <?= $message['status'] ?>"><?= $message['message'] ?></p>
<?php endif; ?>
<form action="" method="post" enctype="multipart/form-data" id="post-new-form" data-redirect="<?= $config['url'] ?>">
<textarea name="content" maxlength="<?= $config['max_characters'] ?>"></textarea>
<div class="post-nav">
<label id="post-attachments-label">Add Files<input type="file" multiple="multiple" name="attachments[]" id="post-attachments" accept="image/*" /></label>
<div id="post-droparea" class="hidden">Add Files</div>
<ul id="post-attachments-list"></ul>
<p id="count"><?= $config['max_characters'] ?></p>
<input type="submit" name="" value="Post" />
</div>
</form>
</div>
<?php require(ROOT.DS.'snippets'.DS.'footer.snippet.php'); ?>
</body>
</html>
|