Commit 808bc22a authored by raphael.peim's avatar raphael.peim

Update Rules.vue and Game.vue

parent a10f0700
<?php
require '../init.php';
if(isset($_POST['message']) && !empty($_POST['message']) && isset($_SESSION['id_utilisateur'])) {
$usr = 0;
if(isset($_POST['usr'])) {
$usr = $_POST['usr'];
}
$sql = "INSERT INTO `messages`(id_user, id_user_private, content)
VALUES (" . intval($_SESSION['id_utilisateur']) . ", " . intval($usr) . ", :message)";
$query = $db->prepare($sql);
$query->bindValue(':message', $_POST['message'], PDO::PARAM_STR);
$query->execute();
}
?>
\ No newline at end of file
<?php
require '../init.php';
if(isset($_SESSION['id_utilisateur'])) {
$message = array();
$sql = "SELECT m.id, u.login, u.avatar, u.avatar_url, m.content, m.`date`, m.id_user_private
FROM `messages` AS m
LEFT JOIN users AS u ON u.id = m.id_user
WHERE (date BETWEEN timestamp(DATE_SUB(NOW(), INTERVAL 2 MINUTE))
AND timestamp(NOW()))
AND (m.id_user_private = 0
OR m.id_user = " . intval($_SESSION['id_utilisateur']) . "
OR m.id_user_private = " . intval($_SESSION['id_utilisateur']) . ")
GROUP BY m.id";
foreach($db->query($sql) as $data) {
$msg = array(
'id_message' => $data['id'],
'login' => $data['login'],
'prive' => $data['id_user_private'],
'message' => strip_tags($data['content']),
'avatar' => $data['avatar'],
'avatar_url' => $data['avatar_url'],
'date' => $data['date']
);
$message[] = $msg;
}
echo json_encode($message);
}
?>
\ No newline at end of file
<?php
require '../init.php';
if(isset($_SESSION['id_utilisateur']))
{
// MAJ session
$sql = "UPDATE `sessions` SET date=CURRENT_TIMESTAMP WHERE id_user = " . intval($_SESSION['id_utilisateur']);
$query = $db->prepare($sql);
$query->execute();
// Liste utilisateurs
$utilisateur = array();
$sql = "SELECT s.id_user, u.login, u.avatar, u.avatar_url
FROM `sessions` AS s
LEFT JOIN users AS u ON u.id = s.id_user
WHERE (s.date BETWEEN timestamp(DATE_SUB(NOW(), INTERVAL 10 SECOND)) AND timestamp(NOW()))
GROUP BY s.id_user";
foreach($db->query($sql) as $data) {
$usr = array(
'id_utilisateur' => $data['id_user'],
'login' => $data['login'],
'avatar' => $data['avatar'],
'avatar_url' => $data['avatar_url']
);
$utilisateur[] = $usr;
}
echo json_encode($utilisateur);
}
?>
\ No newline at end of file
frontend/chat/images/avatar/1.png

1.04 KB

frontend/chat/images/avatar/10.png

718 Bytes

frontend/chat/images/avatar/11.png

809 Bytes

frontend/chat/images/avatar/12.png

825 Bytes

frontend/chat/images/avatar/13.png

943 Bytes

frontend/chat/images/avatar/14.png

984 Bytes

frontend/chat/images/avatar/15.png

922 Bytes

frontend/chat/images/avatar/16.png

1 KB

frontend/chat/images/avatar/17.png

988 Bytes

frontend/chat/images/avatar/18.png

883 Bytes

frontend/chat/images/avatar/19.png

1 KB

frontend/chat/images/avatar/2.png

937 Bytes

frontend/chat/images/avatar/20.png

924 Bytes

frontend/chat/images/avatar/21.png

878 Bytes

frontend/chat/images/avatar/22.png

802 Bytes

frontend/chat/images/avatar/23.png

986 Bytes

frontend/chat/images/avatar/24.png

827 Bytes

frontend/chat/images/avatar/25.png

774 Bytes

frontend/chat/images/avatar/26.png

772 Bytes

frontend/chat/images/avatar/27.png

853 Bytes

