X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fregister.php;h=58bba85333dabce8f077129dc5eee62d21c64b32;hb=24f5e6b3f3f1f29cce8923c38fbdfb24fa5ed5a5;hp=89f561642af36a329c8908372fafafaec72d163c;hpb=95b4bc55bf54c3dffdb714b8a1d8f38cc78355aa;p=friendica.git diff --git a/mod/register.php b/mod/register.php index 89f561642a..58bba85333 100644 --- a/mod/register.php +++ b/mod/register.php @@ -8,6 +8,8 @@ function register_post(&$a) { $verified = 0; $blocked = 1; + $arr = array('post' => $_POST); + call_hooks('register_post', $arr); $max_dailies = intval(get_config('system','max_daily_registrations')); if($max_dailes) { @@ -150,6 +152,16 @@ function register_post(&$a) { if(count($r)) $err .= t('Nickname is already registered. Please choose another.') . EOL; + // Check deleted accounts that had this nickname. Doesn't matter to us, + // but could be a security issue for federated platforms. + + $r = q("SELECT * FROM `userd` + WHERE `username` = '%s' LIMIT 1", + dbesc($nickname) + ); + if(count($r)) + $err .= t('Nickname was once registered here and may not be re-used. Please choose another.') . EOL; + if(strlen($err)) { notice( $err ); return; @@ -159,26 +171,17 @@ function register_post(&$a) { $new_password = autoname(6) . mt_rand(100,9999); $new_password_encoded = hash('whirlpool',$new_password); - $res=openssl_pkey_new(array( - 'digest_alg' => 'sha1', - 'private_key_bits' => 4096, - 'encrypt_key' => false )); + require_once('include/crypto.php'); - // Get private key + $result = new_keypair(1024); - if(empty($res)) { + if($result === false) { notice( t('SERIOUS ERROR: Generation of security keys failed.') . EOL); return; } - $prvkey = ''; - - openssl_pkey_export($res, $prvkey); - - // Get public key - - $pkey = openssl_pkey_get_details($res); - $pubkey = $pkey["key"]; + $prvkey = $result['prvkey']; + $pubkey = $result['pubkey']; /** * @@ -191,25 +194,13 @@ function register_post(&$a) { * */ - $sres=openssl_pkey_new(array( - 'digest_alg' => 'sha1', - 'private_key_bits' => 512, - 'encrypt_key' => false )); - - // Get private key - - $sprvkey = ''; - - openssl_pkey_export($sres, $sprvkey); - - // Get public key - - $spkey = openssl_pkey_get_details($sres); - $spubkey = $spkey["key"]; + $sres = new_keypair(512); + $sprvkey = $sres['prvkey']; + $spubkey = $sres['pubkey']; $r = q("INSERT INTO `user` ( `guid`, `username`, `password`, `email`, `openid`, `nickname`, - `pubkey`, `prvkey`, `spubkey`, `sprvkey`, `register_date`, `verified`, `blocked` ) - VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d )", + `pubkey`, `prvkey`, `spubkey`, `sprvkey`, `register_date`, `verified`, `blocked`, `timezone` ) + VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 'UTC' )", dbesc(generate_user_guid()), dbesc($username), dbesc($new_password_encoded), @@ -278,8 +269,8 @@ function register_post(&$a) { return; } $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `nick`, `photo`, `thumb`, `micro`, `blocked`, `pending`, `url`, `nurl`, - `request`, `notify`, `poll`, `confirm`, `poco`, `name-date`, `uri-date`, `avatar-date` ) - VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' ) ", + `request`, `notify`, `poll`, `confirm`, `poco`, `name-date`, `uri-date`, `avatar-date`, `closeness` ) + VALUES ( %d, '%s', 1, '%s', '%s', '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', 0 ) ", intval($newuid), datetime_convert(), dbesc($username), @@ -302,17 +293,13 @@ function register_post(&$a) { } - $use_gravatar = ((get_config('system','no_gravatar')) ? false : true); - - // if we have an openid photo use it. - // otherwise unless it is disabled, use gravatar - - if($use_gravatar || strlen($photo)) { + // if we have no OpenID photo try to look up an avatar + if(! strlen($photo)) + $photo = avatar_img($email); + // unless there is no avatar-plugin loaded + if(strlen($photo)) { require_once('include/Photo.php'); - - if(($use_gravatar) && (! strlen($photo))) - $photo = gravatar_img($email); $photo_failure = false; $filename = basename($photo); @@ -321,7 +308,7 @@ function register_post(&$a) { if($img->is_valid()) { $img->scaleImageSquare(175); - + $hash = photo_new_resource(); $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 ); @@ -530,6 +517,11 @@ function register_content(&$a) { $license = ''; $o = get_markup_template("register.tpl"); + + $arr = array('template' => $o); + + call_hooks('register_form',$arr); + $o = replace_macros($o, array( '$oidhtml' => $oidhtml, '$invitations' => get_config('system','invitation_only'),