コード例 #1
0
ファイル: chat-request.php プロジェクト: Pyozer/Interminale
            $id = $donnees[$i]['id'];
            $msg = $donnees[$i]['message'];
            $auteur = $donnees[$i]['auteur'];
            $datemsgorigin = $donnees[$i]['date_msg'];
            $datemsg = AffDate($datemsgorigin);
            $datetimemsg = date('c', $datemsgorigin);
            include $_SERVER['DOCUMENT_ROOT'] . '/app/view/chatmsg.template.php';
        }
    } else {
        echo '<div id="message" style="padding: 20px 5px 0 20px;font-size: 20px;"><p><strong>Aucun message :/</strong></p></div>';
    }
}
/**
* On enregistre message envoyé dans le chat et renvoi info user
**/
if (isset($_POST['sendchatmsg']) && isset($_POST['message'])) {
    $message = htmlspecialchars($_POST['message']);
    $envoimsg = $DB_con->prepare("INSERT INTO chat(message, auteur, date_msg) VALUES(:message, :auteur, :date_msg)");
    $envoimsg->execute(array('message' => $message, 'auteur' => $_SESSION['username'], 'date_msg' => time()));
    $usermsg = $_SESSION['username'];
    if (!isset($_SESSION['prenomplusnom'])) {
        $info_profil_me = $profil->get_profil_info($usermsg);
        $_SESSION['prenomplusnom'] = $info_profil_me['prenomplusnom'];
    }
    $nameuser = $_SESSION['prenomplusnom'];
    $msg = $message;
    $dateactuel = time();
    $date = AffDate($dateactuel);
    $reponse = array('usermsg' => $usermsg, 'nameuser' => $nameuser, 'message' => $msg, 'date' => $date);
    echo json_encode($reponse);
}
コード例 #2
0
ファイル: post_user.php プロジェクト: Pyozer/Interminale
         $requetepostsuser->execute(array('auteur' => $user_id));
     } else {
         $requetepostsuser = $DB_con->prepare("SELECT * FROM posts WHERE auteur=:auteur AND public=:public ORDER BY id DESC");
         $requetepostsuser->execute(array('public' => "1", 'auteur' => $user_id));
     }
 }
 if ($requetepostsuser->rowCount() > 0) {
     while ($selectedPost = $requetepostsuser->fetch()) {
         $post_id = $selectedPost['id'];
         $post_user_name = $selectedPost['auteur'];
         $nameuser = $profil->get_profil_info_name($post_user_name);
         $post_name = $nameuser['prenomplusnom'];
         $post_message = $selectedPost['content'];
         $public = $selectedPost['public'];
         $timestamp = $selectedPost['date_post'];
         $date = AffDate($timestamp, "post");
         $datetime = date('c', $timestamp);
         $img_post = $selectedPost['img_post'];
         $post_like = $like->get_nbr_likes($post_id);
         $post_comments = $comment->get_nbr_comments($post_id);
         $hrefimgprofil = $img->get_img_profil_post($post_user_name);
         if ($like->verif_if_like($post_id, $_SESSION['userid'])) {
             $likedornot = "liked";
         } else {
             $likedornot = "";
         }
         include $_SERVER['DOCUMENT_ROOT'] . '/app/view/post.template.php';
     }
 } else {
     include $_SERVER['DOCUMENT_ROOT'] . '/app/view/no-post.template.php';
 }
コード例 #3
0
     $_SESSION['prenomplusnom'] = $info_profil_me['prenomplusnom'];
 }
 if (!isset($_SESSION['imgprofil'])) {
     $_SESSION['imgprofil'] = $img->get_img_profil_post($pseudo_me);
 }
 $name_me = $_SESSION['prenomplusnom'];
 $imgprofil_me = $_SESSION['imgprofil'];
 $pseudo_usermsg = $donnees[$i]['pseudo_exp'];
 $info_profil_pseudo_usermsg = $profil->get_profil_info($pseudo_usermsg);
 $name_pseudo_usermsg = $info_profil_pseudo_usermsg['prenomplusnom'];
 $imgprofil_pseudo_usermsg = $img->get_img_profil_post($pseudo_usermsg);
 $id_msg = $donnees[$i]['id'];
 $id_conv = $donnees[$i]['id_conv'];
 $msg = $donnees[$i]['message'];
 $date = $donnees[$i]['date_msg'];
 $date = AffDate($date, "message");
 if ($donnees[$i]['pseudo_dest'] == $pseudo_me) {
     $message->msg_put_read($id_conv);
 }
 if ($donnees[$i]['pseudo_exp'] == $pseudo_me) {
     ob_start();
     include $_SERVER['DOCUMENT_ROOT'] . '/app/view/message_me.template.php';
     $view = ob_get_clean();
     ob_end_flush();
 } else {
     ob_start();
     include $_SERVER['DOCUMENT_ROOT'] . '/app/view/message_to_me.template.php';
     $view = ob_get_clean();
     ob_end_flush();
 }
 $arr = array('status' => 1, 'view' => $view);
