aboutsummaryrefslogtreecommitdiffstats
path: root/include/identity.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-08-24 01:14:42 -0700
committerfriendica <info@friendica.com>2012-08-24 01:14:42 -0700
commitb08d070e1531f5a824687a2d36accb288d2ee54a (patch)
tree72dd9a05983b2a2e8e55b79703ff508b7600b754 /include/identity.php
parent2456174cc905d2d0ae19d21c94fec2c5552322a8 (diff)
downloadvolse-hubzilla-b08d070e1531f5a824687a2d36accb288d2ee54a.tar.gz
volse-hubzilla-b08d070e1531f5a824687a2d36accb288d2ee54a.tar.bz2
volse-hubzilla-b08d070e1531f5a824687a2d36accb288d2ee54a.zip
basic identity creation
Diffstat (limited to 'include/identity.php')
-rw-r--r--include/identity.php41
1 files changed, 41 insertions, 0 deletions
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 @@
<?php
+require_once('include/zot.php');
+require_once('include/crypto.php');
function create_identity($arr) {
+ $ret = array('success' => 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;
}