-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathVariableStream.php
More file actions
49 lines (40 loc) · 1.07 KB
/
VariableStream.php
File metadata and controls
49 lines (40 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
namespace FPDF\Scripts\PDFMemImage;
// Stream handler to read from global variables
class VariableStream {
public $context;
private $varname;
private $position;
public function stream_open ($path, $mode, $options, &$opened_path) {
$url = parse_url($path);
$this->varname = $url['host'];
if (!isset($GLOBALS[$this->varname])) {
trigger_error('Global variable ' . $this->varname . ' does not exist', E_USER_WARNING);
return false;
}
$this->position = 0;
return true;
}
public function stream_read ($count) {
$ret = substr($GLOBALS[$this->varname], $this->position, $count);
$this->position += strlen($ret);
return $ret;
}
public function stream_eof () {
return $this->position >= strlen($GLOBALS[$this->varname]);
}
public function stream_tell () {
return $this->position;
}
public function stream_seek ($offset, $whence) {
if ($whence != SEEK_SET) {
return false;
}
$this->position = $offset;
return true;
}
public function stream_stat () {
return [];
}
}