Issues (366)

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.

libs/altsys/class/D3LanguageManager.class.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
/**
4
 * Class D3LanguageManager
5
 */
6
class D3LanguageManager
7
{
8
    public $default_language = 'english';
9
10
    public $language = 'english';
11
12
    public $salt;
13
14
    public $cache_path;
15
16
    public $cache_prefix = 'lang';
17
18
    public $my_language = false;
19
20
    //HACK by domifara
21
22
    //public function D3LanguageManager()
23
24
    /**
25
     * D3LanguageManager constructor.
26
     */
27
28
    public function __construct()
29
    {
30
        $this->language = preg_replace('/[^0-9a-zA-Z_-]/', '', @$GLOBALS['xoopsConfig']['language']);
31
32
        $this->salt = mb_substr(md5(XOOPS_ROOT_PATH . XOOPS_DB_USER . XOOPS_DB_PREFIX), 0, 6);
33
34
        $this->cache_path = XOOPS_TRUST_PATH . '/cache';
35
36
        if (defined('ALTSYS_MYLANGUAGE_ROOT_PATH') && file_exists(ALTSYS_MYLANGUAGE_ROOT_PATH)) {
37
            $this->my_language = ALTSYS_MYLANGUAGE_ROOT_PATH;
0 ignored issues
show
Documentation Bug introduced by
The property $my_language was declared of type boolean, but ALTSYS_MYLANGUAGE_ROOT_PATH is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
38
        }
39
    }
40
41
    //HACK by domifara for php5.3+
42
43
    //function getInstance( $conn = null )
44
45
    /**
46
     * @param null $conn
47
     * @return \D3LanguageManager
48
     */
49
50
    public static function getInstance($conn = null)
51
    {
52
        static $instance;
53
54
        if (!isset($instance)) {
55
            $instance = new self();
56
        }
57
58
        return $instance;
59
    }
60
61
    /**
62
     * @param      $resource
63
     * @param      $mydirname
64
     * @param null $mytrustdirname
65
     * @param bool $read_once
66
     */
67
68
    public function read($resource, $mydirname, $mytrustdirname = null, $read_once = true)
69
    {
70
        $d3file = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/mytrustdirname.php';
71
72
        if (empty($mytrustdirname) && is_file($d3file)) {
73
            require $d3file;
74
        }
75
76
        if (empty($this->language)) {
77
            $this->language = preg_replace('/[^0-9a-zA-Z_-]/', '', @$GLOBALS['xoopsConfig']['language']);
78
        }
79
80
        $cache_file = $this->getCacheFileName($resource, $mydirname);
81
82
        $root_file = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/language/' . $this->language . '/' . $resource;
83
84
        // language overriding by XOOPS_ROOT_PATH/my_language
85
86
        if ($this->my_language) {
87
            $mylang_file = $this->my_language . '/modules/' . $mydirname . '/' . $this->language . '/' . $resource;
88
89
            if (is_file($mylang_file)) {
90
                require_once $mylang_file;
91
            }
92
93
            $original_error_level = error_reporting();
94
95
            error_reporting($original_error_level & ~E_NOTICE);
96
        }
97
98
        if (empty($mytrustdirname)) {
99
            // conventional module
100
101
            $default_file = XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/language/' . $this->default_language . '/' . $resource;
102
103
            if (is_file($cache_file)) {
104
                require_once $cache_file;
105
            } elseif (is_file($root_file)) {
106
                require_once $root_file;
107
            } elseif (is_file($default_file)) {
108
                // fall back english
109
110
                require_once $default_file;
111
            }
112
        } else {
113
            // D3 modules
114
115
            $trust_file = XOOPS_TRUST_PATH . '/modules/' . $mytrustdirname . '/language/' . $this->language . '/' . $resource;
116
117
            $default_file = XOOPS_TRUST_PATH . '/modules/' . $mytrustdirname . '/language/' . $this->default_language . '/' . $resource;
118
119
            if (is_file($cache_file)) {
120
                require_once $cache_file;
121
            } elseif (is_file($root_file)) {
122
                require_once $root_file;
123
            } elseif (is_file($trust_file)) {
124
                if ($read_once) {
125
                    require_once $trust_file;
126
                } else {
127
                    require $trust_file;
128
                }
129
            } elseif (is_file($default_file)) {
130
                // fall back english
131
132
                if ($read_once) {
133
                    require_once $default_file;
134
                } else {
135
                    require $default_file;
136
                }
137
            }
138
        }
139
140
        if ($this->my_language) {
141
            error_reporting($original_error_level);
0 ignored issues
show
The variable $original_error_level does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
142
        }
143
    }
144
145
    /**
146
     * @param      $resource
147
     * @param      $mydirname
148
     * @param null $language
149
     * @return string
150
     */
151
152
    public function getCacheFileName($resource, $mydirname, $language = null)
153
    {
154
        if (empty($language)) {
155
            $language = $this->language;
156
        }
157
158
        return $this->cache_path . '/' . $this->cache_prefix . '_' . $this->salt . '_' . $mydirname . '_' . $language . '_' . $resource;
159
    }
160
}
161