コード例 #4
0
ファイル: tweet.php プロジェクト: Pyozer/TwitterRemake
<?php

use Core\Config;
use App\Vendor\Tweets;
$userid = $_SESSION['userid'];
$tweets = Tweets::getInstance($DB_con, $userid);
/* On récupère tous les tweets d'un utilisateur */
$alltweets = $tweets->getUserTweets();
foreach ($alltweets as $keyPrimary => $tweet) {
    $href = "/profil.php?user="******" " . $tweet->nom;
    $user_username = "******" . $tweet->pseudo;
    $datetime = new DateTime($tweet->date);
    $date_timeago = $datetime->format(DateTime::ISO8601);
    $date_publish = AffDate(strtotime($tweet->date));
    $idtweet = $tweet->id;
    $tweet_text = $tweet->tweet;
    $img_profil = "https://pbs.twimg.com/profile_images/671484118035734532/KBNaQRTb_400x400.png";
    $img_tweet = $tweet->img_tweet;
    $nbr_rt = $tweet->nbr_rt;
    $nbr_fav = $tweet->nbr_fav;
    $nbr_reply = $tweet->nbr_reply;
    require Config::get('view.paths') . '/templates/tweet.template.php';
}
コード例 #5
0
ファイル: post-request.php プロジェクト: Pyozer/Interminale
 /* On stock le tabeau dans une variable */
 $friends = $amis->get_friends_with_user($_SESSION['username']);
 $classelist = $classe->get_user_classe($_SESSION['username']);
 $listaffiche = array_merge($friends, $classelist);
 $requeteposts = $DB_con->prepare("SELECT * FROM posts WHERE (auteur REGEXP(:auteurs) OR public=:public) AND id > :lastid ORDER BY id DESC");
 $requeteposts->execute(array('auteurs' => implode('|', $listaffiche), 'public' => 1, 'lastid' => $lastid));
 if ($requeteposts->rowCount() > 0) {
     while ($selectedPost = $requeteposts->fetch()) {
         $post_id = $selectedPost['id'];
         $post_user_name = $selectedPost['auteur'];
         $nameuser = $profil->get_profil_info_name($post_user_name);
         $post_name = $nameuser['prenomplusnom'];
         $post_message = $selectedPost['content'];
         $public = $selectedPost['public'];
         $date = $selectedPost['date_post'];
         $date = AffDate($date, "post");
         $img_post = $selectedPost['img_post'];
         $post_like = $like->get_nbr_likes($post_id);
         $post_comments = $comment->get_nbr_comments($post_id);
         $hrefimgprofil = $img->get_img_profil_post($post_user_name);
         if ($like->verif_if_like($post_id, $_SESSION['userid'])) {
             $likedornot = "liked";
         } else {
             $likedornot = "";
         }
         ob_start();
         include $_SERVER['DOCUMENT_ROOT'] . '/app/view/post.template.php';
         $view = ob_get_clean();
         ob_end_flush();
         $arr = array('status' => 1, 'view' => $view, 'auteur' => $post_name);
         echo json_encode($arr);
コード例 #6
0
ファイル: comment.php プロジェクト: Pyozer/Interminale
    if ($nbrcomment < 5) {
        $requetecomment = $DB_con->prepare("SELECT * FROM comments WHERE id_post=:id_post ORDER BY id DESC");
        $requetecomment->execute(array('id_post' => $post_id));
    } else {
        $requetecomment = $DB_con->prepare("SELECT * FROM comments WHERE id_post=:id_post ORDER BY id DESC LIMIT 5");
        $requetecomment->execute(array('id_post' => $post_id));
    }
    $numcomment = 0;
    while ($selectedComment = $requetecomment->fetch()) {
        $comment_id = $selectedComment['id'];
        $comment_auteur = $selectedComment['auteur'];
        $nameuser = $profil->get_profil_info_name($comment_auteur);
        $comment_name = $nameuser['prenomplusnom'];
        $comment_message = $selectedComment['content'];
        $timestamp = $selectedComment['date_comment'];
        $comment_date = AffDate($timestamp, "comment");
        $datetimecomment = date('c', $timestamp);
        $hrefimgprofil = $img->get_img_profil_post($comment_auteur);
        $numcomment = $numcomment + 1;
        include $_SERVER['DOCUMENT_ROOT'] . '/app/view/comment.template.php';
    }
} catch (PDOException $e) {
    echo $e->getMessage();
}
if ($nbrcomment > 5) {
    ?>
	<div id="btnloadmore<?php 
    echo $post_id;
    ?>
" class="centered">
		<button type="button" class="btn btn-outline-primary btn-sm" id="loadmore" style="border-radius: 25px;" onClick="afficher_plus(<?php 
コード例 #7
0
<?php

//****************************************************
// Controller: Affichage message envoyés
//****************************************************
try {
    $requetemsg_sent = $DB_con->prepare("SELECT * FROM messages WHERE pseudo_exp=:pseudo_exp ORDER BY id DESC LIMIT 15");
    $requetemsg_sent->execute(array('pseudo_exp' => $_SESSION['username']));
    if ($requetemsg_sent->rowCount() > 0) {
        while ($selectedMsg = $requetemsg_sent->fetch()) {
            $id_msg = $selectedMsg['id'];
            $pseudo_dest = $selectedMsg['pseudo_dest'];
            $info_profil_dest = $profil->get_profil_info($pseudo_dest);
            $name_dest = $info_profil_dest['prenomplusnom'];
            $date_envoi = $selectedMsg['date_msg'];
            $date_envoi = AffDate($date_envoi, "message");
            $imgprofil_dest = $img->get_img_profil_post($pseudo_dest);
            include $_SERVER['DOCUMENT_ROOT'] . '/app/view/messagerie_envoyer.template.php';
        }
    } else {
        include $_SERVER['DOCUMENT_ROOT'] . '/app/view/no-msg.template.php';
    }
} catch (PDOException $e) {
    echo $e->getMessage();
}
コード例 #8
0
    $id = htmlspecialchars($_POST['post_id']);
    $lastcomment = (int) htmlspecialchars($_POST['lastcomment']);
    $nbrcomments = $comment->get_nbr_comments($id);
    $requeteoldcomments = $DB_con->prepare("SELECT * FROM comments WHERE id_post=:id_post ORDER BY id DESC LIMIT " . $lastcomment . ", 5");
    $requeteoldcomments->execute(array('id_post' => $id));
    $numcomment = $lastcomment;
    while ($selectedComment = $requeteoldcomments->fetch()) {
        $post_id = $id;
        $comment_id = $selectedComment['id'];
        $comment_auteur = $selectedComment['auteur'];
        $nameuser = $profil->get_profil_info_name($comment_auteur);
        $comment_name = $nameuser['prenomplusnom'];
        $comment_message = $selectedComment['content'];
        $comment_date = $selectedComment['date_comment'];
        /*$comment_date = strftime('%d %B %Y à %H:%M', $comment_date);*/
        $comment_date = AffDate($comment_date, "comment");
        $hrefimgprofil = $img->get_img_profil_post($comment_auteur);
        $numcomment = $numcomment + 1;
        include $_SERVER['DOCUMENT_ROOT'] . '/app/view/comment.template.php';
    }
    if ($nbrcomments > $numcomment) {
        ?>
		<div id="btnloadmore<?php 
        echo $id;
        ?>
" class="centered">
			<button type="button" class="btn btn-outline-primary btn-sm" id="loadmore" style="border-radius: 25px;" onClick="afficher_plus(<?php 
        echo $id;
        ?>
);">Afficher plus</button>
		</div>
コード例 #9
0
ファイル: messagerie.php プロジェクト: Pyozer/Interminale
<?php

//****************************************************
// Controller: Affichage conversation messages privés
//****************************************************
try {
    /* On récupère tous les messages concernant l'utilisateur */
    $requetemsg_list = $DB_con->prepare("SELECT * FROM messages WHERE (pseudo_dest=:me OR pseudo_exp=:me) ORDER BY date_msg DESC");
    $requetemsg_list->execute(array('me' => $_SESSION['username']));
    if ($requetemsg_list->rowCount() > 0) {
        $lastid_conv = array();
        while ($selectedMsg = $requetemsg_list->fetch()) {
            $id_msg = $selectedMsg['id'];
            $id_conv = $selectedMsg['id_conv'];
            $lastdate = $selectedMsg['date_msg'];
            $date_envoi = AffDate($lastdate, "message");
            $pseudo_dest = $selectedMsg['pseudo_dest'];
            $pseudo_exp = $selectedMsg['pseudo_exp'];
            if ($pseudo_dest == $_SESSION['username']) {
                $pseudo_usermsg = $pseudo_exp;
            } else {
                $pseudo_usermsg = $pseudo_dest;
            }
            $checklu = $DB_con->prepare("SELECT lu FROM messages WHERE pseudo_dest=:me AND pseudo_exp=:usermsg AND id_conv=:id_conv AND lu=:lu ORDER BY date_msg DESC");
            $checklu->execute(array('me' => $_SESSION['username'], 'usermsg' => $pseudo_usermsg, 'id_conv' => $id_conv, 'lu' => 0));
            if ($checklu->rowCount() > 0) {
                $lu = 0;
            } else {
                $lu = 1;
            }
            if ($lu == 1) {