]> git.mxchange.org Git - friendica.git/blobdiff - include/user.php
Parameter should fit ...
[friendica.git] / include / user.php
index ae05b9e112f633c36d2eb70b172895938a8a71f5..a05bd831a8e7d81aa19344d3853846acc363ee36 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Friendica\Core\System;
+
 require_once('include/config.php');
 require_once('include/network.php');
 require_once('include/plugin.php');
@@ -66,7 +68,7 @@ function create_user($arr) {
                        require_once('library/openid.php');
                        $openid = new LightOpenID;
                        $openid->identity = $openid_url;
-                       $openid->returnUrl = z_root() . '/openid';
+                       $openid->returnUrl = System::baseUrl() . '/openid';
                        $openid->required = array('namePerson/friendly', 'contact/email', 'namePerson');
                        $openid->optional = array('namePerson/first','media/image/aspect11','media/image/default');
                        try {
@@ -97,13 +99,6 @@ function create_user($arr) {
        if(mb_strlen($username) < 3)
                $result['message'] .= t('Name too short.') . EOL;
 
-       // I don't really like having this rule, but it cuts down
-       // on the number of auto-registrations by Russian spammers
-
-       //  Using preg_match was completely unreliable, due to mixed UTF-8 regex support
-       //      $no_utf = get_config('system','no_utf');
-       //      $pat = (($no_utf) ? '/^[a-zA-Z]* [a-zA-Z]*$/' : '/^\p{L}* \p{L}*$/u' );
-
        // So now we are just looking for a space in the full name.
 
        $loose_reg = get_config('system','no_regfullname');
@@ -182,17 +177,7 @@ function create_user($arr) {
        $prvkey = $keys['prvkey'];
        $pubkey = $keys['pubkey'];
 
-       /**
-        *
-        * Create another keypair for signing/verifying
-        * salmon protocol messages. We have to use a slightly
-        * less robust key because this won't be using openssl
-        * but the phpseclib. Since it is PHP interpreted code
-        * it is not nearly as efficient, and the larger keys
-        * will take several minutes each to process.
-        *
-        */
-
+       // Create another keypair for signing/verifying salmon protocol messages.
        $sres    = new_keypair(512);
        $sprvkey = $sres['prvkey'];
        $spubkey = $sres['pubkey'];
@@ -216,7 +201,7 @@ function create_user($arr) {
                dbesc($default_service_class)
        );
 
-       if($r) {
+       if ($r) {
                $r = q("SELECT * FROM `user`
                        WHERE `username` = '%s' AND `password` = '%s' LIMIT 1",
                        dbesc($username),
@@ -243,9 +228,7 @@ function create_user($arr) {
        );
        if ((dbm::is_result($r)) && (count($r) > 1) && $newuid) {
                $result['message'] .= t('Nickname is already registered. Please choose another.') . EOL;
-               q("DELETE FROM `user` WHERE `uid` = %d",
-                       intval($newuid)
-               );
+               dba::delete('user', array('uid' => $newuid));
                return $result;
        }
 
@@ -256,17 +239,16 @@ function create_user($arr) {
                        t('default'),
                        1,
                        dbesc($username),
-                       dbesc(z_root() . "/photo/profile/{$newuid}.jpg"),
-                       dbesc(z_root() . "/photo/avatar/{$newuid}.jpg"),
+                       dbesc(System::baseUrl() . "/photo/profile/{$newuid}.jpg"),
+                       dbesc(System::baseUrl() . "/photo/avatar/{$newuid}.jpg"),
                        intval($publish),
                        intval($netpublish)
 
                );
-               if($r === false) {
+               if ($r === false) {
                        $result['message'] .=  t('An error occurred creating your default profile. Please try again.') . EOL;
                        // Start fresh next time.
-                       $r = q("DELETE FROM `user` WHERE `uid` = %d",
-                               intval($newuid));
+                       dba::delete('user', array('uid' => $newuid));
                        return $result;
                }
 
@@ -325,24 +307,27 @@ function create_user($arr) {
 
                        $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 4 );
 
-                       if($r === false)
+                       if ($r === false) {
                                $photo_failure = true;
+                       }
 
                        $img->scaleImage(80);
 
                        $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 5 );
 
-                       if($r === false)
+                       if ($r === false) {
                                $photo_failure = true;
+                       }
 
                        $img->scaleImage(48);
 
                        $r = $img->store($newuid, 0, $hash, $filename, t('Profile Photos'), 6 );
 
-                       if($r === false)
+                       if ($r === false) {
                                $photo_failure = true;
+                       }
 
-                       if(! $photo_failure) {
+                       if (! $photo_failure) {
                                q("UPDATE `photo` SET `profile` = 1 WHERE `resource-id` = '%s' ",
                                        dbesc($hash)
                                );
@@ -385,17 +370,17 @@ function user_create_self_contact($uid) {
                datetime_convert(),
                dbesc($user['username']),
                dbesc($user['nickname']),
-               dbesc(z_root()."/photo/profile/".$user['uid'].".jpg"),
-               dbesc(z_root()."/photo/avatar/".$user['uid'].".jpg"),
-               dbesc(z_root()."/photo/micro/".$user['uid'].".jpg"),
-               dbesc(z_root()."/profile/".$user['nickname']),
-               dbesc(normalise_link(z_root()."/profile/".$user['nickname'])),
-               dbesc($user['nickname'].'@'.substr(z_root(), strpos(z_root(),'://') + 3)),
-               dbesc(z_root()."/dfrn_request/".$user['nickname']),
-               dbesc(z_root()."/dfrn_notify/".$user['nickname']),
-               dbesc(z_root()."/dfrn_poll/".$user['nickname']),
-               dbesc(z_root()."/dfrn_confirm/".$user['nickname']),
-               dbesc(z_root()."/poco/".$user['nickname']),
+               dbesc(System::baseUrl()."/photo/profile/".$user['uid'].".jpg"),
+               dbesc(System::baseUrl()."/photo/avatar/".$user['uid'].".jpg"),
+               dbesc(System::baseUrl()."/photo/micro/".$user['uid'].".jpg"),
+               dbesc(System::baseUrl()."/profile/".$user['nickname']),
+               dbesc(normalise_link(System::baseUrl()."/profile/".$user['nickname'])),
+               dbesc($user['nickname'].'@'.substr(System::baseUrl(), strpos(System::baseUrl(),'://') + 3)),
+               dbesc(System::baseUrl()."/dfrn_request/".$user['nickname']),
+               dbesc(System::baseUrl()."/dfrn_notify/".$user['nickname']),
+               dbesc(System::baseUrl()."/dfrn_poll/".$user['nickname']),
+               dbesc(System::baseUrl()."/dfrn_confirm/".$user['nickname']),
+               dbesc(System::baseUrl()."/poco/".$user['nickname']),
                dbesc(datetime_convert()),
                dbesc(datetime_convert()),
                dbesc(datetime_convert())
@@ -419,7 +404,7 @@ function send_register_pending_eml($email, $sitename, $username) {
        $body = sprintf($body, $username, $sitename);
 
        return notification(array(
-               'type' => "SYSTEM_EMAIL",
+               'type' => SYSTEM_EMAIL,
                'to_email' => $email,
                'subject'=> sprintf( t('Registration at %s'), $sitename),
                'body' => $body));
@@ -465,7 +450,7 @@ function send_register_open_eml($email, $sitename, $siteurl, $username, $passwor
                $body = sprintf($body, $email, $sitename, $siteurl, $username, $password);
 
                return notification(array(
-                       'type' => "SYSTEM_EMAIL",
+                       'type' => SYSTEM_EMAIL,
                        'to_email' => $email,
                        'subject'=> sprintf( t('Registration details for %s'), $sitename),
                        'preamble'=> $preamble,