Issues (314)

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.

files/commonfiles/admin/clone.php (12 issues)

1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * Modulebuilder module for xoops
14
 *
15
 * @copyright      module for xoops
16
 * @license        GPL 2.0 or later
17
 * @package        modulebuilder
18
 * @since          1.0
19
 * @min_xoops      2.5.11
20
 * @author         Wedega - Email:<[email protected]> - Website:<https://wedega.com>
21
 * @version        $Id: 1.0 images.php 1 Mon 2018-03-19 10:04:51Z XOOPS Project (www.xoops.org) $
22
 */
23
24
use Xmf\Request;
25
26
require __DIR__ . '/header.php';
27
// It recovered the value of argument op in URL$
28
$op = Request::getString('op', 'list');
29
30
$templateMain = 'modulebuilder_admin_clone.tpl';
31
32
switch ($op) {
33
    case 'list':
34
    default:
35
        $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('clone.php'));
36
        require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
37
        $form  = new \XoopsThemeForm(\sprintf(\_AM_MODULEBUILDER_CLONE_TITLE, $helper->getModule()->getVar('name', 'E')), 'clone', 'clone.php', 'post', true);
0 ignored issues
show
The constant _AM_MODULEBUILDER_CLONE_TITLE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
38
        $clone = new \XoopsFormText(\_AM_MODULEBUILDER_CLONE_NAME, 'clone', 20, 20, '');
0 ignored issues
show
The constant _AM_MODULEBUILDER_CLONE_NAME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
39
        $clone->setDescription(\_AM_MODULEBUILDER_CLONE_NAME_DSC);
0 ignored issues
show
The constant _AM_MODULEBUILDER_CLONE_NAME_DSC was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
40
        $form->addElement($clone, true);
41
        $form->addElement(new \XoopsFormHidden('op', 'submit'));
42
        $form->addElement(new \XoopsFormButton('', '', \_SUBMIT, 'submit'));
43
        $GLOBALS['xoopsTpl']->assign('form', $form->render());
44
45
        break;
46
    case 'submit':
47
        // Security Check
