Mukho

Fix Bug and Update DB

......@@ -9,7 +9,7 @@ module.exports=function(){
port:'3306',
user:'root',
password:'',
database:'userdb'
database:'singer_composer'
// host:config.host,
// port:config.port,
// user:config.user,
......
......@@ -5,7 +5,7 @@ module.exports=(function(){
port:'3306',
user:'root',
password:'',
database:'userdb'
database:'singer_composer'
},
example: {
host: '',
......
......@@ -40,38 +40,7 @@
<div class="text-center text-white">
<!-- Page heading-->
<h1 class="mb-5">묵호가 만든 놀이터다. 작곡가와 가수가 서로 연결되는데 그 목적이 있다.</h1>
<!-- Signup form-->
<!-- * * * * * * * * * * * * * * *-->
<!-- * * SB Forms Contact Form * *-->
<!-- * * * * * * * * * * * * * * *-->
<!-- This form is pre-integrated with SB Forms.-->
<!-- To make this form functional, sign up at-->
<!-- https://startbootstrap.com/solution/contact-forms-->
<!-- to get an API token!-->
<form class="form-subscribe" id="contactForm" data-sb-form-api-token="API_TOKEN">
<!-- ID input-->
<div class="row">
<div class="row">
<a class="btn btn-primary" href="/board/list">임시게시판</a>
</div>
</div>
<!-- Submit success message-->
<!---->
<!-- This is what your users will see when the form-->
<!-- has successfully submitted-->
<div class="d-none" id="submitSuccessMessage">
<div class="text-center mb-3">
<div class="fw-bolder">Form submission successful!</div>
<p>To activate this form, sign up at</p>
<a class="text-white" href="https://startbootstrap.com/solution/contact-forms">https://startbootstrap.com/solution/contact-forms</a>
</div>
</div>
<!-- Submit error message-->
<!---->
<!-- This is what your users will see when there is-->
<!-- an error submitting the form-->
<div class="d-none" id="submitErrorMessage"><div class="text-center text-danger mb-3">Error sending message!</div></div>
</form>
<iframe width="560" height="315" src="https://www.youtube.com/embed/wgbr7exUnzE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
</div>
......
......@@ -23,17 +23,26 @@ DB 구조(*ID, password, type) -> 형식에 맞게 추가<br>
추가된 형식에 맞는 로그인 및 세션 등 변경<br>
alter table userDB add nickname varchar(20) not null;<br>
CREATE TABLE `board` (
`idx` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`title` varchar(50) NOT NULL,
`content` mediumtext NOT NULL,
`regdate` datetime NOT NULL,
`modidate` datetime NOT NULL,
`passwd` varchar(50) NOT NULL,
`hit` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`idx`)
);<br><br>
Database = singer_composer
create table userdb(
ID varchar(20) not null primary key,
password varchar(20) not null,
type varchar(10) not null,
nickname varchar(20) not null,
profilemsg varchar(300)
)engine=innodb;
create table board(
idx int not null primary key auto_increment,
name varchar(50) not null,
title varchar(50) not null,
content mediumtext not null,
regdate datetime not null,
modidate datetime not null,
passwd varchar(50) not null,
hit int not null
)engine=innodb;<br><br>
DB구조 - board에서 사용됨(*idx, name, title, content, regdate, modidate, passwd, hit)<br>
*idx int, name varchar(50), title varchar(50), content mediumtext, regdate datetime, modidate datetime, passwd varchar(50), hit int<br>
......@@ -42,6 +51,6 @@ DB구조 - board에서 사용됨(*idx, name, title, content, regdate, modidate,
LF 오류시 git config --global core.autocrlf true 입력<br><br>
최종 수정: 2021-11-19 12:19<br>
최종 수정 내용: 메뉴바/하단 추가, 게시판에 기본 서식 추가, 로그인시에만 게시판 관련 경로에 접근가능하게 함, 사용자 로그 생성<br>
최종 수정: 2021-11-19 02:23<br>
최종 수정 내용: 프로필 추가, 메뉴바/하단 추가, 게시판에 기본 서식 추가, 로그인시에만 게시판 관련 경로에 접근가능하게 함, 사용자 로그 생성<br>
수정 내용: 경로 지정 수정, 제목 추가, userDB, 회원가입에 nickname요소 추가, 세션에 ID + 닉네임 전달기능 추가, 게시판의 글쓰기 및 글 열람 기능 추가.
......
......@@ -15,11 +15,7 @@ router.get('/list/:page', function(req, res, next) {
else{
var page = req.params.page;
var sql = "select idx, name, title, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
<<<<<<< HEAD
"date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate from userdb.board";
=======
"date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate,hit from board";
>>>>>>> c29f2a5d1c3813d7d5c357acc015b4d40a6e701d
"date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit from board";
board.query(sql, function(err,rows) {
if (err) console.error("err : " + err);
......@@ -31,7 +27,6 @@ router.get('/list/:page', function(req, res, next) {
}
});
router.get('/list', function(req,res,next){
var id = req.user;
if(!id) res.sendFile(path.join(__dirname, "../../public/login.html"))
......@@ -56,7 +51,7 @@ router.post('/write', function(req,res,next){
var passwd = req.body.passwd
var datas = [name,title,content,passwd]
var sql = "insert into board(name, title, content, regdate, modidate, passwd,hit) values(?,?,?,now(),now(),?,0)";
var sql = "insert into board(name, title, content, regdate, modidate, passwd, hit) values(?,?,?,now(),now(),?,0)";
board.query(sql,datas, function (err, rows) {
if (err) console.error("err : " + err);
......@@ -70,7 +65,7 @@ router.post('/write', function(req,res,next){
router.get('/read/:idx', function(req,res,next){
var idx = req.params.idx
var sql = "select idx, name, title, content, date_format(modidate,'%Y-%m-%d %H:%i:%s') modidate, " +
"date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate,hit from userdb.board where idx=?";
"date_format(regdate,'%Y-%m-%d %H:%i:%s') regdate, hit from board where idx=?";
board.query(sql,[idx], function(err,row){
if(err) console.error(err)
......
......@@ -12,7 +12,7 @@ var connection = mysql.createConnection({
port : 3306,
user: 'root',
password : '',
database : 'userDB'
database : 'singer_composer'
})
connection.connect();
......
......@@ -15,23 +15,23 @@ router.get('/', function(req, res){
myinfo.query(sql,[id],function(err,rows) {
if (err) console.error("err : " + err);
var nickname = req.user.nickname;
var job = rows[0].type;
var type = rows[0].type;
var profilemsg = rows[0].profilemsg;
console.log(req.user.ID+'('+nickname+') 유저가 myProfile을 보고있습니다.')
res.render('profile.ejs', {'ID':id, 'nickname': nickname, 'profilemsg': profilemsg, 'job': job})
console.log(req.user.ID+'('+nickname+') 유저가 프로필을 보고있습니다.')
res.render('profile.ejs', {'ID':id, 'nickname': nickname, 'profilemsg': profilemsg, 'type': type})
})
}
});
router.get('/update', function(req,res){
var sql = "select profilemsg from userdb";
var sql = 'select profilemsg from userdb where id ="'+req.user.ID+'"';
myinfo.query(sql, function(err,rows) {
if (err) console.error("err : " + err);
var id = req.user.ID;
var nickname = req.user.nickname;
var profilemsg = rows[0].profilemsg;
res.render('profmsgedit.ejs', {'ID':id, 'nickname': nickname, 'profilemsg':profilemsg});
res.render('profmsgedit.ejs', {'ID':id, 'nickname': nickname, 'profilemsg': profilemsg});
})
})
......@@ -46,6 +46,8 @@ router.post('/update', function(req,res,next){
var sql = "update userdb set profilemsg =?, nickname=?, type=? where id =?"
myinfo.query(sql,datas,function(err,result){
if(err) console.error(err)
console.log(req.user.ID+'('+nickname+') 유저가 프로필을 수정했습니다.')
res.redirect('/profile')
})
})
......
......@@ -12,7 +12,7 @@ var connection = mysql.createConnection({
port : 3306,
user: 'root',
password : '',
database : 'userDB'
database : 'singer_composer'
})
connection.connect();
......
......@@ -27,7 +27,7 @@
<li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li>
</ul>
<div class="user">
<a> <%= nickname %> 님 안녕하세요 </section></a>
<a href = "/profile"> <%=nickname%></a><a>님 안녕하세요</a>
<a class="btn btn-primary" href="/logout">로그아웃</a>
</div>
</div>
......@@ -44,9 +44,9 @@
<td>등록일</td>
</tr>
<%
for(var i = (page * page_num) - page_num; i < (page * page_num); i++) {
if(i > length){
i++;
for(var i = (page * page_num)-1; i >= (page * page_num) - page_num; i--) {
if(i >= length){
i--;
}else{
var data = rows[i]
%>
......
......@@ -27,7 +27,7 @@
<li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li>
</ul>
<div class="user">
<a href = "/profile"> <%=nickname%></a><a>님 안녕하세요 </a>
<a href = "/profile"> <%=nickname%></a><a>님 안녕하세요</a>
<a class="btn btn-primary" href="/logout">로그아웃</a>
</div>
</div>
......@@ -40,36 +40,7 @@
<div class="text-center text-white">
<!-- Page heading-->
<h1 class="mb-5">묵호가 만든 놀이터다. 작곡가와 가수가 서로 연결되는데 그 목적이 있다.</h1>
<!-- Signup form-->
<!-- * * * * * * * * * * * * * * *-->
<!-- * * SB Forms Contact Form * *-->
<!-- * * * * * * * * * * * * * * *-->
<!-- This form is pre-integrated with SB Forms.-->
<!-- To make this form functional, sign up at-->
<!-- https://startbootstrap.com/solution/contact-forms-->
<!-- to get an API token!-->
<form class="form-subscribe" id="contactForm" data-sb-form-api-token="API_TOKEN">
<!-- ID input-->
<div class="row">
<a class="btn btn-primary" href="/board/list">임시게시판</a>
</div>
<!-- Submit success message-->
<!---->
<!-- This is what your users will see when the form-->
<!-- has successfully submitted-->
<div class="d-none" id="submitSuccessMessage">
<div class="text-center mb-3">
<div class="fw-bolder">Form submission successful!</div>
<p>To activate this form, sign up at</p>
<a class="text-white" href="https://startbootstrap.com/solution/contact-forms">https://startbootstrap.com/solution/contact-forms</a>
</div>
</div>
<!-- Submit error message-->
<!---->
<!-- This is what your users will see when there is-->
<!-- an error submitting the form-->
<div class="d-none" id="submitErrorMessage"><div class="text-center text-danger mb-3">Error sending message!</div></div>
</form>
<iframe width="560" height="315" src="https://www.youtube.com/embed/wgbr7exUnzE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
</div>
......
......@@ -26,7 +26,7 @@
<li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li>
</ul>
<div class="user">
<a> <%= nickname %> 님 안녕하세요 </section></a>
<a href = "/profile"> <%=nickname%></a><a>님 안녕하세요</a>
<a class="btn btn-primary" href="/logout">로그아웃</a>
</div>
</div>
......@@ -41,7 +41,7 @@
<dt class = nic_tit>닉네임</dt>
<dd class = nic_ele><%=nickname%></dd>
<dt class = nic_tit>직종</dt>
<dd class = nic_ele><%=job%></dd>
<dd class = nic_ele><%=type%></dd>
<dt class = nic_tit>상태 메시지</dt>
<dd class = nic_ele><%=profilemsg%></dd>
</div>
......
......@@ -26,7 +26,7 @@
<li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li>
</ul>
<div class="user">
<a> <%= nickname %> 님 안녕하세요 </section></a>
<a href = "/profile"> <%=nickname%></a><a>님 안녕하세요</a>
<a class="btn btn-primary" href="/logout">로그아웃</a>
</div>
</div>
......
......@@ -24,7 +24,7 @@
<li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li>
</ul>
<div class="user">
<a> <%= nickname %> 님 안녕하세요 </section></a>
<a href = "/profile"> <%=nickname%></a><a>님 안녕하세요</a>
<a class="btn btn-primary" href="/logout">로그아웃</a>
</div>
</div>
......
......@@ -23,7 +23,7 @@
<li><a href="#" class="nav-link px-2 link-dark">???(미구현)</a></li>
</ul>
<div class="user">
<a> <%= nickname %> 님 안녕하세요 </section></a>
<a href = "/profile"> <%=nickname%></a><a>님 안녕하세요</a>
<a class="btn btn-primary" href="/logout">로그아웃</a>
</div>
</div>
......