Showing
18 changed files
with
138 additions
and
98 deletions
assets/img/1637811003566__titleData.txt
0 → 100644
This diff could not be displayed because it is too large.
assets/img/1637811317443__아이즈원 김채원.jpeg
0 → 100644

49.1 KB
assets/img/1637811397226__아이즈원 김채원.jpeg
0 → 100644

49.1 KB
assets/img/1637811451785__아이즈원 김채원.jpeg
0 → 100644

49.1 KB
assets/img/1637811867223__아이즈원 김채원.jpeg
0 → 100644

49.1 KB
assets/img/1637811938917__아이즈원 김채원.jpeg
0 → 100644

49.1 KB
assets/img/1637812900298__아이즈원 김채원.jpeg
0 → 100644

49.1 KB
assets/img/1637813650214__아이즈원 김채원.jpeg
0 → 100644

49.1 KB
assets/img/1637813866064__아이즈원 김채원.jpeg
0 → 100644

49.1 KB
assets/img/1637814184588__아이즈원 김채원.jpeg
0 → 100644

49.1 KB
assets/img/1637814388184__아이즈원 김채원.jpeg
0 → 100644

49.1 KB
assets/img/1637814418953__아이즈원 김채원.jpeg
0 → 100644

49.1 KB
assets/img/1637814470972__아이즈원 김채원.jpeg
0 → 100644

