|
|
<?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';
|
|
|
|
|
|
// ---
|
|
|
// --- 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=rand(0, 5);
|
|
|
if (isset($argv[2])) $mode=intval($argv[2]);
|
|
|
|
|
|
$the_block = blockchain::getBlockWithHash($block_hash);
|
|
|
if ($the_block === FALSE) die();
|
|
|
|
|
|
$bandeau = 50;
|
|
|
$marge = 0;
|
|
|
$text_border = 20;
|
|
|
$width = GRAPH_WIDTH;
|
|
|
$height = 2;
|
|
|
|
|
|
// Pour que l'image simple ait les proportions que l'image full
|
|
|
$width = $marge + ($width*2) + (2*$text_border);
|
|
|
$height = $marge + ($height*2);
|
|
|
|
|
|
$img_w = $width;
|
|
|
$img_h = $height+(2*$bandeau);
|
|
|
|
|
|
// création d'une image plus haute pour inclure bandeaux haut et bas
|
|
|
$img = imagecreatetruecolor($img_w, $img_h);
|
|
|
|
|
|
$paramHeader = blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
|
|
|
|
|
|
imagefilledrectangle($img, 0, $bandeau, $width, $bandeau + $height, $paramHeader[2]);
|
|
|
|
|
|
imagefilledrectangle($img, 0, 0, 0, $img_h, $paramHeader[2]);
|
|
|
imagefilledrectangle($img, $img_w-1, 0, $img_w-1, $img_h, $paramHeader[2]);
|
|
|
|
|
|
imagepng($img, DATA_PATH.'/hashes/'.$the_block->hash.'.png');
|
|
|
|
|
|
imagedestroy($img);
|
|
|
|
|
|
?>
|