This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
phing-build.php
89 lines (84 loc) · 2.95 KB
/
phing-build.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
/**
* Look Busy
*
* Mocks a Phing build for each directory in this project's parent directory, then loops
*
* PHP Version 5.3
*
* @package look-busy
* @author Doug Hurst <[email protected]>
* @requires pcntl
*/
declare(ticks = 1);
date_default_timezone_set('America/Chicago');
pcntl_signal(SIGINT, 'handleSignal');
function walk($directory, Closure $callback) {
foreach (array_filter(scandir($directory), function($f) { return $f != '.' && $f != '..'; }) as $file) {
if (is_dir($directory.DIRECTORY_SEPARATOR.$file)) {
walk($directory.DIRECTORY_SEPARATOR.$file, $callback);
} else {
$callback($file);
}
}
};
function makeRenderer(array $renderers) {
return function($file) use ($renderers) {
echo "\033["
.$renderers[rand(0, count($renderers) - 1)]($file)
."\033[m";
};
}
function handleSignal($signal) {
echo PHP_EOL."\033[0;31m".'Halting build!'.PHP_EOL."\033[m";
sleep(1);
echo "\033[0;33m".'Unwinding stack...'.PHP_EOL."\033[m";
sleep(1);
echo "\033[0;37m".'Build halted at '.rand(1,99).'%.'.PHP_EOL."\033[m".PHP_EOL;
exit(1);
}
while (true) {
walk(
realpath(__DIR__.DIRECTORY_SEPARATOR.'..'),
makeRenderer(array(
function($filename) {
return "0;37m".'phing> ['.date('r').'] Building include() files for '.$filename.PHP_EOL;
},
function($filename) {
return "0;31m".'PHP ERROR: parse(): cannot parse '.$filename.PHP_EOL;
},
function($filename) {
return "0;37m".'phing> ['.date('r').'] Generating collation from '.$filename.PHP_EOL;
},
function($filename) {
return "0;37m".'phing> ['.date('r').'] Found '.rand(2, 9).' tasks in "'.$filename.'"'.PHP_EOL;
},
function($filename) {
return "0;33m".'WARNING: file '.$filename.' contains deprecated flags'.PHP_EOL;
},
function($filename) {
echo "\033[0;37m".'phing> ['.date('r').'] Waiting for response from server (ftp.'
.current(explode('.', $filename))
.'.com)...'
.PHP_EOL;
sleep(rand(1, 3));
return '';
},
function($filename) {
echo "\033[0;37m".'phing> ['.date('r').'] Collecting entropy...'.PHP_EOL."\033[m";
do {
sleep(rand(1, 2));
echo "\033[0;36m"
.array_reduce(
unpack('H*', file_get_contents('/dev/urandom', false, null, 0, 40)),
function($i, $x) { return $i.$x; },
' >> '
)
.PHP_EOL
."\033[m";
} while(rand(1, 3) != 1);
return '';
}
)
));
}