49.1 KB
... | @@ -61,17 +61,16 @@ create table board( | ... | @@ -61,17 +61,16 @@ create table board( |
61 | >UPDATE board SET idx = @COUNT:=@COUNT+1; | 61 | >UPDATE board SET idx = @COUNT:=@COUNT+1; |
62 | 62 | ||
63 | --- | 63 | --- |
64 | -### 최종 수정: 2021-11-24 04:54<br> | 64 | +### 최종 수정: 2021-11-25 14:00<br> |
65 | ### 수정 내용: | 65 | ### 수정 내용: |
66 | -0. 채팅기능에 버그가 있는 것 같음-피드백 바람(undefined님이 나가셨습니다. -> 콘솔에 계속 출력됨) // socket.io의 express-session 호환 문제로 후순위 개발로 미룸 | ||
67 | -1. 로그에 IP 추가 | ||
68 | -2. 로그에 시간 추가 | ||
69 | -3. 시간 실시간 반영 | ||
70 | -4. 게시글 수정 및 삭제 세션+권한 연동/DB수정 | ||
71 | -5. 버그 수정 | ||
72 | -6. 게시글 조회수 구현 | ||
73 | -7. 프로필 수정 세션 연동 | ||
74 | -8. 프로필 사진 추가 | ||
75 | -9. 프로필 검색 추가 | ||
76 | -10. 프로필 비주얼 업데이트 | ||
77 | -11. etc | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
66 | +0. 채팅기능에 버그가 있는 것 같음(undefined님이 나가셨습니다. -> 콘솔에 계속 출력됨) // socket.io의 express-session 호환 문제로 후순위 개발로 미룸 | ||
67 | +1. 로그에 시간/IP 추가 | ||
68 | +2. 시간 실시간 반영 | ||
69 | +3. 게시글 수정 및 삭제 세션+권한 연동/DB수정 | ||
70 | +4. 버그 수정 | ||
71 | +5. 게시글 조회수 구현 | ||
72 | +6. 프로필 수정 세션 연동 | ||
73 | +7. 프로필 사진 추가 | ||
74 | +8. 프로필 검색 추가 | ||
75 | +9. 프로필 비주얼 업데이트 | ||
76 | +10. 코드 다듬음 | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -73,53 +73,64 @@ router.get('/', function(req, res){ | ... | @@ -73,53 +73,64 @@ router.get('/', function(req, res){ |
73 | }else{ | 73 | }else{ |
74 | var profilepic = "../assets/img/noneprofilepic.png"; | 74 | var profilepic = "../assets/img/noneprofilepic.png"; |
75 | } | 75 | } |
76 | - console.log(profilepic) | ||
77 | console.log(logString+req.user.ID+'('+nickname+') 유저가 프로필을 보고있습니다.('+ip+')') | 76 | console.log(logString+req.user.ID+'('+nickname+') 유저가 프로필을 보고있습니다.('+ip+')') |
78 | res.render('profile.ejs', {'ID':id, 'nickname':nickname, 'profnickname': nickname, 'type': type, 'profilemsg': profilemsg, 'profilepic':profilepic}) | 77 | res.render('profile.ejs', {'ID':id, 'nickname':nickname, 'profnickname': nickname, 'type': type, 'profilemsg': profilemsg, 'profilepic':profilepic}) |
79 | }) | 78 | }) |
80 | } | 79 | } |
81 | catch{ | 80 | catch{ |
82 | - console.log(logString+'익명 유저의 프로필 접근 시도를 거부했습니다.('+ip+')') | 81 | + if(!id){ |
83 | - res.sendFile(path.join(__dirname, "../../public/login.html")) | 82 | + console.log(logString+'익명 유저의 프로필 접근 시도를 거부했습니다.('+ip+')') |
83 | + res.sendFile(path.join(__dirname, "../../public/login.html")) | ||
84 | + } | ||
84 | } | 85 | } |
85 | 86 | ||
86 | }); | 87 | }); |
87 | 88 | ||
88 | router.post('/', function(req,res){ | 89 | router.post('/', function(req,res){ |
89 | - var searNick; | ||
90 | - searNick = req.body.search; | ||
91 | var ip = requestIp.getClientIp(req); | 90 | var ip = requestIp.getClientIp(req); |
91 | + try{ | ||
92 | + var id = req.user.ID; | ||
93 | + var searNick; | ||
94 | + searNick = req.body.search; | ||
92 | 95 | ||
93 | - var sql = 'select * from userdb where nickname="'+req.body.search+'"'; | 96 | + var sql = 'select * from userdb where nickname="'+req.body.search+'"'; |
94 | 97 | ||
95 | - myinfo.query(sql, function(err,rows) { | 98 | + myinfo.query(sql, function(err,rows) { |
96 | - if (err) console.error("err : " + err); | 99 | + if (err) console.error("err : " + err); |
97 | - if (rows.length != 0){ | 100 | + if (rows.length != 0){ |
98 | - var id = req.user.ID; | 101 | + var id = req.user.ID; |
99 | - var nickname = req.user.nickname; | 102 | + var nickname = req.user.nickname; |
100 | - var type = rows[0].type; | 103 | + var type = rows[0].type; |
101 | - var profilemsg = rows[0].profilemsg; | 104 | + var profilemsg = rows[0].profilemsg; |
102 | - var profnickname = rows[0].nickname; | 105 | + var profnickname = rows[0].nickname; |
103 | - if(rows[0].profilepic){ | 106 | + if(rows[0].profilepic){ |
104 | - var profilepic = "../assets/img/"+rows[0].profilepic; | 107 | + var profilepic = "../assets/img/"+rows[0].profilepic; |
105 | - }else{ | 108 | + }else{ |
106 | - var profilepic = "../assets/img/noneprofilepic.png"; | 109 | + var profilepic = "../assets/img/noneprofilepic.png"; |
110 | + } | ||
111 | + console.log(type) | ||
112 | + console.log(logString+req.user.ID+'('+nickname+') 유저가 프로필 열람 중입니다.('+ip+')') | ||
113 | + res.render('other_profile.ejs', {'ID':id, 'nickname': nickname, 'type':type, 'profilemsg': profilemsg, 'message':'', 'profnickname': profnickname, 'profilepic':profilepic}); | ||
107 | } | 114 | } |
108 | - console.log(type) | 115 | + else { |
109 | - console.log(logString+req.user.ID+'('+nickname+') 유저가 프로필 열람 중입니다.('+ip+')') | 116 | + var id = req.user.ID; |
110 | - res.render('other_profile.ejs', {'ID':id, 'nickname': nickname, 'type':type, 'profilemsg': profilemsg, 'message':'', 'profnickname': profnickname, 'profilepic':profilepic}); | 117 | + var nickname = req.user.nickname; |
111 | - } | 118 | + var profnickname = req.body.profnickname; |
112 | - else { | 119 | + var type = req.body.type; |
113 | - var id = req.user.ID; | 120 | + var profilemsg = req.body.profilemsg |
114 | - var nickname = req.user.nickname; | 121 | + var profilepic = req.body.profilepic |
115 | - var profnickname = req.body.profnickname; | ||
116 | - var type = req.body.type; | ||
117 | - var profilemsg = req.body.profilemsg | ||
118 | - var profilepic = req.body.profilepic | ||
119 | 122 | ||
120 | - res.render('other_profile.ejs', {'ID':id, 'nickname': nickname, 'profnickname': profnickname, 'type': type, 'profilemsg': profilemsg, 'message':'해당 유저를 찾을 수 없습니다', 'profilepic':profilepic}) | 123 | + console.log(logString+req.user.ID+'('+nickname+') 유저가 프로필 검색에 실패했습니다.(시도 닉네임: req.body.search // '+ip+')') |
124 | + res.render('other_profile.ejs', {'ID':id, 'nickname': nickname, 'profnickname': profnickname, 'type': type, 'profilemsg': profilemsg, 'message':'해당 유저를 찾을 수 없습니다', 'profilepic':profilepic}) | ||
125 | + } | ||
126 | + }) | ||
127 | + } | ||
128 | + catch{ | ||
129 | + if(!id){ | ||
130 | + console.log(logString+'익명 유저의 프로필 검색 시도를 거부했습니다.('+ip+')') | ||
131 | + res.sendFile(path.join(__dirname, "../../public/login.html")) | ||
121 | } | 132 | } |
122 | - }) | 133 | + } |
123 | }) | 134 | }) |
124 | 135 | ||
125 | router.get('/update', function(req,res){ | 136 | router.get('/update', function(req,res){ |
... | @@ -153,71 +164,102 @@ router.get('/update', function(req,res){ | ... | @@ -153,71 +164,102 @@ router.get('/update', function(req,res){ |
153 | 164 | ||
154 | router.post('/update', function(req,res,next){ | 165 | router.post('/update', function(req,res,next){ |
155 | var ip = requestIp.getClientIp(req); | 166 | var ip = requestIp.getClientIp(req); |
156 | - var id = req.user.ID; | 167 | + try{ |
157 | - var profilemsg = req.body.profilemsg; | 168 | + var id = req.user.ID; |
158 | - var nickname = req.body.nickname; | 169 | + var profilemsg = req.body.profilemsg; |
159 | - var type = req.body.type; | 170 | + var nickname = req.body.nickname; |
160 | - var datas = [profilemsg, nickname, type, id] | 171 | + var type = req.body.type; |
161 | - | 172 | + var datas = [profilemsg, nickname, type, id] |
162 | - // 기존 type과 profile만 추출하기 위한 쿼리 | 173 | + |
163 | - var oldType; | 174 | + // 기존 type과 profile만 추출하기 위한 쿼리 |
164 | - var oldProfilemsg; | 175 | + var oldType; |
165 | - | 176 | + var oldProfilemsg; |
166 | - var subsql = 'select * from userdb where ID="'+id+'"'; | 177 | + |
167 | - myinfo.query(subsql, function(err, result){ | 178 | + var subsql = 'select * from userdb where ID="'+id+'"'; |
168 | - if(err) console.error(err) | 179 | + myinfo.query(subsql, function(err, result){ |
169 | - | 180 | + if(err) console.error(err) |
170 | - oldType = result[0].type; | 181 | + |
171 | - oldProfilemsg = result[0].profilemsg; | 182 | + oldType = result[0].type; |
172 | - }) | 183 | + oldProfilemsg = result[0].profilemsg; |
173 | - | 184 | + }) |
174 | - // 닉네임 중복 거르기 | 185 | + |
175 | - var sql_ = 'select * from userdb where nickname="'+nickname+'"'; | 186 | + // 닉네임 중복 거르기 |
176 | - myinfo.query(sql_, function(err, result){ | 187 | + var sql_ = 'select * from userdb where nickname="'+nickname+'"'; |
177 | - if(err) console.error(err) | 188 | + myinfo.query(sql_, function(err, result){ |
178 | - // 변경하려는 닉네임이 중복이 아닌 경우 or 닉네임 변경이 없는 수정 | 189 | + if(err) console.error(err) |
179 | - if(!result.length || (result.length && req.user.ID == result[0].ID)){ | 190 | + // 변경하려는 닉네임이 중복이 아닌 경우 or 닉네임 변경이 없는 수정 |
180 | - // 운영자인 경우 타입을 변경시키지 않고 고정 | 191 | + if(!result.length || (result.length && req.user.ID == result[0].ID)){ |
181 | - if(oldType == '운영자'){ | 192 | + // 운영자인 경우 타입을 변경시키지 않고 고정 |
182 | - type = '운영자' | 193 | + if(oldType == '운영자'){ |
183 | - datas[2] = '운영자'; | 194 | + type = '운영자' |
195 | + datas[2] = '운영자'; | ||
196 | + } | ||
197 | + | ||
198 | + var sql = "update userdb set profilemsg =?, nickname=?, type=? where id =?" | ||
199 | + myinfo.query(sql,datas,function(err,result){ | ||
200 | + if(err) console.error(err) | ||
201 | + | ||
202 | + console.log(logString+req.user.ID+'('+req.session.passport.user.nickname+') 유저가 프로필을 수정했습니다.('+ip+')') | ||
203 | + console.log(" ▷ 변경전: "+id+"("+req.user.nickname+") "+oldType+" // "+oldProfilemsg) | ||
204 | + req.session.passport.user.nickname = nickname; | ||
205 | + console.log(" ▶ 변경후: "+id+"("+nickname+") "+type+" // "+profilemsg) | ||
206 | + res.redirect('/profile'); | ||
207 | + }) | ||
184 | } | 208 | } |
185 | - | 209 | + else{ // 다른 유저의 닉네임과 중복되는 경우 |
186 | - var sql = "update userdb set profilemsg =?, nickname=?, type=? where id =?" | 210 | + console.log(logString+id+" 유저가 중복된 닉네임으로 변경을 시도했습니다.(시도한 닉네임: "+req.body.nickname+" // ("+ip+')') |
187 | - myinfo.query(sql,datas,function(err,result){ | 211 | + res.render('profmsgedit.ejs', {nickname: req.session.passport.user.nickname, profilemsg: oldProfilemsg, message : '중복된 닉네임입니다.'}) |
188 | - if(err) console.error(err) | 212 | + } |
189 | - | 213 | + }) |
190 | - console.log(logString+req.user.ID+'('+req.session.passport.user.nickname+') 유저가 프로필을 수정했습니다.('+ip+')') | 214 | + } |
191 | - console.log(" ▷ 변경전: "+id+"("+req.user.nickname+") "+oldType+" // "+oldProfilemsg) | 215 | + catch{ |
192 | - req.session.passport.user.nickname = nickname; | 216 | + if(!id){ |
193 | - console.log(" ▶ 변경후: "+id+"("+nickname+") "+type+" // "+profilemsg) | 217 | + console.log(logString+'익명 유저의 프로필 수정 시도를 거부했습니다.('+ip+')') |
194 | - res.redirect('/profile'); | 218 | + res.sendFile(path.join(__dirname, "../../public/login.html")) |
195 | - }) | ||
196 | - } | ||
197 | - else{ // 다른 유저의 닉네임과 중복되는 경우 | ||
198 | - console.log(logString+id+" 유저가 중복된 닉네임으로 변경을 시도했습니다.(시도한 닉네임: "+req.body.nickname+" // ("+ip+')') | ||
199 | - res.render('profmsgedit.ejs', {nickname: req.session.passport.user.nickname, profilemsg: oldProfilemsg, message : '중복된 닉네임입니다.'}) | ||
200 | } | 219 | } |
201 | - }) | 220 | + } |
202 | }) | 221 | }) |
203 | 222 | ||
204 | router.get('/upload', function(req,res){ | 223 | router.get('/upload', function(req,res){ |
205 | - res.render('uploadprof.ejs') | 224 | + var ip = requestIp.getClientIp(req); |
225 | + try{ | ||
226 | + var id = req.user.ID; | ||
227 | + if(id) res.render('uploadprof.ejs') | ||
228 | + } | ||
229 | + catch{ | ||
230 | + if(!id){ | ||
231 | + console.log(logString+'익명 유저의 프로필 사진 업로드 접근 시도를 거부했습니다.('+ip+')') | ||
232 | + res.send("<script>alert('로그인이 필요합니다.');opener.location.href='/login';window.close();</script>"); | ||
233 | + } | ||
234 | + } | ||
206 | }) | 235 | }) |
207 | 236 | ||
208 | router.post('/upload', upload.single('userfile'), function(req,res){ | 237 | router.post('/upload', upload.single('userfile'), function(req,res){ |
209 | - var id = req.user.ID; | ||
210 | var ip = requestIp.getClientIp(req); | 238 | var ip = requestIp.getClientIp(req); |
211 | - var profilepic = req.file.filename; | 239 | + try{ |
212 | - console.log(profilepic) | 240 | + var id = req.user.ID; |
213 | - var datas = [profilepic, id] | 241 | + var ip = requestIp.getClientIp(req); |
242 | + var profilepic = req.file.filename; | ||
243 | + var datas = [profilepic, id] | ||
214 | 244 | ||
215 | - var sql = "update userdb set profilepic =? where id =?" | 245 | + var picName = profilepic.substr(15) |
246 | + var sql = "update userdb set profilepic =? where id =?" | ||
216 | myinfo.query(sql,datas,function(err,result){ | 247 | myinfo.query(sql,datas,function(err,result){ |
217 | if(err) console.error(err) | 248 | if(err) console.error(err) |
218 | - console.log(logString+req.user.ID+'('+req.user.nickname+') 유저가 프로필 사진을 업로드했습니다.('+ip+')') | 249 | + console.log(logString+req.user.ID+'('+req.user.nickname+') 유저가 프로필 사진을 업로드했습니다.(파일명: '+picName+' // '+ip+')') |
219 | - res.send('업로드 성공!: '+req.file); | 250 | + res.send("<script>alert('업로드가 완료되었습니다.');window.close();</script>"); |
220 | }) | 251 | }) |
252 | + } | ||
253 | + catch{ | ||
254 | + if(!id){ | ||
255 | + console.log(logString+'익명 유저의 프로필 사진 업로드 시도를 거부했습니다.('+ip+')') | ||
256 | + res.sendFile(path.join(__dirname, "../../public/login.html")) | ||
257 | + } | ||
258 | + else{ | ||
259 | + console.log(logString+req.user.ID+'('+req.user.nickname+') 유저가 파일 업로드 없이 업로드를 시도했습니다.('+ip+')') | ||
260 | + res.send("<script>alert('파일을 업로드 해주세요.');history.back();</script>"); | ||
261 | + } | ||
262 | + } | ||
221 | }) | 263 | }) |
222 | 264 | ||
223 | 265 | ||
... | @@ -230,7 +272,6 @@ function popup(){ | ... | @@ -230,7 +272,6 @@ function popup(){ |
230 | 272 | ||
231 | function enterkey() { | 273 | function enterkey() { |
232 | if (window.event.keyCode == 13) { | 274 | if (window.event.keyCode == 13) { |
233 | - | ||
234 | // 엔터키가 눌렸을 때 실행할 내용 | 275 | // 엔터키가 눌렸을 때 실행할 내용 |
235 | send(); | 276 | send(); |
236 | } | 277 | } | ... | ... |
... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
4 | <meta charset="UTF-8"> | 4 | <meta charset="UTF-8"> |
5 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> | 5 | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
6 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | 6 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
7 | - <title>파일 업로드</title> | 7 | + <title>묵호 - 프로필 사진 업로드</title> |
8 | </head> | 8 | </head> |
9 | <body> | 9 | <body> |
10 | <form action = 'upload' method = 'post' enctype="multipart/form-data"> | 10 | <form action = 'upload' method = 'post' enctype="multipart/form-data"> | ... | ... |
-
Please register or login to post a comment