PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 3.1.0
Defender Security – Malware Scanner, Login Security & Firewall v3.1.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / vendor / opis / closure / src / ClosureStream.php

ClosureStream.php in Defender Security – Malware Scanner, Login Security & Firewall 3.1.0, at vendor/opis/closure/src/ClosureStream.php

100 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /* ===========================================================================
3 * Copyright (c) 2018-2021 Zindex Software
4 *
5 * Licensed under the MIT License
6 * =========================================================================== */
7
8 namespace Opis\Closure;
9
10 /**
11 * @internal
12 */
13 class ClosureStream
14 {
15 const STREAM_PROTO = 'closure';
16
17 protected static $isRegistered = false;
18
19 protected $content;
20
21 protected $length;
22
23 protected $pointer = 0;
24
25 function stream_open($path, $mode, $options, &$opened_path)
26 {
27 $this->content = "<?php\nreturn " . substr($path, strlen(static::STREAM_PROTO . '://')) . ";";
28 $this->length = strlen($this->content);
29 return true;
30 }
31
32 public function stream_read($count)
33 {
34 $value = substr($this->content, $this->pointer, $count);
35 $this->pointer += $count;
36 return $value;
37 }
38
39 public function stream_eof()
40 {
41 return $this->pointer >= $this->length;
42 }
43
44 public function stream_set_option($option, $arg1, $arg2)
45 {
46 return false;
47 }
48
49 public function stream_stat()
50 {
51 $stat = stat(__FILE__);
52 $stat[7] = $stat['size'] = $this->length;
53 return $stat;
54 }
55
56 public function url_stat($path, $flags)
57 {
58 $stat = stat(__FILE__);
59 $stat[7] = $stat['size'] = $this->length;
60 return $stat;
61 }
62
63 public function stream_seek($offset, $whence = SEEK_SET)
64 {
65 $crt = $this->pointer;
66
67 switch ($whence) {
68 case SEEK_SET:
69 $this->pointer = $offset;
70 break;
71 case SEEK_CUR:
72 $this->pointer += $offset;
73 break;
74 case SEEK_END:
75 $this->pointer = $this->length + $offset;
76 break;
77 }
78
79 if ($this->pointer < 0 || $this->pointer >= $this->length) {
80 $this->pointer = $crt;
81 return false;
82 }
83
84 return true;
85 }
86
87 public function stream_tell()
88 {
89 return $this->pointer;
90 }
91
92 public static function register()
93 {
94 if (!static::$isRegistered) {
95 static::$isRegistered = stream_wrapper_register(static::STREAM_PROTO, __CLASS__);
96 }
97 }
98
99 }
100