Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

52 lines
1.6 KiB

  1. <?php
  2. /**
  3. * Module: update_notes
  4. * Purpose: AJAX synchronisation of notes page
  5. */
  6. use Friendica\App;
  7. use Friendica\Core\L10n;
  8. use Friendica\DI;
  9. require_once("mod/notes.php");
  10. function update_notes_content(App $a) {
  11. $profile_uid = intval($_GET["p"]);
  12. header("Content-type: text/html");
  13. echo "<!DOCTYPE html><html><body>\r\n";
  14. echo "<section>";
  15. /**
  16. *
  17. * Grab the page inner contents by calling the content function from the profile module directly,
  18. * but move any image src attributes to another attribute name. This is because
  19. * some browsers will prefetch all the images for the page even if we don't need them.
  20. * The only ones we need to fetch are those for new page additions, which we'll discover
  21. * on the client side and then swap the image back.
  22. *
  23. */
  24. $text = notes_content($a, $profile_uid);
  25. if (DI::pConfig()->get(local_user(), "system", "bandwidth_saver")) {
  26. $replace = "<br />".L10n::t("[Embedded content - reload page to view]")."<br />";
  27. $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
  28. $text = preg_replace($pattern, $replace, $text);
  29. $pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
  30. $text = preg_replace($pattern, $replace, $text);
  31. $pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
  32. $text = preg_replace($pattern, $replace, $text);
  33. $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
  34. $text = preg_replace($pattern, $replace, $text);
  35. }
  36. // reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well
  37. echo str_replace("\t", " ", $text);
  38. echo "</section>";
  39. echo "</body></html>\r\n";
  40. exit();
  41. }