]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Register.php
Some removed escapeTags calls
[friendica.git] / src / Module / Register.php
index 8a92b250882e846f7fee46ef2eb2f28d15cf3084..909e61a998688f6e4118140ced1f3ffbd3cdcaa7 100644 (file)
@@ -1,4 +1,23 @@
 <?php
+/**
+ * @copyright Copyright (C) 2010-2021, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
 
 namespace Friendica\Module;
 
@@ -12,6 +31,8 @@ use Friendica\Core\Worker;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model;
+use Friendica\Model\User;
+use Friendica\Util\Proxy;
 use Friendica\Util\Strings;
 
 /**
@@ -61,7 +82,7 @@ class Register extends BaseModule
                if ($max_dailies) {
                        $count = DBA::count('user', ['`register_date` > UTC_TIMESTAMP - INTERVAL 1 day']);
                        if ($count >= $max_dailies) {
-                               Logger::log('max daily registrations exceeded.');
+                               Logger::notice('max daily registrations exceeded.');
                                notice(DI::l10n()->t('This site has exceeded the number of allowed daily account registrations. Please try again tomorrow.'));
                                return '';
                        }
@@ -87,7 +108,7 @@ class Register extends BaseModule
                if (DI::config()->get('system', 'publish_all')) {
                        $profile_publish = '<input type="hidden" name="profile_publish_reg" value="1" />';
                } else {
-                       $publish_tpl = Renderer::getMarkupTemplate('profile_publish.tpl');
+                       $publish_tpl = Renderer::getMarkupTemplate('profile/publish.tpl');
                        $profile_publish = Renderer::replaceMacros($publish_tpl, [
                                '$instance'     => 'reg',
                                '$pubdesc'      => DI::l10n()->t('Include your profile in member directory?'),
@@ -113,7 +134,7 @@ class Register extends BaseModule
                $o = Renderer::replaceMacros($tpl, [
                        '$invitations'  => DI::config()->get('system', 'invitation_only'),
                        '$permonly'     => intval(DI::config()->get('config', 'register_policy')) === self::APPROVE,
-                       '$permonlybox'  => ['permonlybox', DI::l10n()->t('Note for the admin'), '', DI::l10n()->t('Leave a message for the admin, why you want to join this node'), 'required'],
+                       '$permonlybox'  => ['permonlybox', DI::l10n()->t('Note for the admin'), '', DI::l10n()->t('Leave a message for the admin, why you want to join this node'), DI::l10n()->t('Required')],
                        '$invite_desc'  => DI::l10n()->t('Membership on this site is by invitation only.'),
                        '$invite_label' => DI::l10n()->t('Your invitation code: '),
                        '$invite_id'    => $invite_id,
@@ -165,8 +186,6 @@ class Register extends BaseModule
        {
                BaseModule::checkFormSecurityTokenRedirectOnError('/register', 'register');
 
-               $a = DI::app();
-
                $arr = ['post' => $_POST];
                Hook::callAll('register_post', $arr);
 
@@ -231,10 +250,6 @@ class Register extends BaseModule
                        DI::baseUrl()->redirect('register/');
                }
 
-
-               // Overwriting the "tar pit" field with the real one
-               $arr['email'] = $arr['field1'];
-
                if ($additional_account) {
                        $user = DBA::selectFirst('user', ['email'], ['uid' => local_user()]);
                        if (!DBA::isResult($user)) {
@@ -247,6 +262,9 @@ class Register extends BaseModule
 
                        $arr['password1'] = $arr['confirm'] = $arr['parent_password'];
                        $arr['repeat'] = $arr['email'] = $user['email'];
+               } else {
+                       // Overwriting the "tar pit" field with the real one
+                       $arr['email'] = $arr['field1'];
                }
 
                if ($arr['email'] != $arr['repeat']) {
@@ -284,7 +302,7 @@ class Register extends BaseModule
 
                $using_invites = DI::config()->get('system', 'invitation_only');
                $num_invites   = DI::config()->get('system', 'number_invites');
-               $invite_id = (!empty($_POST['invite_id']) ? Strings::escapeTags(trim($_POST['invite_id'])) : '');
+               $invite_id = (!empty($_POST['invite_id']) ? trim($_POST['invite_id']) : '');
 
                if (intval(DI::config()->get('config', 'register_policy')) === self::OPEN) {
                        if ($using_invites && $invite_id) {
@@ -347,18 +365,16 @@ class Register extends BaseModule
 
                        // send notification to admins
                        while ($admin = DBA::fetch($admins_stmt)) {
-                               \notification([
-                                       'type'         => NOTIFY_SYSTEM,
+                               DI::notify()->createFromArray([
+                                       'type'         => Model\Notification\Type::SYSTEM,
                                        'event'        => 'SYSTEM_REGISTER_REQUEST',
+                                       'uid'          => $admin['uid'],
+                                       'link'         => $base_url . '/admin/users/',
                                        'source_name'  => $user['username'],
                                        'source_mail'  => $user['email'],
                                        'source_nick'  => $user['nickname'],
                                        'source_link'  => $base_url . '/admin/users/',
-                                       'link'         => $base_url . '/admin/users/',
-                                       'source_photo' => $base_url . '/photo/avatar/' . $user['uid'] . '.jpg',
-                                       'to_email'     => $admin['email'],
-                                       'uid'          => $admin['uid'],
-                                       'language'     => ($admin['language'] ?? '') ?: 'en',
+                                       'source_photo' => User::getAvatarUrl($user, Proxy::SIZE_THUMB),
                                        'show_in_notification_page' => false
                                ]);
                        }