Issues (992)

Security Analysis    not enabled

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

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  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.
  Header Injection
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.

class/Mailer.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace XoopsModules\Extgallery;
4
5
/**
6
 * ExtGallery Class Manager
7
 *
8
 * You may not change or alter any portion of this comment or credits
9
 * of supporting developers from this source code or any supporting source code
10
 * which is considered copyrighted (c) material of the original comment or credit authors.
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 *
15
 * @copyright   {@link https://xoops.org/ XOOPS Project}
16
 * @license     GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 * @author      Zoullou (http://www.zoullou.net)
18
 * @package     ExtGallery
19
 */
20
21
use phpmailerException;
22
use XoopsModules\Extgallery;
23
use XoopsMultiMailer;
24
25
26
27
28
29
30
31
require_once XOOPS_ROOT_PATH . '/class/mail/xoopsmultimailer.php';
32
33
/**
34
 * Class Extgallery\Mailer
35
 */
36
class Mailer
37
{
38
    public $mailer;
39
    public $type;
40
    public $tags = [];
41
    public $ecardId;
42
    public $subject;
43
    public $toEmail;
44
    public $toName;
45
    public $fromEmail;
46
    public $fromName;
47
    public $greetings;
48
    public $description;
49
    public $photo;
50
51
    /**
52
     * @param $type
53
     */
54
    public function __construct($type)
55
    {
56
        $this->mailer = new XoopsMultiMailer();
57
        $this->type   = $type;
58
    }
59
60
    public function imageIncluded()
61
    {
62
        if ('' === $this->photo->getVar('photo_serveur')) {
63
            $photoPath = XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/medium/' . $this->photo->getVar('photo_name');
64
        } else {
65
            $photoPath = $this->photo->getVar('photo_serveur') . $this->photo->getVar('photo_name');
66
        }
67
        $this->tags['PHOTO_SRC'] = 'cid:photo';
68
        $this->tags['STAMP_SRC'] = 'cid:stamp';
69
        $this->mailer->addEmbeddedImage($photoPath, 'photo');
70
        $this->mailer->addEmbeddedImage(XOOPS_ROOT_PATH . '/modules/extgallery/assets/images/stamp.gif', 'stamp');
71
    }
72
73
    public function imageLinked()
74
    {
75
        if ('' == $this->photo->getVar('photo_serveur')) {
76
            $photoUrl = XOOPS_URL . '/uploads/extgallery/public-photo/medium/' . $this->photo->getVar('photo_name');
77
        } else {
78
            $photoUrl = $this->photo->getVar('photo_serveur') . $this->photo->getVar('photo_name');
79
        }
80
        $this->tags['PHOTO_SRC'] = $photoUrl;
81
        $this->tags['STAMP_SRC'] = XOOPS_URL . '/modules/extgallery/assets/images/stamp.gif';
82
    }
83
84
    public function send()
85
    {
86
        $this->assignTags();
87
        if ('included' === $this->type) {
88
            $this->imageIncluded();
89
        } elseif ('linked' === $this->type) {
90
            $this->imageLinked();
91
        }
92
93
        $this->mailer->From     = $this->fromEmail;
94
        $this->mailer->FromName = $this->fromName;
95
        $this->mailer->Subject  = $this->subject;
96
        $this->mailer->Body     = $this->loadTemplate('ecard_html.tpl');
97
        $this->mailer->AltBody  = $this->loadTemplate('ecard_text.tpl');
98
        $this->mailer->addAddress($this->toEmail, $this->toName);
99
        //$this->mailer->AddReplyTo($this->fromEmail, $this->fromName);
100
        try {
101
            $this->mailer->send();
102
        } catch (phpmailerException $e) {
103
            echo 'Caught exception: ', $e->getMessage(), "\n", '<br>';
104
        }
105
    }
106
107
    public function assignTags()
108
    {
109
        $this->tags['ECARD_LINK']  = XOOPS_URL . '/modules/extgallery/public-viewecard.php?id=' . $this->ecardId;
110
        $this->tags['EXP_EMAIL']   = $this->fromEmail;
111
        $this->tags['EXP_NAME']    = $this->fromName;
112
        $this->tags['REC_NAME']    = $this->toName;
113
        $this->tags['GREETINGS']   = $this->greetings;
114
        $this->tags['DESCRIPTION'] = $this->description;
115
        $this->tags['MODULE_LINK'] = XOOPS_URL . '/modules/extgallery/';
116
        $this->tags['SITE_NAME']   = $GLOBALS['xoopsConfig']['sitename'];
117
        $this->tags['SITE_URL']    = XOOPS_URL;
118
    }
119
120
    /**
121
     * @param $name
122
     *
123
     * @return mixed|string
124
     */
125
    public function loadTemplate($name)
126
    {
127
        global $xoopsConfig;
128
129
        if (\file_exists(XOOPS_ROOT_PATH . '/modules/extgallery/language/' . $xoopsConfig['language'] . '/mail_template/' . $name)) {
130
            $path = XOOPS_ROOT_PATH . '/modules/extgallery/language/' . $xoopsConfig['language'] . '/mail_template/' . $name;
131
        } else {
132
            $path = XOOPS_ROOT_PATH . '/modules/extgallery/language/english/mail_template/' . $name;
133
        }
134
        $fd   = @\fopen($path, 'rb');
135
        $body = \fread($fd, \filesize($path));
0 ignored issues
show
It seems like $fd can also be of type false; however, parameter $stream of fread() does only seem to accept resource, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

135
        $body = \fread(/** @scrutinizer ignore-type */ $fd, \filesize($path));
Loading history...
136
        // replace tags with actual values
137
        foreach ($this->tags as $k => $v) {
138
            $body = \str_replace('{' . $k . '}', $v, $body);
139
        }
140
141
        return $body;
142
    }
143
144
    /**
145
     * @param $ecardId
146
     */
147
    public function setEcardId($ecardId)
148
    {
149
        $this->ecardId = $ecardId;
150
    }
151
152
    /**
153
     * @param $subject
154
     */
155
    public function setSubject($subject)
156
    {
157
        $this->subject = $subject;
158
    }
159
160
    /**
161
     * @param $email
162
     */
163
    public function setToEmail($email)
164
    {
165
        $this->toEmail = $email;
166
    }
167
168
    /**
169
     * @param $name
170
     */
171
    public function setToName($name)
172
    {
173
        $this->toName = $name;
174
    }
175
176
    /**
177
     * @param $email
178
     */
179
    public function setFromEmail($email)
180
    {
181
        $this->fromEmail = $email;
182
    }
183
184
    /**
185
     * @param $name
186
     */
187
    public function setFromName($name)
188
    {
189
        $this->fromName = $name;
190
    }
191
192
    /**
193
     * @param $greetings
194
     */
195
    public function setGreetings($greetings)
196
    {
197
        $this->greetings = $greetings;
198
    }
199
200
    /**
201
     * @param $description
202
     */
203
    public function setDescription($description)
204
    {
205
        $this->description = $description;
206
    }
207
208
    /**
209
     * @param $photo
210
     */
211
    public function setPhoto($photo)
212
    {
213
        $this->photo = $photo;
214
    }
215
}
216