diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/admin.php | 3 | ||||
-rw-r--r-- | mod/contacts.php | 50 | ||||
-rw-r--r-- | mod/item.php | 29 | ||||
-rw-r--r-- | mod/network.php | 2 | ||||
-rw-r--r-- | mod/openid.php | 3 | ||||
-rw-r--r-- | mod/pubsub.php | 6 | ||||
-rw-r--r-- | mod/receive.php | 26 |
7 files changed, 63 insertions, 56 deletions
diff --git a/mod/admin.php b/mod/admin.php index 1a926443f..7799e64ab 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -197,6 +197,7 @@ function admin_page_site_post(&$a){ $timeout = ((x($_POST,'timeout')) ? intval(trim($_POST['timeout'])) : 60); $dfrn_only = ((x($_POST,'dfrn_only')) ? True : False); $ostatus_disabled = !((x($_POST,'ostatus_disabled')) ? True : False); + $diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False); set_config('config','sitename',$sitename); @@ -241,6 +242,7 @@ function admin_page_site_post(&$a){ set_config('system','curl_timeout', $timeout); set_config('system','dfrn_only', $dfrn_only); set_config('system','ostatus_disabled', $ostatus_disabled); + set_config('system','diaspora_enabled', $diaspora_enabled); info( t('Site settings updated.') . EOL); goaway($a->get_baseurl() . '/admin/site' ); @@ -325,6 +327,7 @@ function admin_page_site(&$a) { '$no_utf' => array('no_utf', t("UTF-8 Regular expressions"), !get_config('system','no_utf'), "Use PHP UTF8 regular expressions"), '$no_community_page' => array('no_community_page', t("Show Community Page"), !get_config('system','no_community_page'), "Display a Community page showing all recent public postings on this site."), '$ostatus_disabled' => array('ostatus_disabled', t("Enable OStatus support"), !get_config('system','ostatus_disable'), "Provide built-in OStatus \x28identi.ca, status.net, etc.\x29 compatibility. All communications in OStatus are public, so privacy warnings will be occasionally displayed."), + '$diaspora_enabled' => array('diaspora_enabled', t("Enable Diaspora support"), get_config('system','diaspora_enabled'), "Provide built-in Diaspora network compatibility."), '$dfrn_only' => array('dfrn_only', t('Only allow Friendika contacts'), get_config('system','dfrn_only'), "All contacts must use Friendika protocols. All other built-in communication protocols disabled."), '$verifyssl' => array('verifyssl', t("Verify SSL"), get_config('system','verifyssl'), "If you wish, you can turn on strict certificate checking. This will mean you cannot connect (at all) to self-signed SSL sites."), '$proxyuser' => array('proxyuser', t("Proxy user"), get_config('system','proxyuser'), ""), diff --git a/mod/contacts.php b/mod/contacts.php index e4be93cd5..4decc5042 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -87,25 +87,15 @@ function contacts_post(&$a) { $priority = intval($_POST['poll']); - if($priority == (-1)) - if($priority > 5 || $priority < 0) $priority = 0; - $rating = intval($_POST['reputation']); - if($rating > 5 || $rating < 0) - $rating = 0; - - $reason = notags(trim($_POST['reason'])); - $info = escape_tags(trim($_POST['info'])); - $r = q("UPDATE `contact` SET `profile-id` = %d, `priority` = %d , `rating` = %d, `reason` = '%s', `info` = '%s' + $r = q("UPDATE `contact` SET `profile-id` = %d, `priority` = %d , `info` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($profile_id), intval($priority), - intval($rating), - dbesc($reason), dbesc($info), intval($contact_id), intval(local_user()) @@ -163,9 +153,9 @@ function contacts_content(&$a) { if($cmd === 'block') { $blocked = (($orig_record[0]['blocked']) ? 0 : 1); $r = q("UPDATE `contact` SET `blocked` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($blocked), - intval($contact_id), - intval(local_user()) + intval($blocked), + intval($contact_id), + intval(local_user()) ); if($r) { //notice( t('Contact has been ') . (($blocked) ? t('blocked') : t('unblocked')) . EOL ); @@ -178,9 +168,9 @@ function contacts_content(&$a) { if($cmd === 'ignore') { $readonly = (($orig_record[0]['readonly']) ? 0 : 1); $r = q("UPDATE `contact` SET `readonly` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($readonly), - intval($contact_id), - intval(local_user()) + intval($readonly), + intval($contact_id), + intval(local_user()) ); if($r) { info( (($readonly) ? t('Contact has been ignored') : t('Contact has been unignored')) . EOL ); @@ -193,7 +183,7 @@ function contacts_content(&$a) { // create an unfollow slap - if($orig_record[0]['network'] === 'stat') { + if($orig_record[0]['network'] === NETWORK_OSTATUS) { $tpl = get_markup_template('follow_slap.tpl'); $slap = replace_macros($tpl, array( '$name' => $a->user['username'], @@ -215,13 +205,15 @@ function contacts_content(&$a) { slapper($a->user,$orig_record[0]['notify'],$slap); } } - - if($orig_record[0]['network'] === 'dfrn') { + elseif($orig_record[0]['network'] === NETWORK_DIASPORA) { + require_once('include/diaspora.php'); + diaspora_unshare($a->user,$orig_record[0]); + } + elseif($orig_record[0]['network'] === NETWORK_DFRN) { require_once('include/items.php'); dfrn_deliver($a->user,$orig_record[0],'placeholder', 1); } - contact_remove($orig_record[0]['id']); info( t('Contact has been removed.') . EOL ); goaway($a->get_baseurl() . '/contacts'); @@ -275,8 +267,6 @@ function contacts_content(&$a) { $sparkle = ''; } - $grps = ''; - $insecure = '<div id="profile-edit-insecure"><p><img src="images/unlock_icon.gif" alt="' . t('Privacy Unavailable') . '" /> ' . t('Private communications are not available for this contact.') . '</p></div>'; @@ -290,6 +280,9 @@ function contacts_content(&$a) { $lblsuggest = (($r[0]['network'] === NETWORK_DFRN) ? '<div id="contact-suggest-wrapper"><a href="fsuggest/' . $r[0]['id'] . '" id="contact-suggest">' . t('Suggest friends') . '</a></div>' : ''); + $poll_enabled = (($r[0]['network'] !== NETWORK_DIASPORA) ? true : false); + + $nettype = '<div id="contact-edit-nettype">' . sprintf( t('Network type: %s'),network_to_name($r[0]['network'])) . '</div>'; $o .= replace_macros($tpl,array( '$header' => t('Contact Editor'), @@ -308,9 +301,10 @@ function contacts_content(&$a) { '$lblcrepair' => t("Repair contact URL settings \x28WARNING: Advanced\x29"), '$lblrecent' => t('View conversations'), '$lblsuggest' => $lblsuggest, - '$grps' => $grps, '$delete' => t('Delete contact'), - '$poll_interval' => contact_poll_interval($r[0]['priority']), + '$nettype' => $nettype, + '$poll_interval' => contact_poll_interval($r[0]['priority'],(! $poll_enabled)), + '$poll_enabled' => $poll_enabled, '$lastupdtext' => t('Last updated: '), '$updpub' => t('Update public posts: '), '$last_update' => $last_update, @@ -323,9 +317,6 @@ function contacts_content(&$a) { '$info' => $r[0]['info'], '$blocked' => (($r[0]['blocked']) ? '<div id="block-message">' . t('Currently blocked') . '</div>' : ''), '$ignored' => (($r[0]['readonly']) ? '<div id="ignore-message">' . t('Currently ignored') . '</div>' : ''), - '$rating' => contact_reputation($r[0]['rating']), - '$reason' => $r[0]['reason'], - '$groups' => '', // group_selector(), '$photo' => $r[0]['photo'], '$name' => $r[0]['name'], '$dir_icon' => $dir_icon, @@ -420,11 +411,12 @@ function contacts_content(&$a) { $o .= replace_macros($tpl, array( '$img_hover' => sprintf( t('Visit %s\'s profile [%s]'),$rr['name'],$rr['url']), '$edit_hover' => t('Edit contact'), + '$contact_photo_menu' => contact_photo_menu($rr), '$id' => $rr['id'], '$alt_text' => $alt_text, '$dir_icon' => $dir_icon, '$thumb' => $rr['thumb'], - '$name' => substr($rr['name'],0,20), + '$name' => $rr['name'], '$username' => $rr['name'], '$sparkle' => $sparkle, '$url' => $url diff --git a/mod/item.php b/mod/item.php index ef0b232d5..dd42014eb 100644 --- a/mod/item.php +++ b/mod/item.php @@ -15,6 +15,8 @@ * */ +require_once('include/crypto.php'); + function item_post(&$a) { if((! local_user()) && (! remote_user())) @@ -674,6 +676,27 @@ function item_post(&$a) { pop_lang(); } + + // We won't be able to sign Diaspora comments for authenticated visitors - we don't have their private key + + if($self) { + require_once('include/bb2diaspora.php'); + $signed_body = html_entity_decode(bb2diaspora($datarray['body'])); + $myaddr = $a->user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3); + if($datarray['verb'] === ACTIVITY_LIKE) + $signed_text = $datarray['guid'] . ';' . 'Post' . ';' . $parent_item['guid'] . ';' . 'true' . ';' . $myaddr; + else + $signed_text = $datarray['guid'] . ';' . $parent_item['guid'] . ';' . $signed_body . ';' . $myaddr; + + $authorsig = base64_encode(rsa_sign($signed_text,$a->user['prvkey'],'sha')); + + q("insert into sign (`iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", + intval($post_id), + dbesc($signed_text), + dbesc(base64_encode($authorsig)), + dbesc($myaddr) + ); + } } else { $parent = $post_id; @@ -799,6 +822,12 @@ function item_post(&$a) { } } + + + + + + logger('post_complete'); // figure out how to return, depending on from whence we came diff --git a/mod/network.php b/mod/network.php index cf4c994f0..c0645fe7a 100644 --- a/mod/network.php +++ b/mod/network.php @@ -188,7 +188,7 @@ function network_content(&$a, $update = 0) { if(count($r)) { $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $star_sql AND `contact-id` IN ( " . intval($cid) . " )) "; $o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o; - if($r[0]['network'] !== NETWORK_MAIL && $r[0]['network'] !== NETWORK_DFRN && $r[0]['network'] !== NETWORK_FACEBOOK && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { + if($r[0]['network'] !== NETWORK_MAIL && $r[0]['network'] !== NETWORK_DFRN && $r[0]['network'] !== NETWORK_FACEBOOK && $r[0]['network'] !== NETWORK_DIASPORA && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { notice( t('Private messages to this person are at risk of public disclosure.') . EOL); } diff --git a/mod/openid.php b/mod/openid.php index 6fbd013b8..3c3293147 100644 --- a/mod/openid.php +++ b/mod/openid.php @@ -55,7 +55,8 @@ function openid_content(&$a) { } - $r = q("SELECT * FROM `user` WHERE `openid` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1", + $r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey` + FROM `user` WHERE `openid` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1", dbesc($_SESSION['openid']) ); if(! count($r)) { diff --git a/mod/pubsub.php b/mod/pubsub.php index d6e3d378f..4dff5d531 100644 --- a/mod/pubsub.php +++ b/mod/pubsub.php @@ -122,6 +122,12 @@ function pubsub_post(&$a) { $contact = $r[0]; + // we have no way to match Diaspora guid's with atom post id's and could get duplicates. + // we'll assume that direct delivery is robust (and this is a bad assumption, but the duplicates are messy). + + if($r[0]['network'] === NETWORK_DIASPORA) + hub_post_return(); + $feedhub = ''; require_once('include/items.php'); diff --git a/mod/receive.php b/mod/receive.php index c3738c143..34128518b 100644 --- a/mod/receive.php +++ b/mod/receive.php @@ -15,8 +15,6 @@ function receive_post(&$a) { if($a->argc != 3 || $a->argv[1] !== 'users') http_status_exit(500); - logger('receive: raw input: ' . file_get_contents('php://input'), LOGGER_DATA); - $guid = $a->argv[2]; $r = q("SELECT * FROM `user` WHERE `guid` = '%s' LIMIT 1", @@ -43,29 +41,7 @@ function receive_post(&$a) { if(! is_array($msg)) http_status_exit(500); - - $parsed_xml = parse_xml_string($msg['message'],false); - - $xmlbase = $parsed_xml->post; - - if($xmlbase->request) { - diaspora_request($importer,$xmlbase->request); - } - elseif($xmlbase->status_message) { - diaspora_post($importer,$xmlbase->status_message); - } - elseif($xmlbase->comment) { - diaspora_comment($importer,$xmlbase->comment,$msg); - } - elseif($xmlbase->like) { - diaspora_like($importer,$xmlbase->like,$msg); - } - elseif($xmlbase->retraction) { - diaspora_retraction($importer,$xmlbase->retraction,$msg); - } - else { - logger('mod-diaspora: unknown message type: ' . print_r($xmlbase,true)); - } + diaspora_dispatch($importer,$msg); http_status_exit(200); // NOTREACHED |