Facebook
From angeryblobowo, 5 Years ago, written in PHP.
Embed
Download Paste or View Raw
Hits: 209
  1. <?php
  2. $f_id = isset($_POST["id"])?$_POST["id"]:"";
  3. $f_msg = isset($_POST["msg"])?$_POST["msg"]:"";
  4.  
  5.  
  6. if($f_id == "")
  7.     die("Nie podano ID!");
  8. else
  9. {
  10.     if($f_msg=="")
  11.         echo "Jakiś tam komunikat";
  12.     else
  13.     {
  14.         $content = $_POST["id"] . ";" . $_POST['msg'].PHP_EOL;
  15.         $file = "wiadomosci.txt";
  16.         $saved_file = fopen($file, 'a+');
  17.         $data = file($file);
  18.         $ok = false;
  19.         for($i=count($data)-1; $i>=0; $i--)
  20.         {
  21.             $record = explode(";", $data[$i]);
  22.             if($f_id == $record[0])
  23.                 {
  24.                     $ok = true;
  25.                     break;
  26.                 }
  27.         }
  28.  
  29.         if($ok == true)
  30.             echo $record[1].'<br>';
  31.         else
  32.             echo "NIe lol";
  33.  
  34.         fwrite($saved_file, $content);
  35.         fclose($saved_file);
  36.     }
  37. }
  38. ?>