]> git.mxchange.org Git - friendica.git/blob - mod/update_profile.php
Merge pull request #2319 from stieben/develop
[friendica.git] / mod / update_profile.php
1 <?php
2
3 /**
4  * Module: update_profile
5  * Purpose: AJAX synchronisation of profile page
6  *
7  */
8
9
10 require_once('mod/profile.php');
11
12 if(! function_exists('update_profile_content')) {
13 function update_profile_content(&$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         /**
21          * We can remove this hack once Internet Explorer recognises HTML5 natively
22          */
23
24         echo "<section>";
25
26         /**
27          *
28          * Grab the page inner contents by calling the content function from the profile module directly,
29          * but move any image src attributes to another attribute name. This is because
30          * some browsers will prefetch all the images for the page even if we don't need them.
31          * The only ones we need to fetch are those for new page additions, which we'll discover
32          * on the client side and then swap the image back.
33          *
34          */
35
36         $text = profile_content($a,$profile_uid);
37
38         $pattern = "/<img([^>]*) src=\"([^\"]*)\"/";
39         $replace = "<img\${1} dst=\"\${2}\"";
40         $text = preg_replace($pattern, $replace, $text);
41
42         $replace = '<br />' . t('[Embedded content - reload page to view]') . '<br />';
43         $pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
44         $text = preg_replace($pattern, $replace, $text);
45         $pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
46         $text = preg_replace($pattern, $replace, $text);
47         $pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
48         $text = preg_replace($pattern, $replace, $text);
49     $pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
50     $text = preg_replace($pattern, $replace, $text);
51
52         /**
53          * reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well
54          */
55
56         echo str_replace("\t",'       ',$text);
57         echo "</section>";
58         echo "</body></html>\r\n";
59         killme();
60 }
61 }