This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 | * Nip Framework |
||
5 | * |
||
6 | * @category Nip |
||
7 | * @copyright 2009 Nip Framework |
||
8 | * @license http://www.opensource.org/licenses/mit-license.php The MIT License |
||
9 | * @version SVN: $Id: Handler.php 70 2009-04-29 11:47:12Z victor.stanciu $ |
||
10 | */ |
||
11 | class Nip_File_Handler |
||
0 ignored issues
–
show
|
|||
12 | { |
||
13 | const MODE_READ = "r"; |
||
14 | const MODE_WRITE = "w"; |
||
15 | const MODE_APPEND = "a"; |
||
16 | |||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | public $name; |
||
22 | |||
23 | /** |
||
24 | * @var null|string |
||
25 | */ |
||
26 | public $path = null; |
||
27 | |||
28 | /** |
||
29 | * @var null|string |
||
30 | */ |
||
31 | public $url = null; |
||
32 | |||
33 | public $data; |
||
34 | public $extension; |
||
35 | public $permissions = 0777; |
||
36 | protected $handle = null; |
||
37 | |||
38 | /** |
||
39 | * Nip_File_Handler constructor. |
||
40 | * @param bool $data |
||
41 | */ |
||
42 | public function __construct($data = false) |
||
43 | { |
||
44 | if ($data) { |
||
45 | foreach ($data as $key => $value) { |
||
0 ignored issues
–
show
|
|||
46 | $this->{$key} = $value; |
||
47 | } |
||
48 | } |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @param $name |
||
53 | * @param $arguments |
||
54 | * @return $this |
||
55 | */ |
||
56 | public function __call($name, $arguments) |
||
57 | { |
||
58 | if (substr($name, 0, 3) == 'set') { |
||
59 | $name = str_replace("set", "", $name); |
||
60 | $name{0} = strtolower($name{0}); |
||
61 | |||
62 | $this->$name = $arguments[0]; |
||
63 | return $this; |
||
64 | } else { |
||
65 | trigger_error("Method [$name] not defined", E_USER_ERROR); |
||
66 | } |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @param $upload |
||
71 | */ |
||
72 | public function upload($upload) |
||
73 | { |
||
74 | move_uploaded_file($upload["tmp_name"], $this->path); |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * @return $this |
||
79 | */ |
||
80 | public function delete() |
||
81 | { |
||
82 | return Nip_File_System::instance()->deleteFile($this->path); |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * @return $this|false |
||
87 | */ |
||
88 | public function gzip() |
||
89 | { |
||
90 | if (function_exists("gzencode")) { |
||
91 | $this->data = gzencode($this->data, 9, FORCE_GZIP); |
||
92 | } else { |
||
93 | return false; |
||
94 | } |
||
95 | return $this; |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * @param bool $data |
||
100 | * @param string $mode |
||
101 | */ |
||
102 | public function write($data = false, $mode = self::MODE_APPEND) |
||
103 | { |
||
104 | if ($data) { |
||
105 | $this->setData($data); |
||
0 ignored issues
–
show
The method
setData does not exist on object<Nip_File_Handler> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
106 | } |
||
107 | |||
108 | $this->open($mode); |
||
109 | fwrite($this->handle, $this->data); |
||
110 | $this->close($mode); |
||
0 ignored issues
–
show
The call to
Nip_File_Handler::close() has too many arguments starting with $mode .
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 ![]() |
|||
111 | |||
112 | chmod($this->path, $this->permissions); |
||
113 | } |
||
114 | |||
115 | /** |
||
116 | * @param bool $data |
||
117 | */ |
||
118 | public function rewrite($data = false) |
||
119 | { |
||
120 | return $this->write($data, self::MODE_WRITE); |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * @param string $mode |
||
125 | * @return $this |
||
126 | */ |
||
127 | public function open($mode = self::MODE_READ) |
||
128 | { |
||
129 | $this->handle = fopen($this->path, $mode); |
||
130 | return $this; |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * @return $this |
||
135 | */ |
||
136 | public function close() |
||
137 | { |
||
138 | if ($this->handle) { |
||
139 | fclose($this->handle); |
||
140 | $this->handle = null; |
||
141 | } else { |
||
142 | trigger_error("Attempting to close an unopened file", E_USER_WARNING); |
||
143 | } |
||
144 | |||
145 | return $this; |
||
146 | } |
||
147 | |||
148 | |||
149 | /** |
||
150 | * @return null|string |
||
151 | */ |
||
152 | public function getUrl() |
||
153 | { |
||
154 | if ($this->url === null) { |
||
155 | $this->initUrl(); |
||
156 | } |
||
157 | return $this->url; |
||
158 | } |
||
159 | |||
160 | |||
161 | public function initUrl() |
||
162 | { |
||
163 | $this->url = ''; |
||
164 | } |
||
165 | |||
166 | /** |
||
167 | * @return null|string |
||
168 | */ |
||
169 | public function getPath() |
||
170 | { |
||
171 | if ($this->path === null) { |
||
172 | $this->initPath(); |
||
173 | } |
||
174 | return $this->path; |
||
175 | } |
||
176 | |||
177 | public function initPath() |
||
178 | { |
||
179 | $this->path = ''; |
||
180 | } |
||
181 | |||
182 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.