Showing
16 changed files
with
61 additions
and
33 deletions
... | @@ -38,14 +38,23 @@ app.use("/chat", express.static(__dirname+ "/chat")); | ... | @@ -38,14 +38,23 @@ app.use("/chat", express.static(__dirname+ "/chat")); |
38 | app.set('view engine', 'ejs') | 38 | app.set('view engine', 'ejs') |
39 | 39 | ||
40 | // 로그용 | 40 | // 로그용 |
41 | -var today = new Date(); | 41 | +var logString; |
42 | -var year = today.getFullYear(); | 42 | +function getTime(){ |
43 | -var month = ('0' + (today.getMonth()+1)).slice(-2); | 43 | + var today = new Date(); |
44 | -var day = ('0' + today.getDate()).slice(-2); | 44 | + var year = today.getFullYear(); |
45 | -var hour = ('0' + today.getHours()).slice(-2); | 45 | + var month = ('0' + (today.getMonth()+1)).slice(-2); |
46 | -var minute = ('0' + today.getMinutes()).slice(-2); | 46 | + var day = ('0' + today.getDate()).slice(-2); |
47 | -var second = ('0' + today.getSeconds()).slice(-2); | 47 | + var hour = ('0' + today.getHours()).slice(-2); |
48 | -var logString = '['+year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second+'] '; | 48 | + var minute = ('0' + today.getMinutes()).slice(-2); |
49 | + var second = ('0' + today.getSeconds()).slice(-2); | ||
50 | + logString = '['+year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second+'] '; | ||
51 | +} | ||
52 | +// 시간 갱신용 | ||
53 | +function init(){ | ||
54 | + getTime(); | ||
55 | + setInterval(getTime, 1000) | ||
56 | +} | ||
57 | +init() | ||
49 | 58 | ||
50 | app.use(session({ | 59 | app.use(session({ |
51 | secret: 'keyboard cat', | 60 | secret: 'keyboard cat', |
... | @@ -84,7 +93,7 @@ io.sockets.on('connection', function(socket) { | ... | @@ -84,7 +93,7 @@ io.sockets.on('connection', function(socket) { |
84 | 93 | ||
85 | /* 새로운 유저가 접속했을 경우 다른 소켓에게도 알려줌 */ | 94 | /* 새로운 유저가 접속했을 경우 다른 소켓에게도 알려줌 */ |
86 | socket.on('newUser', function(name) { | 95 | socket.on('newUser', function(name) { |
87 | - console.log(name + ' 님이 접속하였습니다.') | 96 | + console.log(logString + name + ' 님이 접속하였습니다.') |
88 | 97 | ||
89 | /* 소켓에 이름 저장해두기 */ | 98 | /* 소켓에 이름 저장해두기 */ |
90 | socket.name = name | 99 | socket.name = name |
... | @@ -106,7 +115,7 @@ io.sockets.on('connection', function(socket) { | ... | @@ -106,7 +115,7 @@ io.sockets.on('connection', function(socket) { |
106 | 115 | ||
107 | /* 접속 종료 */ | 116 | /* 접속 종료 */ |
108 | socket.on('disconnect', function() { | 117 | socket.on('disconnect', function() { |
109 | - console.log(socket.name + '님이 나가셨습니다.') | 118 | + console.log(logString+socket.name + '님이 나가셨습니다.') |
110 | 119 | ||
111 | /* 나가는 사람을 제외한 나머지 유저에게 메시지 전송 */ | 120 | /* 나가는 사람을 제외한 나머지 유저에게 메시지 전송 */ |
112 | socket.broadcast.emit('update', {type: 'disconnect', name: 'SERVER', message: socket.name + '님이 나가셨습니다.'}); | 121 | socket.broadcast.emit('update', {type: 'disconnect', name: 'SERVER', message: socket.name + '님이 나가셨습니다.'}); | ... | ... |
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> |
6 | <meta name="description" content="" /> | 6 | <meta name="description" content="" /> |
7 | <meta name="author" content="" /> | 7 | <meta name="author" content="" /> |
8 | - <title>묵호 - 놀이터</title> | 8 | + <title>묵호 - About</title> |
9 | <!-- Favicon--> | 9 | <!-- Favicon--> |
10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> | 10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> |
11 | <!-- Bootstrap icons--> | 11 | <!-- Bootstrap icons--> | ... | ... |
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> |
6 | <meta name="description" content="" /> | 6 | <meta name="description" content="" /> |
7 | <meta name="author" content="" /> | 7 | <meta name="author" content="" /> |
8 | - <title>묵호 - 놀이터</title> | 8 | + <title>묵호 - 게시판</title> |
9 | <!-- Favicon--> | 9 | <!-- Favicon--> |
10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> | 10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> |
11 | <!-- Bootstrap icons--> | 11 | <!-- Bootstrap icons--> | ... | ... |
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> |
6 | <meta name="description" content="" /> | 6 | <meta name="description" content="" /> |
7 | <meta name="author" content="" /> | 7 | <meta name="author" content="" /> |
8 | - <title>묵호 - 놀이터</title> | 8 | + <title>묵호 - 로그인</title> |
9 | <!-- Favicon--> | 9 | <!-- Favicon--> |
10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> | 10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> |
11 | <!-- Bootstrap icons--> | 11 | <!-- Bootstrap icons--> | ... | ... |
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> |
6 | <meta name="description" content="" /> | 6 | <meta name="description" content="" /> |
7 | <meta name="author" content="" /> | 7 | <meta name="author" content="" /> |
8 | - <title>묵호 - 놀이터</title> | 8 | + <title>묵호 - 회원가입</title> |
9 | <!-- Favicon--> | 9 | <!-- Favicon--> |
10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> | 10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> |
11 | <!-- Bootstrap icons--> | 11 | <!-- Bootstrap icons--> | ... | ... |
... | @@ -60,14 +60,10 @@ create table board( | ... | @@ -60,14 +60,10 @@ create table board( |
60 | >UPDATE board SET idx = @COUNT:=@COUNT+1; | 60 | >UPDATE board SET idx = @COUNT:=@COUNT+1; |
61 | 61 | ||
62 | --- | 62 | --- |
63 | -### 최종 수정: 2021-11-20 21:44<br> | 63 | +### 최종 수정: 2021-11-23 01:48<br> |
64 | ### 수정 내용: | 64 | ### 수정 내용: |
65 | -1. 최근 있었던 DB명세구조 변경 | 65 | +0. 채팅기능에 버그가 있는 것 같음-피드백 바람(undefined님이 나가셨습니다. -> 콘솔에 계속 출력됨) |
66 | ->alter table board drop passwd;<br> | 66 | +1. 일부 수정 |
67 | ->alter table board add ID varchar(20) not null;<br> | ||
68 | ->alter table board change name nickname;<br> | ||
69 | ->alter table board modify nickname varchar(20); | ||
70 | - | ||
71 | 2. 로그에 시간 추가 | 67 | 2. 로그에 시간 추가 |
72 | 3. 시간 실시간 반영 | 68 | 3. 시간 실시간 반영 |
73 | 4. 게시글 수정 및 삭제 세션+권한 연동/DB수정 | 69 | 4. 게시글 수정 및 삭제 세션+권한 연동/DB수정 |
... | @@ -75,4 +71,3 @@ create table board( | ... | @@ -75,4 +71,3 @@ create table board( |
75 | 6. 게시글 조회수 구현 | 71 | 6. 게시글 조회수 구현 |
76 | 7. 프로필 수정 세션 연동 | 72 | 7. 프로필 수정 세션 연동 |
77 | 8. etc | 73 | 8. etc |
... | \ No newline at end of file | ... | \ No newline at end of file |
78 | - | ... | ... |
... | @@ -5,11 +5,35 @@ var path = require('path') // 상대경로 | ... | @@ -5,11 +5,35 @@ var path = require('path') // 상대경로 |
5 | var mysql_odbc = require('../../db/db_board')(); | 5 | var mysql_odbc = require('../../db/db_board')(); |
6 | var myinfo = mysql_odbc.init(); | 6 | var myinfo = mysql_odbc.init(); |
7 | 7 | ||
8 | +// 로그용 | ||
9 | +var logString; | ||
10 | +function getTime(){ | ||
11 | + var today = new Date(); | ||
12 | + var year = today.getFullYear(); | ||
13 | + var month = ('0' + (today.getMonth()+1)).slice(-2); | ||
14 | + var day = ('0' + today.getDate()).slice(-2); | ||
15 | + var hour = ('0' + today.getHours()).slice(-2); | ||
16 | + var minute = ('0' + today.getMinutes()).slice(-2); | ||
17 | + var second = ('0' + today.getSeconds()).slice(-2); | ||
18 | + logString = '['+year+'-'+month+'-'+day+' '+hour+':'+minute+':'+second+'] '; | ||
19 | +} | ||
20 | +// 시간 갱신용 | ||
21 | +function init(){ | ||
22 | + getTime(); | ||
23 | + setInterval(getTime, 1000) | ||
24 | +} | ||
25 | +init() | ||
26 | + | ||
8 | router.get('/', function(req, res){ | 27 | router.get('/', function(req, res){ |
9 | var id = req.user; | 28 | var id = req.user; |
10 | - if(!id) res.sendFile(path.join(__dirname, "../../public/login.html")) | 29 | + if(!id){ |
30 | + console.log(logString+'익명 유저의 채팅 접근을 거부했습니다.') | ||
31 | + res.sendFile(path.join(__dirname, "../../public/login.html")) | ||
32 | + } | ||
11 | if(id){ | 33 | if(id){ |
12 | - res.render('chat.ejs', {'nickname':id.nickname}) | 34 | + var nickname = req.user.nickname |
35 | + console.log(logString+req.user.ID+'('+nickname+') 유저가 채팅 중입니다.') | ||
36 | + res.render('chat.ejs', {'nickname':nickname}) | ||
13 | } | 37 | } |
14 | }); | 38 | }); |
15 | 39 | ... | ... |
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> |
6 | <meta name="description" content="" /> | 6 | <meta name="description" content="" /> |
7 | <meta name="author" content="" /> | 7 | <meta name="author" content="" /> |
8 | - <title>묵호 - 놀이터</title> | 8 | + <title>묵호 - About</title> |
9 | <!-- Favicon--> | 9 | <!-- Favicon--> |
10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> | 10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> |
11 | <!-- Bootstrap icons--> | 11 | <!-- Bootstrap icons--> | ... | ... |
... | @@ -2,7 +2,7 @@ | ... | @@ -2,7 +2,7 @@ |
2 | <html> | 2 | <html> |
3 | <head> | 3 | <head> |
4 | <meta charset="utf-8"> | 4 | <meta charset="utf-8"> |
5 | - <title>채팅</title> | 5 | + <title>묵호 - 놀이터</title> |
6 | <link rel="stylesheet" href="/css/chat.css"> | 6 | <link rel="stylesheet" href="/css/chat.css"> |
7 | <script src="/socket.io/socket.io.js"></script> | 7 | <script src="/socket.io/socket.io.js"></script> |
8 | <script src="/js/chat.js"></script> | 8 | <script src="/js/chat.js"></script> | ... | ... |
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> |
6 | <meta name="description" content="" /> | 6 | <meta name="description" content="" /> |
7 | <meta name="author" content="" /> | 7 | <meta name="author" content="" /> |
8 | - <title>묵호 - 놀이터</title> | 8 | + <title>묵호 - 게시판</title> |
9 | <!-- Favicon--> | 9 | <!-- Favicon--> |
10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> | 10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> |
11 | <!-- Bootstrap icons--> | 11 | <!-- Bootstrap icons--> | ... | ... |
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> |
6 | <meta name="description" content="" /> | 6 | <meta name="description" content="" /> |
7 | <meta name="author" content="" /> | 7 | <meta name="author" content="" /> |
8 | - <title>묵호 - 놀이터</title> | 8 | + <title>묵호 - 로그인</title> |
9 | <!-- Favicon--> | 9 | <!-- Favicon--> |
10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> | 10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> |
11 | <!-- Bootstrap icons--> | 11 | <!-- Bootstrap icons--> | ... | ... |
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> |
6 | <meta name="description" content="" /> | 6 | <meta name="description" content="" /> |
7 | <meta name="author" content="" /> | 7 | <meta name="author" content="" /> |
8 | - <title>내 정보</title> | 8 | + <title>묵호 - 내 정보</title> |
9 | <!-- Favicon--> | 9 | <!-- Favicon--> |
10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> | 10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> |
11 | <!-- Bootstrap icons--> | 11 | <!-- Bootstrap icons--> | ... | ... |
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> |
6 | <meta name="description" content="" /> | 6 | <meta name="description" content="" /> |
7 | <meta name="author" content="" /> | 7 | <meta name="author" content="" /> |
8 | - <title>정보 수정</title> | 8 | + <title>묵호 - 내 정보 수정</title> |
9 | <!-- Favicon--> | 9 | <!-- Favicon--> |
10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> | 10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> |
11 | <!-- Bootstrap icons--> | 11 | <!-- Bootstrap icons--> | ... | ... |
1 | <!DOCTYPE html> | 1 | <!DOCTYPE html> |
2 | <html> | 2 | <html> |
3 | <head> | 3 | <head> |
4 | - <title>묵호 - 놀이터</title> | 4 | + <title>묵호 - <%= row.title %></title> |
5 | <!-- Favicon--> | 5 | <!-- Favicon--> |
6 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> | 6 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> |
7 | <!-- Bootstrap icons--> | 7 | <!-- Bootstrap icons--> | ... | ... |
... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | 5 | <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> |
6 | <meta name="description" content="" /> | 6 | <meta name="description" content="" /> |
7 | <meta name="author" content="" /> | 7 | <meta name="author" content="" /> |
8 | - <title>묵호 - 놀이터</title> | 8 | + <title>묵호 - 회원가입</title> |
9 | <!-- Favicon--> | 9 | <!-- Favicon--> |
10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> | 10 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> |
11 | <!-- Bootstrap icons--> | 11 | <!-- Bootstrap icons--> | ... | ... |
1 | <!DOCTYPE html> | 1 | <!DOCTYPE html> |
2 | <html> | 2 | <html> |
3 | <head> | 3 | <head> |
4 | - <title>묵호 - 놀이터</title> | 4 | + <title>묵호 - 글쓰기</title> |
5 | <!-- Favicon--> | 5 | <!-- Favicon--> |
6 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> | 6 | <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> |
7 | <!-- Bootstrap icons--> | 7 | <!-- Bootstrap icons--> | ... | ... |
-
Please register or login to post a comment