aboutsummaryrefslogtreecommitdiffstats
path: root/boot.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-03-10 18:45:58 -0700
committerfriendica <info@friendica.com>2013-03-10 18:45:58 -0700
commit952b2ef2ab256d46d616db70edc42ffe640a5e9d (patch)
tree1bd9cb83a6beae2beb5ff30b1b26d604e7ccfc06 /boot.php
parent0d504715c1859276e919ddc6b236f946c783714f (diff)
downloadvolse-hubzilla-952b2ef2ab256d46d616db70edc42ffe640a5e9d.tar.gz
volse-hubzilla-952b2ef2ab256d46d616db70edc42ffe640a5e9d.tar.bz2
volse-hubzilla-952b2ef2ab256d46d616db70edc42ffe640a5e9d.zip
.
Diffstat (limited to 'boot.php')
-rw-r--r--boot.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/boot.php b/boot.php
index 7c14f7925..8fad37f06 100644
--- a/boot.php
+++ b/boot.php
@@ -992,6 +992,18 @@ function check_config(&$a) {
if(! x($build))
$build = set_config('system','db_version',DB_UPDATE_VERSION);
+ $saved = get_config('system','urlverify');
+ if(! $saved)
+ set_config('system','urlverify',bin2hex(z_root()));
+ if(($saved) && ($saved != bin2hex(z_root()))) {
+ // our URL changed. Do something.
+ $oldurl = hex2bin($saved);
+ fix_system_urls($oldurl,z_root());
+ set_config('system','urlverify',bin2hex(z_root()));
+
+ }
+
+
// $url = get_config('system','baseurl');
// if the url isn't set or the stored url is radically different
@@ -1130,6 +1142,53 @@ function check_config(&$a) {
+function fix_system_urls($oldurl,$newurl) {
+
+ require_once('include/crypto.php');
+
+ // Basically a site rename, but this can happen if you change from http to https for instance - even if the site name didn't change
+ // This should fix URL changes on our site, but other sites will end up with orphan hublocs which they will try to contact and will
+ // cause wasted communications.
+ // What we need to do after fixing this up is to send a revocation of the old URL to every other site that we communicate with so
+ // that they can clean up their hubloc tables (this includes directories).
+ // It's a very expensive operation so you don't want to have to do it often or after your site gets to be large.
+
+ $r = q("select xchan_hash, channel_prvkey from xchan left join channel on channel_hash = xchan_hash where xchan_url = '%s'",
+ dbesc($oldurl)
+ );
+ if($r) {
+ foreach($r as $rr) {
+ $channel = substr($rr['xchan_addr'],0,strpos($rr['xchan_addr'],'@'));
+ $parsed = @parse_url($rr['xchan_url']);
+ if(! $parsed)
+ continue;
+ $newhost = $parsed['host'];
+ $rhs = $newhost . (($parsed['port']) ? ':' . $parsed['port'] : '') . (($parsed['path']) ? $parsed['path'] : '');
+
+ $x = q("update xchan set xchan_addr = '%s', xchan_url = '%s', xchan_connurl = '%s' where xchan_hash = '%s' limit 1",
+ dbesc($channel . '@' . $rhs),
+ dbesc($newurl),
+ dbesc($newurl . '/poco/' . $channel),
+ dbesc($rr['xchan_hash'])
+ );
+
+
+ $y = q("update hubloc set hubloc_addr = '%s', hubloc_url = '%s', hubloc_url_sig = '%s', hubloc_host = '%s', hubloc_callback = '%s' where hubloc_hash = '%s' and hubloc_url = '%s' limit 1",
+ dbesc($channel . '@' . $rhs),
+ dbesc($newurl),
+ dbesc(base64url_encode(rsa_sign($newurl,$rr['channel_prvkey']))),
+ dbesc($newhost),
+ dbesc($newurl . '/post'),
+ dbesc($rr['xchan_hash']),
+ dbesc($oldurl)
+ );
+ }
+ }
+}
+
+
+
+
// wrapper for adding a login box. If $register == true provide a registration
// link. This will most always depend on the value of $a->config['system']['register_policy'].
// returns the complete html for inserting into the page