Issues (4714)

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.

src/Intraface/functions.php (15 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
// amountToOutput
3 View Code Duplication
if (!function_exists('amountToOutput')) {
4
    /**
5
     * This function is dynamically redefinable.
6
     * @see $GLOBALS['_global_function_callback_e']
7
     */
8
    function amountToOutput($args)
0 ignored issues
show
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
amountToOutput uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
9
    {
10
        $args = func_get_args();
11
        return call_user_func_array($GLOBALS['_global_function_callback_amountToOutput'], $args);
12
    }
13
    if (!isset($GLOBALS['_global_function_callback_amountToOutput'])) {
14
        $GLOBALS['_global_function_callback_amountToOutput'] = null;
15
    }
16
}
17
18
$GLOBALS['_global_function_callback_amountToOutput'] = 'intraface_AmountToOutput';
19
20
/**
21
 * Outputs country specific notation
22
 * @todo Add information about the country
23
 */
24
function amountToOutput($amount)
0 ignored issues
show
The function amountToOutput() has been defined more than once; this definition is ignored, only the first definition in this file (L8-12) is considered.

This check looks for functions that have already been defined in the same file.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
25
{
26
    return number_format($amount, 2, ',', '.');
27
}
28
29
// amountToForm
30 View Code Duplication
if (!function_exists('amountToForm')) {
31
    /**
32
     * This function is dynamically redefinable.
33
     * @see $GLOBALS['_global_function_callback_e']
34
     */
35
    function amountToForm($args)
0 ignored issues
show
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
amountToForm uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
36
    {
37 2
        $args = func_get_args();
38 2
        return call_user_func_array($GLOBALS['_global_function_callback_amountToForm'], $args);
39
    }
40
    if (!isset($GLOBALS['_global_function_callback_amountToForm'])) {
41
        $GLOBALS['_global_function_callback_amountToForm'] = null;
42
    }
43
}
44
45
$GLOBALS['_global_function_callback_amountToForm'] = 'intraface_AmountToForm';
46
47
48
/**
49
 * Outputs country specific amounts in the forms
50
 */
51
function intraface_amountToForm($amount)
52
{
53 2
    return number_format($amount, 2, ',', '');
54
}
55
56
// autoop()
57 View Code Duplication
if (!function_exists('autoop')) {
58
    /**
59
     * This function is dynamically redefinable.
60
     * @see $GLOBALS['_global_function_callback_email']
61
     */
62
    function autoop($args)
0 ignored issues
show
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
autoop uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
63
    {
64
        $args = func_get_args();
65
        return call_user_func_array($GLOBALS['_global_function_callback_autoop'], $args);
66
    }
67
    if (!isset($GLOBALS['_global_function_callback_autoop'])) {
68
        $GLOBALS['_global_function_callback_autoop'] = null;
69
    }
70
}
71
72
function intraface_autoop($text)
73
{
74
    require_once 'markdown.php';
75
    require_once 'smartypants.php';
76
77
    $text = MarkDown($text);
78
    $text = SmartyPants($text);
79
    return $text;
80
}
81
82
$GLOBALS['_global_function_callback_autoop'] = 'intraface_autoop';
83
84
// autoop()
85 View Code Duplication
if (!function_exists('autohtml')) {
86
    /**
87
     * This function is dynamically redefinable.
88
     * @see $GLOBALS['_global_function_callback_email']
89
     */
90
    function autohtml($args)
0 ignored issues
show
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
autohtml uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
91
    {
92
        $args = func_get_args();
93
        return call_user_func_array($GLOBALS['_global_function_callback_autohtml'], $args);
94
    }
95
    if (!isset($GLOBALS['_global_function_callback_autohtml'])) {
96
        $GLOBALS['_global_function_callback_autohtml'] = null;
97
    }
98
}
99
100
function intraface_autohtml($text)
101
{
102
    require_once 'markdown.php';
103
    require_once 'smartypants.php';
104
105
    $text = nl2br($text);
106
    $text = MarkDown($text);
107
    $text = SmartyPants($text);
108
    echo $text;
109
}
110
111
$GLOBALS['_global_function_callback_autohtml'] = 'intraface_autohtml';
112
113
// Dynamic global functions
114 View Code Duplication
if (!function_exists('safeToDb')) {
115
    /**
116
     * This function is dynamically redefinable.
117
     * @see $GLOBALS['_global_function_callback_e']
118
     */
119
    function safeToDb($args)
0 ignored issues
show
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
safeToDb uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
120
    {
121 226
        $args = func_get_args();
122 226
        return call_user_func_array($GLOBALS['_global_function_callback_safetodb'], $args);
123
    }
124
    if (!isset($GLOBALS['_global_function_callback_safetodb'])) {
125
        $GLOBALS['_global_function_callback_safetodb'] = null;
126
    }
127
}
128
$GLOBALS['_global_function_callback_safetodb'] = 'intraface_safetodb';
129
130
/**
131
 * Function to be called before putting data in the database
132
 *
133
 * @author  Lars Olesen <[email protected]>
134
 */
135
function intraface_safetodb($data)
136
{
137 226
    if (is_object($data)) {
138 6
        return $data;
139
    }
140
141 226
    if (is_array($data)) {
142 197
        return array_map('safeToDb', $data);
143
    }
144
145 224
    if (get_magic_quotes_gpc()) {
146
        $data = stripslashes($data);
147
    }
148
149 224
    return mysql_escape_string($data);
0 ignored issues
show
Deprecated Code introduced by
The function mysql_escape_string() has been deprecated with message: Deprecated as of PHP 5.3.0. Relying on this feature is highly discouraged (use mysql_real_escape_string() instead).

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
150
}
151
152
//Dynamic global functions
153 View Code Duplication
if (!function_exists('filesize_readable')) {
154
    /**
155
     * This function is dynamically redefinable.
156
     * @see $GLOBALS['_global_function_callback_e']
157
     */
158
    function filesize_readable($args)
0 ignored issues
show
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
filesize_readable uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
159
    {
160
        $args = func_get_args();
161
        return call_user_func_array($GLOBALS['_global_function_callback_filesize_readable'], $args);
162
    }
163
    if (!isset($GLOBALS['_global_function_callback_filesize_readable'])) {
164
        $GLOBALS['_global_function_callback_filesize_readable'] = null;
165
    }
166
}
167
$GLOBALS['_global_function_callback_filesize_readable'] = 'intraface_filesize_readable';
168
169
/*
170
 * Function to convert filesize to readable sizes.
171
 * from: http://us3.php.net/filesize
172
 */
173
function intraface_filesize_readable($size, $retstring = null)
174
{
175
    // adapted from code at http://aidanlister.com/repos/v/function.size_readable.php
176
    $sizes = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
177
    if ($retstring === null) {
178
        $retstring = '%01.2f %s';
179
    }
180
    $lastsizestring = end($sizes);
181
    foreach ($sizes as $sizestring) {
182
        if ($size < 1024) {
183
            break;
184
        }
185
        if ($sizestring != $lastsizestring) {
186
            $size /= 1024;
187
        }
188
    }
189
    if ($sizestring == $sizes[0]) {
0 ignored issues
show
The variable $sizestring seems to be defined by a foreach iteration on line 181. 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...
190
        // Bytes aren't normally fractional
191
        $retstring = '%01d %s';
192
    }
193
    return sprintf($retstring, $size, $sizestring);
194
}
195
196
function intrafaceBackendErrorhandler($errno, $errstr, $errfile, $errline, $errcontext)
197
{
198
    if (!defined('ERROR_LOG')) {
199
        define('ERROR_LOG', dirname(__FILE__) . '/../log/error.log');
200
    }
201
    $errorhandler = new ErrorHandler;
202
    if (!defined('ERROR_LEVEL_CONTINUE_SCRIPT')) {
203
        define('ERROR_LEVEL_CONTINUE_SCRIPT', E_ALL);
204
    }
205
    $errorhandler->addObserver(new ErrorHandler_Observer_File(ERROR_LOG));
206
    // From php.net "~ $a: Bits that are set in $a are not set, and vice versa." That means the observer is used on everything but ERROR_LEVEL_CONTINUE_SCRIPT
207
    $errorhandler->addObserver(new ErrorHandler_Observer_Echo, ~ ERROR_LEVEL_CONTINUE_SCRIPT);
208
    return $errorhandler->handleError($errno, $errstr, $errfile, $errline, $errcontext);
209
}
210
211
function intrafaceBackendExceptionhandler($e)
212
{
213
    $errorhandler = new ErrorHandler;
214
    $errorhandler->addObserver(new ErrorHandler_Observer_File(ERROR_LOG));
215
    $errorhandler->addObserver(new ErrorHandler_Observer_Echo);
216
    return $errorhandler->handleException($e);
217
}
218
219
function intrafaceFrontendErrorhandler($errno, $errstr, $errfile, $errline, $errcontext)
220
{
221
    $errorhandler = new ErrorHandler;
222
    $errorhandler->addObserver(new ErrorHandler_Observer_File(ERROR_LOG));
223
    if (defined('SERVER_STATUS') && SERVER_STATUS == 'TEST') {
224
        // From php.net "~ $a: Bits that are set in $a are not set, and vice versa." That means the observer is used on everything but ERROR_LEVEL_CONTINUE_SCRIPT
225
        $errorhandler->addObserver(new ErrorHandler_Observer_BlueScreen, ~ ERROR_LEVEL_CONTINUE_SCRIPT);
226
    } else {
227
        $errorhandler->addObserver(new ErrorHandler_Observer_User, ~ ERROR_LEVEL_CONTINUE_SCRIPT); // See description of ~ above
228
    }
229
    return $errorhandler->handleError($errno, $errstr, $errfile, $errline, $errcontext);
230
}
231
232
function intrafaceFrontendExceptionhandler($e)
233
{
234
    $errorhandler = new ErrorHandler;
235
    $errorhandler->addObserver(new ErrorHandler_Observer_File(ERROR_LOG));
236
    if (defined('SERVER_STATUS') && SERVER_STATUS == 'TEST') {
237
        $errorhandler->addObserver(new ErrorHandler_Observer_BlueScreen);
238
    } else {
239
        $errorhandler->addObserver(new ErrorHandler_Observer_User);
240
    }
241
    return $errorhandler->handleException($e);
242
}
243