aboutsummaryrefslogtreecommitdiff
path: root/templates/postform.inc.php
diff options
context:
space:
mode:
authorArno Richter <oelna@oelna.de>2022-12-13 22:27:21 +0100
committerArno Richter <oelna@oelna.de>2022-12-13 22:27:44 +0100
commit0b075f3ea2616cfde4d976199a69ba631174a336 (patch)
treebb1feef58d9c714f6c3fb0b75f1e52b0181cf2af /templates/postform.inc.php
parentf0e3ff408db8ee40611f75cdf96892f90034bd60 (diff)
downloadmicroblog-0b075f3ea2616cfde4d976199a69ba631174a336.tar.gz
microblog-0b075f3ea2616cfde4d976199a69ba631174a336.tar.bz2
microblog-0b075f3ea2616cfde4d976199a69ba631174a336.zip
gave up and sorted files into a directory structure. made snippets for header, nav and footer. made it easier to add additional css files as themes. prepare a little for addition of a real template engine. added a css reset file to share between themes, if warranted.
Diffstat (limited to 'templates/postform.inc.php')
-rw-r--r--templates/postform.inc.php54
1 files changed, 54 insertions, 0 deletions
diff --git a/templates/postform.inc.php b/templates/postform.inc.php
new file mode 100644
index 0000000..149028b
--- /dev/null
+++ b/templates/postform.inc.php
@@ -0,0 +1,54 @@
+<?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
+ );
+
+ rebuild_feeds();
+ if($config['ping'] == true) ping_microblog();
+ if($config['crosspost_to_twitter'] == true) {
+ $twitter_response = json_decode(twitter_post_status($_POST['content']), true);
+
+ if(!empty($twitter_response['errors'])) {
+ $message['message'] .= ' (But crossposting to twitter failed!)';
+ }
+ }
+
+ header('Location: '.$config['url']);
+ die();
+ }
+ }
+
+ $title_suffix = 'new post';
+ require(ROOT.DS.'snippets'.DS.'header.snippet.php');
+
+?><body>
+ <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">
+ <textarea name="content" maxlength="<?= $config['max_characters'] ?>"></textarea>
+ <p id="count"><?= $config['max_characters'] ?></p>
+ <input type="submit" name="" value="Post" />
+ </form>
+ </div>
+ <?php require(ROOT.DS.'snippets'.DS.'footer.snippet.php'); ?>
+</body>
+</html>