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