aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rwxr-xr-xinclude/config.php1
-rwxr-xr-xinclude/delivery.php8
-rwxr-xr-xinclude/diaspora.php17
-rwxr-xr-xinclude/network.php45
-rwxr-xr-xinclude/notifier.php11
5 files changed, 82 insertions, 0 deletions
diff --git a/include/config.php b/include/config.php
index 2cddda0b8..4cff38090 100755
--- a/include/config.php
+++ b/include/config.php
@@ -80,6 +80,7 @@ function set_config($family,$key,$value) {
// manage array value
$dbvalue = (is_array($value)?serialize($value):$value);
+ $dbvalue = (is_bool($value) ? intval($value) : $value);
if(get_config($family,$key,true) === false) {
$a->config[$family][$key] = $value;
diff --git a/include/delivery.php b/include/delivery.php
index 532dcd699..794b8f27a 100755
--- a/include/delivery.php
+++ b/include/delivery.php
@@ -321,6 +321,14 @@ function delivery_run($argv, $argc){
$x[0]['writable'] = 1;
}
+ $ssl_policy = get_config('system','ssl_policy');
+ fix_contact_ssl_policy($x[0],$ssl_policy);
+
+ // If we are setup as a soapbox we aren't accepting input from this person
+
+ if($x[0]['page-flags'] == PAGE_SOAPBOX)
+ break;
+
require_once('library/simplepie/simplepie.inc');
logger('mod-delivery: local delivery');
local_delivery($x[0],$atom);
diff --git a/include/diaspora.php b/include/diaspora.php
index 04238f17c..06df9c24a 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -9,6 +9,12 @@ require_once('include/queue_fn.php');
function diaspora_dispatch_public($msg) {
+ $enabled = intval(get_config('system','diaspora_enabled'));
+ if(! $enabled) {
+ logger('mod-diaspora: disabled');
+ return;
+ }
+
$r = q("SELECT `user`.* FROM `user` WHERE `user`.`uid` IN ( SELECT `contact`.`uid` FROM `contact` WHERE `contact`.`network` = '%s' AND `contact`.`addr` = '%s' ) AND `account_expired` = 0 ",
dbesc(NETWORK_DIASPORA),
dbesc($msg['author'])
@@ -29,6 +35,12 @@ function diaspora_dispatch($importer,$msg) {
$ret = 0;
+ $enabled = intval(get_config('system','diaspora_enabled'));
+ if(! $enabled) {
+ logger('mod-diaspora: disabled');
+ return;
+ }
+
// php doesn't like dashes in variable names
$msg['message'] = str_replace(
@@ -2271,6 +2283,11 @@ function diaspora_send_mail($item,$owner,$contact) {
function diaspora_transmit($owner,$contact,$slap,$public_batch) {
+ $enabled = intval(get_config('system','diaspora_enabled'));
+ if(! $enabled) {
+ return 200;
+ }
+
$a = get_app();
$logid = random_string(4);
$dest_url = (($public_batch) ? $contact['batch'] : $contact['notify']);
diff --git a/include/network.php b/include/network.php
index 9e1ed2091..38d0980d5 100755
--- a/include/network.php
+++ b/include/network.php
@@ -824,3 +824,48 @@ function scale_external_images($s,$include_link = true) {
}
return $s;
}
+
+
+function fix_contact_ssl_policy(&$contact,$new_policy) {
+
+ $ssl_changed = false;
+ if((intval($new_policy) == SSL_POLICY_SELFSIGN || $new_policy === 'self') && strstr($contact['url'],'https:')) {
+ $ssl_changed = true;
+ $contact['url'] = str_replace('https:','http:',$contact['url']);
+ $contact['request'] = str_replace('https:','http:',$contact['request']);
+ $contact['notify'] = str_replace('https:','http:',$contact['notify']);
+ $contact['poll'] = str_replace('https:','http:',$contact['poll']);
+ $contact['confirm'] = str_replace('https:','http:',$contact['confirm']);
+ $contact['poco'] = str_replace('https:','http:',$contact['poco']);
+ }
+
+ if((intval($new_policy) == SSL_POLICY_FULL || $new_policy === 'full') && strstr($contact['url'],'http:')) {
+ $ssl_changed = true;
+ $contact['url'] = str_replace('http:','https:',$contact['url']);
+ $contact['request'] = str_replace('http:','https:',$contact['request']);
+ $contact['notify'] = str_replace('http:','https:',$contact['notify']);
+ $contact['poll'] = str_replace('http:','https:',$contact['poll']);
+ $contact['confirm'] = str_replace('http:','https:',$contact['confirm']);
+ $contact['poco'] = str_replace('http:','https:',$contact['poco']);
+ }
+
+ if($ssl_changed) {
+ q("update contact set
+ url = '%s',
+ request = '%s',
+ notify = '%s',
+ poll = '%s',
+ confirm = '%s',
+ poco = '%s'
+ where id = %d limit 1",
+ dbesc($contact['url']),
+ dbesc($contact['request']),
+ dbesc($contact['notify']),
+ dbesc($contact['poll']),
+ dbesc($contact['confirm']),
+ dbesc($contact['poco']),
+ intval($contact['id'])
+ );
+ }
+}
+
diff --git a/include/notifier.php b/include/notifier.php
index d63ad7ae7..ca7c7b92e 100755
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -537,6 +537,17 @@ function notifier_run($argv, $argc){
$x[0]['writable'] = 1;
}
+ // if contact's ssl policy changed, which we just determined
+ // is on our own server, update our contact links
+
+ $ssl_policy = get_config('system','ssl_policy');
+ fix_contact_ssl_policy($x[0],$ssl_policy);
+
+ // If we are setup as a soapbox we aren't accepting input from this person
+
+ if($x[0]['page-flags'] == PAGE_SOAPBOX)
+ break;
+
require_once('library/simplepie/simplepie.inc');
logger('mod-delivery: local delivery');
local_delivery($x[0],$atom);