format('U')); //$twt = $datetime . "\t$new_post\n"; $twt = date('c') . "\t$new_post\n"; if (strpos($contents, NEW_TWT_MARKER) !== false) { // Add the previous marker // Take note that doesn't not work if twtxt file has CRLF line ending // (which is wrong anyway) $twt = NEW_TWT_MARKER . $twt; $contents = str_replace(NEW_TWT_MARKER, $twt, $contents); } else { // Fall back if the marker is not found. $contents .= $twt; } // TODO: Add error handling if write to the file fails // For example due to permissions problems // https://www.w3docs.com/snippets/php/how-can-i-handle-the-warning-of-file-get-contents-function-in-php.html $file_write_result = file_put_contents($txt_file_path, $contents); header('Refresh:0; url=.'); exit; } else { ?>