Move wisski instance code to separate package

This commit is contained in:
Tom Wiesing 2022-10-17 14:20:15 +02:00
parent 7c3c84e116
commit 063f3f9b7d
No known key found for this signature in database
67 changed files with 533 additions and 409 deletions

View file

@ -0,0 +1,34 @@
<?php
// This file contains code to execute a php execution server.
// It is passed as a *command line literal * directly to 'drush:script'.
//
// As such it is preprocessed and shortened.
// It should only contain comments at the beginning of each line, and only starting with '//'.
// See wisski_php_server.go.
// don't buffer stdin!
stream_set_read_buffer(STDIN,0);
// stop all other output
ob_start(null,0,PHP_OUTPUT_HANDLER_CLEANABLE);
while($line = fgets(STDIN)){
// decode the command to run
$code=@json_decode($line);
// execute it
try{
$json = json_encode([eval($code),""]);
}catch(Throwable $t){
$json = json_encode([null,(string)$t]);
}
if($json===false) {
$json = '[null,"Error encoding result"]';
}
// and write out the result
ob_end_clean();
fwrite(STDOUT,"$json\n");
ob_start(null,0,PHP_OUTPUT_HANDLER_CLEANABLE);
}