This commit is contained in:
2018-10-31 10:06:43 +01:00
parent e121c6f6dd
commit b3ad46d98a
39 changed files with 1757 additions and 1116 deletions

View File

@@ -32,7 +32,9 @@ class blockchain
'BCC' => '00000000000000000019f112ec0a9982926f1258cdcc558dd7c3b7e5dc7fa148',
'SEGWIT_LOCK' => '0000000000000000012e6060980c6475a9a8e62a1bf44b76c5d51f707d54522c',
'SEGWIT' => '000000000000000000cbeff0b533f8e1189cf09dfbebf57a8ebe349362811b80',
'HURRICANE_1' => '0000000000000000000fe6d521a187a5523d5cef6f6c178923ff82ffe5a0f372'
'HURRICANE_1' => '0000000000000000000fe6d521a187a5523d5cef6f6c178923ff82ffe5a0f372',
'WHALE201810' => '0000000000000000000f9f2dadfb8f312572183272802cbfcc4ff95b4ee6777d',
'BLOCK21E800' => '00000000000000000021e800c1e8df51b22c1588e5a624bea17e9faa34b2dc4a'
);
// ---
@@ -211,7 +213,7 @@ class blockchain
return NULL;
}
public static function DrawBlockHeaderFooter($the_block, $vImage, $hauteur)
public static function DrawBlockHeaderFooter($the_block, $vImage, $hauteur, $couleur = -1)
{
$color_tab = [
[
@@ -250,18 +252,27 @@ class blockchain
[40, 40, 40],
[158,227,253]
],
[
[255, 255, 255],
[0, 0, 0]
],
[
[0, 0, 0],
[255, 255, 255]
],
[
[255, 255, 255],
[255, 0, 0]
]
];
$color = rand(0,count($color_tab)-1);
$color = $couleur;
if ($color == -1) $color = rand(0,count($color_tab)-1);
// Rajout des HASHES
$white = imagecolorallocate($vImage, 254, 254, 254);
$black = imagecolorallocate($vImage, $color_tab[$color][1][0], $color_tab[$color][1][1], $color_tab[$color][1][2]);
$fond = imagecolorallocate($vImage, $color_tab[$color][0][0], $color_tab[$color][0][1], $color_tab[$color][0][2]);
$fond = imagecolorallocate($vImage, $color_tab[$color][0][0], $color_tab[$color][0][1], $color_tab[$color][0][2]);
$w = imagesx($vImage);
$h = imagesy($vImage);
@@ -272,7 +283,7 @@ class blockchain
imagefilledrectangle($vImage, 0, 0, $w, $h, $white);
$len = strlen($the_block->hash);
$ratio_w = $w / $len;
$ratio_w = ($w - 10) / $len;
$ratio_h = $hauteur / 32; // car hexadécimal
// Récupérer les hashes dans 2 tableaux
@@ -295,7 +306,7 @@ class blockchain
$coin_x1 = $ratio_w * $i;
$coin_x2 = $ratio_w * ($i + 1);
$coin_y1 = $hauteur;
$coin_y2 = hexdec($tableau1[$i])*$ratio_h;
$coin_y2 = 5 + hexdec($tableau1[$i])*$ratio_h;
$points1[] = $coin_x1;
$points1[] = $coin_y2;
@@ -306,7 +317,7 @@ class blockchain
$coin_x1 = $ratio_w * $i;
$coin_x2 = $ratio_w * ($i + 1);
$coin_y1 = $hauteur;
$coin_y2 = 16 - (hexdec($tableau2[$i])*$ratio_h);
$coin_y2 = 25 - hexdec($tableau2[$i])*$ratio_h;
$points2[] = $coin_x1;
$points2[] = $coin_y2;
@@ -314,6 +325,28 @@ class blockchain
$points2[] = $coin_y2;
}
// Rajouter une barre au HASH
$coin_x1 = $ratio_w * $i;
$coin_x2 = $ratio_w * ($i + 1);
$coin_y1 = $hauteur;
$coin_y2 = 5;
$points1[] = $coin_x1;
$points1[] = $coin_y2;
$points1[] = $coin_x2;
$points1[] = $coin_y2;
// Rajouter une barre au PREV HASH
$coin_x1 = $ratio_w * $i;
$coin_x2 = $ratio_w * ($i + 1);
$coin_y1 = $hauteur;
$coin_y2 = 25;
$points2[] = $coin_x1;
$points2[] = $coin_y2;
$points2[] = $coin_x2;
$points2[] = $coin_y2;
// Rajouter un coin
$points1[] = $w;
$points1[] = $hauteur - 1;
@@ -324,7 +357,7 @@ class blockchain
// Inverser le PREV HASH
for($i=0;$i<count($points2);$i+=2)
{
$points2[$i+1] = ($h - 12) - $points2[$i+1];
$points2[$i+1] = $h - $points2[$i+1];
if ($points2[$i+1] >= $h) $points2[$i+1] = $h - 1;
}
@@ -332,12 +365,10 @@ class blockchain
imagefilledpolygon($vImage, $points1, (count($points1)/2), $fond);
imagepolygon($vImage, $points1, (count($points1)/2), $black);
// dessiner le PREV HASH
// Dessiner le PREV HASH
imagefilledpolygon($vImage, $points2, (count($points2)/2), $fond);
imagepolygon($vImage, $points2, (count($points2)/2), $black);
imagefilledrectangle($vImage, 0, $hauteur, $w, $h-$hauteur, $black);
// Rajout des textes
$the_name = blockchain::hash2SpecialName($the_block->hash);
if ($the_name == $the_block->hash) $the_name = date('Ymd H:i:s', $the_block->time);