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.

51 lines
1.6 KiB

  1. <?php
  2. /**
  3. * Module: update_notes
  4. * Purpose: AJAX synchronisation of notes page
  5. */
  6. require_once("mod/notes.php");
  7. function update_notes_content(App $a) {
  8. $profile_uid = intval($_GET["p"]);
  9. header("Content-type: text/html");
  10. echo "<!DOCTYPE html><html><body>\r\n";
  11. echo "<section>";
  12. /**
  13. *
  14. * Grab the page inner contents by calling the content function from the profile module directly,
  15. * but move any image src attributes to another attribute name. This is because
  16. * some browsers will prefetch all the images for the page even if we don't need them.
  17. * The only ones we need to fetch are those for new page additions, which we'll discover
  18. * on the client side and then swap the image back.
  19. *
  20. */
  21. $text = notes_content($a, $profile_uid);
  22. $pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
  23. $replace = "<img\${1} dst=\"\${2}\"";
  24. $text = preg_replace($pattern, $replace, $text);
  25. if (get_pconfig(local_user(), "system", "bandwith_saver")) {
  26. $replace = "<br />".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. killme();
  41. }