Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class users{
- private $bdd;
- public function __construct(){
- require_once('core/db.php');
- $this->bdd = $connect;
- }
- public function checkPassword(){
- $email = $_POST['mail'];
- $my_mdp = hash_hmac('ripemd160',$_POST['password'], 'si tu aimes la wac tape dans tes mains');
- $req = $this->bdd->prepare("SELECT * FROM user WHERE mail = '$email'");
- $req->execute();
- $status = $req->fetch();
- if ($status['activee'] == "0") {
- echo "<p class='red-text text-darken-2'>Ce compte a été suprimé.</p>";
- }
- else {
- if (isset($email) && isset($my_mdp)) {
- $req = $this->bdd->prepare("SELECT * FROM user WHERE mail = '$email' AND password = '$my_mdp'");
- $req->execute();
- $check = $req->fetch();
- if ($check['mail'] != $email ) {
- require_once('connect.php');
- echo "<p class='red-text text-darken-2'>adresse mail ou mot de passe invalide.</p>";
- }
- elseif($check['password'] != $my_mdp) {
- require_once('connect.php');
- echo "<p class='red-text text-darken-2'>adresse mail ou mot de passe invalide</p>";
- }
- else{
- header('Location: index.php?controller=UserController&action=timeline');
- }
- }
- $_SESSION['ID'] = $check['id'];
- $_SESSION['pseudo'] = $check['pseudo'];
- $_SESSION['nom'] = $check['nom'];
- $_SESSION['mail'] = $check['mail'];
- $_SESSION['password'] = $_POST['password'];
- $_SESSION['img_profil'] = $check['img_profil'];
- $_SESSION['img_couverture'] = $check['img_couverture'];
- $_SESSION['description'] = $check['description'];
- $_SESSION['web'] = $check['web'];
- $_SESSION['date_nais'] = $check['date_nais'];
- $_SESSION['date_ins'] = $check['date_ins'];
- $_SESSION['activee'] = $check['activee'];
- $_SESSION['ville'] = $check['ville_id'];
- }
- }
- public function addUsers(){
- if(isset($_POST['nom']) && isset($_POST['pseudo']) && isset($_POST['ville']) && isset($_POST['date_nais']) &&
- isset($_POST['mail']) && isset($_POST['password'])){
- $req = $this->bdd->prepare("INSERT INTO user(pseudo, nom, ville_id,
- date_nais, mail, password) VALUES ('".$_POST['pseudo']."', '".$_POST['nom']."',
- '".$_POST['ville']."', '".$_POST['date_nais']."', '".$_POST['mail']."', '".hash_hmac('ripemd160',$_POST['password'], 'si tu aimes la wac tape dans tes mains')."')");
- $req->execute();
- echo '<p class="black-text text-darken-2">Votre inscription a bien était enregistrée, vous allez recevoir un mail pour pouvoir la confirmée ... OU PAS<p><br>
- <form class="osef" action="index.php?controller=UserController&action=connection" method="post">
- <input class="btn waves-effect waves-light blue" type="submit" name="confirm" value="Se connecter">
- </form>';
- require_once('index.php');
- }
- else
- {
- return false;
- }
- }
- public function membre(){
- $req = $this->bdd->prepare('SELECT * FROM user INNER JOIN villes_france_free ON user.ville_id =
- villes_france_free.ville_id WHERE id = "'.$_SESSION['ID'].'"');
- $req->execute();
- $affiche = $req->fetch();
- echo"<div id='Info'>";
- echo "<br><p class='black-text text-darken-2'>".$affiche["nom"]."<br><a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$affiche['id']."'>@".$affiche["pseudo"]."</a><br>".$affiche["date_nais"].
- "<br>".$affiche["ville_nom"]."<br>".$affiche["mail"]."<br></p>";
- echo "</div>";
- }
- public function disconnect(){
- session_destroy();
- header('Location: index.php?controller=UserController&action=connection');
- }
- public function change(){
- $req = $this->bdd->prepare('UPDATE user SET nom = "'.$_POST['new_nom'].'",
- pseudo = "'.$_POST['new_pseudo'].'", web = "'.$_POST['web'].'", description = "'.$_POST['description'].'",
- mail = "'.$_POST['new_email'].'", password = "'.hash_hmac('ripemd160',$_POST['new_mdp'], 'si tu aimes la wac tape dans tes mains').'" WHERE id = "'.$_SESSION['ID'].'"');
- $req->execute();
- header('Location: index.php?controller=UserController&action=membre');
- }
- public function add_img_P(){
- if(isset($_POST['img_P'])){
- $req = $this->bdd->prepare("UPDATE user SET img_profil = '".$_POST['img_P']."' WHERE id = '".$_SESSION['ID']."'");
- $req->execute();
- header('Location: index.php?controller=UserController&action=change');
- }
- }
- public function add_img_C(){
- if(isset($_POST['img_C'])){
- $req = $this->bdd->prepare("UPDATE user SET img_couverture = '".$_POST['img_C']."' WHERE id = '".$_SESSION['ID']."'");
- $req->execute();
- header('Location: index.php?controller=UserController&action=change');
- }
- }
- public function img_profil(){
- $email = $_SESSION['mail'];
- $req = $this->bdd->query("SELECT img_profil FROM user WHERE mail = '$email'");
- $req = $req->fetch();
- echo "<img class= 'img_p' src= ".$req['img_profil'].">";
- }
- public function img_cover(){
- $email = $_SESSION['mail'];
- $req = $this->bdd->query("SELECT img_couverture FROM user WHERE mail = '$email'");
- $req = $req->fetch();
- echo "<img class= 'img_c' src= ".$req['img_couverture'].">";
- }
- public function delete_confirm(){
- $req = $this->bdd->prepare('UPDATE user SET activee = "0" WHERE ID = "'.$_SESSION['ID'].'"');
- $req->execute();
- echo "<p class='black-text text-darken-2'>Voter compte à bien été surprimé<p>";
- }
- public function AddHashTag(){
- if(!empty($_POST['hastag'])){
- $hash = htmlspecialchars($_POST['hashtag']);
- $id = $_SESSION['ID'];
- $req = $this->bdd->prepare("SELECT * FROM `user` INNER JOIN hashtag ON user.id = hashtag.id_tweet WHERE id = $id ");
- $req->execute();
- $req = $this->bdd->prepare("INSERT INTO `hashtag`(`name_hashtag`,`id_tweet`) VALUES ('$hash',$id)");
- $req->execute();
- }
- $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'index.php';
- header('Location: ' . $referer);
- }
- public function Poster(){
- if(!empty($_POST['tweet'])){
- $post = htmlspecialchars($_POST['tweet']);
- $id = $_SESSION['ID'];
- if(strlen($post) <= 140) {
- $req = $this->bdd->prepare('SELECT * FROM `user` INNER JOIN tweet ON user.id = tweet.id_user WHERE id = '.$id.' ');
- $req->execute();
- $req = $this->bdd->prepare("INSERT INTO `tweet` (`tweet`,`date_tweet` ,`id_user`) VALUES ('$post', NOW(), '$id')");
- $req->execute();
- }
- }
- $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'index.php';
- header('Location: ' . $referer);
- }
- public function readtweet(){
- $req = $this->bdd->prepare('SELECT * FROM tweet INNER JOIN user ON tweet.id_user=user.id ORDER BY date_tweet DESC LIMIT 20');
- $req->execute();
- echo "<div class = 'Twe'>";
- while($aff = $req->fetch()){
- echo "<div class= 'tw'><img class= 'img_t' src= ".$aff['img_profil']."><p><a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$aff['id']."'>@".$aff['pseudo']."</a></p><p>".htmlspecialchars($aff['tweet'])."</p><p>".$aff['date_tweet']."</p>";
- if(isset($_SESSION['ID'])){
- $reqq = $this->bdd->prepare('SELECT * FROM commentaire INNER JOIN user ON commentaire.id_user=user.id WHERE id_tweet = '.$aff['id_tweet'].'');
- $reqq->execute();
- echo "commentaire ";
- while($afff = $reqq->fetch()){
- echo "<a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$aff['id']."'>@".$afff['pseudo']."</a> : ";
- echo $afff['com']."<br>";
- }
- echo "</script><form class='osef' action='index.php?controller=UserController&action=comment&id=".$aff['id_tweet']."' method='post'>
- <textarea id='comment' name='comment' class='materialize-textarea'rows='8' cols='80'></textarea>
- <input class='btn waves-effect waves-light blue' type='submit' name='user' value='commentaire'></input></form>";
- $sql = $this->bdd->prepare('SELECT * FROM tweet_like WHERE id_user = "'.$_SESSION['ID'].'" AND id_tweet = "'.$aff['id_tweet'].'"');
- $sql2 = $sql->execute();
- if($sql->rowCount() == 0){
- echo "<form class='osef' action='index.php?controller=UserController&action=like&id=".$aff['id_tweet']."' method='post'>
- <input class='waves-effect waves-light btn blue' type='submit' name='like' value='Like'></input>
- </form>";
- }
- else{
- echo "<form class='osef' action='index.php?controller=UserController&action=unlike&id=".$aff['id_tweet']."' method='post'>
- <input class='waves-effect waves-light btn blue' type='submit' name='unlike' value='Unlike'></input>
- </form>";
- }
- echo "<form class='osef' action='index.php?controller=UserController&action=retweet&id=".$aff['id_tweet']."' method='post'>
- <input class='waves-effect waves-light btn blue' type='submit' name='unlike' value='retweet'></input>
- </form></div>";
- }
- echo "</div>";
- }
- echo "</div>";
- }
- public function showMemberTwt() {
- $req = $this->bdd->prepare('SELECT * FROM tweet INNER JOIN user ON tweet.id_user=user.id WHERE id_user = '.$_SESSION['ID'].' ORDER BY date_tweet DESC LIMIT 20 ');
- $req->execute();
- //var_dump('SELECT * FROM tweet INNER JOIN user ON tweet.id_user=user.id ORDER BY date_tweet DESC WHERE id_user = LIMIT 20');
- echo "<div class = 'Twe'>";
- while($aff = $req->fetch()){
- echo "<div class= 'tw'><img class= 'img_t' src= ".$aff['img_profil']."><p><a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$aff['id']."'>@".$aff['pseudo']."</a></p><p>".htmlspecialchars($aff['tweet'])."</p><p>".$aff['date_tweet']."</p>";
- $reqq = $this->bdd->prepare('SELECT * FROM commentaire INNER JOIN user ON commentaire.id_user=user.id WHERE id_tweet = '.$aff['id_tweet'].'');
- $reqq->execute();
- echo "commentaire ";
- while($afff = $reqq->fetch()){
- echo "<a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$aff['id']."'>@".$afff['pseudo']."</a> : ";
- echo $afff['com']."<br>";
- }
- echo "<form class='osef' action='index.php?controller=UserController&action=comment&id=".$aff['id_tweet']."' method='post'>
- <textarea id='comment' name='comment' class='materialize-textarea'rows='8' cols='80'></textarea>
- <input class='btn waves-effect waves-light blue' type='submit' name='user' value='commentaire'></form>";
- $sql = $this->bdd->prepare('SELECT * FROM tweet_like WHERE id_user = "'.$_SESSION['ID'].'" AND id_tweet = "'.$aff['id_tweet'].'"');
- $sql2 = $sql->execute();
- if($sql->rowCount() == 0){
- echo "<form class='osef' action='index.php?controller=UserController&action=like&id=".$aff['id_tweet']."' method='post'>
- <input class='waves-effect waves-light btn blue' type='submit' name='like' value='Like'></input>
- </form></div>";
- }
- else{
- echo "<form class='osef' action='index.php?controller=UserController&action=unlike&id=".$aff['id_tweet']."' method='post'>
- <input class='waves-effect waves-light btn blue' type='submit' name='unlike' value='Unlike'></input>
- </form></div>";
- }
- }
- echo "</div>";
- }
- public function all_users(){
- global $id, $pp;
- $req = $this->bdd->prepare('SELECT * FROM user WHERE id !=\''.$_SESSION['ID'].'\'');
- $req->execute();
- echo "<div class = 'all'>";
- while($aff = $req->fetch()){
- $id = $aff['id'];
- echo "<div class= 'tw'><p><a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$aff['id']."'>@".$aff['pseudo']."</a></p><p>".$aff['mail']."</p><img class= 'img_t' src= ".$aff['img_profil'].">";
- $pp = $this->bdd->prepare("SELECT * FROM follow INNER JOIN user ON follow.id_followers=user.id WHERE id_followers = '".$_SESSION['ID']."' AND id_following = $id");
- $pp->execute();
- if($pp->rowCount() == 0) {
- echo "<form class='osef' action='index.php?controller=UserController&action=follow&user_id=".$id."' method='post'>
- <input class='btn waves-effect waves-light blue' type='submit' name='user' value='follow'>
- </form>";
- }
- else {
- echo "<form class='osef' action='index.php?controller=UserController&action=unfollow&user_id=".$id."' method='post'>
- <input class='btn waves-effect waves-light blue' type='submit' name='user' value='unfollow'>
- </form>";
- }
- echo "</div>";
- }
- echo "</div>";
- }
- public function follow(){
- $ids = $_SESSION['ID'];
- $id = $_GET['user_id'];
- $req = $this->bdd->prepare("SELECT * FROM user INNER JOIN follow ON user.id=follow.id_followers WHERE id = $ids");
- $req->execute();
- $req = $this->bdd->prepare("SELECT * FROM user INNER JOIN follow ON user.id=follow.id_following WHERE id = $id ");
- $req->execute();
- $req = $this->bdd->prepare("INSERT INTO `follow` (`id_followers`,`id_following`) VALUES ($ids, $id)");
- $req->execute();
- $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'index.php';
- header('Location: ' . $referer);
- }
- public function unfollow(){
- $ids = $_SESSION['ID'];
- $id = $_GET['user_id'];
- $req = $this->bdd->prepare("SELECT * FROM user INNER JOIN follow ON user.id=follow.id_followers WHERE id = $ids");
- $req->execute();
- $req = $this->bdd->prepare("SELECT * FROM user INNER JOIN follow ON user.id=follow.id_following WHERE id = $id ");
- $req->execute();
- $req = $this->bdd->prepare("DELETE FROM follow WHERE id_followers = $ids AND id_following = $id");
- $req->execute();
- $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'index.php';
- header('Location: ' . $referer);
- }
- public function comment(){
- if(!empty($_POST['comment'])){
- $req = $this->bdd->prepare('INSERT INTO commentaire(id_user, id_tweet, com) VALUES ("'.$_SESSION['ID'].'", "'.$_GET['id'].'", "'.$_POST['comment'].'")');
- $req->execute();
- }
- $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'index.php';
- header('Location: ' . $referer);
- }
- public function like(){
- $req = $this->bdd->prepare('INSERT INTO tweet_like(id_user, id_tweet) VALUES ("'.$_SESSION['ID'].'", "'.$_GET['id'].'")');
- $req->execute();
- $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'index.php';
- header('Location: ' . $referer);
- }
- public function unlike(){
- $req = $this->bdd->prepare('DELETE FROM tweet_like WHERE id_user = "'.$_SESSION['ID'].'" AND id_tweet = "'.$_GET['id'].'"');
- $req->execute();
- $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'index.php';
- header('Location: ' . $referer);
- }
- public function follower(){
- $idf = $_SESSION['ID'];
- $req = $this->bdd->prepare("SELECT COUNT(*) AS cont FROM user INNER JOIN follow ON user.id=follow.id_followers WHERE user.id='$idf'");
- $req->execute();
- $reqs = $this->bdd->prepare("SELECT COUNT(*) AS cunt FROM user INNER JOIN follow ON user.id=follow.id_following WHERE user.id='$idf'");
- $reqs->execute();
- echo "<div id='flw'>";
- while ($aff=$reqs ->fetch()) {
- echo "<form class='osef' action='index.php?controller=UserController&action=affFollow' method='post'>";
- echo "<input class='btn waves-effect waves-light blue' type='submit' name='user' value='Abonnée : ".$aff['cunt']."'></form>";
- }
- while($aff = $req->fetch()){
- echo "<form class='osef' action='index.php?controller=UserController&action=affFollowing' method='post'>";
- echo "<input class='btn waves-effect waves-light blue' type='submit' name='user' value='Abonnements : ".$aff['cont']."'></form>";
- }
- echo "</div>";
- }
- public function affFollow() {
- $idf = $_SESSION['ID'];
- $requete = $this->bdd->prepare("SELECT * FROM follow INNER JOIN user ON follow.id_following=$idf WHERE id = id_followers");
- $requete->execute();
- $requetes = $this->bdd->prepare("SELECT * FROM follow INNER JOIN user ON follow.id_followers=$idf WHERE id = id_following");
- $requetes->execute();
- echo "<div class= 'tw'><h3>FOLLOWERS</h3><hr/>";
- while($aff = $requete->fetch()){
- $pp = $this->bdd->prepare("SELECT * FROM follow INNER JOIN user ON follow.id_followers=user.id WHERE id_followers = '".$_SESSION['ID']."' AND id_following = ".$aff['id']);
- $pp->execute();
- echo "<p><a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$aff['id']."'>@".$aff['pseudo']."</a></p><img class= 'img_t' src= ".$aff['img_profil']."><br>";
- if($pp->rowCount() == 0) {
- echo "<form class='osef' action='index.php?controller=UserController&action=follow&user_id=".$aff['id']."' method='post'>
- <input class='btn waves-effect waves-light blue' type='submit' name='user' value='follow'>
- </form>";
- }
- else {
- echo "<form class='osef' action='index.php?controller=UserController&action=unfollow&user_id=".$aff['id']."' method='post'>
- <input class='btn waves-effect waves-light blue' type='submit' name='user' value='unfollow'>
- </form>";
- }
- }
- echo "</div>";
- }
- public function affFollowing() {
- $idf = $_SESSION['ID'];
- $requete = $this->bdd->prepare("SELECT * FROM follow INNER JOIN user ON follow.id_following=$idf WHERE id = id_followers");
- $requete->execute();
- $requetes = $this->bdd->prepare("SELECT * FROM follow INNER JOIN user ON follow.id_followers=$idf WHERE id = id_following");
- $requetes->execute();
- echo "<div class= 'tw'><h3>FOLLOWING</h3><hr/>";
- while ($aff=$requetes->fetch()) {
- echo "<p><a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$aff['id']."'>@".$aff['pseudo']."</a></p><img class= 'img_t' src= ".$aff['img_profil'].">";
- echo"<form class='osef' action='index.php?controller=UserController&action=unfollow&user_id=".$aff['id']."' method='post'>
- <input class='btn waves-effect waves-light blue' type='submit' name='user' value='unfollow'>
- </form><br>";
- }
- echo "</div>";
- }
- public function send_message(){
- $req = $this->bdd->prepare('SELECT * FROM user WHERE pseudo = "'.htmlspecialchars($_POST['dest']).'"');
- $req->execute();
- while ($aff = $req->fetch()){
- $reqs = $this->bdd->prepare('INSERT INTO messages (id_to, id_by, message) VALUES ('.$aff['id'].','.$_SESSION['ID'].', "'.$_POST['message'].'")');
- $reqs->execute();
- }
- header('location: index.php?controller=UserController&action=messagerie');
- }
- public function read_message(){
- $req = $this->bdd->prepare('SELECT * FROM messages INNER JOIN user ON messages.id_by=user.id WHERE id_to = '.$_SESSION['ID'].' ORDER BY date_env DESC');
- $req->execute();
- echo "<p>Reçu</p>";
- while ($aff = $req->fetch()){
- echo "<div class= 'tw'><img class= 'img_t' src= ".$aff['img_profil']."><p><a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$aff['id']."'>@".$aff['pseudo']."</a></p><p>".htmlspecialchars($aff['message'])."</p>";
- echo "<form class='osef' action='index.php?controller=UserController&action=repondre&id_by=".$aff['id_by']."' method='post'>
- <textarea id='comment' name='message' class='materialize-textarea'rows='8' cols='80'></textarea>
- <input class='btn waves-effect waves-light blue' type='submit' name='user' value='repondre'></form></div>";
- }
- $req = $this->bdd->prepare('SELECT * FROM messages INNER JOIN user ON messages.id_to=user.id WHERE id_by = '.$_SESSION['ID'].' ORDER BY date_env DESC');
- $req->execute();
- echo "<p>envoyer</p>";
- while ($aff = $req->fetch()){
- echo "<div class= 'tw'><img class= 'img_t' src= ".$aff['img_profil']."><p><a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$aff['id']."'>@".$aff['pseudo']."</a></p><p>".htmlspecialchars($aff['message'])."</p></div>";
- }
- }
- public function repondre(){
- $id_to = $_GET['id_by'];
- $req = $this->bdd->prepare('INSERT INTO messages (id_to, id_by, message) VALUES ('.$id_to.','.$_SESSION['ID'].', "'.$_POST['message'].'")');
- var_dump($req);
- $req->execute();
- header('location: index.php?controller=UserController&action=messagerie');
- }
- public function profil(){
- $req = $this->bdd->prepare('SELECT * FROM user INNER JOIN villes_france_free ON user.ville_id =
- villes_france_free.ville_id WHERE id = '.$_GET['id_user'].'');
- $req->execute();
- $affiche = $req->fetch();
- echo"<div id='Info'>";
- echo "<br><p class='black-text text-darken-2'>".$affiche["nom"]."<br><a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$affiche['id']."'>@".$affiche["pseudo"]."</a><br>".$affiche["date_nais"].
- "<br>".$affiche["ville_nom"]."<br>".$affiche["mail"]."<br></p>";
- echo "</div>";
- }
- public function showProfilTwt(){
- $id = $_GET['id_user'];
- $req = $this->bdd->prepare('SELECT * FROM tweet INNER JOIN user ON tweet.id_user=user.id WHERE id_user = '.$_GET['id_user'].' ORDER BY date_tweet DESC LIMIT 20 ');
- $req->execute();
- echo "<div class = 'Twe'>";
- while($aff = $req->fetch()){
- echo "<div class= 'tw'><img class= 'img_t' src= ".$aff['img_profil']."><p><a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$aff['id']."'>@".$aff['pseudo']."</a></p><p>".htmlspecialchars($aff['tweet'])."</p><p>".$aff['date_tweet']."</p>";
- $reqq = $this->bdd->prepare('SELECT * FROM commentaire INNER JOIN user ON commentaire.id_user=user.id WHERE id_tweet = '.$aff['id_tweet'].'');
- $reqq->execute();
- echo "commentaire ";
- while($afff = $reqq->fetch()){
- echo "<a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$aff['id']."'>@".$afff['pseudo']."</a> : ";
- echo $afff['com']."<br>";
- }
- echo "<form class='osef' action='index.php?controller=UserController&action=comment&id=".$aff['id_tweet']."' method='post'>
- <textarea id='comment' name='comment' class='materialize-textarea'rows='8' cols='80'></textarea>
- <input class='btn waves-effect waves-light blue' type='submit' name='user' value='commentaire'></form>";
- $sql = $this->bdd->prepare('SELECT * FROM tweet_like WHERE id_user = "'.$_SESSION['ID'].'" AND id_tweet = "'.$aff['id_tweet'].'"');
- $sql2 = $sql->execute();
- if($sql->rowCount() == 0){
- echo "<form class='osef' action='index.php?controller=UserController&action=like&id=".$aff['id_tweet']."' method='post'>
- <input class='waves-effect waves-light btn blue' type='submit' name='like' value='Like'></input>
- </form>";
- }
- else{
- echo "<form class='osef' action='index.php?controller=UserController&action=unlike&id=".$aff['id_tweet']."' method='post'>
- <input class='waves-effect waves-light btn blue' type='submit' name='unlike' value='Unlike'></input>
- </form>";
- }
- echo "<form class='osef' action='index.php?controller=UserController&action=retweet&id=".$aff['id_tweet']."' method='post'>
- <input class='waves-effect waves-light btn blue' type='submit' name='unlike' value='retweet'></input>
- </form></div>";
- }
- $pp = $this->bdd->prepare("SELECT * FROM follow INNER JOIN user ON follow.id_followers=user.id WHERE id_followers = '".$_SESSION['ID']."' AND id_following = $id");
- $pp->execute();
- if($pp->rowCount() == 0) {
- echo "<form class='osef' action='index.php?controller=UserController&action=follow&user_id=".$id."' method='post'>
- <input class='btn waves-effect waves-light blue' type='submit' name='user' value='follow'>
- </form>";
- }
- else {
- echo "<form class='osef' action='index.php?controller=UserController&action=unfollow&user_id=".$id."' method='post'>
- <input class='btn waves-effect waves-light blue' type='submit' name='user' value='unfollow'>
- </form>";
- }
- echo "</div>";
- echo "</div>";
- }
- public function img_profil_profil(){
- $req = $this->bdd->query("SELECT img_profil FROM user WHERE id = ".$_GET['id_user']."");
- $req = $req->fetch();
- echo "<img class= 'img_p' src= ".$req['img_profil'].">";
- }
- public function img_cover_profil(){
- $req = $this->bdd->query("SELECT img_couverture FROM user WHERE id = ".$_GET['id_user']."");
- $req = $req->fetch();
- echo "<img class= 'img_c' src= ".$req['img_couverture'].">";
- }
- public function followerProfil(){
- $idf = $_GET['id_user'];
- $req = $this->bdd->prepare("SELECT COUNT(*) AS cont FROM user INNER JOIN follow ON user.id=follow.id_followers WHERE user.id='$idf'");
- $req->execute();
- $reqs = $this->bdd->prepare("SELECT COUNT(*) AS cunt FROM user INNER JOIN follow ON user.id=follow.id_following WHERE user.id='$idf'");
- $reqs->execute();
- echo "<div id='flw'>";
- while ($aff=$reqs ->fetch()) {
- echo "<form class='osef' action='index.php?controller=UserController&action=affFollowProfil&id_user=".$idf."' method='post'>";
- echo "<input class='btn waves-effect waves-light blue' type='submit' name='user' value='Abonnée : ".$aff['cunt']."'></form>";
- }
- while($aff = $req->fetch()){
- echo "<form class='osef' action='index.php?controller=UserController&action=affFollowingProfil&id_user=".$idf."' method='post'>";
- echo "<input class='btn waves-effect waves-light blue' type='submit' name='user' value='Abonnements : ".$aff['cont']."'></form>";
- }
- echo "</div>";
- }
- public function affFollowProfil() {
- $idf = $_GET['id_user'];
- $requete = $this->bdd->prepare("SELECT * FROM follow INNER JOIN user ON follow.id_following=$idf WHERE id = id_followers");
- $requete->execute();
- $requetes = $this->bdd->prepare("SELECT * FROM follow INNER JOIN user ON follow.id_followers=$idf WHERE id = id_following");
- $requetes->execute();
- echo "<div class= 'tw'><h3>FOLLOWERS</h3><hr/>";
- while($aff = $requete->fetch()){
- $pp = $this->bdd->prepare("SELECT * FROM follow INNER JOIN user ON follow.id_followers=user.id WHERE id_followers = '".$_SESSION['ID']."' AND id_following = ".$aff['id']);
- $pp->execute();
- echo "<p><a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$aff['id']."'>@".$aff['pseudo']."</a></p><img class= 'img_t' src= ".$aff['img_profil']."><br>";
- }
- echo "</div>";
- }
- public function affFollowingProfil(){
- $idf = $_GET['id_user'];
- $requete = $this->bdd->prepare("SELECT * FROM follow INNER JOIN user ON follow.id_following=$idf WHERE id = id_followers");
- $requete->execute();
- $requetes = $this->bdd->prepare("SELECT * FROM follow INNER JOIN user ON follow.id_followers=$idf WHERE id = id_following");
- $requetes->execute();
- echo "<div class= 'tw'><h3>FOLLOWING</h3><hr/>";
- while ($aff=$requetes->fetch()) {
- echo "<p><a class='lnProf'href='index.php?controller=UserController&action=profil&id_user=".$aff['id']."'>@".$aff['pseudo']."</a></p><img class= 'img_t' src= ".$aff['img_profil'].">";
- }
- echo "</div>";
- }
- public function retweet(){
- $id = $_SESSION['ID'];
- $req = $this->bdd->prepare('SELECT * FROM tweet WHERE id_tweet = '.$_GET['id'].' ');
- $req->execute();
- while ($aa = $req->fetch()) {
- $post = $aa['tweet'];
- $idr = $aa['id_tweet'];
- $req = $this->bdd->prepare('INSERT INTO tweet (tweet, id_retweet,id_user) VALUES ("'.htmlspecialchars($post).'", '.$idr.', '.$id.')');
- $req->execute();
- $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'index.php';
- header('Location: ' . $referer);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement