From b08d070e1531f5a824687a2d36accb288d2ee54a Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 24 Aug 2012 01:14:42 -0700 Subject: basic identity creation --- include/identity.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'include/identity.php') diff --git a/include/identity.php b/include/identity.php index 8f906228f..e4696940c 100644 --- a/include/identity.php +++ b/include/identity.php @@ -1,10 +1,51 @@ false, 'message' => ''); + $nick = trim($_POST['nickname']); + $name = escape_tags($_POST['name']); + if(check_webbie(array($nick)) !== 'nick') { + $ret['message'] = t('Nickname has unsupported characters or is already being used on this site.'); + return $ret; + } + + $guid = zot_new_uid($nick); + $key = new_keypair(4096); + $primary = true; + + $r = q("insert into entity ( entity_account_id, entity_primary, + entity_name, entity_address, entity_global_id, entity_prvkey, + entity_pubkey, entity_pageflags ) + values( %d, %d, '%s', '%s', '%s' '%s', '%s', %d ) ", + + intval(local_user()), + intval($primary), + dbesc($name), + dbesc($nick), + dbesc($guid), + dbesc($key['prvkey']), + dbesc($key['pubkey']), + intval(PAGE_NORMAL) + ); + + $r = q("select * from entity where entity_account_id = %d + and entity_global_id = '%s' limit 1", + intval(local_user()), + dbesc($guid) + ); + if(! ($r && count($r))) { + $ret['message'] = t('Unable to retrieve created identity'); + return $ret; + } + $ret['entity'] = $r[0]; + $ret['success'] = true; + return $ret; } -- cgit v1.2.3