diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/cb.php | 24 | ||||
-rw-r--r-- | mod/follow.php | 27 | ||||
-rw-r--r-- | mod/item.php | 26 | ||||
-rw-r--r-- | mod/network.php | 5 | ||||
-rw-r--r-- | mod/profile.php | 6 | ||||
-rw-r--r-- | mod/pubsub.php | 4 | ||||
-rw-r--r-- | mod/salmon.php | 2 |
7 files changed, 86 insertions, 8 deletions
diff --git a/mod/cb.php b/mod/cb.php new file mode 100644 index 000000000..6375d2398 --- /dev/null +++ b/mod/cb.php @@ -0,0 +1,24 @@ +<?php + +/** + * General purpose landing page for plugins/addons + */ + + +function cb_init(&$a) { + call_hooks('cb_init'); +} + +function cb_post(&$a) { + call_hooks('cb_post', $_POST); +} + +function cb_afterpost(&$a) { + call_hooks('cb_afterpost'); +} + +function cb_content(&$a) { + $o = ''; + call_hooks('cb_content', $o); + return $o; +}
\ No newline at end of file diff --git a/mod/follow.php b/mod/follow.php index 8c1dc348f..eaee7d5ac 100644 --- a/mod/follow.php +++ b/mod/follow.php @@ -15,7 +15,7 @@ function follow_post(&$a) { $email_conversant = false; if($url) { - $links = lrdd($url); + $links = @lrdd($url); if(count($links)) { foreach($links as $link) { if($link['@attributes']['rel'] === NAMESPACE_DFRN) @@ -30,6 +30,26 @@ function follow_post(&$a) { $profile = $link['@attributes']['href']; } + + // Status.Net can have more than one profile URL. We need to match the profile URL + // to a contact on incoming messages to prevent spam, and we won't know which one + // to match. So in case of two, one of them is stored as an alias. Only store URL's + // and not webfinger user@host aliases. If they've got more than two non-email style + // aliases, let's hope we're lucky and get one that matches the feed author-uri because + // otherwise we're screwed. + + foreach($links as $link) { + if($link['@attributes']['rel'] === 'alias') { + if(strpos($link['@attributes']['href'],'@') === false) { + if(isset($profile)) { + if($link['@attributes']['href'] !== $profile) + $alias = $link['@attributes']['href']; + } + else + $profile = $link['@attributes']['href']; + } + } + } } else { if((strpos($orig_url,'@')) && validate_email($orig_url)) { @@ -165,12 +185,13 @@ function follow_post(&$a) { } else { // create contact record - $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `rel`, `priority`, + $r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `alias`, `notify`, `poll`, `name`, `nick`, `photo`, `network`, `rel`, `priority`, `blocked`, `readonly`, `pending` ) - VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 0, 0, 0 ) ", + VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 0, 0, 0 ) ", intval(local_user()), dbesc(datetime_convert()), dbesc($profile), + dbesc($alias), dbesc($notify), dbesc($poll), dbesc($vcard['fn']), diff --git a/mod/item.php b/mod/item.php index 38ef580af..a83373f59 100644 --- a/mod/item.php +++ b/mod/item.php @@ -22,9 +22,12 @@ function item_post(&$a) { $uid = local_user(); + call_hooks('post_local_start', $_POST); + $parent = ((x($_POST,'parent')) ? intval($_POST['parent']) : 0); $parent_item = null; + $parent_contact = null; if($parent) { $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", @@ -35,6 +38,14 @@ function item_post(&$a) { goaway($a->get_baseurl() . "/" . $_POST['return'] ); } $parent_item = $r[0]; + if($parent_item['contact-id'] && $uid) { + $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($parent_item['contact-id']), + intval($uid) + ); + if(count($r)) + $parent_contact = $r[0]; + } } $profile_uid = ((x($_POST,'profile_uid')) ? intval($_POST['profile_uid']) : 0); @@ -185,8 +196,13 @@ function item_post(&$a) { $str_tags = ''; $inform = ''; + $tags = get_tags($body); + if(($parent_contact) && ($parent_contact['network'] === 'stat') && ($parent_contact['nick']) && (! in_array('@' . $parent_contact['nick'],$tags))) { + $body = '@' . $parent_contact['nick'] . ' ' . $body; + $tags[] = '@' . $parent_contact['nick']; + } if(count($tags)) { foreach($tags as $tag) { @@ -199,6 +215,7 @@ function item_post(&$a) { continue; } if(strpos($tag,'@') === 0) { + $stat = false; $name = substr($tag,1); if((strpos($name,'@')) || (strpos($name,'http://'))) { $newname = $name; @@ -232,7 +249,12 @@ function item_post(&$a) { } if(count($r)) { $profile = $r[0]['url']; - $newname = $r[0]['name']; + if($r[0]['network'] === 'stat') { + $newname = $r[0]['nick']; + $stat = true; + } + else + $newname = $r[0]['name']; if(strlen($inform)) $inform .= ','; $inform .= 'cid:' . $r[0]['id']; @@ -249,6 +271,8 @@ function item_post(&$a) { } } + + $wall = 0; if($post_type === 'wall' || $post_type === 'wall-comment') $wall = 1; diff --git a/mod/network.php b/mod/network.php index b0196f92a..f11db45a8 100644 --- a/mod/network.php +++ b/mod/network.php @@ -79,8 +79,10 @@ function network_content(&$a, $update = 0) { $celeb = ((($a->user['page-flags'] == PAGE_SOAPBOX) || ($a->user['page-flags'] == PAGE_COMMUNITY)) ? true : false); - $jotplugins = ""; + $jotplugins = ''; + $jotnets = ''; call_hooks('jot_tool', $jotplugins); + call_hooks('jot_networks', $jotnets); $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); @@ -90,6 +92,7 @@ function network_content(&$a, $update = 0) { '$defloc' => $a->user['default-location'], '$visitor' => 'block', '$emailcc' => t('CC: email addresses'), + '$jotnets' => $jotnets, '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$lockstate' => $lockstate, '$acl' => populate_acl((($group) ? $group_acl : $a->user), $celeb), diff --git a/mod/profile.php b/mod/profile.php index 3b4616a34..8ec29d382 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -135,9 +135,12 @@ function profile_content(&$a, $update = 0) { else $lockstate = 'unlock'; - $jotplugins = ""; + $jotplugins = ''; + $jotnets = ''; call_hooks('jot_tool', $jotplugins); + call_hooks('jot_networks', $jotnets); + $tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); $o .= replace_macros($tpl,array( @@ -147,6 +150,7 @@ function profile_content(&$a, $update = 0) { '$visitor' => (($is_owner || $commvisitor) ? 'block' : 'none'), '$lockstate' => $lockstate, '$emailcc' => t('CC: email addresses'), + '$jotnets' => $jotnets, '$emtitle' => t('Example: bob@example.com, mary@example.com'), '$bang' => '', '$acl' => (($is_owner) ? populate_acl($a->user, $celeb) : ''), diff --git a/mod/pubsub.php b/mod/pubsub.php index 4f4ed2f16..df27c6bc2 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -105,8 +105,10 @@ function pubsub_post(&$a) { intval($contact_id), intval($importer['uid']) ); - if(! count($r)) + if(! count($r)) { + logger('pubsub: no contact record - ignored'); hub_post_return(); + } $contact = $r[0]; diff --git a/mod/salmon.php b/mod/salmon.php index 8c7d921c8..885ba470c 100644 --- a/mod/salmon.php +++ b/mod/salmon.php @@ -177,7 +177,7 @@ function salmon_post(&$a) { * */ - $r = q("SELECT * FROM `contact` WHERE `network` = 'stat' AND ( `url` = '%s' OR `lrdd` = '%s') + $r = q("SELECT * FROM `contact` WHERE `network` = 'stat' AND ( `url` = '%s' OR `alias` = '%s') AND `uid` = %d LIMIT 1", dbesc($author_link), dbesc($author_link), |