]> git.mxchange.org Git - friendica.git/blobdiff - mod/register.php
Merge pull request #5830 from nupplaphil/update_from_boot
[friendica.git] / mod / register.php
index 79e9455cd592939abf08f2a0940b357470bf09d7..73b57124a21613219d5f4363f05991a3eb789f81 100644 (file)
@@ -4,10 +4,12 @@
  */
 
 use Friendica\App;
+use Friendica\BaseModule;
 use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
 use Friendica\Core\L10n;
+use Friendica\Core\Logger;
 use Friendica\Core\PConfig;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
@@ -18,7 +20,7 @@ require_once 'include/enotify.php';
 
 function register_post(App $a)
 {
-       check_form_security_token_redirectOnErr('/register', 'register');
+       BaseModule::checkFormSecurityTokenRedirectOnError('/register', 'register');
 
        $verified = 0;
        $blocked  = 1;
@@ -62,7 +64,7 @@ function register_post(App $a)
 
        $arr['blocked'] = $blocked;
        $arr['verified'] = $verified;
-       $arr['language'] = L10n::getBrowserLanguage();
+       $arr['language'] = L10n::detectLanguage();
 
        try {
                $result = Model\User::create($arr);
@@ -91,17 +93,15 @@ function register_post(App $a)
                // Only send a password mail when the password wasn't manually provided
                if (!x($_POST, 'password1') || !x($_POST, 'confirm')) {
                        $res = Model\User::sendRegisterOpenEmail(
-                               $user['email'],
+                               $user,
                                Config::get('config', 'sitename'),
                                $a->getBaseUrl(),
-                               $user['username'],
-                               $result['password'],
-                               $user
+                               $result['password']
                        );
 
                        if ($res) {
                                info(L10n::t('Registration successful. Please check your email for further instructions.') . EOL);
-                               goaway();
+                               $a->internalRedirect();
                        } else {
                                notice(
                                        L10n::t('Failed to send email message. Here your accout details:<br> login: %s<br> password: %s<br><br>You can change your password after login.',
@@ -112,12 +112,12 @@ function register_post(App $a)
                        }
                } else {
                        info(L10n::t('Registration successful.') . EOL);
-                       goaway();
+                       $a->internalRedirect();
                }
        } elseif (intval(Config::get('config', 'register_policy')) === REGISTER_APPROVE) {
                if (!strlen(Config::get('config', 'admin_email'))) {
                        notice(L10n::t('Your registration can not be processed.') . EOL);
-                       goaway();
+                       $a->internalRedirect();
                }
 
                Model\Register::createForApproval($user['uid'], Config::get('system', 'language'), $_POST['permonlybox']);
@@ -153,17 +153,14 @@ function register_post(App $a)
                }
                // send notification to the user, that the registration is pending
                Model\User::sendRegisterPendingEmail(
-                       $user['uid'],
-                       $user['email'],
+                       $user,
                        Config::get('config', 'sitename'),
-                       $user['username'],
                        $a->getBaseURL(),
-                       $user['nickname'],
                        $result['password']
                );
 
                info(L10n::t('Your registration is pending approval by the site owner.') . EOL);
-               goaway();
+               $a->internalRedirect();
        }
 
        return;
@@ -190,7 +187,7 @@ function register_content(App $a)
        if ($max_dailies) {
                $r = q("select count(*) as total from user where register_date > UTC_TIMESTAMP - INTERVAL 1 day");
                if ($r && $r[0]['total'] >= $max_dailies) {
-                       logger('max daily registrations exceeded.');
+                       Logger::log('max daily registrations exceeded.');
                        notice(L10n::t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.') . EOL);
                        return;
                }
@@ -294,7 +291,7 @@ function register_content(App $a)
                '$showprivstatement' => Config::get('system', 'tosprivstatement'),
                '$privstatement' => $tos->privacy_complete,
                '$baseurl'   => System::baseurl(),
-               '$form_security_token' => get_form_security_token("register"),
+               '$form_security_token' => BaseModule::getFormSecurityToken("register"),
                '$explicit_content' => Config::get('system', 'explicit_content', false),
                '$explicit_content_note' => L10n::t('Note: This node explicitly contains adult content')
        ]);