first commit
This commit is contained in:
57
methode/hashes/assemble.php
Normal file
57
methode/hashes/assemble.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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';
|
||||
|
||||
$width = 840;
|
||||
$height = 104;
|
||||
$h = $height*6;
|
||||
$final_hash = 'default';
|
||||
|
||||
$img = imagecreatetruecolor($width, $h);
|
||||
|
||||
$tr = imagecolorallocate($img, 220, 220, 220);
|
||||
imagecolortransparent($img, $tr);
|
||||
imagefilledrectangle($img, 0, 0, $width, $height*6, $tr);
|
||||
|
||||
$handle = fopen(DATA_PATH.'/hashes2hashes/liste.txt', 'r');
|
||||
if ($handle) {
|
||||
while (($hash = fgets($handle, 4096)) !== false) {
|
||||
$hash = preg_replace('~[[:cntrl:]]~', '', $hash);
|
||||
$split = explode(' ', $hash);
|
||||
$hash = $split[1];
|
||||
if ($final_hash == 'default') $final_hash = $hash;
|
||||
$hash = DATA_PATH.'/hashes/'.$hash.'.png';
|
||||
if (file_exists($hash))
|
||||
{
|
||||
$h -= $height;
|
||||
$src_img = imagecreatefrompng($hash);
|
||||
if ($src_img)
|
||||
{
|
||||
if (FALSE === imagecopy($img, $src_img, 0, $h, 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;
|
||||
}
|
||||
if (!feof($handle)) {
|
||||
echo "Erreur: fgets() a échoué".PHP_EOL;
|
||||
}
|
||||
fclose($handle);
|
||||
} else echo "Erreur: fopen('".DATA_PATH."/hashes2hashes/liste.txt') a échoué".PHP_EOL;
|
||||
|
||||
imagepng($img, DATA_PATH.'/hashes2hashes/'.$final_hash.'.png');
|
||||
|
||||
imagedestroy($img);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user