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

@@ -1,72 +0,0 @@
<?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;
$final_hash = 'default';
$nb_max = 6;
$numprev = 0;
$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);
$handle = fopen(DATA_PATH.'/hashes2hashes/liste.txt', 'r');
if ($handle) {
while (($nb_max > 0)&&(($hash = fgets($handle, 4096)) !== false)) {
$hash = preg_replace('~[[:cntrl:]]~', '', $hash);
$split = explode(' ', $hash);
$numero = intval($split[0]);
$hash = $split[1];
if ($final_hash == 'default') $final_hash = $hash;
if (($numprev != 0) && ($numprev != ($numero - 1))) {
imagefilledrectangle($img, 0, $height*$nb_max, $width, $height*($nb_max-1), $gris);
imagerectangle($img, 0, $height*$nb_max, $width, $height*($nb_max-1), $noir);
echo $nb_max.' '.($numprev+1).' manquant !'.PHP_EOL;
$nb_max -= 1;
}
$numprev = $numero;
$nb_max -= 1;
echo $nb_max.' '.$numero.' '.$hash.PHP_EOL;
$hash = DATA_PATH.'/hashes/'.$hash.'.png';
if (file_exists($hash))
{
$src_img = imagecreatefrompng($hash);
if ($src_img)
{
if (FALSE === imagecopy($img, $src_img, 0, $height*$nb_max, 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;
}
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);
?>

View File

@@ -51,7 +51,12 @@ $img_h = $height+(2*$bandeau);
// création d'une image plus haute pour inclure bandeaux haut et bas
$img = imagecreatetruecolor($img_w, $img_h);
blockchain::DrawBlockHeaderFooter($the_block, $img, $bandeau);
$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');

View File

@@ -1,40 +1,32 @@
#!/bin/bash
flag=$TMP_PATH/hashes_bot.flag
METHODE=hashes
flag=$TMP_PATH/${METHODE}_bot.flag
date=`date +%Y%m%d0000`
if [ -f $flag ];
then
echo "hashes_bot is already running !"
echo "${METHODE}_bot is already running !"
exit 0
fi
touch $flag
cd $APPS_PATH/methode/hashes
cd $APPS_PATH/methode/$METHODE
for BLOCK in `grep LAST $DATA_PATH/block_list.txt | awk '{print $2}'`
do
if [ ! -f $DATA_PATH/hashes/$BLOCK.png ]
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
then
BLOCK_HEIGHT=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $3}'`
php robot.php $BLOCK $((RANDOM % 6))
echo $BLOCK_HEIGHT $BLOCK >> $DATA_PATH/hashes2hashes/liste.txt
mv $DATA_PATH/hashes2hashes/liste.txt $DATA_PATH/hashes2hashes/liste.new
sort -k1 -n $DATA_PATH/hashes2hashes/liste.new > $DATA_PATH/hashes2hashes/liste.txt
rm -f $DATA_PATH/hashes2hashes/liste.new
COMPTEUR=`wc -l $DATA_PATH/hashes2hashes/liste.txt | awk '{print $1}' `
if [ $COMPTEUR -eq 6 ]
then
php assemble.php
rm -f $DATA_PATH/hashes2hashes/liste.old
mv $DATA_PATH/hashes2hashes/liste.txt $DATA_PATH/hashes2hashes/liste.old
fi
fi
BNAME=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $1}'`
if [ "$BNAME" == "LAST" ]
then
touch $DATA_PATH/hashes/$BLOCK.png
touch $DATA_PATH/$METHODE/$BLOCK.png
else
touch -t $date $DATA_PATH/hashes/$BLOCK.png
touch -t $date $DATA_PATH/$METHODE/$BLOCK.png
fi
done