Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

73 linhas
1.7 KiB

<?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];
$nb_max=6;
if (isset($argv[2])) $nb_max=intval($argv[2]);
$width       = 840;
$height      = 104;
$final_hash  = 'default';
$img = imagecreatetruecolor($width, $height*$nb_max);
$gris = imagecolorallocate($img, 180, 180, 180);
$noir = imagecolorallocate($img, 0, 0, 0);
$tr = imagecolorallocate($img, 220, 220, 220);
imagecolortransparent($img, $tr);
imagefilledrectangle($img, 0, 0, $width, $height*$nb_max, $tr);
for($i=0; $i<$nb_max; $i++)
{
  $the_block = blockchain::getBlockWithHash($block_hash);
  if ($the_block === FALSE) die();
 
  $block_hash = $the_block->prev_block;
  $hash=DATA_PATH.'/hashes/'.$the_block->hash.'.png';
  if ($final_hash  == 'default') $final_hash = $hash;
  if (file_exists($hash))
  {
    $src_img = imagecreatefrompng($hash);
    if ($src_img) 
    {
      if (FALSE === imagecopy($img, $src_img, 0, ($height*$i), 0, 0, $width, $height))
        echo "Erreur : problème de copie image".PHP_EOL;
    } else echo "Erreur: ".$hash." ne semble pas être une image PNG".PHP_EOL;
  } else echo "Erreur: ".$hash." n'a pas été trouvé".PHP_EOL;
}
imagepng($img, DATA_PATH.'/hashes2hashes/'.$final_hash.'.png');
imagedestroy($img);
?>