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/mem_cache.php (8 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
if (!defined('BASEPATH')) {
4
    exit('No direct script access allowed');
5
}
6
7
/**
8
 * Image CMS
9
 * Memcache Class
10
 *
11
 */
12
class Mem_cache extends Memcache
13
{
14
15
    public $CI;
16
17
    public $get = 0;
18
19
    public $set = 0;
20
21
    public $key_prefix = '';
22
23
    //Cache config
24
    public $_Config = [
25
                       'store' => 'cache',
26
                       'ttl'   => 3600,
27
                      ];
28
29
    public function __construct() {
30
31
        $this->CI = & get_instance();
32
        $this->connect('localhost', 11211) or die('Could not connect to memcache server.');
33
        $this->key_prefix = base_url();
34
    }
35
36
    /**
37
     * Fetch Cache
38
     *
39
     * @param string $key
40
     *
41
     * @return mixed
0 ignored issues
show
Consider making the return type a bit more specific; maybe use false|string|string[].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
42
     */
43
    public function fetch($key, $group = FALSE) {
0 ignored issues
show
The parameter $group 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...
44
45
        if (($ret = $this->_fetch($key)) === false) {
46
            return false;
47
        } else {
48
            return $ret;
49
        }
50
    }
51
52
    public function _fetch($key) {
53
54
        $key = $this->generatekey($key);
55
56
        $this->get++;
57
58
        return $this->get($key);
59
    }
60
61
    /**
62
     * Fetch cached function
63
     */
64
    public function fetch_func($object, $func, $args = []) {
65
66
        $key = $this->generatekey(get_class($object) . '::' . $func . '::' . serialize($args));
67
68
        $this->get++;
69
70
        return $this->get($key);
71
    }
72
73
    /**
74
     * Store Cache Item
75
     *
76
     * @param string  $key
77
     * @param mixed   $data
78
     * @param int     $ttl
79
     *
80
     * @return bool
81
     */
82
    public function store($key, $data, $ttl = false, $group = false) {
0 ignored issues
show
The parameter $group 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...
83
84
        if (!$ttl) {
85
            $ttl = $this->_Config['ttl'];
86
        }
87
88
        $this->set($this->generatekey($key), $data, FALSE, $ttl);
89
90
        $this->set++;
91
        return TRUE;
92
    }
93
94
    /**
95
     * Cache Function
96
     *
97
     * @return mixed
98
     * @access public
99
     */
100
    public function call($func = [], $args = [], $ttl = FALSE) {
0 ignored issues
show
The parameter $func 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...
101
102
        if ($ttl === FALSE) {
103
            $ttl = $this->_Config['ttl'];
0 ignored issues
show
$ttl is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
104
        }
105
106
        $arguments = func_get_args();
107
108
        //class_name::metohd
109
        $key = get_class($arguments[0][0]) . '::' . $arguments[0][1] . '::' . serialize($args);
110
111 View Code Duplication
        if (($cache = $this->fetch($key)) !== false) {
112
            return $cache;
113
        } else {
114
            $target = array_shift($arguments);
115
            $result = call_user_func_array($target, $args);
116
117
            if (!$this->store($key, $result, false)) {
118
                return FALSE;
119
            }
120
121
            return $result;
122
        }
123
    }
124
125
    /**
126
     * Clean all cache objects
127
     *
128
     * @return void
129
     */
130
    public function Clean() {
131
132
        $this->flush();
133
    }
134
135
    /**
136
     * Clean all cache objects
137
     *
138
     * @return void
139
     */
140
    public function delete_group() {
141
142
        $this->flush();
143
    }
144
145
    /**
146
     * Delete Cache Item
147
     *
148
     * @param string $key - cache item key
149
     *
150
     * @return bool
0 ignored issues
show
Should the return type not be boolean|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
151
     */
152
    public function delete($key) {
153
154
        $this->delete($this->generatekey($key));
155
    }
156
157
    /**
158
     * Delete Cached Function
159
     *
160
     * @return bool
0 ignored issues
show
Should the return type not be boolean|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
161
     */
162
    public function delete_func($object, $func, $args = []) {
163
164
        $file = $this->generatekey(get_class($object) . '::' . $func . '::' . serialize($args));
165
        $this->delete($file);
166
    }
167
168
    /**
169
     * Delete All Cache Items
170
     *
171
     * @return bool
0 ignored issues
show
Should the return type not be boolean|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
172
     * @access public
173
     */
174
    public function delete_all() {
175
176
        $this->flush();
177
    }
178
179
    /**
180
     * Generate key
181
     *
182
     * @param  $key
183
     * @return string */
184
    public function generatekey($key) {
185
186
        return md5($this->key_prefix . $key);
187
    }
188
189
}
190
191
/* End of cache.php */