Issues (102)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Customer/Helper.php (22 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
    HCSF - A multilingual CMS and Shopsystem
5
    Copyright (C) 2014  Marcus Haase - [email protected]
6
7
    This program is free software: you can redistribute it and/or modify
8
    it under the terms of the GNU General Public License as published by
9
    the Free Software Foundation, either version 3 of the License, or
10
    (at your option) any later version.
11
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16
17
    You should have received a copy of the GNU General Public License
18
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
namespace HaaseIT\HCSF\Customer;
22
23
use HaaseIT\Toolbox\Tools;
24
use Zend\ServiceManager\ServiceManager;
25
26
/**
27
 * Class Helper
28
 * @package HaaseIT\HCSF\Customer
29
 */
30
class Helper
31
{
32
    /**
33
     * @var ServiceManager
34
     */
35
    protected $serviceManager;
36
37
    /**
38
     * @var \HaaseIT\HCSF\HelperConfig
39
     */
40
    protected $config;
41
42
    /**
43
     * @var array
44
     */
45
    protected $core = [];
46
47
    /**
48
     * @var array
49
     */
50
    protected $customer = [];
51
52
    /**
53
     * @var array
54
     */
55
    protected $countries = [];
56
57
    /**
58
     * @var array
59
     */
60
    protected $shop = [];
61
62
    /**
63
     * @var \HaaseIT\HCSF\Helper
64
     */
65
    protected $helper;
66
67
    public function __construct(ServiceManager $serviceManager)
68
    {
69
        $this->serviceManager = $serviceManager;
70
        $this->config = $serviceManager->get('config');
71
        $this->core = $this->config->getCore();
72
        $this->countries = $this->config->getCountries();
73
        $this->shop = $this->config->getShop();
74
        $this->helper = $this->serviceManager->get('helper');
75
    }
76
77
    /**
78
     * @param string $sLang
79
     * @param array $aErr
80
     * @param bool $bEdit
81
     * @return array
82
     */
83
    public function validateCustomerForm($sLang, $aErr = [], $bEdit = false)
84
    {
85
        if (empty(filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL))) {
86
            $aErr['email'] = true;
87
        }
88
        $postcorpname = filter_input(INPUT_POST, 'corpname', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
89 View Code Duplication
        if ($this->customer['validate_corpname'] && (empty($postcorpname) || strlen(trim($postcorpname)) < 3)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
            $aErr['corpname'] = true;
91
        }
92
        $postname = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
93 View Code Duplication
        if ($this->customer['validate_name'] && (empty($postname) || strlen(trim($postname)) < 3)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
94
            $aErr['name'] = true;
95
        }
96
        $poststreet = filter_input(INPUT_POST, 'street', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
97 View Code Duplication
        if ($this->customer['validate_street'] && (empty($poststreet) || strlen(trim($poststreet)) < 3)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
98
            $aErr['street'] = true;
99
        }
100
        $postzip = filter_input(INPUT_POST, 'zip', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
101 View Code Duplication
        if ($this->customer['validate_zip'] && (empty($postzip) || strlen(trim($postzip)) < 4)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
102
            $aErr['zip'] = true;
103
        }
104
        $posttown = filter_input(INPUT_POST, 'town', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
105 View Code Duplication
        if ($this->customer['validate_town'] && (empty($posttown) || strlen(trim($posttown)) < 3)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
106
            $aErr['town'] = true;
107
        }
108
        $postphone = filter_input(INPUT_POST, 'phone', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
109 View Code Duplication
        if ($this->customer['validate_phone'] && (empty($postphone) || strlen(trim($postphone)) < 6)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
110
            $aErr['phone'] = true;
111
        }
112
        $postcellphone = filter_input(INPUT_POST, 'cellphone', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
113 View Code Duplication
        if ($this->customer['validate_cellphone'] && (empty($postcellphone) || strlen(trim($postcellphone)) < 11)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
114
            $aErr['cellphone'] = true;
115
        }
116
        $postfax = filter_input(INPUT_POST, 'fax', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
117 View Code Duplication
        if ($this->customer['validate_fax'] && (empty($postfax) || strlen(trim($postfax)) < 6)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
118
            $aErr['fax'] = true;
119
        }
120
        $postcountry = filter_input(INPUT_POST, 'country', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW);
121
        if ($this->customer['validate_country'] && (empty($postcountry) || !isset($this->countries['countries_' .$sLang][$postcountry]))) {
122
            $aErr['country'] = true;
123
        }
124
        $posttos = filter_input(INPUT_POST, 'tos');
125
        if (!$bEdit && $posttos !== 'y') {
126
            $aErr['tos'] = true;
127
        }
128
        $postcancellationdisclaimer = filter_input(INPUT_POST, 'cancellationdisclaimer');
129
        if (!$bEdit && $postcancellationdisclaimer !== 'y') {
130
            $aErr['cancellationdisclaimer'] = true;
131
        }
132
133
        $postpwd = filter_input(INPUT_POST, 'pwd');
134
        $postpwdc = filter_input(INPUT_POST, 'pwdc');
135
        if (!$bEdit || !empty($postpwd)) {
136
            if (strlen($postpwd) < $this->customer['minimum_length_password']) {
137
                $aErr['passwordlength'] = true;
138
            }
139
            if ($postpwd !== $postpwdc) {
140
                $aErr['passwordmatch'] = true;
141
            }
142
        }
143
144
        return $aErr;
145
    }
146
147
    /**
148
     * @param string $sLang
149
     * @return string
150
     */
151
    public function getDefaultCountryByConfig($sLang) {
152
        if (isset($this->core['defaultcountrybylang'][$sLang])) {
153
            return $this->core['defaultcountrybylang'][$sLang];
154
        }
155
        return '';
156
    }
157
158
    /**
159
     * @param string $sKeyConfig
160
     * @param string $sKeyForm
161
     * @param array|bool $aUserData
162
     * @return bool
163
     */
164
    public function getCustomerFormDefaultValue($sKeyConfig, $sKeyForm, $aUserData) {
165
        $sDefaultValue = $this->getUserData($sKeyConfig, $aUserData);
0 ignored issues
show
It seems like $aUserData defined by parameter $aUserData on line 164 can also be of type array; however, HaaseIT\HCSF\Customer\Helper::getUserData() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
166
        if (!$sDefaultValue && isset($_SESSION['formsave_addrform'][$sKeyForm])) {
167
            $sDefaultValue = $_SESSION['formsave_addrform'][$sKeyForm];
168
        }
169
170
        return $sDefaultValue;
171
    }
172
173
    /**
174
     * @param string $sLang
175
     * @param string $sPurpose
176
     * @param array $aErr
177
     * @param bool $aUserData
178
     * @return array
179
     */
180
    public function buildCustomerForm($sLang, $sPurpose = 'none', $aErr = [], $aUserData = false)
181
    {
182
        $sDefaultCountry = $this->getCustomerFormDefaultValue('cust_country', 'country', $aUserData);
183
184
        // Purposes: shoppingcart, userhome, shopadmin, editprofile, register
185
        // fv = field_value, fr = field_required
186
        $aData = [
187
            'purpose' => $sPurpose,
188
            'errormessage' => $aErr,
189
            'readonlycustno' => $sPurpose === 'shopadmin' ? true : false,
190
            'readonly' =>
191
                $sPurpose === 'shopadmin'
192
                || $sPurpose === 'userhome'
193
                || ($sPurpose === 'editprofile' && !$this->customer['allow_edituserprofile'])
194
                || ($sPurpose === 'shoppingcart' && $this->getUserData())
195
            ,
196
            'fv_custno' => Tools::getFormfield(
197
                'custno',
198
                $this->getCustomerFormDefaultValue('cust_no', 'custno', $aUserData),
0 ignored issues
show
$this->getCustomerFormDe..., 'custno', $aUserData) is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
199
                true
200
            ),
201
            'fv_email' => Tools::getFormfield(
202
                'email',
203
                $this->getCustomerFormDefaultValue('cust_email', 'email', $aUserData),
0 ignored issues
show
$this->getCustomerFormDe...', 'email', $aUserData) is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
204
                true
205
            ),
206
            'fv_corpname' => Tools::getFormfield(
207
                'corpname',
208
                $this->getCustomerFormDefaultValue('cust_corp', 'corpname', $aUserData),
0 ignored issues
show
$this->getCustomerFormDe...'corpname', $aUserData) is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
209
                true
210
            ),
211
            'fr_corpname' => $this->customer['validate_corpname'],
212
            'fv_name' => Tools::getFormfield(
213
                'name',
214
                $this->getCustomerFormDefaultValue('cust_name', 'name', $aUserData),
0 ignored issues
show
$this->getCustomerFormDe...e', 'name', $aUserData) is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
215
                true
216
            ),
217
            'fr_name' => $this->customer['validate_name'],
218
            'fv_street' => Tools::getFormfield(
219
                'street',
220
                $this->getCustomerFormDefaultValue('cust_street', 'street', $aUserData),
0 ignored issues
show
$this->getCustomerFormDe..., 'street', $aUserData) is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
221
                true
222
            ),
223
            'fr_street' => $this->customer['validate_street'],
224
            'fv_zip' => Tools::getFormfield(
225
                'zip',
226
                $this->getCustomerFormDefaultValue('cust_zip', 'zip', $aUserData),
0 ignored issues
show
$this->getCustomerFormDe...ip', 'zip', $aUserData) is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
227
                true
228
            ),
229
            'fr_zip' => $this->customer['validate_zip'],
230
            'fv_town' => Tools::getFormfield(
231
                'town',
232
                $this->getCustomerFormDefaultValue('cust_town', 'town', $aUserData),
0 ignored issues
show
$this->getCustomerFormDe...n', 'town', $aUserData) is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
233
                true
234
            ),
235
            'fr_town' => $this->customer['validate_town'],
236
            'fv_phone' => Tools::getFormfield(
237
                'phone',
238
                $this->getCustomerFormDefaultValue('cust_phone', 'phone', $aUserData),
0 ignored issues
show
$this->getCustomerFormDe...', 'phone', $aUserData) is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
239
                true
240
            ),
241
            'fr_phone' => $this->customer['validate_phone'],
242
            'fv_cellphone' => Tools::getFormfield(
243
                'cellphone',
244
                $this->getCustomerFormDefaultValue('cust_cellphone', 'cellphone', $aUserData),
0 ignored issues
show
$this->getCustomerFormDe...cellphone', $aUserData) is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
245
                true
246
            ),
247
            'fr_cellphone' => $this->customer['validate_cellphone'],
248
            'fv_fax' => Tools::getFormfield(
249
                'fax',
250
                $this->getCustomerFormDefaultValue('cust_fax', 'fax', $aUserData),
0 ignored issues
show
$this->getCustomerFormDe...ax', 'fax', $aUserData) is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
251
                true
252
            ),
253
            'fr_fax' => $this->customer['validate_fax'],
254
            'fv_country' => Tools::getFormfield(
255
                'country',
256
                ($sDefaultCountry ? $sDefaultCountry : $this->getDefaultCountryByConfig($sLang)),
0 ignored issues
show
It seems like $sDefaultCountry ? $sDef...CountryByConfig($sLang) can also be of type boolean; however, HaaseIT\Toolbox\Tools::getFormfield() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
257
                true
258
            ),
259
            'fr_country' => $this->customer['validate_country'],
260
        ];
261
262
        if ($sPurpose === 'admin') {
263
            $aData['fv_custgroups'] = $this->customer['customer_groups'];
264
            $aData['fv_custgroup_selected'] = Tools::getFormfield('custgroup', $this->getUserData('cust_group', $aUserData), true);
0 ignored issues
show
$this->getUserData('cust_group', $aUserData) is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
265
        } elseif ($sPurpose === 'shopadmin') {
266
            $aData['fv_custgroup'] = '';
267
            if (isset($this->customer['customer_groups'][$this->getUserData('cust_group', $aUserData)])) {
268
                $aData['fv_custgroup'] = $this->customer['customer_groups'][$this->getUserData('cust_group', $aUserData)];
269
            }
270
        }
271
272
        if ($sPurpose === 'admin' || $sPurpose === 'register' || $sPurpose === 'editprofile') {
273
            $aData['fv_pwd'] = (($sPurpose === 'admin' || $sPurpose === 'editprofile') ? '' : Tools::getFormfield('pwd', ''));
274
            $aData['fv_pwdc'] = (($sPurpose === 'admin' || $sPurpose === 'editprofile') ? '' : Tools::getFormfield('pwdc', ''));
275
        }
276
277
        if ($sPurpose === 'shoppingcart') {
278
            $sRememberedRemarks = '';
279
            if (isset($_SESSION['formsave_addrform']['remarks'])) {
280
                $sRememberedRemarks = $_SESSION['formsave_addrform']['remarks'];
281
            }
282
            $aData['fv_remarks'] = Tools::getFormfield('remarks', $sRememberedRemarks, true);
283
        }
284
285
        if ($sPurpose === 'shoppingcart' || $sPurpose === 'register') {
286
            if (!$this->getUserData()) {
287
                $aData['fv_tos'] = Tools::getCheckbox('tos', 'y');
288
                $aData['fv_cancellationdisclaimer'] = Tools::getCheckbox('cancellationdisclaimer', 'y');
289
            }
290
        }
291
292
        if ($sPurpose === 'shoppingcart') {
293
            $aData['fv_paymentmethods'] = $this->shop['paymentmethods'];
294
            $aData['fv_paymentmethod'] = Tools::getFormfield('paymentmethod', '');
295
        }
296
297
        if ($sPurpose === 'admin') {
298
            $aData['fv_active'] = $this->getUserData('cust_active', $aUserData) === 'y';
299
            $aData['fv_emailverified'] = $this->getUserData('cust_emailverified', $aUserData) === 'y';
300
        }
301
        return $aData;
302
    }
303
304
    /**
305
     * @param $sEmailVerificationcode
306
     * @param $sTargetAddress
307
     * @param ServiceManager $serviceManager
308
     * @param bool $bCust
309
     */
310
    public function sendVerificationMail($sEmailVerificationcode, $sTargetAddress, ServiceManager $serviceManager, $bCust = false)
311
    {
312
        if ($bCust) {
313
            $sSubject = $serviceManager->get('textcats')->T('register_mail_emailverification_subject');
314
315
            $serverhttps = filter_input(INPUT_SERVER, 'HTTPS');
316
            $servername = filter_input(INPUT_SERVER, 'SERVER_NAME', FILTER_SANITIZE_URL);
317
            $aP['link'] = 'http'.($serverhttps === 'on' ? 's' : '').'://';
0 ignored issues
show
Coding Style Comprehensibility introduced by
$aP was never initialized. Although not strictly required by PHP, it is generally a good practice to add $aP = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
318
            $aP['link'] .= $servername.'/_misc/verifyemail.html?key='.$sEmailVerificationcode;
319
320
            $sMessage = $serviceManager->get('twig')->render('customer/sendverificationmail.twig', $aP);
321
        } else {
322
            $hardcodedtextcats = $serviceManager->get('hardcodedtextcats');
323
324
            $sSubject = $hardcodedtextcats->get('newcustomerregistration_mail_subject');
325
            $sMessage = $hardcodedtextcats->get('newcustomerregistration_mail_text1').' ';
326
            $sMessage .= $sTargetAddress.$hardcodedtextcats->get(
327
                'newcustomerregistration_mail_text2').' '.date($this->core['locale_format_date_time']
328
                );
329
            $sTargetAddress = $this->core['email_sender'];
330
        }
331
332
        $this->helper->mailWrapper($sTargetAddress, $sSubject, $sMessage);
333
    }
334
335
    /**
336
     * @param string $sField
337
     * @param bool $aUserdata
338
     * @return bool
339
     */
340
    public function getUserData($sField = '', $aUserdata = false)
341
    {
342
        if (!$aUserdata) {
343
            if (!isset($_SESSION['user']) || !is_array($_SESSION['user'])) {
344
                return false;
345
            } elseif ($sField === '') {
346
                return true;
347
            }
348
349
            if ($sField !== '' && isset($_SESSION['user'][$sField]) && $_SESSION['user'][$sField] !== '') {
350
                return $_SESSION['user'][$sField];
351
            }
352
        } else {
353
            if (isset($aUserdata[$sField])) {
354
                return $aUserdata[$sField];
355
            } elseif ($sField === '') {
356
                return false;
357
            }
358
        }
359
    }
360
}
361