2023-12-19 23:55:46 +00:00
|
|
|
<?php
|
|
|
|
// Bounce if not logged in
|
2024-01-18 22:09:17 +00:00
|
|
|
include_once( 'logcheck.php' );
|
2023-12-19 23:55:46 +00:00
|
|
|
|
|
|
|
$ts = time();
|
|
|
|
$title = isset( $_POST["post_title"] ) ? trim( $_POST["post_title"] ) : null;
|
|
|
|
$body = isset( $_POST["post_body"] ) ? trim( $_POST["post_body"] ) : null;
|
|
|
|
|
|
|
|
// Bounce if requirements are not met for the post
|
|
|
|
if ( !$title || !$body || $title == "" || $body == "" ) {
|
2023-12-21 22:51:05 +00:00
|
|
|
header("Location: blog_log.php?success=0");
|
2023-12-19 23:55:46 +00:00
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
2023-12-22 04:09:03 +00:00
|
|
|
if (!file_exists("posts")) {
|
|
|
|
if (!mkdir("posts", 0775)) {
|
|
|
|
die("Server configuration does not allow for writing files");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-19 23:55:46 +00:00
|
|
|
// Try to write the file
|
|
|
|
$success = file_put_contents( "./posts/" . $ts . "_" . urlencode( $title ) . ".md", $body );
|
|
|
|
if ( $success ) {
|
|
|
|
// Yay! Redirect to admin
|
2024-01-18 17:09:45 +00:00
|
|
|
include_once( 'rss_gen.php' );
|
|
|
|
build_feed();
|
2023-12-21 22:51:05 +00:00
|
|
|
header("Location: admin.php?success=1");
|
2023-12-19 23:55:46 +00:00
|
|
|
die();
|
|
|
|
} else {
|
2023-12-21 22:51:05 +00:00
|
|
|
header("Location: admin.php?success=0");
|
2023-12-19 23:55:46 +00:00
|
|
|
die();
|
|
|
|
}
|