Mukho

Divide board

1 module.exports=(function(){ 1 module.exports=(function(){
2 return{ 2 return{
3 - board:{ 3 + notice_board:{
4 + host:'localhost',
5 + port:3306,
6 + user:'root',
7 + password:'',
8 + database:'singer_composer'
9 + },
10 + composer_board:{
11 + host:'localhost',
12 + port:3306,
13 + user:'root',
14 + password:'',
15 + database:'singer_composer'
16 + },
17 + singer_board:{
18 + host:'localhost',
19 + port:3306,
20 + user:'root',
21 + password:'',
22 + database:'singer_composer'
23 + },
24 + free_board:{
25 + host:'localhost',
26 + port:3306,
27 + user:'root',
28 + password:'',
29 + database:'singer_composer'
30 + },
31 + suggestion_board:{
4 host:'localhost', 32 host:'localhost',
5 port:3306, 33 port:3306,
6 user:'root', 34 user:'root',
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
22 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 22 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
25 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 25 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
26 <li><a href="/chat" class="nav-link px-2 link-dark">채팅</a></li> 26 <li><a href="/chat" class="nav-link px-2 link-dark">채팅</a></li>
27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
28 </ul> 28 </ul>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
22 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 22 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
25 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 25 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
26 <li><a href="/chat" class="nav-link px-2 link-dark">채팅</a></li> 26 <li><a href="/chat" class="nav-link px-2 link-dark">채팅</a></li>
27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
28 </ul> 28 </ul>
...@@ -32,6 +32,24 @@ ...@@ -32,6 +32,24 @@
32 </div> 32 </div>
33 </div> 33 </div>
34 </nav> 34 </nav>
35 + <div class ="wrap">
36 + <div class="list_board">
37 + <a class="board_btn" href="/board/list/notice">
38 + 공지사항
39 + </a>
40 + <a class="board_btn" href="/board/list/composer">
41 + 작곡가 구인
42 + </a>
43 + <a class="board_btn" href="/board/list/singer">
44 + 가수 구인
45 + </a>
46 + <a class="board_btn" href="/board/list/free">
47 + 자유게시판
48 + </a>
49 + <a class="board_btn" href="/board/list/suggestion">
50 + 건의사항
51 + </a>
52 + </div>
35 <!-- Footer--> 53 <!-- Footer-->
36 <footer class="footer bg-light"> 54 <footer class="footer bg-light">
37 <div class="container"> 55 <div class="container">
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
21 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 21 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
22 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 22 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
23 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 23 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
24 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 24 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
25 <li><a href="/chat" class="nav-link px-2 link-dark">채팅</a></li> 25 <li><a href="/chat" class="nav-link px-2 link-dark">채팅</a></li>
26 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 26 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
27 </ul> 27 </ul>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
22 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 22 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
25 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 25 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
26 <li><a href="/chat" class="nav-link px-2 link-dark">채팅</a></li> 26 <li><a href="/chat" class="nav-link px-2 link-dark">채팅</a></li>
27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
28 </ul> 28 </ul>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
22 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 22 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
25 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 25 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
26 <li><a href="/chat" class="nav-link px-2 link-dark">채팅</a></li> 26 <li><a href="/chat" class="nav-link px-2 link-dark">채팅</a></li>
27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
28 </ul> 28 </ul>
......
...@@ -36,7 +36,7 @@ create table userdb( ...@@ -36,7 +36,7 @@ create table userdb(
36 profilepic varchar(300) unique 36 profilepic varchar(300) unique
37 )engine=innodb; 37 )engine=innodb;
38 38
39 -create table board( 39 +create table _board(
40 idx int not null primary key auto_increment, 40 idx int not null primary key auto_increment,
41 nickname varchar(50) not null, 41 nickname varchar(50) not null,
42 title varchar(50) not null, 42 title varchar(50) not null,
...@@ -47,13 +47,13 @@ create table board( ...@@ -47,13 +47,13 @@ create table board(
47 ID varchar(20) not null 47 ID varchar(20) not null
48 )engine=innodb; 48 )engine=innodb;
49 49
50 -create table comment( 50 +create table _comment(
51 idx int auto_increment primary key, 51 idx int auto_increment primary key,
52 ID varchar(20) not null, 52 ID varchar(20) not null,
53 nickname varchar(50) not null, 53 nickname varchar(50) not null,
54 comment mediumtext not null, 54 comment mediumtext not null,
55 bulletin_id int not null, 55 bulletin_id int not null,
56 - foreign key (bulletin_id) references board(idx) on delete cascade 56 + foreign key (bulletin_id) references _board(idx) on delete cascade
57 )engine=innodb; 57 )engine=innodb;
58 ``` 58 ```
59 59
...@@ -69,8 +69,15 @@ create table comment( ...@@ -69,8 +69,15 @@ create table comment(
69 >SET @COUNT = 0;<br> 69 >SET @COUNT = 0;<br>
70 >UPDATE board SET idx = @COUNT:=@COUNT+1; 70 >UPDATE board SET idx = @COUNT:=@COUNT+1;
71 71
72 +- 게시판 추가 DB 이름(댓글은 board 대신 comment)
73 +>공지사항: notice_board
74 +>작곡가 구인: composer_board
75 +>가수 구인: singer_board
76 +>자유게시판: free_board
77 +>건의사항: suggestion_board
78 +
72 --- 79 ---
73 -### 최종 수정: 2021-11-29 19:47<br> 80 +### 최종 수정: 2021-12-01 01:22<br>
74 ### 수정 내용: 81 ### 수정 내용:
75 1. 채팅 구현(팝업) 82 1. 채팅 구현(팝업)
76 2. 시간 실시간 반영 83 2. 시간 실시간 반영
...@@ -82,4 +89,5 @@ create table comment( ...@@ -82,4 +89,5 @@ create table comment(
82 8. 버그 수정 89 8. 버그 수정
83 9. 댓글 등록, 열람, 삭제 기능 구현 및 버그 픽스 90 9. 댓글 등록, 열람, 삭제 기능 구현 및 버그 픽스
84 10. 채팅 중 서버 재시작시 기존 참여자들 리셋시킴 91 10. 채팅 중 서버 재시작시 기존 참여자들 리셋시킴
85 -11. 요소 좌우 길이 80%로 조절
...\ No newline at end of file ...\ No newline at end of file
92 +11. 요소 좌우 길이 80%로 조절
93 +12. 게시판 [공지사항/작곡가 구인/가수 구인/자유게시판/건의사항]으로 분화
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -28,53 +28,800 @@ function init(){ ...@@ -28,53 +28,800 @@ function init(){
28 } 28 }
29 init() 29 init()
30 30
31 -router.get('/list/:page', function(req, res, next) { 31 +router.get('/', function(req,res,next){
32 var ip = requestIp.getClientIp(req); 32 var ip = requestIp.getClientIp(req);
33 var id = req.user; 33 var id = req.user;
34 if(!id){ 34 if(!id){
35 - console.log(logString+'익명 유저의 게시판 접근을 거부했습니다.('+ip+')') 35 + console.log(logString+'익명 유저의 공지사항 게시판 접근을 거부했습니다.('+ip+')')
36 - res.redirect('/board/list/1') 36 + res.sendFile(path.join(__dirname, "../../public/login.html"))
37 + }
38 + else res.redirect('/board/list/notice/1')
39 +})
40 +
41 +// 공지사항
42 +router.get('/list/notice/:page', function(req, res, next) {
43 + var ip = requestIp.getClientIp(req);
44 + var id = req.user;
45 + if(!id){
46 + console.log(logString+'익명 유저의 공지사항 게시판 접근을 거부했습니다.('+ip+')')
47 + res.redirect('/board/list/notice/1')
48 + }
49 + else{
50 + var page = req.params.page;
51 + var sql = "select idx, nickname, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
52 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit from notice_board order by idx desc";
53 + board.query(sql, function(err,rows) {
54 + if (err) console.error("err : " + err);
55 + var id = req.user.ID;
56 + var nickname = req.user.nickname;
57 + console.log(logString+req.user.ID+'('+nickname+') 유저가 공지사항 게시판을 보고있습니다.('+ip+')')
58 + res.render('list.ejs', {'ID':id, 'nickname': nickname, title: '공지사항', rows: rows, page:page, length:rows.length-1,page_num:10,pass:true})
59 + })
60 + }
61 +});
62 +
63 +router.get('/notice', function(req,res,next){
64 + var ip = requestIp.getClientIp(req);
65 + var id = req.user;
66 + if(!id){
67 + console.log(logString+'익명 유저의 공지사항 게시판 접근을 거부했습니다.('+ip+')')
68 + res.sendFile(path.join(__dirname, "../../public/login.html"))
69 + }
70 + else res.redirect('/board/list/notice/1')
71 +})
72 +
73 +router.get('/list/notice', function(req,res,next){
74 + var ip = requestIp.getClientIp(req);
75 + var id = req.user;
76 + if(!id){
77 + console.log(logString+'익명 유저의 공지사항 게시판 접근을 거부했습니다.('+ip+')')
78 + res.sendFile(path.join(__dirname, "../../public/login.html"))
79 + }
80 + else res.redirect('/board/list/notice/1')
81 +})
82 +
83 +router.get('/write/notice', function(req,res,next){
84 + var ip = requestIp.getClientIp(req);
85 + var id = req.user;
86 + if(!id){
87 + console.log(logString+'익명 유저의 공지사항 글쓰기 시도를 거부했습니다.('+ip+')')
88 + res.sendFile(path.join(__dirname, "../../public/login.html"))
89 + }
90 + else{
91 + var id = req.user.ID;
92 + var nickname = req.user.nickname;
93 + console.log(logString+req.user.ID+'('+nickname+') 유저가 공지사항 게시글 작성 중입니다.('+ip+')')
94 + res.render('write.ejs', {'ID':id, 'nickname': nickname, title:"공지사항 글 쓰기"})
95 + }
96 +})
97 +
98 +router.post('/write/notice', function(req,res,next){
99 + var ip = requestIp.getClientIp(req);
100 + var nickname = req.user.nickname // var name = req.body.name
101 + var title = req.body.title
102 + var content = req.body.content
103 + var ID = req.user.ID
104 + var datas = [nickname, title, content, ID]
105 +
106 + var sql = "insert into notice_board(nickname, title, content, regdate, modidate, hit, ID) values(?,?,?,now(),now(),0, ?)";
107 + board.query(sql, datas, function (err, rows) {
108 + if (err) console.error("err : " + err);
109 + });
110 +
111 + var idx_;
112 + var sql_ = "select max(idx) as idx from notice_board"
113 + board.query(sql_, function(err, rows){
114 + if(err) console.error("err : " + err);
115 + idx_ = rows[0].idx;
116 +
117 + if(!idx_) // 글이 없으면 NULL
118 + idx_ = 1;
119 +
120 + console.log(logString+req.user.ID+'('+nickname+') 유저가 공지사항 '+idx_+'번 게시글을 작성했습니다.('+ip+')')
121 + res.redirect('/board/read/notice/'+idx_);
122 + });
123 +})
124 +
125 +router.get('/read/notice/:idx', function(req,res,next){
126 + var ip = requestIp.getClientIp(req);
127 +
128 + var idx = req.params.idx
129 + var sql = "select idx, nickname, title, content, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
130 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit, ID from notice_board where idx=?";
131 + board.query(sql, [idx], function(err,row){
132 + if(err) console.error(err)
133 +
134 + var id = req.user;
135 + if(!id){
136 + console.log(logString+'익명 유저의 공지사항 '+idx+'번 게시물 접근을 거부했습니다.('+ip+')')
137 + res.redirect('/login')
138 + }
139 + else{
140 + var id = req.user.ID;
141 + var nickname = req.user.nickname;
142 +
143 + // 조회수 증가
144 + var sql_ = 'update notice_board set hit=hit+1 where idx="'+idx+'"';
145 + board.query(sql_, function(err, row){
146 + if(err) console.error(err)
147 + })
148 +
149 + var sql_comment = "select idx, nickname, comment from notice_comment where bulletin_id =?"
150 + board.query(sql_comment, [idx], function(err,comment){
151 + if (err) console.error("err : " + err);
152 + res.render('read.ejs', {'ID':id, 'nickname': nickname, title:"공지사항 글 상세", row:row[0], comment:comment, comment_length : comment.length, usernick:req.user.nickname})
153 + })
154 + console.log(logString+req.user.ID+'('+nickname+') 유저가 공지사항 '+idx+'번 게시글을 보고있습니다.('+ip+')')
155 + }
156 + })
157 +})
158 +
159 +router.post('/read/notice/commentwrite', function(req,res,next){
160 + var ip = requestIp.getClientIp(req);
161 + var idx = req.body.idx;
162 + var nickname = req.user.nickname // var name = req.body.name
163 + var comment = req.body.comment
164 + var ID = req.user.ID
165 + var datas = [ID, nickname, comment, idx]
166 +
167 + var sql = "insert into notice_comment(ID, nickname, comment, bulletin_id) values(?, ?, ?, ?)"
168 + board.query(sql, datas, function(err,row){
169 + if (err) console.error("err : " + err);
170 + })
171 + console.log(logString+req.user.ID+'('+nickname+') 유저가 공지사항 '+idx+'번 게시물에 댓글을 작성했습니다.('+ip+')')
172 + res.redirect('/board/read/notice/'+idx);
173 +})
174 +
175 +router.post('/read/notice/commentdelete', function(req,res,next){
176 + var ip = requestIp.getClientIp(req);
177 + var idx = req.body.idxcomment;
178 + var idxbulletin = (req.headers.referer).split('/')[6];
179 + var ID = req.user.ID;
180 + var datas = [ID, idx]
181 +
182 + var sql = "delete from notice_comment where ID =? and idx=?"
183 + board.query(sql,datas,function(err,result){
184 + if(err) console.error(err)
185 + // 삭제를 요청한 사용자가 작성자가 아닌 경우
186 + if(result.affectedRows == 0){
187 + // 운영자세요?
188 + var sql_ = 'select type from userdb where ID="'+ID+'"';
189 + board.query(sql_, function(err_, result_){
190 + if(err_) console.error(err_)
191 +
192 + if(result_[0].type == "운영자"){ // 작성자는 아니나 유저 타입이 운영자인 경우
193 + var sqlAdmin = 'delete from notice_comment where idx="'+idx+'"';
194 + board.query(sqlAdmin, function(err__, result__){
195 + if(err__) console.error(err__)
196 +
197 + var nickname = req.user.nickname;
198 + console.log(logString+"[Admin] "+req.user.ID+'('+nickname+') 유저가 공지사항 '+idxbulletin+'번 글에서 '+idx+'번 댓글을 삭제했습니다.('+ip+')')
199 + res.redirect('/board/read/notice/'+idxbulletin)
200 + })
201 + }
202 + else{ // 작성자도, 운영자도 아니면
203 + var nickname = req.user.nickname;
204 + console.log(logString+req.user.ID+'('+nickname+') 유저의 공지사항 '+idxbulletin+'번 글의 '+idx+'번 댓글 삭제를 거부했습니다.(권한없음 // '+ip+')')
205 + res.send("<script>alert('댓글 작성자가 아닙니다');history.back();</script>");
206 + }
207 + })
208 + }
209 + else{ // 작성자인 경우
210 + var nickname = req.user.nickname;
211 + console.log(logString+req.user.ID+'('+nickname+') 유저가 공지사항 '+idxbulletin+'번 글에서 '+idx+'번 댓글을 삭제했습니다.('+ip+')')
212 + res.redirect('/board/read/notice/'+idxbulletin)
213 + }
214 + })
215 +})
216 +
217 +router.post('/update/notice', function(req,res,next){
218 + var ip = requestIp.getClientIp(req);
219 + var ID = req.user.ID;
220 + var idx = req.body.idx
221 + var title = req.body.title
222 + var content = req.body.content
223 + var datas = [title, content, idx, ID]
224 +
225 + var sql = "update notice_board set title=?,content=?,modidate=now() where idx =? and ID=?"
226 + board.query(sql,datas,function(err,result){
227 + if(err) console.error(err)
228 + if(result.affectedRows==0){
229 + console.log(logString+req.user.ID+'('+req.user.nickname+') 유저의 공지사항 '+idx+'번 게시글 수정을 거부했습니다.(권한없음 // '+ip+')')
230 + res.send("<script>alert('게시글 작성자가 아닙니다.');history.back();</script>")
231 + }
232 + else{
233 + var id = req.user.ID;
234 + var nickname = req.user.nickname;
235 + console.log(logString+req.user.ID+'('+nickname+') 유저가 공지사항 '+idx+'번 게시글을 수정했습니다.('+ip+')')
236 + res.redirect('/board/read/notice/'+idx)
237 + }
238 + })
239 +})
240 +
241 +router.post('/delete/notice', function(req,res,next){
242 + var ip = requestIp.getClientIp(req);
243 + var idx = req.body.idx
244 + var ID = req.user.ID;
245 + var datas = [idx,ID]
246 +
247 + var sql = "delete from notice_board where idx=? and ID=?"
248 + board.query(sql,datas, function(err,result){
249 + if(err) console.error(err)
250 + // 삭제를 요청한 사용자가 작성자가 아닌 경우
251 + if(result.affectedRows == 0){
252 + // 운영자세요?
253 + var sql_ = 'select type from userdb where ID="'+ID+'"';
254 + board.query(sql_, function(err_, result_){
255 + if(err_) console.error(err_)
256 +
257 + if(result_[0].type == "운영자"){ // 작성자는 아니나 유저 타입이 운영자인 경우
258 + var sqlAdmin = 'delete from notice_board where idx="'+idx+'"';
259 + board.query(sqlAdmin, function(err__, result__){
260 + if(err__) console.error(err__)
261 +
262 + var nickname = req.user.nickname;
263 + res.send("<script>alert('게시글이 운영자에 의해 삭제되었습니다.');window.location.href='/board/list/notice/';</script>");
264 + console.log(logString+"[Admin] "+req.user.ID+'('+nickname+') 유저가 공지사항 '+idx+'번 게시글을 삭제했습니다.('+ip+')')
265 + })
266 + }
267 + else{ // 작성자도, 운영자도 아니면
268 + var nickname = req.user.nickname;
269 + console.log(logString+req.user.ID+'('+nickname+') 유저의 공지사항 '+idx+'번 게시글 삭제를 거부했습니다.(권한없음 // '+ip+')')
270 + res.send("<script>alert('게시글 작성자가 아닙니다');history.back();</script>");
271 + }
272 + })
273 + }
274 + else{ // 작성자인 경우
275 + var id = req.user.ID;
276 + var nickname = req.user.nickname;
277 + res.send("<script>alert('게시글이 삭제되었습니다.');window.location.href='/board/list/notice/';</script>");
278 + console.log(logString+req.user.ID+'('+nickname+') 유저가 공지사항 '+idx+'번 게시글을 삭제했습니다.('+ip+')')
279 + }
280 + })
281 +})
282 +
283 +// 작곡가 구인
284 +router.get('/list/composer/:page', function(req, res, next) {
285 + var ip = requestIp.getClientIp(req);
286 + var id = req.user;
287 + if(!id){
288 + console.log(logString+'익명 유저의 작곡가 구인 게시판 접근을 거부했습니다.('+ip+')')
289 + res.redirect('/board/list/composer/1')
290 + }
291 + else{
292 + var page = req.params.page;
293 + var sql = "select idx, nickname, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
294 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit from composer_board order by idx desc";
295 + board.query(sql, function(err,rows) {
296 + if (err) console.error("err : " + err);
297 + var id = req.user.ID;
298 + var nickname = req.user.nickname;
299 + console.log(logString+req.user.ID+'('+nickname+') 유저가 작곡가 구인 게시판을 보고있습니다.('+ip+')')
300 + res.render('list.ejs', {'ID':id, 'nickname': nickname, title: '작곡가 구인', rows: rows, page:page, length:rows.length-1,page_num:10,pass:true})
301 + })
302 + }
303 +});
304 +
305 +router.get('/composer', function(req,res,next){
306 + var ip = requestIp.getClientIp(req);
307 + var id = req.user;
308 + if(!id){
309 + console.log(logString+'익명 유저의 작곡가 구인 게시판 접근을 거부했습니다.('+ip+')')
310 + res.sendFile(path.join(__dirname, "../../public/login.html"))
311 + }
312 + else res.redirect('/board/list/composer/1')
313 +})
314 +
315 +router.get('/list/composer', function(req,res,next){
316 + var ip = requestIp.getClientIp(req);
317 + var id = req.user;
318 + if(!id){
319 + console.log(logString+'익명 유저의 작곡가 구인 게시판 접근을 거부했습니다.('+ip+')')
320 + res.sendFile(path.join(__dirname, "../../public/login.html"))
321 + }
322 + else res.redirect('/board/list/composer/1')
323 +})
324 +
325 +router.get('/write/composer', function(req,res,next){
326 + var ip = requestIp.getClientIp(req);
327 + var id = req.user;
328 + if(!id){
329 + console.log(logString+'익명 유저의 작곡가 구인 글쓰기 시도를 거부했습니다.('+ip+')')
330 + res.sendFile(path.join(__dirname, "../../public/login.html"))
331 + }
332 + else{
333 + var id = req.user.ID;
334 + var nickname = req.user.nickname;
335 + console.log(logString+req.user.ID+'('+nickname+') 유저가 작곡가 구인 게시글 작성 중입니다.('+ip+')')
336 + res.render('write.ejs', {'ID':id, 'nickname': nickname, title:"작곡가 구인 글 쓰기"})
337 + }
338 +})
339 +
340 +router.post('/write/composer', function(req,res,next){
341 + var ip = requestIp.getClientIp(req);
342 + var nickname = req.user.nickname // var name = req.body.name
343 + var title = req.body.title
344 + var content = req.body.content
345 + var ID = req.user.ID
346 + var datas = [nickname, title, content, ID]
347 +
348 + var sql = "insert into composer_board(nickname, title, content, regdate, modidate, hit, ID) values(?,?,?,now(),now(),0, ?)";
349 + board.query(sql, datas, function (err, rows) {
350 + if (err) console.error("err : " + err);
351 + });
352 +
353 + var idx_;
354 + var sql_ = "select max(idx) as idx from composer_board"
355 + board.query(sql_, function(err, rows){
356 + if(err) console.error("err : " + err);
357 + idx_ = rows[0].idx;
358 +
359 + if(!idx_) // 글이 없으면 NULL
360 + idx_ = 1;
361 +
362 + console.log(logString+req.user.ID+'('+nickname+') 유저가 작곡가 구인 '+idx_+'번 게시글을 작성했습니다.('+ip+')')
363 + res.redirect('/board/read/composer/'+idx_);
364 + });
365 +})
366 +
367 +router.get('/read/composer/:idx', function(req,res,next){
368 + var ip = requestIp.getClientIp(req);
369 +
370 + var idx = req.params.idx
371 + var sql = "select idx, nickname, title, content, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
372 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit, ID from composer_board where idx=?";
373 + board.query(sql, [idx], function(err,row){
374 + if(err) console.error(err)
375 +
376 + var id = req.user;
377 + if(!id){
378 + console.log(logString+'익명 유저의 작곡가 구인 '+idx+'번 게시물 접근을 거부했습니다.('+ip+')')
379 + res.redirect('/login')
380 + }
381 + else{
382 + var id = req.user.ID;
383 + var nickname = req.user.nickname;
384 +
385 + // 조회수 증가
386 + var sql_ = 'update composer_board set hit=hit+1 where idx="'+idx+'"';
387 + board.query(sql_, function(err, row){
388 + if(err) console.error(err)
389 + })
390 +
391 + var sql_comment = "select idx, nickname, comment from composer_comment where bulletin_id =?"
392 + board.query(sql_comment, [idx], function(err,comment){
393 + if (err) console.error("err : " + err);
394 + res.render('read.ejs', {'ID':id, 'nickname': nickname, title:"작곡가 구인 글 상세", row:row[0], comment:comment, comment_length : comment.length, usernick:req.user.nickname})
395 + })
396 + console.log(logString+req.user.ID+'('+nickname+') 유저가 작곡가 구인 '+idx+'번 게시글을 보고있습니다.('+ip+')')
397 + }
398 + })
399 +})
400 +
401 +router.post('/read/composer/commentwrite', function(req,res,next){
402 + var ip = requestIp.getClientIp(req);
403 + var idx = req.body.idx;
404 + var nickname = req.user.nickname // var name = req.body.name
405 + var comment = req.body.comment
406 + var ID = req.user.ID
407 + var datas = [ID, nickname, comment, idx]
408 +
409 + var sql = "insert into composer_comment(ID, nickname, comment, bulletin_id) values(?, ?, ?, ?)"
410 + board.query(sql, datas, function(err,row){
411 + if (err) console.error("err : " + err);
412 + })
413 + console.log(logString+req.user.ID+'('+nickname+') 유저가 작곡가 구인 '+idx+'번 게시물에 댓글을 작성했습니다.('+ip+')')
414 + res.redirect('/board/read/composer/'+idx);
415 +})
416 +
417 +router.post('/read/composer/commentdelete', function(req,res,next){
418 + var ip = requestIp.getClientIp(req);
419 + var idx = req.body.idxcomment;
420 + var idxbulletin = (req.headers.referer).split('/')[6];
421 + var ID = req.user.ID;
422 + var datas = [ID, idx]
423 +
424 + var sql = "delete from composer_comment where ID =? and idx=?"
425 + board.query(sql,datas,function(err,result){
426 + if(err) console.error(err)
427 + // 삭제를 요청한 사용자가 작성자가 아닌 경우
428 + if(result.affectedRows == 0){
429 + // 운영자세요?
430 + var sql_ = 'select type from userdb where ID="'+ID+'"';
431 + board.query(sql_, function(err_, result_){
432 + if(err_) console.error(err_)
433 +
434 + if(result_[0].type == "운영자"){ // 작성자는 아니나 유저 타입이 운영자인 경우
435 + var sqlAdmin = 'delete from ncomposer_comment where idx="'+idx+'"';
436 + board.query(sqlAdmin, function(err__, result__){
437 + if(err__) console.error(err__)
438 +
439 + var nickname = req.user.nickname;
440 + console.log(logString+"[Admin] "+req.user.ID+'('+nickname+') 유저가 작곡가 구인 '+idxbulletin+'번 글에서 '+idx+'번 댓글을 삭제했습니다.('+ip+')')
441 + res.redirect('/board/read/composer/'+idxbulletin)
442 + })
443 + }
444 + else{ // 작성자도, 운영자도 아니면
445 + var nickname = req.user.nickname;
446 + console.log(logString+req.user.ID+'('+nickname+') 유저의 작곡가 구인 '+idxbulletin+'번 글의 '+idx+'번 댓글 삭제를 거부했습니다.(권한없음 // '+ip+')')
447 + res.send("<script>alert('댓글 작성자가 아닙니다');history.back();</script>");
448 + }
449 + })
450 + }
451 + else{ // 작성자인 경우
452 + var nickname = req.user.nickname;
453 + console.log(logString+req.user.ID+'('+nickname+') 유저가 작곡가 구인 '+idxbulletin+'번 글에서 '+idx+'번 댓글을 삭제했습니다.('+ip+')')
454 + res.redirect('/board/read/composer/'+idxbulletin)
455 + }
456 + })
457 +})
458 +
459 +router.post('/update/composer', function(req,res,next){
460 + var ip = requestIp.getClientIp(req);
461 + var ID = req.user.ID;
462 + var idx = req.body.idx
463 + var title = req.body.title
464 + var content = req.body.content
465 + var datas = [title, content, idx, ID]
466 +
467 + var sql = "update composer_board set title=?,content=?,modidate=now() where idx =? and ID=?"
468 + board.query(sql,datas,function(err,result){
469 + if(err) console.error(err)
470 + if(result.affectedRows==0){
471 + console.log(logString+req.user.ID+'('+req.user.nickname+') 유저의 작곡가 구인 '+idx+'번 게시글 수정을 거부했습니다.(권한없음 // '+ip+')')
472 + res.send("<script>alert('게시글 작성자가 아닙니다.');history.back();</script>")
473 + }
474 + else{
475 + var id = req.user.ID;
476 + var nickname = req.user.nickname;
477 + console.log(logString+req.user.ID+'('+nickname+') 유저가 작곡가 구인 '+idx+'번 게시글을 수정했습니다.('+ip+')')
478 + res.redirect('/board/read/composer/'+idx)
479 + }
480 + })
481 +})
482 +
483 +router.post('/delete/composer', function(req,res,next){
484 + var ip = requestIp.getClientIp(req);
485 + var idx = req.body.idx
486 + var ID = req.user.ID;
487 + var datas = [idx,ID]
488 +
489 + var sql = "delete from composer_board where idx=? and ID=?"
490 + board.query(sql,datas, function(err,result){
491 + if(err) console.error(err)
492 + // 삭제를 요청한 사용자가 작성자가 아닌 경우
493 + if(result.affectedRows == 0){
494 + // 운영자세요?
495 + var sql_ = 'select type from userdb where ID="'+ID+'"';
496 + board.query(sql_, function(err_, result_){
497 + if(err_) console.error(err_)
498 +
499 + if(result_[0].type == "운영자"){ // 작성자는 아니나 유저 타입이 운영자인 경우
500 + var sqlAdmin = 'delete from composer_board where idx="'+idx+'"';
501 + board.query(sqlAdmin, function(err__, result__){
502 + if(err__) console.error(err__)
503 +
504 + var nickname = req.user.nickname;
505 + res.send("<script>alert('게시글이 운영자에 의해 삭제되었습니다.');window.location.href='/board/list/composer/';</script>");
506 + console.log(logString+"[Admin] "+req.user.ID+'('+nickname+') 유저가 작곡가 구인 '+idx+'번 게시글을 삭제했습니다.('+ip+')')
507 + })
508 + }
509 + else{ // 작성자도, 운영자도 아니면
510 + var nickname = req.user.nickname;
511 + console.log(logString+req.user.ID+'('+nickname+') 유저의 작곡가 구인 '+idx+'번 게시글 삭제를 거부했습니다.(권한없음 // '+ip+')')
512 + res.send("<script>alert('게시글 작성자가 아닙니다');history.back();</script>");
513 + }
514 + })
515 + }
516 + else{ // 작성자인 경우
517 + var id = req.user.ID;
518 + var nickname = req.user.nickname;
519 + res.send("<script>alert('게시글이 삭제되었습니다.');window.location.href='/board/list/composer/';</script>");
520 + console.log(logString+req.user.ID+'('+nickname+') 유저가 작곡가 구인 '+idx+'번 게시글을 삭제했습니다.('+ip+')')
521 + }
522 + })
523 +})
524 +
525 +// 가수 구인
526 +router.get('/list/singer/:page', function(req, res, next) {
527 + var ip = requestIp.getClientIp(req);
528 + var id = req.user;
529 + if(!id){
530 + console.log(logString+'익명 유저의 가수 구인 게시판 접근을 거부했습니다.('+ip+')')
531 + res.redirect('/board/list/singer/1')
532 + }
533 + else{
534 + var page = req.params.page;
535 + var sql = "select idx, nickname, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
536 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit from singer_board order by idx desc";
537 + board.query(sql, function(err,rows) {
538 + if (err) console.error("err : " + err);
539 + var id = req.user.ID;
540 + var nickname = req.user.nickname;
541 + console.log(logString+req.user.ID+'('+nickname+') 유저가 가수 구인 게시판을 보고있습니다.('+ip+')')
542 + res.render('list.ejs', {'ID':id, 'nickname': nickname, title: '가수 구인', rows: rows, page:page, length:rows.length-1,page_num:10,pass:true})
543 + })
544 + }
545 +});
546 +
547 +router.get('/singer', function(req,res,next){
548 + var ip = requestIp.getClientIp(req);
549 + var id = req.user;
550 + if(!id){
551 + console.log(logString+'익명 유저의 가수 구인 게시판 접근을 거부했습니다.('+ip+')')
552 + res.sendFile(path.join(__dirname, "../../public/login.html"))
553 + }
554 + else res.redirect('/board/list/singer/1')
555 +})
556 +
557 +router.get('/list/singer', function(req,res,next){
558 + var ip = requestIp.getClientIp(req);
559 + var id = req.user;
560 + if(!id){
561 + console.log(logString+'익명 유저의 가수 구인 게시판 접근을 거부했습니다.('+ip+')')
562 + res.sendFile(path.join(__dirname, "../../public/login.html"))
563 + }
564 + else res.redirect('/board/list/singer/1')
565 +})
566 +
567 +router.get('/write/singer', function(req,res,next){
568 + var ip = requestIp.getClientIp(req);
569 + var id = req.user;
570 + if(!id){
571 + console.log(logString+'익명 유저의 가수 구인 글쓰기 시도를 거부했습니다.('+ip+')')
572 + res.sendFile(path.join(__dirname, "../../public/login.html"))
573 + }
574 + else{
575 + var id = req.user.ID;
576 + var nickname = req.user.nickname;
577 + console.log(logString+req.user.ID+'('+nickname+') 유저가 가수 구인 게시글 작성 중입니다.('+ip+')')
578 + res.render('write.ejs', {'ID':id, 'nickname': nickname, title:"가수 구인 글 쓰기"})
579 + }
580 +})
581 +
582 +router.post('/write/singer', function(req,res,next){
583 + var ip = requestIp.getClientIp(req);
584 + var nickname = req.user.nickname // var name = req.body.name
585 + var title = req.body.title
586 + var content = req.body.content
587 + var ID = req.user.ID
588 + var datas = [nickname, title, content, ID]
589 +
590 + var sql = "insert into singer_board(nickname, title, content, regdate, modidate, hit, ID) values(?,?,?,now(),now(),0, ?)";
591 + board.query(sql, datas, function (err, rows) {
592 + if (err) console.error("err : " + err);
593 + });
594 +
595 + var idx_;
596 + var sql_ = "select max(idx) as idx from singer_board"
597 + board.query(sql_, function(err, rows){
598 + if(err) console.error("err : " + err);
599 + idx_ = rows[0].idx;
600 +
601 + if(!idx_) // 글이 없으면 NULL
602 + idx_ = 1;
603 +
604 + console.log(logString+req.user.ID+'('+nickname+') 유저가 가수 구인 '+idx_+'번 게시글을 작성했습니다.('+ip+')')
605 + res.redirect('/board/read/singer/'+idx_);
606 + });
607 +})
608 +
609 +router.get('/read/singer/:idx', function(req,res,next){
610 + var ip = requestIp.getClientIp(req);
611 +
612 + var idx = req.params.idx
613 + var sql = "select idx, nickname, title, content, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
614 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit, ID from singer_board where idx=?";
615 + board.query(sql, [idx], function(err,row){
616 + if(err) console.error(err)
617 +
618 + var id = req.user;
619 + if(!id){
620 + console.log(logString+'익명 유저의 '+idx+'번 가수 구인 게시물 접근을 거부했습니다.('+ip+')')
621 + res.redirect('/login')
622 + }
623 + else{
624 + var id = req.user.ID;
625 + var nickname = req.user.nickname;
626 +
627 + // 조회수 증가
628 + var sql_ = 'update singer_board set hit=hit+1 where idx="'+idx+'"';
629 + board.query(sql_, function(err, row){
630 + if(err) console.error(err)
631 + })
632 +
633 + var sql_comment = "select idx, nickname, comment from singer_comment where bulletin_id =?"
634 + board.query(sql_comment, [idx], function(err,comment){
635 + if (err) console.error("err : " + err);
636 + res.render('read.ejs', {'ID':id, 'nickname': nickname, title:"가수 구인 글 상세", row:row[0], comment:comment, comment_length : comment.length, usernick:req.user.nickname})
637 + })
638 + console.log(logString+req.user.ID+'('+nickname+') 유저가 가수 구인 '+idx+'번 게시글을 보고있습니다.('+ip+')')
639 + }
640 + })
641 +})
642 +
643 +router.post('/read/singer/commentwrite', function(req,res,next){
644 + var ip = requestIp.getClientIp(req);
645 + var idx = req.body.idx;
646 + var nickname = req.user.nickname // var name = req.body.name
647 + var comment = req.body.comment
648 + var ID = req.user.ID
649 + var datas = [ID, nickname, comment, idx]
650 +
651 + var sql = "insert into singer_comment(ID, nickname, comment, bulletin_id) values(?, ?, ?, ?)"
652 + board.query(sql, datas, function(err,row){
653 + if (err) console.error("err : " + err);
654 + })
655 + console.log(logString+req.user.ID+'('+nickname+') 유저가 가수 구인 '+idx+'번 게시물에 댓글을 작성했습니다.('+ip+')')
656 + res.redirect('/board/read/singer/'+idx);
657 +})
658 +
659 +router.post('/read/singer/commentdelete', function(req,res,next){
660 + var ip = requestIp.getClientIp(req);
661 + var idx = req.body.idxcomment;
662 + var idxbulletin = (req.headers.referer).split('/')[6];
663 + var ID = req.user.ID;
664 + var datas = [ID, idx]
665 +
666 + var sql = "delete from singer_comment where ID =? and idx=?"
667 + board.query(sql,datas,function(err,result){
668 + if(err) console.error(err)
669 + // 삭제를 요청한 사용자가 작성자가 아닌 경우
670 + if(result.affectedRows == 0){
671 + // 운영자세요?
672 + var sql_ = 'select type from userdb where ID="'+ID+'"';
673 + board.query(sql_, function(err_, result_){
674 + if(err_) console.error(err_)
675 +
676 + if(result_[0].type == "운영자"){ // 작성자는 아니나 유저 타입이 운영자인 경우
677 + var sqlAdmin = 'delete from nsinger_comment where idx="'+idx+'"';
678 + board.query(sqlAdmin, function(err__, result__){
679 + if(err__) console.error(err__)
680 +
681 + var nickname = req.user.nickname;
682 + console.log(logString+"[Admin] "+req.user.ID+'('+nickname+') 유저가 가수 구인 '+idxbulletin+'번 글에서 '+idx+'번 댓글을 삭제했습니다.('+ip+')')
683 + res.redirect('/board/read/singer/'+idxbulletin)
684 + })
685 + }
686 + else{ // 작성자도, 운영자도 아니면
687 + var nickname = req.user.nickname;
688 + console.log(logString+req.user.ID+'('+nickname+') 유저의 가수 구인 '+idxbulletin+'번 글의 '+idx+'번 댓글 삭제를 거부했습니다.(권한없음 // '+ip+')')
689 + res.send("<script>alert('댓글 작성자가 아닙니다');history.back();</script>");
690 + }
691 + })
692 + }
693 + else{ // 작성자인 경우
694 + var nickname = req.user.nickname;
695 + console.log(logString+req.user.ID+'('+nickname+') 유저가 가수 구인 '+idxbulletin+'번 글에서 '+idx+'번 댓글을 삭제했습니다.('+ip+')')
696 + res.redirect('/board/read/singer/'+idxbulletin)
697 + }
698 + })
699 +})
700 +
701 +router.post('/update/singer', function(req,res,next){
702 + var ip = requestIp.getClientIp(req);
703 + var ID = req.user.ID;
704 + var idx = req.body.idx
705 + var title = req.body.title
706 + var content = req.body.content
707 + var datas = [title, content, idx, ID]
708 +
709 + var sql = "update singer_board set title=?,content=?,modidate=now() where idx =? and ID=?"
710 + board.query(sql,datas,function(err,result){
711 + if(err) console.error(err)
712 + if(result.affectedRows==0){
713 + console.log(logString+req.user.ID+'('+req.user.nickname+') 유저의 가수 구인 '+idx+'번 게시글 수정을 거부했습니다.(권한없음 // '+ip+')')
714 + res.send("<script>alert('게시글 작성자가 아닙니다.');history.back();</script>")
715 + }
716 + else{
717 + var id = req.user.ID;
718 + var nickname = req.user.nickname;
719 + console.log(logString+req.user.ID+'('+nickname+') 유저가 가수 구인 '+idx+'번 게시글을 수정했습니다.('+ip+')')
720 + res.redirect('/board/read/singer/'+idx)
721 + }
722 + })
723 +})
724 +
725 +router.post('/delete/singer', function(req,res,next){
726 + var ip = requestIp.getClientIp(req);
727 + var idx = req.body.idx
728 + var ID = req.user.ID;
729 + var datas = [idx,ID]
730 +
731 + var sql = "delete from singer_board where idx=? and ID=?"
732 + board.query(sql,datas, function(err,result){
733 + if(err) console.error(err)
734 + // 삭제를 요청한 사용자가 작성자가 아닌 경우
735 + if(result.affectedRows == 0){
736 + // 운영자세요?
737 + var sql_ = 'select type from userdb where ID="'+ID+'"';
738 + board.query(sql_, function(err_, result_){
739 + if(err_) console.error(err_)
740 +
741 + if(result_[0].type == "운영자"){ // 작성자는 아니나 유저 타입이 운영자인 경우
742 + var sqlAdmin = 'delete from singer_board where idx="'+idx+'"';
743 + board.query(sqlAdmin, function(err__, result__){
744 + if(err__) console.error(err__)
745 +
746 + var nickname = req.user.nickname;
747 + res.send("<script>alert('게시글이 운영자에 의해 삭제되었습니다.');window.location.href='/board/list/singer/';</script>");
748 + console.log(logString+"[Admin] "+req.user.ID+'('+nickname+') 유저가 가수 구인 '+idx+'번 게시글을 삭제했습니다.('+ip+')')
749 + })
750 + }
751 + else{ // 작성자도, 운영자도 아니면
752 + var nickname = req.user.nickname;
753 + console.log(logString+req.user.ID+'('+nickname+') 유저의 가수 구인 '+idx+'번 게시글 삭제를 거부했습니다.(권한없음 // '+ip+')')
754 + res.send("<script>alert('게시글 작성자가 아닙니다');history.back();</script>");
755 + }
756 + })
757 + }
758 + else{ // 작성자인 경우
759 + var id = req.user.ID;
760 + var nickname = req.user.nickname;
761 + res.send("<script>alert('게시글이 삭제되었습니다.');window.location.href='/board/list/singer/';</script>");
762 + console.log(logString+req.user.ID+'('+nickname+') 유저가 가수 구인 '+idx+'번 게시글을 삭제했습니다.('+ip+')')
763 + }
764 + })
765 +})
766 +
767 +// 자유게시판
768 +router.get('/list/free/:page', function(req, res, next) {
769 + var ip = requestIp.getClientIp(req);
770 + var id = req.user;
771 + if(!id){
772 + console.log(logString+'익명 유저의 자유게시판 접근을 거부했습니다.('+ip+')')
773 + res.redirect('/board/list/free/1')
37 } 774 }
38 else{ 775 else{
39 var page = req.params.page; 776 var page = req.params.page;
40 var sql = "select idx, nickname, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " + 777 var sql = "select idx, nickname, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
41 - "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit from board order by idx desc"; 778 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit from free_board order by idx desc";
42 board.query(sql, function(err,rows) { 779 board.query(sql, function(err,rows) {
43 if (err) console.error("err : " + err); 780 if (err) console.error("err : " + err);
44 var id = req.user.ID; 781 var id = req.user.ID;
45 var nickname = req.user.nickname; 782 var nickname = req.user.nickname;
46 - console.log(logString+req.user.ID+'('+nickname+') 유저가 게시판을 보고있습니다.('+ip+')') 783 + console.log(logString+req.user.ID+'('+nickname+') 유저가 자유게시판을 보고있습니다.('+ip+')')
47 - res.render('list.ejs', {'ID':id, 'nickname': nickname, title: '게시판 리스트', rows: rows, page:page, length:rows.length-1,page_num:10,pass:true}) 784 + res.render('list.ejs', {'ID':id, 'nickname': nickname, title: '자유게시판', rows: rows, page:page, length:rows.length-1,page_num:10,pass:true})
48 }) 785 })
49 } 786 }
50 }); 787 });
51 788
52 -router.get('/list', function(req,res,next){ 789 +router.get('/free', function(req,res,next){
790 + var ip = requestIp.getClientIp(req);
791 + var id = req.user;
792 + if(!id){
793 + console.log(logString+'익명 유저의 자유게시판 접근을 거부했습니다.('+ip+')')
794 + res.sendFile(path.join(__dirname, "../../public/login.html"))
795 + }
796 + else res.redirect('/board/list/free/1')
797 +})
798 +
799 +router.get('/list/free', function(req,res,next){
53 var ip = requestIp.getClientIp(req); 800 var ip = requestIp.getClientIp(req);
54 var id = req.user; 801 var id = req.user;
55 if(!id){ 802 if(!id){
56 - console.log(logString+'익명 유저의 게시판 접근을 거부했습니다.('+ip+')') 803 + console.log(logString+'익명 유저의 자유게시판 접근을 거부했습니다.('+ip+')')
57 res.sendFile(path.join(__dirname, "../../public/login.html")) 804 res.sendFile(path.join(__dirname, "../../public/login.html"))
58 } 805 }
59 - else res.redirect('/board/list/1') 806 + else res.redirect('/board/list/free/1')
60 }) 807 })
61 808
62 -router.get('/write', function(req,res,next){ 809 +router.get('/write/free', function(req,res,next){
63 var ip = requestIp.getClientIp(req); 810 var ip = requestIp.getClientIp(req);
64 var id = req.user; 811 var id = req.user;
65 if(!id){ 812 if(!id){
66 - console.log(logString+'익명 유저의 글쓰기 시도를 거부했습니다.('+ip+')') 813 + console.log(logString+'익명 유저의 자유게시판 글쓰기 시도를 거부했습니다.('+ip+')')
67 res.sendFile(path.join(__dirname, "../../public/login.html")) 814 res.sendFile(path.join(__dirname, "../../public/login.html"))
68 } 815 }
69 else{ 816 else{
70 var id = req.user.ID; 817 var id = req.user.ID;
71 var nickname = req.user.nickname; 818 var nickname = req.user.nickname;
72 - console.log(logString+req.user.ID+'('+nickname+') 유저가 게시글 작성 중입니다.('+ip+')') 819 + console.log(logString+req.user.ID+'('+nickname+') 유저가 자유게시판 게시글 작성 중입니다.('+ip+')')
73 - res.render('write.ejs', {'ID':id, 'nickname': nickname, title:"게시판 글 쓰기"}) 820 + res.render('write.ejs', {'ID':id, 'nickname': nickname, title:"자유게시판 글 쓰기"})
74 } 821 }
75 }) 822 })
76 823
77 -router.post('/write', function(req,res,next){ 824 +router.post('/write/free', function(req,res,next){
78 var ip = requestIp.getClientIp(req); 825 var ip = requestIp.getClientIp(req);
79 var nickname = req.user.nickname // var name = req.body.name 826 var nickname = req.user.nickname // var name = req.body.name
80 var title = req.body.title 827 var title = req.body.title
...@@ -82,13 +829,13 @@ router.post('/write', function(req,res,next){ ...@@ -82,13 +829,13 @@ router.post('/write', function(req,res,next){
82 var ID = req.user.ID 829 var ID = req.user.ID
83 var datas = [nickname, title, content, ID] 830 var datas = [nickname, title, content, ID]
84 831
85 - var sql = "insert into board(nickname, title, content, regdate, modidate, hit, ID) values(?,?,?,now(),now(),0, ?)"; 832 + var sql = "insert into free_board(nickname, title, content, regdate, modidate, hit, ID) values(?,?,?,now(),now(),0, ?)";
86 board.query(sql, datas, function (err, rows) { 833 board.query(sql, datas, function (err, rows) {
87 if (err) console.error("err : " + err); 834 if (err) console.error("err : " + err);
88 }); 835 });
89 836
90 var idx_; 837 var idx_;
91 - var sql_ = "select max(idx) as idx from board" 838 + var sql_ = "select max(idx) as idx from free_board"
92 board.query(sql_, function(err, rows){ 839 board.query(sql_, function(err, rows){
93 if(err) console.error("err : " + err); 840 if(err) console.error("err : " + err);
94 idx_ = rows[0].idx; 841 idx_ = rows[0].idx;
...@@ -96,23 +843,23 @@ router.post('/write', function(req,res,next){ ...@@ -96,23 +843,23 @@ router.post('/write', function(req,res,next){
96 if(!idx_) // 글이 없으면 NULL 843 if(!idx_) // 글이 없으면 NULL
97 idx_ = 1; 844 idx_ = 1;
98 845
99 - console.log(logString+req.user.ID+'('+nickname+') 유저가 '+idx_+'번 게시글을 작성했습니다.('+ip+')') 846 + console.log(logString+req.user.ID+'('+nickname+') 유저가 자유게시판 '+idx_+'번 게시글을 작성했습니다.('+ip+')')
100 - res.redirect('/board/read/'+idx_); 847 + res.redirect('/board/read/free/'+idx_);
101 }); 848 });
102 }) 849 })
103 850
104 -router.get('/read/:idx', function(req,res,next){ 851 +router.get('/read/free/:idx', function(req,res,next){
105 var ip = requestIp.getClientIp(req); 852 var ip = requestIp.getClientIp(req);
106 853
107 var idx = req.params.idx 854 var idx = req.params.idx
108 var sql = "select idx, nickname, title, content, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " + 855 var sql = "select idx, nickname, title, content, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
109 - "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit, ID from board where idx=?"; 856 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit, ID from free_board where idx=?";
110 board.query(sql, [idx], function(err,row){ 857 board.query(sql, [idx], function(err,row){
111 if(err) console.error(err) 858 if(err) console.error(err)
112 859
113 var id = req.user; 860 var id = req.user;
114 if(!id){ 861 if(!id){
115 - console.log(logString+'익명 유저의 '+idx+'번 게시물 접근을 거부했습니다.('+ip+')') 862 + console.log(logString+'익명 유저의 자유게시판 '+idx+'번 게시물 접근을 거부했습니다.('+ip+')')
116 res.redirect('/login') 863 res.redirect('/login')
117 } 864 }
118 else{ 865 else{
...@@ -120,22 +867,22 @@ router.get('/read/:idx', function(req,res,next){ ...@@ -120,22 +867,22 @@ router.get('/read/:idx', function(req,res,next){
120 var nickname = req.user.nickname; 867 var nickname = req.user.nickname;
121 868
122 // 조회수 증가 869 // 조회수 증가
123 - var sql_ = 'update board set hit=hit+1 where idx="'+idx+'"'; 870 + var sql_ = 'update free_board set hit=hit+1 where idx="'+idx+'"';
124 board.query(sql_, function(err, row){ 871 board.query(sql_, function(err, row){
125 if(err) console.error(err) 872 if(err) console.error(err)
126 }) 873 })
127 874
128 - var sql_comment = "select idx, nickname, comment from comment where bulletin_id =?" 875 + var sql_comment = "select idx, nickname, comment from free_comment where bulletin_id =?"
129 board.query(sql_comment, [idx], function(err,comment){ 876 board.query(sql_comment, [idx], function(err,comment){
130 if (err) console.error("err : " + err); 877 if (err) console.error("err : " + err);
131 - res.render('read.ejs', {'ID':id, 'nickname': nickname, title:"글 상세", row:row[0], comment:comment, comment_length : comment.length, usernick:req.user.nickname}) 878 + res.render('read.ejs', {'ID':id, 'nickname': nickname, title:"자유게시판 글 상세", row:row[0], comment:comment, comment_length : comment.length, usernick:req.user.nickname})
132 }) 879 })
133 - console.log(logString+req.user.ID+'('+nickname+') 유저가 '+idx+'번 게시글을 보고있습니다.('+ip+')') 880 + console.log(logString+req.user.ID+'('+nickname+') 유저가 자유게시판 '+idx+'번 게시글을 보고있습니다.('+ip+')')
134 } 881 }
135 }) 882 })
136 }) 883 })
137 884
138 -router.post('/read/commentwrite', function(req,res,next){ 885 +router.post('/read/free/commentwrite', function(req,res,next){
139 var ip = requestIp.getClientIp(req); 886 var ip = requestIp.getClientIp(req);
140 var idx = req.body.idx; 887 var idx = req.body.idx;
141 var nickname = req.user.nickname // var name = req.body.name 888 var nickname = req.user.nickname // var name = req.body.name
...@@ -143,22 +890,22 @@ router.post('/read/commentwrite', function(req,res,next){ ...@@ -143,22 +890,22 @@ router.post('/read/commentwrite', function(req,res,next){
143 var ID = req.user.ID 890 var ID = req.user.ID
144 var datas = [ID, nickname, comment, idx] 891 var datas = [ID, nickname, comment, idx]
145 892
146 - var sql = "insert into comment(ID, nickname, comment, bulletin_id) values(?, ?, ?, ?)" 893 + var sql = "insert into free_comment(ID, nickname, comment, bulletin_id) values(?, ?, ?, ?)"
147 board.query(sql, datas, function(err,row){ 894 board.query(sql, datas, function(err,row){
148 if (err) console.error("err : " + err); 895 if (err) console.error("err : " + err);
149 }) 896 })
150 - console.log(logString+req.user.ID+'('+nickname+') 유저가 '+idx+'번 게시물에 댓글을 작성했습니다.('+ip+')') 897 + console.log(logString+req.user.ID+'('+nickname+') 유저가 자유게시판 '+idx+'번 게시물에 댓글을 작성했습니다.('+ip+')')
151 - res.redirect('/board/read/'+idx); 898 + res.redirect('/board/read/free/'+idx);
152 }) 899 })
153 900
154 -router.post('/read/commentdelete', function(req,res,next){ 901 +router.post('/read/free/commentdelete', function(req,res,next){
155 var ip = requestIp.getClientIp(req); 902 var ip = requestIp.getClientIp(req);
156 var idx = req.body.idxcomment; 903 var idx = req.body.idxcomment;
157 - var idxbulletin = (req.headers.referer).split('/')[5]; 904 + var idxbulletin = (req.headers.referer).split('/')[6];
158 var ID = req.user.ID; 905 var ID = req.user.ID;
159 var datas = [ID, idx] 906 var datas = [ID, idx]
160 907
161 - var sql = "delete from comment where ID =? and idx=?" 908 + var sql = "delete from free_comment where ID =? and idx=?"
162 board.query(sql,datas,function(err,result){ 909 board.query(sql,datas,function(err,result){
163 if(err) console.error(err) 910 if(err) console.error(err)
164 // 삭제를 요청한 사용자가 작성자가 아닌 경우 911 // 삭제를 요청한 사용자가 작성자가 아닌 경우
...@@ -169,32 +916,273 @@ router.post('/read/commentdelete', function(req,res,next){ ...@@ -169,32 +916,273 @@ router.post('/read/commentdelete', function(req,res,next){
169 if(err_) console.error(err_) 916 if(err_) console.error(err_)
170 917
171 if(result_[0].type == "운영자"){ // 작성자는 아니나 유저 타입이 운영자인 경우 918 if(result_[0].type == "운영자"){ // 작성자는 아니나 유저 타입이 운영자인 경우
172 - var sqlAdmin = 'delete from comment where idx="'+idx+'"'; 919 + var sqlAdmin = 'delete from nfree_comment where idx="'+idx+'"';
173 board.query(sqlAdmin, function(err__, result__){ 920 board.query(sqlAdmin, function(err__, result__){
174 if(err__) console.error(err__) 921 if(err__) console.error(err__)
175 922
176 var nickname = req.user.nickname; 923 var nickname = req.user.nickname;
177 - console.log(logString+"[Admin] "+req.user.ID+'('+nickname+') 유저가 '+idxbulletin+'번 글에서 '+idx+'번 댓글을 삭제했습니다.('+ip+')') 924 + console.log(logString+"[Admin] "+req.user.ID+'('+nickname+') 유저가 자유게시판 '+idxbulletin+'번 글에서 '+idx+'번 댓글을 삭제했습니다.('+ip+')')
178 - res.redirect('/board/read/'+idxbulletin) 925 + res.redirect('/board/read/free/'+idxbulletin)
179 }) 926 })
180 } 927 }
181 else{ // 작성자도, 운영자도 아니면 928 else{ // 작성자도, 운영자도 아니면
182 var nickname = req.user.nickname; 929 var nickname = req.user.nickname;
183 - console.log(logString+req.user.ID+'('+nickname+') 유저의 '+idxbulletin+'번 글의 '+idx+'번 댓글 삭제를 거부했습니다.(권한없음 // '+ip+')') 930 + console.log(logString+req.user.ID+'('+nickname+') 유저의 자유게시판 '+idxbulletin+'번 글의 '+idx+'번 댓글 삭제를 거부했습니다.(권한없음 // '+ip+')')
184 res.send("<script>alert('댓글 작성자가 아닙니다');history.back();</script>"); 931 res.send("<script>alert('댓글 작성자가 아닙니다');history.back();</script>");
185 } 932 }
186 }) 933 })
187 } 934 }
188 else{ // 작성자인 경우 935 else{ // 작성자인 경우
189 var nickname = req.user.nickname; 936 var nickname = req.user.nickname;
190 - console.log(logString+req.user.ID+'('+nickname+') 유저가 '+idxbulletin+'번 글에서 '+idx+'번 댓글을 삭제했습니다.('+ip+')') 937 + console.log(logString+req.user.ID+'('+nickname+') 유저가 자유게시판 '+idxbulletin+'번 글에서 '+idx+'번 댓글을 삭제했습니다.('+ip+')')
191 - res.redirect('/board/read/'+idxbulletin) 938 + res.redirect('/board/read/free/'+idxbulletin)
939 + }
940 + })
941 +})
942 +
943 +router.post('/update/free', function(req,res,next){
944 + var ip = requestIp.getClientIp(req);
945 + var ID = req.user.ID;
946 + var idx = req.body.idx
947 + var title = req.body.title
948 + var content = req.body.content
949 + var datas = [title, content, idx, ID]
950 +
951 + var sql = "update free_board set title=?,content=?,modidate=now() where idx =? and ID=?"
952 + board.query(sql,datas,function(err,result){
953 + if(err) console.error(err)
954 + if(result.affectedRows==0){
955 + console.log(logString+req.user.ID+'('+req.user.nickname+') 유저의 자유게시판 '+idx+'번 게시글 수정을 거부했습니다.(권한없음 // '+ip+')')
956 + res.send("<script>alert('게시글 작성자가 아닙니다.');history.back();</script>")
957 + }
958 + else{
959 + var id = req.user.ID;
960 + var nickname = req.user.nickname;
961 + console.log(logString+req.user.ID+'('+nickname+') 유저가 자유게시판 '+idx+'번 게시글을 수정했습니다.('+ip+')')
962 + res.redirect('/board/read/free/'+idx)
963 + }
964 + })
965 +})
966 +
967 +router.post('/delete/free', function(req,res,next){
968 + var ip = requestIp.getClientIp(req);
969 + var idx = req.body.idx
970 + var ID = req.user.ID;
971 + var datas = [idx,ID]
972 +
973 + var sql = "delete from free_board where idx=? and ID=?"
974 + board.query(sql,datas, function(err,result){
975 + if(err) console.error(err)
976 + // 삭제를 요청한 사용자가 작성자가 아닌 경우
977 + if(result.affectedRows == 0){
978 + // 운영자세요?
979 + var sql_ = 'select type from userdb where ID="'+ID+'"';
980 + board.query(sql_, function(err_, result_){
981 + if(err_) console.error(err_)
982 +
983 + if(result_[0].type == "운영자"){ // 작성자는 아니나 유저 타입이 운영자인 경우
984 + var sqlAdmin = 'delete from free_board where idx="'+idx+'"';
985 + board.query(sqlAdmin, function(err__, result__){
986 + if(err__) console.error(err__)
987 +
988 + var nickname = req.user.nickname;
989 + res.send("<script>alert('게시글이 운영자에 의해 삭제되었습니다.');window.location.href='/board/list/free/';</script>");
990 + console.log(logString+"[Admin] "+req.user.ID+'('+nickname+') 유저가 자유게시판 '+idx+'번 게시글을 삭제했습니다.('+ip+')')
991 + })
992 + }
993 + else{ // 작성자도, 운영자도 아니면
994 + var nickname = req.user.nickname;
995 + console.log(logString+req.user.ID+'('+nickname+') 유저의 자유게시판 '+idx+'번 게시글 삭제를 거부했습니다.(권한없음 // '+ip+')')
996 + res.send("<script>alert('게시글 작성자가 아닙니다');history.back();</script>");
997 + }
998 + })
999 + }
1000 + else{ // 작성자인 경우
1001 + var id = req.user.ID;
1002 + var nickname = req.user.nickname;
1003 + res.send("<script>alert('게시글이 삭제되었습니다.');window.location.href='/board/list/free/';</script>");
1004 + console.log(logString+req.user.ID+'('+nickname+') 유저가 자유게시판 '+idx+'번 게시글을 삭제했습니다.('+ip+')')
1005 + }
1006 + })
1007 +})
1008 +
1009 +// 건의사항
1010 +router.get('/list/suggestion/:page', function(req, res, next) {
1011 + var ip = requestIp.getClientIp(req);
1012 + var id = req.user;
1013 + if(!id){
1014 + console.log(logString+'익명 유저의 건의사항 게시판 접근을 거부했습니다.('+ip+')')
1015 + res.redirect('/board/list/suggestion/1')
1016 + }
1017 + else{
1018 + var page = req.params.page;
1019 + var sql = "select idx, nickname, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
1020 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit from suggestion_board order by idx desc";
1021 + board.query(sql, function(err,rows) {
1022 + if (err) console.error("err : " + err);
1023 + var id = req.user.ID;
1024 + var nickname = req.user.nickname;
1025 + console.log(logString+req.user.ID+'('+nickname+') 유저가 건의사항 게시판을 보고있습니다.('+ip+')')
1026 + res.render('list.ejs', {'ID':id, 'nickname': nickname, title: '건의사항', rows: rows, page:page, length:rows.length-1,page_num:10,pass:true})
1027 + })
1028 + }
1029 +});
1030 +
1031 +router.get('/suggestion', function(req,res,next){
1032 + var ip = requestIp.getClientIp(req);
1033 + var id = req.user;
1034 + if(!id){
1035 + console.log(logString+'익명 유저의 건의사항 게시판 접근을 거부했습니다.('+ip+')')
1036 + res.sendFile(path.join(__dirname, "../../public/login.html"))
1037 + }
1038 + else res.redirect('/board/list/suggestion/1')
1039 +})
1040 +
1041 +router.get('/list/suggestion', function(req,res,next){
1042 + var ip = requestIp.getClientIp(req);
1043 + var id = req.user;
1044 + if(!id){
1045 + console.log(logString+'익명 유저의 건의사항 게시판 접근을 거부했습니다.('+ip+')')
1046 + res.sendFile(path.join(__dirname, "../../public/login.html"))
1047 + }
1048 + else res.redirect('/board/list/suggestion/1')
1049 +})
1050 +
1051 +router.get('/write/suggestion', function(req,res,next){
1052 + var ip = requestIp.getClientIp(req);
1053 + var id = req.user;
1054 + if(!id){
1055 + console.log(logString+'익명 유저의 건의사항 글쓰기 시도를 거부했습니다.('+ip+')')
1056 + res.sendFile(path.join(__dirname, "../../public/login.html"))
1057 + }
1058 + else{
1059 + var id = req.user.ID;
1060 + var nickname = req.user.nickname;
1061 + console.log(logString+req.user.ID+'('+nickname+') 유저가 건의사항 게시글 작성 중입니다.('+ip+')')
1062 + res.render('write.ejs', {'ID':id, 'nickname': nickname, title:"건의사항 글 쓰기"})
1063 + }
1064 +})
1065 +
1066 +router.post('/write/suggestion', function(req,res,next){
1067 + var ip = requestIp.getClientIp(req);
1068 + var nickname = req.user.nickname // var name = req.body.name
1069 + var title = req.body.title
1070 + var content = req.body.content
1071 + var ID = req.user.ID
1072 + var datas = [nickname, title, content, ID]
1073 +
1074 + var sql = "insert into suggestion_board(nickname, title, content, regdate, modidate, hit, ID) values(?,?,?,now(),now(),0, ?)";
1075 + board.query(sql, datas, function (err, rows) {
1076 + if (err) console.error("err : " + err);
1077 + });
1078 +
1079 + var idx_;
1080 + var sql_ = "select max(idx) as idx from suggestion_board"
1081 + board.query(sql_, function(err, rows){
1082 + if(err) console.error("err : " + err);
1083 + idx_ = rows[0].idx;
1084 +
1085 + if(!idx_) // 글이 없으면 NULL
1086 + idx_ = 1;
1087 +
1088 + console.log(logString+req.user.ID+'('+nickname+') 유저가 건의사항 '+idx_+'번 게시글을 작성했습니다.('+ip+')')
1089 + res.redirect('/board/read/suggestion/'+idx_);
1090 + });
1091 +})
1092 +
1093 +router.get('/read/suggestion/:idx', function(req,res,next){
1094 + var ip = requestIp.getClientIp(req);
1095 +
1096 + var idx = req.params.idx
1097 + var sql = "select idx, nickname, title, content, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
1098 + "date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit, ID from suggestion_board where idx=?";
1099 + board.query(sql, [idx], function(err,row){
1100 + if(err) console.error(err)
1101 +
1102 + var id = req.user;
1103 + if(!id){
1104 + console.log(logString+'익명 유저의 '+idx+'번 건의사항 게시물 접근을 거부했습니다.('+ip+')')
1105 + res.redirect('/login')
1106 + }
1107 + else{
1108 + var id = req.user.ID;
1109 + var nickname = req.user.nickname;
1110 +
1111 + // 조회수 증가
1112 + var sql_ = 'update suggestion_board set hit=hit+1 where idx="'+idx+'"';
1113 + board.query(sql_, function(err, row){
1114 + if(err) console.error(err)
1115 + })
1116 +
1117 + var sql_comment = "select idx, nickname, comment from suggestion_comment where bulletin_id =?"
1118 + board.query(sql_comment, [idx], function(err,comment){
1119 + if (err) console.error("err : " + err);
1120 + res.render('read.ejs', {'ID':id, 'nickname': nickname, title:"건의사항 글 상세", row:row[0], comment:comment, comment_length : comment.length, usernick:req.user.nickname})
1121 + })
1122 + console.log(logString+req.user.ID+'('+nickname+') 유저가 건의사항 '+idx+'번 게시글을 보고있습니다.('+ip+')')
192 } 1123 }
193 }) 1124 })
1125 +})
1126 +
1127 +router.post('/read/suggestion/commentwrite', function(req,res,next){
1128 + var ip = requestIp.getClientIp(req);
1129 + var idx = req.body.idx;
1130 + var nickname = req.user.nickname // var name = req.body.name
1131 + var comment = req.body.comment
1132 + var ID = req.user.ID
1133 + var datas = [ID, nickname, comment, idx]
1134 +
1135 + var sql = "insert into suggestion_comment(ID, nickname, comment, bulletin_id) values(?, ?, ?, ?)"
1136 + board.query(sql, datas, function(err,row){
1137 + if (err) console.error("err : " + err);
1138 + })
1139 + console.log(logString+req.user.ID+'('+nickname+') 유저가 건의사항 '+idx+'번 게시물에 댓글을 작성했습니다.('+ip+')')
1140 + res.redirect('/board/read/suggestion/'+idx);
1141 +})
1142 +
1143 +router.post('/read/suggestion/commentdelete', function(req,res,next){
1144 + var ip = requestIp.getClientIp(req);
1145 + var idx = req.body.idxcomment;
1146 + var idxbulletin = (req.headers.referer).split('/')[6];
1147 + var ID = req.user.ID;
1148 + var datas = [ID, idx]
1149 +
1150 + var sql = "delete from suggestion_comment where ID =? and idx=?"
1151 + board.query(sql,datas,function(err,result){
1152 + if(err) console.error(err)
1153 + // 삭제를 요청한 사용자가 작성자가 아닌 경우
1154 + if(result.affectedRows == 0){
1155 + // 운영자세요?
1156 + var sql_ = 'select type from userdb where ID="'+ID+'"';
1157 + board.query(sql_, function(err_, result_){
1158 + if(err_) console.error(err_)
194 1159
1160 + if(result_[0].type == "운영자"){ // 작성자는 아니나 유저 타입이 운영자인 경우
1161 + var sqlAdmin = 'delete from nsuggestion_comment where idx="'+idx+'"';
1162 + board.query(sqlAdmin, function(err__, result__){
1163 + if(err__) console.error(err__)
1164 +
1165 + var nickname = req.user.nickname;
1166 + console.log(logString+"[Admin] "+req.user.ID+'('+nickname+') 유저가 건의사항 '+idxbulletin+'번 글에서 '+idx+'번 댓글을 삭제했습니다.('+ip+')')
1167 + res.redirect('/board/read/suggestion/'+idxbulletin)
1168 + })
1169 + }
1170 + else{ // 작성자도, 운영자도 아니면
1171 + var nickname = req.user.nickname;
1172 + console.log(logString+req.user.ID+'('+nickname+') 유저의 건의사항 '+idxbulletin+'번 글의 '+idx+'번 댓글 삭제를 거부했습니다.(권한없음 // '+ip+')')
1173 + res.send("<script>alert('댓글 작성자가 아닙니다');history.back();</script>");
1174 + }
1175 + })
1176 + }
1177 + else{ // 작성자인 경우
1178 + var nickname = req.user.nickname;
1179 + console.log(logString+req.user.ID+'('+nickname+') 유저가 건의사항 '+idxbulletin+'번 글에서 '+idx+'번 댓글을 삭제했습니다.('+ip+')')
1180 + res.redirect('/board/read/suggestion/'+idxbulletin)
1181 + }
1182 + })
195 }) 1183 })
196 1184
197 -router.post('/update', function(req,res,next){ 1185 +router.post('/update/suggestion', function(req,res,next){
198 var ip = requestIp.getClientIp(req); 1186 var ip = requestIp.getClientIp(req);
199 var ID = req.user.ID; 1187 var ID = req.user.ID;
200 var idx = req.body.idx 1188 var idx = req.body.idx
...@@ -202,29 +1190,29 @@ router.post('/update', function(req,res,next){ ...@@ -202,29 +1190,29 @@ router.post('/update', function(req,res,next){
202 var content = req.body.content 1190 var content = req.body.content
203 var datas = [title, content, idx, ID] 1191 var datas = [title, content, idx, ID]
204 1192
205 - var sql = "update board set title=?,content=?,modidate=now() where idx =? and ID=?" 1193 + var sql = "update suggestion_board set title=?,content=?,modidate=now() where idx =? and ID=?"
206 board.query(sql,datas,function(err,result){ 1194 board.query(sql,datas,function(err,result){
207 if(err) console.error(err) 1195 if(err) console.error(err)
208 if(result.affectedRows==0){ 1196 if(result.affectedRows==0){
209 - console.log(logString+req.user.ID+'('+req.user.nickname+') 유저의 '+idx+'번 게시글 수정을 거부했습니다.(권한없음 // '+ip+')') 1197 + console.log(logString+req.user.ID+'('+req.user.nickname+') 유저의 건의사항 '+idx+'번 게시글 수정을 거부했습니다.(권한없음 // '+ip+')')
210 res.send("<script>alert('게시글 작성자가 아닙니다.');history.back();</script>") 1198 res.send("<script>alert('게시글 작성자가 아닙니다.');history.back();</script>")
211 } 1199 }
212 else{ 1200 else{
213 var id = req.user.ID; 1201 var id = req.user.ID;
214 var nickname = req.user.nickname; 1202 var nickname = req.user.nickname;
215 - console.log(logString+req.user.ID+'('+nickname+') 유저가 '+idx+'번 게시글을 수정했습니다.('+ip+')') 1203 + console.log(logString+req.user.ID+'('+nickname+') 유저가 건의사항 '+idx+'번 게시글을 수정했습니다.('+ip+')')
216 - res.redirect('/board/read/'+idx) 1204 + res.redirect('/board/read/suggestion/'+idx)
217 } 1205 }
218 }) 1206 })
219 }) 1207 })
220 1208
221 -router.post('/delete', function(req,res,next){ 1209 +router.post('/delete/suggestion', function(req,res,next){
222 var ip = requestIp.getClientIp(req); 1210 var ip = requestIp.getClientIp(req);
223 var idx = req.body.idx 1211 var idx = req.body.idx
224 var ID = req.user.ID; 1212 var ID = req.user.ID;
225 var datas = [idx,ID] 1213 var datas = [idx,ID]
226 1214
227 - var sql = "delete from board where idx=? and ID=?" 1215 + var sql = "delete from suggestion_board where idx=? and ID=?"
228 board.query(sql,datas, function(err,result){ 1216 board.query(sql,datas, function(err,result){
229 if(err) console.error(err) 1217 if(err) console.error(err)
230 // 삭제를 요청한 사용자가 작성자가 아닌 경우 1218 // 삭제를 요청한 사용자가 작성자가 아닌 경우
...@@ -235,18 +1223,18 @@ router.post('/delete', function(req,res,next){ ...@@ -235,18 +1223,18 @@ router.post('/delete', function(req,res,next){
235 if(err_) console.error(err_) 1223 if(err_) console.error(err_)
236 1224
237 if(result_[0].type == "운영자"){ // 작성자는 아니나 유저 타입이 운영자인 경우 1225 if(result_[0].type == "운영자"){ // 작성자는 아니나 유저 타입이 운영자인 경우
238 - var sqlAdmin = 'delete from board where idx="'+idx+'"'; 1226 + var sqlAdmin = 'delete from suggestion_board where idx="'+idx+'"';
239 board.query(sqlAdmin, function(err__, result__){ 1227 board.query(sqlAdmin, function(err__, result__){
240 if(err__) console.error(err__) 1228 if(err__) console.error(err__)
241 1229
242 var nickname = req.user.nickname; 1230 var nickname = req.user.nickname;
243 - res.send("<script>alert('게시글이 운영자에 의해 삭제되었습니다.');window.location.href='/board/list/';</script>"); 1231 + res.send("<script>alert('게시글이 운영자에 의해 삭제되었습니다.');window.location.href='/board/list/suggestion/';</script>");
244 - console.log(logString+"[Admin] "+req.user.ID+'('+nickname+') 유저가 '+idx+'번 게시글을 삭제했습니다.('+ip+')') 1232 + console.log(logString+"[Admin] "+req.user.ID+'('+nickname+') 유저가 건의사항 '+idx+'번 게시글을 삭제했습니다.('+ip+')')
245 }) 1233 })
246 } 1234 }
247 else{ // 작성자도, 운영자도 아니면 1235 else{ // 작성자도, 운영자도 아니면
248 var nickname = req.user.nickname; 1236 var nickname = req.user.nickname;
249 - console.log(logString+req.user.ID+'('+nickname+') 유저의 '+idx+'번 게시글 삭제를 거부했습니다.(권한없음 // '+ip+')') 1237 + console.log(logString+req.user.ID+'('+nickname+') 유저의 건의사항 '+idx+'번 게시글 삭제를 거부했습니다.(권한없음 // '+ip+')')
250 res.send("<script>alert('게시글 작성자가 아닙니다');history.back();</script>"); 1238 res.send("<script>alert('게시글 작성자가 아닙니다');history.back();</script>");
251 } 1239 }
252 }) 1240 })
...@@ -254,8 +1242,8 @@ router.post('/delete', function(req,res,next){ ...@@ -254,8 +1242,8 @@ router.post('/delete', function(req,res,next){
254 else{ // 작성자인 경우 1242 else{ // 작성자인 경우
255 var id = req.user.ID; 1243 var id = req.user.ID;
256 var nickname = req.user.nickname; 1244 var nickname = req.user.nickname;
257 - res.send("<script>alert('게시글이 삭제되었습니다.');window.location.href='/board/list/';</script>"); 1245 + res.send("<script>alert('게시글이 삭제되었습니다.');window.location.href='/board/list/suggestion/';</script>");
258 - console.log(logString+req.user.ID+'('+nickname+') 유저가 '+idx+'번 게시글을 삭제했습니다.('+ip+')') 1246 + console.log(logString+req.user.ID+'('+nickname+') 유저가 건의사항 '+idx+'번 게시글을 삭제했습니다.('+ip+')')
259 } 1247 }
260 }) 1248 })
261 }) 1249 })
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
22 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 22 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
25 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 25 + <li><a href="/board class="nav-link px-2 link-dark">게시판</a></li>
26 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li> 26 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li>
27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
28 </ul> 28 </ul>
......
...@@ -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 %></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-->
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
23 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 23 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
24 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 24 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
25 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 25 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
26 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 26 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
27 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li> 27 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li>
28 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 28 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
29 </ul> 29 </ul>
...@@ -35,25 +35,49 @@ ...@@ -35,25 +35,49 @@
35 </nav> 35 </nav>
36 <div class ="wrap"> 36 <div class ="wrap">
37 <div class="list_board"> 37 <div class="list_board">
38 - <a class="board_btn" href="/board/list"> 38 + <a class="board_btn" href="/board/list/notice">
39 공지사항 39 공지사항
40 </a> 40 </a>
41 - <a class="board_btn" href="/board/list"> 41 + <a class="board_btn" href="/board/list/composer">
42 작곡가 구인 42 작곡가 구인
43 </a> 43 </a>
44 - <a class="board_btn" href="/board/list"> 44 + <a class="board_btn" href="/board/list/singer">
45 가수 구인 45 가수 구인
46 </a> 46 </a>
47 - <a class="board_btn" href="/board/list"> 47 + <a class="board_btn" href="/board/list/free">
48 자유게시판 48 자유게시판
49 </a> 49 </a>
50 - <a class="board_btn" href="/board/list"> 50 + <a class="board_btn" href="/board/list/suggestion">
51 건의사항 51 건의사항
52 </a> 52 </a>
53 </div> 53 </div>
54 54
55 <div class="container px-5 my-5"> 55 <div class="container px-5 my-5">
56 <h1><%= title %></h1> 56 <h1><%= title %></h1>
57 + <%
58 + var addr;
59 + %>
60 + <%
61 + switch(title){
62 + case '공지사항':
63 + addr = 'notice';
64 + break;
65 + case '작곡가 구인':
66 + addr = 'composer';
67 + break;
68 + case '가수 구인':
69 + addr = 'singer';
70 + break;
71 + case '자유게시판':
72 + addr = 'free';
73 + break;
74 + case '건의사항':
75 + addr = 'suggestion';
76 + break;
77 + %>
78 + <%
79 + }
80 + %>
57 <table border="1"> 81 <table border="1">
58 <tr> 82 <tr>
59 <td>번호</td> 83 <td>번호</td>
...@@ -73,7 +97,7 @@ ...@@ -73,7 +97,7 @@
73 <tr> 97 <tr>
74 <td><%=data.idx%></td> 98 <td><%=data.idx%></td>
75 <td><%=data.nickname%></td> 99 <td><%=data.nickname%></td>
76 - <td><a href="/board/read/<%=data.idx%>"><%=data.title%></a></td> 100 + <td><a href="/board/read/<%=addr%>/<%=data.idx%>"><%=data.title%></a></td>
77 <td><%=data.hit%></td> 101 <td><%=data.hit%></td>
78 <td><%=data.modidate%></td> 102 <td><%=data.modidate%></td>
79 <td><%=data.regdate%></td> 103 <td><%=data.regdate%></td>
...@@ -84,10 +108,9 @@ ...@@ -84,10 +108,9 @@
84 <tr> 108 <tr>
85 <td colspan="6"> 109 <td colspan="6">
86 <% 110 <%
87 -
88 for(var j = 0; j < rows.length/page_num ; j++){ 111 for(var j = 0; j < rows.length/page_num ; j++){
89 %> 112 %>
90 - [<a href="/board/list/<%= j + 1 %>"><%= j+1 %></a>] 113 + [<a href="/board/<%=addr%>/list/<%= j + 1 %>"><%= j+1 %></a>]
91 <% 114 <%
92 } 115 }
93 %> 116 %>
...@@ -95,7 +118,7 @@ ...@@ -95,7 +118,7 @@
95 </tr> 118 </tr>
96 </table> 119 </table>
97 <nav class="navbar"> 120 <nav class="navbar">
98 - <a class="btn btn-outline-primary me-2" href="/board/write">글쓰기</a> 121 + <a class="btn btn-outline-primary me-2" href="/board/write/<%=addr%>">글쓰기</a>
99 </nav> 122 </nav>
100 </div> 123 </div>
101 </div> 124 </div>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
22 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 22 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
25 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 25 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
26 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li> 26 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li>
27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
28 </ul> 28 </ul>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
22 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 22 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
25 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 25 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
26 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li> 26 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li>
27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
28 </ul> 28 </ul>
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
21 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 21 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
22 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 22 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
23 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 23 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
24 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 24 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
25 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li> 25 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li>
26 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 26 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
27 </ul> 27 </ul>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
22 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 22 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
25 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 25 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
26 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li> 26 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li>
27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
28 </ul> 28 </ul>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
22 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 22 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
25 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 25 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
26 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li> 26 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li>
27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
28 </ul> 28 </ul>
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
19 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 19 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
20 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 20 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
21 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 21 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
22 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 22 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
23 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li> 23 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li>
24 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 24 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
25 </ul> 25 </ul>
...@@ -29,16 +29,40 @@ ...@@ -29,16 +29,40 @@
29 </div> 29 </div>
30 </div> 30 </div>
31 </nav> 31 </nav>
32 + <%
33 + var addr;
34 + %>
32 <div class="container px-5 my-5"> 35 <div class="container px-5 my-5">
33 <h1><%= title %></h1> 36 <h1><%= title %></h1>
37 + <%
38 + switch(title){
39 + case '공지사항 글 상세':
40 + addr = 'notice';
41 + break;
42 + case '작곡가 구인 글 상세':
43 + addr = 'composer';
44 + break;
45 + case '가수 구인 글 상세':
46 + addr = 'singer';
47 + break;
48 + case '자유게시판 글 상세':
49 + addr = 'free';
50 + break;
51 + case '건의사항 글 상세':
52 + addr = 'suggestion';
53 + break;
54 + %>
55 + <%
56 + }
57 + %>
34 <script> 58 <script>
35 function submit2(frm){ 59 function submit2(frm){
36 - frm.action="/board/delete"; 60 + frm.action="/board/delete/<%=addr%>";
37 frm.submit(); 61 frm.submit();
38 return true; 62 return true;
39 } 63 }
40 </script> 64 </script>
41 - <form action="/board/update" method="post"> 65 + <form action="/board/update/<%=addr%>" method="post">
42 <table border="1"> 66 <table border="1">
43 <input type="hidden" name="idx" value="<%=row.idx%>"/> 67 <input type="hidden" name="idx" value="<%=row.idx%>"/>
44 <tr> 68 <tr>
...@@ -69,7 +93,7 @@ ...@@ -69,7 +93,7 @@
69 <td colspan="3"> 93 <td colspan="3">
70 <button type="submit">글 수정</button> 94 <button type="submit">글 수정</button>
71 <button type="summit" onclick="return submit2(this.form);">글 삭제</button> 95 <button type="summit" onclick="return submit2(this.form);">글 삭제</button>
72 - <a href="/board/list"> 96 + <a href="/board/<%=addr%>/list">
73 <input type="button" value="목록"> 97 <input type="button" value="목록">
74 </a> 98 </a>
75 </td> 99 </td>
...@@ -81,7 +105,7 @@ ...@@ -81,7 +105,7 @@
81 <h1>댓글</h1> 105 <h1>댓글</h1>
82 <script> 106 <script>
83 function submit3(frm){ 107 function submit3(frm){
84 - frm.action="/board/read/commentdelete"; 108 + frm.action="/board/read/<%=addr%>/commentdelete";
85 frm.submit(); 109 frm.submit();
86 return true; 110 return true;
87 } 111 }
...@@ -89,12 +113,12 @@ ...@@ -89,12 +113,12 @@
89 113
90 } 114 }
91 </script> 115 </script>
92 - <form action="/board/read/commentwrite" method="post"> 116 + <form action="/board/read/<%=addr%>/commentwrite" method="post">
93 <table border="1"> 117 <table border="1">
94 <input type="hidden" name="idx" value="<%=row.idx%>"/> 118 <input type="hidden" name="idx" value="<%=row.idx%>"/>
95 <tr> 119 <tr>
96 <td>닉네임</td> 120 <td>닉네임</td>
97 - <td>댓글</td> 121 + <td>내용</td>
98 </tr> 122 </tr>
99 <% 123 <%
100 for(var i=0; i<comment_length; i++){ 124 for(var i=0; i<comment_length; i++){
...@@ -115,7 +139,7 @@ ...@@ -115,7 +139,7 @@
115 } 139 }
116 %> 140 %>
117 <tr> 141 <tr>
118 - <td><%=usernick%></td> 142 + <td><%=nickname%></td>
119 <td><textarea name="comment" id="comment" cols="30" rows="2" required></textarea></td> 143 <td><textarea name="comment" id="comment" cols="30" rows="2" required></textarea></td>
120 <td colspan="2"> 144 <td colspan="2">
121 <button type="submit">댓글 쓰기</button> 145 <button type="submit">댓글 쓰기</button>
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
22 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 22 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 23 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 24 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
25 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 25 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
26 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li> 26 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li>
27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 27 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
28 </ul> 28 </ul>
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
18 <a class="navbar-brand" href="/main">묵호의 놀이터</a> 18 <a class="navbar-brand" href="/main">묵호의 놀이터</a>
19 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0"> 19 <ul class="nav col-12 col-md-auto mb-2 justify-content-center mb-md-0">
20 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li> 20 <li><a href="/about" class="nav-link px-2 link-dark">About</a></li>
21 - <li><a href="/board/list" class="nav-link px-2 link-dark">게시판</a></li> 21 + <li><a href="/board" class="nav-link px-2 link-dark">게시판</a></li>
22 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li> 22 <li><a href = "javascript:;" onclick = "window.open('/chat','파일 업로드','width=500, height=801, toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=no');" class="nav-link px-2 link-dark">채팅</a></li>
23 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li> 23 <li><a href="http://khuhub.khu.ac.kr/2017104034/Singer-Composer" target="_blank" class="nav-link px-2 link-dark">사이트 git</a></li>
24 </ul> 24 </ul>
...@@ -28,9 +28,33 @@ ...@@ -28,9 +28,33 @@
28 </div> 28 </div>
29 </div> 29 </div>
30 </nav> 30 </nav>
31 + <%
32 + var addr;
33 + %>
31 <div class="container px-5 my-5"> 34 <div class="container px-5 my-5">
32 <h1><%= title %></h1> 35 <h1><%= title %></h1>
33 - <form action="/board/write" method="post"> 36 + <%
37 + switch(title){
38 + case '공지사항 글 쓰기':
39 + addr = 'notice';
40 + break;
41 + case '작곡가 구인 글 쓰기':
42 + addr = 'composer';
43 + break;
44 + case '가수 구인 글 쓰기':
45 + addr = 'singer';
46 + break;
47 + case '자유게시판 글 쓰기':
48 + addr = 'free';
49 + break;
50 + case '건의사항 글 쓰기':
51 + addr = 'suggestion';
52 + break;
53 + %>
54 + <%
55 + }
56 + %>
57 + <form action="/board/write/<%=addr%>" method="post">
34 58
35 <table border="1"> 59 <table border="1">
36 <tr> 60 <tr>
......