48
        if (!$GLOBALS['xoopsSecurity']->check()) {
49
            \redirect_header('clone.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
50
        }
51
        $clone = Request::getString('clone', '', 'POST');
52
        //check if name is valid
53
        if (empty($clone) || \preg_match('/[^a-zA-Z0-9\_\-]/', $clone)) {
54
            \redirect_header('clone.php', 3, \sprintf(\_AM_MODULEBUILDER_CLONE_INVALIDNAME, $clone));
0 ignored issues
show
The constant _AM_MODULEBUILDER_CLONE_INVALIDNAME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
55
        }
56
57
        // Check wether the cloned module exists or not
58
        $dirClone = $GLOBALS['xoops']->path('modules/' . $clone);
59
        if ($clone && \is_dir($dirClone)) {
60
            \redirect_header('clone.php', 3, \sprintf(\_AM_MODULEBUILDER_CLONE_EXISTS, $clone));
0 ignored issues
show
The constant _AM_MODULEBUILDER_CLONE_EXISTS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
61
        }
62
63
        $patterns = [
64
            \mb_strtolower(\MODULEBUILDER_DIRNAME)          => \mb_strtolower($clone),
0 ignored issues
show
The constant MODULEBUILDER_DIRNAME was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
65
            \mb_strtoupper(\MODULEBUILDER_DIRNAME)          => \mb_strtoupper($clone),
66
            \ucfirst(\mb_strtolower(\MODULEBUILDER_DIRNAME)) => \ucfirst(\mb_strtolower($clone)),
67
        ];
68
69
        $patKeys   = \array_keys($patterns);
70
        $patValues = \array_values($patterns);
71
        cloneFileFolder(\MODULEBUILDER_PATH);
0 ignored issues
show
The constant MODULEBUILDER_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
72
        $logocreated = createLogo(\mb_strtolower($clone));
73
74
        //change module name in modinfo.php
75
        // file, read it
76
        $content = \file_get_contents($dirClone . '/language/english/modinfo.php');
77
        $content = \str_replace('Modulebuilder', \mb_strtolower($clone), $content);
78
        file_put_contents($dirClone . '/language/english/modinfo.php', $content);
79
80
        $msg = '';
81
        if (\is_dir($GLOBALS['xoops']->path('modules/' . \mb_strtolower($clone)))) {
82
            $msg .= \sprintf(\_AM_MODULEBUILDER_CLONE_CONGRAT, "<a href='" . \XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin&op=installlist'>" . \ucfirst(\mb_strtolower($clone)) . '</a>') . "<br>\n";
0 ignored issues
show
The constant _AM_MODULEBUILDER_CLONE_CONGRAT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
83
            if (!$logocreated) {
84
                $msg .= \_AM_MODULEBUILDER_CLONE_IMAGEFAIL;
0 ignored issues
show
The constant _AM_MODULEBUILDER_CLONE_IMAGEFAIL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
85
            }
86
        } else {
87
            $msg .= \_AM_MODULEBUILDER_CLONE_FAIL;
0 ignored issues
show
The constant _AM_MODULEBUILDER_CLONE_FAIL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
88
        }
89
        $GLOBALS['xoopsTpl']->assign('result', $msg);
90
        break;
91
}
92
require __DIR__ . '/footer.php';
93
94
// recursive cloning script
95
/**
96
 * @param $path
97
 */
98
function cloneFileFolder($path)
99
{
100
    global $patKeys;
101
    global $patValues;
102
103
    //remove \XOOPS_ROOT_PATH and add after replace, otherwise there can be a bug if \XOOPS_ROOT_PATH contains same pattern
104
    $newPath = \XOOPS_ROOT_PATH . \str_replace($patKeys[0], $patValues[0], \substr($path, \strlen(\XOOPS_ROOT_PATH)));
105
106
    if (\is_dir($path)) {
107
        // create new dir
108
        if (!\mkdir($newPath) && !\is_dir($newPath)) {
109
            throw new \RuntimeException(\sprintf('Directory "%s" was not created', $newPath));
110
        }
111
112
        // check all files in dir, and process it
113
        $handle = \opendir($path);
114
        if ($handle) {
0 ignored issues
show
$handle is of type resource, thus it always evaluated to false.
Loading history...
115
            while (false !== ($file = \readdir($handle))) {
116
                if (0 !== \mb_strpos($file, '.')) {
117
                    cloneFileFolder("{$path}/{$file}");
118
                }
119
            }
120
            \closedir($handle);
121
        }
122
    } else {
123
        $noChangeExtensions = ['jpeg', 'jpg', 'gif', 'png', 'zip', 'ttf'];
124
        if (\in_array(\mb_strtolower(\pathinfo($path, \PATHINFO_EXTENSION)), $noChangeExtensions, true)) {
0 ignored issues
show
It seems like pathinfo($path, PATHINFO_EXTENSION) can also be of type array; however, parameter $string of mb_strtolower() does only seem to accept string, 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

124
        if (\in_array(\mb_strtolower(/** @scrutinizer ignore-type */ \pathinfo($path, \PATHINFO_EXTENSION)), $noChangeExtensions, true)) {
Loading history...
125
            // image
126
            \copy($path, $newPath);
127
        } else {
128
            // file, read it
129
            $content = \file_get_contents($path);
130
            $content = \str_replace($patKeys, $patValues, $content);
131
            \file_put_contents($newPath, $content);
132
        }
133
    }
134
}
135
136
/**
137
 * @param $dirname
138
 *
139
 * @return bool
140
 */
141
function createLogo($dirname)
142
{
143
    if (!\extension_loaded('gd')) {
144
        return false;
145
    }
146
    $requiredFunctions = [
147
        'imagecreatefrompng',
148
        'imagecolorallocate',
149
        'imagefilledrectangle',
150
        'imagepng',
151
        'imagedestroy',
152
        'imagefttext',
153
        'imagealphablending',
154
        'imagesavealpha',
155
    ];
156
    foreach ($requiredFunctions as $func) {
157
        if (!\function_exists($func)) {
158
            return false;
159
        }
160
    }
161
    //            unset($func);
162
163
    if (!\file_exists($imageBase = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/logoModule.png'))
164
        || !\file_exists($font = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/VeraBd.ttf'))) {
165
        return false;
166
    }
167
168
    $imageModule = \imagecreatefrompng($imageBase);
169
    // save existing alpha channel
170
    \imagealphablending($imageModule, false);
171
    \imagesavealpha($imageModule, true);
172
173
    //Erase old text
174
    $greyColor = \imagecolorallocate($imageModule, 237, 237, 237);
175
    \imagefilledrectangle($imageModule, 5, 35, 85, 46, $greyColor);
176
177
    // Write text
178
    $textColor     = \imagecolorallocate($imageModule, 0, 0, 0);
179
    $spaceToBorder = (int)((80 - \mb_strlen($dirname) * 6.5) / 2);
180
    \imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, \ucfirst($dirname), []);
181
182
    // Set transparency color
183
    //$white = imagecolorallocatealpha($imageModule, 255, 255, 255, 127);
184
    //imagefill($imageModule, 0, 0, $white);
185
    //imagecolortransparent($imageModule, $white);
186
187
    \imagepng($imageModule, $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/logoModule.png'));
188
    \imagedestroy($imageModule);
189
190
    return true;
191
}