Issues (496)

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.

class/Adsense.php (1 issue)

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 namespace XoopsModules\Smartobject;
2
3
/*
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * @copyright    XOOPS Project https://xoops.org/
15
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
16
 * @package
17
 * @since
18
 * @author     XOOPS Development Team
19
 */
20
21
use XoopsModules\Smartobject;
22
23
// defined('XOOPS_ROOT_PATH') || die('Restricted access');
24
25
//require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php';
26
27
/**
28
 * Class SmartobjectAdsense
29
 */
30
class Adsense extends Smartobject\BaseSmartObject
31
{
32
    /**
33
     * SmartobjectAdsense constructor.
34
     */
35
    public function __construct()
36
    {
37
        $this->quickInitVar('adsenseid', XOBJ_DTYPE_INT, true);
38
        $this->quickInitVar('description', XOBJ_DTYPE_TXTAREA, true, _CO_SOBJECT_ADSENSE_DESCRIPTION, _CO_SOBJECT_ADSENSE_DESCRIPTION_DSC);
39
        $this->quickInitVar('client_id', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_CLIENT_ID, _CO_SOBJECT_ADSENSE_CLIENT_ID_DSC);
40
        $this->quickInitVar('tag', XOBJ_DTYPE_TXTBOX, false, _CO_SOBJECT_ADSENSE_TAG, _CO_SOBJECT_ADSENSE_TAG_DSC);
41
        $this->quickInitVar('format', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_FORMAT, _CO_SOBJECT_ADSENSE_FORMAT_DSC);
42
        $this->quickInitVar('border_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_BORDER_COLOR, _CO_SOBJECT_ADSENSE_BORDER_COLOR_DSC);
43
        $this->quickInitVar('background_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_BACKGROUND_COLOR, _CO_SOBJECT_ADSENSE_BORDER_COLOR_DSC);
44
        $this->quickInitVar('link_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_LINK_COLOR, _CO_SOBJECT_ADSENSE_LINK_COLOR_DSC);
45
        $this->quickInitVar('url_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_URL_COLOR, _CO_SOBJECT_ADSENSE_URL_COLOR_DSC);
46
        $this->quickInitVar('text_color', XOBJ_DTYPE_TXTBOX, true, _CO_SOBJECT_ADSENSE_TEXT_COLOR, _CO_SOBJECT_ADSENSE_TEXT_COLOR_DSC);
47
        $this->quickInitVar('style', XOBJ_DTYPE_TXTAREA, false, _CO_SOBJECT_ADSENSE_STYLE, _CO_SOBJECT_ADSENSE_STYLE_DSC);
48
49
        $this->setControl('format', [
50
            'handler' => 'adsense',
51
            'method'  => 'getFormats'
52
        ]);
53
54
        $this->setControl('border_color', [
55
            'name'      => 'text',
56
            'size'      => 6,
57
            'maxlength' => 6
58
        ]);
59
60
        $this->setControl('background_color', [
61
            'name'      => 'text',
62
            'size'      => 6,
63
            'maxlength' => 6
64
        ]);
65
66
        $this->setControl('link_color', [
67
            'name'      => 'text',
68
            'size'      => 6,
69
            'maxlength' => 6
70
        ]);
71
72
        $this->setControl('url_color', [
73
            'name'      => 'text',
74
            'size'      => 6,
75
            'maxlength' => 6
76
        ]);
77
78
        $this->setControl('text_color', [
79
            'name'      => 'text',
80
            'size'      => 6,
81
            'maxlength' => 6
82
        ]);
83
    }
84
85
    /**
86
     * @param  string $key
87
     * @param  string $format
88
     * @return mixed
89
     */
90
    public function getVar($key, $format = 's')
91
    {
92
        if ('s' === $format && in_array($key, [])) {
93
            //            return call_user_func(array($this, $key));
94
            return $this->{$key}();
95
        }
96
97
        return parent::getVar($key, $format);
98
    }
99
100
    /**
101
     * @return string
102
     */
103
    public function render()
104
    {
105
        global $smartobjectAdsenseHandler;
106
        if ('' !== $this->getVar('style', 'n')) {
107
            $ret = '<div style="' . $this->getVar('style', 'n') . '">';
108
        } else {
109
            $ret = '<div>';
110
        }
111
112
        $ret .= '<script type="text/javascript"><!--
113
google_ad_client = "' . $this->getVar('client_id', 'n') . '";
114
google_ad_width = ' . $smartobjectAdsenseHandler->adFormats[$this->getVar('format', 'n')]['width'] . ';
115
google_ad_height = ' . $smartobjectAdsenseHandler->adFormats[$this->getVar('format', 'n')]['height'] . ';
116
google_ad_format = "' . $this->getVar('format', 'n') . '";
117
google_ad_type = "text";
118
google_ad_channel ="";
119
google_color_border = "' . $this->getVar('border_color', 'n') . '";
120
google_color_bg = "' . $this->getVar('background_color', 'n') . '";
121
google_color_link = "' . $this->getVar('link_color', 'n') . '";
122
google_color_url = "' . $this->getVar('url_color', 'n') . '";
123
google_color_text = "' . $this->getVar('text_color', 'n') . '";
124
//--></script>
125
<script type="text/javascript"
126
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
127
</script>
128
</div>';
129
130
        return $ret;
131
    }
132
133
    /**
134
     * @return string
135
     */
136
    public function getXoopsCode()
137
    {
138
        $ret = '[adsense]' . $this->getVar('tag', 'n') . '[/adsense]';
139
140
        return $ret;
141
    }
142
143
    /**
144
     * @param $var
145
     * @return bool
146
     */
147
    public function emptyString($var)
148
    {
149
        return (strlen($var) > 0);
150
    }
151
152
    /**
153
     * @return mixed|string
154
     */
155 View Code Duplication
    public function generateTag()
0 ignored issues
show
This method seems to be duplicated in 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...
156
    {
157
        $title = rawurlencode(strtolower($this->getVar('description', 'e')));
158
        $title = xoops_substr($title, 0, 10, '');
159
        // Transformation des ponctuations
160
        $pattern = [
161
            '/%09/', // Tab
162
            '/%20/', // Space
163
            '/%21/', // !
164
            '/%22/', // "
165
            '/%23/', // #
166
            '/%25/', // %
167
            '/%26/', // &
168
            '/%27/', // '
169
            '/%28/', // (
170
            '/%29/', // )
171
            '/%2C/', // ,
172
            '/%2F/', // /
173
            '/%3A/', // :
174
            '/%3B/', // ;
175
            '/%3C/', // <
176
            '/%3D/', // =
177
            '/%3E/', // >
178
            '/%3F/', // ?
179
            '/%40/', // @
180
            '/%5B/', // [
181
            '/%5C/', // \
182
            '/%5D/', // ]
183
            '/%5E/', // ^
184
            '/%7B/', // {
185
            '/%7C/', // |
186
            '/%7D/', // }
187
            '/%7E/', // ~
188
            "/\./" // .
189
        ];
190
        $rep_pat = [
191
            '-',
192
            '-',
193
            '-',
194
            '-',
195
            '-',
196
            '-100',
197
            '-',
198
            '-',
199
            '-',
200
            '-',
201
            '-',
202
            '-',
203
            '-',
204
            '-',
205
            '-',
206
            '-',
207
            '-',
208
            '-',
209
            '-at-',
210
            '-',
211
            '-',
212
            '-',
213
            '-',
214
            '-',
215
            '-',
216
            '-',
217
            '-',
218
            '-'
219
        ];
220
        $title   = preg_replace($pattern, $rep_pat, $title);
221
222
        // Transformation des caractères accentués
223
        $pattern = [
224
            '/%B0/', // °
225
            '/%E8/', // è
226
            '/%E9/', // é
227
            '/%EA/', // ê
228
            '/%EB/', // ë
229
            '/%E7/', // ç
230
            '/%E0/', // à
231
            '/%E2/', // â
232
            '/%E4/', // ä
233
            '/%EE/', // î
234
            '/%EF/', // ï
235
            '/%F9/', // ù
236
            '/%FC/', // ü
237
            '/%FB/', // û
238
            '/%F4/', // ô
239
            '/%F6/', // ö
240
        ];
241
        $rep_pat = ['-', 'e', 'e', 'e', 'e', 'c', 'a', 'a', 'a', 'i', 'i', 'u', 'u', 'u', 'o', 'o'];
242
        $title   = preg_replace($pattern, $rep_pat, $title);
243
244
        $tableau = explode('-', $title); // Transforme la chaine de caract�res en tableau
245
        $tableau = array_filter($tableau, [$this, 'emptyString']); // Supprime les chaines vides du tableau
246
        $title   = implode('-', $tableau); // Transforme un tableau en chaine de caract�res s�par� par un tiret
247
248
        $title .= time();
249
        $title = md5($title);
250
251
        return $title;
252
    }
253
254
    /**
255
     * @return string
256
     */
257
    public function getCloneLink()
258
    {
259
        $ret = '<a href="' . SMARTOBJECT_URL . 'admin/adsense.php?op=clone&adsenseid=' . $this->getVar('adsenseid') . '"><img src="' . SMARTOBJECT_IMAGES_ACTIONS_URL . 'editcopy.png" alt="' . _CO_SOBJECT_ADSENSE_CLONE . '" title="' . _CO_SOBJECT_ADSENSE_CLONE . '"></a>';
260
261
        return $ret;
262
    }
263
}
264