| @ -1,4 +1,10 @@ | |||||
| [ | [ | ||||
| { | |||||
| "hash": "00000000000000000000a63021c17572b66507c6b6623ccf4e780272d19b2528", | |||||
| "height": 824513, | |||||
| "name": "BURN2024", | |||||
| "desc": "Le 03 janvier 2024, Binance a envoyé 26,9 BTC (valorisés 1,2 millions de dollars) sur un Genesis Wallet" | |||||
| }, | |||||
| { | { | ||||
| "hash": "00000000000000000001e6d99b42a2fe649591e7b97b1d4327e2bc3ade53d6d7", | "hash": "00000000000000000001e6d99b42a2fe649591e7b97b1d4327e2bc3ade53d6d7", | ||||
| "height": 772923, | "height": 772923, | ||||
| @ -0,0 +1,7 @@ | |||||
| [ | |||||
| { | |||||
| "hash":"a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d", | |||||
| "name":"Pizza Transaction", | |||||
| "desc":"This transaction was made by Laszlo Hanyecz in 2010 where he paid Jeremy Sturdivant 10,000 bitcoin for two pizzas bought at Papa John's" | |||||
| } | |||||
| ] | |||||
| @ -335,13 +335,15 @@ class blockchain | |||||
| { | { | ||||
| $path = APP_PATH.'/blockchain/data/blocks.json'; | $path = APP_PATH.'/blockchain/data/blocks.json'; | ||||
| $jsonString = file_get_contents($path); | $jsonString = file_get_contents($path); | ||||
| self::$special_blocks = json_decode($jsonString, true); | |||||
| if ($jsonString === FALSE) die('blocks spéciaux non trouvés'); | |||||
| $blocks = json_decode($jsonString, true); | |||||
| foreach($blocks as $block) | |||||
| self::$special_blocks[] = new block($block["hash"],$block["height"],$block["name"],$block["desc"]); | |||||
| } | } | ||||
| public static function init(){ | public static function init(){ | ||||
| self::init_v2(); | self::init_v2(); | ||||
| } | } | ||||
| // --- | // --- | ||||
| // --- Retourne le JSON du tableau des blocs speciaux | // --- Retourne le JSON du tableau des blocs speciaux | ||||
| // --- | // --- | ||||
| @ -387,18 +389,31 @@ class blockchain | |||||
| return self::getBlockWithHash($block_hash); | return self::getBlockWithHash($block_hash); | ||||
| } | } | ||||
| // ---- | |||||
| // ---- | |||||
| public static function getSpecialBlockList() | |||||
| { | |||||
| foreach(self::$special_blocks as $block) | |||||
| { | |||||
| $the_block=self::getBlockWithHash($block->hash); | |||||
| echo $block->name.' '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL; | |||||
| } | |||||
| } | |||||
| // --- | // --- | ||||
| // --- Accès au dernier block en cache ... | // --- Accès au dernier block en cache ... | ||||
| // --- | // --- | ||||
| public static function getLastCacheBlockHash() | public static function getLastCacheBlockHash() | ||||
| { | { | ||||
| // on commence par le cache d'images | // on commence par le cache d'images | ||||
| /* | |||||
| $myarray = glob(DATA_PATH.'/hasard/*.png'); | $myarray = glob(DATA_PATH.'/hasard/*.png'); | ||||
| if (isset($myarray[0])) | if (isset($myarray[0])) | ||||
| { | { | ||||
| usort( $myarray, function( $a, $b ) { return filemtime($b) - filemtime($a); } ); | usort( $myarray, function( $a, $b ) { return filemtime($b) - filemtime($a); } ); | ||||
| return substr(basename($myarray[0],'.png'),0,strlen(self::$special_blocks[0]->hash)); | return substr(basename($myarray[0],'.png'),0,strlen(self::$special_blocks[0]->hash)); | ||||
| } | } | ||||
| */ | |||||
| // S'il n'y a rien dans le cache d'images | // S'il n'y a rien dans le cache d'images | ||||
| $filename=DATA_PATH.'/finished_block_list.txt'; | $filename=DATA_PATH.'/finished_block_list.txt'; | ||||
| @ -14,34 +14,25 @@ require_once '../global/inc/config.php'; | |||||
| // --- | // --- | ||||
| require_once 'inc/block.php'; | require_once 'inc/block.php'; | ||||
| // --- | |||||
| // --- Par défaut on cherche le dernier block | |||||
| // --- | |||||
| $block_hash = 'LAST'; | |||||
| // --- | |||||
| // --- Le cas échéant, on cherche block passé en argument | |||||
| // --- | |||||
| if (isset($argv[1])) $block_hash = $argv[1]; | |||||
| // --- | // --- | ||||
| // --- On interroge la blockchain | // --- On interroge la blockchain | ||||
| // --- => Ce qui a pour effet de placer le block dans le cache | // --- => Ce qui a pour effet de placer le block dans le cache | ||||
| // --- | // --- | ||||
| $the_block = blockchain::getSpecialBlock($block_hash); | |||||
| blockchain::getSpecialBlocklist(); | |||||
| $the_block = blockchain::getBlockWithHash(blockchain::getLastBlockHash()); | |||||
| if ($the_block === FALSE) die(); | if ($the_block === FALSE) die(); | ||||
| echo $block_hash.' '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL; | |||||
| echo 'LAST '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL; | |||||
| exit(0); | |||||
| if ($block_hash == 'LAST') | |||||
| // On a demandé le dernier block | |||||
| // On remonte sur les huits derniers pour accélerer les prochaines navigations | |||||
| for($max=0;($max<8)&&(!file_exists(DATA_PATH.'/json/'.$the_block->prev_block.'.zip'));$max++) | |||||
| { | { | ||||
| // On a demandé le dernier block | |||||
| // On remonte sur les huits derniers pour accélerer les prochaines navigations | |||||
| for($max=0;($max<8)&&(!file_exists(DATA_PATH.'/json/'.$the_block->prev_block.'.zip'));$max++) | |||||
| { | |||||
| $block_hash = $the_block->prev_block; | |||||
| $the_block = blockchain::getBlockWithHash($block_hash); | |||||
| if ($the_block === FALSE) die(); | |||||
| echo 'CACHE '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL; | |||||
| } | |||||
| $block_hash = $the_block->prev_block; | |||||
| $the_block = blockchain::getBlockWithHash($block_hash); | |||||
| if ($the_block === FALSE) die(); | |||||
| echo 'CACHE '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL; | |||||
| } | } | ||||
| ?> | ?> | ||||
| @ -13,26 +13,7 @@ cd $APPS_PATH/blockchain | |||||
| rm -f $DATA_PATH/block_list.tmp | 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 \ | |||||
| WHALE201909 WHALE20201026 \ | |||||
| BLOCK21E800 GOLGOTH201909 EQUILIBRE \ | |||||
| DEMISSION20200110 2020JUMP9000 \ | |||||
| SOPHIA202002 EQUILIBRE202002 COVID19 \ | |||||
| RIP_STEEVE HALVING_3 DORMEUR \ | |||||
| FIRST_USD_TX 2020JUMP10000 \ | |||||
| NO_REWARD MORNING_STAR SALVADOR \ | |||||
| BAB_BRUXELLES POITIERS UKRAINE \ | |||||
| ELISABETH_2_HAS_DIED BERNIQUE \ | |||||
| LAST" | |||||
| for BLOCK in $LISTBLOCKS | |||||
| do | |||||
| php robot.php $BLOCK >> $DATA_PATH/block_list.tmp | |||||
| done | |||||
| php robot.php > $DATA_PATH/block_list.tmp | |||||
| # Sort the block list by Height | # Sort the block list by Height | ||||
| sort -k3 -n $DATA_PATH/block_list.tmp > $DATA_PATH/block_list.txt | sort -k3 -n $DATA_PATH/block_list.tmp > $DATA_PATH/block_list.txt | ||||
| @ -0,0 +1,30 @@ | |||||
| <?php | |||||
| // --- | |||||
| // --- La config globale | |||||
| // --- | |||||
| require_once '../global/inc/config.php'; | |||||
| // --- | |||||
| // --- External dependances | |||||
| // --- | |||||
| require TOPISTO_PATH.'/ressources/vendor/autoload.php'; | |||||
| // --- | |||||
| // --- Internal dependances | |||||
| // --- | |||||
| require_once APP_PATH.'/blockchain/inc/block.php'; | |||||
| // --- | |||||
| // --- Par défaut on cherche le dernier block | |||||
| // --- Le cas échéant, on cherche block passé en argument | |||||
| // --- | |||||
| $block_hash = 'LAST'; | |||||
| if (isset($argv[1])) $block_hash = $argv[1]; | |||||
| $the_block = blockchain::getBlockWithHash($block_hash); | |||||
| if ($the_block === FALSE) die(); | |||||
| echo $the_block->height.' '.$the_block->time.' '.$the_block->n_tx.' '.$the_block->nonce.' '.$the_block->prev_block.PHP_EOL; | |||||
| ?> | |||||
| @ -13,5 +13,7 @@ DATE=`date +%Y%m%d0000` | |||||
| if [ -f scripts/$1.sh ]; | if [ -f scripts/$1.sh ]; | ||||
| then | then | ||||
| source scripts/$1.sh | |||||
| script=$1 | |||||
| shift | |||||
| source scripts/$script.sh $* | |||||
| fi | fi | ||||
| @ -37,3 +37,9 @@ $APPS_PATH/scripts/tweet.sh | |||||
| # Clean OLD DATA | # Clean OLD DATA | ||||
| # | # | ||||
| $APPS_PATH/scripts/clean_data.sh | $APPS_PATH/scripts/clean_data.sh | ||||
| # | |||||
| # the 100 lastest BLOCKS must have at least the nonce method | |||||
| # | |||||
| $APPS_PATH/scripts/100blocks.sh | |||||
| @ -0,0 +1,133 @@ | |||||
| #!/bin/bash | |||||
| lescript=`basename $0 .sh` | |||||
| # | |||||
| # TOOLS | |||||
| # | |||||
| function debug | |||||
| { | |||||
| if [ -f $FLAG_PATH/debug ] | |||||
| then | |||||
| echo $1 | |||||
| fi | |||||
| } | |||||
| function sortie | |||||
| { | |||||
| exit $1 | |||||
| } | |||||
| function succes | |||||
| { | |||||
| debug "SUCCES" | |||||
| sortie 0 | |||||
| } | |||||
| function echec | |||||
| { | |||||
| debug "ECHEC" | |||||
| exit 1 | |||||
| } | |||||
| # | |||||
| # PARAMETRES PAR FICHIER FLAGS | |||||
| # | |||||
| if [ -f $FLAG_PATH/no_blocks ] | |||||
| then | |||||
| debug "No blocks" | |||||
| echec | |||||
| fi | |||||
| BLOCK=`grep LAST $DATA_PATH/block_list.txt | awk '{print $2}'` | |||||
| TODAY=$(date -d '00:00:00' +%s) | |||||
| N=0 | |||||
| while [ $N -ne 100 ] | |||||
| do | |||||
| echo $BLOCK | |||||
| cd $APPS_PATH/info | |||||
| infos=`php robot.php $BLOCK` | |||||
| HEIGHT=`echo $infos | awk '{print $1}'` | |||||
| TIMETS=`echo $infos | awk '{print $2}'` | |||||
| NBTX=`echo $infos | awk '{print $3}'` | |||||
| NONCE=`echo $infos | awk '{print $4}'` | |||||
| PREV=`echo $infos | awk '{print $5}'` | |||||
| if [ -z "$TIMETS" ] | |||||
| then | |||||
| break | |||||
| fi | |||||
| if [ $TIMETS -lt $TODAY ] | |||||
| then | |||||
| break | |||||
| fi | |||||
| # | |||||
| # TEST DU FLAG | |||||
| # | |||||
| flag=$FLAG_PATH/bot_${lescript}_${BLOCK}.flag | |||||
| if [ -f $flag ] | |||||
| then | |||||
| debug "${lescript}_${BLOCK} already done" | |||||
| continue | |||||
| fi | |||||
| touch $flag | |||||
| if [ ! -f $DATA_PATH/nonce/$BLOCK.png ] | |||||
| then | |||||
| # | |||||
| # Si c'est la première fois que l'on dessine le block | |||||
| # On choisit la méthode qui découle du nonce | |||||
| # | |||||
| cd $APPS_PATH/nonce | |||||
| nbmethodes=`cat $DATA_PATH/nonce_methods_list.txt | wc -l` | |||||
| lenonce=`php robot.php $BLOCK` | |||||
| lamethode=$((lenonce % nbmethodes)) | |||||
| if [ $lamethode -eq 0 ] | |||||
| then | |||||
| lamethode=$nbmethodes | |||||
| fi | |||||
| LISTE_METHODE=`cat $DATA_PATH/nonce_methods_list.txt | head -n $lamethode | tail -1` | |||||
| cd $APPS_PATH/methode2 | |||||
| for METHODE in $LISTE_METHODE | |||||
| do | |||||
| if [ ! -d $DATA_PATH/$METHODE ] | |||||
| then | |||||
| mkdir -p $DATA_PATH/$METHODE | |||||
| fi | |||||
| echo $BLOCK $NAME $METHODE | |||||
| if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ] | |||||
| then | |||||
| php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2 | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png | |||||
| fi | |||||
| done | |||||
| cd - >> /dev/null | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png | |||||
| fi | |||||
| rm -f $flag | |||||
| BLOCK=$PREV | |||||
| N=$(($N+1)) | |||||
| done | |||||
| # | |||||
| # List of finished blocks | |||||
| # | |||||
| rm -f $DATA_PATH/finished_block_list.txt | |||||
| grep -v CACHE $DATA_PATH/block_list.txt >> $DATA_PATH/finished_block_list.txt | |||||
| # | |||||
| # SORTIE AVEC SUCCES | |||||
| # | |||||
| succes | |||||
| @ -0,0 +1,86 @@ | |||||
| #!/bin/bash | |||||
| lescript=`basename $0 .sh` | |||||
| # | |||||
| # TOOLS | |||||
| # | |||||
| function debug | |||||
| { | |||||
| if [ -f $FLAG_PATH/debug ] | |||||
| then | |||||
| echo $1 | |||||
| fi | |||||
| } | |||||
| function sortie | |||||
| { | |||||
| exit $1 | |||||
| } | |||||
| function succes | |||||
| { | |||||
| debug "SUCCES" | |||||
| sortie 0 | |||||
| } | |||||
| function echec | |||||
| { | |||||
| debug "ECHEC" | |||||
| exit 1 | |||||
| } | |||||
| # | |||||
| # PARAMETRES PAR FICHIER FLAGS | |||||
| # | |||||
| if [ -f $FLAG_PATH/no_blocks ] | |||||
| then | |||||
| debug "No blocks" | |||||
| echec | |||||
| fi | |||||
| BLOCK=`grep LAST $DATA_PATH/block_list.txt | awk '{print $2}'` | |||||
| echo $BLOCK | |||||
| cd $APPS_PATH/info | |||||
| infos=`php robot.php $BLOCK` | |||||
| HEIGHT=`echo $infos | awk '{print $1}'` | |||||
| TIMETS=`echo $infos | awk '{print $2}'` | |||||
| NBTX=`echo $infos | awk '{print $3}'` | |||||
| NONCE=`echo $infos | awk '{print $4}'` | |||||
| PREV=`echo $infos | awk '{print $5}'` | |||||
| # | |||||
| # TEST DU FLAG | |||||
| # | |||||
| flag=$FLAG_PATH/bot_${lescript}_${BLOCK}.flag | |||||
| if [ -f $flag ] | |||||
| then | |||||
| debug "${lescript}_${BLOCK} already done" | |||||
| fi | |||||
| touch $flag | |||||
| LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf` | |||||
| cd $APPS_PATH/methode2 | |||||
| for METHODE in $LISTE_METHODE | |||||
| do | |||||
| if [ ! -d $DATA_PATH/$METHODE ] | |||||
| then | |||||
| mkdir -p $DATA_PATH/$METHODE | |||||
| fi | |||||
| echo $BLOCK $NAME $METHODE | |||||
| if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ] | |||||
| then | |||||
| php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2 | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png | |||||
| fi | |||||
| done | |||||
| cd - >> /dev/null | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png | |||||
| # | |||||
| # SORTIE AVEC SUCCES | |||||
| # | |||||
| succes | |||||
| @ -1,6 +1,5 @@ | |||||
| #!/bin/bash | #!/bin/bash | ||||
| lescript=`basename $0 .sh` | lescript=`basename $0 .sh` | ||||
| flag=$TMP_PATH/bot_$lescript.flag | |||||
| # | # | ||||
| # TOOLS | # TOOLS | ||||
| @ -0,0 +1,105 @@ | |||||
| #!/bin/bash | |||||
| lescript=blocks2 | |||||
| # | |||||
| # TOOLS | |||||
| # | |||||
| function debug | |||||
| { | |||||
| if [ -f $FLAG_PATH/debug ] | |||||
| then | |||||
| echo $1 | |||||
| fi | |||||
| } | |||||
| function sortie | |||||
| { | |||||
| exit $1 | |||||
| } | |||||
| function succes | |||||
| { | |||||
| debug "SUCCES" | |||||
| sortie 0 | |||||
| } | |||||
| function echec | |||||
| { | |||||
| debug "ECHEC" | |||||
| exit 1 | |||||
| } | |||||
| # | |||||
| # PARAMETRES PAR FICHIER FLAGS | |||||
| # | |||||
| if [ -f $FLAG_PATH/no_blocks ] | |||||
| then | |||||
| debug "No blocks" | |||||
| echec | |||||
| fi | |||||
| while IFS='' read -r line || [[ -n "$line" ]]; do | |||||
| NAME=`echo $line | awk '{print $1}'` | |||||
| BLOCK=`echo $line | awk '{print $2}'` | |||||
| HEIGHT=`echo $line | awk '{print $3}'` | |||||
| NBTX=`echo $line | awk '{print $4}'` | |||||
| # | |||||
| # TEST DU FLAG | |||||
| # | |||||
| flag=$FLAG_PATH/bot_${lescript}_${BLOCK}.flag | |||||
| if [ -f $flag ] | |||||
| then | |||||
| debug "${lescript}_${BLOCK} already done" | |||||
| continue | |||||
| fi | |||||
| touch $flag | |||||
| # | |||||
| # CHOISIR UNE METHODE2 AU HASARD | |||||
| # | |||||
| # LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf` | |||||
| # LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf | head -n 1` | |||||
| # en rajoutant le head, on ne fait qu'un seul dessin | |||||
| LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf | head -n 1` | |||||
| if [ $HEIGHT -eq 1 ] | |||||
| then | |||||
| LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v treemap | grep -v robot | shuf | head -n 1` | |||||
| fi | |||||
| cd $APPS_PATH/methode2 | |||||
| for METHODE in $LISTE_METHODE | |||||
| do | |||||
| if [ ! -d $DATA_PATH/$METHODE ] | |||||
| then | |||||
| mkdir -p $DATA_PATH/$METHODE | |||||
| fi | |||||
| echo $BLOCK $NAME $METHODE | |||||
| if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ] | |||||
| then | |||||
| php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2 | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png | |||||
| fi | |||||
| done | |||||
| cd - >> /dev/null | |||||
| if [ ! -f $DATA_PATH/hasard/$BLOCK.png ] | |||||
| then | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png | |||||
| fi | |||||
| rm -f $flag | |||||
| done < $DATA_PATH/block_list.txt | |||||
| # | |||||
| # List of finished blocks | |||||
| # | |||||
| rm -f $DATA_PATH/finished_block_list.txt | |||||
| grep -v CACHE $DATA_PATH/block_list.txt >> $DATA_PATH/finished_block_list.txt | |||||
| # | |||||
| # SORTIE AVEC SUCCES | |||||
| # | |||||
| succes | |||||
| @ -1,6 +1,5 @@ | |||||
| #!/bin/bash | #!/bin/bash | ||||
| lescript=`basename $0 .sh` | lescript=`basename $0 .sh` | ||||
| flag=$TMP_PATH/bot_$lescript.flag | |||||
| # | # | ||||
| # TOOLS | # TOOLS | ||||
| @ -59,62 +58,13 @@ while IFS='' read -r line || [[ -n "$line" ]]; do | |||||
| if [ ! -f $DATA_PATH/nonce/$BLOCK.png ] | if [ ! -f $DATA_PATH/nonce/$BLOCK.png ] | ||||
| then | then | ||||
| # | |||||
| # Si c'est la première fois que l'on dessine le block | |||||
| # On choisit la méthode qui découle du nonce | |||||
| # | |||||
| cd $APPS_PATH/nonce | |||||
| nbmethodes=`cat $DATA_PATH/nonce_methods_list.txt | wc -l` | |||||
| lenonce=`php robot.php $BLOCK` | |||||
| lamethode=$((lenonce % nbmethodes)) | |||||
| if [ $lamethode -eq 0 ] | |||||
| then | |||||
| lamethode=$nbmethodes | |||||
| fi | |||||
| LISTE_METHODE=`cat $DATA_PATH/nonce_methods_list.txt | head -n $lamethode | tail -1` | |||||
| else | |||||
| # | |||||
| # CHOISIR UNE METHODE2 AU HASARD | |||||
| # | |||||
| LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf` | |||||
| if [ $NBTX -lt 10 ] | |||||
| then | |||||
| LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | grep -v treemap | grep -v mondrian | shuf` | |||||
| fi | |||||
| fi | |||||
| cd $APPS_PATH/methode2 | |||||
| for METHODE in $LISTE_METHODE | |||||
| do | |||||
| if [ ! -d $DATA_PATH/$METHODE ] | |||||
| then | |||||
| mkdir -p $DATA_PATH/$METHODE | |||||
| fi | |||||
| echo $BLOCK $NAME $METHODE | |||||
| if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ] | |||||
| then | |||||
| php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2 | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png | |||||
| fi | |||||
| done | |||||
| cd - >> /dev/null | |||||
| if [ ! -f $DATA_PATH/nonce/$BLOCK.png ] | |||||
| then | |||||
| cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png | |||||
| echo "Aucune image pour nonce !" | |||||
| fi | fi | ||||
| rm -f $flag | rm -f $flag | ||||
| done < $DATA_PATH/block_list.txt | done < $DATA_PATH/block_list.txt | ||||
| # | |||||
| # List of finished blocks | |||||
| # | |||||
| rm -f $DATA_PATH/finished_block_list.txt | |||||
| grep -v CACHE $DATA_PATH/block_list.txt >> $DATA_PATH/finished_block_list.txt | |||||
| # | # | ||||
| # SORTIE AVEC SUCCES | # SORTIE AVEC SUCCES | ||||
| # | # | ||||
| @ -0,0 +1,140 @@ | |||||
| #!/bin/bash | |||||
| lescript=`basename $0 .sh` | |||||
| flag=$TMP_PATH/bot_$lescript.flag | |||||
| # | |||||
| # TOOLS | |||||
| # | |||||
| function debug | |||||
| { | |||||
| if [ -f $FLAG_PATH/debug ] | |||||
| then | |||||
| echo $1 | |||||
| fi | |||||
| } | |||||
| function sortie | |||||
| { | |||||
| if [ -f $flag ] | |||||
| then | |||||
| rm -f $flag | |||||
| fi | |||||
| exit $1 | |||||
| } | |||||
| function succes | |||||
| { | |||||
| debug "SUCCES" | |||||
| sortie 0 | |||||
| } | |||||
| function echec | |||||
| { | |||||
| debug "ECHEC" | |||||
| exit 1 | |||||
| } | |||||
| # | |||||
| # TEST DU FLAG | |||||
| # | |||||
| if [ -f $flag ] | |||||
| then | |||||
| debug "$0 is already running !" | |||||
| echec | |||||
| fi | |||||
| touch $flag | |||||
| # | |||||
| # PARAMETRES PAR FICHIER FLAGS | |||||
| # | |||||
| if [ -f $FLAG_PATH/no_blocks ] | |||||
| then | |||||
| debug "No blocks" | |||||
| echec | |||||
| fi | |||||
| # | |||||
| # CHOISIR UNE METHODE2 AU HASARD | |||||
| # | |||||
| ROBOT=`ls $APPS_PATH/methode2 | shuf | tail -n 1` | |||||
| debug $ROBOT | |||||
| $APPS_PATH/methode2/robot.sh $ROBOT | |||||
| succes | |||||
| # | |||||
| # CHOISIR UNE METHODE AU HASARD | |||||
| # | |||||
| ROBOT=`ls $APPS_PATH/methode | grep -v hashes | shuf | tail -n 1` | |||||
| debug $ROBOT | |||||
| # | |||||
| # Y A PLUS QU'A ! | |||||
| # | |||||
| if [ ! -f $FLAG_PATH/no_$ROBOT ] | |||||
| then | |||||
| cd $APPS_PATH/methode/$ROBOT | |||||
| for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt` | |||||
| do | |||||
| # | |||||
| # Pour renouveller l'affichage des blocs remarquables | |||||
| # De temps en temps (15%), on efface le block | |||||
| # | |||||
| if [ $((RANDOM % 100)) -lt 15 ] | |||||
| then | |||||
| rm -f $DATA_PATH/$ROBOT/$BLOCK.png | |||||
| fi | |||||
| # | |||||
| # Si l'image n'existe pas, on la calcule | |||||
| # | |||||
| if [ ! -f $DATA_PATH/$ROBOT/$BLOCK.png ] | |||||
| then | |||||
| debug "Compute $DATA_PATH/$ROBOT/$BLOCK.png" | |||||
| php robot.php $BLOCK | |||||
| fi | |||||
| # | |||||
| # Les actions suivantes ne sont réalisées que si | |||||
| # robot.php a produit une image | |||||
| # | |||||
| if [ -f $DATA_PATH/$ROBOT/$BLOCK.png ] | |||||
| then | |||||
| # | |||||
| # Les blocs remarquables sont anti datés à minuit | |||||
| # Pour l'affichage et le nettoyage automatique | |||||
| # | |||||
| BNAME=`grep $BLOCK $DATA_PATH/block_list.txt | awk '{print $1}'` | |||||
| if [ "$BNAME" != "LAST" ] | |||||
| then | |||||
| touch -t $DATE $DATA_PATH/$ROBOT/$BLOCK.png | |||||
| if [ -f $DATA_PATH/spline/$BLOCK.png ] | |||||
| then | |||||
| rm -f $DATA_PATH/hasard/$BLOCK.png | |||||
| ln $DATA_PATH/spline/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png | |||||
| fi | |||||
| fi | |||||
| # | |||||
| # Maintenir le hasard | |||||
| # | |||||
| if [ ! -f $DATA_PATH/hasard/$BLOCK.png ] | |||||
| then | |||||
| ln $DATA_PATH/$ROBOT/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png | |||||
| fi | |||||
| fi | |||||
| done | |||||
| fi | |||||
| # | |||||
| # List of finished blocks | |||||
| # | |||||
| rm -f $DATA_PATH/finished_block_list.txt | |||||
| grep -v CACHE $DATA_PATH/block_list.txt >> $DATA_PATH/finished_block_list.txt | |||||
| # | |||||
| # SORTIE AVEC SUCCES | |||||
| # | |||||
| succes | |||||
| @ -2,7 +2,9 @@ | |||||
| # Antidater les données des blocks connus | # Antidater les données des blocks connus | ||||
| date=`date +%Y%m%d0000` | date=`date +%Y%m%d0000` | ||||
| touch -t $date $DATA_PATH/emptybot/* | |||||
| touch -t $date $DATA_PATH/emptybot/*.{png,txt} | |||||
| for BLOCK in `grep -v LAST $DATA_PATH/block_list.txt | grep -v CACHE | awk '{print $2}'` | for BLOCK in `grep -v LAST $DATA_PATH/block_list.txt | grep -v CACHE | awk '{print $2}'` | ||||
| do | do | ||||
| touch -t $date $DATA_PATH/*/$BLOCK.* | touch -t $date $DATA_PATH/*/$BLOCK.* | ||||
| @ -13,10 +15,11 @@ if [ "$#" -eq "0" ] | |||||
| then | then | ||||
| if [ -d $DATA_PATH ] | if [ -d $DATA_PATH ] | ||||
| then | then | ||||
| find $DATA_PATH -mtime +3 -type f -name *.png -exec rm -f {} \; | |||||
| find $DATA_PATH -mtime +3 -type f -name *.zip -exec rm -f {} \; | |||||
| echo "CLEAN +3 $DATA_PATH" > $TMP_PATH/clean_data.log | |||||
| find $DATA_PATH -mtime +3 -type f -name *.png -exec rm -f {} \; | |||||
| find $DATA_PATH -mtime +3 -type f -name *.zip -exec rm -f {} \; | |||||
| find $TMP_PATH -mtime +3 -type f -name *.flag -exec rm -f {} \; | |||||
| find $TMP_PATH -mtime +3 -type f -name *.flag -exec rm -f {} \; | |||||
| fi | fi | ||||
| else | else | ||||
| if [ "$1" -eq "FULL" ] | if [ "$1" -eq "FULL" ] | ||||
| @ -48,22 +48,34 @@ touch $flag | |||||
| # DO IT ! | # DO IT ! | ||||
| # | # | ||||
| while IFS='' read -r line || [[ -n "$line" ]]; do | while IFS='' read -r line || [[ -n "$line" ]]; do | ||||
| NAME=`echo $line | awk '{print $1}'` | |||||
| BLOCK=`echo $line | awk '{print $2}'` | |||||
| HEIGHT=`echo $line | awk '{print $3}'` | |||||
| NBTX=`echo $line | awk '{print $4}'` | |||||
| # | # | ||||
| # On choisit la méthode qui découle du nonce | # On choisit la méthode qui découle du nonce | ||||
| # | # | ||||
| cd $APPS_PATH/nonce | cd $APPS_PATH/nonce | ||||
| nbmethodes=`ls $APPS_PATH/methode2 | grep -v robot | wc -l` | |||||
| nbmethodes=`cat $DATA_PATH/nonce_methods_list.txt | wc -l` | |||||
| lenonce=`php robot.php $BLOCK` | lenonce=`php robot.php $BLOCK` | ||||
| lamethode=$((lenonce%nbmethodes)) | |||||
| [ $lamethode -eq 0 ] ; lamethode=$nbmethodes | |||||
| METHODE=`ls $APPS_PATH/methode2 | grep -v robot | head -n $lamethode` | |||||
| lamethode=$((lenonce % nbmethodes)) | |||||
| if [ $lamethode -eq 0 ] | |||||
| then | |||||
| lamethode=$nbmethodes | |||||
| fi | |||||
| METHODE=`cat $DATA_PATH/nonce_methods_list.txt | head -n $lamethode | tail -1` | |||||
| echo $NAME $METHODE $lenonce $nbmethodes $lamethode | |||||
| if [ -f $DATA_PATH/$METHODE/$BLOCK.png ] | if [ -f $DATA_PATH/$METHODE/$BLOCK.png ] | ||||
| then | then | ||||
| cp $DATA_PATH/$METHODE/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png | cp $DATA_PATH/$METHODE/$BLOCK.png $DATA_PATH/nonce/$BLOCK.png | ||||
| fi | fi | ||||
| done < $DATA_PATH/block_list.txt | done < $DATA_PATH/block_list.txt | ||||
| rm -f $flag | |||||
| # | # | ||||
| # SORTIE AVEC SUCCES | # SORTIE AVEC SUCCES | ||||
| # | # | ||||
| succes | succes | ||||
| @ -82,7 +82,7 @@ then | |||||
| $APPS_PATH/twitter/twitterbot/robot.sh 2>&1 | $APPS_PATH/twitter/twitterbot/robot.sh 2>&1 | ||||
| # "auto likes" from Topisto | # "auto likes" from Topisto | ||||
| $APPS_PATH/twitter/likebot/robot.sh 2>&1 | |||||
| # $APPS_PATH/twitter/likebot/robot.sh 2>&1 | |||||
| touch $DATA_PATH/twitterbot/$DATEHOUR | touch $DATA_PATH/twitterbot/$DATEHOUR | ||||
| else | else | ||||