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