moving forward again
This commit is contained in:
parent
c28da56737
commit
9a39d4ade2
@ -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),
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
46
mod/post.php
46
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);
|
||||
$msgtype = ((x($_REQUEST,'type')) ? $_REQUEST['type'] : '');
|
||||
|
||||
$importer = $r[0];
|
||||
if($msgtype === 'notify') {
|
||||
|
||||
// add to receive queue
|
||||
// qreceive_add($_REQUEST);
|
||||
|
||||
$ret['result'] = true;
|
||||
json_return_and_die($ret);
|
||||
}
|
||||
|
||||
$xml = file_get_contents('php://input');
|
||||
|
||||
logger('mod-post: new zot: ' . $xml, LOGGER_DATA);
|
||||
|
||||
if(! $xml)
|
||||
http_status_exit(500);
|
||||
|
||||
$msg = zot_decode($importer,$xml);
|
||||
|
||||
logger('mod-post: decoded msg: ' . print_r($msg,true), LOGGER_DATA);
|
||||
|
||||
if(! is_array($msg))
|
||||
http_status_exit(500);
|
||||
|
||||
$ret = 0;
|
||||
$ret = zot_incoming($bulk_delivery, $importer,$msg);
|
||||
http_status_exit(($ret) ? $ret : 200);
|
||||
// NOTREACHED
|
||||
}
|
||||
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
||||
|
@ -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");
|
||||
|
Reference in New Issue
Block a user