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