#!/usr/bin/php
<?php
$content = 'redirect=false&code=' . urlencode(file_get_contents('php://stdin'));
$streamParams = array(
'http' => array(
'method' => 'POST',
'content' => $content,
'header' => 'Content-Type: application/x-www-form-urlencoded',
),
);
$context = stream_context_create($streamParams);
$fp = fopen('http://paste.roguecoders.com/', 'rb', false, $context);
if (!$fp) {
throw new Exception("Error opening stream");
} else {
$result = stream_get_contents($fp);
echo "URL: $result\n";
if (PHP_OS == 'Darwin') {
$x = popen('pbcopy', 'w');
fwrite($x, $result);
fclose($x);
}
}