Compare commits
18 Commits
e0cde58e4a
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| f154d9ab4d | |||
| d403c2c90f | |||
| 2be9292816 | |||
| ebbb33cb45 | |||
| c812e2f79d | |||
| 1fab7825da | |||
| 5e70658660 | |||
| 4801821219 | |||
| 42123bbad6 | |||
| dddc112916 | |||
| 4455798ad8 | |||
| 1689bd6cd3 | |||
| 514daaeaf1 | |||
| dd9e477e47 | |||
| 3f4bdf65e0 | |||
| ccede092d0 | |||
| 86576841f4 | |||
| 43d87614ea |
@@ -2,6 +2,8 @@
|
||||
|
||||
$url = 'http://x:m3lch1s3d3k@127.0.0.1:8332';
|
||||
|
||||
$url = 'http://bitcoinrpc:EF/iNKFWzQkpoTB+VFaSGk1+qZPckHsLfKu+3HZddpRr@77.159.16.114:8332';
|
||||
|
||||
$data = array("method" => "getbestblockhash");
|
||||
$json_data = json_encode($data);
|
||||
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
<?php
|
||||
|
||||
class block
|
||||
{
|
||||
public $hash = null;
|
||||
public $height = null;
|
||||
public $name = null;
|
||||
public $desc = null;
|
||||
|
||||
function __construct($ahash, $aheight, $aname = null, $adesc = null)
|
||||
{
|
||||
$this->hash = $ahash;
|
||||
$this->height = $aheight;
|
||||
$this->name = $aname;
|
||||
$this->desc = $adesc;
|
||||
}
|
||||
}
|
||||
|
||||
class blockchain
|
||||
{
|
||||
private static $url_info = 'https://blockchain.info/fr';
|
||||
@@ -9,8 +25,11 @@ class blockchain
|
||||
*
|
||||
* 'GENESIS' - Premier block de la blochain
|
||||
* 'THE_ANSWER' - Block 42 (pour le fun)
|
||||
* 'HAL_FINLEY' - Hal Finley has mined this block
|
||||
* 'FIRST_TX' - First exchange between Satoshi and Hal Finley
|
||||
* 'LUCIFER' - Block 666 (pour le fun)
|
||||
* 'LEET' - Block 1337 (pour le fun)
|
||||
* 'FISRT_USD_TX' - Martti Malmi change 5000 BTC for 5,02 $
|
||||
* 'PIZZA' - Block 57035 : le block du pizza day, 22 05 2010
|
||||
* 'HALVING_1' - First halving, block 2100000, 28 11 2012
|
||||
* 'HALVING_2' - Second halving, block 420000, 09 07 2017
|
||||
@@ -18,34 +37,269 @@ class blockchain
|
||||
* 'BCC' - Block 478558 : Bitcoin Cash Fork 01/08/2017
|
||||
* 'SEGWIT_LOCK' - Block 479808 SEGWIT est verrouillé 09 08 2017
|
||||
* 'SEGWIT' - Block 481823 SEGWIT est activé 24 08 2017
|
||||
* 'HALVING_3' - Third Hhalving, block 630000, 11 05 2020
|
||||
* 'DORMEUR' - Block 631058 Une adresse datant de 2009 dépense ses 50 BTC de reward
|
||||
* TX : cb1440c787d8a46977886405a34da89939e1b04907f567bf182ef27ce53a8d71
|
||||
*
|
||||
* ____JUMP______ : Lorsque le cours atteint certains palier (à la hausse ou à la baisse)
|
||||
* WHALE____ : Lorsqu'une baleine remonte respirer (grosse TX)
|
||||
* GOLGOTH____ : Lorsque le GOLGOTH pousse fort ... (grosse TX)
|
||||
*/
|
||||
private static $special_blocks = array (
|
||||
'GENESIS' => '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
|
||||
'THE_ANSWER' => '00000000314e90489514c787d615cea50003af2023796ccdd085b6bcc1fa28f5',
|
||||
'LUCIFER' => '00000000fc5b3c76f27f810ee775e480ae7fd604fd196b2d8da4257fcd39f4f9',
|
||||
'LEET' => '000000008bf44a528a09d203203a6a97c165cf53a92ecc27aed0b49b86a19564',
|
||||
'TOPISTO' => '000000000a73e64735a2b75c97ea674950a9018da1420d01328a918c9ff9852c',
|
||||
'PIZZA' => '00000000006de085dadb3ec413ef074022fe781121b467e98960280dd246bb00',
|
||||
'HALVING_1' => '000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e',
|
||||
'WHALE201311' => '0000000000000001bc7156dd1183c87859b326affa3a5cdd157e809537f0b284',
|
||||
'HALVING_2' => '000000000000000002cce816c0ab2c5c269cb081896b7dcb34b8422d6b74ffa1',
|
||||
'BIP_91_LOCK' => '0000000000000000015411ca4b35f7b48ecab015b14de5627b647e262ba0ec40',
|
||||
'BCC' => '00000000000000000019f112ec0a9982926f1258cdcc558dd7c3b7e5dc7fa148',
|
||||
'SEGWIT_LOCK' => '0000000000000000012e6060980c6475a9a8e62a1bf44b76c5d51f707d54522c',
|
||||
'SEGWIT' => '000000000000000000cbeff0b533f8e1189cf09dfbebf57a8ebe349362811b80',
|
||||
'HURRICANE_1' => '0000000000000000000fe6d521a187a5523d5cef6f6c178923ff82ffe5a0f372',
|
||||
'BLOCK21E800' => '00000000000000000021e800c1e8df51b22c1588e5a624bea17e9faa34b2dc4a',
|
||||
'WHALE201810' => '0000000000000000000f9f2dadfb8f312572183272802cbfcc4ff95b4ee6777d'
|
||||
private static $special_blocks = null;
|
||||
|
||||
// ----
|
||||
// -- Des fonctions outils
|
||||
// -- Parce que depuis PHP.7.0.33-10, file_get_contents ne focnitonne plus en HTTPS
|
||||
// ----
|
||||
private static function get_curl_data($url)
|
||||
{
|
||||
$ch = curl_init();
|
||||
$timeout = 5;
|
||||
curl_setopt($ch,CURLOPT_URL,$url);
|
||||
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
|
||||
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
|
||||
$data = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $data;
|
||||
}
|
||||
|
||||
private static function get_data($url, $with_curl = true)
|
||||
{
|
||||
if (!$with_curl)
|
||||
return file_get_contents($url);
|
||||
|
||||
return self::get_curl_data($url);
|
||||
}
|
||||
|
||||
//
|
||||
// Init special blocks array ...
|
||||
//
|
||||
public static function init()
|
||||
{
|
||||
self::$special_blocks = array ();
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'000000000000000000070daa5861fe1e7064ef8007825431229c6c1cab2c766f',
|
||||
654364,
|
||||
'WHALE20201026'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000000000000005c0f74e8b00c3961d6dfbf32936edeaa300015949f3c4',
|
||||
632676,
|
||||
'2020JUMP10000'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000000000000000f811e171eee52157e9a95963140e62fa83610f23ea7e',
|
||||
631058,
|
||||
'DORMEUR'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'000000000000000000024bead8df69990852c202db0e0097c1a12ea637d7e96d',
|
||||
630000,
|
||||
'HALVING_3'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'0000000000000000001186079bbf9a5d945231236135af7a766bd34d814e7319',
|
||||
628710,
|
||||
'RIP_STEEVE'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'000000000000000000099457d2aeb2b7fc8ad8adb1490814cb674dc5767ae9b9',
|
||||
622453,
|
||||
'COVID19'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000000000000001a3c68111789a6c2cc76f1209d1dae63b05460053eb2b',
|
||||
619165,
|
||||
'EQUILIBRE202002'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'0000000000000000000f2306f08e8f34872a24dfaad3423801a91ee1626e9ea4',
|
||||
618986,
|
||||
'SOPHIA202002'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'0000000000000000001085a869441fa2aa77f149a887af0ce59846ef51da6e4c',
|
||||
616193,
|
||||
'EQUILIBRE'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'0000000000000000000b05f877e6e49b380f4f78b3cfb605b67439f825dba197',
|
||||
613470,
|
||||
'2020JUMP9000'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000000000000009e8fb4ac719a362c1c4e3df439740069ee58e2a713258',
|
||||
612149,
|
||||
'DEMISSION20200110'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'000000000000000000051f84a7a1d0f5b2ddaf5682cbec5f7acb2bf5fa339725',
|
||||
593879,
|
||||
'GOLGOTH201909'
|
||||
);
|
||||
|
||||
// 94 500 BTC, soit environ 1 milliards de dollars, 700 dollars de fees ...
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000000000000014fcb29e6e3b0ead3bd2e307d7f619a935f1d5323e9013',
|
||||
593468,
|
||||
'WHALE201909'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'0000000000000000000f9f2dadfb8f312572183272802cbfcc4ff95b4ee6777d',
|
||||
545911,
|
||||
'WHALE201810'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000000000000021e800c1e8df51b22c1588e5a624bea17e9faa34b2dc4a',
|
||||
528249,
|
||||
'BLOCK21E800'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'0000000000000000000fe6d521a187a5523d5cef6f6c178923ff82ffe5a0f372',
|
||||
506734,
|
||||
'HURRICANE_1'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'000000000000000000cbeff0b533f8e1189cf09dfbebf57a8ebe349362811b80',
|
||||
481823,
|
||||
'SEGWIT'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'0000000000000000012e6060980c6475a9a8e62a1bf44b76c5d51f707d54522c',
|
||||
479808,
|
||||
'SEGWIT_LOCK'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000000000000019f112ec0a9982926f1258cdcc558dd7c3b7e5dc7fa148',
|
||||
478559,
|
||||
'BCC'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'0000000000000000015411ca4b35f7b48ecab015b14de5627b647e262ba0ec40',
|
||||
477120,
|
||||
'BIP_91_LOCK'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'000000000000000002cce816c0ab2c5c269cb081896b7dcb34b8422d6b74ffa1',
|
||||
420000,
|
||||
'HALVING_2'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'0000000000000001bc7156dd1183c87859b326affa3a5cdd157e809537f0b284',
|
||||
270953,
|
||||
'WHALE201311'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e',
|
||||
210000,
|
||||
'HALVING_1'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'000000000000041c718cd2fa4270ab80c917bb94caa79c84b417b7924a867a68',
|
||||
196883,
|
||||
'JOHN_CONWAY'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000006de085dadb3ec413ef074022fe781121b467e98960280dd246bb00',
|
||||
57035,
|
||||
'PIZZA'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000132fbe8314fc571c0be60b31ccd461c9ee85f42bde8c6d160a9dacc0',
|
||||
24835,
|
||||
'FIRST_USD_TX'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'000000000a73e64735a2b75c97ea674950a9018da1420d01328a918c9ff9852c',
|
||||
5637,
|
||||
'TOPISTO'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000a70ba4a405c67310757606dd955cf1a3a8e5c042335d78394ea6cb67',
|
||||
3654,
|
||||
'DORMEUR_ORIGINE'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'000000008bf44a528a09d203203a6a97c165cf53a92ecc27aed0b49b86a19564',
|
||||
1337,
|
||||
'LEET'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000fc5b3c76f27f810ee775e480ae7fd604fd196b2d8da4257fcd39f4f9',
|
||||
666,
|
||||
'LUCIFER'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000d1145790a8694403d4063f323d499e655c83426834d4ce2f8dd4a2ee',
|
||||
170,
|
||||
'FIRST_TX'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000a2886c95400fd3b263b9920af80b118b28fee5d2a162a18e4d9d8b2f',
|
||||
78,
|
||||
'HAL_FINLEY'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'00000000314e90489514c787d615cea50003af2023796ccdd085b6bcc1fa28f5',
|
||||
42,
|
||||
'THE_ANSWER'
|
||||
);
|
||||
|
||||
self::$special_blocks[] = new block(
|
||||
'000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
|
||||
0,
|
||||
'GENESIS'
|
||||
);
|
||||
}
|
||||
|
||||
// ---
|
||||
// --- Retourne le nom d'un block à partie de son hash
|
||||
// --- Retourne le JSON du tableau des blocs speciaux
|
||||
// ---
|
||||
public static function getSpecialBlocksJSON()
|
||||
{
|
||||
return json_encode(self::$special_blocks);
|
||||
}
|
||||
|
||||
// ---
|
||||
// --- Retourne le nom d'un block à partir de son hash
|
||||
// --- si ce n'est pas un block special, on renvoie le hash
|
||||
// ---
|
||||
public static function hash2SpecialName($block_hash)
|
||||
{
|
||||
foreach(self::$special_blocks as $key => $value)
|
||||
if ($block_hash == $value) return $key;
|
||||
foreach(self::$special_blocks as $value)
|
||||
if ($block_hash == $value->hash) return $value->name;
|
||||
|
||||
return $block_hash;
|
||||
}
|
||||
@@ -59,7 +313,14 @@ class blockchain
|
||||
{
|
||||
$block_hash = '';
|
||||
|
||||
if (isset(self::$special_blocks[$nom_du_block])) $block_hash = self::$special_blocks[$nom_du_block];
|
||||
foreach(self::$special_blocks as $value)
|
||||
{
|
||||
if ($nom_du_block == $value->name)
|
||||
{
|
||||
$block_hash = $value->hash;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (file_exists(self::$offline_block)) $block_hash = 'offline';
|
||||
|
||||
@@ -78,7 +339,7 @@ class blockchain
|
||||
if (isset($myarray[0]))
|
||||
{
|
||||
usort( $myarray, function( $a, $b ) { return filemtime($b) - filemtime($a); } );
|
||||
return substr(basename($myarray[0],'.png'),0,strlen(self::$special_blocks['GENESIS']));
|
||||
return substr(basename($myarray[0],'.png'),0,strlen(self::$special_blocks[0]->hash));
|
||||
}
|
||||
|
||||
// S'il n'y a rien dans le cache d'images
|
||||
@@ -107,7 +368,7 @@ class blockchain
|
||||
if (file_exists(self::$offline_block)) return 'offline';
|
||||
|
||||
$filename=self::$url_info.'/latestblock';
|
||||
$message = file_get_contents($filename);
|
||||
$message=self::get_data($filename);
|
||||
if ($message === FALSE) return FALSE;
|
||||
$the_block = json_decode($message);
|
||||
return $the_block->hash;
|
||||
@@ -124,7 +385,7 @@ class blockchain
|
||||
if (!file_exists(DATA_PATH."/json/$block_hash.zip"))
|
||||
{
|
||||
$filename=self::$url_info.'/rawblock/'.$block_hash;
|
||||
$message = file_get_contents($filename);
|
||||
$message=self::get_data($filename);
|
||||
if ( $message === FALSE ) return FALSE;
|
||||
$the_block = json_decode($message);
|
||||
return self::saveBlockInTmpDir($the_block);
|
||||
@@ -141,6 +402,14 @@ class blockchain
|
||||
{
|
||||
if (file_exists(DATA_PATH.'/json/'.$the_block->hash.'.zip')) return $the_block;
|
||||
|
||||
// Blockchain.info renvoie des nonces négatifs
|
||||
// Je repasse par la forme binaire pour retrouver
|
||||
// une valeur positive
|
||||
$the_block->nonce_binary_str = decbin($the_block->nonce);
|
||||
if (strlen($the_block->nonce_binary_str) > 32) $the_block->nonce_binary_str = substr($the_block->nonce_binary_str,-32,32);
|
||||
$the_block->topisto_nonce_blockchain_info = $the_block->nonce;
|
||||
$the_block->nonce = bindec($the_block->nonce_binary_str);
|
||||
|
||||
if (!isset($the_block->topisto_inputs))
|
||||
{
|
||||
$the_block->topisto_inputs = 0;
|
||||
@@ -241,6 +510,19 @@ class blockchain
|
||||
[240,147,43],
|
||||
[255,255,255]
|
||||
],
|
||||
// pour splinelineblack
|
||||
[
|
||||
[17,61,86],
|
||||
[254,254,254]
|
||||
],
|
||||
[
|
||||
[17,61,86],
|
||||
[255,134,63]
|
||||
],
|
||||
[
|
||||
[234,220,207],
|
||||
[127,106,85]
|
||||
],
|
||||
[
|
||||
[48,51,107],
|
||||
[255,255,255]
|
||||
@@ -443,4 +725,6 @@ class blockchain
|
||||
}
|
||||
}
|
||||
|
||||
blockchain::init();
|
||||
|
||||
?>
|
||||
|
||||
@@ -15,9 +15,15 @@ rm -f $DATA_PATH/block_list.tmp
|
||||
|
||||
LISTBLOCKS="GENESIS THE_ANSWER LUCIFER LEET \
|
||||
TOPISTO PIZZA HALVING_1 WHALE201311 \
|
||||
JOHN_CONWAY DORMEUR_ORIGINE \
|
||||
HALVING_2 BIP_91_LOCK BCC SEGWIT_LOCK \
|
||||
SEGWIT HURRICANE_1 WHALE201810 \
|
||||
BLOCK21E800 \
|
||||
WHALE201909 WHALE20201026 \
|
||||
BLOCK21E800 GOLGOTH201909 EQUILIBRE \
|
||||
DEMISSION20200110 2020JUMP9000 \
|
||||
SOPHIA202002 EQUILBIRE202002 COVID19 \
|
||||
RIP_STEEVE HALVING_3 DORMEUR \
|
||||
FIRST_USD_TX 2020JUMP10000 \
|
||||
LAST"
|
||||
|
||||
for BLOCK in $LISTBLOCKS
|
||||
|
||||
@@ -11,5 +11,7 @@ export FLAG_PATH=$APPS_PATH/../flags
|
||||
MINUTE=`date +%M`
|
||||
DATE=`date +%Y%m%d0000`
|
||||
|
||||
source scripts/blocks2.sh
|
||||
|
||||
if [ -f scripts/$1.sh ];
|
||||
then
|
||||
source scripts/$1.sh
|
||||
fi
|
||||
|
||||
135
methode2/spirale/draw.php
Normal file
135
methode2/spirale/draw.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
function DrawBlock($the_block, $vImage, $parametres)
|
||||
{
|
||||
// valeurs par défaut
|
||||
$type = 1;
|
||||
|
||||
// Ces variables vont permettre de caler les lignes
|
||||
// dans la zone de dessin en se laissant des marges
|
||||
// en haut et en bas
|
||||
$somme = 0;
|
||||
$min =-1;
|
||||
$max = 0;
|
||||
$marge_x = 10;
|
||||
$marge_y = 10;
|
||||
$facteur_max = 2.5;
|
||||
$alpha = 0;
|
||||
|
||||
// Détermine si on dessine les tx, les fees ou la récompense
|
||||
if (isset($parametres['type'])) $type = $parametres['type'];
|
||||
|
||||
// Paramètres de dessin
|
||||
if (isset($parametres['x'])) $x = $parametres['x'];
|
||||
if (isset($parametres['y'])) $y = $parametres['y'];
|
||||
if (isset($parametres['width'])) $width = $parametres['width'];
|
||||
if (isset($parametres['height'])) $height = $parametres['height'];
|
||||
if (isset($parametres['font_color'])) $vFgColor = $parametres['font_color'];
|
||||
if (isset($parametres['background_color'])) $vBgColor = $parametres['background_color'];
|
||||
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB'];
|
||||
if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB'];
|
||||
|
||||
// Je reprends les couleurs de Tyler Hobbs
|
||||
$couleursRGB=[
|
||||
[234,220,207],
|
||||
[197,46,39],
|
||||
[183,230,214],
|
||||
[248,200,40],
|
||||
[51,41,32],
|
||||
[250,142,41],
|
||||
[5,37,32],
|
||||
[233,201,58],
|
||||
[183,230,214]
|
||||
];
|
||||
$couleurs = [];
|
||||
$nb_couleurs = count($couleursRGB);
|
||||
for($i=0;$i<$nb_couleurs;$i++)
|
||||
$couleurs[$i] = imagecolorallocate($vImage,$couleursRGB[$i][0],$couleursRGB[$i][1],$couleursRGB[$i][2]);
|
||||
|
||||
// Prendre une des couleurs au hasard comme couleur de fond
|
||||
shuffle($couleurs);
|
||||
$fond = $couleurs[0];
|
||||
shuffle($couleurs);
|
||||
|
||||
// Remplir le fond
|
||||
imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond);
|
||||
|
||||
// Récup des données
|
||||
$data = blockchain::getTransactionData($the_block, $type);
|
||||
$n_data = count($data);
|
||||
|
||||
// Calcul des min max
|
||||
foreach($data as $v)
|
||||
{
|
||||
if ($v['value'] > $max) $max = $v['value'];
|
||||
if (($v['value'] < $min)||($min == -1)) $min = $v['value'];
|
||||
$somme += $v['value'];
|
||||
}
|
||||
if ($min == $max) $max = $min + 1;
|
||||
if ($somme == 0) return;
|
||||
|
||||
// On commence au centre de l'image
|
||||
$xc = $x + ($width / 2);
|
||||
$yc = $y + ($height / 2);
|
||||
$r = $width / 3;
|
||||
$cur = 0;
|
||||
$n = 0;
|
||||
$x1 = $xc;
|
||||
$y1 = $yc;
|
||||
$x2 = $xc;
|
||||
$y2 = $yc;
|
||||
|
||||
// Trouver le max
|
||||
$max=0;
|
||||
while(true){
|
||||
$r1 = 0.05 * $max;
|
||||
$x2 = $xc + $r1*cos($r1);
|
||||
$y2 = $yc + $r1*sin($r1);
|
||||
if (($x2 > $width) || ($x2 < 0)) break;
|
||||
if (($y2 > $height) || ($y2 < 0)) break;
|
||||
imageline($vImage, $x1, $y1, $x2, $y2, $couleurs[0]);
|
||||
$x1 = $x2;
|
||||
$y1 = $y2;
|
||||
$max++;
|
||||
}
|
||||
$coef = floatval($max) / floatval($somme);
|
||||
|
||||
$cur = 0;
|
||||
$n = 0;
|
||||
$x1 = $xc;
|
||||
$y1 = $yc;
|
||||
$x2 = $xc;
|
||||
$y2 = $yc;
|
||||
|
||||
foreach($data as $transaction)
|
||||
{
|
||||
// chaque fois que toutes les couleurs ont été utilisées
|
||||
// on mélange leur ordre
|
||||
if (!($n%$nb_couleurs)) shuffle($couleurs);
|
||||
// S'il n'y a qu'une transaction
|
||||
// Ou Si la transaction courante représente plus du 5eme de la somme des tx
|
||||
// On s'interdit la couleur de fond
|
||||
if (($n_data == 1)||($transaction['value'] > ($somme/5)))
|
||||
while ($couleurs[$n%$nb_couleurs] == $fond) $n++;
|
||||
$couleur = $couleurs[$n%$nb_couleurs];
|
||||
|
||||
// le segment de couleur est de longueur proportionnelle
|
||||
// à la valeur de sa transaction
|
||||
$next = $cur + ($coef*$transaction['value']);
|
||||
if ($next > $max) $next = $max;
|
||||
|
||||
while($cur<$next)
|
||||
{
|
||||
$r1 = 0.05 * $cur;
|
||||
$x2 = $xc + $r1*cos($r1);
|
||||
$y2 = $yc + $r1*sin($r1);
|
||||
imageline($vImage, $x1, $y1, $x2, $y2, $couleur);
|
||||
$x1 = $x2;
|
||||
$y1 = $y2;
|
||||
$cur++;
|
||||
}
|
||||
$n++;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -28,14 +28,50 @@ function DrawBlock($the_block, $vImage, $parametres)
|
||||
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB'];
|
||||
if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB'];
|
||||
|
||||
// Une chance sur deux d'inverser entre fg et bg
|
||||
// Forcer les couleurs
|
||||
$hasard = rand(0,10);
|
||||
$couleur=3;$val=0;
|
||||
if ($hasard > $val++) $couleur = 5;
|
||||
if ($hasard > $val++) $couleur = 6;
|
||||
if ($hasard > $val++) $couleur = 7;
|
||||
if ($hasard > $val++) $couleur = 8;
|
||||
|
||||
$couleur = 8;
|
||||
switch($couleur) {
|
||||
case 3:
|
||||
case 5:
|
||||
$fondRGB=[0,0,0];
|
||||
$fond=imagecolorallocate($vImage,$fondRGB[0],$fondRGB[1],$fondRGB[2]);
|
||||
$couleurRGB=[240,147,43];
|
||||
$couleur=imagecolorallocate($vImage,$couleurRGB[0],$couleurRGB[1],$couleurRGB[2]);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
$fondRGB=[17,61,86];
|
||||
$couleurRGB=[255,134,63];
|
||||
break;
|
||||
|
||||
case 8:
|
||||
$fondRGB=[234,220,207];
|
||||
$couleurRGB=[252,196,37];
|
||||
break;
|
||||
|
||||
default:
|
||||
$fondRGB=[17,61,86];
|
||||
$couleurRGB=[73,20,26];
|
||||
}
|
||||
|
||||
$img_w = $width;
|
||||
$img_h = $height+(2*$y);
|
||||
|
||||
// Redessiner entête et pied de page
|
||||
$p2 = blockchain::DrawBlockHeaderFooter($the_block, $vImage, $y, $couleur);
|
||||
|
||||
$fond=imagecolorallocate($vImage,$fondRGB[0],$fondRGB[1],$fondRGB[2]);
|
||||
//$couleur=imagecolorallocate($vImage,$couleurRGB[0],$couleurRGB[1],$couleurRGB[2]);
|
||||
|
||||
// Remplir le fond
|
||||
imagefilledrectangle($vImage, $x+($marge_x/2), $y+($marge_y/2), $x+$width-+($marge_x/2), $y+$height-+($marge_y/2), $fond);
|
||||
imagefilledrectangle($vImage, 0, $y, $width, $y + $height, $fond);
|
||||
imageline($vImage, 0, 5, 0, $img_h-25, $p2[2]);
|
||||
imageline($vImage, $width-1, 5, $width-1, $img_h-25, $p2[2]);
|
||||
|
||||
$vColor = array();
|
||||
// Dégradé de 192 couleurs entre la couleur de dessin et le blanc
|
||||
@@ -62,6 +98,13 @@ function DrawBlock($the_block, $vImage, $parametres)
|
||||
for($i=0;$i<$nb_colors;$i++)
|
||||
{
|
||||
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
|
||||
// Pas de blanc <=> c'est la transparence ...
|
||||
if (($rgbval[0] == $rgbval[1])&&($rgbval[1] == $rgbval[2])&&($rgbval[0] == 254))
|
||||
{
|
||||
$rgbval[0] = 255;
|
||||
$rgbval[1] = 255;
|
||||
$rgbval[2] = 255;
|
||||
}
|
||||
$vColor[192+$i] = new ColorGradient();
|
||||
$vColor[192+$i]->pct = ((192+$i)*1.0) / 256;
|
||||
$vColor[192+$i]->color = imagecolorallocate($vImage, $rgbval[0], $rgbval[1], $rgbval[2]);
|
||||
|
||||
216
methode2/tylerhobbs/draw.php
Normal file
216
methode2/tylerhobbs/draw.php
Normal file
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
|
||||
function DrawBlock($the_block, $vImage, $parametres)
|
||||
{
|
||||
// valeurs par défaut
|
||||
$type = 1;
|
||||
|
||||
// Ces variables vont permettre de caler les lignes
|
||||
// dans la zone de dessin en se laissant des marges
|
||||
// en haut et en bas
|
||||
$somme = 0;
|
||||
$min =-1;
|
||||
$max = 0;
|
||||
$marge_x = 10;
|
||||
$marge_y = 10;
|
||||
$facteur_max = 2.5;
|
||||
|
||||
// Détermine si on dessine les tx, les fees ou la récompense
|
||||
if (isset($parametres['type'])) $type = $parametres['type'];
|
||||
|
||||
// Paramètres de dessin
|
||||
if (isset($parametres['x'])) $x = $parametres['x'];
|
||||
if (isset($parametres['y'])) $y = $parametres['y'];
|
||||
if (isset($parametres['width'])) $width = $parametres['width'];
|
||||
if (isset($parametres['height'])) $height = $parametres['height'];
|
||||
if (isset($parametres['font_color'])) $vFgColor = $parametres['font_color'];
|
||||
if (isset($parametres['background_color'])) $vBgColor = $parametres['background_color'];
|
||||
if (isset($parametres['font_RGB'])) $vFgRGB = $parametres['font_RGB'];
|
||||
if (isset($parametres['background_RGB'])) $vBgRGB = $parametres['background_RGB'];
|
||||
|
||||
$fondRGB=[234,220,207];
|
||||
$couleursRGB=[
|
||||
[197,46,39],
|
||||
[183,230,214],
|
||||
[248,200,40],
|
||||
[51,41,32],
|
||||
[250,142,41],
|
||||
[5,37,32],
|
||||
[233,201,58],
|
||||
[183,230,214]
|
||||
];
|
||||
|
||||
shuffle($couleursRGB);
|
||||
|
||||
$pas = $height / (count($couleursRGB)-1);
|
||||
|
||||
$img_w = $width;
|
||||
$img_h = $height+(2*$y);
|
||||
|
||||
// Redessiner entête et pied de page
|
||||
$p2 = blockchain::DrawBlockHeaderFooter($the_block, $vImage, $y, 8);
|
||||
$fond=imagecolorallocate($vImage,$fondRGB[0],$fondRGB[1],$fondRGB[2]);
|
||||
|
||||
// Remplir le fond
|
||||
imagefilledrectangle($vImage, 0, $y, $width, $y + $height, $fond);
|
||||
// Tracer des bords à droite et à gauche
|
||||
imageline($vImage, 0, 5, 0, $img_h-25, $p2[2]);
|
||||
imageline($vImage, $width-1, 5, $width-1, $img_h-25, $p2[2]);
|
||||
|
||||
// Récup des données
|
||||
$data = blockchain::getTransactionData($the_block, $type);
|
||||
$n_data = count($data);
|
||||
|
||||
// Un calculateur de Spline
|
||||
$oCurve = new CubicSplines();
|
||||
|
||||
// Calcul des min max
|
||||
foreach($data as $v)
|
||||
{
|
||||
if ($v['value'] > $max) $max = $v['value'];
|
||||
if (($v['value'] < $min)||($min == -1)) $min = $v['value'];
|
||||
$somme += $v['value'];
|
||||
}
|
||||
if ($min == $max) $max = $min + 1;
|
||||
if ($somme == 0) return;
|
||||
|
||||
// On se prend une plus grosse marge en hauteur
|
||||
$coef = ($height - (4*$marge_y)) / $somme;
|
||||
$limite_x = $x + ($width - (2*$marge_x));
|
||||
$dx = round(($width - (2*$marge_x)) / (TX_HASH_LEN+10));
|
||||
|
||||
$h0 = 0;
|
||||
$hauteur = $y + (2*$marge_y);
|
||||
$special_draw = (count($data) == 1);
|
||||
$etage = -1;
|
||||
|
||||
// [ TODO ] L'épaisseur du trait dépend du nombre de transactions
|
||||
$epaisseur = 5;
|
||||
|
||||
foreach($data as $transaction)
|
||||
{
|
||||
//
|
||||
// La nouvelle hauteur : cumule des montants de transaction
|
||||
//
|
||||
$hauteur += $coef * $transaction['value'];
|
||||
|
||||
//
|
||||
// Gestion de la couleur
|
||||
//
|
||||
if ($etage != floor($hauteur/$pas))
|
||||
{
|
||||
$etage = floor($hauteur/$pas);
|
||||
|
||||
$vColor = array();
|
||||
// Dégradé de 192 couleurs entre la couleur de dessin et le blanc
|
||||
$nb_colors = 192;
|
||||
$hex_val = array(
|
||||
ColorGradient::rgb2hex($couleursRGB[$etage]),
|
||||
ColorGradient::rgb2hex([255,255,255])
|
||||
);
|
||||
$gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors);
|
||||
for($i=0;$i<$nb_colors;$i++)
|
||||
{
|
||||
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
|
||||
// Pas de blanc <=> c'est la transparence ...
|
||||
if (($rgbval[0] == $rgbval[1])&&($rgbval[1] == $rgbval[2])&&($rgbval[0] > 252))
|
||||
{
|
||||
$rgbval[0] = 255;
|
||||
$rgbval[1] = 255;
|
||||
$rgbval[2] = 255;
|
||||
}
|
||||
$vColor[$i] = new ColorGradient();
|
||||
$vColor[$i]->pct = ($i*1.0) / 256;
|
||||
$vColor[$i]->color = imagecolorallocate($vImage, $rgbval[0], $rgbval[1], $rgbval[2]);
|
||||
}
|
||||
// On ajoute un dégradé de 64 couleurs entre le blanc et la couleur de fond
|
||||
$nb_colors = 64;
|
||||
$hex_val = array(
|
||||
ColorGradient::rgb2hex([255,255,255]),
|
||||
ColorGradient::rgb2hex($fondRGB)
|
||||
);
|
||||
$gradient = ColorGradient::gradient($hex_val[0], $hex_val[1], $nb_colors);
|
||||
for($i=0;$i<$nb_colors;$i++)
|
||||
{
|
||||
$rgbval = ColorGradient::hex2rgb($gradient[$i]);
|
||||
// Pas de blanc <=> c'est la transparence ...
|
||||
if (($rgbval[0] == $rgbval[1])&&($rgbval[1] == $rgbval[2])&&($rgbval[0] > 252))
|
||||
{
|
||||
$rgbval[0] = 255;
|
||||
$rgbval[1] = 255;
|
||||
$rgbval[2] = 255;
|
||||
}
|
||||
$vColor[192+$i] = new ColorGradient();
|
||||
$vColor[192+$i]->pct = ((192+$i)*1.0) / 256;
|
||||
$vColor[192+$i]->color = imagecolorallocate($vImage, $rgbval[0], $rgbval[1], $rgbval[2]);
|
||||
}
|
||||
$nb_colors = 256;
|
||||
}
|
||||
|
||||
//
|
||||
// Cas des blocks qui n'ont qu'une seule transaction
|
||||
// On se cale au milieu
|
||||
//
|
||||
if ($special_draw) $hauteur = $y + ($height / 2);
|
||||
|
||||
//
|
||||
// Ne pas tracer 2 lignes à la même hauteur
|
||||
// => c'est possible du fait de l'arrondi
|
||||
// si la transaction a un montant faible
|
||||
//
|
||||
if ((floor($hauteur)-$h0)<2) continue;
|
||||
$h0 = floor($hauteur);
|
||||
|
||||
$x0 = $x + $marge_x;
|
||||
|
||||
//
|
||||
// On découpe la ligne en fonction du nombre de DIGIT
|
||||
// dans le hash des transactions
|
||||
//
|
||||
$facteur = 0.1;
|
||||
$aCoords = array();
|
||||
$aCoords[$x0] = $h0; $x0 += $dx;
|
||||
$aCoords[$x0] = $h0; $x0 += $dx;
|
||||
$aCoords[$x0] = $h0; $x0 += $dx;
|
||||
$aCoords[$x0] = $h0; $x0 += $dx;
|
||||
$aCoords[$x0] = $h0; $x0 += $dx;
|
||||
$aCoords[$x0] = $h0; $x0 += $dx;
|
||||
$aCoords[$x0] = $h0; $x0 += $dx;
|
||||
$aCoords[$x0] = $h0; $x0 += $dx;
|
||||
$aCoords[$x0] = $h0; $x0 += $dx;
|
||||
$aCoords[$x0] = $h0; $x0 += $dx;
|
||||
for ($i = 0; $i < TX_HASH_LEN; $i++)
|
||||
{
|
||||
$y0 = $h0;
|
||||
$valeur = hexdec($transaction['hash'][$i]);
|
||||
if ($valeur != 0) $y0 += floor(($valeur - 8) * $facteur);
|
||||
$x0 += $dx;
|
||||
$aCoords[$x0] = $y0;
|
||||
|
||||
if ($y0 == $h0) continue;
|
||||
|
||||
$facteur = 0.1 + (($facteur_max*$i) / TX_HASH_LEN);
|
||||
if ($facteur > $facteur_max) $facteur = $facteur_max;
|
||||
}
|
||||
|
||||
for($i=0;$i<$epaisseur;$i++)
|
||||
{
|
||||
foreach($aCoords as &$aCoord)
|
||||
{
|
||||
$aCoord += 1;
|
||||
if ($aCoord < $y+$marge_y) $aCoord = $y+$marge_y;
|
||||
if ($aCoord > ($y+$height-$marge_y)) $aCoord = $y+$height-$marge_y;
|
||||
}
|
||||
|
||||
$oCurve->setInitCoords($aCoords);
|
||||
$r = $oCurve->processCoords();
|
||||
if ($r)
|
||||
{
|
||||
$curveGraph = new Plot($r);
|
||||
$curveGraph->drawLine($vImage, $vColor, $x0, $limite_x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -72,7 +72,8 @@ if (file_exists($image_file))
|
||||
// --- Tweet
|
||||
// ---
|
||||
$tweet = "Lucky One on #bitcoin #blockchain 's".PHP_EOL;
|
||||
$tweet .= "Someone put an empty block and get the reward for it !".PHP_EOL;
|
||||
$tweet .= "Someone put an empty block ...".PHP_EOL;
|
||||
$tweet .= "And get the reward for it !".PHP_EOL;
|
||||
$tweet .= "Block height : ".$the_block->height.PHP_EOL;
|
||||
$tweet .= "[ See more on www.topisto.net ]";
|
||||
$success = twitter::tweet($tweet, $image_file);
|
||||
|
||||
1
twitter/twitterbot/followers.json
Normal file
1
twitter/twitterbot/followers.json
Normal file
@@ -0,0 +1 @@
|
||||
["CryptoPressNews","ryushi_w","JoelPlatoon"]
|
||||
@@ -69,7 +69,7 @@ if (file_exists($image_file))
|
||||
// ---
|
||||
// --- Tweet
|
||||
// ---
|
||||
$tweet = "#computerart : #bitcoin #blockchain 's".PHP_EOL;
|
||||
$tweet = "#computerart :".PHP_EOL."#bitcoin #blockchain 's".PHP_EOL;
|
||||
$tweet .= $argv[2]." Block, Height : ".$the_block->height.PHP_EOL;
|
||||
$tweet .= "[ See more on www.topisto.net ]";
|
||||
$success = twitter::tweet($tweet, $image_file);
|
||||
|
||||
Reference in New Issue
Block a user