diff --git a/public/ajax/readRecords.php b/public/ajax/readRecords.php index 8077419..ef7bc22 100644 --- a/public/ajax/readRecords.php +++ b/public/ajax/readRecords.php @@ -17,7 +17,7 @@ Prix en junes'; $params["antenne_slug"] = $antenne_slug; - $requete = "SELECT products.*, users.username, users.pubkey + $requete = "SELECT products.*, users.username, users.pubkey FROM products LEFT JOIN antennes ON antennes.id = products.antenne_id @@ -50,7 +50,13 @@ $number"; $prix = $row['prix']; $vendeur = $row['username']; - $produit = $row['name']; + $status = $row['status']; + if ($status == "solde") { + $produit = "[$status] "; + } else { + $produit = ""; + } + $produit .= $row['name']; $pubkey = $row['pubkey']; $pubkeyShort = substr($pubkey, 0, 8); $vendeur_format = "$vendeur"; diff --git a/scripts/check_sold.sh b/scripts/check_sold.sh new file mode 100755 index 0000000..dfb9953 --- /dev/null +++ b/scripts/check_sold.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +#DUNITER="http://192.168.9.54:45000" +DUNITER="https://duniter-g1.p2p.legal" +TXBLOCKS=$(curl -s ${DUNITER}/blockchain/with/tx | jq '.result.blocks[]') +TXBLOCKS=$(echo "$TXBLOCKS" | tail -n 5 | tr '\n' ' ') + +#echo "$TXBLOCKS" + +for i in $TXBLOCKS2; do + result=$(curl -s ${DUNITER}/blockchain/block/$i | jq '.transactions[].comment' | grep -v '""' | tr -d '"') + isSell=$(echo "$result" | grep "Merci") +# [[ ! -z $isSell ]] && echo $isSell +# echo --- + sleep 1 +done + + +isSell="[Achat GMarche] : testCesium" +isSell=$(echo $isSell | cut -d' ' -f4-) + +echo "$isSell est vendu" + +req="UPDATE products SET status = 'solde' WHERE name = '$isSell';" + +mysql --database gmarche -e "$req" +mysql --database gmarche -e "SELECT name,status FROM products;" + +exit 0