-
Notifications
You must be signed in to change notification settings - Fork 2
/
newpost.php
52 lines (39 loc) · 1.17 KB
/
newpost.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
<?php
// Initialise session
session_start();
define('APP_RAN', '');
require_once('config.php');
$target_dir = dirname(__FILE__);
$auth = file_get_contents($target_dir . '/session.php');
$date = $_GET['date'];
$year = date('Y', strtotime($date));
$month = date('m', strtotime($date));
$day = date('d', strtotime($date));
if (isset($_POST['content']) && isset($_POST['content']) != '') {
if (isset($_SESSION['hauth']) && $_SESSION['hauth'] == $auth) {
$newcontent = $_POST['content'];
if (substr($newcontent,0,3) != '@@ ') {
$newcontent = '@@ '.$newcontent;
}
$post_array = explode("\n", $newcontent);
$last = count($post_array)-1;
if (strpos($post_array[$last], '!!') === false) {
$newcontent .= "\n\n!! ".date('H:i:s');
}
if(!file_exists('posts/'.$year)) {
mkdir('posts/'.$year);
}
if(!file_exists('posts/'.$year.'/'.$month)) {
mkdir('posts/'.$year.'/'.$month);
}
$file = $target_dir.'/posts/'.$year.'/'.$month.'/'.$date.'.md';
if ( file_exists( $file ) ) {
unlink( $file );
}
file_put_contents($file, $newcontent);
include('rss.php');
header("location: ".BASE_URL."?date=" . $_GET['date']);
exit();
}
}
?>