Mukho

update little bit

......@@ -38,14 +38,23 @@ app.use("/chat", express.static(__dirname+ "/chat"));
app.set('view engine', 'ejs')
// 로그용
var today = new Date();
var year = today.getFullYear();
var month = ('0' + (today.getMonth()+1)).slice(-2);
var day = ('0' + today.getDate()).slice(-2);
var hour = ('0' + today.getHours()).slice(-2);
var minute = ('0' + today.getMinutes()).slice(-2);
var second = ('0' + today.getSeconds()).slice(-2);
var logString = '['+year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second+'] ';
var logString;
function getTime(){
var today = new Date();
var year = today.getFullYear();
var month = ('0' + (today.getMonth()+1)).slice(-2);
var day = ('0' + today.getDate()).slice(-2);
var hour = ('0' + today.getHours()).slice(-2);
var minute = ('0' + today.getMinutes()).slice(-2);
var second = ('0' + today.getSeconds()).slice(-2);
logString = '['+year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second+'] ';
}
// 시간 갱신용
function init(){
getTime();
setInterval(getTime, 1000)
}
init()
app.use(session({
secret: 'keyboard cat',
......@@ -84,7 +93,7 @@ io.sockets.on('connection', function(socket) {
/* 새로운 유저가 접속했을 경우 다른 소켓에게도 알려줌 */
socket.on('newUser', function(name) {
console.log(name + ' 님이 접속하였습니다.')
console.log(logString + name + ' 님이 접속하였습니다.')
/* 소켓에 이름 저장해두기 */
socket.name = name
......@@ -106,7 +115,7 @@ io.sockets.on('connection', function(socket) {
/* 접속 종료 */
socket.on('disconnect', function() {
console.log(socket.name + '님이 나가셨습니다.')
console.log(logString+socket.name + '님이 나가셨습니다.')
/* 나가는 사람을 제외한 나머지 유저에게 메시지 전송 */
socket.broadcast.emit('update', {type: 'disconnect', name: 'SERVER', message: socket.name + '님이 나가셨습니다.'});
......
......@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>묵호 - 놀이터</title>
<title>묵호 - About</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
<!-- Bootstrap icons-->
......
......@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>묵호 - 놀이터</title>
<title>묵호 - 게시판</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
<!-- Bootstrap icons-->
......
......@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>묵호 - 놀이터</title>
<title>묵호 - 로그인</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
<!-- Bootstrap icons-->
......
......@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>묵호 - 놀이터</title>
<title>묵호 - 회원가입</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
<!-- Bootstrap icons-->
......
......@@ -60,14 +60,10 @@ create table board(
>UPDATE board SET idx = @COUNT:=@COUNT+1;
---
### 최종 수정: 2021-11-20 21:44<br>
### 최종 수정: 2021-11-23 01:48<br>
### 수정 내용:
1. 최근 있었던 DB명세구조 변경
>alter table board drop passwd;<br>
>alter table board add ID varchar(20) not null;<br>
>alter table board change name nickname;<br>
>alter table board modify nickname varchar(20);
0. 채팅기능에 버그가 있는 것 같음-피드백 바람(undefined님이 나가셨습니다. -> 콘솔에 계속 출력됨)
1. 일부 수정
2. 로그에 시간 추가
3. 시간 실시간 반영
4. 게시글 수정 및 삭제 세션+권한 연동/DB수정
......@@ -75,4 +71,3 @@ create table board(
6. 게시글 조회수 구현
7. 프로필 수정 세션 연동
8. etc
\ No newline at end of file
......
......@@ -5,11 +5,35 @@ var path = require('path') // 상대경로
var mysql_odbc = require('../../db/db_board')();
var myinfo = mysql_odbc.init();
// 로그용
var logString;
function getTime(){
var today = new Date();
var year = today.getFullYear();
var month = ('0' + (today.getMonth()+1)).slice(-2);
var day = ('0' + today.getDate()).slice(-2);
var hour = ('0' + today.getHours()).slice(-2);
var minute = ('0' + today.getMinutes()).slice(-2);
var second = ('0' + today.getSeconds()).slice(-2);
logString = '['+year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second+'] ';
}
// 시간 갱신용
function init(){
getTime();
setInterval(getTime, 1000)
}
init()
router.get('/', function(req, res){
var id = req.user;
if(!id) res.sendFile(path.join(__dirname, "../../public/login.html"))
if(!id){
console.log(logString+'익명 유저의 채팅 접근을 거부했습니다.')
res.sendFile(path.join(__dirname, "../../public/login.html"))
}
if(id){
res.render('chat.ejs', {'nickname':id.nickname})
var nickname = req.user.nickname
console.log(logString+req.user.ID+'('+nickname+') 유저가 채팅 중입니다.')
res.render('chat.ejs', {'nickname':nickname})
}
});
......
......@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>묵호 - 놀이터</title>
<title>묵호 - About</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
<!-- Bootstrap icons-->
......
......@@ -2,7 +2,7 @@
<html>
<head>
<meta charset="utf-8">
<title>채팅</title>
<title>묵호 - 놀이터</title>
<link rel="stylesheet" href="/css/chat.css">
<script src="/socket.io/socket.io.js"></script>
<script src="/js/chat.js"></script>
......
......@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>묵호 - 놀이터</title>
<title>묵호 - 게시판</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
<!-- Bootstrap icons-->
......
......@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>묵호 - 놀이터</title>
<title>묵호 - 로그인</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
<!-- Bootstrap icons-->
......
......@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>내 정보</title>
<title>묵호 - 내 정보</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
<!-- Bootstrap icons-->
......
......@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>정보 수정</title>
<title>묵호 - 내 정보 수정</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
<!-- Bootstrap icons-->
......
<!DOCTYPE html>
<html>
<head>
<title>묵호 - 놀이터</title>
<title>묵호 - <%= row.title %></title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
<!-- Bootstrap icons-->
......
......@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>묵호 - 놀이터</title>
<title>묵호 - 회원가입</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
<!-- Bootstrap icons-->
......
<!DOCTYPE html>
<html>
<head>
<title>묵호 - 놀이터</title>
<title>묵호 - 글쓰기</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="../assets/favicon.ico" />
<!-- Bootstrap icons-->
......