Ajout d'une bande grise si hash absent dans assemble.php
This commit is contained in:
@@ -16,37 +16,52 @@ require TOPISTO_PATH.'/ressources/vendor/autoload.php';
|
|||||||
|
|
||||||
$width = 840;
|
$width = 840;
|
||||||
$height = 104;
|
$height = 104;
|
||||||
$h = $height*6;
|
|
||||||
$final_hash = 'default';
|
$final_hash = 'default';
|
||||||
|
$nb_max = 6;
|
||||||
|
$numprev = 0;
|
||||||
|
|
||||||
$img = imagecreatetruecolor($width, $h);
|
$img = imagecreatetruecolor($width, $height*$nb_max);
|
||||||
|
|
||||||
|
$gris = imagecolorallocate($img, 180, 180, 180);
|
||||||
|
$noir = imagecolorallocate($img, 0, 0, 0);
|
||||||
|
|
||||||
$tr = imagecolorallocate($img, 220, 220, 220);
|
$tr = imagecolorallocate($img, 220, 220, 220);
|
||||||
imagecolortransparent($img, $tr);
|
imagecolortransparent($img, $tr);
|
||||||
imagefilledrectangle($img, 0, 0, $width, $height*6, $tr);
|
imagefilledrectangle($img, 0, 0, $width, $height*$nb_max, $tr);
|
||||||
|
|
||||||
$handle = fopen(DATA_PATH.'/hashes2hashes/liste.txt', 'r');
|
$handle = fopen(DATA_PATH.'/hashes2hashes/liste.txt', 'r');
|
||||||
if ($handle) {
|
if ($handle) {
|
||||||
while (($hash = fgets($handle, 4096)) !== false) {
|
while (($nb_max > 0)&&(($hash = fgets($handle, 4096)) !== false)) {
|
||||||
|
|
||||||
$hash = preg_replace('~[[:cntrl:]]~', '', $hash);
|
$hash = preg_replace('~[[:cntrl:]]~', '', $hash);
|
||||||
$split = explode(' ', $hash);
|
$split = explode(' ', $hash);
|
||||||
|
$numero = intval($split[0]);
|
||||||
$hash = $split[1];
|
$hash = $split[1];
|
||||||
|
|
||||||
if ($final_hash == 'default') $final_hash = $hash;
|
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';
|
$hash = DATA_PATH.'/hashes/'.$hash.'.png';
|
||||||
if (file_exists($hash))
|
if (file_exists($hash))
|
||||||
{
|
{
|
||||||
$h -= $height;
|
|
||||||
$src_img = imagecreatefrompng($hash);
|
$src_img = imagecreatefrompng($hash);
|
||||||
if ($src_img)
|
if ($src_img)
|
||||||
{
|
{
|
||||||
if (FALSE === imagecopy($img, $src_img, 0, $h, 0, 0, $width, $height))
|
if (FALSE === imagecopy($img, $src_img, 0, $height*$nb_max, 0, 0, $width, $height))
|
||||||
echo "Erreur : problème de copie image".PHP_EOL;
|
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." ne semble pas être une image PNG".PHP_EOL;
|
||||||
} else echo "Erreur: ".$hash." n'a pas été trouvé".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);
|
fclose($handle);
|
||||||
} else echo "Erreur: fopen('".DATA_PATH."/hashes2hashes/liste.txt') a échoué".PHP_EOL;
|
} else echo "Erreur: fopen('".DATA_PATH."/hashes2hashes/liste.txt') a échoué".PHP_EOL;
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ do
|
|||||||
sort -k1 -n $DATA_PATH/hashes2hashes/liste.new > $DATA_PATH/hashes2hashes/liste.txt
|
sort -k1 -n $DATA_PATH/hashes2hashes/liste.new > $DATA_PATH/hashes2hashes/liste.txt
|
||||||
rm -f $DATA_PATH/hashes2hashes/liste.new
|
rm -f $DATA_PATH/hashes2hashes/liste.new
|
||||||
COMPTEUR=`wc -l $DATA_PATH/hashes2hashes/liste.txt | awk '{print $1}' `
|
COMPTEUR=`wc -l $DATA_PATH/hashes2hashes/liste.txt | awk '{print $1}' `
|
||||||
|
echo $COMPTEUR
|
||||||
if [ $COMPTEUR -eq 6 ]
|
if [ $COMPTEUR -eq 6 ]
|
||||||
then
|
then
|
||||||
php assemble.php
|
php assemble.php
|
||||||
|
|||||||
Reference in New Issue
Block a user