mirror of
https://github.com/sorenpeter/timeline.git
synced 2025-12-15 10:57:01 +00:00
Post-redirect-get for new_twt
This commit is contained in:
parent
eb6aa2aad7
commit
c6cbed680f
2 changed files with 14 additions and 8 deletions
|
|
@ -17,6 +17,8 @@ $public_txt_url = $config['public_txt_url'];
|
||||||
$timezone = $config['timezone'];
|
$timezone = $config['timezone'];
|
||||||
require_once 'libs/load_timezone.php';
|
require_once 'libs/load_timezone.php';
|
||||||
|
|
||||||
|
//session_start(); // Post-Redirect-Get Pattern based on: https://icodemag.com/prg-pattern-in-php-what-why-and-how/
|
||||||
|
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
$new_post = filter_input(INPUT_POST, 'new_post');
|
$new_post = filter_input(INPUT_POST, 'new_post');
|
||||||
$new_post = trim($new_post);
|
$new_post = trim($new_post);
|
||||||
|
|
@ -31,10 +33,12 @@ if (isset($_POST['submit'])) {
|
||||||
// Check if we have a point to insert the next Twt
|
// Check if we have a point to insert the next Twt
|
||||||
define('NEW_TWT_MARKER', "#~~~#\n");
|
define('NEW_TWT_MARKER', "#~~~#\n");
|
||||||
|
|
||||||
if (!file_exists($txt_file_path)) {
|
// if (!file_exists($txt_file_path)) {
|
||||||
echo 'twtxt.txt file does not exist. Check your config.';
|
// echo '';
|
||||||
exit;
|
// exit;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
if(!file_exists($txt_file_path)) exit("<p class='notice'>twtxt.txt file does not exist. Check your <code>config.ini</code></p>");
|
||||||
|
|
||||||
$contents = file_get_contents($txt_file_path);
|
$contents = file_get_contents($txt_file_path);
|
||||||
|
|
||||||
|
|
@ -77,6 +81,10 @@ if (isset($_POST['submit'])) {
|
||||||
//header("Location: refresh?url=".$public_txt_url); // Trying to fix issue with douple posting
|
//header("Location: refresh?url=".$public_txt_url); // Trying to fix issue with douple posting
|
||||||
//exit;
|
//exit;
|
||||||
|
|
||||||
|
//$_SESSION["message"] = $msg;
|
||||||
|
header('Location: '.$_SERVER['QUERY_STRING']);
|
||||||
|
exit;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
require_once "partials/base.php";
|
require_once "partials/base.php";
|
||||||
$title = "New post - $title";
|
$title = "New post - $title";
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,6 @@ $media_upload = getcwd() . "/" . $config["media_upload"] . "/";
|
||||||
// Credits: https://www.geeksforgeeks.org/how-to-select-and-upload-multiple-files-with-html-and-php-using-http-post/
|
// Credits: https://www.geeksforgeeks.org/how-to-select-and-upload-multiple-files-with-html-and-php-using-http-post/
|
||||||
|
|
||||||
session_start(); // Post-Redirect-Get Pattern based on: https://icodemag.com/prg-pattern-in-php-what-why-and-how/
|
session_start(); // Post-Redirect-Get Pattern based on: https://icodemag.com/prg-pattern-in-php-what-why-and-how/
|
||||||
|
|
||||||
// Check if form was submitted
|
|
||||||
if(isset($_POST['submit'])) {
|
if(isset($_POST['submit'])) {
|
||||||
|
|
||||||
$msg = "<p class='notice'>";
|
$msg = "<p class='notice'>";
|
||||||
|
|
@ -70,7 +68,7 @@ if(isset($_POST['submit'])) {
|
||||||
// If file with name already exists then append time in
|
// If file with name already exists then append time in
|
||||||
// front of name of the file to avoid overwriting of file
|
// front of name of the file to avoid overwriting of file
|
||||||
if(file_exists($file_path)) {
|
if(file_exists($file_path)) {
|
||||||
$msg .= "Error uploading {$file_name} - File already exists! <br>";
|
$msg .= "Error uploading <strong>{$file_name}</strong> - File already exists! <br>";
|
||||||
// $file_path = $upload_dir.date('Y-m-d_').$file_name;
|
// $file_path = $upload_dir.date('Y-m-d_').$file_name;
|
||||||
|
|
||||||
// if( move_uploaded_file($file_tmpname, $file_path)) {
|
// if( move_uploaded_file($file_tmpname, $file_path)) {
|
||||||
|
|
@ -112,7 +110,7 @@ if(isset($_POST['submit'])) {
|
||||||
|
|
||||||
// If file extension not valid
|
// If file extension not valid
|
||||||
//$msg .= '<p class="warning">';
|
//$msg .= '<p class="warning">';
|
||||||
$msg .= "Error uploading {$file_name} for unknown reason";
|
$msg .= "Error uploading <strong>{$file_name}</strong> for unknown reason";
|
||||||
$msg .= "({$file_ext} file type is not allowed)<br>";
|
$msg .= "({$file_ext} file type is not allowed)<br>";
|
||||||
//$msg .= '</p>';
|
//$msg .= '</p>';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue