base64download

in #base646 years ago (edited)

base64download.php to access the files from any server running php.

<?php require_once 'cleanstring.php'; $user = $_GET['user']; $permlink = $_GET['permlink']; $jsid = rand(1,90); $content = "{ \"id\":\"$jsid\", \"jsonrpc\":\"2.0\", \"method\":\"get_content\", \"params\":[\"$user\",\"$permlink\"] }";

$url = "http://steemd.privex.io/";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

$json_response = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ( $status != 200 ) {
$url = "https://api.steemit.com/";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

$json_response = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ( $status != 200 )
{
    die("No Steem Api response, please try again.");
}

}

curl_close($curl);

$response = json_decode($json_response, true);

$compbody = $response['result']['body'];

$teile = explode("base64filename", $compbody);

$filename = $teile['1'];
$filebodyprep = $teile['2'];
$teile = explode("base64file",$filebodyprep);
$filebody = $teile['1'];
$filebody = base64_decode($filebody);
$filename = removespace($filename);

$tempdir = sys_get_temp_dir();
$tmpName = "$tempdir/$filename";

$file = fopen($tmpName, 'w');

fwrite($file, $filebody);
fclose($file);

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="'.basename($tmpName).'"');
header('Pragma: public');
header('Content-Length: ' . filesize($tmpName));
readfile($tmpName);

ob_clean();
flush();
unlink($tmpName);
//decode test end

?>

Sort:  

Congratulations @filebot! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You published more than 10 posts. Your next target is to reach 20 posts.

Click here to view your Board
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Do not miss the last post from @steemitboard:

Valentine challenge - Love is in the air!

Support SteemitBoard's project! Vote for its witness and get one more award!