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