Issues (519)

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/Files/User/UserPrint.php (9 issues)

1
<?php namespace XoopsModules\Tdmcreate\Files\User;
2
3
use XoopsModules\Tdmcreate;
4
use XoopsModules\Tdmcreate\Files;
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
/**
15
 * tdmcreate module.
16
 *
17
 * @copyright       XOOPS Project (https://xoops.org)
18
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
19
 *
20
 * @since           2.5.0
21
 *
22
 * @author          Txmod Xoops http://www.txmodxoops.org
23
 *
24
 * @version         $Id: UserPrint.php 12258 2014-01-02 09:33:29Z timgno $
25
 */
26
27
/**
28
 * Class UserPrint.
29
 */
30
class UserPrint extends Files\CreateFile
31
{
32
    /**
33
     * @var mixed
34
     */
35
    private $uc = null;
36
37
    /**
38
     * @var string
39
     */
40
    private $xc = null;
41
42
    /**
43
     *  @public function constructor
44
     *  @param null
45
     */
46
    public function __construct()
47
    {
48
        parent::__construct();
49
        $this->xc = Tdmcreate\Files\CreateXoopsCode::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like XoopsModules\Tdmcreate\F...oopsCode::getInstance() of type XoopsModules\Tdmcreate\Files\CreateXoopsCode is incompatible with the declared type string of property $xc.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
50
        $this->phpcode = Tdmcreate\Files\CreatePhpCode::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like XoopsModules\Tdmcreate\F...ePhpCode::getInstance() of type XoopsModules\Tdmcreate\Files\CreatePhpCode is incompatible with the declared type string of property $phpcode.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
51
        $this->uc = UserXoopsCode::getInstance();
52
    }
53
54
    /**
55
     *  @static function getInstance
56
     *  @param null
57
     * @return UserPrint
58
     */
59
    public static function getInstance()
60
    {
61
        static $instance = false;
62
        if (!$instance) {
63
            $instance = new self();
64
        }
65
66
        return $instance;
67
    }
68
69
    /**
70
     *  @public function write
71
     *  @param string $module
72
     *  @param mixed $table
73
     *  @param string $filename
74
     */
75
    public function write($module, $table, $filename)
76
    {
77
        $this->setModule($module);
78
        $this->setTable($table);
79
        $this->setFileName($filename);
80
    }
81
82
    /**
83
     *  @public function getUserPrint
84
     *  @param string $moduleDirname
85
     *  @param string $language
86
     *
87
     * @return string
88
     */
89
    public function getUserPrint($moduleDirname, $language)
90
    {
91
        $stuModuleDirname = mb_strtoupper($moduleDirname);
92
        $table = $this->getTable();
93
        $tableName = $table->getVar('table_name');
94
        $tableSoleName = $table->getVar('table_solename');
95
        $ucfModuleDirname = ucfirst($moduleDirname);
0 ignored issues
show
The assignment to $ucfModuleDirname is dead and can be removed.
Loading history...
96
        $ucfTableName = ucfirst($tableName);
0 ignored issues
show
The assignment to $ucfTableName is dead and can be removed.
Loading history...
97
        $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'));
98
        foreach (array_keys($fields) as $f) {
99
            $fieldName = $fields[$f]->getVar('field_name');
100
            $rpFieldName = $fieldName;
0 ignored issues
show
The assignment to $rpFieldName is dead and can be removed.
Loading history...
101
            if (mb_strpos($fieldName, '_')) {
102
                $str = mb_strpos($fieldName, '_');
103
                if (false !== $str) {
104
                    $rpFieldName = mb_substr($fieldName, $str + 1, mb_strlen($fieldName));
105
                }
106
            }
107
            if ((0 == $f) && (1 == $this->table->getVar('table_autoincrement'))) {
108
                $fieldId = $fieldName;
109
            } else {
110
                if (1 == $fields[$f]->getVar('field_main')) {
111
                    $fieldMain = $fieldName; // fieldMain = fields parameters main field
112
                }
113
            }
114
            $ucfFieldName = ucfirst($fieldName);
115
        }
116
        $ccFieldId = $this->getCamelCase($fieldId, false, true);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $fieldId does not seem to be defined for all execution paths leading up to this point.
Loading history...
117
        $stuLpFieldName = mb_strtoupper($ccFieldId);
118
        $ret = $this->getInclude();
119
        $ret .= $this->xc->getXcXoopsRequest($ccFieldId, (string)$fieldId, '', 'Int');
120
        $ret .= $this->phpcode->getPhpCodeCommentLine('Define Stylesheet');
121
        $ret .= $this->xc->getXcAddStylesheet();
122
        $redirectHeader = $this->xc->getXcRedirectHeader("{$stuModuleDirname}_URL . '/index.php'", '', '2', "{$language}NO{$stuLpFieldName}", false, "\t");
123
        $ret .= $this->phpcode->getPhpCodeConditions("empty(\${$ccFieldId})", '', '', $redirectHeader);
124
        $ret .= $this->phpcode->getPhpCodeCommentLine('Verify that the article is published');
125
        if (false !== mb_strpos($fieldName, 'published')) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $fieldName seems to be defined by a foreach iteration on line 98. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
126
            $ret .= $this->phpcode->getPhpCodeCommentLine('Not yet', $fieldName);
127
            $redirectHeader .= $this->getSimpleString('exit();');
128
            $ret .= $this->phpcode->getPhpCodeConditions("\${$ccFieldId}->getVar('{$fieldName}') == 0 || \${$ccFieldId}->getVar('{$fieldName}') > time()", '', '', $redirectHeader);
129
        }
130
        if (false !== mb_strpos($fieldName, 'expired')) {
131
            $ret .= $this->phpcode->getPhpCodeCommentLine('Expired', $ucfFieldName);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $ucfFieldName seems to be defined by a foreach iteration on line 98. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
132
            $redirectHeader .= $this->getSimpleString('exit();');
133
            $ret .= $this->phpcode->getPhpCodeConditions("\${$ccFieldId}->getVar('{$fieldName}') != 0 && \${$ccFieldId}->getVar('{$fieldName}') < time()", '', '', $redirectHeader);
134
        }
135
        if (false !== mb_strpos($fieldName, 'date')) {
136
            $ret .= $this->phpcode->getPhpCodeCommentLine('Date', $ucfFieldName);
137
            $redirectHeader .= $this->getSimpleString('exit();');
138
            $ret .= $this->phpcode->getPhpCodeConditions("\${$ccFieldId}->getVar('{$fieldName}') != 0 && \${$ccFieldId}->getVar('{$fieldName}') < time()", '', '', $redirectHeader);
139
        }
140
        if (false !== mb_strpos($fieldName, 'time')) {
141
            $ret .= $this->phpcode->getPhpCodeCommentLine('Time', $ucfFieldName);
142
            $redirectHeader .= $this->getSimpleString('exit();');
143
            $ret .= $this->phpcode->getPhpCodeConditions("\${$ccFieldId}->getVar('{$fieldName}') != 0 && \${$ccFieldId}->getVar('{$fieldName}') < time()", '', '', $redirectHeader);
144
        }
145
        $ret .= $this->xc->getXcGet($tableName, $ccFieldId, '', true);
146
        $gperm = $this->xc->getXcCheckRight('!$gpermHandler', "{$moduleDirname}_view", "\${$ccFieldId}->getVar('{$fieldId}')", '$groups', "\$GLOBALS['xoopsModule']->getVar('mid')", true);
147
        $ret .= $this->phpcode->getPhpCodeCommentLine('Verify permissions');
148
        $noPerm = $this->xc->getXcRedirectHeader("{$stuModuleDirname}_URL . '/index.php'", '', '3', '_NOPERM', false, "\t");
149
        $noPerm .= $this->getSimpleString('exit();', "\t");
150
        $ret .= $this->phpcode->getPhpCodeConditions($gperm, '', '', $noPerm);
151
        $ret .= $this->xc->getXcGetValues($tableName, $tableSoleName, '', true);
152
        $contentForeach = $this->xc->getXcXoopsTplAppend('"{$k}"', '$v', "\t");
153
        $ret .= $this->phpcode->getPhpCodeForeach($tableSoleName, false, 'k', 'v', $contentForeach);
154
        $ret .= $this->xc->getXcTplAssign('xoops_sitename', "\$GLOBALS['xoopsConfig']['sitename']");
155
        $getVar = $this->xc->getXcGetVar('', $tableSoleName, $fieldMain, true);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $fieldMain does not seem to be defined for all execution paths leading up to this point.
Loading history...
156
        $stripTags = $this->phpcode->getPhpCodeStripTags('', $getVar . ' - ' . "{$language}PRINT" . ' - ' . "\$GLOBALS['xoopsModule']->name()", true);
157
        $ret .= $this->xc->getXcTplAssign('xoops_pagetitle', $stripTags);
158
        $ret .= $this->xc->getXcTplDisplay($tableName . '_print.tpl', '', false);
159
160
        return $ret;
161
    }
162
163
    /**
164
     *  @public function render
165
     *  @param null
166
     * @return bool|string
167
     */
168
    public function render()
169
    {
170
        $module = $this->getModule();
171
        $filename = $this->getFileName();
172
        $moduleDirname = $module->getVar('mod_dirname');
173
        $language = $this->getLanguage($moduleDirname, 'MA');
174
        $content = $this->getHeaderFilesComments($module, $filename);
175
        $content .= $this->getUserPrint($moduleDirname, $language);
176
177
        $this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
178
179
        return $this->renderFile();
180
    }
181
}
182