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) {
|
function create_account($arr) {
|
||||||
|
|
||||||
// Required: { email, password, password2, tos }
|
// Required: { email, password }
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
$result = array('success' => false, 'user' => null, 'password' => '', 'message' => '');
|
$result = array('success' => false, 'user' => null, 'password' => '', 'message' => '');
|
||||||
@ -60,26 +60,11 @@ function create_account($arr) {
|
|||||||
|
|
||||||
$result['password'] = $new_password;
|
$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
|
$r = q("INSERT INTO account
|
||||||
( account_parent, account_password, account_email, account_language,
|
( account_parent, account_password, account_email, account_language,
|
||||||
account_created, account_flags, account_roles, account_expires, account_service_class )
|
account_created, account_flags, account_roles, account_expires,
|
||||||
|
account_service_class )
|
||||||
VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', '%s' )",
|
VALUES ( %d, '%s', '%s', '%s', '%s', %d, %d, '%s', '%s' )",
|
||||||
intval($parent),
|
intval($parent),
|
||||||
dbesc($password_encoded),
|
dbesc($password_encoded),
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
|
|
||||||
class simple_identity {
|
class simple_identity {
|
||||||
|
|
||||||
private identity_uid;
|
private $identity_uid;
|
||||||
private identity_name;
|
private $identity_name;
|
||||||
private identity_url;
|
private $identity_url;
|
||||||
private identity_photo;
|
private $identity_photo;
|
||||||
|
|
||||||
function __construct($uid = '',$name = '',$url = '',$photo = '') {
|
function __construct($uid = '',$name = '',$url = '',$photo = '') {
|
||||||
$this->identity_uid = $uid;
|
$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
|
// Generic XML return
|
||||||
// Outputs a basic dfrn XML status structure to STDOUT, with a <status> variable
|
// 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.
|
// Given an item and an identity, verify the signature.
|
||||||
|
|
||||||
function zot_verify(&$item,$identity) {
|
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) {
|
function zot_notify($entity,$url) {
|
||||||
$x = z_post_url($url, array(
|
$x = z_post_url($url, array(
|
||||||
'zot_uid' => $entity['entity_global_id'],
|
'type' => 'notify',
|
||||||
'callback' => z_root() . '/zot',
|
'guid' => $entity['entity_global_id'],
|
||||||
|
'callback' => z_root() . '/post',
|
||||||
'spec' => ZOT_REVISION)
|
'spec' => ZOT_REVISION)
|
||||||
);
|
);
|
||||||
return($x);
|
return($x);
|
||||||
|
46
mod/post.php
46
mod/post.php
@ -5,47 +5,23 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
require_once('include/salmon.php');
|
require_once('include/zot.php');
|
||||||
require_once('include/crypto.php');
|
|
||||||
// not yet ready for prime time
|
|
||||||
//require_once('include/zot.php');
|
|
||||||
|
|
||||||
function post_post(&$a) {
|
function post_post(&$a) {
|
||||||
|
|
||||||
$bulk_delivery = false;
|
$ret = array('result' => false, 'message' => '');
|
||||||
|
|
||||||
if($a->argc == 1) {
|
$msgtype = ((x($_REQUEST,'type')) ? $_REQUEST['type'] : '');
|
||||||
$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];
|
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
|
// fullname plus random number
|
||||||
$test[] = legal_webbie($x) . mt_rand(1000,9999);
|
$test[] = legal_webbie($x) . mt_rand(1000,9999);
|
||||||
|
|
||||||
header('content-type: application/json');
|
json_return_and_die(check_webbie($test));
|
||||||
echo json_encode(check_webbie($test));
|
|
||||||
killme();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($cmd === 'checkaddr.json') {
|
if($cmd === 'checkaddr.json') {
|
||||||
@ -54,9 +52,7 @@ function zentity_init(&$a) {
|
|||||||
|
|
||||||
//print_r($test);
|
//print_r($test);
|
||||||
|
|
||||||
header('content-type: application/json');
|
json_return_and_die(check_webbie($test));
|
||||||
echo json_encode(check_webbie($test));
|
|
||||||
killme();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,9 +18,7 @@ function zregister_init(&$a) {
|
|||||||
if($result['message'])
|
if($result['message'])
|
||||||
$result['error'] = true;
|
$result['error'] = true;
|
||||||
|
|
||||||
header('content-type: application/json');
|
json_return_and_die($result);
|
||||||
echo json_encode($result);
|
|
||||||
killme();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$pw1 = t("Password too short");
|
$pw1 = t("Password too short");
|
||||||
|
Reference in New Issue
Block a user