Issues (1177)

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.

application/modules/mailer/mailer.php (2 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
use CMSFactory\assetManager;
4
5
if (!defined('BASEPATH')) {
6
    exit('No direct script access allowed');
7
}
8
9
/**
10
 * Image CMS
11
 *
12
 * Класс отображения страниц по ID.
13
 */
14
class Mailer extends MY_Controller
15
{
16
17
    public $settings = [];
18
19
    public function __construct() {
20
        parent::__construct();
21
22
        $this->load->module('core');
23
        $lang = new MY_Lang();
24
        $lang->load('mailer');
25
    }
26
27
    /**
28
     * Подписка пользователей.
29
     */
30
    public function index() {
31
        $this->load->library('form_validation');
32
33
        if ($this->input->post()) {
34
35
            $this->form_validation->set_rules('user_email', lang('Your e-mail', 'mailer'), 'required|trim|valid_email');
36
37
            if ($this->form_validation->run($this) == FALSE) {
38
39
                echo $errors = validation_errors();
40
                redirect('/mailer/error/');
41
            } else {
42
43
                $email = $this->input->post('user_email');
44
45
                /** @var CI_DB_result $query */
46
                $query = $this->db->get_where('mail', ['email' => $email]);
47
                $row = $query->num_rows() > 0 ? $query->row() : false;
48
49
                if ($row && $this->input->post('add_user_mail') != 1) {
50
                    redirect('/mailer/already/');
51
52
                } elseif (!$row && $this->input->post('add_user_mail') == 1) {
53
                    redirect('/mailer/no/');
54
55
                }
56
57
                if ($this->input->post('add_user_mail') == 2) {
58
59
                    $date = date('U');
60
61
                    if ($this->dx_auth->is_email_available($email)) {
62
63
                        $this->registerUserByEmail($email);
64
                    }
65
66
                    $data = [
67
                             'email' => $email,
68
                             'date'  => $date,
69
                            ];
70
71
                    $this->db->insert('mail', $data);
72
73
                    redirect('/mailer/success/');
74
                } else {
75
                    $this->db->delete('mail', ['email' => $email]);
76
                    redirect('/mailer/cancel/');
77
                }
78
            }
79
        }
80
    }
81
82
    public function ajaxSubmit() {
83
84
        $this->load->library('form_validation');
85
        $this->form_validation->set_rules('user_email', lang('Your e-mail', 'mailer'), 'required|trim|valid_email');
86
87
        if ($this->form_validation->run($this) == FALSE) {
88
            assetManager::create()
89
                ->setData(
90
                    [
91
                     'mailer_errors' => validation_errors(),
92
                    ]
93
                )
94
                ->render('error', true);
95
        } else {
96
97
            $email = $this->input->post('user_email');
98
99
            /** @var CI_DB_result $query */
100
            $query = $this->db->get_where('mail', ['email' => $email]);
101
            $row = $query->num_rows() > 0 ? $query->row() : false;
102
103
            if ($row && $this->input->post('add_user_mail') != 1) {
104
105
                assetManager::create()->render('already', true);
106
                exit;
107
            } elseif (!$row && $this->input->post('add_user_mail') == 1) {
108
109
                assetManager::create()->render('no', true);
110
                exit;
111
            }
112
113
            if ($this->input->post('add_user_mail') == 2) {
114
115
                if ($this->dx_auth->is_email_available($email)) {
116
117
                    $this->registerUserByEmail($email);
118
                }
119
120
                $date = date('U');
121
                $data = [
122
                         'email' => $email,
123
                         'date'  => $date,
124
                        ];
125
126
                $this->db->insert('mail', $data);
127
                assetManager::create()
128
                    ->setData(
129
                        ['email' => $query]
130
                    )
131
                    ->render('success', true);
132
133
            } else {
134
                $this->db->delete('mail', ['email' => $email]);
135
                assetManager::create()->render('cancel', true);
136
            }
137
        }
138
    }
139
140
    /**
141
     * Register subscribed user by email
142
     * @param string $email - user email
143
     * @return false|null
144
     */
145
    private function registerUserByEmail($email) {
146
        if (!$email) {
147
            return FALSE;
148
        }
149
        $username = array_shift(explode('@', $email));
0 ignored issues
show
explode('@', $email) cannot be passed to array_shift() as the parameter $array expects a reference.
Loading history...
150
        $password = random_string('alnum', 8);
151
        $key = random_string('alnum', 5);
152
        $this->dx_auth->register($username, $password, $email, '', $key);
153
    }
154
155
    /**
156
     * @return void
157
     */
158
    public function getForm() {
159
        assetManager::create()
160
            ->render('form', true);
161
    }
162
163
    /**
164
     * @return void
165
     */
166
    public function success() {
167
        assetManager::create()
168
            ->render('success', true);
169
    }
170
171
    /**
172
     * @return void
173
     */
174
    public function already() {
175
        assetManager::create()
176
            ->render('already', true);
177
    }
178
179
    /**
180
     * @return void
181
     */
182
    public function cancel() {
183
        assetManager::create()
184
            ->render('cancel', true);
185
    }
186
187
    /**
188
     *@return void
189
     */
190
    public function no() {
191
        assetManager::create()
192
            ->render('no', true);
193
    }
194
195
    /**
196
     * @return void
197
     */
198
    public function error() {
199
        assetManager::create()
200
            ->render('error', true);
201
    }
202
203
    /**
204
     *  Create modules table in db
205
     *
206
     * @return bool
0 ignored issues
show
Should the return type not be boolean|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
207
     */
208 View Code Duplication
    public function _install() {
209
210
        $this->load->dbforge();
211
212
        $fields = [
213
                   'id'    => [
214
                               'type'           => 'INT',
215
                               'constraint'     => 11,
216
                               'auto_increment' => TRUE,
217
                              ],
218
                   'email' => [
219
                               'type'       => 'VARCHAR',
220
                               'constraint' => 255,
221
                               'default'    => NULL,
222
                              ],
223
                   'date'  => [
224
                               'type'       => 'int',
225
                               'constraint' => 15,
226
                               'default'    => NULL,
227
                              ],
228
                  ];
229
230
        $this->dbforge->add_key('id', TRUE);
231
        $this->dbforge->add_field($fields);
232
        $this->dbforge->create_table('mail', TRUE);
233
234
        $this->db->where('name', 'mailer')
235
            ->update('components', ['autoload' => '1', 'enabled' => '1']);
236
    }
237
238
    public function _deinstall() {
239
240
        $this->load->dbforge();
241
        $this->dbforge->drop_table('mailer');
242
    }
243
244
}
245
246
/* End of file mailer.php */