diff --git a/Timeline/css/modal.css b/Timeline/css/modal.css index 41f9f66e38f27a69ed44dad200b4402a1cf1cfb6..540d27bcb95771b4772e83b9baa2e18496fc778d 100755 --- a/Timeline/css/modal.css +++ b/Timeline/css/modal.css @@ -1,4 +1,4 @@ -.vote { +.vote, .vote:focus, .vote:active { float : left; background-color: #52b3da; color: white; @@ -47,7 +47,9 @@ border-color:#66CC33; } - +.glyphicon-send { + color : white; +} .btn-circle span { padding-right: 6px; } .tab-content { @@ -62,4 +64,8 @@ img { margin-right: auto; margin-left: auto; max-height: 400px; +} + +.nav-tabs a, .nav-tabs a:hover{ + color:black; } \ No newline at end of file diff --git a/Timeline/js/modal.js b/Timeline/js/modal.js index e16d49bc4c5dd71f63d1dd6b75632e1896a2ce7b..64dc0e03abd82f7316fec78760d260111ec45030 100755 --- a/Timeline/js/modal.js +++ b/Timeline/js/modal.js @@ -62,6 +62,10 @@ $(document).ready(function (){ { $("#like").attr("disabled", true); } + else + { + $("#nbr_like").attr("idphoto", idphoto); + } } else @@ -71,7 +75,33 @@ $(document).ready(function (){ } }); - - }); + $('#like').click(function () { + + var nombre = $("#nbr_like").text(); + var idphoto = $("#nbr_like").attr("idphoto"); + + $.ajax({ + + type:'POST', + url:'script_like.php', + data:"nombre="+nombre+"&idphoto="+idphoto, + success:function(msg) { + + if(msg == "OK") + { + $("#like").attr("disabled", true); + + nombre = nombre + 1; + + $("#nbr_like").html(nombre); + } + + } + }); + + }); + }); + + }); \ No newline at end of file diff --git a/Timeline/mes_posts.php b/Timeline/mes_posts.php index 44cc4e16fdfc78137e6ab86d2f26ec7cd2b0f594..9900ba3740a5ce2ac61766e3aedc21699650a0a9 100755 --- a/Timeline/mes_posts.php +++ b/Timeline/mes_posts.php @@ -64,9 +64,9 @@ <!-- fichier css perso --> <link rel="stylesheet" href="css/menu.css"> <link rel="stylesheet" href="css/mes_posts.css"> - <link rel="stylesheet" type="text/css" href="css/modal.css"> <link rel="stylesheet" type="text/css" href="css/buttonLink.css"> - + <link rel="stylesheet" type="text/css" href="css/modal.css"> + </head> <body> diff --git a/Timeline/modal.php b/Timeline/modal.php index b5be55016c6d1322257923a1d8e03a09004f0081..834ab2478a81c1d15f43006b9fb6159dfda085a2 100755 --- a/Timeline/modal.php +++ b/Timeline/modal.php @@ -61,9 +61,9 @@ echo '</div>'; echo '</div>'; echo '<div class="modal-footer">'; -echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Vote pour la photo la plus trash">Trash<span class="badge trash">0</span></button>'; -echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Vote pour la photo où ça pécho sec">Love<span class="badge love">0</span></button>'; -echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Photo de toute beauté" id="like">Like<span class="badge like">0</span></button>'; +echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Vote pour la photo la plus trash">Trash<span class="badge">0</span></button>'; +echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Vote pour la photo où ça pécho sec">Love<span class="badge">0</span></button>'; +echo '<button class="btn btn-primary vote" data-toggle="tooltip" title="Photo de toute beauté" id="like">Like<span class="badge" id="nbr_like" idphoto="" >0</span></button>'; echo '</div>'; echo '</div>'; diff --git a/Timeline/script_like.php b/Timeline/script_like.php new file mode 100755 index 0000000000000000000000000000000000000000..598ae20796439ca69e88dc8515f8fa1eb887e998 --- /dev/null +++ b/Timeline/script_like.php @@ -0,0 +1,60 @@ +<?php + +session_start(); + +$id = $_SESSION['login']; +$nombre = $_POST['nombre']; +$idphoto = $_POST['idphoto']; + +$nombre = $nombre + 1; + +function addLike($db, $idphoto, $id) { + + $stmt = $db->prepare("INSERT INTO liker(idphoto, idutilisateur) VALUES (:idphoto,'$id')"); + $stmt->bindParam(':idphoto', $idphoto); + return $stmt->execute(); +} + +function upCompteurLike($db, $idphoto, $val) { + $stmt = $db->prepare("UPDATE photo SET nblike='$val' WHERE idphoto=:id"); + $stmt->bindParam(':id', $idphoto); + return $stmt->execute(); +} + +try{ + + /* Connexion à la base de données avec PDO */ + + $DB = new PDO("pgsql:host=localhost;dbname=projet_web", "postgres", "root"); + + $result = addLike($DB, $idphoto, $id); + + if($result) + { + $done = upCompteurLike($DB, $idphoto, $nombre); + if($done) + { + echo "OK"; + } + else + { + echo "erreur"; + } + } + else + { + echo "erreur"; + } + + $DB = null; + + + } + + catch(PDOException $e){ + echo "Database Error"; + } + + + +?> \ No newline at end of file