Repository navigation
Minsung03 working #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
minsung03
wants to merge
13
commits into
minsung03
Choose a base branch
from
minsung03_working
base: minsung03
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
028bb9b
2020-10-06
minsung03 dfe6a66
feat: 로그인/회원가입 기능 추가 완료
minsung03 a9bb0cd
feat: 불필요한 코드 제거
minsung03 e1aec58
2020-10-13
minsung03 a16ec35
feat: captcha 완료
minsung03 151bc0b
feat: search api 제작
minsung03 035cfb4
refactor: include에서 root path 추가
minsung03 89e9c5c
feat: search 작업 중
minsung03 a6b2e83
2020-10-16
minsung03 6973c65
2020-10-19
minsung03 be69079
feat: 프로필 페이지 제작중
minsung03 8006604
feat 프로필페이지 제작중
minsung03 d3fa26f
feat: 프로필 페이지 제작과 캡차 복붙 방지, 회원가입 리스트 수정
minsung03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| RewriteEngine On | ||
|
|
||
| RewriteRule ^([^.]+)$ index.php?param=$1 [QSA,L] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| <?php | ||
|
|
||
| switch ($_POST['action']) { | ||
|
|
||
| case 'login' : | ||
| [ | ||
| 'userid' => $userid, | ||
| 'password' => $pass, | ||
| ] = $_POST; | ||
|
|
||
| $user = fetch("SELECT * FROM users WHERE id = ? AND password = password(?)", [$userid, $pass]); | ||
|
|
||
| access($user, "아이디 또는 비밀번호가 잘못되었습니다."); | ||
|
|
||
| $_SESSION['user'] = $user; | ||
| alert('로그인 되었습니다.'); | ||
| move('/'); | ||
|
|
||
| break; | ||
|
|
||
| case 'join' : | ||
| [ | ||
| 'userid' => $userid, | ||
| 'password' => $pass, | ||
| 'password_chk' => $passchk, | ||
| 'username' => $username | ||
| ] = $_POST; | ||
|
|
||
| access($userid !== "" && $pass !== "" && $username !== "", "빈칸이 존재합니다."); | ||
| access($pass == $passchk, "비밀번호 재입력의 값이 잘못되었습니다."); | ||
|
|
||
| $sql = "INSERT INTO users(`id`, `name`, `password`) VALUES (?, ?, PASSWORD(?))"; | ||
|
|
||
| access(execute($sql, [$userid, $username, $pass]), "DB 에러"); | ||
|
|
||
| alert("회원가입 완료."); | ||
| move("./login"); | ||
|
|
||
| break; | ||
|
|
||
| default: break; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?php | ||
|
|
||
| echo $_POST["search"]; | ||
|
|
||
| switch($_POST['search']){ | ||
| case "search": | ||
| [ | ||
| 'searchbox' => $searchbox, | ||
| 'searchbtn' => $searchbtn, | ||
| ] = $_POST; | ||
|
|
||
| $user = fetchAll("INSERT INTO users(`id`, `name`) VALUES(?,?)", [$searchbox]); | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <?php | ||
| $result = fetchAll("SELECT `id`, `name` FROM users WHERE id LIKE ?", ["%{$_GET['q']}%"]); | ||
| echo json_encode($result); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?php | ||
| $param = isset($_GET['param']) ? explode("/", $_GET['param']) : []; | ||
| $page = $param[0] ?? NULL; | ||
| $action = $param[1] ?? NULL; | ||
| $idx = $param[2] ?? NULL; | ||
| $include_file = $action ?? $page; | ||
|
Comment on lines
+2
to
+6
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extract함수를 사용해 보는 것은 어떨까요?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 참고해보도록 하겠습니당 |
||
|
|
||
| if (isset($_POST['action'])) { | ||
| include_once(HOME . "/actions/{$page}.php"); | ||
| exit; | ||
| } | ||
|
|
||
| if ($page === 'api') { | ||
| include_once(HOME . "/api/{$action}.php"); | ||
| exit; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <?php | ||
|
|
||
| function alert($msg) | ||
| { | ||
| echo "<script>alert('{$msg}');</script>"; | ||
| } | ||
|
|
||
| function move($url = false) | ||
| { | ||
| echo "<script>"; | ||
| echo $url ? "location.replace('{$url}');" : "history.back()"; | ||
| echo "</script>"; | ||
| exit; | ||
| } | ||
|
|
||
| function access($bool, $msg, $url = false) | ||
| { | ||
| if (!$bool) { | ||
| alert($msg); | ||
| move($url); | ||
| } | ||
| } | ||
|
|
||
| function execute($sql, $data = []) | ||
| { | ||
| $db = new PDO("mysql:host=localhost; dbname=member; charset=utf8mb4;", "root", ""); | ||
| $result = $db->prepare($sql); | ||
| $result->execute($data); | ||
| $db = null; | ||
| return $result; | ||
| } | ||
|
|
||
| function fetch($sql, $data = []) | ||
| { | ||
| return execute($sql, $data)->fetch(PDO::FETCH_OBJ); | ||
| } | ||
|
|
||
| function fetchAll($sql, $data = []) | ||
| { | ||
| return execute($sql, $data)->fetchAll(PDO::FETCH_OBJ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?php | ||
| session_start(); | ||
|
|
||
| define("HOME", __dir__); | ||
|
|
||
| include_once(HOME . "/core/lib.php"); | ||
| include_once(HOME . "/core/common.php"); | ||
|
|
||
|
|
||
| include_once(HOME . "/view/template/header.php"); | ||
| if (isset($include_file)) { | ||
| include_once(HOME . "/view/{$page}/{$include_file}.php"); | ||
| } else { | ||
| include_once(HOME . "/view/template/main.php"); | ||
| } | ||
| include_once(HOME . "/view/template/footer.php"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| const code = [ | ||
| 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T', | ||
| 'U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','r','j','k','l','m','n','o','p','q', 'r','s', | ||
| 't', 'u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9' | ||
| ]; | ||
|
|
||
| const getCaptchaString = () => Array(6) | ||
| .fill(0) | ||
| .map(() => Math.floor(Math.random() * code.length)) | ||
| .map(index => code[index]) | ||
| .join(''); | ||
|
|
||
| document.querySelector('#maincaptcha').value = getCaptchaString(); | ||
|
|
||
| if(document.getElementById("maincaptcha").length < 7){ | ||
| document.getElementById("maincaptcha").empty(); | ||
| } | ||
| // document.oncontextmenu = function() {return false}; | ||
| // document.ondragstart = function() {return false}; | ||
| // document.onselectstart = function() {return false}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| function friend_box(obj) { | ||
| let id = document.createElement("div"); | ||
| id.innerHTML = obj.id; | ||
| document.querySelector(".result").appendChild(id); | ||
|
|
||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| const form = document.getElementsByTagName("form")[0]; | ||
| form.addEventListener("submit", function (e) { | ||
| e.preventDefault(); | ||
|
|
||
| if (e.target.search.value != "" || e.target.search.value < -1) { | ||
| const url = `/api/search?q=${e.target.search.value}`; | ||
|
|
||
| let result = document.getElementsByClassName("result"); | ||
| fetch(url) | ||
| .then(res => res.json()) | ||
| .then(data => { | ||
| data?.forEach(item => { | ||
| friend_box(item); | ||
| }) | ||
| }); | ||
|
|
||
| } else alert("검색어를 입력해라"); | ||
|
|
||
| // const box = document.getElementById("searchbox").value; | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| <div class="userlist"></div> | ||
|
|
||
| <script src="/js/profile.js"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <!doctype html> | ||
| <html lang="ko"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" | ||
| content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
| <title>Document</title> | ||
| </head> | ||
| <body> | ||
| <ul> | ||
| <li><a href="/user/usersearch">사용자검색</a></li> | ||
| <li><a href="/user/friendlist">친구요청</a></li> | ||
| <li><a href="/">HOME</a></li> | ||
| <?php if (isset($_SESSION['user'])) { ?> | ||
| <li><?php echo $_SESSION['user']->name?>님 환영합니다.</li> | ||
| <li><a href="/user/logout">로그아웃</a></li> | ||
| <?php } else { ?> | ||
| <li><a href="/user/login">로그인</a></li> | ||
| <li><a href="/user/join">회원가입</a></li> | ||
| <?php } ?> | ||
| </ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 얼굴책 메인페이지입니다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| <div class="container"> | ||
| <h1>회원가입</h1> | ||
| <form method="post" action=""> | ||
| <fieldset> | ||
| <legend>회원가입 작성 폼</legend> | ||
| <input type="hidden" name="action" value="join"> | ||
| <div class="row"> | ||
| <div class="col-10 offset-1"> | ||
| <input type="hidden" name="action" value="join"/> | ||
| <div class="row"> | ||
| <label for="userid" class="col-sm-2col-form-label">Email</label> | ||
| <div class="col-sm-10"> | ||
| <input type="email" class="form-control" id="userid" name="userid" | ||
| placeholder="email을 입력하세요"> | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <label for="birth" class="col-sm-2col-form-label">BirthYear</label> | ||
| <div class="col-sm-10"> | ||
| <input type="text" class="form-control" id="birthYear" name="birth" | ||
| placeholder="생년월일을 입력해주세요"> | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <label for="password" class="col-sm-2col-form-label">Password</label> | ||
| <div class="col-sm-10"> | ||
| <input type="password" class="form-control" id="password" name="password" | ||
| placeholder="비밀번호를 입력하세요"> | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <label for="password_chk" class="col-sm-2col-form-label">Password Check</label> | ||
| <div class="col-sm-10"> | ||
| <input type="password" class="form-control" id="password_chk" name="password_chk" | ||
| placeholder="비밀번호를 확인해주세요"> | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <label for="captcha" class="col-sm-2col-form-label">Captcha</label> | ||
| <div class="col-sm-10"> | ||
| <input type="text" class="form-control" name="captcha" id="maincaptcha" oncontextmenu="return false" ondragstart="return false" readonly> | ||
| <div id="log"></div> | ||
| <input type="text" class="form-control" id="captcha" | ||
| placeholder="자동입력방지문자를 입력해주세요"> | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <label for="username" class="col-sm-2col-form-label">Username</label> | ||
| <div class="col-sm-10"> | ||
| <input type="text" class="form-control" name="username" id="username"> | ||
| </div> | ||
| </div> | ||
| <div class="row"> | ||
| <div class="col-sm-10"> | ||
| <button type="submit" class="btn btn-primary">회원가입</button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </fieldset> | ||
| </form> | ||
| </div> | ||
| <script src="/js/captcha.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <div class="container"> | ||
| <h1>로그인</h1> | ||
| <div class="container"> | ||
| <form method="post" action=""> | ||
| <fieldset> | ||
| <legend>로그인 폼 작성</legend> | ||
| <input type="hidden" name="action" value="login"> | ||
| <div class="row"> | ||
| <div class="col-10 offset-1"> | ||
| <div class="form-group"> | ||
| <label for="userid">Email</label> | ||
| <input type="email" class="form-control" id="userid" name="userid"> | ||
| </div> | ||
| <div class="form-group"> | ||
| <label for="password">Password</label> | ||
| <input type="password" class="form-control" id="password" name="password"> | ||
| </div> | ||
| <button type="submit" class="btn btn-primary">로그인</button> | ||
| </div> | ||
| </div> | ||
| </fieldset> | ||
| </form> | ||
| </div> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| <?php | ||
| session_destroy(); | ||
| alert('로그아웃 되었습니다.'); | ||
| move('/'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <form method="post" action="../../actions/userSearch.php"> | ||
| <label for="search"></label> | ||
| <label for="plusfr"></label> | ||
| <div class="usersearch"> | ||
| <input type="hidden" name="action" value="search"> | ||
| <input type="text" name="search" class="form-control" id="searchbox" placeholder="사용자 검색..."> | ||
| </div> | ||
| <button type="submit" class="searchbtn">검색</button> | ||
| </form> | ||
| <div class="result"></div> | ||
| <script src="/js/profile.js"></script> | ||
| <script src="/js/usersearch.js"></script> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$_POST에 넘어온 값을 풀어서 변수에 담는걸로 보이는데 맞나요?
맞다면 자바스크립트의 구조분해할당과 같은 역할을 하는 건가요?