Update config.php

This commit is contained in:
Lucas 2021-09-16 20:23:42 -03:00 committed by GitHub
parent 56ba3d4a3a
commit 14737e359c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 10 deletions

View File

@ -1,26 +1,33 @@
<?php
// Name (and path) of you twtxt.txt file
$txt_file = '../twtxt.txt';
session_start();
$new_post = filter_input(INPUT_POST, 'new_post');
// $new_post = filter_input(INPUT_POST, 'new_post', FILTER_SANITIZE_SPECIAL_CHARS);
// Generate ID
function id(){
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randstring = '';
$i=0;
while ($i <= 6) {
$randstring .= $characters[rand(0, strlen($characters))];
$i++;
}
return $randstring;
}
$id=id();
if($new_post) {
$contents = file_get_contents($txt_file);
// $contents .= "\n" . date(DATE_RFC3339) . "\t" ;
$contents .= "\n" . date("Y-m-d\TH:i:s\Z") . "\t" ;
$contents = $_SESSION["twtxt"];
$contents .= "\n" . date("Y-m-d\TH:i:s\Z") . "\t(#" . $id . ")\t" ;
$contents .= "$new_post";
file_put_contents($txt_file, $contents);
$_SESSION["twtxt"] = $contents;
header("Refresh:0; url=index.html");
//header("Location: index.html");
//header("Location: $txt_file");
exit;
} else {
//header("Location: index.html");
//header("Location: index.html");
echo "Opps something went wrong...\n\nCheck the error_log on the server";
exit;
}