Skip to content

Instantly share code, notes, and snippets.

@jwne
Forked from SilverCory/submit.php
Created May 20, 2016 19:41
Show Gist options
  • Save jwne/bb42af4f897a7f439593b7fbaa8ce68a to your computer and use it in GitHub Desktop.
Save jwne/bb42af4f897a7f439593b7fbaa8ce68a to your computer and use it in GitHub Desktop.
So you can past log files to hastebin. Because it's moar sexy than the ones they provide.
// PUT THIS SECTION AT http://your-site.com/submit.php
<?php
function grab_dump($var)
{
ob_start();
var_dump($var);
return ob_get_clean();
}
function sendTo( $string ) {
//echo( $string );
header( "Location: " . $string );
}
$ch = curl_init("http://hastebin.com/documents");
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST["pastetext"] );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$response = curl_exec( $ch );
if($errno = curl_errno($ch)) {
$error_message = curl_strerror($errno);
sendTo( "http://cURL.error/({$errno}):_{$error_message}" );
}
$keyJson = json_decode( $response, true );
sendTo( "http://hastebin.com/" . $keyJson['key'] );
//======================================= SECTION TWO ===========================================//
// Use this as /usr/share/pastebin.d/hastebin.com.conf
// Yeah you need pastebinit.
// Something like "sudo apt-get install pastebinit" to install it.
/*
[pastebin]
basename = your-site.com
regexp = "http://your-site.com"
[format]
user = desc
content = pastetext
page = page
[defaults]
page = "/submit.php"
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment