|
|
<?php
|
|
|
|
|
|
// ---
|
|
|
// --- Listening to blockchain.info to get the last block
|
|
|
// ---
|
|
|
|
|
|
// ---
|
|
|
// --- La config globale
|
|
|
// ---
|
|
|
require_once '../../global/inc/config.php';
|
|
|
|
|
|
// ---
|
|
|
// --- External dependances
|
|
|
// ---
|
|
|
require TOPISTO_PATH.'/ressources/vendor/autoload.php';
|
|
|
|
|
|
// ---
|
|
|
// --- Internal dependances
|
|
|
// ---
|
|
|
require_once APP_PATH.'/blockchain/inc/block.php';
|
|
|
require_once APP_PATH.'/methode/spline/inc/splines.php';
|
|
|
|
|
|
// ---
|
|
|
// --- Par défaut on cherche le dernier block
|
|
|
// ---
|
|
|
$block_hash = 'LAST';
|
|
|
|
|
|
// ---
|
|
|
// --- Le cas échéant, on cherche block passé en argument
|
|
|
// ---
|
|
|
if (isset($argv[1])) $block_hash = $argv[1];
|
|
|
|
|
|
$mode=8;
|
|
|
if (isset($argv[2])) $mode=intval($argv[2]);
|
|
|
|
|
|
$the_block = blockchain::getBlockWithHash($block_hash);
|
|
|
if ($the_block === FALSE) die();
|
|
|
|
|
|
$the_name = blockchain::hash2SpecialName($the_block->hash);
|
|
|
if ($the_name == $the_block->hash) $the_name ='';
|
|
|
|
|
|
$mode = 0;
|
|
|
$iterations = 1;
|
|
|
|
|
|
$bandeau = 50;
|
|
|
$marge = 25;
|
|
|
$text_border = 20;
|
|
|
$width = GRAPH_WIDTH;
|
|
|
$height = GRAPH_HEIGHT;
|
|
|
|
|
|
$img_w = $marge + ($width*2) + (2*$text_border);
|
|
|
$img_h = $marge + ($height*2) + (2*$bandeau);
|
|
|
|
|
|
// création d'une image plus haute pour inclure bandeaux haut et bas
|
|
|
$img = imagecreatetruecolor( $img_w, $img_h);
|
|
|
|
|
|
$param_header = blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
|
|
$tr_color = $param_header[0];
|
|
|
$fond = $param_header[1];
|
|
|
$font = $param_header[3];
|
|
|
$fontColor = $param_header[2];
|
|
|
|
|
|
//
|
|
|
// Les 4 parties du block : inputs, outputs, fees, reward
|
|
|
//
|
|
|
$mode=5;
|
|
|
$iterations=50;
|
|
|
|
|
|
$type=1;
|
|
|
$x0 = $text_border; $y0 = $bandeau;
|
|
|
topisto_spline::DefaultDrawBlock($the_block, $img, $x0, $y0, $bandeau + $width*2, $height, $type);
|
|
|
|
|
|
$type=3;
|
|
|
$x0 = $text_border; $y0 = $marge+$height+$bandeau;
|
|
|
topisto_spline::DefaultDrawBlock($the_block, $img, $x0, $y0, $width, $height, $type);
|
|
|
|
|
|
$type=4;
|
|
|
$x0 = $text_border+$marge+$width; $y0 = $marge+$height+$bandeau;
|
|
|
topisto_spline::DefaultDrawBlock($the_block, $img, $x0, $y0, $width, $height, $type);
|
|
|
|
|
|
imagefilledrectangle($img, 0, $bandeau, $text_border, $img_h-$bandeau, $fond);
|
|
|
imagefilledrectangle($img, $img_w-$text_border, $bandeau, $img_w, $img_h-$bandeau, $fond);
|
|
|
imagefilledrectangle($img, $text_border+$width, $bandeau + $height, $text_border+$marge+$width, $img_h-$bandeau, $fond);
|
|
|
imagefilledrectangle($img, 0, $bandeau+$height, $img_w - $text_border, $bandeau+$marge+$height, $fond);
|
|
|
|
|
|
// Les textes
|
|
|
$the_texte = "Outputs : ".$the_block->topisto_inputs;
|
|
|
imagettftext($img,15, 90, $text_border-3, $bandeau+$height, $fontColor, $font, $the_texte);
|
|
|
|
|
|
$the_texte = "Fees : ".$the_block->topisto_fees;
|
|
|
imagettftext($img,15, 90, $text_border-3, $bandeau+(2*$height)+$marge-3, $fontColor, $font, $the_texte);
|
|
|
|
|
|
$the_texte = "Reward : ".$the_block->topisto_reward;
|
|
|
imagettftext($img,15, 90, $text_border+$width+$marge-3, $bandeau+(2*$height)+$marge-3, $fontColor, $font, $the_texte);
|
|
|
|
|
|
imagepng($img, DATA_PATH.'/full_spline/'.$the_block->hash.'.png');
|
|
|
|
|
|
imagedestroy($img);
|
|
|
|
|
|
?>
|