33 lines
911 B
PHP
33 lines
911 B
PHP
<?php
|
|
// Bounce if not logged in
|
|
include_once( 'logcheck.php' );
|
|
|
|
$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 == "" ) {
|
|
header("Location: blog_log.php?success=0");
|
|
die();
|
|
}
|
|
|
|
if (!file_exists("posts")) {
|
|
if (!mkdir("posts", 0775)) {
|
|
die("Server configuration does not allow for writing files");
|
|
}
|
|
}
|
|
|
|
// Try to write the file
|
|
$success = file_put_contents( "./posts/" . $ts . "_" . urlencode( $title ) . ".md", $body );
|
|
if ( $success ) {
|
|
// Yay! Redirect to admin
|
|
include_once( 'rss_gen.php' );
|
|
build_feed();
|
|
header("Location: admin.php?success=1");
|
|
die();
|
|
} else {
|
|
header("Location: admin.php?success=0");
|
|
die();
|
|
}
|