From 852ea1aedd22ea55ae07bcba4eb9bcf0b0018704 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 14 Mar 2011 18:34:58 -0700 Subject: force last-child on foster children, disallow time travel --- include/items.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index e930ab5d2..2294fe294 100644 --- a/include/items.php +++ b/include/items.php @@ -401,6 +401,17 @@ function get_atom_elements($feed,$item) { $res['edited'] = $item->get_date('c'); + // Disallow time travelling posts + + $d1 = strtotime($res['created']); + $d2 = strtotime($res['edited']); + $d3 = strtotime('now'); + + if($d1 > $d3) + $res['created'] = datetime_convert(); + if($d2 > $d3) + $res['edited'] = datetime_convert(); + $rawowner = $item->get_item_tags(NAMESPACE_DFRN, 'owner'); if($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']) $res['owner-name'] = unxmlify($rawowner[0]['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['name'][0]['data']); @@ -702,6 +713,18 @@ function item_store($arr,$force_parent = false) { intval($current_post) ); + /** + * If this is now the last-child, force all _other_ children of this parent to *not* be last-child + */ + + if($arr['last-child']) { + $r = q("UPDATE `item` SET `last-child` = 0 WHERE `parent-uri` = '%s' AND `uid` = %d AND `id` != %d", + dbesc($arr['uri']), + intval($arr['uid']), + intval($current_post) + ); + } + return $current_post; } -- cgit v1.2.3 From f01538a54f68c172e09aabed90e2651ca2305675 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 15 Mar 2011 17:31:49 -0700 Subject: content expiration --- include/items.php | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 2294fe294..051659321 100644 --- a/include/items.php +++ b/include/items.php @@ -1507,3 +1507,49 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { return $o; } +function item_expire($uid,$days) { + + if((! $uid) || (! $days)) + return; + + $r = q("SELECT * FROM `item` + WHERE `uid` = %d + AND `created` < UTC_TIMESTAMP() - INTERVAL %d DAY + AND `id` = `parent` + AND `deleted` = 0", + intval($uid), + intval($days) + ); + + if(! count($r)) + return; + + logger('expire: # items=' . count($r) ); + + foreach($r as $item) { + + // Only expire posts, not photos and photo comments + + if(strlen($item['resource-id'])) + continue; + + $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item['id']) + ); + + // kill the kids + + $r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + dbesc($item['parent-uri']), + intval($item['uid']) + ); + + } + + proc_run('php',"include/notifier.php","expire","$uid"); + +} \ No newline at end of file -- cgit v1.2.3 From 7e33c1072a4a948941e2522afe0123899b0abddd Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 19 Mar 2011 01:19:11 -0700 Subject: stuff to make connecting to diaspora profiles easier --- include/items.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 051659321..6900c5920 100644 --- a/include/items.php +++ b/include/items.php @@ -905,6 +905,8 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { require_once('simplepie/simplepie.inc'); + if(! $contact) + logger('consume feed: anonymous'); $feed = new SimplePie(); $feed->set_raw_data($xml); if($datedir) -- cgit v1.2.3 From be67cf663bc645d9825c7d6c6059663fead06645 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 19 Mar 2011 05:10:05 -0700 Subject: minor edits --- include/items.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 6900c5920..051659321 100644 --- a/include/items.php +++ b/include/items.php @@ -905,8 +905,6 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { require_once('simplepie/simplepie.inc'); - if(! $contact) - logger('consume feed: anonymous'); $feed = new SimplePie(); $feed->set_raw_data($xml); if($datedir) -- cgit v1.2.3 From f198c5cff8932bc1d42c34869afecec6dcab2f46 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 30 Mar 2011 04:07:47 -0700 Subject: secure profile failure --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 051659321..58fad9927 100644 --- a/include/items.php +++ b/include/items.php @@ -762,7 +762,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if(! $rino_enable) $rino = 0; - $url = $contact['notify'] . '?dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); + $url = $contact['notify'] . '&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); logger('dfrn_deliver: ' . $url); -- cgit v1.2.3 From 04cd865cc94c1c3647beb567baf1bb64af269c4e Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 30 Mar 2011 04:20:40 -0700 Subject: placeholder arg in dfrn conversations --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 58fad9927..4a740e55b 100644 --- a/include/items.php +++ b/include/items.php @@ -762,7 +762,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if(! $rino_enable) $rino = 0; - $url = $contact['notify'] . '&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); + $url = $contact['notify'] . '?f=&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); logger('dfrn_deliver: ' . $url); -- cgit v1.2.3 From 0fe997490df7fbd3d108c8da931e4823b0a4b2d9 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 30 Mar 2011 15:04:18 -0700 Subject: dfrn remote profile protocol revision --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 4a740e55b..58fad9927 100644 --- a/include/items.php +++ b/include/items.php @@ -762,7 +762,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if(! $rino_enable) $rino = 0; - $url = $contact['notify'] . '?f=&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); + $url = $contact['notify'] . '&dfrn_id=' . $idtosend . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . (($rino) ? '&rino=1' : ''); logger('dfrn_deliver: ' . $url); -- cgit v1.2.3 From b5bcf44354410e2c37d5ec143c7050c3903200ed Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 4 Apr 2011 01:18:28 -0700 Subject: profile not set --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 58fad9927..1dd39d2ba 100644 --- a/include/items.php +++ b/include/items.php @@ -901,7 +901,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { * */ -function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0) { +function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_feed = false) { require_once('simplepie/simplepie.inc'); -- cgit v1.2.3 From 793967a1d3c23fcf1f3b00a2832f51e6f473f4bd Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 4 Apr 2011 19:36:18 -0700 Subject: better handling of troublesome feeds. --- include/items.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 1dd39d2ba..a9ac85969 100644 --- a/include/items.php +++ b/include/items.php @@ -180,7 +180,7 @@ function construct_activity_object($item) { if($item['object']) { $o = '' . "\r\n"; - $r = @simplexml_load_string($item['object']); + $r = parse_xml_string($item['object']); if($r->type) $o .= '' . xmlify($r->type) . '' . "\r\n"; if($r->id) @@ -206,7 +206,7 @@ function construct_activity_target($item) { if($item['target']) { $o = '' . "\r\n"; - $r = @simplexml_load_string($item['target']); + $r = parse_xml_string($item['target']); if($r->type) $o .= '' . xmlify($r->type) . '' . "\r\n"; if($r->id) @@ -241,8 +241,14 @@ function get_atom_elements($feed,$item) { $res = array(); $author = $item->get_author(); - $res['author-name'] = unxmlify($author->get_name()); - $res['author-link'] = unxmlify($author->get_link()); + if($author) { + $res['author-name'] = unxmlify($author->get_name()); + $res['author-link'] = unxmlify($author->get_link()); + } + else { + $res['author-name'] = unxmlify($feed->get_title()); + $res['author-link'] = unxmlify($feed->get_permalink()); + } $res['uri'] = unxmlify($item->get_id()); $res['title'] = unxmlify($item->get_title()); $res['body'] = unxmlify($item->get_content()); @@ -343,7 +349,6 @@ function get_atom_elements($feed,$item) { // the wild, by sanitising it and converting supported tags to bbcode before we rip out any remaining // html. - if((strpos($res['body'],'<') !== false) || (strpos($res['body'],'>') !== false)) { $res['body'] = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', @@ -783,7 +788,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { return 3; } - $res = simplexml_load_string($xml); + $res = parse_xml_string($xml); if((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id))) return (($res->status) ? $res->status : 3); @@ -878,7 +883,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { return 3; } - $res = simplexml_load_string($xml); + $res = parse_xml_string($xml); return $res->status; @@ -916,6 +921,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee if($feed->error()) logger('consume_feed: Error parsing XML: ' . $feed->error()); + $permalink = $feed->get_permalink(); // Check at the feed level for updated contact name and/or photo @@ -1230,6 +1236,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee // Head post of a conversation. Have we seen it? If not, import it. $item_id = $item->get_id(); + $datarray = get_atom_elements($feed,$item); $r = q("SELECT `uid`, `last-child`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", @@ -1275,7 +1282,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee if(! is_array($contact)) return; - if($contact['network'] === 'stat') { + if($contact['network'] === 'stat' || stristr($permalink,'twitter.com')) { if(strlen($datarray['title'])) unset($datarray['title']); $datarray['last-child'] = 1; -- cgit v1.2.3 From 438473529c667f151aefcede1d7fa6b8b22f2d91 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 5 Apr 2011 17:41:02 -0700 Subject: atom categories and tag import --- include/items.php | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index a9ac85969..b17eadba2 100644 --- a/include/items.php +++ b/include/items.php @@ -456,7 +456,22 @@ function get_atom_elements($feed,$item) { if((x($res,'verb')) && ($res['verb'] === 'http://ostatus.org/schema/1.0/unfollow')) $res['verb'] = ACTIVITY_UNFOLLOW; - + + $cats = $item->get_categories(); + if($cats) { + $tag_arr = array(); + foreach($cats as $cat) { + $term = $cat->get_term(); + if(! $term) + $term = $cat->get_label(); + $scheme = $cat->get_scheme(); + if($scheme && $term && stristr($scheme,'X-DFRN:')) + $tag_arr[] = substr($scheme,7,1) . '[url=' . unxmlify(substr($scheme,9)) . ']' . unxmlify($term) . '[/url]'; + elseif($term) + $tag_arr[] = $term; + } + $res['tag'] = implode(',', $tag_arr); + } $rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'object'); @@ -614,6 +629,7 @@ function item_store($arr,$force_parent = false) { $arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : ''); $arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0 ); $arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : ''); + $arr['tag'] = ((x($arr,'tag')) ? notags(trim($arr['tag'])) : ''); if($arr['parent-uri'] === $arr['uri']) { $parent_id = 0; @@ -1503,6 +1519,13 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { if(strlen($actarg)) $o .= $actarg; + $tags = item_getfeedtags($item); + if(count($tags)) { + foreach($tags as $t) { + $o .= '' . "\r\n"; + } + } + $mentioned = get_mentions($item); if($mentioned) $o .= $mentioned; @@ -1513,6 +1536,29 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { return $o; } + +function item_getfeedtags($item) { + $ret = array(); + $matches = false; + $cnt = preg_match_all('|\#\[url\=(.+?)\](.+?)\[\/url\]|',$item['tag'],$matches); + if($cnt) { + for($x = 0; $x < count($matches); $x ++) { + if($matches[1][$x]) + $ret[] = array('#',$matches[1][$x], $matches[2][$x]); + } + } + $matches = false; + $cnt = preg_match_all('|\@\[url\=(.+?)\](.+?)\[\/url\]|',$item['tag'],$matches); + if($cnt) { + for($x = 0; $x < count($matches); $x ++) { + if($matches[1][$x]) + $ret[] = array('#',$matches[1][$x], $matches[2][$x]); + } + } + return $ret; +} + + function item_expire($uid,$days) { -- cgit v1.2.3 From 6728a11ee38e890a0ce9b8b6d96dba98a7238129 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 6 Apr 2011 19:41:16 -0700 Subject: support feed attachments/enclosures, and fix for bug #30 --- include/items.php | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index b17eadba2..501f2f944 100644 --- a/include/items.php +++ b/include/items.php @@ -468,11 +468,34 @@ function get_atom_elements($feed,$item) { if($scheme && $term && stristr($scheme,'X-DFRN:')) $tag_arr[] = substr($scheme,7,1) . '[url=' . unxmlify(substr($scheme,9)) . ']' . unxmlify($term) . '[/url]'; elseif($term) - $tag_arr[] = $term; + $tag_arr[] = notags(trim($term)); } $res['tag'] = implode(',', $tag_arr); } + $attach = $item->get_enclosures(); + if($attach) { + $att_arr = array(); + foreach($attach as $att) { + $len = intval($att->get_length()); + $link = str_replace(',','%2D', notags(trim($att->get_link()))); + $title = str_replace(',','%2D',notags(trim($att->get_title()))); + $type = notags(trim($att->get_type())); + if((! $link) || (strpos($link,'http') !== 0)) + continue; + + if(! $title) + $title = ' '; + if(! $type) + $type = 'application/octet-stream'; + + // this isn't legal html - there is no size in an 'a' tag, remember to strip it before display + + $att_arr[] = '' . $title . ''; + } + $res['attach'] = implode(',', $att_arr); + } + $rawobj = $item->get_item_tags(NAMESPACE_ACTIVITY, 'object'); if($rawobj) { @@ -1526,6 +1549,8 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { } } + $o .= item_getfeedattach($item); + $mentioned = get_mentions($item); if($mentioned) $o .= $mentioned; @@ -1558,6 +1583,26 @@ function item_getfeedtags($item) { return $ret; } +function item_getfeedattach($item) { + $ret = array(); + $arr = explode(',',$item['attach']); + if(count($arr)) { + foreach($arr as $r) { + $matches = false; + $cnt = preg_match('|\(.+?)|',$item['attach'],$matches); + if($cnt) { + $ret .= ' Date: Wed, 6 Apr 2011 20:03:06 -0700 Subject: some fixes to attachment output in feed --- include/items.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 501f2f944..9eaee4573 100644 --- a/include/items.php +++ b/include/items.php @@ -1584,14 +1584,14 @@ function item_getfeedtags($item) { } function item_getfeedattach($item) { - $ret = array(); + $ret = ''; $arr = explode(',',$item['attach']); if(count($arr)) { foreach($arr as $r) { $matches = false; - $cnt = preg_match('|\(.+?)|',$item['attach'],$matches); + $cnt = preg_match('|\(.+?)|',$r,$matches); if($cnt) { - $ret .= ' Date: Wed, 6 Apr 2011 20:36:24 -0700 Subject: xmlify enclosure items --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 9eaee4573..c617f13cb 100644 --- a/include/items.php +++ b/include/items.php @@ -1591,11 +1591,11 @@ function item_getfeedattach($item) { $matches = false; $cnt = preg_match('|\(.+?)|',$r,$matches); if($cnt) { - $ret .= ' Date: Wed, 6 Apr 2011 21:59:07 -0700 Subject: attachment storage --- include/items.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index c617f13cb..596946681 100644 --- a/include/items.php +++ b/include/items.php @@ -653,6 +653,7 @@ function item_store($arr,$force_parent = false) { $arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0 ); $arr['body'] = ((x($arr,'body')) ? trim($arr['body']) : ''); $arr['tag'] = ((x($arr,'tag')) ? notags(trim($arr['tag'])) : ''); + $arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : ''); if($arr['parent-uri'] === $arr['uri']) { $parent_id = 0; -- cgit v1.2.3 From 940d216395406744f23fe4144f2a503688624b45 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 10 Apr 2011 18:38:55 -0700 Subject: initial dfrn update to pass perms --- include/items.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 596946681..d7644fb42 100644 --- a/include/items.php +++ b/include/items.php @@ -867,14 +867,14 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if($dissolve) $postvars['dissolve'] = '1'; - if(($contact['rel']) && ($contact['rel'] != REL_FAN) && (! $contact['blocked']) && (! $contact['readonly'])) { - $postvars['data'] = $atom; - } - elseif($owner['page-flags'] == PAGE_COMMUNITY) { + + if((($contact['rel']) && ($contact['rel'] != REL_FAN) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { $postvars['data'] = $atom; + $postvars['perm'] = 'rw'; } else { $postvars['data'] = str_replace('1','0',$atom); + $postvars['perm'] = 'r'; } if($rino && $rino_allowed && (! $dissolve)) { @@ -916,7 +916,6 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) { if((! $curl_stat) || (! strlen($xml))) return(-1); // timed out - if(strpos($xml,'status; - + return $res->status; } -- cgit v1.2.3 From 0ed2d19ac8e0b624dd4c971dd3f053f7b02b04d4 Mon Sep 17 00:00:00 2001 From: Friendika Date: Mon, 11 Apr 2011 20:11:21 -0700 Subject: death to comment box oddities (a slow death as it will take some time for everybody to upgrade) --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index d7644fb42..86579512e 100644 --- a/include/items.php +++ b/include/items.php @@ -1367,8 +1367,8 @@ function new_follower($importer,$contact,$datarray,$item) { // create contact record - set to readonly $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `name`, `nick`, `photo`, `network`, `rel`, - `blocked`, `readonly`, `pending` ) - VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 1, 1 ) ", + `blocked`, `readonly`, `pending`, `writable` ) + VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, 0, 1, 1, 1 ) ", intval($importer['uid']), dbesc(datetime_convert()), dbesc($url), -- cgit v1.2.3 From 3c4e5014350a76c75e7d55edd8be988c0a0cefec Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 13 Apr 2011 01:53:40 -0700 Subject: convert feed attach to bbcode --- include/items.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 86579512e..82752e168 100644 --- a/include/items.php +++ b/include/items.php @@ -477,10 +477,12 @@ function get_atom_elements($feed,$item) { if($attach) { $att_arr = array(); foreach($attach as $att) { - $len = intval($att->get_length()); - $link = str_replace(',','%2D', notags(trim($att->get_link()))); - $title = str_replace(',','%2D',notags(trim($att->get_title()))); - $type = notags(trim($att->get_type())); + $len = intval($att->get_length()); + $link = str_replace(array(',','"'),array('%2D','%22'),notags(trim(unxmlify($att->get_link())))); + $title = str_replace(array(',','"'),array('%2D','%22'),notags(trim(unxmlify($att->get_title())))); + $type = str_replace(array(',','"'),array('%2D','%22'),notags(trim(unxmlify($att->get_type())))); + if(strpos($type,';')) + $type = substr($type,0,strpos($type,';')); if((! $link) || (strpos($link,'http') !== 0)) continue; @@ -489,9 +491,7 @@ function get_atom_elements($feed,$item) { if(! $type) $type = 'application/octet-stream'; - // this isn't legal html - there is no size in an 'a' tag, remember to strip it before display - - $att_arr[] = '' . $title . ''; + $att_arr[] = '[attach]href="' . $link . '" size="' . $len . '" type="' . $type . '" title="' . $title . '"[/attach]'; } $res['attach'] = implode(',', $att_arr); } @@ -1588,13 +1588,13 @@ function item_getfeedattach($item) { if(count($arr)) { foreach($arr as $r) { $matches = false; - $cnt = preg_match('|\(.+?)|',$r,$matches); + $cnt = preg_match('|\[attach\]href=\"(.+?)\" size=\"(.+?)\" type=\"(.+?)\" title=\"(.+?)\"\[\/attach\]|',$r,$matches); if($cnt) { $ret .= ' Date: Thu, 14 Apr 2011 17:13:13 -0700 Subject: set utf-8 on all emails --- include/items.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 82752e168..733cd8048 100644 --- a/include/items.php +++ b/include/items.php @@ -1415,7 +1415,9 @@ function new_follower($importer,$contact,$datarray,$item) { $res = mail($r[0]['email'], t("You have a new follower at ") . $a->config['sitename'], $email, - 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] ); + 'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] . "\n" + . 'Content-type: text/plain; charset=UTF-8' . "\n" + . 'Content-transfer-encoding: 8bit' ); } } -- cgit v1.2.3 From e00068334f414b42cd7a25c594a47efb86d5bb2f Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 30 Apr 2011 17:24:37 -0700 Subject: fix private images --- include/items.php | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'include/items.php') 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; -- cgit v1.2.3 From 59fd70e568fbc93922769333c55d8c1fa72cea9d Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 4 May 2011 02:20:44 -0700 Subject: issues with private photos - hitting internal size limits --- include/items.php | 1 + 1 file changed, 1 insertion(+) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index c5ecac777..3a3085f1b 100644 --- a/include/items.php +++ b/include/items.php @@ -701,6 +701,7 @@ function item_store($arr,$force_parent = false) { $parent_id = 0; $arr['thr-parent'] = $arr['parent-uri']; $arr['parent-uri'] = $arr['uri']; + $arr['gravity'] = 0; } else { logger('item_store: item parent was not found - ignoring item'); -- cgit v1.2.3 From 2c63b65e3c66bcb0a047ce51c04d23376aa6c525 Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 6 May 2011 06:30:33 -0700 Subject: refactor "which link to show" logic --- include/items.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 3a3085f1b..b7863f838 100644 --- a/include/items.php +++ b/include/items.php @@ -1205,6 +1205,13 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee $item_id = $item->get_id(); $datarray = get_atom_elements($feed,$item); + if(! x($datarray,'author-name')) + $datarray['author-name'] = $contact['name']; + if(! x($datarray,'author-link')) + $datarray['author-link'] = $contact['url']; + if(! x($datarray,'author-avatar')) + $datarray['author-avatar'] = $contact['thumb']; + $r = q("SELECT `uid`, `last-child`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['uid']) @@ -1278,6 +1285,15 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $secure_fee $datarray = get_atom_elements($feed,$item); + if(is_array($contact)) { + if(! x($datarray,'author-name')) + $datarray['author-name'] = $contact['name']; + if(! x($datarray,'author-link')) + $datarray['author-link'] = $contact['url']; + if(! x($datarray,'author-avatar')) + $datarray['author-avatar'] = $contact['thumb']; + } + $r = q("SELECT `uid`, `last-child`, `edited`, `body` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['uid']) -- cgit v1.2.3 From c052d688284fda76c612325b237d8352f2abb5d4 Mon Sep 17 00:00:00 2001 From: Friendika Date: Tue, 10 May 2011 16:12:50 -0700 Subject: don't use load_view_file() except in email templates and install of htconfig - to avoid getting wrong file when package is updated by copying over an older version. --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index b7863f838..c75e509cf 100644 --- a/include/items.php +++ b/include/items.php @@ -113,7 +113,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) $items = $r; - $feed_template = load_view_file('view/atom_feed.tpl'); + $feed_template = file_get_contents('view/atom_feed.tpl'); $atom = ''; -- cgit v1.2.3 From b2e92e0af32f86212d15748c6d432d658905d4b6 Mon Sep 17 00:00:00 2001 From: Friendika Date: Wed, 11 May 2011 04:37:13 -0700 Subject: deprecate load_view_file --- include/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index c75e509cf..6f15b6814 100644 --- a/include/items.php +++ b/include/items.php @@ -113,7 +113,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) $items = $r; - $feed_template = file_get_contents('view/atom_feed.tpl'); + $feed_template = get_markup_template('atom_feed.tpl'); $atom = ''; @@ -1421,7 +1421,7 @@ function new_follower($importer,$contact,$datarray,$item) { $a = get_app(); if(count($r)) { if(($r[0]['notify-flags'] & NOTIFY_INTRO) && ($r[0]['page-flags'] == PAGE_NORMAL)) { - $email_tpl = load_view_file('view/follow_notify_eml.tpl'); + $email_tpl = get_intltext_template('follow_notify_eml.tpl'); $email = replace_macros($email_tpl, array( '$requestor' => ((strlen($name)) ? $name : t('[Name Withheld]')), '$url' => $url, -- cgit v1.2.3 From 45b9bd96baa12c426b1a0a629e81908a59f149d9 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 14 May 2011 06:16:21 -0700 Subject: wrong author came from feed, not from FB --- include/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 6f15b6814..8c2c78696 100644 --- a/include/items.php +++ b/include/items.php @@ -1530,7 +1530,7 @@ function atom_entry($item,$type,$author,$owner,$comment = false) { if(is_array($author)) $o .= atom_author('author',$author['name'],$author['url'],80,80,$author['thumb']); else - $o .= atom_author('author',$item['name'],$item['url'],80,80,$item['thumb']); + $o .= atom_author('author',(($item['author-name']) ? $item['author-name'] : $item['name']),(($item['author-link']) ? $item['author-link'] : $item['url']),80,80,(($item['author-avatar']) ? $item['author-avatar'] : $item['thumb'])); if(strlen($item['owner-name'])) $o .= atom_author('dfrn:owner',$item['owner-name'],$item['owner-link'],80,80,$item['owner-avatar']); -- cgit v1.2.3 From 0abf2f11c6b3caaad2f9a833f477a094b7488e9a Mon Sep 17 00:00:00 2001 From: Friendika Date: Fri, 20 May 2011 15:46:41 -0700 Subject: patches for youtube's change in link and embed formats, please test --- include/items.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 8c2c78696..3170b9384 100644 --- a/include/items.php +++ b/include/items.php @@ -354,6 +354,9 @@ function get_atom_elements($feed,$item) { $res['body'] = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', '[youtube]$1[/youtube]', $res['body']); + $res['body'] = preg_replace('#].+?' . 'http://www.youtube.com/embed/[A-Za-z0-9\-_=]+).+?#s', + '[youtube]$1[/youtube]', $res['body']); + $res['body'] = oembed_html2bbcode($res['body']); $config = HTMLPurifier_Config::createDefault(); @@ -521,6 +524,10 @@ function get_atom_elements($feed,$item) { $body = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', '[youtube]$1[/youtube]', $body); + $res['body'] = preg_replace('#].+?' . 'http://www.youtube.com/embed/[A-Za-z0-9\-_=]+).+?#s', + '[youtube]$1[/youtube]', $res['body']); + + $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); @@ -560,6 +567,9 @@ function get_atom_elements($feed,$item) { $body = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', '[youtube]$1[/youtube]', $body); + $res['body'] = preg_replace('#].+?' . 'http://www.youtube.com/embed/[A-Za-z0-9\-_=]+).+?#s', + '[youtube]$1[/youtube]', $res['body']); + $config = HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); -- cgit v1.2.3 From ccbdc9b2fc78b47935c79e748fb8bf75e827800f Mon Sep 17 00:00:00 2001 From: Friendika Date: Sat, 21 May 2011 01:17:07 -0700 Subject: regex stuffed up --- include/items.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/items.php') diff --git a/include/items.php b/include/items.php index 3170b9384..55b17158a 100644 --- a/include/items.php +++ b/include/items.php @@ -354,7 +354,7 @@ function get_atom_elements($feed,$item) { $res['body'] = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', '[youtube]$1[/youtube]', $res['body']); - $res['body'] = preg_replace('#].+?' . 'http://www.youtube.com/embed/[A-Za-z0-9\-_=]+).+?#s', + $res['body'] = preg_replace('#].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?#s', '[youtube]$1[/youtube]', $res['body']); $res['body'] = oembed_html2bbcode($res['body']); @@ -524,7 +524,7 @@ function get_atom_elements($feed,$item) { $body = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', '[youtube]$1[/youtube]', $body); - $res['body'] = preg_replace('#].+?' . 'http://www.youtube.com/embed/[A-Za-z0-9\-_=]+).+?#s', + $res['body'] = preg_replace('#].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?#s', '[youtube]$1[/youtube]', $res['body']); @@ -567,7 +567,7 @@ function get_atom_elements($feed,$item) { $body = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s', '[youtube]$1[/youtube]', $body); - $res['body'] = preg_replace('#].+?' . 'http://www.youtube.com/embed/[A-Za-z0-9\-_=]+).+?#s', + $res['body'] = preg_replace('#].+?' . 'http://www.youtube.com/embed/([A-Za-z0-9\-_=]+).+?#s', '[youtube]$1[/youtube]', $res['body']); $config = HTMLPurifier_Config::createDefault(); -- cgit v1.2.3