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
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
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
<div class="row h-100"> <div class="row h-100">
<div id="chat" class="col-3 h-100" style="border: 1px solid black;"> <div id="chat" class="col-3 h-100" style="border: 1px solid black;">
<frameset class="w-100 h-100"> <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> </frameset>
</div> </div>
<div class="col-9 h-100" style="border: 1px solid black;"> <div class="col-9 h-100" style="border: 1px solid black;">
...@@ -17,16 +18,15 @@ ...@@ -17,16 +18,15 @@
<script> <script>
import Navbar from '@/components/Navbar' import Navbar from '@/components/Navbar'
// import Input from '@/components/Input'
export default { export default {
name: 'Game', name: 'Game',
components: { components: {
Navbar Navbar
// Input
}, },
data() { data() {
return { return {
frame: "https://eden.imt-lille-douai.fr/~alexandre.trochon/chatserver?login=" + localStorage.login,
input: { type: 'text', id: 'message', placeholder: 'Ecrivez votre message' } input: { type: 'text', id: 'message', placeholder: 'Ecrivez votre message' }
} }
}, },
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="body"> <div class="body">
<Navbar/> <Navbar/>
<div class="container d-flex justify-content-center"> <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>
</div> </div>
</template> </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