aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2010-11-11 20:32:20 -0800
committerFriendika <info@friendika.com>2010-11-11 20:32:20 -0800
commit7db4a0dd2ee631c4b0652e5852b1bb6f5ca50e63 (patch)
tree3b2c764f16027fa4221a8f09e726c54b4558abc4 /include
parent16ba93a5b14433f5090255999a1958d4bb2ed611 (diff)
downloadvolse-hubzilla-7db4a0dd2ee631c4b0652e5852b1bb6f5ca50e63.tar.gz
volse-hubzilla-7db4a0dd2ee631c4b0652e5852b1bb6f5ca50e63.tar.bz2
volse-hubzilla-7db4a0dd2ee631c4b0652e5852b1bb6f5ca50e63.zip
give orphans a second chance, linkify naked links
Diffstat (limited to 'include')
-rw-r--r--include/bbcode.php5
-rw-r--r--include/items.php74
-rw-r--r--include/poller.php5
3 files changed, 51 insertions, 33 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index 961494b16..52ca86bc1 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -17,10 +17,15 @@ function bbcode($Text) {
$MAILSearchString = $URLSearchString . " a-zA-Z0-9\.@";
// Perform URL Search
+
+ $Text = preg_replace("/[^\]\=](http\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]*)/", ' <a href="$1" >$1</a>', $Text);
+ $Text = preg_replace("/[^\]\=](https\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%]*)/", ' <a href="$1" >$1</a>', $Text);
+
$Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href="$1" >$1</a>', $Text);
$Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '<a href="$1" >$2</a>', $Text);
//$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '<a href="$1" target="_blank">$2</a>', $Text);
+
// Perform MAIL Search
$Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '<a href="mailto:$1">$1</a>', $Text);
$Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.+?)\[\/mail\]/", '<a href="mailto:$1">$2</a>', $Text);
diff --git a/include/items.php b/include/items.php
index 65041418b..584236f78 100644
--- a/include/items.php
+++ b/include/items.php
@@ -546,9 +546,41 @@ function item_store($arr) {
$arr['object'] = ((x($arr,'object')) ? trim($arr['object']) : '');
$arr['target-type'] = ((x($arr,'target-type')) ? notags(trim($arr['target-type'])) : '');
$arr['target'] = ((x($arr,'target')) ? trim($arr['target']) : '');
+ $arr['allow_cid'] = ((x($arr,'allow_cid')) ? trim($arr['allow_cid']) : '');
+ $arr['allow_gid'] = ((x($arr,'allow_gid')) ? trim($arr['allow_gid']) : '');
+ $arr['deny_cid'] = ((x($arr,'deny_cid')) ? trim($arr['deny_cid']) : '');
+ $arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : '');
- $parent_id = 0;
- $parent_missing = false;
+
+
+ if($arr['parent-uri'] === $arr['uri']) {
+ $parent_id = 0;
+ $allow_cid = $arr['allow_cid'];
+ $allow_gid = $arr['allow_gid'];
+ $deny_cid = $arr['deny_cid'];
+ $deny_gid = $arr['deny_gid'];
+ }
+ else {
+
+ // find the parent and snarf the item id and ACL's
+
+ $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
+ dbesc($arr['parent-uri']),
+ intval($arr['uid'])
+ );
+
+ if(count($r)) {
+ $parent_id = $r[0]['id'];
+ $allow_cid = $r[0]['allow_cid'];
+ $allow_gid = $r[0]['allow_gid'];
+ $deny_cid = $r[0]['deny_cid'];
+ $deny_gid = $r[0]['deny_gid'];
+ }
+ else {
+ logger('item_store: item parent was not found - ignoring item');
+ return 0;
+ }
+ }
dbesc_array($arr);
@@ -560,23 +592,7 @@ function item_store($arr) {
. implode("', '", array_values($arr))
. "')" );
- // find the parent and snarf the item id and ACL's
-
- $r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
- dbesc($arr['parent-uri']),
- intval($arr['uid'])
- );
-
- if(count($r)) {
- $parent_id = $r[0]['id'];
- $allow_cid = $r[0]['allow_cid'];
- $allow_gid = $r[0]['allow_gid'];
- $deny_cid = $r[0]['deny_cid'];
- $deny_gid = $r[0]['deny_gid'];
- }
- else {
- $parent_missing = true;
- }
+ // find the item we just created
$r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
$arr['uri'], // already dbesc'd
@@ -586,23 +602,15 @@ function item_store($arr) {
$current_post = $r[0]['id'];
logger('item_store: created item ' . $current_post);
}
- else
- return 0;
-
- if($parent_missing) {
-
- logger('item_store: item parent was not found - ignoring item');
-
- // perhaps the parent was deleted, but in any case, this thread is dead
- // and unfortunately our brand new item now has to be destroyed
-
- q("DELETE FROM `item` WHERE `id` = %d LIMIT 1",
- intval($current_post)
- );
+ else {
+ logger('item_store: could not locate created item');
return 0;
}
- // Set parent id - all of the parent's ACL's are also inherited by this post
+ if($arr['parent-uri'] === $arr['uri'])
+ $parent_id = $current_post;
+
+ // Set parent id - and also make sure to inherit the parent's ACL's.
$r = q("UPDATE `item` SET `parent` = %d, `allow_cid` = '%s', `allow_gid` = '%s',
`deny_cid` = '%s', `deny_gid` = '%s' WHERE `id` = %d LIMIT 1",
diff --git a/include/poller.php b/include/poller.php
index f214625a1..3d19d003b 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -179,6 +179,11 @@
consume_feed($xml,$importer,$contact,$hub);
+ // do it twice. Ensures that children of parents which may be later in the stream aren't tossed
+
+ consume_feed($xml,$importer,$contact,$hub);
+
+
if((strlen($hub)) && (($contact['rel'] == REL_BUD) || (($contact['network'] === 'stat') && (! $contact['readonly'])))) {
logger('poller: subscribing to hub(s) : ' . $hub . ' contact name : ' . $contact['name'] . ' local user : ' . $importer['name']);
$hubs = explode(',', $hub);