Skip to content

Commit ea9b610

Browse files
committed
Rename docker attribute to pipe
1 parent 4516d3b commit ea9b610

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

play.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
$retval = U::get($_SESSION, 'retval');
3636

37-
if ( is_object($retval) && is_object($retval->docker) && strlen(U::get($_POST, "emcc_output", '')) > 0 ) {
37+
if ( is_object($retval) && is_object($retval->pipe) && strlen(U::get($_POST, "emcc_output", '')) > 0 ) {
3838
cc4e_emcc_get_output($retval, $displayname, $email, $_SESSION['id']);
3939
$_SESSION['retval'] = $retval;
4040
}
@@ -135,8 +135,8 @@
135135
</textarea>
136136
</p>
137137
</form>
138-
<?php if ( is_object($retval) && isset($retval->docker) && is_object($retval->docker) && is_string($retval->docker->stdout) && strlen($retval->docker->stdout) > 0 ) {
139-
$rows = substr_count( $retval->docker->stdout, "\n" );
138+
<?php if ( is_object($retval) && isset($retval->pipe) && is_object($retval->pipe) && is_string($retval->pipe->stdout) && strlen($retval->pipe->stdout) > 0 ) {
139+
$rows = substr_count( $retval->pipe->stdout, "\n" );
140140
if ( $rows < 5 ) $rows = 5;
141141
if ( $rows > 30 ) $rows = 30;
142142
?>
@@ -145,7 +145,7 @@
145145
</p>
146146
<p>
147147
<textarea id="myoutput" name="output" style="width:100%; border: 1px black solid;" rows="<?= $rows ?>">
148-
<?php echo(htmlentities($retval->docker->stdout)); ?>
148+
<?php echo(htmlentities($retval->pipe->stdout)); ?>
149149
</textarea>
150150
</p>
151151
<?php } ?>

play_util.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function cc4e_play_header($lines) {
2828
function cc4e_play_errors($retval) {
2929
global $LOGGED_IN;
3030
if ( ! $LOGGED_IN ) return false;
31-
$compiler = $retval->docker->stderr ?? false;
31+
$compiler = $retval->pipe->stderr ?? false;
3232

3333
if ( is_string($compiler) && strlen($compiler) > 0 ) {
3434
echo '<pre style="color:red;">'."\n";
@@ -50,7 +50,7 @@ function cc4e_play_errors($retval) {
5050
} else if ( isset($retval->hasmain) && $retval->hasmain === false ) {
5151
echo('<p style="color:blue;">Compile only: You need a main() for your code to be run</p>'."\n");
5252
return true;
53-
} else if ( isset($retval->docker->stdout) && strlen($retval->docker->stdout) > 0 ) {
53+
} else if ( isset($retval->pipe->stdout) && strlen($retval->pipe->stdout) > 0 ) {
5454
return false;
5555
} else if ( isset($retval->minimum) && $retval->minimum === false ) {
5656
echo('<p style="color:red;">Your program did not produce any output</p>'."\n");
@@ -85,13 +85,13 @@ function cc4e_play_output($retval) {
8585
<?php
8686
if ( ! $LOGGED_IN ) return;
8787
// https://stackoverflow.com/questions/3008035/stop-an-input-field-in-a-form-from-being-submitted
88-
if ( isset($retval->docker->stdout) ) {
88+
if ( isset($retval->pipe->stdout) ) {
8989
echo '<form style="color: blue;">'."\n";
9090
echo '<div style="color: blue;">'."\n";
9191
echo "Output from your program:\n\n";
9292
// echo '<textarea id="myouput" readonly name="output" style="color: blue; width:100%; border: 1px black solid;">';
9393
echo('<div id="myoutput" class="xpre_text"><pre>');
94-
echo(htmlentities($retval->docker->stdout, ENT_NOQUOTES));
94+
echo(htmlentities($retval->pipe->stdout, ENT_NOQUOTES));
9595
// echo("</textarea>\n");
9696
echo("</pre></div>\n");
9797
echo("</div>\n");

sandbox/check/test.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
$fail = false;
1919

2020
$compile = $retval->assembly->status == 0;
21-
$failure = isset($retval->docker->failure) && is_string($retval->docker->failure) ? $retval->docker->failure : false;
21+
$failure = isset($retval->pipe->failure) && is_string($retval->pipe->failure) ? $retval->pipe->failure : false;
2222

2323
if ( ! $compile ) {
2424
$fail = "Compiler error";
@@ -47,10 +47,10 @@
4747
} else if ( strpos($failure, "exceeded")> 0 && $stdout ) {
4848
// Cool
4949
} else {
50-
$fail = "Docker failure: ". $failure;
50+
$fail = "Pipe/process failure: ". $failure;
5151
}
52-
} else if ( isset($retval->docker->stdout) ) {
53-
$output = $retval->docker->stdout;
52+
} else if ( isset($retval->pipe->stdout) ) {
53+
$output = $retval->pipe->stdout;
5454
if ( strlen($output) < 1 ) {
5555
$fail = "Did not produce any output";
5656
}

sandbox/sandbox.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,13 @@ function cc4e_emcc($user_id, $code, $input, $main=null, $note=null)
221221
$env = null;
222222
$timeout = 10.0;
223223

224-
$retval->docker = cc4e_pipe($command, $stdin, $cwd, $env, $timeout);
224+
$retval->pipe = cc4e_pipe($command, $stdin, $cwd, $env, $timeout);
225225

226226
$retval->tempdir = $tempdir;
227227
$retval->user_id = $user_id;
228228

229229
$hexfolder = bin2hex($tempdir);
230-
if ( strlen($retval->docker->stderr) < 1 ) {
230+
if ( strlen($retval->pipe->stderr) < 1 ) {
231231
$retval->js = $CFG->apphome . '/emcompile/load.php/' . $hexfolder . '/a.out.js';
232232
$retval->wasm = $CFG->apphome . '/emcompile/load.php/' . $hexfolder . '/a.out.wasm';
233233
$retval->hasmain = true;
@@ -243,7 +243,7 @@ function cc4e_emcc($user_id, $code, $input, $main=null, $note=null)
243243
function cc4e_emcc_get_output($retval, $displayname, $email, $user_id)
244244
{
245245
if ( ! is_object($retval) ) return;
246-
if ( ! is_object($retval->docker) ) return;
246+
if ( ! is_object($retval->pipe) ) return;
247247
if ( strlen(U::get($_POST, "emcc_output", '')) < 1 ) return;
248248

249249
$tempdir = $retval->tempdir ?? '';
@@ -254,7 +254,7 @@ function cc4e_emcc_get_output($retval, $displayname, $email, $user_id)
254254
} else {
255255
$output = substr(U::get($_POST, 'emcc_output', ''), 0, 20000);
256256
$_SESSION['output'] = $output;
257-
$retval->docker->stdout = $output;
257+
$retval->pipe->stdout = $output;
258258
$retval->output = $output;
259259
$retval->displayname = $displayname;
260260
$retval->email = $email;
@@ -500,10 +500,10 @@ function cc4e_rate_limit($retval)
500500
if ( $count >= $BUCKET_SIZE ) {
501501
if ( ! is_object($retval) ) {
502502
$retval = new \stdClass();
503-
$retval->docker = new \stdClass();
503+
$retval->pipe = new \stdClass();
504504
}
505-
$retval->docker->stdout = "";
506-
$retval->docker->stderr = "Rate Exceeded...";
505+
$retval->pipe->stdout = "";
506+
$retval->pipe->stderr = "Rate Exceeded...";
507507
$_SESSION['retval'] = $retval;
508508
return true;
509509
} else {

tools/ccauto/index.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
$retval = U::get($_SESSION, 'retval');
164164
$actual = U::get($_SESSION, 'actual');
165165

166-
if ( is_object($retval) && is_object($retval->docker) && strlen(U::get($_POST, "emcc_output", '')) > 0 ) {
166+
if ( is_object($retval) && is_object($retval->pipe) && strlen(U::get($_POST, "emcc_output", '')) > 0 ) {
167167
$_SESSION['actual'] = U::get($_POST, 'emcc_output', '');
168168
cc4e_emcc_get_output($retval, $displayname, $email, $LAUNCH->user->id);
169169
$_SESSION['retval'] = $retval;
@@ -199,7 +199,7 @@
199199
return;
200200
}
201201
$_SESSION['retval'] = $retval;
202-
$actual = isset($retval->docker->stdout) && strlen($retval->docker->stdout) > 0 ? $retval->docker->stdout : false;
202+
$actual = isset($retval->pipe->stdout) && strlen($retval->pipe->stdout) > 0 ? $retval->pipe->stdout : false;
203203
$_SESSION['actual'] = $actual;
204204
$_SESSION['checkgrade'] = 'true';
205205
}

0 commit comments

Comments
 (0)