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.

59 lines
1.7 KiB

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