send.php 765B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. //#########################################################
  3. // Part of project php-IRC-js
  4. //
  5. // xhr_write.php - write command to file "send"
  6. //
  7. // Author: Mario Chorvath - Bedna
  8. // Start 2016
  9. //
  10. // Licence GNU General Public License
  11. // Version 2
  12. // http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
  13. //#########################################################
  14. // Get data from JavaScript
  15. $text = rawurldecode ($_SERVER['HTTP_X_TEXT']);
  16. // Name must be set
  17. if (!isset ($text)) {
  18. echo 'ERROR: Name required';
  19. }
  20. // If file open
  21. if ($handle = fopen ("send", "w")) {
  22. // Write command to file
  23. fwrite ($handle, $text);
  24. fclose ($handle);
  25. // Send data back to JavaScript
  26. echo $text;
  27. flush ();
  28. }
  29. // If error
  30. else {
  31. echo "ERROR open file 'send'";
  32. }
  33. ?>