summaryrefslogtreecommitdiff
path: root/blapaste.php
diff options
context:
space:
mode:
authorPhil Burton <phil@d3r.com>2018-01-11 11:18:13 +0000
committerPhil Burton <phil@d3r.com>2018-01-11 11:18:13 +0000
commit06af94800a8f51fb36073bfb3ea4449b80758c6c (patch)
tree723f974f7ca4362b03e0d25135b91469be30d577 /blapaste.php
parent2cc37300f9e88549e93a2c8d4f0f8170695e592a (diff)
Fix formattingHEADmaster
Diffstat (limited to 'blapaste.php')
-rwxr-xr-xblapaste.php27
1 files changed, 21 insertions, 6 deletions
diff --git a/blapaste.php b/blapaste.php
index db11734..19290da 100755
--- a/blapaste.php
+++ b/blapaste.php
@@ -1,24 +1,39 @@
#!/usr/bin/php
<?php
+
+/**
+ * Takes standard input and sends it all to p.of.je via post
+ *
+ * @author Phil Burton <phil@d3r.com>
+ */
+
+// Grab the STIN
$stdin = fopen("php://stdin", "r");
$paste = "";
+
while (false !== ($line = fgets($stdin))) {
- $paste .= $line;
+ $paste .= $line;
}
+
+// Set-up a curl request
$url = "http://p.of.je/submit.php";
-$myvars = "paste=" . urlencode($paste);
+$myvars = "paste=" . urlencode($paste); // Requires url encoding
+
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+
$response = curl_exec($ch);
$response = explode("\n", $response);
+
+// Get and return response
foreach ($response as $line) {
- if (strpos($line, "Location") !== false) {
- echo $line . "\n";
- exit;
- }
+ if (strpos($line, "Location") !== false) {
+ echo $line . "\n";
+ exit;
+ }
}
echo "failed\n";