Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 47 lines (37 sloc) 1.062 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: 2012 by Digital Mars

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;
?>
Something went wrong with that request. Please try again.