Compare commits
10 Commits
e557174e96
...
f3728dd939
Author | SHA1 | Date |
---|---|---|
poka | f3728dd939 | |
poka | 65fa534743 | |
poka | 022cf49eea | |
poka | 1987ca71b3 | |
poka | 46a4b54118 | |
poka | b035d4022d | |
poka | f73d15220e | |
poka | 49ea6216d6 | |
poka | 7da07e5b16 | |
poka | 48668e7433 |
|
@ -1,8 +1,9 @@
|
||||||
config/config.php
|
config/config.php
|
||||||
|
scripts/.loc_hash
|
||||||
.idea
|
.idea
|
||||||
/public/uploads
|
/public/uploads
|
||||||
/tmp
|
/tmp
|
||||||
vendor
|
vendor
|
||||||
composer.json
|
composer.json
|
||||||
composer.lock
|
composer.lock
|
||||||
/src/Framework/SwiftMailerFactory.php
|
/src/Framework/SwiftMailerFactory.php
|
||||||
|
|
|
@ -18,12 +18,12 @@
|
||||||
<th>Prix en junes</th>';
|
<th>Prix en junes</th>';
|
||||||
|
|
||||||
$params["antenne_slug"] = $antenne_slug;
|
$params["antenne_slug"] = $antenne_slug;
|
||||||
$requete = "SELECT products.*, users.username, users.pubkey
|
$requete = "SELECT products.*, users.username, users.pubkey
|
||||||
FROM products
|
FROM products
|
||||||
LEFT JOIN antennes
|
LEFT JOIN antennes
|
||||||
ON antennes.id = products.antenne_id
|
ON antennes.id = products.antenne_id
|
||||||
LEFT JOIN users
|
LEFT JOIN users
|
||||||
ON users.id = products.user_id
|
ON users.id = products.user_id
|
||||||
WHERE antennes.slug = :antenne_slug";
|
WHERE antennes.slug = :antenne_slug";
|
||||||
$stmt = $bdd->prepare($requete);
|
$stmt = $bdd->prepare($requete);
|
||||||
$stmt2 = $bdd->prepare($requete);
|
$stmt2 = $bdd->prepare($requete);
|
||||||
|
@ -51,7 +51,13 @@
|
||||||
<td>$number</td>";
|
<td>$number</td>";
|
||||||
$prix = $row['prix'];
|
$prix = $row['prix'];
|
||||||
$vendeur = $row['username'];
|
$vendeur = $row['username'];
|
||||||
$produit = $row['name'];
|
$quantite = $row['quantite'];
|
||||||
|
if ($quantite == "0") {
|
||||||
|
$produit = "[Vendu] ";
|
||||||
|
} else {
|
||||||
|
$produit = "";
|
||||||
|
}
|
||||||
|
$produit .= $row['name'];
|
||||||
$pubkey = $row['pubkey'];
|
$pubkey = $row['pubkey'];
|
||||||
$pubkeyShort = substr($pubkey, 0, 8);
|
$pubkeyShort = substr($pubkey, 0, 8);
|
||||||
$vendeur_format = "<a target=\"_blank\" href=\"https://g1.duniter.fr/#/app/wot/$pubkey/\">$vendeur</a>";
|
$vendeur_format = "<a target=\"_blank\" href=\"https://g1.duniter.fr/#/app/wot/$pubkey/\">$vendeur</a>";
|
||||||
|
@ -60,7 +66,7 @@
|
||||||
$data .= '<td><img src="/uploads/products/'.$antenne_slug.'/'.$row['image'].'" width="100" height="100" /></td>';
|
$data .= '<td><img src="/uploads/products/'.$antenne_slug.'/'.$row['image'].'" width="100" height="100" /></td>';
|
||||||
$data .= '<td>'.$vendeur_format.'</td>';
|
$data .= '<td>'.$vendeur_format.'</td>';
|
||||||
$data .= '<td>'.$cle_pub_format.'</td>';
|
$data .= '<td>'.$cle_pub_format.'</td>';
|
||||||
$data .= '<td>'.$row['quantite'].'</td>';
|
$data .= '<td>'.$quantite.'</td>';
|
||||||
$data .= '<td>'.$prix.'</td>';
|
$data .= '<td>'.$prix.'</td>';
|
||||||
if ($row['username'] == $nom_connecte ) {
|
if ($row['username'] == $nom_connecte ) {
|
||||||
$data .= '<td>';
|
$data .= '<td>';
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
[ "$EUID" -ne 0 ] && sudo="sudo" || sudo=""
|
||||||
|
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
||||||
|
|
||||||
|
start=`date +%s`
|
||||||
|
date=$(date +'%d-%m-%y à %H:%M')
|
||||||
|
echo "### $date ###"
|
||||||
|
|
||||||
|
## Initialisation
|
||||||
|
DUNITER=$(grep g1_node $SCRIPTPATH/../config/config.php | awk '{ print $3}' | tr -d ';' | tr -d "'")
|
||||||
|
TXBLOCKS=$(curl -s $DUNITER/blockchain/with/tx | jq '.result.blocks[]')
|
||||||
|
TXBLOCKS=$(echo "$TXBLOCKS" | tail -n 2 | tr '\n' ' ')
|
||||||
|
keyword="\[Achat GMarche] : "
|
||||||
|
[ ! -e $SCRIPTPATH/.loc_hash ] && touch $SCRIPTPATH/.loc_hash
|
||||||
|
|
||||||
|
## Récupération des transactions avec commentaire GMarche
|
||||||
|
|
||||||
|
for i in $TXBLOCKS; do
|
||||||
|
result=$(curl -s $DUNITER/blockchain/block/$i | jq '.transactions[].hash, .transactions[].comment' | grep -v '""' | tr -d '"' | grep -B1 "$keyword")
|
||||||
|
rhash=$(echo "$result" | head -n1)
|
||||||
|
rcom=$(echo "$result" | tail -n1)
|
||||||
|
if [[ ! -z $result && -z $(grep $rhash $SCRIPTPATH/.loc_hash) ]]; then
|
||||||
|
isSell+=$(echo -e "$rcom;")
|
||||||
|
echo "$rhash" >> $SCRIPTPATH/.loc_hash
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
## Ajout des transactions en piscine pour les users GMarche
|
||||||
|
|
||||||
|
req="SELECT pubkey FROM users;"
|
||||||
|
usersPubkeys=$($sudo mysql --database gmarche -e "$req" | grep .)
|
||||||
|
|
||||||
|
for i in $usersPubkeys; do
|
||||||
|
result=$(curl -s $DUNITER/tx/history/$i/pending | jq '. | select(.history.sending == [])' | jq '.history.pending[].hash,.history.pending[].comment' | tr -d '"')
|
||||||
|
rhash=$(echo "$result" | head -n1)
|
||||||
|
rcom=$(echo "$result" | tail -n1)
|
||||||
|
if [[ ! -z $result && -z $(grep $rhash $SCRIPTPATH/.loc_hash) ]]; then
|
||||||
|
isSell+=$(echo -e "$rcom;")
|
||||||
|
echo "$rhash" >> $SCRIPTPATH/.loc_hash
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
## Retrait de l'identifiant gmarche des commentaires
|
||||||
|
isSell=$(echo $isSell | sed "s/$keyword//g")
|
||||||
|
|
||||||
|
[[ ! -z $isSell ]] && echo "$isSell est vendu"
|
||||||
|
|
||||||
|
## Retrait d'un quantité pour les articles vendu
|
||||||
|
IFS=';'; ADDR=($isSell); unset IFS;
|
||||||
|
for i in "${ADDR[@]}"; do
|
||||||
|
#req="UPDATE products SET status = 'solde' WHERE name = '$i';"
|
||||||
|
req="UPDATE products SET quantite = CASE WHEN quantite = 0 THEN quantite ELSE quantite - 1 END WHERE name = '$i';"
|
||||||
|
$sudo mysql --database gmarche -e "$req"
|
||||||
|
done
|
||||||
|
|
||||||
|
#$sudo mysql --database gmarche -e "SELECT name,status FROM products;"
|
||||||
|
|
||||||
|
end=`date +%s`
|
||||||
|
runtime=$((end-start))
|
||||||
|
echo "Temps d'execution: ${runtime}s"
|
||||||
|
exit 0
|
|
@ -116,14 +116,16 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">Annuler</button>
|
||||||
<button type="button" class="btn btn-primary"
|
<button type="submit" value="submit" class="btn btn-primary"
|
||||||
onclick="connexion(document.getElementById('pseudo').value,document.getElementById('mdp').value)">Valider</button>
|
onclick="connexion(document.getElementById('pseudo').value,document.getElementById('mdp').value)">Valider</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>
|
||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue