diff --git a/boot.php b/boot.php
index 3991d0757..c9760a99a 100644
--- a/boot.php
+++ b/boot.php
@@ -2,7 +2,7 @@
set_time_limit(0);
-define ( 'FRIENDIKA_VERSION', '2.1.964' );
+define ( 'FRIENDIKA_VERSION', '2.1.965' );
define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
define ( 'DB_UPDATE_VERSION', 1054 );
@@ -845,7 +845,9 @@ function login($register = false) {
$tpl = load_view_file("view/login.tpl");
}
-
+
+// $o = '';
+
$o = replace_macros($tpl,array(
'$logout' => t('Logout'),
'$register_html' => $register_html,
diff --git a/include/bbcode.php b/include/bbcode.php
index 6fadbaf7e..89a14988a 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -80,7 +80,7 @@ function bbcode($Text,$preserve_nl = false) {
// Images
// [img]pathtoimage[/img]
- $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '', $Text);
+ $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '', $Text);
// html5 video and audio
diff --git a/include/items.php b/include/items.php
index 733cd8048..c5ecac777 100644
--- a/include/items.php
+++ b/include/items.php
@@ -1496,10 +1496,17 @@ function atom_author($tag,$name,$uri,$h,$w,$photo) {
function atom_entry($item,$type,$author,$owner,$comment = false) {
+ $a = get_app();
+
if($item['deleted'])
return '' . "\r\n";
- $a = get_app();
+
+ if($item['allow_cid'] || $item['allow_gid'] || $item['deny_cid'] || $item['deny_gid'])
+ $body = fix_private_photos($item['body'],$owner['uid']);
+ else
+ $body = $item['body'];
+
$o = "\r\n\r\n\r\n";
@@ -1517,8 +1524,8 @@ function atom_entry($item,$type,$author,$owner,$comment = false) {
$o .= '' . xmlify($item['title']) . '' . "\r\n";
$o .= '' . xmlify(datetime_convert('UTC','UTC',$item['created'] . '+00:00',ATOM_TIME)) . '' . "\r\n";
$o .= '' . xmlify(datetime_convert('UTC','UTC',$item['edited'] . '+00:00',ATOM_TIME)) . '' . "\r\n";
- $o .= '' . base64url_encode($item['body'], true) . '' . "\r\n";
- $o .= '' . xmlify(($type === 'html') ? bbcode($item['body']) : $item['body']) . '' . "\r\n";
+ $o .= '' . base64url_encode($body, true) . '' . "\r\n";
+ $o .= '' . xmlify(($type === 'html') ? bbcode($body) : $body) . '' . "\r\n";
$o .= '' . "\r\n";
if($comment)
$o .= '' . intval($item['last-child']) . '' . "\r\n";
@@ -1563,6 +1570,38 @@ function atom_entry($item,$type,$author,$owner,$comment = false) {
return $o;
}
+function fix_private_photos($s,$uid) {
+ $a = get_app();
+ logger('fix_private_photos');
+
+ if(preg_match("/\[img\](.+?)\[\/img\]/is",$s,$matches)) {
+ $image = $matches[1];
+ logger('fix_private_photos: found photo ' . $image);
+ if(stristr($image ,$a->get_baseurl() . '/photo/')) {
+ $i = basename($image);
+ $i = str_replace('.jpg','',$i);
+ $x = strpos($i,'-');
+ if($x) {
+ $res = substr($i,$x+1);
+ $i = substr($i,0,$x);
+ $r = q("SELECT * FROM `photo` WHERE `resource-id` = '%s' AND `scale` = %d AND `uid` = %d",
+ dbesc($i),
+ intval($res),
+ intval($uid)
+ );
+ if(count($r)) {
+ logger('replacing photo');
+ $s = str_replace($image, 'data:image/jpg;base64,' . base64_encode($r[0]['data']), $s);
+ }
+ }
+ logger('fix_private_photos: replaced: ' . $s, LOGGER_DATA);
+ }
+ }
+ return($s);
+}
+
+
+
function item_getfeedtags($item) {
$ret = array();
$matches = false;