diff options
author | friendica <info@friendica.com> | 2013-02-07 20:06:01 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2013-02-07 20:06:01 -0800 |
commit | 71cfa661934510beefe48eac74f1b50603086595 (patch) | |
tree | d9da845cb7df2c6abee56a3356dcb0fda4d8f2ae | |
parent | 5c21798ed3c68d6dded1c75166ee0e9bb4ac5d14 (diff) | |
download | volse-hubzilla-71cfa661934510beefe48eac74f1b50603086595.tar.gz volse-hubzilla-71cfa661934510beefe48eac74f1b50603086595.tar.bz2 volse-hubzilla-71cfa661934510beefe48eac74f1b50603086595.zip |
I think we're finally done with import_xchan_from_json - everything has been converted to import_xchan now
-rw-r--r-- | include/zot.php | 120 |
1 files changed, 0 insertions, 120 deletions
diff --git a/include/zot.php b/include/zot.php index 31974a8c6..39983f712 100644 --- a/include/zot.php +++ b/include/zot.php @@ -398,131 +398,11 @@ function zot_register_hub($arr) { } -// Takes a json array from zot_finger and imports the xchan and hublocs -// If the xchan already exists, update the name and photo if these have changed. -// - - -function import_xchan_from_json($j) { - - $ret = array('success' => false); - - $xchan_hash = base64url_encode(hash('whirlpool',$j->guid . $j->guid_sig, true)); - $import_photos = false; - - if(! rsa_verify($j->guid,base64url_decode($j->guid_sig),$j->key)) { - logger('import_xchan_from_json: Unable to verify channel signature for ' . $j->address); - $ret['message'] = t('Unable to verify channel signature'); - return $ret; - } - - $r = q("select * from xchan where xchan_hash = '%s' limit 1", - dbesc($xchan_hash) - ); - - if($r) { - if($r[0]['xchan_photo_date'] != $j->photo_updated) - $update_photos = true; - if(($r[0]['xchan_name_date'] != $j->name_updated) || ($r[0]['xchan_connurl'] != $j->connections_url)) { - $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s' where xchan_hash = '%s' limit 1", - dbesc($j->name), - dbesc($j->name_updated), - dbesc($j->connections_url), - dbesc($xchan_hash) - ); - } - } - else { - $import_photos = true; - $x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype, - xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date) - values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s') ", - dbesc($xchan_hash), - dbesc($j->guid), - dbesc($j->guid_sig), - dbesc($j->key), - dbesc($j->photo_mimetype), - dbesc($j->photo), - dbesc($j->address), - dbesc($j->url), - dbesc($j->connections_url), - dbesc($j->name), - dbesc('zot'), - dbesc($j->photo_updated), - dbesc($j->name_updated) - ); - - } - - - if($import_photos) { - - require_once("Photo.php"); - - $photos = import_profile_photo($j->photo,$xchan_hash); - $r = q("update xchan set xchan_photo_date = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s' - where xchan_hash = '%s' limit 1", - dbesc($j->photo_updated), - dbesc($photos[0]), - dbesc($photos[1]), - dbesc($photos[2]), - dbesc($photos[3]), - dbesc($xchan_hash) - ); - } - - if($j->locations) { - foreach($j->locations as $location) { - if(! rsa_verify($location->url,base64url_decode($location->url_sig),$j->key)) { - logger('import_xchan_from_json: Unable to verify site signature for ' . $location->url); - $ret['message'] .= sprintf( t('Unable to verify site signature for %s'), $location->url) . EOL; - continue; - } - - $r = q("select * from hubloc where hubloc_hash = '%s' and hubloc_url = '%s' limit 1", - dbesc($xchan_hash), - dbesc($location->url) - ); - if($r) { - if(($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location->primary)) { - $r = q("update hubloc set hubloc_flags = (hubloc_flags ^ %d) where hubloc_id = %d limit 1", - intval(HUBLOC_FLAGS_PRIMARY), - intval($r[0]['hubloc_id']) - ); - } - continue; - } - - $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_flags, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey) - values ( '%s','%s','%s','%s', %d ,'%s','%s','%s','%s','%s')", - dbesc($j->guid), - dbesc($j->guid_sig), - dbesc($xchan_hash), - dbesc($location->address), - intval((intval($location->primary)) ? HUBLOC_FLAGS_PRIMARY : 0), - dbesc($location->url), - dbesc($location->url_sig), - dbesc($location->host), - dbesc($location->callback), - dbesc($location->sitekey) - ); - - } - - } - - if(! x($ret,'message')) { - $ret['success'] = true; - $ret['hash'] = $xchan_hash; - } - return $ret; -} // Takes a json associative array from zot_finger and imports the xchan and hublocs // If the xchan already exists, update the name and photo if these have changed. // - function import_xchan($arr) { $ret = array('success' => false); |