From e6fd6bfd89ada9b5aeea8fcac1614546deba85aa Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 31 Mar 2012 17:44:34 -0700 Subject: more error handling --- include/network.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/network.php') diff --git a/include/network.php b/include/network.php index 22157ff18..9e1ed2091 100755 --- a/include/network.php +++ b/include/network.php @@ -364,6 +364,9 @@ function lrdd($uri, $debug = false) { logger('lrdd: host_meta: ' . $xml, LOGGER_DATA); + if(! stristr($xml,' Date: Mon, 2 Apr 2012 23:07:26 -0700 Subject: make contact ssl_policy change a function since it is used in a few places --- include/network.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'include/network.php') 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']) + ); + } +} + -- cgit v1.2.3