-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathttyrec-player.php
More file actions
44 lines (37 loc) · 955 Bytes
/
ttyrec-player.php
File metadata and controls
44 lines (37 loc) · 955 Bytes
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
<?php
require_once __DIR__ . '/../vendor/autoload.php';
$filename = "tty.log";
$handle = fopen($filename, "rb");
$data = stream_get_contents($handle);
fclose($handle);
$p = new \Tty\TtyRec\Parser($data);
$t = new \Tty\Terminal();
$r = new \Tty\Renderer\AsciiRenderer();
$i = 0;
$max = 100024;
$debug = false;
if (!$debug) {
echo chr(27) . '[2J';
echo chr(27) . '[;H';
}
$startStamp = null;
while ($frame = $p->getFrame()) {
if (!$startStamp) {
$startStamp = $frame->getStamp();
}
if ($i<$max) {
if ($debug) {
echo "Frame $i: [" . date('d/M/Y H:i:s', $frame->getStamp()) . "] len: " . $frame->getLength() . "\n";
echo $frame->toAscii() . "\n";
}
$t->write($frame->getPayload());
if (!$debug) {
echo chr(27) . '[;H';
}
echo $r->render($t);
//echo "-------\n";
usleep(100000 * 3);
}
$i++;
}
exit("Done\n");