Issues (431)

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.

include/classes/mysqlims.class.php (7 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
 * This class will run queries on master/slave servers depending on the query itself.
4
 */
5
class mysqlims extends mysqli
6
{
7
    private $mysqliW;
8
    private $mysqliR = null;
9
    private $slave = false;
10
    public $lastused = null;
11
    
12
    /*
13
     * Pass main and slave connection arrays to the constructor, and strict as true/false
14
     *
15
     * @param array $main
16
     * @param array $slave
17
     * @param boolean $strict
18
     *
19
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
20
     */
21
    public function __construct($main, $slave = false, $strict = false)
22
    {
23
        if ($strict) {
24
            $this->mysqliW = new mysqli_strict($main['host'],
0 ignored issues
show
The call to mysqli_strict::__construct() has too many arguments starting with $main['host'].

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
25
                $main['user'], $main['pass'],
26
                $main['name'], $main['port']);
27 View Code Duplication
            if ($slave && is_array($slave) && isset($slave['enabled']) && $slave['enabled']
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
                === true) {
29
                $this->mysqliR = new mysqli_strict($slave['host'],
0 ignored issues
show
The call to mysqli_strict::__construct() has too many arguments starting with $slave['host'].

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
30
                    $slave['user'], $slave['pass'],
31
                    $slave['name'], $slave['port']);
32
                $this->slave = true;
33
            }
34
        } else {
35
            $this->mysqliW = new mysqli($main['host'],
36
                $main['user'], $main['pass'],
37
                $main['name'], $main['port']);
38 View Code Duplication
            if ($slave && is_array($slave) && isset($slave['enabled']) && $slave['enabled']
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
39
                === true) {
40
                $this->mysqliR = new mysqli($slave['host'],
41
                    $slave['user'], $slave['pass'],
42
                    $slave['name'], $slave['port']);
43
                $this->slave = true;
44
            }
45
        }
46
47
        if ($this->mysqliW->connect_errno) {
48
            throw new Exception("Failed to connect to MySQL: (".$this->mysqliW->connect_errno.") ".$this->mysqliW->connect_error);
49
        }
50
51
        if ($this->slave === true && $this->mysqliR->connect_errno) {
52
            throw new Exception("Failed to connect to MySQL: (".$this->mysqliR->connect_errno.") ".$this->mysqliR->connect_error);
53
        }
54
    }
55
56
    /*
57
     * Override standard mysqli_prepare to select master/slave server
58
     * @param $string query
59
     *
60
     * @return mysqli_stmt
61
     */
62 View Code Duplication
    public function prepare($query)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
63
    {
64
        if (stripos($query, "SELECT") && stripos($query, "FOR UPDATE") === false && stripos($query, "INSERT") === false  && $this->slave !== false) {
65
            $this->lastused = $this->mysqliR;
66
            return $this->mysqliR->prepare($query);
67
        } else {
68
            $this->lastused = $this->mysqliW;
69
            return $this->mysqliW->prepare($query);
70
        }
71
    }
72
73
    /*
74
     * Override standard mysqli_query to select master/slave server
75
     * @param string $query
76
     * @param int $resultmode
77
     *
78
     * @return boolean
79
     * @return mixed
80
     */
81 View Code Duplication
    public function query($query, $resultmode = MYSQLI_STORE_RESULT)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
82
    {
83
        if (stripos($query, "SELECT") && stripos($query, "FOR UPDATE") === false && stripos($query, "INSERT") === false && $this->slave !== false) {/* Use readonly server */
84
            $this->lastused = $this->mysqliR;
85
            return $this->mysqliR->query($query, $resultmode);
86
        } else {
87
            $this->lastused = $this->mysqliW;
88
            return $this->mysqliW->query($query, $resultmode);
89
        }
90
    }
91
}
92