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