This repository has been archived by the owner on Dec 5, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.php
69 lines (57 loc) · 1.44 KB
/
index.php
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
set_time_limit(0);
error_reporting(-1);
header('Content-Type: text/plain');
ini_set('display_errors', true);
while(ob_get_level())ob_end_flush();
ob_implicit_flush(true);
function write($msg){
echo $msg;
flush();
}
function writeln($msg){
write($msg.PHP_EOL);
}
function writehr(){
writeln(str_repeat('-', 80));
}
writeln('EXECUTION EVENT LOG'.str_repeat(' ', 1024));
require('src/InterExec.php');
$ds = DIRECTORY_SEPARATOR;
$ext = $ds=='/' ? 'sh' : 'bat';
$cmd = '"'.__DIR__.$ds.'test'.$ds.'test.'.$ext.'"';
$exec = new InterExec($cmd);
$exec->interval = 1;
$exec->on('start', function($exec){
writeln('Started');
});
$exec->on('stop', function($exec, $exitcode){
writeln('Stopped');
});
$exec->on('abort', function($exec, $reason){
writeln('Aborted');
});
$exec->on('tick', function($exec){
writeln('Tick');
});
$exec->on('input', function($exec, $last){
$resp = array(
'Enter your name: ' => 'Chris',
'And your surname: ' => 'Sciberras',
'Press any key to continue . . . ' => ''
);
$data = isset($resp[$last]) ? $resp[$last] : '';
writeln('Input: '.$data);
return $data.PHP_EOL;
});
$exec->on('output', function($exec, $data){
writeln('Output: '.$data);
});
$exec->on('error', function($exec, $data){
writeln('Error: '.$data);
});
$exec->run();
writehr();
writeln('EXECUTION CONTEXT');
print_r($exec);
?>