기본 콘텐츠로 건너뛰기

node.js 홈페이지 구축

node.js를 이용한 홈페이지 구축을 해보자...

하하 물론 node.js는 얼추 보긴 했는데 
문제는 웹 페이지 제작 능력이 완전 바닥 그냥
깡으로 만들어 봐야겠다 ㅋㅋㅋㅋㅋㅋ 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="ko" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>멍개님의 Home Page입니다</title>
<style type="text/css">
.auto-style1 {
    font-size: xx-large;
}
.auto-style2 {
    margin-left: 15px;
}
.auto-style3 {
    border-style: solid;
    border-width: 2px;
}
.auto-style4 {
    margin-left: 100px;
}
</style>
<script>
    alert('멍개의 페이지 오신것을 환영합니다. ㅎㅎ');
</script>
<script>
    $(.auto_style).click(function(){
        alert('asd');
        });
</script>
</head>
<body>
<form method="post">
<p class="auto-style1"><strong><a href="file:///F:/bird%20모음/frog.png">
<img alt="" class="auto-style3" height="57" src="frog_small.png" width="100" /><!-- MSComment="autothumbnail" xthumbnail-orig-image="file:///F:/bird 모음/frog.png" --></a>멍개 
Home                              
</strong><input name="login_id" style="width: 132px; height: 31px" value="id" /> <strong><input name="login_pass" style="width: 132px; height: 31px" type="text" value="password" /></strong>
<strong>
<input class="auto-style2" name="submit1" style="width: 55px" type="submit" value="login" /> </strong>
<input name="submit" type="submit" value="회원가입" /></form>
 </p>
