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