frontend/chat/images/avatar/28.png

828 Bytes

frontend/chat/images/avatar/29.png

1.11 KB

frontend/chat/images/avatar/3.png

945 Bytes

frontend/chat/images/avatar/30.png

990 Bytes

frontend/chat/images/avatar/31.png

1.05 KB

frontend/chat/images/avatar/32.png

1009 Bytes

frontend/chat/images/avatar/33.png

802 Bytes

frontend/chat/images/avatar/34.png

891 Bytes

frontend/chat/images/avatar/35.png

992 Bytes

frontend/chat/images/avatar/36.png

986 Bytes

frontend/chat/images/avatar/37.png

827 Bytes

frontend/chat/images/avatar/38.png

891 Bytes

frontend/chat/images/avatar/39.png

995 Bytes

frontend/chat/images/avatar/4.png

833 Bytes

frontend/chat/images/avatar/40.png

933 Bytes

frontend/chat/images/avatar/41.png

910 Bytes

frontend/chat/images/avatar/42.png

935 Bytes

frontend/chat/images/avatar/43.png

833 Bytes

frontend/chat/images/avatar/44.png

892 Bytes

frontend/chat/images/avatar/45.png

741 Bytes

frontend/chat/images/avatar/46.png

1 KB

frontend/chat/images/avatar/47.png

878 Bytes

frontend/chat/images/avatar/48.png

940 Bytes

frontend/chat/images/avatar/49.png

819 Bytes

frontend/chat/images/avatar/5.png

973 Bytes

frontend/chat/images/avatar/50.png

1.07 KB

frontend/chat/images/avatar/6.png

915 Bytes

frontend/chat/images/avatar/7.png

955 Bytes

frontend/chat/images/avatar/8.png

1.12 KB

frontend/chat/images/avatar/9.png

752 Bytes

frontend/chat/images/graphic/deconnexion.png

289 Bytes

frontend/chat/images/graphic/message.png

333 Bytes

frontend/chat/images/graphic/profil.png

412 Bytes

This diff is collapsed.
<?php
header('Content-Type:text/html;charset=utf-8');
// BDD
define('DB_HOST', 'localhost');
define('DB_PORT', 8888);
define('DB_DATABASE', 'dbtest');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', 'root');
// Infos site
define('URL_SITE', 'http://localhost:8888/IMT/CDAW/frontend/chat/'); //adresse du dossier avec le projet
define('URL_MEDIA', 'http://localhost:8888/IMT/CDAW/frontend/chat/images/'); //adresse du dossier images
define('URL_PROFIL', 'https://www.google.fr/?q=');
define('PATH_SITE', '/chemin/chat/');
// Connexion BDD
$db = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_DATABASE . ';charset=utf8', DB_USERNAME, DB_PASSWORD);
// Session
session_start();
?>
\ No newline at end of file
frontend/src/assets/img/rules.png

225 KB

......@@ -5,7 +5,8 @@
<div class="row h-100">
<div id="chat" class="col-3 h-100" style="border: 1px solid black;">
<frameset class="w-100 h-100">
<frame src="https://eden.imt-lille-douai.fr/~alexandre.trochon/chatserver/" />
<frame :src="frame" />
<!-- <frame src="http://localhost:8888/IMT/CDAW/frontend/chat" /> -->
</frameset>
</div>
<div class="col-9 h-100" style="border: 1px solid black;">
......@@ -17,16 +18,15 @@
<script>
import Navbar from '@/components/Navbar'
// import Input from '@/components/Input'
export default {
name: 'Game',
components: {
Navbar
// Input
},
data() {
return {
frame: "https://eden.imt-lille-douai.fr/~alexandre.trochon/chatserver?login=" + localStorage.login,
input: { type: 'text', id: 'message', placeholder: 'Ecrivez votre message' }
}
},
......
......@@ -2,7 +2,7 @@
<div class="body">
<Navbar/>
<div class="container d-flex justify-content-center">
<h1>Les règles</h1>
<img src="../assets/img/rules.png" class="img-fluid" alt="Responsive image" style="border: 1px solid black;" />
</div>
</div>
</template>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment