diff options
author | friendica <info@friendica.com> | 2012-08-08 18:50:04 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-08-08 18:50:04 -0700 |
commit | 9a39d4ade21af15e9d6a3aae1f467f0d173cc0de (patch) | |
tree | 569a3839709bf452b44515dc8c6d3f887f78b9dc | |
parent | c28da5673731acbedecb4209c38b72046db597e1 (diff) | |
download | volse-hubzilla-9a39d4ade21af15e9d6a3aae1f467f0d173cc0de.tar.gz volse-hubzilla-9a39d4ade21af15e9d6a3aae1f467f0d173cc0de.tar.bz2 volse-hubzilla-9a39d4ade21af15e9d6a3aae1f467f0d173cc0de.zip |
moving forward again
-rw-r--r-- | include/account.php | 23 | ||||
-rw-r--r-- | include/identity.php | 8 | ||||
-rw-r--r-- | include/network.php | 7 | ||||
-rw-r--r-- | include/zot.php | 7 | ||||
-rw-r--r-- | mod/post.php | 44 | ||||
-rw-r--r-- | mod/zentity.php | 8 | ||||
-rw-r--r-- | mod/zregister.php | 4 |
7 files changed, 32 insertions, 69 deletions
diff --git a/include/account.php b/include/account.php index 6e096b8bf..10ef6c525 100644 --- a/include/account.php +++ b/include/account.php @@ -9,7 +9,7 @@ require_once('include/datetime.php'); function create_account($arr) { - // Required: { email, password, password2, tos } + // Required: { email, password } $a = get_app(); $result = array('success' => false, 'user' => null, 'password' => '', 'message' => ''); @@ -60,26 +60,11 @@ function create_account($arr) { $result['password'] = $new_password; - require_once('include/crypto.php'); - - $keys = new_keypair(4096); - - if($keys === false) { - $result['message'] .= t('SERIOUS ERROR: Generation of security keys failed.') . EOL; - return $result; - } - - $default_service_class = get_config('system','default_service_class'); - if(! $default_service_class) - $default_service_class = ''; - - - $prvkey = $keys['prvkey']; - $pubkey = $keys['pubkey']; $r = q("INSERT INTO account - ( account_parent, account_password, account_email, account_language, - account_created, account_flags, account_roles, account_expires, account_service_class ) + ( account_parent, account_password, account_email, account_language, + account_created, account_flags, account_roles, account_expires, + account_service_class ) VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', '%s' )", intval($parent), dbesc($password_encoded), diff --git a/include/identity.php b/include/identity.php index 7067bc667..5164b5eae 100644 --- a/include/identity.php +++ b/include/identity.php @@ -4,10 +4,10 @@ class simple_identity { - private identity_uid; - private identity_name; - private identity_url; - private identity_photo; + private $identity_uid; + private $identity_name; + private $identity_url; + private $identity_photo; function __construct($uid = '',$name = '',$url = '',$photo = '') { $this->identity_uid = $uid; diff --git a/include/network.php b/include/network.php index 0e16f3c2d..8617c1f44 100644 --- a/include/network.php +++ b/include/network.php @@ -275,6 +275,13 @@ function z_post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0 +function json_return_and_die($x) { + header("content-type: application/json"); + echo json_encode($x); + killme(); +} + + // Generic XML return // Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable diff --git a/include/zot.php b/include/zot.php index 6fe202aa8..f978971ea 100644 --- a/include/zot.php +++ b/include/zot.php @@ -52,15 +52,16 @@ function zot_sign(&$item,$identity) { // Given an item and an identity, verify the signature. function zot_verify(&$item,$identity) { - return rsa_verify($item[signed'],base64url_decode($item['signature']),$identity['pubkey']); + return rsa_verify($item['signed'],base64url_decode($item['signature']),$identity['pubkey']); } function zot_notify($entity,$url) { $x = z_post_url($url, array( - 'zot_uid' => $entity['entity_global_id'], - 'callback' => z_root() . '/zot', + 'type' => 'notify', + 'guid' => $entity['entity_global_id'], + 'callback' => z_root() . '/post', 'spec' => ZOT_REVISION) ); return($x); diff --git a/mod/post.php b/mod/post.php index 4a7e33b23..c5430d46e 100644 --- a/mod/post.php +++ b/mod/post.php @@ -5,47 +5,23 @@ */ -require_once('include/salmon.php'); -require_once('include/crypto.php'); -// not yet ready for prime time -//require_once('include/zot.php'); +require_once('include/zot.php'); function post_post(&$a) { - $bulk_delivery = false; + $ret = array('result' => false, 'message' => ''); - if($a->argc == 1) { - $bulk_delivery = true; - } - else { - $nickname = $a->argv[2]; - $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' - AND `account_expired` = 0 LIMIT 1", - dbesc($nickname) - ); - if(! count($r)) - http_status_exit(500); - - $importer = $r[0]; - } - - $xml = file_get_contents('php://input'); - - logger('mod-post: new zot: ' . $xml, LOGGER_DATA); + $msgtype = ((x($_REQUEST,'type')) ? $_REQUEST['type'] : ''); - if(! $xml) - http_status_exit(500); + if($msgtype === 'notify') { - $msg = zot_decode($importer,$xml); + // add to receive queue + // qreceive_add($_REQUEST); - logger('mod-post: decoded msg: ' . print_r($msg,true), LOGGER_DATA); - - if(! is_array($msg)) - http_status_exit(500); + $ret['result'] = true; + json_return_and_die($ret); + } - $ret = 0; - $ret = zot_incoming($bulk_delivery, $importer,$msg); - http_status_exit(($ret) ? $ret : 200); - // NOTREACHED } + diff --git a/mod/zentity.php b/mod/zentity.php index 4963d7190..011ae8e79 100644 --- a/mod/zentity.php +++ b/mod/zentity.php @@ -29,9 +29,7 @@ function zentity_init(&$a) { // fullname plus random number $test[] = legal_webbie($x) . mt_rand(1000,9999); - header('content-type: application/json'); - echo json_encode(check_webbie($test)); - killme(); + json_return_and_die(check_webbie($test)); } if($cmd === 'checkaddr.json') { @@ -54,9 +52,7 @@ function zentity_init(&$a) { //print_r($test); - header('content-type: application/json'); - echo json_encode(check_webbie($test)); - killme(); + json_return_and_die(check_webbie($test)); } diff --git a/mod/zregister.php b/mod/zregister.php index 7a8d67e78..87a5cff0c 100644 --- a/mod/zregister.php +++ b/mod/zregister.php @@ -18,9 +18,7 @@ function zregister_init(&$a) { if($result['message']) $result['error'] = true; - header('content-type: application/json'); - echo json_encode($result); - killme(); + json_return_and_die($result); } $pw1 = t("Password too short"); |