]> git.mxchange.org Git - friendica.git/blobdiff - include/user.php
get rid of 'Friendika'
[friendica.git] / include / user.php
index 75a91b096770f80e6c8cb4db63e8539accf6666f..282bbdbba24761acc46d6a9bfeb78b25cf725678 100644 (file)
@@ -24,9 +24,11 @@ function create_user($arr) {
        $email      = ((x($arr,'email'))      ? notags(trim($arr['email']))      : '');
        $openid_url = ((x($arr,'openid_url')) ? notags(trim($arr['openid_url'])) : '');
        $photo      = ((x($arr,'photo'))      ? notags(trim($arr['photo']))      : '');
-       $publish    = ((x($arr,'profile_publish_reg') && intval($arr['profile_publish_reg'])) ? 1 : 0);
        $password   = ((x($arr,'password'))   ? trim($arr['password'])           : '');
+       $blocked    = ((x($arr,'blocked'))    ? intval($arr['blocked'])  : 0);
+       $verified   = ((x($arr,'verified'))   ? intval($arr['verified']) : 0);
 
+       $publish    = ((x($arr,'profile_publish_reg') && intval($arr['profile_publish_reg'])) ? 1 : 0);
        $netpublish = ((strlen(get_config('system','directory_submit_url'))) ? $publish : 0);
                
        $tmp_str = $openid_url;
@@ -97,11 +99,11 @@ function create_user($arr) {
 
 
        if(! allowed_email($email))
-                       $result['message'] .= t('Your email domain is not among those allowed on this site.') . EOL;
+               $result['message'] .= t('Your email domain is not among those allowed on this site.') . EOL;
 
        if((! valid_email($email)) || (! validate_email($email)))
                $result['message'] .= t('Not a valid email address.') . EOL;
-
+               
        // Disallow somebody creating an account using openid that uses the admin email address,
        // since openid bypasses email verification. We'll allow it if there is not yet an admin account.
 
@@ -145,13 +147,18 @@ function create_user($arr) {
 
        require_once('include/crypto.php');
 
-       $keys = new_keypair(1024);
+       $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'];
 
@@ -171,8 +178,8 @@ function create_user($arr) {
        $spubkey = $sres['pubkey'];
 
        $r = q("INSERT INTO `user` ( `guid`, `username`, `password`, `email`, `openid`, `nickname`,
-               `pubkey`, `prvkey`, `spubkey`, `sprvkey`, `register_date`, `verified`, `blocked`, `timezone` )
-               VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 'UTC' )",
+               `pubkey`, `prvkey`, `spubkey`, `sprvkey`, `register_date`, `verified`, `blocked`, `timezone`, `service_class` )
+               VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 'UTC', '%s' )",
                dbesc(generate_user_guid()),
                dbesc($username),
                dbesc($new_password_encoded),
@@ -185,7 +192,8 @@ function create_user($arr) {
                dbesc($sprvkey),
                dbesc(datetime_convert()),
                intval($verified),
-               intval($blocked)
+               intval($blocked),
+               dbesc($default_service_class)
        );
 
        if($r) {
@@ -269,6 +277,26 @@ function create_user($arr) {
                require_once('include/group.php');
                group_add($newuid, t('Friends'));
 
+               $r = q("SELECT id FROM `group` WHERE uid = %d AND name = '%s'",
+                       intval($newuid),
+                       dbesc(t('Friends'))
+               );
+               if($r && count($r)) {
+                       $def_gid = $r[0]['id'];
+
+                       q("UPDATE user SET def_gid = %d WHERE uid = %d",
+                               intval($r[0]['id']),
+                               intval($newuid)
+                       );
+               }
+
+               if(get_config('system', 'newuser_private') && $def_gid) {
+                       q("UPDATE user SET allow_gid = '%s' WHERE uid = %d",
+                          dbesc("<" . $def_gid . ">"),
+                          intval($newuid)
+                       );
+               }
+
        }
 
        // if we have no OpenID photo try to look up an avatar
@@ -282,7 +310,11 @@ function create_user($arr) {
 
                $filename = basename($photo);
                $img_str = fetch_url($photo,true);
-               $img = new Photo($img_str);
+               // guess mimetype from headers or filename
+               $type = guess_image_type($photo,true);
+
+               
+               $img = new Photo($img_str, $type);
                if($img->is_valid()) {
 
                        $img->scaleImageSquare(175);
@@ -322,4 +354,4 @@ function create_user($arr) {
        $result['user'] = $u;
        return $result;
 
-}
\ No newline at end of file
+}