aboutsummaryrefslogtreecommitdiffstats
path: root/include/network.php
diff options
context:
space:
mode:
authorzottel <github@zottel.net>2012-04-03 09:27:46 +0200
committerzottel <github@zottel.net>2012-04-03 09:27:46 +0200
commite5cd5aab5cf5fd5019ec3178f09f5515c390c9d9 (patch)
tree76e322f19d3ada0106a2c7c9664537e602ed88ed /include/network.php
parent7127626f55f0ae5843d38145bf80022b98e4a8d8 (diff)
parent5d0d9f877294258cb90e1c496b4db750ee99f3ca (diff)
downloadvolse-hubzilla-e5cd5aab5cf5fd5019ec3178f09f5515c390c9d9.tar.gz
volse-hubzilla-e5cd5aab5cf5fd5019ec3178f09f5515c390c9d9.tar.bz2
volse-hubzilla-e5cd5aab5cf5fd5019ec3178f09f5515c390c9d9.zip
Merge remote branch 'upstream/master'
Diffstat (limited to 'include/network.php')
-rwxr-xr-xinclude/network.php45
1 files changed, 45 insertions, 0 deletions
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'])
+ );
+ }
+}
+