<p>
<input class="auto-style4" name="Button1" style="width: 92px" type="button" value="게시판" /></p>
<form method="post">
</form>
</body>
</html>
cs
`

cs
일단 그냥 웹 페이지를 제작을 해볼려고 한다. 우선 node로 로그인 기능을 넣어보아야 겠다 
머라도 만들어 봐야 실력이 빠르게 늘 것 같다.

 
기본적으로 페이지는 이런식으로 구상을 하려고 한다.

일단은 로그인 기능을 만들어야 겠다
로그인 소스는 어디선가 구해놓은게 있다 으하핳 ㅋㅋㅋㅋ


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(document).ready(function(){
    // 삭제
    $('#btn_remove').on('click',function(){
        var ck = new Array();
        $('.ck:checked').each(function(index,item){
            ck.push($(item).val());
        });
        $.ajax({
            url:'/remove',
            type:'GET',
            data:{ck:ck},
            success:function(data){
                alert(data+'삭제');
                $('#btn_list').trigger('click');
            }
        });
    });
    // 수정
    $('#btn_add').on('click',function(){
        var id = $('#id').val();
        var pw = $('#pw').val();
        var name = $('#name').val();
        var age = $('#age').val();
        var gender = $('#gender').val();
        $.ajax({
            url:'/add',
            type:'POST',
            data:{id:id,pw:pw,name:name,age:age,gender:gender},
            success:function(data){
                alert(data+'님 추가');
                $('#btn_list').trigger('click');
            }
        });
    });
    // 추가
    $('#btn_modify').on('click',function(){
        var id = $('#id').val();
        var pw = $('#pw').val();
        var name = $('#name').val();
        var age = $('#age').val();
        var gender = $('#gender').val();
        $.ajax({
            url:'/modifyById',
            type:'POST',
            data:{id:id,pw:pw,name:name,age:age,gender:gender},
            success:function(data){
                alert(data+'님 수정');
                $('#btn_list').trigger('click');
            }
        });
    });
    // 목록
    $('#btn_list').on('click',function(){
        $.ajax({
            url:'/list',
            type:'GET',
            success:function(data){
                $('#list').empty();
                $(data).each(function(index,item){
                    $('#list').append('<tr>');
                    $('#list').append('<td><input type="checkbox" class="ck" value="'+item.id+'"></td>');
                    $('#list').append('<td>'+item.id+'</td>');
                    $('#list').append('<td>'+item.pw+'</td>');
                    $('#list').append('<td>'+item.name+'</td>');
                    $('#list').append('<td>'+item.age+'</td>');
                    $('#list').append('<td>'+item.gender+'</td>');
                    $('#list').append('</tr>');
                });
            }
        });
    });
});
</script>
</head>
<body>
    <table border="1">
        <thead>
            <tr>
                <th>id</th>
                <th>pw</th>
                <th>name</th>
                <th>age</th>
                <th>gender</th>
                <th>추가</th>
                <th>수정</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><input type="text" id="id"></td>
                <td><input type="password" id="pw"></td>
                <td><input type="text" id="name"></td>
                <td><input type="text" id="age"></td>
                <td>
                    <select id="gender">
                        <option value="m"></option>
                        <option value="f"></option>
                    </select>
                </td>
                <td><button id="btn_add">add</button></td>
                <td><button id="btn_modify">modify</button></td>
            </tr>
        </tbody>
    </table>
    <button id="btn_list">회원리스트</button>
    <table border="1">
        <thead>
            <tr>
                <th></th>
                <th>id</th>
                <th>pw</th>
                <th>name</th>
                <th>age</th>
                <th>gender</th>
            </tr>
        </thead>
        <tbody id="list">
        </tbody>
    </table>
    <button id="btn_remove">remove</button>
</body>
</html>
cs
클라이언트 측 소스파일

 
이런게 되어져 있다.

일단 크게잡으면 메인 페이지에서 회원가입을 누르면 이 페이지로 넘어오게 해야겠다.

그전에 회원가입을 했을때 이 데이터가 저장될 DB Table을 만들어야 겠다.

 
DB 테이블은 잘 만들었다.
 
기본적으로 값을 그냥 넣어봤다 

어디선가 주어온 소스 내용에 맞춰서 디비를 만들었다.
DB 생성 끝
회원가입 페이지로 넘어가면 이 DB에서 자료를 꺼냈다 뺐다가 해야겠군..

이 두개의 페이지를 어떤식으로 연결을 시킬것인가.......

 
대충 이런식으로 구성 할 생각....

채팅은 기본적으로 구성은 해뒀고

웹 게임을 제작을 해보고 싶은데 어떤 웹 게임을 만들지..... 
흠...........

로그인 부분만 구현 끝나면 게시판이랑 채팅부분은 금방 구현할거 같은데

웹게임이 문제네

moon_and_james-26 

댓글

이 블로그의 인기 게시물

[git] git log 확인하기

git log를 통해서 커밋 이력과 해당 커밋에서 어떤 작업이 있었는지에 대해 조회를 할 수 있다. 우선 git에서의 주요 명령어부터 알아보겠다. $ git push [branch name] $ git pull [branch name] 여기서 branch name은 로컬일 경우 해당 브런치 이름만 적으면 되지만 깃허브 원격 저장소로 연결을 원할 경우는 해당 브런치 이름 앞에 꼭 origin을 붙이도록 한다. $ git brnch [branch name] $ git checkout [branch name] branch일경우 해당 브런치를 생성을 한다. 여기서 현재의 브런치를 기준으로 브런치를 따는것이다. checkout은 브런치를 바꾸는 것이다.(HEAD~[숫자]를 이용하면 해당 커밋으로 움직일수 있다.. 아니면 해당 커밋 번호를 통해 직접 옮기는것도 가능하다.) -> 해당 커밋으로 옮기는 것일뿐 실질적으로 바뀌는 것은 없다. 해당 커밋으로 완전히 되돌리려면 reset이라는 명령어를 써야한다. 처음 checkout을 쓰면 매우 신기하게 느껴진다. 막 폴더가 생겼다가 지워졌다가 ㅋㅋㅋㅋㅋ  master 브런치에서는 ht.html파일이 존재하지만 a브런치에서는 존재하지않는다. checkout 으로 변경을 하면 D 로 명시를 해준다.  $ git log 해당 브런치의 커밋 내역을 보여준다. a 브런치의 커밋 내역들이다. (머지 테스트를 하느라 커밋 내용이 거의 비슷하다 ㅋㅋ) master 브런치의 커밋 내역들이다. 커밋 번호, 사용자, 날짜, 내용순으로 등장을 한다. 이건 단순히 지금까지의 내역을 훑어보기 좋다. 좀더 세밀한 내용을 봐보자. $ git log --stat --stat을 붙이면 기존의 로그에서 간략하게 어떤 파일에서

[git] pull을 하여 최신코드를 내려받자

보면 먼가 로고가 다르게 뜨는것을 확인을 할 수가있다. C:\Users\mung\Desktop\etc\study\python-gene>git checkout remotes/origin/master Note: checking out 'remotes/origin/master'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:   git checkout -b HEAD is now at 29e282a... fetch test C:\Users\mung\Desktop\etc\study\python-gene>git branch * (HEAD detached at origin/master)   master   test1   test2 깃이 잘 쓰면 참 좋은놈인데 어지간히 쓰기가 까다롭다. 처음에 깃을 푸시 성공하는데만 한달정도 걸렸던걸로 기억이 난다.. ㅋㅋㅋ 여담으로  깃 프로필을 가면 아래사진 처럼 보인다. 기여도에 따라서 초록색으로 작은 박스가 채워지는데 저걸 잔디라고 표현을 한다고 합니다 ㅎ 저 사진은 제 깃 기여도 사진입니당 ㅋㅋㅋㅋ 다시 본론으로 돌아와서 ㅋㅋ pull을 하면 깃에 최신 소

[kali linux] sqlmap - post요청 injection 시도

아래 내용은 직접 테스트 서버를 구축하여 테스트 함을 알립니다.  실 서버에 사용하여 얻는 불이익에는 책임을 지지 않음을 알립니다. sqlmap을 이용하여 get요청이 아닌 post요청에 대해서 injection공격을 시도하자. 뚀한 다양한 플래그를 이용하여 DB 취약점 테스트를 진행을 해보려고 한다. 서버  OS : windows 7 64bit Web server : X Server engine : node.js Framework : expresss Use modules : mysql Address : 172.30.1.30 Open port : 6000번 공격자 OS : kali linux 64bit use tools : sqlmap Address : 172.30.1.57 우선 서버측 부터  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 var  express  =  require( 'express' ); var  app  =  express(); var  mysql  =  require( 'mysql' ); var  ccc  =  mysql.createConnection({     host: '127.0.0.1' ,     user: 'root' ,     post: '3306' ,     password: '*********' ,     database: 'test' }) app.post(