Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sfcode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ayush
sfcode
Commits
0d45b97a
Commit
0d45b97a
authored
Dec 03, 2020
by
Gudipaty Aniket
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added execute.php
parent
de2633b0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
backend/execute.php
backend/execute.php
+53
-0
No files found.
backend/execute.php
0 → 100644
View file @
0d45b97a
<?php
$postData
=
file_get_contents
(
"php://input"
);
$uid
=
$postData
[
'id'
];
$filename
=
$postData
[
'filename'
];
$language
=
$postData
[
'language'
];
$input_data
=
$postData
[
'input_data'
];
$ret_stat
=
0
;
$template
=
$uid
.
strval
(
rand
(
1
,
1000000
));
$in_fname
=
"temp_in"
.
$template
;
$file
=
fopen
(
$in_fname
,
'w'
);
file_put_contents
(
$in_fname
,
$input_data
);
fclose
(
$file
);
$out_fname
=
"temp_out"
.
$template
;
if
(
strcmp
(
$language
,
"cpp"
)
==
0
)
{
$base
=
basename
(
$filename
,
".cpp"
);
system
(
"./"
.
$uid
.
"/"
.
$base
.
" < "
.
$in_fname
.
" > "
.
$out_fname
,
$ret_stat
);
}
else
if
(
strcmp
(
$language
,
"java"
)
==
0
)
{
$base
=
basename
(
$filename
,
".java"
);
system
(
"java -cp "
.
$uid
.
"/ "
.
$base
.
" < "
.
$in_fname
.
" > "
.
$out_fname
,
$ret_stat
);
}
else
if
(
strcmp
(
$language
,
"python"
)
==
0
)
{
system
(
"python3 "
.
$uid
.
"/"
.
$filename
.
" < "
.
$in_fname
.
" > "
.
$out_fname
,
$ret_stat
);
}
if
(
$ret_stat
!=
0
)
{
echo
"Runtime Error!!"
;
}
else
{
$file
=
fopen
(
$out_fname
,
'r'
);
echo
fread
(
$file
,
filesize
(
$out_fname
));
fclose
(
$file
);
}
unlink
(
$in_fname
);
unlink
(
$out_fname
);
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment