Verifyemail   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 7
dl 0
loc 59
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A preparePage() 0 32 4
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\Controller\Customer;
22
23
use Zend\ServiceManager\ServiceManager;
24
25
/**
26
 * Class Verifyemail
27
 * @package HaaseIT\HCSF\Controller\Customer
28
 */
29
class Verifyemail extends Base
30
{
31
    /**
32
     * @var \HaaseIT\Toolbox\Textcat
33
     */
34
    private $textcats;
35
36
    /**
37
     * @var \PDO
38
     */
39
    private $db;
40
41
    /**
42
     * Verifyemail constructor.
43
     * @param ServiceManager $serviceManager
44
     */
45
    public function __construct(ServiceManager $serviceManager)
46
    {
47
        parent::__construct($serviceManager);
48
        $this->textcats = $serviceManager->get('textcats');
49
        $this->db = $serviceManager->get('db');
50
    }
51
52
    /**
53
     *
54
     */
55
    public function preparePage()
56
    {
57
        $this->P = new \HaaseIT\HCSF\CorePage($this->serviceManager);
58
        $this->P->cb_pagetype = 'content';
59
60
        if ($this->helperCustomer->getUserData()) {
61
            $this->P->oPayload->cl_html = $this->textcats->T('denied_default');
62
        } else {
63
            $sql = 'SELECT cust_email, cust_id FROM customer '
64
               .'WHERE cust_emailverificationcode = :key AND cust_emailverified = \'n\'';
65
            /** @var \PDOStatement $hResult */
66
            $hResult = $this->db->prepare($sql);
67
            $hResult->bindValue(':key', filter_input(INPUT_GET, 'key', FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW), \PDO::PARAM_STR);
68
            $hResult->execute();
69
            $iRows = $hResult->rowCount();
70
71
            if ($iRows == 1) {
72
                $aRow = $hResult->fetch();
73
                $aData = ['cust_emailverified' => 'y', 'cust_id' => $aRow['cust_id']];
74
                $sql = \HaaseIT\Toolbox\DBTools::buildPSUpdateQuery($aData, 'customer', 'cust_id');
75
                /** @var \PDOStatement $hResult */
76
                $hResult = $this->db->prepare($sql);
77
                foreach ($aData as $sKey => $sValue) {
78
                    $hResult->bindValue(':'.$sKey, $sValue);
79
                }
80
                $hResult->execute();
81
                $this->P->oPayload->cl_html = $this->textcats->T('register_emailverificationsuccess');
82
            } else {
83
                $this->P->oPayload->cl_html = $this->textcats->T('register_emailverificationfail');
84
            }
85
        }
86
    }
87
}
88