|
1
|
|
|
<?php |
|
2
|
|
|
require_once __DIR__ .'/../vendor/autoload.php'; |
|
3
|
|
|
use Kristuff\Mishell\Console; |
|
4
|
|
|
|
|
5
|
|
|
declare(ticks = 1); // Allow posix signal handling |
|
6
|
|
|
pcntl_async_signals(true); |
|
7
|
|
|
pcntl_signal(SIGINT,"shutdown"); |
|
8
|
|
|
register_shutdown_function("shutdown"); // Handle END of script |
|
9
|
|
|
|
|
10
|
|
|
// Console::newWindow(); |
|
11
|
|
|
// standWithUkraine("Stand with Ukraine <3", "Slava Ukraini"); |
|
12
|
|
|
// Console::clear(the war); |
|
13
|
|
|
// Console::destroy("the duck"); |
|
14
|
|
|
// Console::help("PLEASE!"); |
|
15
|
|
|
printLoader(777, false); // à "la va vite".. u sleep? or not u sleep? or caleçon ? .. |
|
16
|
|
|
splash(); |
|
17
|
|
|
goIndex(); |
|
18
|
|
|
|
|
19
|
|
|
function goIndex() |
|
20
|
|
|
{ |
|
21
|
|
|
splash(); |
|
22
|
|
|
splash(); |
|
23
|
|
|
Console::newWindow(); |
|
24
|
|
|
printHeader('index'); |
|
25
|
|
|
printIndex(); |
|
26
|
|
|
askIndex(); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
function shutdown(){ |
|
30
|
|
|
// echo "\033c"; // Clear terminal |
|
31
|
|
|
// echo PHP_EOL; // New line |
|
32
|
|
|
Console::clear(); |
|
33
|
|
|
Console::clear(); |
|
34
|
|
|
Console::clear(); |
|
35
|
|
|
Console::clear(); |
|
36
|
|
|
Console::clear(); |
|
37
|
|
|
Console::log('SIGINT signal detected, terminate script...'); |
|
38
|
|
|
sleep(1); |
|
39
|
|
|
|
|
40
|
|
|
// .. |
|
41
|
|
|
// Console::restoreWindow(); |
|
42
|
|
|
exit(0); |
|
|
|
|
|
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
function printLoader($introDelay = 75000, $printAll = true) |
|
46
|
|
|
{ |
|
47
|
|
|
Console::newWindow(); |
|
48
|
|
|
splash(); |
|
49
|
|
|
Console::clear(); |
|
50
|
|
|
splash(); |
|
51
|
|
|
Console::clear(); |
|
52
|
|
|
Console::log(); |
|
53
|
|
|
Console::log(Console::text(" _ _ _ _ ", 'yellow').Console::text(' ', 'yellow').Console::text('', 'green') ); |
|
54
|
|
|
Console::log(Console::text(" _ __ (_)__| |_ ___| | | ", 'yellow').Console::text(' ', 'yellow').Console::text('', 'green') ); |
|
55
|
|
|
Console::log(Console::text(" | ' \| (_-< ' \/ -_) | | ", 'yellow').Console::text(' ', 'yellow').Console::text('', 'green') ); |
|
56
|
|
|
Console::log(Console::text(" |_|_|_|_/__/_||_\___|_|_| ", 'yellow').Console::text('By ', 'yellow').Console::text("kr157uff", 'green') ); |
|
57
|
|
|
Console::log(); |
|
58
|
|
|
Console::log(' '.Console::text("-----------------------------------------------------------------", "green")); |
|
59
|
|
|
Console::log(' '.Console::text("kristuff/mishell: A mini PHP library to build CLI app and reports", "green")); |
|
60
|
|
|
Console::log(' '.Console::text('Made with ', 'green') . Console::text('♥', 'red'). |
|
61
|
|
|
Console::text(' ', 'green'). |
|
62
|
|
|
Console::text(" | © 2017-2024 kri157uff", "green")); |
|
63
|
|
|
Console::log(' '.Console::text("-----------------------------------------------------------------", "green")); |
|
64
|
|
|
Console::log(); |
|
65
|
|
|
usleep($introDelay * random_int(7, 11)); |
|
66
|
|
|
$new = Console::text("NEW", 'green', 'blink'); |
|
67
|
|
|
$fullRowString = Console::pad('', Console::getColumns()); |
|
68
|
|
|
$badgeOnline = Console::text(' ONLINE ', 'yellow', 'green'). ' '; |
|
69
|
|
|
$badgeError = Console::text(' 💀 ERR ', 'yellow', 'red'); |
|
70
|
|
|
$badgeOffline = Console::text(' BROKEN ', 'yellow', 'yellow'). ' '; |
|
71
|
|
|
$badgeBroken = Console::text(' 😜 LIKELY NEED INTERNAL REWRITE ', 'yellow', 'red'); |
|
72
|
|
|
$swu = Console::text('StandWith', 'yellow', 'blue').Console::text('Ukraine', 'blue', 'yellow'); |
|
73
|
|
|
$copyright = Console::text(' [*]', 'green').Console::text(" © 2017-2024 ", 'yellow').Console::text('kri157uff', 'green').Console::text(' aka ', 'yellow').Console::text('Kristuff', 'green'); |
|
74
|
|
|
$head1 = Console::text(' [*]', 'blue').Console::text(' Kr157uff/mishell ', 'yellow').Console::text(" v1.6 ", 'yellow', 'blue').' released '.$new.Console::text(' ', 'yellow'); |
|
75
|
|
|
$progress = Console::text(' [*]', 'blue').Console::text(' This is another ', 'yellow').Console::text('fake', 'green', 'underlined').Console::text(' progress message (', 'yellow').Console::text('0%', 'green').Console::text(') completed', 'yellow'); |
|
76
|
|
|
$progress1 = Console::text(' [*]', 'yellow').Console::text(' In fact I\'m already loaded for a while...', 'yellow'); |
|
77
|
|
|
$twitter = Console::text(' [*]', 'blue').Console::text(' Twitter microservices status: ', 'yellow').$badgeOffline; |
|
78
|
|
|
$weSWU = Console::text(' [*]', 'blue').Console::text(' We ', 'yellow').$swu; |
|
79
|
|
|
$msg1 = Console::text(' [*]', 'blue'). Console::text(' Tortoise vs Hare Race will starting soon. Place your bets! ...', 'yellow'); |
|
80
|
|
|
$msg2 = Console::text(' [*]', 'blue').Console::text(' 🐢 ', 'green').Console::text('Tortoise progress ... ', 'green'); |
|
81
|
|
|
$msg3 = Console::text(' [*]', 'blue').Console::text(' 🐇 ', 'yellow').Console::text('Hare progress ... ', 'green'); |
|
82
|
|
|
Console::log($head1); |
|
83
|
|
|
usleep($introDelay * random_int(1, 4)); |
|
84
|
|
|
Console::log(); |
|
85
|
|
|
Console::log($copyright); |
|
86
|
|
|
Console::log(); |
|
87
|
|
|
usleep($introDelay * random_int(3, 5)); |
|
88
|
|
|
Console::log($weSWU); |
|
89
|
|
|
Console::log(); |
|
90
|
|
|
usleep($introDelay * random_int(5, 7)); |
|
91
|
|
|
Console::log($twitter); |
|
92
|
|
|
Console::log(); |
|
93
|
|
|
usleep($introDelay * random_int(1, 2)); |
|
94
|
|
|
Console::log($msg1); |
|
95
|
|
|
Console::log(); |
|
96
|
|
|
Console::log($msg2); |
|
97
|
|
|
Console::log(); |
|
98
|
|
|
Console::log($msg3); |
|
99
|
|
|
Console::log(); |
|
100
|
|
|
usleep($introDelay * random_int(2, 4)); |
|
101
|
|
|
Console::log($progress); |
|
102
|
|
|
Console::log(); |
|
103
|
|
|
Console::log($progress1); |
|
104
|
|
|
Console::log(); |
|
105
|
|
|
// |
|
106
|
|
|
$harePurcent = 0; |
|
107
|
|
|
$tortPurcent = 0; |
|
108
|
|
|
$twitterStatus = [ |
|
109
|
|
|
Console::text(' [*]', 'green').Console::text(' Twitter microservices status: ', 'yellow').$badgeOnline, |
|
110
|
|
|
Console::text(' [*]', 'yellow').Console::text(' Twitter microservices status: ', 'yellow').$badgeOffline, |
|
111
|
|
|
Console::text(' [*]', 'red') .Console::text(' Twitter microservices status: ', 'yellow'). $badgeError, |
|
112
|
|
|
]; |
|
113
|
|
|
for ($i=1 ; $i<=100 ; $i++) { |
|
114
|
|
|
$isOdd = ($i % 2 == 0); |
|
115
|
|
|
|
|
116
|
|
|
$progress = Console::text(' [*]', 'blue').Console::text(' This is another ', 'yellow').Console::text('fake', 'green', 'bold', 'underlined').Console::text(' progress message (', 'yellow').Console::text($i .'%', 'green').Console::text(' completed)', 'yellow'); |
|
117
|
|
|
$twitter = $twitterStatus[random_int(0, 2)]; |
|
118
|
|
|
|
|
119
|
|
|
if ($i < 75 ){ |
|
120
|
|
|
$isOdd && $tortPurcent++; |
|
121
|
|
|
} else { |
|
122
|
|
|
$twitter = Console::text(' [*]', 'red').Console::text(' Twitter microservices status: ', 'yellow').$badgeBroken; |
|
123
|
|
|
$tortPurcent = min($tortPurcent + 3, 100); |
|
124
|
|
|
} |
|
125
|
|
|
if ($i == 100) { |
|
126
|
|
|
Console::text(' [*]', 'red').Console::text(' Twitter microservices status: ', 'yellow').$badgeBroken; |
|
127
|
|
|
} |
|
128
|
|
|
$harePurcent++; |
|
129
|
|
|
if ($i== 100){ |
|
130
|
|
|
$tortColor = $tortPurcent >= $harePurcent ? 'green' : 'red' ; |
|
131
|
|
|
$hareColor = $tortPurcent < $harePurcent ? 'green' : 'red' ; |
|
132
|
|
|
} else { |
|
133
|
|
|
$tortColor = $tortPurcent >= $harePurcent ? 'green' : 'yellow' ; |
|
134
|
|
|
$hareColor = $tortPurcent < $harePurcent ? 'green' : 'yellow' ; |
|
135
|
|
|
} |
|
136
|
|
|
$msg1 = $i==100 ? |
|
137
|
|
|
Console::text(' [*]', 'blue').Console::text(' Tortoise vs Hare Race - Final Results', 'yellow') : |
|
138
|
|
|
Console::text(' [*]', 'blue').Console::text(' Tortoise vs Hare Race: ', 'yellow').Console::text(' RUNNING ', 'yellow', 'yellow'). ' ' ; |
|
139
|
|
|
$msg2 = Console::text(' [*]', $i==100 ? $tortColor : 'blue').Console::text(' 🐢 ', 'green').Console::text('Tortoise progress: ', 'yellow').Console::progressBar($tortPurcent, $tortColor, $tortColor); |
|
140
|
|
|
$msg3 = Console::text(' [*]', $i==100 ? $hareColor : 'blue').Console::text(' 🐇 ', 'yellow'). Console::text('Hare progress: ', 'yellow').Console::progressBar($harePurcent, $hareColor, $hareColor); |
|
141
|
|
|
$msg2End = $tortPurcent == 100 ? ' '.Console::text('🏆 WINNER!!!', 'green') : ''; |
|
142
|
|
|
$msgs = [ |
|
143
|
|
|
$head1 |
|
144
|
|
|
, |
|
145
|
|
|
' ', $copyright, |
|
146
|
|
|
' ', $weSWU, |
|
147
|
|
|
' ', $twitter, |
|
148
|
|
|
' ', $msg1, |
|
149
|
|
|
' ', $msg2.$msg2End, |
|
150
|
|
|
' ', $msg3, |
|
151
|
|
|
' ', $progress, |
|
152
|
|
|
' ', $progress1, |
|
153
|
|
|
' ', |
|
154
|
|
|
]; |
|
155
|
|
|
|
|
156
|
|
|
// rewrite the last printed lines |
|
157
|
|
|
Console::overwrite($msgs); |
|
158
|
|
|
|
|
159
|
|
|
// wait for a while, so we see the animation |
|
160
|
|
|
usleep($introDelay); |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
$apt1 = Console::text(' dpkg install nothing [ ', 'yellow').Console::progressBar(0, 'default', 'default','default', Console::getColumns() - 26, ' ', '.', false).Console::text(' ]', 'yellow'); |
|
164
|
|
|
$apt2 = Console::pad(Console::text(' dpkg finished to install nothing ...', 'yellow'), Console::getColumns() -26); |
|
165
|
|
|
$apt3 = ''; |
|
166
|
|
|
$apt4 = Console::pad(Console::text(' it works on my machine ...', 'yellow'), Console::getColumns() -26); |
|
167
|
|
|
$apt5 = ''; |
|
168
|
|
|
$apt6 = Console::pad(Console::text(' failed to import new galaxy, we will retry later ...', 'red'), Console::getColumns() -26); |
|
169
|
|
|
|
|
170
|
|
|
usleep($introDelay * random_int(2, 3)); |
|
171
|
|
|
Console::log($apt1); |
|
172
|
|
|
for ($i=1 ; $i<=100 ; $i++) { |
|
173
|
|
|
$apt1 = Console::text(' dpkg install nothing [ ', 'yellow').Console::progressBar($i, 'default', 'default','default', Console::getColumns() - 26, ' ', '#', false).Console::text(' ]', 'yellow'); |
|
174
|
|
|
Console::overwrite($apt1); |
|
175
|
|
|
usleep($introDelay / 3); |
|
176
|
|
|
} |
|
177
|
|
|
Console::overwrite($apt2); |
|
178
|
|
|
|
|
179
|
|
|
Console::log($apt3); |
|
180
|
|
|
for ($i=1 ; $i<=100 ; $i++) { |
|
181
|
|
|
$apt3 = Console::text(' dpkg purge nothing [ ', 'yellow').Console::progressBar($i, 'default', 'default','default', Console::getColumns() - 26, Console::text('.', 'yellow'), Console::text('#', 'green'), false).Console::text(' ]', 'yellow'); |
|
182
|
|
|
Console::overwrite($apt3); |
|
183
|
|
|
usleep($introDelay / 4); |
|
184
|
|
|
} |
|
185
|
|
|
Console::overwrite($apt4); |
|
186
|
|
|
|
|
187
|
|
|
usleep($introDelay * random_int(2, 3)); |
|
188
|
|
|
Console::log($apt5); |
|
189
|
|
|
for ($i=1 ; $i<=100 ; $i++) { |
|
190
|
|
|
$apt5 = Console::text(' importing new galaxy [ ', 'yellow').Console::progressBar($i, 'default', 'default','default', Console::getColumns() - 26, Console::text('.', 'yellow'), Console::text('!', 'red'), false).Console::text(' ]', 'yellow'); |
|
191
|
|
|
Console::overwrite($apt5); |
|
192
|
|
|
usleep($introDelay / 5 ); |
|
193
|
|
|
} |
|
194
|
|
|
Console::overwrite($apt6); |
|
195
|
|
|
|
|
196
|
|
|
$magicTime = $printAll ? 122000 : false; |
|
197
|
|
|
|
|
198
|
|
|
Console::log(' '.Console::text("- CRITICAL FAILURE -", 'yellow', 'red')); |
|
199
|
|
|
usleep($magicTime ?? 556000); |
|
|
|
|
|
|
200
|
|
|
Console::overwrite(Console::text(" just kidding ...", 'yellow')); |
|
201
|
|
|
usleep($magicTime ?? 9155000); |
|
202
|
|
|
Console::overwrite(Console::text(" demo complete", 'green')); |
|
203
|
|
|
usleep($magicTime ?? 1355000); |
|
204
|
|
|
Console::overwrite(Console::text(" oh wait! I forgot something 🤔", 'yellow')); |
|
205
|
|
|
usleep($magicTime ?? 1355000); |
|
206
|
|
|
|
|
207
|
|
|
if ($printAll) { |
|
208
|
|
|
|
|
209
|
|
|
Console::overwrite($fullRowString); |
|
210
|
|
|
Console::log( |
|
211
|
|
|
Console::text(" →", 'yellow').Console::text(' → ', 'blue'). |
|
212
|
|
|
Console::text(" →", 'yellow').Console::text(' → ', 'blue'). |
|
213
|
|
|
Console::text(" →", 'yellow').Console::text(' → ', 'blue'). |
|
214
|
|
|
Console::text(" →", 'yellow').Console::text(' → ', 'blue'). |
|
215
|
|
|
$swu. |
|
216
|
|
|
Console::text(" ←", 'yellow').Console::text(' ← ', 'blue'). |
|
217
|
|
|
Console::text(" ←", 'yellow').Console::text(' ← ', 'blue'). |
|
218
|
|
|
Console::text(" ←", 'yellow').Console::text(' ← ', 'blue'). |
|
219
|
|
|
Console::text(" ←", 'yellow').Console::text(' ← ', 'blue') |
|
220
|
|
|
); |
|
221
|
|
|
usleep($introDelay * 10); |
|
222
|
|
|
|
|
223
|
|
|
Console::log(); |
|
224
|
|
|
Console::log( Console::text(" also forgot to install Kr157uff-socials-links-2.0 package", 'yellow')); usleep(1355000); |
|
225
|
|
|
Console::overwrite( Console::text(" Do you want to install Kr157uff-socials-links package? (634 Go)", 'yellow')); usleep(1355000); |
|
226
|
|
|
Console::log( Console::text(" i readed in your mind and detected ", 'yellow').Console::text('YES OF COURSE', 'yellow').Console::text(" ...", 'yellow')); usleep($introDelay * 5); |
|
227
|
|
|
Console::log( Console::text(" i never cheat ...", 'yellow')); usleep($introDelay * 5); |
|
228
|
|
|
Console::log( Console::text(" okay sometimes ...", 'yellow')); |
|
229
|
|
|
$socials = [ |
|
230
|
|
|
["name" => "Github", "user" => "kristuff ", "link" => "https://github.com/kristuff"], |
|
231
|
|
|
["name" => "Twitter", "user" => "@_kristuff ", "link" => "https://twitter.com/_kristuff"], |
|
232
|
|
|
["name" => "Mastodon", "user" => "@kristuff ", "link" => "https://infosec.exchange/@kristuff"], |
|
233
|
|
|
]; |
|
234
|
|
|
|
|
235
|
|
|
$aptLink = Console::text(' unpacking Kr157uff-social-links-2.0-prod-test [ ', 'yellow').Console::progressBar(0, 'default', 'default','default', Console::getColumns() - 56, '.', Console::text('#', 'green'), false).Console::text(' ]', 'yellow'); |
|
236
|
|
|
Console::log(); |
|
237
|
|
|
Console::log(); |
|
238
|
|
|
Console::log(); |
|
239
|
|
|
Console::log($aptLink); |
|
240
|
|
|
Console::log(); |
|
241
|
|
|
|
|
242
|
|
|
$i = 0; |
|
243
|
|
|
foreach ($socials as $social){ |
|
244
|
|
|
$socialLog = Console::pad( |
|
245
|
|
|
Console::text(' preparing to unpack ', 'yellow'). |
|
246
|
|
|
Console::text('kristuff-'.$social['name'].'.deb', 'green'). |
|
247
|
|
|
Console::text(' ...', 'yellow'), |
|
248
|
|
|
Console::getColumns() - 12 |
|
249
|
|
|
) ; |
|
250
|
|
|
$socialLog3 = Console::text( ' created symlink ', 'yellow'). |
|
251
|
|
|
Console::text('/usr/bin/'.$social['user'], 'yellow'). |
|
252
|
|
|
Console::text(' → ', 'yellow'). |
|
253
|
|
|
Console::text($social['link'], 'lightblue', 'underlined'); |
|
254
|
|
|
|
|
255
|
|
|
$socialLog2 = Console::text( ' unpacking ', 'yellow'). |
|
256
|
|
|
Console::text('kristuff-'. $social['name'].'-prod-test~deb12u99', 'yellow'). |
|
257
|
|
|
Console::text('-prod-test~deb12u99', 'green'). |
|
258
|
|
|
Console::text(' ...', 'yellow'); |
|
259
|
|
|
|
|
260
|
|
|
|
|
261
|
|
|
$aptLink = Console::text(' unpacking ', 'yellow'). |
|
262
|
|
|
Console::text('kristuff-social-links_2.0-prod-test~deb12u99', 'yellow'). |
|
263
|
|
|
Console::text(' [ ', 'yellow'). |
|
264
|
|
|
Console::progressBar(round(($i+0.3)/(count($socials)*2)*100), 'default', 'default','default', Console::getColumns() - 64, '.', Console::text('#', 'green'), false).Console::text(' ]', 'yellow'); |
|
265
|
|
|
|
|
266
|
|
|
Console::overwrite([$fullRowString,$fullRowString]); |
|
267
|
|
|
Console::overwrite([$socialLog, $socialLog2]); |
|
268
|
|
|
Console::log($socialLog3); |
|
269
|
|
|
Console::log(); |
|
270
|
|
|
Console::log($aptLink); |
|
271
|
|
|
usleep($introDelay * random_int(2, 4)); |
|
272
|
|
|
|
|
273
|
|
|
$i++; |
|
274
|
|
|
$aptLink = Console::text(' unpacking ', 'yellow'). |
|
275
|
|
|
Console::text('kristuff-social-links_2.0-prod-test~deb12u99', 'yellow'). |
|
276
|
|
|
Console::text(' [ ', 'yellow'). |
|
277
|
|
|
Console::progressBar(round($i+0.3/count($socials)*2*100), 'default', 'default','default', |
|
278
|
|
|
Console::getColumns() - 64, '.', Console::text('#', 'green'), false). |
|
279
|
|
|
Console::text(' ]', 'yellow'); |
|
280
|
|
|
usleep($introDelay * random_int(2, 4)); |
|
281
|
|
|
Console::overwrite([$fullRowString,$fullRowString]); |
|
282
|
|
|
Console::overwrite([' ', $aptLink]); |
|
283
|
|
|
$i++; |
|
284
|
|
|
} |
|
285
|
|
|
|
|
286
|
|
|
$aptLink = Console::text(' unpacking ', 'yellow'). |
|
287
|
|
|
Console::text('kristuff-social-links_2.0-prod-test~deb12u99', 'yellow'). |
|
288
|
|
|
Console::text(' [ ', 'yellow'). |
|
289
|
|
|
Console::progressBar(100, 'default', 'default','default', |
|
290
|
|
|
Console::getColumns() - 64, '.', Console::text('#', 'green'), false). |
|
291
|
|
|
Console::text(' ]', 'yellow'); |
|
292
|
|
|
|
|
293
|
|
|
Console::overwrite($aptLink); |
|
294
|
|
|
usleep($introDelay * random_int(10, 50)); |
|
295
|
|
|
|
|
296
|
|
|
Console::overwrite(Console::pad('', Console::getColumns())); |
|
297
|
|
|
$aptLink = Console::text(' unpacking ', 'yellow'). |
|
298
|
|
|
Console::text('kristuff-social-links_2.0-prod-test~deb12u99', 'yellow'). |
|
299
|
|
|
Console::text(' completed ... ', 'yellow'). |
|
300
|
|
|
|
|
301
|
|
|
Console::overwrite($fullRowString); |
|
|
|
|
|
|
302
|
|
|
Console::log($aptLink); |
|
303
|
|
|
Console::log(); |
|
304
|
|
|
Console::log(Console::text(" _ _ _ _ ", 'yellow').Console::text(' ', 'yellow').Console::text('', 'green') ); |
|
305
|
|
|
Console::log(Console::text(" _ __ (_)__| |_ ___| | | ", 'yellow').Console::text(' ', 'yellow').Console::text('', 'green') ); |
|
306
|
|
|
Console::log(Console::text(" | ' \| (_-< ' \/ -_) | | ", 'yellow').Console::text(' ', 'yellow').Console::text('', 'green') ); |
|
307
|
|
|
Console::log(Console::text(" |_|_|_|_/__/_||_\___|_|_| ", 'yellow').Console::text('By ', 'yellow').Console::text("kr157uff", 'green') ); |
|
308
|
|
|
Console::log(' '.Console::text("-----------------------------------------------------------------", "green")); |
|
309
|
|
|
Console::log(' '.Console::text("kr157uff/mishell: A mini PHP library to build CLI app and reports", "green")); |
|
310
|
|
|
Console::log(' '.Console::text('Made with ', 'green') . Console::text('♥', 'red'). |
|
311
|
|
|
Console::text(' in France', 'green'). |
|
312
|
|
|
Console::text(" | © 2017-2024 kri157uff", "green")); |
|
313
|
|
|
Console::log(' '.Console::text("-----------------------------------------------------------------", "green")); |
|
314
|
|
|
Console::log(); |
|
315
|
|
|
usleep(1200000); |
|
316
|
|
|
usleep($introDelay * random_int(10, 50)); |
|
317
|
|
|
Console::log(); |
|
318
|
|
|
Console::log(Console::text(" If you don't have the time to read, you can replay this intro slowwwly. Hura!", 'yellow')); |
|
319
|
|
|
Console::log(); |
|
320
|
|
|
|
|
321
|
|
|
} |
|
322
|
|
|
|
|
323
|
|
|
usleep($introDelay * random_int(20, 40)); |
|
324
|
|
|
Console::restoreWindow(); |
|
325
|
|
|
|
|
326
|
|
|
} |
|
327
|
|
|
|
|
328
|
|
|
function standWithUkraine($msg1, $msg2, $delay = 2000000) |
|
329
|
|
|
{ |
|
330
|
|
|
// *open* new window |
|
331
|
|
|
Console::newWindow(); |
|
332
|
|
|
|
|
333
|
|
|
// get columns / lines and calculate middle |
|
334
|
|
|
$lines = Console::getLines(); |
|
335
|
|
|
$cols = Console::getColumns(); |
|
336
|
|
|
$middle = round($lines/2); |
|
337
|
|
|
|
|
338
|
|
|
for ($i= 1; $i <= $lines ; $i++){ |
|
339
|
|
|
|
|
340
|
|
|
switch($i){ |
|
341
|
|
|
case $middle -1: |
|
342
|
|
|
Console::log(Console::pad($msg1, $cols, ' ', STR_PAD_BOTH), 'yellow', 'blue'); |
|
343
|
|
|
break; |
|
344
|
|
|
case $middle: |
|
345
|
|
|
Console::log(Console::pad(' ', $cols, ' ', STR_PAD_BOTH), 'yellow', 'blue'); |
|
346
|
|
|
break; |
|
347
|
|
|
case $middle +1: |
|
348
|
|
|
Console::log(Console::pad(' ', $cols, ' ', STR_PAD_BOTH), 'blue', 'yellow'); |
|
349
|
|
|
break; |
|
350
|
|
|
case $middle +2: |
|
351
|
|
|
Console::log(Console::pad($msg2, $cols, ' ', STR_PAD_BOTH), 'blue', 'yellow'); |
|
352
|
|
|
break; |
|
353
|
|
|
case $lines: |
|
354
|
|
|
Console::relog(Console::pad('Please wait a moment ', $cols, ' ', STR_PAD_LEFT), 'blue', 'yellow'); |
|
355
|
|
|
break; |
|
356
|
|
|
|
|
357
|
|
|
default: |
|
358
|
|
|
if ($i > $middle) { |
|
359
|
|
|
Console::log(Console::pad(' ', $cols), 'blue', 'yellow'); |
|
360
|
|
|
} else { |
|
361
|
|
|
Console::log(Console::pad(' ', $cols), 'yellow', 'blue'); |
|
362
|
|
|
} |
|
363
|
|
|
} |
|
364
|
|
|
} |
|
365
|
|
|
|
|
366
|
|
|
usleep($delay); |
|
367
|
|
|
// restore previous window |
|
368
|
|
|
Console::restoreWindow(); |
|
369
|
|
|
} |
|
370
|
|
|
|
|
371
|
|
|
function getIndex() |
|
372
|
|
|
{ |
|
373
|
|
|
$index = []; |
|
374
|
|
|
$new = Console::text("NEW", 'green', 'blink'); |
|
375
|
|
|
|
|
376
|
|
|
$index[99] = ['Quit ', 'Quit and *restore* my terminal ' , '']; |
|
377
|
|
|
$index[1] = ['Styles ', 'How to get basic styles ' , 'demo.styles.php ' , '']; |
|
378
|
|
|
$index[2] = ['Colors ', 'How to get foreground colors ' , 'demo.colors.php ' , '']; |
|
379
|
|
|
$index[3] = ['Backgrounds ', 'How to get background colors ' , 'demo.bgcolors.php ' , '']; |
|
380
|
|
|
$index[7] = ['Pad ', 'How to get padded string ' .Console::text( ' Console::pad() ' , 'lightblue' ). 'overview' , 'demo.pad.php', '']; |
|
381
|
|
|
$index[8] = ['Size ', 'How to get lines/columns number ' , 'demo.size.php ' , '']; |
|
382
|
|
|
$index[11] = ['Ask ', 'How to ask? (get user input) ' , 'demo.ask.php ' , '']; |
|
383
|
|
|
$index[12] = ['Ask Number ', 'How to ask and expect a number? ' , 'demo.askint.php ' , '']; |
|
384
|
|
|
$index[13] = ['Ask Password ', 'How to ask and hide input ' , 'demo.askpassword.php ' , '']; |
|
385
|
|
|
$index[14] = ['Table ', 'How to print a table? ' , 'demo.table. php ' , '']; |
|
386
|
|
|
$index[15] = ['Bell ', 'How to run the bell? ' , 'demo.bell.ph p ' , '']; |
|
387
|
|
|
$index[16] = ['Progress (1) ', 'How to print progress message? ' .Console::text( ' Console::relog() ' , 'lightblue' ). 'overview' , 'demo.progress.php', '']; |
|
388
|
|
|
$index[17] = ['Progress (2) ', 'How to print progress message? ' .Console::text( ' Console::overwrite() ' , 'lightblue' ). 'basic usage '.$new, 'demo.progress2.php', '']; |
|
389
|
|
|
$index[18] = ['Progress (3) ', 'How to print progress message? ' .Console::text( ' Console::overwrite() ' , 'lightblue' ). 'advanced usage '.$new, 'demo.progress3.php', '']; |
|
390
|
|
|
$index[19] = ['New window ', 'How to open new/restore window? ' , 'demo.window.php ' , '']; |
|
391
|
|
|
$index[80] = ['BlueScreen ', 'How to print blue screen ' .Console::text( ' Console::BUG(?)', 'yellow').' OLD && ' .$new , 'demo.bluescreen.php' , '']; |
|
392
|
|
|
$index[90] = ['Loader ', 'Replay the loader ' .Console::text( ' RealTime™v2.0 ' , 'yellow ', 'blue') . ' ' .$new, '']; |
|
393
|
|
|
$index[91] = ['Loader ', 'Replay the loader (more slowly) ' .Console::text( ' SLOOOOW! ', 'black', 'yellow'). ' ' .$new , '']; |
|
394
|
|
|
$index[92] = ['Loader ', 'Replay the loader (very slowly) ' .Console::text( ' SLOOOOOOOOOOOOW! ', 'yellow', 'red' ). ' ' .$new , '']; |
|
395
|
|
|
$index[800] = ['lifeA ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
396
|
|
|
$index[801] = ['lifeB ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
397
|
|
|
$index[802] = ['lifeC ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
398
|
|
|
$index[803] = ['lifeE ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
399
|
|
|
$index[804] = ['lifeF ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
400
|
|
|
$index[805] = ['lifeG ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
401
|
|
|
$index[807] = ['lifeH ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
402
|
|
|
$index[808] = ['lifeI ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
403
|
|
|
$index[809] = ['lifeJ ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
404
|
|
|
$index[810] = ['lifeK ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
405
|
|
|
$index[811] = ['lifeL ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
406
|
|
|
$index[812] = ['lifeMNO ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
407
|
|
|
$index[822] = ['lifePQ ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
408
|
|
|
$index[844] = ['lifeR ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
409
|
|
|
$index[888] = ['lifeNOSS ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
410
|
|
|
$index[869] = ['lifeTHE-TEA ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
411
|
|
|
$index[870] = ['lifeUV-SOL-AIR ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
412
|
|
|
$index[890] = ['lifeW ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
413
|
|
|
$index[899] = ['lifeXYQ ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , '', '']; |
|
414
|
|
|
$index[81] = ['life. ', 'How to print " I love life " ' .Console::text( ' 5tandWith', 'yellow' , 'blue').Console::text('Ukraine', 'blue', 'yellow'). ' '.$new , 'demo.standwithukraine.php', '']; |
|
415
|
|
|
|
|
416
|
|
|
return $index; |
|
417
|
|
|
} |
|
418
|
|
|
|
|
419
|
|
|
function printHeader($title = '', $demoPart = false) |
|
420
|
|
|
{ |
|
421
|
|
|
Console::log(Console::text(" _ _ _ _ ", 'yellow')); |
|
422
|
|
|
Console::log(Console::text(" _ __ (_)__| |_ ___| | | ", 'yellow').Console::text(' Kr157uff/Mishell ', 'green') . Console::text(' v1.6 ', 'yellow', 'blue'). ' '. Console::text(' StandWith ', 'yellow', 'blue')); |
|
423
|
|
|
Console::log(Console::text(" | ' \| (_-< ' \/ -_) | | ", 'yellow').Console::text(' Made with ', 'green') . Console::text('♥', 'red') . Console::text(' in France', 'green'). ' '.Console::text(' Ukraine ', 'blue', 'yellow')); |
|
424
|
|
|
Console::log(Console::text(" |_|_|_|_/__/_||_\___|_|_| ", 'yellow'). |
|
425
|
|
|
Console::text(' © 2017-2024 Kr157uff (', 'green') . |
|
426
|
|
|
Console::text('https://github.com/kristuff', 'green', 'underlined') . |
|
427
|
|
|
Console::text(')', 'green') |
|
428
|
|
|
); |
|
429
|
|
|
|
|
430
|
|
|
Console::log(); |
|
431
|
|
|
$demoTitle = Console::pad(' Mishell Interactive Sample - '.$title. ' ', 108, ' ', STR_PAD_BOTH); |
|
432
|
|
|
Console::log(Console::text(' ┌'.Console::pad('', 108, '─').'┐', 'yellow')); |
|
433
|
|
|
Console::log(Console::text(' │'.$demoTitle.'│', 'yellow')); |
|
434
|
|
|
|
|
435
|
|
|
if ($demoPart){ |
|
436
|
|
|
Console::log(Console::text(' └'.Console::pad('', 108, '─').'┘', 'yellow')); |
|
437
|
|
|
Console::log(); |
|
438
|
|
|
} |
|
439
|
|
|
} |
|
440
|
|
|
|
|
441
|
|
|
function printSampleHeader($index, $title) |
|
442
|
|
|
{ |
|
443
|
|
|
Console::log(' ' . Console::text(' - '. $index .' - ' . $title . ' ', 'yellow', 'blue')); |
|
444
|
|
|
Console::log(); |
|
445
|
|
|
} |
|
446
|
|
|
|
|
447
|
|
|
function printIndex() |
|
448
|
|
|
{ |
|
449
|
|
|
$rowHeaders = [ |
|
450
|
|
|
'Index' => 5, |
|
451
|
|
|
'Item' => 20, |
|
452
|
|
|
'Description' => 75 |
|
453
|
|
|
]; |
|
454
|
|
|
$i = 0; |
|
455
|
|
|
|
|
456
|
|
|
// customize table separator |
|
457
|
|
|
Console::$horizontalSeparator = '─'; |
|
458
|
|
|
Console::$verticalSeparator = Console::text('│', 'yellow'); |
|
459
|
|
|
Console::$verticalInnerSeparator = ' '; |
|
460
|
|
|
Console::$tableCellPadding = ' '; |
|
461
|
|
|
|
|
462
|
|
|
$line = Console::text(' ├', 'yellow'); |
|
463
|
|
|
$isFirst = true; |
|
464
|
|
|
foreach ($rowHeaders as $column => $pad){ |
|
465
|
|
|
$line .= $isFirst ? '': Console::text('┬', 'yellow'); |
|
466
|
|
|
$line .= Console::text(Console::pad('', $pad+2, '─'), 'yellow'); |
|
467
|
|
|
$isFirst = false; |
|
468
|
|
|
} |
|
469
|
|
|
$line .= Console::text('┤', 'yellow'); |
|
470
|
|
|
Console::log($line); |
|
471
|
|
|
|
|
472
|
|
|
$isFirst = true; |
|
473
|
|
|
$line = Console::text(' │', 'yellow'); |
|
474
|
|
|
foreach ($rowHeaders as $column => $pad){ |
|
475
|
|
|
$line .= $isFirst ? '': Console::text('│', 'yellow'); |
|
476
|
|
|
$line .= Console::text(Console::pad(' '.$column. ' ', $pad +2), 'yellow'); |
|
477
|
|
|
$isFirst = false; |
|
478
|
|
|
} |
|
479
|
|
|
$line .= Console::text('│', 'yellow'); |
|
480
|
|
|
Console::log($line); |
|
481
|
|
|
|
|
482
|
|
|
|
|
483
|
|
|
$isFirst = true; |
|
484
|
|
|
$line = Console::text(' ├', 'yellow'); |
|
485
|
|
|
foreach ($rowHeaders as $column => $pad){ |
|
486
|
|
|
$line .= $isFirst ? '': Console::text('┼', 'yellow'); |
|
487
|
|
|
$line .= Console::text(Console::pad('', $pad+2, '─'), 'yellow'); |
|
488
|
|
|
$isFirst = false; |
|
489
|
|
|
} |
|
490
|
|
|
$line .= Console::text('┤', 'yellow'); |
|
491
|
|
|
|
|
492
|
|
|
Console::log($line); |
|
493
|
|
|
|
|
494
|
|
|
foreach (getIndex() as $key => $value){ |
|
495
|
|
|
if (file_exists( __DIR__ . '/'. $value[2])) { |
|
496
|
|
|
Console::log(' '. |
|
497
|
|
|
Console::TableRowStart(). |
|
498
|
|
|
Console::text(Console::TableRowCell($key, 5, Console::ALIGN_CENTER),'green'). |
|
499
|
|
|
Console::text(Console::TableRowCell($value[0], 20),'green'). // no alignment set => default is left |
|
500
|
|
|
Console::text(Console::TableRowCell($value[1], 75),'green') |
|
501
|
|
|
); |
|
502
|
|
|
$i++; |
|
503
|
|
|
} |
|
504
|
|
|
} |
|
505
|
|
|
|
|
506
|
|
|
$isFirst = true; |
|
507
|
|
|
$line = Console::text(' └', 'yellow'); |
|
508
|
|
|
foreach ($rowHeaders as $column => $pad){ |
|
509
|
|
|
$line .= $isFirst ? '': Console::text('┴', 'yellow'); |
|
510
|
|
|
$line .= Console::text(Console::pad('', $pad+2, '─'), 'yellow'); |
|
511
|
|
|
$isFirst = false; |
|
512
|
|
|
} |
|
513
|
|
|
$line .= Console::text('┘', 'yellow'); |
|
514
|
|
|
|
|
515
|
|
|
Console::log($line); |
|
516
|
|
|
Console::log(''); |
|
517
|
|
|
Console::log(' '. Console::text('Tips:', 'underlined', 'bold')); |
|
518
|
|
|
Console::log(' '. Console::text(' - At any time you can stop this program using [') .Console::text('Ctrl+C', 'green') .Console::text('] ')); |
|
519
|
|
|
Console::log(''); |
|
520
|
|
|
// reset table separators to defaults |
|
521
|
|
|
Console::resetDefaults(); |
|
522
|
|
|
} |
|
523
|
|
|
|
|
524
|
|
|
|
|
525
|
|
|
function splash() |
|
526
|
|
|
{ |
|
527
|
|
|
// magical stuff |
|
528
|
|
|
Console::newWindow(); |
|
529
|
|
|
|
|
530
|
|
|
// get columns / lines and calculate middle |
|
531
|
|
|
$lines = Console::getLines(); |
|
532
|
|
|
$cols = Console::getColumns(); |
|
533
|
|
|
$middle = round($lines/2); |
|
534
|
|
|
|
|
535
|
|
|
for ($i= 1; $i <= $lines ; $i++){ |
|
536
|
|
|
switch($i){ |
|
537
|
|
|
case $middle -1: Console::log(Console::pad("Stand With Ukraine <3", $cols, ' ', STR_PAD_BOTH), 'yellow', 'blue'); break; |
|
538
|
|
|
case $middle: Console::log(Console::pad(' ', $cols, ' ', STR_PAD_BOTH), 'yellow', 'blue'); break; |
|
539
|
|
|
case $middle +1: Console::log(Console::pad(' ', $cols, ' ', STR_PAD_BOTH), 'blue', 'yellow'); break; |
|
540
|
|
|
case $middle +2: Console::log(Console::pad('Slava Ukraini', $cols, ' ', STR_PAD_BOTH), 'blue', 'yellow'); break; |
|
541
|
|
|
case $lines: Console::print(Console::pad(' Wait a few seconds or hint Ctrl+C', $cols , ' ', STR_PAD_LEFT), 'blue', 'yellow'); break; // no new line here |
|
542
|
|
|
default: |
|
543
|
|
|
if ($i > $middle) { |
|
544
|
|
|
Console::log(Console::pad(' ', $cols), 'blue', 'yellow'); |
|
545
|
|
|
} else { |
|
546
|
|
|
Console::log(Console::pad(' ', $cols), 'yellow', 'blue'); |
|
547
|
|
|
} |
|
548
|
|
|
} |
|
549
|
|
|
} |
|
550
|
|
|
|
|
551
|
|
|
// magical stuff.. |
|
552
|
|
|
usleep(74442); |
|
553
|
|
|
|
|
554
|
|
|
// restore previous window |
|
555
|
|
|
Console::restoreWindow(); |
|
556
|
|
|
|
|
557
|
|
|
} |
|
558
|
|
|
|
|
559
|
|
|
|
|
560
|
|
|
function askIndex() |
|
561
|
|
|
{ |
|
562
|
|
|
$base = Console::text(' Kr157uff/mishell-demo' , 'yellow'); |
|
563
|
|
|
$base .= Console::text('~$ ' , 'gray'); |
|
564
|
|
|
$selectedIndex = Console::askInt($base . Console::text(' Enter desired index then press [Enter] to run sample > ', 'yellow')); |
|
565
|
|
|
$index = getIndex(); |
|
566
|
|
|
|
|
567
|
|
|
switch($selectedIndex){ |
|
568
|
|
|
case 90: |
|
569
|
|
|
splash(); |
|
570
|
|
|
printLoader(100000); |
|
571
|
|
|
splash(); |
|
572
|
|
|
goIndex(); |
|
573
|
|
|
break; |
|
574
|
|
|
case 91: |
|
575
|
|
|
splash(); |
|
576
|
|
|
splash(); |
|
577
|
|
|
printLoader(275000); |
|
578
|
|
|
splash(); |
|
579
|
|
|
goIndex(); |
|
580
|
|
|
break; |
|
581
|
|
|
|
|
582
|
|
|
case 92: |
|
583
|
|
|
splash(); |
|
584
|
|
|
splash(); |
|
585
|
|
|
splash(); |
|
586
|
|
|
printLoader(575000); |
|
587
|
|
|
splash(); |
|
588
|
|
|
goIndex(); |
|
589
|
|
|
break; |
|
590
|
|
|
|
|
591
|
|
|
|
|
592
|
|
|
case 99: |
|
593
|
|
|
//Console::clear(); |
|
594
|
|
|
Console::restoreWindow(); |
|
595
|
|
|
break; |
|
596
|
|
|
case 0: |
|
597
|
|
|
Console::log(); |
|
598
|
|
|
// Console::restoreWindow(); |
|
599
|
|
|
exit(); |
|
|
|
|
|
|
600
|
|
|
break; |
|
601
|
|
|
|
|
602
|
|
|
default: |
|
603
|
|
|
|
|
604
|
|
|
if ($selectedIndex >= 800){ |
|
605
|
|
|
splash(); |
|
606
|
|
|
splash(); |
|
607
|
|
|
splash(); |
|
608
|
|
|
Console::clear(); |
|
609
|
|
|
goIndex(); |
|
610
|
|
|
break; |
|
611
|
|
|
} |
|
612
|
|
|
|
|
613
|
|
|
if (array_key_exists($selectedIndex, getIndex())) { |
|
|
|
|
|
|
614
|
|
|
|
|
615
|
|
|
$title = $index[$selectedIndex][0]; |
|
616
|
|
|
$fileName = $index[$selectedIndex][2]; |
|
617
|
|
|
$samplefileName = $index[$selectedIndex][3]; |
|
618
|
|
|
$filePath = __DIR__ . '/'. $fileName; |
|
619
|
|
|
$samplefilePath = __DIR__ . '/'. $samplefileName; |
|
620
|
|
|
|
|
621
|
|
|
Console::clear(); |
|
622
|
|
|
printHeader($title, true); |
|
623
|
|
|
//printSampleHeader($selectedIndex, $title); |
|
624
|
|
|
|
|
625
|
|
|
Console::log($base . Console::text('Start running sample index [', 'yellow') . |
|
626
|
|
|
Console::text( $selectedIndex, 'lightcyan') . |
|
627
|
|
|
Console::text(']', 'yellow')); |
|
628
|
|
|
|
|
629
|
|
|
Console::log($base . Console::text('Loading sample [', 'yellow') . |
|
630
|
|
|
Console::text( $title, 'lightcyan') . |
|
631
|
|
|
Console::text('] in file [', 'yellow') . |
|
632
|
|
|
Console::text( $fileName, 'lightcyan') . |
|
633
|
|
|
Console::text(']', 'yellow')); |
|
634
|
|
|
|
|
635
|
|
|
if (file_exists($filePath)){ |
|
636
|
|
|
//Console::log(); |
|
637
|
|
|
include $filePath; |
|
638
|
|
|
|
|
639
|
|
|
if (!empty($samplefileName) && file_exists($samplefilePath)){ |
|
640
|
|
|
include $samplefilePath; |
|
641
|
|
|
$filePath = $samplefilePath; |
|
642
|
|
|
} |
|
643
|
|
|
//Console::log(); |
|
644
|
|
|
Console::log($base . Console::text('End running [', 'yellow') . |
|
645
|
|
|
Console::text( $title, 'lightcyan') . |
|
646
|
|
|
Console::text(']', 'yellow')); |
|
647
|
|
|
|
|
648
|
|
|
$response = Console::ask($base . Console::text('Do you want to see the code that has been executed? (type y/Y to see the code) > ', 'yellow')); |
|
649
|
|
|
if (strtoupper($response) === 'Y') { |
|
650
|
|
|
Console::log($base . Console::text('The code in file [', 'yellow') . |
|
651
|
|
|
Console::text( $fileName, 'lightcyan') . |
|
652
|
|
|
Console::text('] is:', 'yellow')); |
|
653
|
|
|
Console::log(); |
|
654
|
|
|
|
|
655
|
|
|
$lines = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|
656
|
|
|
$count = 1; |
|
657
|
|
|
|
|
658
|
|
|
Console::log(Console::pad(' ', 100, '-'), 'green'); |
|
659
|
|
|
foreach($lines as $line){ |
|
660
|
|
|
$codeLine = rtrim($line); |
|
661
|
|
|
$isComment = substr(ltrim($codeLine), 0, 2) === '//'; |
|
662
|
|
|
$isPhp = substr(ltrim($codeLine), 0, 5) === '<?php' || substr(ltrim($codeLine), 0, 2) === '?>'; |
|
663
|
|
|
$color = $isPhp ? 'blue' : ($isComment ? 'green' : 'green'); |
|
664
|
|
|
Console::log(' '. Console::text($codeLine, $color)); |
|
665
|
|
|
$count++; |
|
666
|
|
|
} |
|
667
|
|
|
Console::log(Console::pad(' ', 100, '-'), 'green'); |
|
668
|
|
|
Console::log(); |
|
669
|
|
|
} |
|
670
|
|
|
} else { |
|
671
|
|
|
Console::log($base . Console::text('Error' , 'red')); |
|
672
|
|
|
Console::log($base . Console::text(' => File missing [' . $fileName . ']' , 'red')); |
|
673
|
|
|
} |
|
674
|
|
|
|
|
675
|
|
|
} else { |
|
676
|
|
|
Console::log($base . Console::text('Error:', 'red')); |
|
677
|
|
|
Console::log($base . Console::text('=> the value you entered is not a valid index number.', 'red')); |
|
678
|
|
|
askIndex(); |
|
679
|
|
|
} |
|
680
|
|
|
|
|
681
|
|
|
Console::ask($base . Console::text('Press [Enter] to go back to index > ', 'yellow')); |
|
682
|
|
|
goIndex(); |
|
683
|
|
|
} |
|
684
|
|
|
} |
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.