forked from kinaba/dlang-ref-jp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.php
More file actions
46 lines (37 loc) · 1.04 KB
/
process.php
File metadata and controls
46 lines (37 loc) · 1.04 KB
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
<?php
/**
Runnable examples functionality
Copyright: Damian Ziemba 2012
License: http://boost.org/LICENSE_1_0.txt, Boost License 1.0
Authors: Andrei Alexandrescu, Damian Ziemba
*/
if (!isset($_POST))
$_POST = $HTTP_POST_VARS;
if (!isset($_POST["code"]))
return;
$code = $_POST['code'];
$stdin = $_POST['stdin'];
$args = $_POST['args'];
$str = "compiler=dmd2&code=$code&stdin=$stdin&args=$args&unittest=1";
$result = "";
$fp = fsockopen("dpaste.dzfl.pl", 80, $errno,$errstr, 15);
if ($fp)
{
fputs($fp, "POST /request/ HTTP/1.1\r\n");
fputs($fp, "Host: dpaste.dzfl.pl\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ".strlen($str)."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $str."\r\n\r\n");
while(!feof($fp))
$result .= fgets($fp,4096);
fclose($fp);
}
$pos = strpos($result, '<?xml ');
if ($pos !== false) {
header("Content-Type: application/xml");
echo substr($result, $pos, -5);
}
else
echo $result;
?>