diff --git a/.gitignore b/.gitignore index 63eb14d..b4cc05f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,11 @@ config/config.php +scripts/.loc_hash .idea -public/uploads +public/uploads/* +!public/uploads/default.png tmp vendor composer.json composer.lock -src/Framework/SwiftMailerFactory.php \ No newline at end of file +src/Framework/SwiftMailerFactory.php + diff --git a/public/css/mapael.css b/public/css/mapael.css index 3ff5edc..dc3f3c8 100644 --- a/public/css/mapael.css +++ b/public/css/mapael.css @@ -1,8 +1,19 @@ .mapael .map { - background-color: #cddee0; + background-color: rgba(0, 0, 0, 0.3); + padding: 15px; margin-bottom: 10px; position: relative; + width: 60%; + left: 50%; + transform: translateX(-50%); + border-radius: 10%; } + +.home_map { + font-size:1.2rem; + font-weight:bold; +} + /* For all zoom buttons */ .mapael .zoomButton { background-color: #fff; @@ -38,7 +49,7 @@ } .mapael .mapTooltip { position: absolute; - background-color: #474c4b; + background-color: #1D1D1D; moz-opacity: 0.70; opacity: 0.70; filter: alpha(opacity=70); @@ -48,4 +59,4 @@ max-width: 200px; display: none; color: #fff; -} \ No newline at end of file +} diff --git a/public/css/products.css b/public/css/products.css new file mode 100644 index 0000000..870b7c9 --- /dev/null +++ b/public/css/products.css @@ -0,0 +1,82 @@ +.container_main { + background-color: #2E2E2E; +} +.tableau { + width:100%; + background-color: white; + table-layout: fixed; + border-collapse: collapse; + /* border-spacing: 1px; // pour contrer les style de base */ +} +/* Entête */ +.tableau th { + border-spacing: 0; + border-collapse: collapse; + padding: 0rem; + text-align: center; + border-left: lightgray 1px solid; + background-color:#999690; + color:#fff; +} +.tableau .colonne_image { + padding: 0; !important; +} +.tableau td { + border-bottom: solid 1px black; + border-left: lightgray 1px solid; + padding-left: 0.7rem; +} +.align_droite { + + text-align: right; + padding-right: 2rem; +} +.breadcrumb { + font-size: 1rem; +} + +.toggle_radio { + position: relative; + background: rgba(0,0,0,.1); + margin: -3px auto 4px 10px; + overflow: hidden; + padding: 0 !important; + border-radius: 50px; + height: 28px; + width: 215px; +} +.toggle_radio > * { + float: left; +} +.toggle_radio input[type=radio]{ + display: none; +} +.toggle_radio label{ + color: rgba(0,0,0,.9); + z-index: 0; + display: block; + width: 100px; + height: 20px; + margin: 3px 3px; + border-radius: 50px; + cursor: pointer; + z-index: 1; + text-align: center; +} +.toggle_option_slider{ + width: 100px; + height: 20px; + position: absolute; + top: 4px; + border-radius: 50px; + transition: all .4s ease; +} + +#first_toggle:checked ~ .toggle_option_slider{ + background: rgba(0,0,0,.3); + left: 3px; +} +#second_toggle:checked ~ .toggle_option_slider{ + background: rgba(0,0,0,.3); + left: 109px; +} diff --git a/public/css/style.css b/public/css/style.css index 71a6f6f..6706233 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -19,10 +19,19 @@ btn-custom { -webkit-font-smoothing: antialiased; } +#logo_home { + width:30rem; + margin: 0 auto; + margin-top: -15px; + margin-bottom: 10px; + text-align: center; +} + img { max-width: 100%; height: auto; } + #la_page { text-align: center; width: 1174px; @@ -30,6 +39,7 @@ img { height:auto; margin-left: auto; margin-right: auto; + opacity:0.9; } #la_page a { @@ -58,7 +68,9 @@ li { background-size: 100% auto; font-family: Bree Serif, Arial, sans-serif; font-size: 14px; + opacity:0.97; } + header.header { width: 389px; height: 259px; @@ -86,19 +98,24 @@ header.header img { font-size: 26px; } -.article { - width:auto; - height:auto; - font-size: 24px; -} -.article2 { +.article .article2 { width:auto; height:auto; font-size: 24px; } + .container { font-family: Arial, sans-serif; } + +.container.home { + font-family: Arial, sans-serif; + height:auto; + width:60rem; + text-align:center; + border: 0px; +} + .profil_user { height: 400px; width: 900px; @@ -175,7 +192,7 @@ header.header img { } body.loading .loadingPubkey { - overflow: hidden; + overflow: hidden; display: block; } diff --git a/public/models/readRecords.php b/public/models/readRecords.php index 8b740c0..f679ae9 100644 --- a/public/models/readRecords.php +++ b/public/models/readRecords.php @@ -2,28 +2,28 @@ session_start(); ini_set('display_errors', 0); include '../../config/config.php'; -$antenne_slug = $_GET['antenne_slug']; -$nom_connecte = $_SESSION['user']; -$bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password); + $antenne_slug = $_GET['antenne_slug']; + $nom_connecte = $_SESSION['user']; + $bdd = new \PDO("mysql:host=$db_server;dbname=$db_name", $db_username, $db_password); -// Affichage des intitulés de colonnes -$data = ' - - - - - - - - '; + // Affichage des intitulés de colonnes + $data = '
No.Bien / servicePhotoVendeurClé publiqueQuantitéPrix en junes
+ + + + + + + + '; -$params["antenne_slug"] = $antenne_slug; -$requete = "SELECT products.*, users.username, users.pubkey - FROM products - LEFT JOIN antennes - ON antennes.id = products.antenne_id - LEFT JOIN users - ON users.id = products.user_id + $params["antenne_slug"] = $antenne_slug; + $requete = "SELECT products.*, users.username, users.pubkey + FROM products + LEFT JOIN antennes + ON antennes.id = products.antenne_id + LEFT JOIN users + ON users.id = products.user_id WHERE antennes.slug = :antenne_slug"; $stmt = $bdd->prepare($requete); $stmt2 = $bdd->prepare($requete); @@ -49,49 +49,61 @@ if ($count > 0) $data .= ""; - $prix = $row['prix']; - $vendeur = $row['username']; - $produit = $row['name']; - $pubkey = $row['pubkey']; - $pubkeyShort = substr($pubkey, 0, 8); - $vendeur_format = "$vendeur"; - $cle_pub_format = " $pubkeyShort... "; - $data .= ''; - $data .= ''; - $data .= ''; - $data .= ''; - $data .= ''; - $data .= ''; - if ($row['username'] == $nom_connecte ) { - $data .= ''; + $imagep = '../uploads/products/'.$antenne_slug.'/'.$row['image'].''; + if (file_exists($imagep) && $row['image']) { + $data .= ''; + } else { + $data .= ''; + } + $data .= ''; + $data .= ''; + $data .= ''; + $data .= ''; + if ($row['username'] == $nom_connecte ) { + $data .= ''; - $data .= ''; + $imagep = '../uploads/recherches/'.$antenne_slug.'/'.$row['image'].''; + if (file_exists($imagep) && $row['image']) { + $data .= ''; + } else { + $data .= ''; + } $data .= ''; $data .= ''; $data .= ''; diff --git a/public/uploads/default.png b/public/uploads/default.png new file mode 100755 index 0000000..ee6994b Binary files /dev/null and b/public/uploads/default.png differ diff --git a/scripts/check_sold.sh b/scripts/check_sold.sh new file mode 100755 index 0000000..a245b45 --- /dev/null +++ b/scripts/check_sold.sh @@ -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 diff --git a/src/Auth/Action/LoginAttemptAction.php b/src/Auth/Action/LoginAttemptAction.php index 7b301a7..e0e493c 100644 --- a/src/Auth/Action/LoginAttemptAction.php +++ b/src/Auth/Action/LoginAttemptAction.php @@ -57,7 +57,6 @@ class LoginAttemptAction session_start(); } $_SESSION['role'] = $this->userTable->findRole($params['username']); - //$nom_user = $_SESSION['user'] = $params['username']; $_SESSION['user'] = $params['username']; $path = $this->session->get('auth.redirect') ?: $this->router->generateUri('gmarche.index'); $this->session->delete('auth.redirect'); diff --git a/src/Gmarche/views/index.twig b/src/Gmarche/views/index.twig index 37e89a4..2e5eeb2 100644 --- a/src/Gmarche/views/index.twig +++ b/src/Gmarche/views/index.twig @@ -4,9 +4,9 @@ Ğ1-Marché : Régions {% if page > 1 %}, page {{ page }} {% endif %} {% endblock %} {% block body %} -
- -
+
+ +
    @@ -17,7 +17,7 @@
-
+ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/Product/views/admin/products/index.twig b/src/Product/views/admin/products/index.twig index f418154..d60e97f 100644 --- a/src/Product/views/admin/products/index.twig +++ b/src/Product/views/admin/products/index.twig @@ -2,91 +2,10 @@ {% extends 'layout.twig' %} {% block title "Ğ1-Marché - Produits" %} + {% block body %} - -
+
No.Bien / servicePhotoVendeurClé publiqueQuantitéPrix en junes
$number'.$produit.''.$vendeur_format.''.$cle_pub_format.''.$row['quantite'].''.$prix.''; - $data .= ''.$produit.''.$vendeur_format.''.$cle_pub_format.''.$quantite.''.$prix.''; + $data .= ''.$produit.''.$vendeur_format.''.$pubkeyShort.'...'.$row['quantite'].'