phingofficial /
phing
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.
| 1 | <?php |
||||||||
| 2 | |||||||||
| 3 | /** |
||||||||
| 4 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||||
| 5 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||||
| 6 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||||
| 7 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||||
| 8 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||||
| 9 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||||
| 10 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||||
| 11 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||||
| 12 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||||
| 13 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||||
| 14 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||||
| 15 | * |
||||||||
| 16 | * This software consists of voluntary contributions made by many individuals |
||||||||
| 17 | * and is licensed under the LGPL. For more information please see |
||||||||
| 18 | * <http://phing.info>. |
||||||||
| 19 | */ |
||||||||
| 20 | |||||||||
| 21 | namespace Phing\Io; |
||||||||
| 22 | |||||||||
| 23 | use Phing\Exception\BuildException; |
||||||||
| 24 | |||||||||
| 25 | /** |
||||||||
| 26 | * Extended file stream wrapper class which auto-creates directories. |
||||||||
| 27 | * |
||||||||
| 28 | * @author Michiel Rook <[email protected]> |
||||||||
| 29 | */ |
||||||||
| 30 | class ExtendedFileStream |
||||||||
| 31 | { |
||||||||
| 32 | private $fp; |
||||||||
| 33 | |||||||||
| 34 | public static function registerStream() |
||||||||
| 35 | { |
||||||||
| 36 | if (!in_array('efile', stream_get_wrappers())) { |
||||||||
| 37 | stream_wrapper_register('efile', __CLASS__); |
||||||||
| 38 | } |
||||||||
| 39 | } |
||||||||
| 40 | |||||||||
| 41 | public static function unregisterStream() |
||||||||
| 42 | { |
||||||||
| 43 | stream_wrapper_unregister('efile'); |
||||||||
| 44 | } |
||||||||
| 45 | |||||||||
| 46 | // @codingStandardsIgnoreStart |
||||||||
| 47 | |||||||||
| 48 | /** |
||||||||
| 49 | * @param $path |
||||||||
| 50 | * @param $mode |
||||||||
| 51 | * @param $options |
||||||||
| 52 | * @param $opened_path |
||||||||
| 53 | * |
||||||||
| 54 | * @throws IOException |
||||||||
| 55 | * |
||||||||
| 56 | * @return bool |
||||||||
| 57 | */ |
||||||||
| 58 | public function stream_open($path, $mode, $options, &$opened_path) |
||||||||
|
0 ignored issues
–
show
The parameter
$options is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||||
| 59 | { |
||||||||
| 60 | // if we're on Windows, urldecode() the path again |
||||||||
| 61 | if ('\\' == FileSystem::getFileSystem()->getSeparator()) { |
||||||||
| 62 | $path = urldecode($path); |
||||||||
| 63 | } |
||||||||
| 64 | |||||||||
| 65 | $filepath = substr($path, 8); |
||||||||
| 66 | |||||||||
| 67 | $this->createDirectories(dirname($filepath)); |
||||||||
| 68 | |||||||||
| 69 | $this->fp = fopen($filepath, $mode); |
||||||||
| 70 | |||||||||
| 71 | if (!$this->fp) { |
||||||||
| 72 | throw new BuildException("Unable to open stream for path {$path}"); |
||||||||
| 73 | } |
||||||||
| 74 | |||||||||
| 75 | return true; |
||||||||
| 76 | } |
||||||||
| 77 | |||||||||
| 78 | public function stream_close() |
||||||||
| 79 | { |
||||||||
| 80 | fclose($this->fp); |
||||||||
| 81 | $this->fp = null; |
||||||||
| 82 | } |
||||||||
| 83 | |||||||||
| 84 | /** |
||||||||
| 85 | * @param $count |
||||||||
| 86 | * |
||||||||
| 87 | * @return string |
||||||||
| 88 | */ |
||||||||
| 89 | public function stream_read($count) |
||||||||
| 90 | { |
||||||||
| 91 | return fread($this->fp, $count); |
||||||||
| 92 | } |
||||||||
| 93 | |||||||||
| 94 | /** |
||||||||
| 95 | * @param $data |
||||||||
| 96 | * |
||||||||
| 97 | * @return int |
||||||||
| 98 | */ |
||||||||
| 99 | public function stream_write($data) |
||||||||
| 100 | { |
||||||||
| 101 | return fwrite($this->fp, $data); |
||||||||
| 102 | } |
||||||||
| 103 | |||||||||
| 104 | /** |
||||||||
| 105 | * @return bool |
||||||||
| 106 | */ |
||||||||
| 107 | public function stream_eof() |
||||||||
| 108 | { |
||||||||
| 109 | return feof($this->fp); |
||||||||
| 110 | } |
||||||||
| 111 | |||||||||
| 112 | /** |
||||||||
| 113 | * @return int |
||||||||
| 114 | */ |
||||||||
| 115 | public function stream_tell() |
||||||||
| 116 | { |
||||||||
| 117 | return ftell($this->fp); |
||||||||
| 118 | } |
||||||||
| 119 | |||||||||
| 120 | /** |
||||||||
| 121 | * @param $offset |
||||||||
| 122 | * @param $whence |
||||||||
| 123 | * |
||||||||
| 124 | * @return int |
||||||||
| 125 | */ |
||||||||
| 126 | public function stream_seek($offset, $whence) |
||||||||
| 127 | { |
||||||||
| 128 | return fseek($this->fp, $offset, $whence); |
||||||||
| 129 | } |
||||||||
| 130 | |||||||||
| 131 | /** |
||||||||
| 132 | * @return bool |
||||||||
| 133 | */ |
||||||||
| 134 | public function stream_flush() |
||||||||
| 135 | { |
||||||||
| 136 | return fflush($this->fp); |
||||||||
| 137 | } |
||||||||
| 138 | |||||||||
| 139 | /** |
||||||||
| 140 | * @return array |
||||||||
| 141 | */ |
||||||||
| 142 | public function stream_stat() |
||||||||
| 143 | { |
||||||||
| 144 | return fstat($this->fp); |
||||||||
| 145 | } |
||||||||
| 146 | |||||||||
| 147 | // @codingStandardsIgnoreEnd |
||||||||
| 148 | |||||||||
| 149 | /** |
||||||||
| 150 | * @param $path |
||||||||
| 151 | * |
||||||||
| 152 | * @return bool |
||||||||
| 153 | */ |
||||||||
| 154 | public function unlink($path) |
||||||||
|
0 ignored issues
–
show
The parameter
$path is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||||
| 155 | { |
||||||||
| 156 | return false; |
||||||||
| 157 | } |
||||||||
| 158 | |||||||||
| 159 | /** |
||||||||
| 160 | * @param $path_from |
||||||||
| 161 | * @param $path_to |
||||||||
| 162 | * |
||||||||
| 163 | * @return bool |
||||||||
| 164 | */ |
||||||||
| 165 | public function rename($path_from, $path_to) |
||||||||
|
0 ignored issues
–
show
The parameter
$path_to is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$path_from is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||||
| 166 | { |
||||||||
| 167 | return false; |
||||||||
| 168 | } |
||||||||
| 169 | |||||||||
| 170 | /** |
||||||||
| 171 | * @param $path |
||||||||
| 172 | * @param $mode |
||||||||
| 173 | * @param $options |
||||||||
| 174 | * |
||||||||
| 175 | * @return bool |
||||||||
| 176 | */ |
||||||||
| 177 | public function mkdir($path, $mode, $options) |
||||||||
|
0 ignored issues
–
show
The parameter
$path is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$mode is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$options is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||||
| 178 | { |
||||||||
| 179 | return false; |
||||||||
| 180 | } |
||||||||
| 181 | |||||||||
| 182 | /** |
||||||||
| 183 | * @param $path |
||||||||
| 184 | * @param $options |
||||||||
| 185 | * |
||||||||
| 186 | * @return bool |
||||||||
| 187 | */ |
||||||||
| 188 | public function rmdir($path, $options) |
||||||||
|
0 ignored issues
–
show
The parameter
$options is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$path is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||||
| 189 | { |
||||||||
| 190 | return false; |
||||||||
| 191 | } |
||||||||
| 192 | |||||||||
| 193 | /** |
||||||||
| 194 | * @param $path |
||||||||
| 195 | */ |
||||||||
| 196 | private function createDirectories($path) |
||||||||
| 197 | { |
||||||||
| 198 | $f = new File($path); |
||||||||
| 199 | if (!$f->exists()) { |
||||||||
| 200 | $f->mkdirs(); |
||||||||
| 201 | } |
||||||||
| 202 | } |
||||||||
| 203 | } |
||||||||
| 204 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.