diff --git a/INSTALL.txt b/INSTALL.txt
index dd4c747e..053c3390 100644
--- a/INSTALL.txt
+++ b/INSTALL.txt
@@ -15,20 +15,32 @@ hosting provider prior to installation.
Before you begin: Choose a domain name or subdomain name for your server.
Put some thought into this - because changing it is currently not-supported.
Things will break, and some of your friends may have difficulty communicating
-with you. We plan to address this limitation in a future release.
+with you. We plan to address this limitation in a future release. Also decide
+if you wish to connect with members of the Diaspora network, as this will
+impact the installation requirements.
+
+Decide if you will use SSL and obtain an SSL cert. Communications with the
+Diaspora network MAY require both SSL AND an SSL cert signed by a CA which is
+recognised by the major browsers. Friendika will work with self-signed certs
+but Diaspora communication may not. For best results, install your cert PRIOR
+to installing Friendika and when visiting your site for the initial
+installation in step 5, please use the https: link. (Use the http: or non-SSL
+link if your cert is self-signed).
1. Requirements
- Apache with mod-rewrite enabled and "Options All" so you can use a
local .htaccess file
- - PHP 5.2+. The later the better. You'll need 5.3 for encryption of key
-exchange conversations
+ - PHP 5.2+. The later the better. PHP 5.3 is required for communications
+with the Diaspora network and improved security.
+
- PHP *command line* access with register_argc_argv set to true in the
-php.ini file
- - curl, gd, mysql, mbstring, and openssl extensions
+php.ini file [or see 'poormancron' in section 8]
+
+ - curl, gd, mysql, mbstring, mcrypt, and openssl extensions
+
- some form of email server or email gateway such that PHP mail() works
- - mcrypt (optional; used for end-to-end message encryption)
- Mysql 5.x
@@ -36,12 +48,8 @@ php.ini file
(Windows) [Note: other options are presented in Section 8 of this document]
- Installation into a top-level domain or sub-domain (without a
-directory/path component in the URL) is preferred. Directory paths will
-not be as convenient to use and have not been thoroughly tested.
-
- [Dreamhost.com offers all of the necessary hosting features at a
-reasonable price. If your hosting provider doesn't allow Unix shell access,
-you might have trouble getting everything to work.]
+directory/path component in the URL) is preferred. This is REQUIRED if
+you wish to communicate with the Diaspora network.
2. Unpack the Friendika files into the root of your web server document area.
@@ -58,7 +66,9 @@ write or create files in your web directory, create an empty file called
.htconfig.php and make it writable by the web server.
5. Visit your website with a web browser and follow the instructions. Please
-note any error messages and correct these before continuing.
+note any error messages and correct these before continuing. If you are using
+SSL with a known signature authority (recommended), use the https: link to your
+website. If you are using a self-signed cert or no cert, use the http: link.
6. *If* the automated installation fails for any reason, check the following:
@@ -99,7 +109,9 @@ have troubles with this section please contact your hosting provider for
assistance. Friendika will not work correctly if you cannot perform this step.
Alternative: You may be able to use the 'poormancron' plugin to perform this
-step if you are using a recent Friendika release. To do this, edit the file
+step if you are using a recent Friendika release. 'poormancron' may result in
+perfomance and memory issues and is only suitable for small sites with one or
+two users and a handful of contacts. To do this, edit the file
".htconfig.php" and look for a line describing your plugins. On a fresh
installation, it will look like
@@ -114,7 +126,7 @@ $a->config['system']['addon'] = 'js_upload,poormancron';
and save your changes.
-
+
#####################################################################
If things don't work...
diff --git a/addon/facebook/facebook.php b/addon/facebook/facebook.php
index ed59daff..33895f80 100644
--- a/addon/facebook/facebook.php
+++ b/addon/facebook/facebook.php
@@ -151,6 +151,8 @@ function fb_get_friends($uid) {
logger('facebook: fb_get_friends: ' . $s, LOGGER_DATA);
$j = json_decode($s);
logger('facebook: fb_get_friends: json: ' . print_r($j,true), LOGGER_DATA);
+ if(! $j->data)
+ return;
foreach($j->data as $person) {
$s = fetch_url('https://graph.facebook.com/' . $person->id . '?access_token=' . $access_token);
if($s) {
diff --git a/boot.php b/boot.php
index bfdae47b..28467006 100644
--- a/boot.php
+++ b/boot.php
@@ -8,9 +8,9 @@ require_once("include/pgettext.php");
require_once('include/nav.php');
-define ( 'FRIENDIKA_VERSION', '2.2.1079' );
+define ( 'FRIENDIKA_VERSION', '2.2.1083' );
define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
-define ( 'DB_UPDATE_VERSION', 1081 );
+define ( 'DB_UPDATE_VERSION', 1082 );
define ( 'EOL', " \r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
diff --git a/database.sql b/database.sql
index 605433e6..f6ae4c7c 100644
--- a/database.sql
+++ b/database.sql
@@ -38,7 +38,7 @@ CREATE TABLE IF NOT EXISTS `config` (
`k` char(255) NOT NULL,
`v` text NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE=MYISAM DEFAULT CHARSET=utf8;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
@@ -267,6 +267,7 @@ CREATE TABLE IF NOT EXISTS `photo` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(10) unsigned NOT NULL,
`contact-id` int(10) unsigned NOT NULL,
+ `guid` char(64) NOT NULL,
`resource-id` char(255) NOT NULL,
`created` datetime NOT NULL,
`edited` datetime NOT NULL,
@@ -288,7 +289,8 @@ CREATE TABLE IF NOT EXISTS `photo` (
KEY `resource-id` (`resource-id`),
KEY `album` (`album`),
KEY `scale` (`scale`),
- KEY `profile` (`profile`)
+ KEY `profile` (`profile`),
+ KEY `guid` (`guid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
@@ -426,7 +428,7 @@ CREATE TABLE IF NOT EXISTS `register` (
`password` CHAR(255) NOT NULL,
`language` CHAR(16) NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `clients` (
@@ -434,7 +436,7 @@ CREATE TABLE IF NOT EXISTS `clients` (
`pw` VARCHAR( 20 ) NOT NULL ,
`redirect_uri` VARCHAR( 200 ) NOT NULL ,
PRIMARY KEY ( `client_id` )
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `tokens` (
`id` VARCHAR( 40 ) NOT NULL ,
@@ -442,7 +444,7 @@ CREATE TABLE IF NOT EXISTS `tokens` (
`expires` INT NOT NULL ,
`scope` VARCHAR( 200 ) NOT NULL ,
PRIMARY KEY ( `id` )
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `auth_codes` (
`id` VARCHAR( 40 ) NOT NULL ,
@@ -451,7 +453,7 @@ CREATE TABLE IF NOT EXISTS `auth_codes` (
`expires` INT NOT NULL ,
`scope` VARCHAR( 250 ) NOT NULL ,
PRIMARY KEY ( `id` )
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `queue` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
@@ -460,7 +462,7 @@ CREATE TABLE IF NOT EXISTS `queue` (
`created` DATETIME NOT NULL ,
`last` DATETIME NOT NULL ,
`content` MEDIUMTEXT NOT NULL
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `pconfig` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
@@ -468,7 +470,7 @@ CREATE TABLE IF NOT EXISTS `pconfig` (
`cat` CHAR( 255 ) NOT NULL ,
`k` CHAR( 255 ) NOT NULL ,
`v` MEDIUMTEXT NOT NULL
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `hook` (
@@ -476,7 +478,7 @@ CREATE TABLE IF NOT EXISTS `hook` (
`hook` CHAR( 255 ) NOT NULL ,
`file` CHAR( 255 ) NOT NULL ,
`function` CHAR( 255 ) NOT NULL
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `addon` (
@@ -486,7 +488,7 @@ CREATE TABLE IF NOT EXISTS `addon` (
`installed` TINYINT( 1 ) NOT NULL DEFAULT '0' ,
`timestamp` BIGINT NOT NULL DEFAULT '0' ,
`plugin_admin` TINYINT( 1 ) NOT NULL DEFAULT '0'
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `event` (
@@ -507,13 +509,13 @@ CREATE TABLE IF NOT EXISTS `event` (
`allow_gid` MEDIUMTEXT NOT NULL ,
`deny_cid` MEDIUMTEXT NOT NULL ,
`deny_gid` MEDIUMTEXT NOT NULL
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `cache` (
`k` CHAR( 255 ) NOT NULL PRIMARY KEY ,
`v` TEXT NOT NULL,
`updated` DATETIME NOT NULL
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `fcontact` (
@@ -534,14 +536,14 @@ CREATE TABLE IF NOT EXISTS `fcontact` (
`updated` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
INDEX ( `addr` ),
INDEX ( `network` )
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `ffinder` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`uid` INT UNSIGNED NOT NULL ,
`cid` INT UNSIGNED NOT NULL ,
`fid` INT UNSIGNED NOT NULL
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `fsuggest` (
@@ -554,7 +556,7 @@ CREATE TABLE IF NOT EXISTS `fsuggest` (
`photo` CHAR( 255 ) NOT NULL ,
`note` TEXT NOT NULL ,
`created` DATETIME NOT NULL
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `mailacct` (
@@ -569,7 +571,7 @@ CREATE TABLE IF NOT EXISTS `mailacct` (
`reply_to` CHAR( 255 ) NOT NULL ,
`pubmail` TINYINT(1) NOT NULL DEFAULT '0',
`last_check` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `attach` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
@@ -585,13 +587,13 @@ CREATE TABLE IF NOT EXISTS `attach` (
`allow_gid` MEDIUMTEXT NOT NULL ,
`deny_cid` MEDIUMTEXT NOT NULL ,
`deny_gid` MEDIUMTEXT NOT NULL
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `guid` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`guid` CHAR( 64 ) NOT NULL ,
INDEX ( `guid` )
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `sign` (
@@ -601,6 +603,6 @@ CREATE TABLE IF NOT EXISTS `sign` (
`signature` TEXT NOT NULL ,
`signer` CHAR( 255 ) NOT NULL ,
INDEX ( `iid` )
-) ENGINE = MYISAM DEFAULT CHARSET=utf8;
+) ENGINE = MyISAM DEFAULT CHARSET=utf8;
diff --git a/include/Contact.php b/include/Contact.php
index 4ca77d06..7524c0ce 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -85,3 +85,55 @@ function unmark_for_death($contact) {
);
}}
+if(! function_exists('contact_photo_menu')){
+function contact_photo_menu($contact) {
+
+ $a = get_app();
+
+ $contact_url="";
+ $pm_url="";
+ $status_link="";
+ $photos_link="";
+ $posts_link="";
+
+ $sparkle = false;
+ if($contact['network'] === NETWORK_DFRN) {
+ $sparkle = true;
+ $profile_link = $a->get_baseurl() . '/redir/' . $contact['id'];
+ }
+ else
+ $profile_link = $contact['url'];
+
+ if($profile_link === 'mailbox')
+ $profile_link = '';
+
+ if($sparkle) {
+ $status_link = $profile_link . "?url=status";
+ $photos_link = $profile_link . "?url=photos";
+ $profile_link = $profile_link . "?url=profile";
+ $pm_url = $a->get_baseurl() . '/message/new/' . $contact['id'];
+ }
+
+ $contact_url = $a->get_baseurl() . '/contacts/' . $contact['id'];
+ $posts_link = $a->get_baseurl() . '/network/?cid=' . $contact['id'];
+
+ $menu = Array(
+ t("View status") => $status_link,
+ t("View profile") => $profile_link,
+ t("View photos") => $photos_link,
+ t("View recent") => $posts_link,
+ t("Edit contact") => $contact_url,
+ t("Send PM") => $pm_url,
+ );
+
+
+ $args = array('contact' => $contact, 'menu' => $menu);
+
+ call_hooks('contact_photo_menu', $args);
+
+ $o = "";
+ foreach($menu as $k=>$v){
+ if ($v!="") $o .= "
$k \n";
+ }
+ return $o;
+}}
diff --git a/include/Photo.php b/include/Photo.php
index de4c3d9e..1450374f 100644
--- a/include/Photo.php
+++ b/include/Photo.php
@@ -185,11 +185,20 @@ class Photo {
public function store($uid, $cid, $rid, $filename, $album, $scale, $profile = 0, $allow_cid = '', $allow_gid = '', $deny_cid = '', $deny_gid = '') {
+ $r = q("select `guid` from photo where `resource-id` = '%s' and `guid` != '' limit 1",
+ dbesc($rid)
+ );
+ if(count($r))
+ $guid = $r[0]['guid'];
+ else
+ $guid = get_guid();
+
$r = q("INSERT INTO `photo`
- ( `uid`, `contact-id`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
- VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )",
+ ( `uid`, `contact-id`, `guid`, `resource-id`, `created`, `edited`, `filename`, `album`, `height`, `width`, `data`, `scale`, `profile`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid` )
+ VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', %d, %d, '%s', '%s', '%s', '%s' )",
intval($uid),
intval($cid),
+ dbesc($guid),
dbesc($rid),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
diff --git a/include/acl_selectors.php b/include/acl_selectors.php
index 48ba77a8..66fe104e 100644
--- a/include/acl_selectors.php
+++ b/include/acl_selectors.php
@@ -170,7 +170,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p
$sql_extra .= " AND `network` IN ( 'dfrn' ) ";
}
elseif($privatenet) {
- $sql_extra .= " AND `network` IN ( 'dfrn', 'mail', 'face' ) ";
+ $sql_extra .= " AND `network` IN ( 'dfrn', 'mail', 'face', 'dspr' ) ";
}
diff --git a/include/auth.php b/include/auth.php
index 768af626..b7b96bdc 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -48,7 +48,8 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
goaway(z_root());
}
- $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
+ $r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
+ FROM `user` WHERE `uid` = %d LIMIT 1",
intval($_SESSION['uid'])
);
@@ -183,7 +184,8 @@ else {
// process normal login request
- $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
+ $r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
+ FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
dbesc(trim($_POST['openid_url'])),
dbesc(trim($_POST['openid_url'])),
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
new file mode 100644
index 00000000..7f7b8748
--- /dev/null
+++ b/include/bb2diaspora.php
@@ -0,0 +1,178 @@
+', '', $s[1]) . '[/code]';
+}
+
+
+ // BBcode 2 HTML was written by WAY2WEB.net
+ // extended to work with Mistpark/Friendika - Mike Macgirvin
+
+function bb2diaspora($Text,$preserve_nl = false) {
+
+ // Replace any html brackets with HTML Entities to prevent executing HTML or script
+ // Don't use strip_tags here because it breaks [url] search by replacing & with amp
+
+ $Text = str_replace("<", "<", $Text);
+ $Text = str_replace(">", ">", $Text);
+
+
+ if($preserve_nl)
+ $Text = str_replace(array("\n","\r"), array('',''),$Text);
+
+ // Set up the parameters for a URL search string
+ $URLSearchString = "^\[\]";
+ // Set up the parameters for a MAIL search string
+ $MAILSearchString = $URLSearchString;
+
+ // Perform URL Search
+
+ // [img]pathtoimage[/img]
+
+
+ $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '[$1]($1)', $Text);
+ $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.*?)\[/url\])", '[$2]($1)', $Text);
+
+// $Text = preg_replace("/\[img\](.*?)\[\/img\]/", t('Image/photo: ') . '$1', $Text);
+// $Text = preg_replace("/\[img\](.*?)\[\/img\]/", t('image/photo'), $Text);
+
+ // Perform MAIL Search
+ $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '[$1](mailto:$1)', $Text);
+ $Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.*?)\[\/mail\]/", '[$2](mailto:$1)', $Text);
+
+ $Text = str_replace('*', '\\*', $Text);
+ $Text = str_replace('_', '\\_', $Text);
+
+ $Text = str_replace('`','\\`', $Text);
+
+ // Check for bold text
+ $Text = preg_replace("(\[b\](.*?)\[\/b\])is",'**$1**',$Text);
+
+ // Check for Italics text
+ $Text = preg_replace("(\[i\](.*?)\[\/i\])is",'_$1_',$Text);
+
+ // Check for Underline text
+// $Text = preg_replace("(\[u\](.*?)\[\/u\])is",'$1 ',$Text);
+
+ // Check for strike-through text
+// $Text = preg_replace("(\[s\](.*?)\[\/s\])is",'$1 ',$Text);
+
+ // Check for over-line text
+// $Text = preg_replace("(\[o\](.*?)\[\/o\])is",'$1 ',$Text);
+
+ // Check for colored text
+// $Text = preg_replace("(\[color=(.*?)\](.*?)\[\/color\])is","$2 ",$Text);
+
+ // Check for sized text
+// $Text = preg_replace("(\[size=(.*?)\](.*?)\[\/size\])is","$2 ",$Text);
+
+ // Check for list text
+// $Text = preg_replace("/\[list\](.*?)\[\/list\]/is", '' ,$Text);
+// $Text = preg_replace("/\[list=1\](.*?)\[\/list\]/is", '' ,$Text);
+// $Text = preg_replace("/\[list=i\](.*?)\[\/list\]/s",'' ,$Text);
+// $Text = preg_replace("/\[list=I\](.*?)\[\/list\]/s", '' ,$Text);
+// $Text = preg_replace("/\[list=a\](.*?)\[\/list\]/s", '' ,$Text);
+// $Text = preg_replace("/\[list=A\](.*?)\[\/list\]/s", '' ,$Text);
+// $Text = preg_replace("/\[li\](.*?)\[\/li\]/s", '$1 ' ,$Text);
+
+// $Text = preg_replace("/\[td\](.*?)\[\/td\]/s", '$1 ' ,$Text);
+// $Text = preg_replace("/\[tr\](.*?)\[\/tr\]/s", '$1 ' ,$Text);
+// $Text = preg_replace("/\[table\](.*?)\[\/table\]/s", '' ,$Text);
+
+// $Text = preg_replace("/\[table border=1\](.*?)\[\/table\]/s", '' ,$Text);
+// $Text = preg_replace("/\[table border=0\](.*?)\[\/table\]/s", '' ,$Text);
+
+
+// $Text = str_replace("[*]", "", $Text);
+
+ // Check for font change text
+// $Text = preg_replace("(\[font=(.*?)\](.*?)\[\/font\])","$2 ",$Text);
+
+ // Declare the format for [code] layout
+
+ $Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/is",'stripdcode_br_cb',$Text);
+
+// $CodeLayout = '$1
';
+ // Check for [code] text
+ $Text = preg_replace("/\[code\](.*?)\[\/code\]/is","```$1```", $Text);
+
+
+
+
+ // Declare the format for [quote] layout
+// $QuoteLayout = '$1 ';
+ // Check for [quote] text
+// $Text = preg_replace("/\[quote\](.*?)\[\/quote\]/is","$QuoteLayout", $Text);
+
+ // Images
+
+ // html5 video and audio
+
+// $Text = preg_replace("/\[video\](.*?)\[\/video\]/", '$1 ', $Text);
+
+// $Text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '$1 ', $Text);
+
+// $Text = preg_replace("/\[iframe\](.*?)\[\/iframe\]/", '', $Text);
+
+ // [img=widthxheight]image source[/img]
+// $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/", ' ', $Text);
+
+// if (get_pconfig(local_user(), 'oembed', 'use_for_youtube' )==1){
+// // use oembed for youtube links
+// $Text = preg_replace("/\[youtube\]/",'[embed]',$Text);
+// $Text = preg_replace("/\[\/youtube\]/",'[/embed]',$Text);
+// } else {
+// // Youtube extensions
+ // $Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text);
+ // $Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text);
+// $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", 'VIDEO ', $Text);
+// }
+// $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", ' ', $Text);
+
+
+
+ // oembed tag
+// $Text = oembed_bbcode2html($Text);
+
+ // If we found an event earlier, strip out all the event code and replace with a reformatted version.
+
+// if(x($ev,'desc') && x($ev,'start')) {
+// $sub = format_event_html($ev);
+
+ // $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/is",$sub,$Text);
+ //$Text = preg_replace("/\[event\-start\](.*?)\[\/event\-start\]/is",'',$Text);
+// $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/is",'',$Text);
+// $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/is",'',$Text);
+// $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",'',$Text);
+// }
+
+
+
+ call_hooks('bb2diaspora',$Text);
+
+ return $Text;
+}
diff --git a/include/bbcode.php b/include/bbcode.php
index 3619015c..a3f2971e 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -41,7 +41,7 @@ function bbcode($Text,$preserve_nl = false) {
// Perform URL Search
- $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'\%\$\!\+\,]+)/", ' $2 ', $Text);
+ $Text = preg_replace("/([^\]\=]|^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\%\$\!\+\,]+)/", '$1$2 ', $Text);
$Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '$1 ', $Text);
$Text = preg_replace("(\[url\=([$URLSearchString]*)\](.*?)\[/url\])", '$2 ', $Text);
@@ -134,7 +134,7 @@ function bbcode($Text,$preserve_nl = false) {
// Youtube extensions
$Text = preg_replace("/\[youtube\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text);
$Text = preg_replace("/\[youtube\]https?:\/\/youtu.be\/(.*?)\[\/youtube\]/",'[youtube]$1[/youtube]',$Text);
- $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", 'VIDEO ', $Text);
+ $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", 'VIDEO ', $Text);
}
// $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", ' ', $Text);
diff --git a/include/contact_selectors.php b/include/contact_selectors.php
index ac1e38e4..1303acf7 100644
--- a/include/contact_selectors.php
+++ b/include/contact_selectors.php
@@ -46,10 +46,11 @@ function contact_reputation($current) {
}
-function contact_poll_interval($current) {
+function contact_poll_interval($current, $disabled = false) {
+ $dis = (($disabled) ? ' disabled="disabled" ' : '');
$o = '';
- $o .= ' ' . "\r\n";
+ $o .= " " . "\r\n";
$rep = array(
0 => t('Frequently'),
@@ -67,3 +68,13 @@ function contact_poll_interval($current) {
$o .= "\r\n";
return $o;
}
+
+
+function network_to_name($s) {
+
+ call_hooks('network_to_name', $s);
+
+ return str_replace(array(NETWORK_DFRN,NETWORK_OSTATUS,NETWORK_FEED,NETWORK_MAIL,NETWORK_DIASPORA,NETWORK_FACEBOOK,NETWORK_ZOT),
+ array(t('Friendika'),t('OStatus'),t('RSS/Atom'),t('Email'),t('Diaspora'),t('Facebook'),t('Zot!')),$s);
+
+}
diff --git a/include/diaspora.php b/include/diaspora.php
index f3adc608..90c80236 100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -2,6 +2,74 @@
require_once('include/crypto.php');
require_once('include/items.php');
+require_once('include/bb2diaspora.php');
+
+function diaspora_dispatch($importer,$msg) {
+
+ $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);
+ }
+ elseif($xmlbase->photo) {
+ diaspora_photo($importer,$xmlbase->photo,$msg);
+ }
+ else {
+ logger('diaspora_dispatch: unknown message type: ' . print_r($xmlbase,true));
+ }
+ return;
+}
+
+function diaspora_get_contact_by_handle($uid,$handle) {
+ $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND `uid` = %d AND `addr` = '%s' LIMIT 1",
+ dbesc(NETWORK_DIASPORA),
+ intval($uid),
+ dbesc($handle)
+ );
+ if($r && count($r))
+ return $r[0];
+ return false;
+}
+
+function find_diaspora_person_by_handle($handle) {
+ $r = q("select * from fcontact where network = '%s' and addr = '%s' limit 1",
+ dbesc(NETWORK_DIASPORA),
+ dbesc($handle)
+ );
+ if(count($r)) {
+ // update record occasionally so it doesn't get stale
+ $d = strtotime($r[0]['updated'] . ' +00:00');
+ if($d < strtotime('now - 14 days')) {
+ q("delete from fcontact where id = %d limit 1",
+ intval($r[0]['id'])
+ );
+ }
+ else
+ return $r[0];
+ }
+ require_once('include/Scrape.php');
+ $r = probe_url($handle, PROBE_DIASPORA);
+ if((count($r)) && ($r['network'] === NETWORK_DIASPORA)) {
+ add_fcontact($r);
+ return ($r);
+ }
+ return false;
+}
+
function get_diaspora_key($uri) {
logger('Fetching diaspora key for: ' . $uri);
@@ -13,16 +81,6 @@ function get_diaspora_key($uri) {
}
-function diaspora_base_message($type,$data) {
-
- $tpl = get_markup_template('diaspora_' . $type . '.tpl');
- if(! $tpl)
- return '';
- return replace_macros($tpl,$data);
-
-}
-
-
function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey) {
$a = get_app();
@@ -262,42 +320,6 @@ function diaspora_decode($importer,$xml) {
}
-function diaspora_get_contact_by_handle($uid,$handle) {
- $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND `uid` = %d AND `addr` = '%s' LIMIT 1",
- dbesc(NETWORK_DIASPORA),
- intval($uid),
- dbesc($handle)
- );
- if($r && count($r))
- return $r[0];
- return false;
-}
-
-function find_diaspora_person_by_handle($handle) {
- $r = q("select * from fcontact where network = '%s' and addr = '%s' limit 1",
- dbesc(NETWORK_DIASPORA),
- dbesc($handle)
- );
- if(count($r)) {
- // update record occasionally so it doesn't get stale
- $d = strtotime($r[0]['updated'] . ' +00:00');
- if($d < strtotime('now - 14 days')) {
- q("delete from fcontact where id = %d limit 1",
- intval($r[0]['id'])
- );
- }
- else
- return $r[0];
- }
- require_once('include/Scrape.php');
- $r = probe_url($handle, PROBE_DIASPORA);
- if((count($r)) && ($r['network'] === NETWORK_DIASPORA)) {
- add_fcontact($r);
- return ($r);
- }
- return false;
-}
-
function diaspora_request($importer,$xml) {
@@ -413,32 +435,7 @@ function diaspora_post($importer,$xml) {
$created = unxmlify($xml->created_at);
$private = ((unxmlify($xml->public) == 'false') ? 1 : 0);
- $body = unxmlify($xml->raw_message);
-
- require_once('library/HTMLPurifier.auto.php');
- require_once('include/html2bbcode.php');
-
- $maxlen = get_max_import_size();
- if($maxlen && (strlen($body) > $maxlen))
- $body = substr($body,0, $maxlen);
-
- if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
-
- $body = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+? #s',
- '[youtube]$1[/youtube]', $body);
-
- $body = preg_replace('##s',
- '[youtube]$1[/youtube]', $body);
-
- $body = oembed_html2bbcode($body);
-
- $config = HTMLPurifier_Config::createDefault();
- $config->set('Cache.DefinitionImpl', null);
- $purifier = new HTMLPurifier($config);
- $body = $purifier->purify($body);
-
- $body = html2bbcode($body);
- }
+ $body = diaspora2bb($xml->raw_message);
$datarray = array();
$datarray['uid'] = $importer['uid'];
@@ -522,7 +519,7 @@ function diaspora_comment($importer,$xml,$msg) {
if($parent_author_signature) {
- $owner_signed_data = $guid . ';' . $parent_guid . ';' . $text . ';' . $msg['author'];
+ $owner_signed_data = $guid . ';' . $parent_guid . ';' . $text . ';' . $diaspora_handle;
$parent_author_signature = base64_decode($parent_author_signature);
@@ -536,32 +533,7 @@ function diaspora_comment($importer,$xml,$msg) {
// Phew! Everything checks out. Now create an item.
- require_once('library/HTMLPurifier.auto.php');
- require_once('include/html2bbcode.php');
-
- $body = $text;
-
- $maxlen = get_max_import_size();
- if($maxlen && (strlen($body) > $maxlen))
- $body = substr($body,0, $maxlen);
-
- if((strpos($body,'<') !== false) || (strpos($body,'>') !== false)) {
-
- $body = preg_replace('#]+>.+?' . 'http://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+? #s',
- '[youtube]$1[/youtube]', $body);
-
- $body = preg_replace('##s',
- '[youtube]$1[/youtube]', $body);
-
- $body = oembed_html2bbcode($body);
-
- $config = HTMLPurifier_Config::createDefault();
- $config->set('Cache.DefinitionImpl', null);
- $purifier = new HTMLPurifier($config);
- $body = $purifier->purify($body);
-
- $body = html2bbcode($body);
- }
+ $body = diaspora2bb($text);
$message_id = $diaspora_handle . ':' . $guid;
@@ -596,13 +568,67 @@ function diaspora_comment($importer,$xml,$msg) {
dbesc(base64_encode($author_signature)),
dbesc($diaspora_handle)
);
+
+ // if the message isn't already being relayed, notify others
+ // the existence of parent_author_signature means the parent_author or owner
+ // is already relaying.
+
+ proc_run('php','include/notifier.php','comment',$message_id);
+ }
+ return;
+}
+
+function diaspora_photo($importer,$xml,$msg) {
+
+ $remote_photo_path = notags(unxmlify($xml->remote_photo_path));
+
+ $remote_photo_name = notags(unxmlify($xml->remote_photo_name));
+
+ $status_message_guid = notags(unxmlify($xml->status_message_guid));
+
+ $guid = notags(unxmlify($xml->guid));
+
+ $diaspora_handle = notags(unxmlify($xml->diaspora_handle));
+
+ $public = notags(unxmlify($xml->public));
+
+ $created_at = notags(unxmlify($xml_created_at));
+
+
+ $contact = diaspora_get_contact_by_handle($importer['uid'],$msg['author']);
+ if(! $contact)
+ return;
+
+ if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
+ logger('diaspora_photo: Ignoring this author.');
+ http_status_exit(202);
+ // NOTREACHED
}
- // notify others
- return;
+ $r = q("SELECT * FROM `item` WHERE `uid` = %d AND `guid` = '%s' LIMIT 1",
+ intval($importer['uid']),
+ dbesc($status_message_guid)
+ );
+ if(! count($r)) {
+ logger('diaspora_photo: parent item not found: parent: ' . $parent_guid . ' item: ' . $guid);
+ return;
+ }
+ $parent_item = $r[0];
+ $link_text = '[img]' . $remote_photo_path . $remote_photo_name . '[/img]' . "\n";
+
+ $r = q("update item set `body` = '%s' where `id` = %d and `uid` = %d limit 1",
+ dbesc($link_text . $parent_item['body']),
+ intval($parent_item['id']),
+ intval($parent_item['uid'])
+ );
+
+ return;
}
+
+
+
function diaspora_like($importer,$xml,$msg) {
$a = get_app();
@@ -689,7 +715,8 @@ function diaspora_like($importer,$xml,$msg) {
}
if($parent_author_signature) {
- $owner_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $msg['author'];
+// $owner_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $msg['author'];
+ $owner_signed_data = $guid . ';' . $parent_guid . ';' . $target_type . ';' . $positive . ';' . $diaspora_handle;
$parent_author_signature = base64_decode($parent_author_signature);
@@ -768,7 +795,12 @@ EOT;
);
}
- // FIXME send notification
+ // if the message isn't already being relayed, notify others
+ // the existence of parent_author_signature means the parent_author or owner
+ // is already relaying.
+
+ if(! $parent_author_signature)
+ proc_run('php','include/notifier.php','comment',$message_id);
return;
}
@@ -777,19 +809,32 @@ function diaspora_retraction($importer,$xml) {
$guid = notags(unxmlify($xml->guid));
$diaspora_handle = notags(unxmlify($xml->diaspora_handle));
+ $type = notags(unxmlify($xml->type));
$contact = diaspora_get_contact_by_handle($importer['uid'],$diaspora_handle);
if(! $contact)
return;
-// if(($contact['rel'] == CONTACT_IS_FOLLOWER) || ($contact['blocked']) || ($contact['readonly'])) {
-// logger('diaspora_retraction: Ignoring this author.');
-// http_status_exit(202);
-// // NOTREACHED
-// }
-
-
+ if($type === 'Person') {
+ contact_remove($contact['id']);
+ }
+ elseif($type === 'Post') {
+ $r = q("select * from item where guid = '%s' and uid = %d limit 1",
+ dbesc('guid'),
+ intval($importer['uid'])
+ );
+ if(count($r)) {
+ if(link_compare($r[0]['author-link'],$contact['url'])) {
+ q("update item set `deleted` = 1, `changed` = '%s' where `id` = %d limit 1",
+ dbesc(datetime_convert()),
+ intval($r[0]['id'])
+ );
+ }
+ }
+ }
+ http_exit_status(202);
+ // NOTREACHED
}
function diaspora_share($me,$contact) {
@@ -805,20 +850,54 @@ function diaspora_share($me,$contact) {
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$me,$contact,$me['prvkey'],$contact['pubkey'])));
- post_url($contact['notify'] . '/',$slap);
- $return_code = $a->get_curl_code();
- logger('diaspora_send_share: returns: ' . $return_code);
- return $return_code;
+ return(diaspora_transmit($owner,$contact,$slap));
}
+function diaspora_unshare($me,$contact) {
+
+ $a = get_app();
+ $myaddr = $me['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+
+ $tpl = get_markup_template('diaspora_retract.tpl');
+ $msg = replace_macros($tpl, array(
+ '$guid' => $me['guid'],
+ '$type' => 'Person',
+ '$handle' => $myaddr
+ ));
+
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$me,$contact,$me['prvkey'],$contact['pubkey'])));
+
+ return(diaspora_transmit($owner,$contact,$slap));
+
+}
+
+
+
function diaspora_send_status($item,$owner,$contact) {
$a = get_app();
$myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
$theiraddr = $contact['addr'];
- require_once('include/bbcode.php');
- $body = xmlify(bbcode($item['body']));
+ $images = array();
+
+ $body = $item['body'];
+
+ $cnt = preg_match_all('|\[img\](.*?)\[\/img\]|',$body,$matches,PREG_SET_ORDER);
+ if($cnt) {
+ foreach($matches as $mtch) {
+ $detail = array();
+ $detail['str'] = $mtch[0];
+ $detail['path'] = dirname($mtch[1]) . '/';
+ $detail['file'] = basename($mtch[1]);
+ $detail['guid'] = $item['guid'];
+ $detail['handle'] = $myaddr;
+ $images[] = $detail;
+ $body = str_replace($detail['str'],t('link'),$body);
+ }
+ }
+
+ $body = xmlify(bb2diaspora($body));
$public = (($item['private']) ? 'false' : 'true');
require_once('include/datetime.php');
@@ -833,17 +912,59 @@ function diaspora_send_status($item,$owner,$contact) {
'$created' => $created
));
- logger('diaspora_send_status: base message: ' . $msg, LOGGER_DATA);
+ logger('diaspora_send_status: ' . $owner['username'] . ' -> ' . $contact['name'] . ' base message: ' . $msg, LOGGER_DATA);
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
- post_url($contact['notify'] . '/',$slap);
- $return_code = $a->get_curl_code();
- logger('diaspora_send_status: returns: ' . $return_code);
+ $return_code = diaspora_transmit($owner,$contact,$slap);
+
+ if(count($images)) {
+ diaspora_send_images($item,$owner,$contact,$images);
+ }
+
return $return_code;
}
+function diaspora_send_images($item,$owner,$contact,$images) {
+ $a = get_app();
+ if(! count($images))
+ return;
+ $mysite = substr($a->get_baseurl(),strpos($a->get_baseurl(),'://') + 3) . '/photo';
+
+ $tpl = get_markup_template('diaspora_photo.tpl');
+ foreach($images as $image) {
+ if(! stristr($image['path'],$mysite))
+ continue;
+ $resource = str_replace('.jpg','',$image['file']);
+ $resource = substr($resource,0,strpos($resource,'-'));
+
+ $r = q("select * from photo where `resource-id` = '%s' and `uid` = %d limit 1",
+ dbesc($resource),
+ intval($owner['uid'])
+ );
+ if(! count($r))
+ continue;
+ $public = (($r[0]['allow_cid'] || $r[0]['allow_gid'] || $r[0]['deny_cid'] || $r[0]['deny_gid']) ? 'false' : 'true' );
+ $msg = replace_macros($tpl,array(
+ '$path' => xmlify($image['path']),
+ '$filename' => xmlify($image['file']),
+ '$msg_guid' => xmlify($image['guid']),
+ '$guid' => xmlify($r[0]['guid']),
+ '$handle' => xmlify($image['handle']),
+ '$public' => xmlify($public),
+ '$created_at' => xmlify(datetime_convert('UTC','UTC',$r[0]['created'],'Y-m-d h:i:s \U\T\C'))
+ ));
+
+
+ logger('diaspora_send_photo: base message: ' . $msg, LOGGER_DATA);
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+
+ diaspora_transmit($owner,$contact,$slap);
+ }
+
+}
+
function diaspora_send_followup($item,$owner,$contact) {
$a = get_app();
@@ -869,16 +990,16 @@ function diaspora_send_followup($item,$owner,$contact) {
$like = false;
}
- $text = bbcode($item['body']);
+ $text = bb2diaspora($item['body']);
// sign it
if($like)
- $signed_text = $item['guid'] . ';' . $target_type . ';' . $positive . ';' . $myaddr;
+ $signed_text = $item['guid'] . ';' . $target_type . ';' . $parent_guid . ';' . $positive . ';' . $myaddr;
else
$signed_text = $item['guid'] . ';' . $parent_guid . ';' . $text . ';' . $myaddr;
- $authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey']),'sha');
+ $authorsig = base64_encode(rsa_sign($signed_text,$owner['uprvkey'],'sha'));
$msg = replace_macros($tpl,array(
'$guid' => xmlify($item['guid']),
@@ -894,11 +1015,7 @@ function diaspora_send_followup($item,$owner,$contact) {
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
- post_url($contact['notify'] . '/',$slap);
- $return_code = $a->get_curl_code();
- logger('diaspora_send_followup: returns: ' . $return_code);
- return $return_code;
-
+ return(diaspora_transmit($owner,$contact,$slap));
}
@@ -937,7 +1054,7 @@ function diaspora_send_relay($item,$owner,$contact) {
$like = false;
}
- $text = bbcode($item['body']);
+ $text = bb2diaspora($item['body']);
// sign it
@@ -970,10 +1087,7 @@ function diaspora_send_relay($item,$owner,$contact) {
$slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
- post_url($contact['notify'] . '/',$slap);
- $return_code = $a->get_curl_code();
- logger('diaspora_send_relay: returns: ' . $return_code);
- return $return_code;
+ return(diaspora_transmit($owner,$contact,$slap));
}
@@ -981,8 +1095,42 @@ function diaspora_send_relay($item,$owner,$contact) {
function diaspora_send_retraction($item,$owner,$contact) {
+ $a = get_app();
+ $myaddr = $owner['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+
+ $tpl = get_markup_template('diaspora_retract.tpl');
+ $msg = replace_macros($tpl, array(
+ '$guid' => $item['guid'],
+ '$type' => 'Post',
+ '$handle' => $myaddr
+ ));
+
+ $slap = 'xml=' . urlencode(urlencode(diaspora_msg_build($msg,$owner,$contact,$owner['uprvkey'],$contact['pubkey'])));
+
+ return(diaspora_transmit($owner,$contact,$slap));
+}
+function diaspora_transmit($owner,$contact,$slap) {
-}
\ No newline at end of file
+ $a = get_app();
+
+ post_url($contact['notify'] . '/',$slap);
+ $return_code = $a->get_curl_code();
+ logger('diaspora_transmit: returns: ' . $return_code);
+
+ if(! $return_code) {
+ logger('diaspora_transmit: queue message');
+ // queue message for redelivery
+ q("INSERT INTO `queue` ( `cid`, `created`, `last`, `content`)
+ VALUES ( %d, '%s', '%s', '%s') ",
+ intval($contact['id']),
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ dbesc($slap)
+ );
+ }
+
+ return(($return_code) ? $return_code : (-1));
+}
diff --git a/include/group.php b/include/group.php
index 1ebae7b7..f21ce42e 100644
--- a/include/group.php
+++ b/include/group.php
@@ -124,9 +124,10 @@ function group_public_members($gid) {
$r = q("SELECT `contact`.`id` AS `contact-id` FROM `group_member`
LEFT JOIN `contact` ON `contact`.`id` = `group_member`.`contact-id`
WHERE `gid` = %d AND `group_member`.`uid` = %d
- AND `contact`.`network` != 'dfrn' AND `contact`.`network` != 'mail' AND `contact`.`network` != 'face' ",
+ AND ( `contact`.`network` = '%s' OR `contact`.`notify` = '' )",
intval($gid),
- intval(local_user())
+ intval(local_user()),
+ dbesc(NETWORK_OSTATUS)
);
if(count($r))
$ret = count($r);
diff --git a/include/items.php b/include/items.php
index 746e3b29..150be270 100644
--- a/include/items.php
+++ b/include/items.php
@@ -12,6 +12,18 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
if(! strlen($owner_nick))
killme();
+ $public_feed = (($dfrn_id) ? false : true);
+ $starred = false;
+ $converse = false;
+
+ if($public_feed && $a->argc > 2) {
+ for($x = 2; $x < $a->argc; $x++) {
+ if($a->argv[$x] == 'converse')
+ $converse = true;
+ }
+ }
+
+
$sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' ";
$r = q("SELECT `contact`.*, `user`.`uid` AS `user_uid`, `user`.`nickname`, `user`.`timezone`
@@ -29,7 +41,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
$birthday = feed_birthday($owner_id,$owner['timezone']);
- if(strlen($dfrn_id)) {
+ if(! $public_feed) {
$sql_extra = '';
switch($direction) {
@@ -81,7 +93,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
);
}
- if($dfrn_id === '' || $dfrn_id === '*')
+ if($public_feed)
$sort = 'DESC';
else
$sort = 'ASC';
@@ -89,6 +101,11 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
if(! strlen($last_update))
$last_update = 'now -30 days';
+ if($public_feed) {
+ if(! $converse)
+ $sql_extra .= " AND `contact`.`self` = 1 ";
+ }
+
$check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s');
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
@@ -152,7 +169,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
// public feeds get html, our own nodes use bbcode
- if($dfrn_id === '') {
+ if($public_feed) {
$type = 'html';
// catch any email that's in a public conversation and make sure it doesn't leak
if($item['private'])
@@ -1556,7 +1573,7 @@ function subscribe_to_hub($url,$importer,$contact) {
intval($importer['uid'])
);
}
- if(! count($r))
+ if((! count($r)) || $contact['network'] === NETWORK_DIASPORA)
return;
$push_url = get_config('system','url') . '/pubsub/' . $r[0]['nickname'] . '/' . $contact['id'];
diff --git a/include/network.php b/include/network.php
index d4f0d8aa..691a8c9f 100644
--- a/include/network.php
+++ b/include/network.php
@@ -508,7 +508,7 @@ function fetch_xrd_links($url) {
$xrd_timeout = intval(get_config('system','xrd_timeout'));
$redirects = 0;
- $xml = fetch_url($url,false,$redirects,(($xrd_timeout) ? $xrd_timeout : 30));
+ $xml = fetch_url($url,false,$redirects,(($xrd_timeout) ? $xrd_timeout : 20));
logger('fetch_xrd_links: ' . $xml, LOGGER_DATA);
@@ -536,7 +536,7 @@ function fetch_xrd_links($url) {
$aliases = array($alias);
else
$aliases = $alias;
- if($aliases && count($aliases)) {
+ if(is_array($aliases) && count($aliases)) {
foreach($aliases as $alias) {
$links[]['@attributes'] = array('rel' => 'alias' , 'href' => $alias);
}
diff --git a/include/notifier.php b/include/notifier.php
index cf8871fb..e92a4f6a 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -139,7 +139,7 @@ function notifier_run($argv, $argc){
$hub = get_config('system','huburl');
// If this is a public conversation, notify the feed hub
- $notify_hub = true;
+ $public_message = true;
// fill this in with a single salmon slap if applicable
$slap = '';
@@ -150,10 +150,40 @@ function notifier_run($argv, $argc){
$parent = $items[0];
- if($parent['wall'] == 0 && (! $expire)) {
+ // This is IMPORTANT!!!!
+
+ // We will only send a "notify owner to relay" or followup message if the referenced post
+ // originated on our system by virtue of having our hostname somewhere
+ // in the URI, AND it was a comment (not top_level) AND the parent originated elsewhere.
+ // if $parent['wall'] == 1 we will already have the parent message in our array
+ // and we will relay the whole lot.
+
+ // expire sends an entire group of expire messages and cannot be forwarded.
+ // However the conversation owner will be a part of the conversation and will
+ // be notified during this run.
+ // Other DFRN conversation members will be alerted during polled updates.
+
+ // Diaspora members currently are not notified of expirations, and other networks have
+ // either limited or no ability to process deletions. We should at least fix Diaspora
+ // by stringing togther an array of retractions and sending them onward.
+
+
+ $localhost = $a->get_hostname();
+ if(strpos($localhost,':'))
+ $localhost = substr($localhost,0,strpos($localhost,':'));
+
+ /**
+ *
+ * Be VERY CAREFUL if you make any changes to the following line. Seemingly innocuous changes
+ * have been known to cause runaway conditions which affected several servers, along with
+ * permissions issues.
+ *
+ */
+
+ if((! $top_level) && ($parent['wall'] == 0) && (! $expire) && (stristr($target_item['uri'],$localhost))) {
// local followup to remote post
$followup = true;
- $notify_hub = false; // not public
+ $public_message = false; // not public
$conversant_str = dbesc($parent['contact-id']);
}
else {
@@ -163,7 +193,7 @@ function notifier_run($argv, $argc){
|| (strlen($parent['allow_gid']))
|| (strlen($parent['deny_cid']))
|| (strlen($parent['deny_gid']))) {
- $notify_hub = false; // private recipients, not public
+ $public_message = false; // private recipients, not public
}
$allow_people = expand_acl($parent['allow_cid']);
@@ -177,7 +207,7 @@ function notifier_run($argv, $argc){
$recipients[] = $item['contact-id'];
$conversants[] = $item['contact-id'];
// pull out additional tagged people to notify (if public message)
- if($notify_hub && strlen($item['inform'])) {
+ if($public_message && strlen($item['inform'])) {
$people = explode(',',$item['inform']);
foreach($people as $person) {
if(substr($person,0,4) === 'cid:') {
@@ -241,7 +271,7 @@ function notifier_run($argv, $argc){
));
if($cmd === 'mail') {
- $notify_hub = false; // mail is not public
+ $public_message = false; // mail is not public
$body = fix_private_photos($item['body'],$owner['uid']);
@@ -257,7 +287,7 @@ function notifier_run($argv, $argc){
));
}
elseif($cmd === 'suggest') {
- $notify_hub = false; // suggestions are not public
+ $public_message = false; // suggestions are not public
$sugg_template = get_markup_template('atom_suggest.tpl');
@@ -296,7 +326,7 @@ function notifier_run($argv, $argc){
// private emails may be in included in public conversations. Filter them.
- if(($notify_hub) && $item['private'])
+ if(($public_message) && $item['private'])
continue;
$contact = get_item_contact($item,$contacts);
@@ -305,7 +335,7 @@ function notifier_run($argv, $argc){
$atom .= atom_entry($item,'text',$contact,$owner,true);
- if(($top_level) && ($notify_hub) && ($item['author-link'] === $item['owner-link']) && (! $expire))
+ if(($top_level) && ($public_message) && ($item['author-link'] === $item['owner-link']) && (! $expire))
$slaps[] = atom_entry($item,'html',$contact,$owner,true);
}
}
@@ -403,7 +433,7 @@ function notifier_run($argv, $argc){
// only send salmon if public - e.g. if it's ok to notify
// a public hub, it's ok to send a salmon
- if((count($slaps)) && ($notify_hub) && (! $expire)) {
+ if((count($slaps)) && ($public_message) && (! $expire)) {
logger('notifier: slapdelivery: ' . $contact['name']);
foreach($slaps as $slappy) {
if($contact['notify']) {
@@ -505,12 +535,15 @@ function notifier_run($argv, $argc){
require_once('include/diaspora.php');
if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode))
break;
+
+ if(! $contact['pubkey'])
+ break;
if($target_item['verb'] === ACTIVITY_DISLIKE) {
// unsupported
break;
}
- elseif($target_item['deleted'] && (! $parent_item['verb'] === ACTIVITY_LIKE)) {
+ elseif(($target_item['deleted']) && ($target_item['verb'] !== ACTIVITY_LIKE)) {
// diaspora delete,
diaspora_send_retraction($target_item,$owner,$contact);
break;
@@ -544,7 +577,7 @@ function notifier_run($argv, $argc){
// send additional slaps to mentioned remote tags (@foo@example.com)
- if($slap && count($url_recipients) && ($followup || $top_level) && $notify_hub && (! $expire)) {
+ if($slap && count($url_recipients) && ($followup || $top_level) && $public_message && (! $expire)) {
if(! get_config('system','dfrn_only')) {
foreach($url_recipients as $url) {
if($url) {
@@ -556,7 +589,7 @@ function notifier_run($argv, $argc){
}
}
- if((strlen($hub)) && ($notify_hub)) {
+ if((strlen($hub)) && ($public_message)) {
$hubs = explode(',', $hub);
if(count($hubs)) {
foreach($hubs as $h) {
@@ -572,12 +605,12 @@ function notifier_run($argv, $argc){
}
}
- if($notify_hub) {
+ if($public_message) {
/**
*
* If you have less than 999 dfrn friends and it's a public message,
- * we'll just go ahead and push them out securely with dfrn/rino.
+ * we'll just go ahead and push them out securely with dfrn/rino or Diaspora.
* If you've got more than that, you'll have to rely on PuSH delivery.
*
*/
@@ -592,9 +625,10 @@ function notifier_run($argv, $argc){
*/
$r = q("SELECT `id`, `name` FROM `contact`
- WHERE `network` = '%s' AND `uid` = %d AND `blocked` = 0 AND `pending` = 0
+ WHERE `network` in ('%s','%s') AND `uid` = %d AND `blocked` = 0 AND `pending` = 0
AND `rel` != %d ",
dbesc(NETWORK_DFRN),
+ dbesc(NETWORK_DIASPORA),
intval($owner['uid']),
intval(CONTACT_IS_SHARING)
);
@@ -607,19 +641,66 @@ function notifier_run($argv, $argc){
/* Don't deliver to folks who have already been delivered to */
- if(! in_array($rr['id'], $conversants)) {
- $n = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
- intval($rr['id'])
- );
+ if(in_array($rr['id'],$conversants)) {
+ logger('notifier: already delivered id=' . $rr['id']);
+ continue;
+ }
- if(count($n)) {
+ $n = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
+ intval($rr['id'])
+ );
+
+ if(count($n)) {
+ $contact = $n[0];
+ logger('pubdeliver: network: ' . $contact['network']);
+
+ switch($contact['network']) {
+ case NETWORK_DFRN :
+ logger('notifier: dfrnpubdelivery: ' . $contact['name']);
+ $deliver_status = dfrn_deliver($owner,$contact,$atom);
+ break;
+ case NETWORK_DIASPORA :
+ require_once('include/diaspora.php');
+
+ logger('notifier: diaspora pubdelivery: ' . $contact['name']);
+
+ if(get_config('system','dfrn_only') || (! get_config('system','diaspora_enabled')) || (! $normal_mode)) {
+ logger('notifier: diaspora pubdelivery not allowed at this time');
+ break;
+ }
+
+ if(! $contact['pubkey']) {
+ logger('notifier: diaspora pubdelivery: no pubkey');
+ break;
+ }
- logger('notifier: dfrnpubdelivery: ' . $n[0]['name']);
- $deliver_status = dfrn_deliver($owner,$n[0],$atom);
+ if($target_item['verb'] === ACTIVITY_DISLIKE) {
+ // unsupported
+ break;
+ }
+ elseif(($target_item['deleted']) && ($target_item['verb'] !== ACTIVITY_LIKE)) {
+ // diaspora delete,
+ diaspora_send_retraction($target_item,$owner,$contact);
+ break;
+ }
+ elseif($followup) {
+ // send comments, likes and retractions of likes to owner to relay
+ diaspora_send_followup($target_item,$owner,$contact);
+ break;
+ }
+ elseif($target_item['parent'] != $target_item['id']) {
+ // we are the relay - send comments, likes and unlikes to our conversants
+ diaspora_send_relay($target_item,$owner,$contact);
+ break;
+ }
+ elseif($top_level) {
+ diaspora_send_status($target_item,$owner,$contact);
+ break;
+ }
+ default:
+ break;
}
}
- else
- logger('notifier: dfrnpubdelivery: ignoring ' . $rr['name']);
}
}
}
diff --git a/include/poller.php b/include/poller.php
index 651736a9..e80b696b 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -82,12 +82,18 @@ function poller_run($argv, $argc){
if(! $restart)
proc_run('php','include/cronhooks.php');
+ // Only poll from those with suitable relationships,
+ // and which have a polling address and ignore Diaspora since
+ // we are unable to match those posts with a Diaspora GUID and prevent duplicates.
+
$contacts = q("SELECT `id` FROM `contact`
WHERE ( `rel` = %d OR `rel` = %d ) AND `poll` != ''
+ AND `network` != '%s'
$sql_extra
AND `self` = 0 AND `blocked` = 0 AND `readonly` = 0 ORDER BY RAND()",
intval(CONTACT_IS_SHARING),
- intval(CONTACT_IS_FRIEND)
+ intval(CONTACT_IS_FRIEND),
+ dbesc(NETWORK_DIASPORA)
);
if(! count($contacts)) {
diff --git a/include/queue.php b/include/queue.php
index fb65d5c2..f1bcf2e9 100644
--- a/include/queue.php
+++ b/include/queue.php
@@ -29,6 +29,11 @@ function queue_run($argv, $argc){
load_hooks();
+ if($argc > 1)
+ $queue_id = intval($argv[1]);
+ else
+ $queue_id = 0;
+
$deadguys = array();
logger('queue: start');
@@ -44,27 +49,41 @@ function queue_run($argv, $argc){
q("DELETE FROM `queue` WHERE `created` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
}
- $r = q("SELECT `id` FROM `queue` WHERE `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ");
+ if($queue_id)
+ $r = q("SELECT `id` FROM `queue` WHERE `id` = %d LIMIT 1",
+ intval($queue_id)
+ );
+ else
+ $r = q("SELECT `id` FROM `queue` WHERE `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ");
if(! count($r)){
return;
}
- call_hooks('queue_predeliver', $a, $r);
+ if(! $queue_id)
+ call_hooks('queue_predeliver', $a, $r);
// delivery loop
require_once('include/salmon.php');
+ require_once('include/diaspora.php');
foreach($r as $q_item) {
// queue_predeliver hooks may have changed the queue db details,
// so check again if this entry still needs processing
- $qi = q("SELECT * FROM `queue` WHERE `id` = %d AND `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ",
- intval($q_item['id'])
- );
+ if($queue_id) {
+ $qi = q("select * from queue where `id` = %d limit 1",
+ intval($queue_id)
+ );
+ }
+ else {
+ $qi = q("SELECT * FROM `queue` WHERE `id` = %d AND `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE ",
+ intval($q_item['id'])
+ );
+ }
if(! count($qi))
continue;
@@ -82,7 +101,8 @@ function queue_run($argv, $argc){
continue;
}
- $u = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
+ $u = q("SELECT `user`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`
+ FROM `user` WHERE `uid` = %d LIMIT 1",
intval($c[0]['uid'])
);
if(! count($u)) {
@@ -120,6 +140,18 @@ function queue_run($argv, $argc){
remove_queue_item($q_item['id']);
}
break;
+ case NETWORK_DIASPORA:
+ if($contact['notify']) {
+ logger('queue: diaspora_delivery: item ' . $q_item['id'] . ' for ' . $contact['name']);
+ $deliver_status = diaspora_transmit($owner,$contact,$data);
+
+ if($deliver_status == (-1))
+ update_queue_time($q_item['id']);
+ else
+ remove_queue_item($q_item['id']);
+ }
+ break;
+
default:
$params = array('owner' => $owner, 'contact' => $contact, 'queue' => $q_item, 'result' => false);
call_hooks('queue_deliver', $a, $params);
diff --git a/include/salmon.php b/include/salmon.php
index 4043b4f1..9153f899 100644
--- a/include/salmon.php
+++ b/include/salmon.php
@@ -73,6 +73,13 @@ function slapper($owner,$url,$slap) {
if(! strlen($url))
return;
+
+ if(! $owner['sprvkey']) {
+ logger(sprintf("slapper: user '%s' (%d) does not have a salmon private key. Send failed.",
+ $owner['username'],$owner['uid']));
+ return;
+ }
+
// add all namespaces to item
$namespaces = <<< EOT
@@ -102,11 +109,11 @@ EOT;
$precomputed = '.YXBwbGljYXRpb24vYXRvbSt4bWw=.YmFzZTY0dXJs.UlNBLVNIQTI1Ng==';
- $signature = base64url_encode(rsa_sign(str_replace('=','',$data . $precomputed),true),$owner['sprvkey']);
+ $signature = base64url_encode(rsa_sign(str_replace('=','',$data . $precomputed),$owner['sprvkey']));
- $signature2 = base64url_encode(rsa_sign($data . $precomputed),$owner['sprvkey']);
+ $signature2 = base64url_encode(rsa_sign($data . $precomputed,$owner['sprvkey']));
- $signature3 = base64url_encode(rsa_sign($data),$owner['sprvkey']);
+ $signature3 = base64url_encode(rsa_sign($data,$owner['sprvkey']));
$salmon_tpl = get_markup_template('magicsig.tpl');
diff --git a/mod/admin.php b/mod/admin.php
index 1a926443..7799e64a 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 e4be93cd..3b2b16ac 100644
--- a/mod/contacts.php
+++ b/mod/contacts.php
@@ -163,9 +163,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 +178,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 +193,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 +215,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');
@@ -290,6 +292,9 @@ function contacts_content(&$a) {
$lblsuggest = (($r[0]['network'] === NETWORK_DFRN)
? '' : '');
+ $poll_enabled = (($r[0]['network'] !== NETWORK_DIASPORA) ? true : false);
+
+ $nettype = '' . sprintf( t('Network type: %s'),network_to_name($r[0]['network'])) . '
';
$o .= replace_macros($tpl,array(
'$header' => t('Contact Editor'),
@@ -310,7 +315,9 @@ function contacts_content(&$a) {
'$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,
@@ -420,11 +427,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/openid.php b/mod/openid.php
index 6fbd013b..3c329314 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 d6e3d378..4dff5d53 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 c3738c14..34128518 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
diff --git a/update.php b/update.php
index adfb5fe0..ef036008 100644
--- a/update.php
+++ b/update.php
@@ -1,6 +1,6 @@
true
-
+
{{ endfor }}
diff --git a/view/contact_edit.tpl b/view/contact_edit.tpl
index 66479210..0ee88d37 100644
--- a/view/contact_edit.tpl
+++ b/view/contact_edit.tpl
@@ -3,6 +3,8 @@
$name
+$nettype
+