Advertisement
Guest User

write.php

a guest
Jan 16th, 2022
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. <?php
  2.     header("Location: " . $_SERVER['HTTP_REFERER']);
  3.  
  4.     $post = $_POST['content'];
  5.  
  6.     $post = htmlspecialchars($post);
  7.     $post = filter_var($post, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
  8.     $post = str_replace("\n", " ", $post);
  9.     $post = str_replace("\r", " ", $post);
  10.  
  11.     // Test if post matches last post
  12.     $first_line = fgets(fopen("content.txt", 'r'));
  13.     $format_post = "- " . $post . "\n";
  14.     if ($first_line == $format_post) {
  15.         exit();
  16.     }
  17.  
  18.     if ($post != "" && strlen($post) <= 400 && ! ctype_space($post)) {
  19.         file_put_contents("content.txt",  "- " . $post . "\n" . file_get_contents("content.txt"));
  20.     }
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement