Issues (1177)

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.

application/libraries/MY_Lang.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
2
3
if (!defined('BASEPATH')) {
4
    exit('No direct script access allowed');
5
}
6
7
/**
8
 * Code Igniter Gettext Extension library
9
 *
10
 * This Library overides the original CI's language class. Needs the  $config['language'] variable set as it_IT or en_EN or fr_FR ...
11
 *
12
 * @package       Gettext Extension
13
 * @author        wokamoto
14
 * @copyright     Copyright (c) 2012
15
 * @license       http://www.gnu.org/licenses/lgpl.txt
16
 * @link
17
 * @version       Version 0.1
18
 * @since         2012 January, 27th
19
 */
20
// ------------------------------------------------------------------------
21
22
class MY_Lang extends CI_Lang
23
{
24
25
    private $ci;
26
27
    private $gettext_language;
28
29
    private $gettext_codeset;
30
31
    private $gettext_domain;
32
33
    private $gettext_path;
34
35
    /**
36
     * The constructor initialize the library
37
     *
38
     * @return MY_Lang
39
     */
40
    public function __construct() {
41
        parent::__construct();
42
    }
43
44
    private function _language() {
45
        static $language;
46
47
        if (!isset($this->ci)) {
48
            $this->ci = & get_instance();
49
        }
50
51
        if (!isset($language)) {
52
            $language = $this->ci->config->item('language');
53
        }
54
55
        if (!isset($language) || !in_array($language, $this->ci->config->item('selectable_languages'))) {
56
            $language = 'english';
57
        }
58
59
        if ($language != $this->ci->config->item('language')) {
60
            $this->ci->config->set_item('language', $language);
61
        }
62
63
        return empty($language) ? 'english' : $language;
64
    }
65
66
    /**
67
     * Load a language file
68
     *
69
     * @access	public
70
     * @param	mixed	the name of the language file to be loaded. Can be an array
71
     * @param	string	the language (english, etc.)
72
     * @return	mixed
73
     */
74
    public function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '') {
75
        return parent::load($langfile, !empty($idiom) ? $idiom : $this->_language(), $return, $add_suffix, $alt_path);
76
    }
77
78
    /**
79
     * This method overides the original load method. Its duty is loading the domain files by config or by default internal settings.
80
     *
81
     * @access	public
82
     * @param	string	$userlang	the language, set as ja_JP or it_IT or en_EN or fr_FR ...
83
     * @param	string	$codeset	the codeset, set as UTF-8 or EUC ...
84
     * @return	bool
85
     */
86
    public function load_gettext($userlang = '', $codeset = '', $textdomain = 'lang', $path = '') {
87
        if (!isset($this->ci)) {
88
            $this->ci = & get_instance();
89
        }
90
91
        $this->gettext_language = $this->language_select(!empty($userlang) ? $userlang : $this->_language());
92
        $this->gettext_codeset = !empty($codeset) ? $codeset : $this->ci->config->item('charset');
93
        $this->gettext_domain = $textdomain;
94
        $this->gettext_path = !empty($path) ? $path : APPPATH . 'language/locale';
95
        log_message('debug', 'Gettext Class language was set by parameter:' . $this->gettext_language . ',' . $this->gettext_codeset);
96
97
        /* put env and set locale */
98
        putenv("LANG={$this->gettext_language}");
99
        setlocale(LC_ALL, $this->gettext_language);
100
101
        /* bind text domain */
102
        $textdomain_path = bindtextdomain($this->gettext_domain, $this->gettext_path);
103
        bind_textdomain_codeset($this->gettext_domain, $this->gettext_codeset);
104
        textdomain($this->gettext_domain);
105
        log_message('debug', 'Gettext Class path: ' . $textdomain_path);
106
        log_message('debug', 'Gettext Class the domain: ' . $this->gettext_domain);
107
108
        return true;
109
    }
110
111
    private function language_select($userlang = '') {
112
        $userlang = !empty($userlang) ? $userlang : $this->_language();
113
114
        switch ($userlang) {
115
            case 'japanese':
116
                $userlang = 'ja_JP';
117
                break;
118
            case 'english':
119
            default:
120
                $userlang = 'en';
121
                break;
122
        }
123
        return $userlang;
124
    }
125
126
    /**
127
     * Fetch a single line of text from the language array
128
     *
129
     * @access	public
130
     * @param	string	$line	the language line
131
     * @return	string
132
     */
133
    public function line($line = '', $params = FALSE) {
134
135
        if ($params !== FALSE || FALSE === ($value = parent::line($line))) {
136
            $value = $this->_trans($line, $params);
137
        }
138
139
        return $value ? $value : $line;
140
    }
141
142
    /**
143
     *  Plural forms added by Tchinkatchuk
144
     *  http://www.codeigniter.com/forums/viewthread/2168/
145
     */
146
147
    /**
148
     * The translator method
149
     *
150
     * @access private
151
     * @param string $original the original string to translate
152
     * @param array $aParams the plural parameters
153
     * @return false|string the string translated
154
     */
155
    private function _trans($original, $aParams = false) {
156
        if (!isset($this->gettext_domain)) {
157
            return false;
158
        }
159
160
        if ($aParams && isset($aParams['plural']) && isset($aParams['count'])) {
161
            $sTranslate = ngettext($original, $aParams['plural'], $aParams['count']);
162
            $sTranslate = $this->replaceDynamically($sTranslate, $aParams);
163
        } else {
164
            $sTranslate = gettext($original);
165
            if (is_array($aParams) && count($aParams)) {
166
                $sTranslate = $this->replaceDynamically($sTranslate, $aParams);
167
            }
168
        }
169
170
        return $sTranslate;
171
    }
172
173
    /**
174
     * Allow dynamic allocation in traduction
175
     *
176
     * @final
177
     * @access private
178
     * @param  string $sString
179
     * @return string
180
     */
181
    private function replaceDynamically($sString) {
182
        $aTrad = [];
183
        for ($i = 1, $iMax = func_num_args(); $i < $iMax; $i++) {
184
            $arg = func_get_arg($i);
185
            if (is_array($arg)) {
186
                foreach ($arg as $key => $sValue) {
187
                    $aTrad['%' . $key] = $sValue;
188
                }
189
            } else {
190
                $aTrad['%' . $key] = $arg;
0 ignored issues
show
The variable $key seems to be defined by a foreach iteration on line 186. Are you sure the iterator is never empty, otherwise this variable is not defined?

It seems like you are relying on a variable being defined by an iteration:

foreach ($a as $b) {
}

// $b is defined here only if $a has elements, for example if $a is array()
// then $b would not be defined here. To avoid that, we recommend to set a
// default value for $b.


// Better
$b = 0; // or whatever default makes sense in your context
foreach ($a as $b) {
}

// $b is now guaranteed to be defined here.
Loading history...
191
            }
192
        }
193
194
        return strtr($sString, $aTrad);
195
    }
196
197
}