From 028bb9be42d8339aa37cf1ecb31bea313bb154b7 Mon Sep 17 00:00:00 2001 From: minsung03 Date: Tue, 6 Oct 2020 19:01:03 +0900 Subject: [PATCH 01/13] 2020-10-06 --- .htaccess | 5 +++ autoload.php | 18 +++++++++ public/index.php | 14 +++++++ src/App/DB.php | 34 ++++++++++++++++ src/App/Library.php | 12 ++++++ src/App/Route.php | 33 +++++++++++++++ src/App/View.php | 13 ++++++ src/Controller/MainController.php | 14 +++++++ src/Controller/MasterController.php | 13 ++++++ src/Controller/UserController.php | 63 +++++++++++++++++++++++++++++ src/Views/User/common.css | 3 ++ src/Views/User/join.php | 49 ++++++++++++++++++++++ src/Views/User/login.php | 41 +++++++++++++++++++ src/Views/layout/foooter.php | 2 + src/Views/layout/header.php | 34 ++++++++++++++++ src/Views/layout/main.php | 2 + web.php | 14 +++++++ 17 files changed, 364 insertions(+) create mode 100644 .htaccess create mode 100644 autoload.php create mode 100644 public/index.php create mode 100644 src/App/DB.php create mode 100644 src/App/Library.php create mode 100644 src/App/Route.php create mode 100644 src/App/View.php create mode 100644 src/Controller/MainController.php create mode 100644 src/Controller/MasterController.php create mode 100644 src/Controller/UserController.php create mode 100644 src/Views/User/common.css create mode 100644 src/Views/User/join.php create mode 100644 src/Views/User/login.php create mode 100644 src/Views/layout/foooter.php create mode 100644 src/Views/layout/header.php create mode 100644 src/Views/layout/main.php create mode 100644 web.php diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..efea1f1 --- /dev/null +++ b/.htaccess @@ -0,0 +1,5 @@ +RewriteEngine On + +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^(.+)$ index.php/$1 [QSA,L] \ No newline at end of file diff --git a/autoload.php b/autoload.php new file mode 100644 index 0000000..51f799b --- /dev/null +++ b/autoload.php @@ -0,0 +1,18 @@ +prepare($sql); + $query->execute($data); + return $query->fetch($mode); + } + + public static function fetchAll($sql, $data = [], $mode = \PDO::FETCH_OBJ) + { + $query = self::getDB()->prepare($sql); + $query->execute($data); + return $query->fetchAll($mode); + } + public static function lastId() + { + return self::getDB()->lastInsertId(); + } +} \ No newline at end of file diff --git a/src/App/Library.php b/src/App/Library.php new file mode 100644 index 0000000..0540d0a --- /dev/null +++ b/src/App/Library.php @@ -0,0 +1,12 @@ +$css, 'msg'=>$msg]; + header("Location: " . $target); + } + } +?> \ No newline at end of file diff --git a/src/App/Route.php b/src/App/Route.php new file mode 100644 index 0000000..a039309 --- /dev/null +++ b/src/App/Route.php @@ -0,0 +1,33 @@ +{$action[1]}(); + return; + } + } + echo "잘못된 접근!"; + } +} \ No newline at end of file diff --git a/src/App/View.php b/src/App/View.php new file mode 100644 index 0000000..c9bf939 --- /dev/null +++ b/src/App/View.php @@ -0,0 +1,13 @@ +'Hello World']; + $this->render("main",$datas); + } +} \ No newline at end of file diff --git a/src/Controller/MasterController.php b/src/Controller/MasterController.php new file mode 100644 index 0000000..cb40038 --- /dev/null +++ b/src/Controller/MasterController.php @@ -0,0 +1,13 @@ +render("User/join"); + } + + public function registerProcess() + { + $userid = $_POST["userid"]; + $pass = $_POST["password"]; + $passchk =$_POST["passwordchk"]; + $username = $_POST["username"]; + + if($userid == "" || $pass == "" || $username = ""){ + Library::msgAndGo("입력하지 않은곳이 있습니다.", "../User/join"); + return; + } + if($pass != $passchk){ + Library::msgAndGo("비밀번호가 일치하지 않습니다.", "/User/join"); + return; + } + $sql = "INSERT INTO users(`id`, `name`, `password`, `level`) VALUES (?, ?, PASSWORD(?), ?)"; + + $result = DB::execute($sql, [$userid, $username, $pass, 1]); + + if($result != 1){ + Library::msgAndGo("올바른 값이 안들어갔습니다.", "../User/join"); + return; + } + Library::msgAndGo("회원가입이 완료됨. 로그인 바람.", "../User/login", "success"); + return; + } + } + + public function loginprocess(){ + $userid = $_POST["userid"]; + $pass = $_POST["password"]; + $sql = "SELECT * FROM users WHERE id = ? AND password = PASSWORD(?)"; + $user = DB::fetch($sql, [$userid, $pass]); + + if($user == null){ + Library::msgAndGo("비밀번호가 달라!", "../User/login"); + return; + } + $_SESSION["user"] = $user; + Library::msgAndGo("로그인 되었다!", "/", "success"); + return; + } + public function logout() + { + unset($_SESSION["user"]); + Library::msgAndGo("로그아웃 되었습니다.", "/", "success"); + return; + } +} \ No newline at end of file diff --git a/src/Views/User/common.css b/src/Views/User/common.css new file mode 100644 index 0000000..45fcffc --- /dev/null +++ b/src/Views/User/common.css @@ -0,0 +1,3 @@ +.container{display: flex; justify-content: center;} +.row{ line-height: 50px; } +.my-3{text-align: center; } \ No newline at end of file diff --git a/src/Views/User/join.php b/src/Views/User/join.php new file mode 100644 index 0000000..1b4d088 --- /dev/null +++ b/src/Views/User/join.php @@ -0,0 +1,49 @@ + + + + + + 얼굴책 가입 + + + +
+
+

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+
+
+ + \ No newline at end of file diff --git a/src/Views/User/login.php b/src/Views/User/login.php new file mode 100644 index 0000000..afa1b85 --- /dev/null +++ b/src/Views/User/login.php @@ -0,0 +1,41 @@ + + + + + + 얼굴책 로그인 + + + +
+
+

로그인

+
+
+
+ + +
+
+ + +
+ +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/Views/layout/foooter.php b/src/Views/layout/foooter.php new file mode 100644 index 0000000..691287b --- /dev/null +++ b/src/Views/layout/foooter.php @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/src/Views/layout/header.php b/src/Views/layout/header.php new file mode 100644 index 0000000..e50c91f --- /dev/null +++ b/src/Views/layout/header.php @@ -0,0 +1,34 @@ + + + + + + + + Document + + +
+
+ +
+ +
out"> + +
+ + +
+ +
+ + 로그아웃 +
+ +
+ 회원가입 + 로그인 +
+ + + \ No newline at end of file diff --git a/src/Views/layout/main.php b/src/Views/layout/main.php new file mode 100644 index 0000000..b34b38c --- /dev/null +++ b/src/Views/layout/main.php @@ -0,0 +1,2 @@ +

+

메인페이지입니다.

\ No newline at end of file diff --git a/web.php b/web.php new file mode 100644 index 0000000..2daa56b --- /dev/null +++ b/web.php @@ -0,0 +1,14 @@ + Date: Wed, 7 Oct 2020 15:00:28 +0900 Subject: [PATCH 02/13] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8/?= =?UTF-8?q?=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EC=99=84=EB=A3=8C=20-=20MVC=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .htaccess | 4 +- MVC/.htaccess | 5 ++ autoload.php => MVC/autoload.php | 0 {public => MVC/public}/index.php | 0 {src => MVC/src}/App/DB.php | 14 ++--- MVC/src/App/Library.php | 29 +++++++++++ {src => MVC/src}/App/Route.php | 0 {src => MVC/src}/App/View.php | 0 .../src}/Controller/MainController.php | 0 .../src}/Controller/MasterController.php | 0 .../src}/Controller/UserController.php | 1 + {src => MVC/src}/Views/User/join.php | 42 ++++++++++++--- {src => MVC/src}/Views/User/login.php | 28 +++++----- {src => MVC/src}/Views/layout/foooter.php | 0 {src => MVC/src}/Views/layout/header.php | 0 {src => MVC/src}/Views/layout/main.php | 0 web.php => MVC/web.php | 2 +- actions/user.php | 42 +++++++++++++++ core/common.php | 11 ++++ core/lib.php | 41 +++++++++++++++ index.php | 16 ++++++ src/App/Library.php | 12 ----- src/Views/User/common.css | 3 -- view/template/footer.php | 2 + view/template/header.php | 20 ++++++++ view/template/main.php | 1 + view/user/join.php | 51 +++++++++++++++++++ view/user/js/captcha.js | 0 view/user/login.php | 24 +++++++++ view/user/logout.php | 4 ++ 30 files changed, 306 insertions(+), 46 deletions(-) create mode 100644 MVC/.htaccess rename autoload.php => MVC/autoload.php (100%) rename {public => MVC/public}/index.php (100%) rename {src => MVC/src}/App/DB.php (63%) create mode 100644 MVC/src/App/Library.php rename {src => MVC/src}/App/Route.php (100%) rename {src => MVC/src}/App/View.php (100%) rename {src => MVC/src}/Controller/MainController.php (100%) rename {src => MVC/src}/Controller/MasterController.php (100%) rename {src => MVC/src}/Controller/UserController.php (99%) rename {src => MVC/src}/Views/User/join.php (62%) rename {src => MVC/src}/Views/User/login.php (93%) rename {src => MVC/src}/Views/layout/foooter.php (100%) rename {src => MVC/src}/Views/layout/header.php (100%) rename {src => MVC/src}/Views/layout/main.php (100%) rename web.php => MVC/web.php (99%) create mode 100644 actions/user.php create mode 100644 core/common.php create mode 100644 core/lib.php create mode 100644 index.php delete mode 100644 src/App/Library.php delete mode 100644 src/Views/User/common.css create mode 100644 view/template/footer.php create mode 100644 view/template/header.php create mode 100644 view/template/main.php create mode 100644 view/user/join.php create mode 100644 view/user/js/captcha.js create mode 100644 view/user/login.php create mode 100644 view/user/logout.php diff --git a/.htaccess b/.htaccess index efea1f1..0ce0dcb 100644 --- a/.htaccess +++ b/.htaccess @@ -1,5 +1,3 @@ RewriteEngine On -RewriteCond %{REQUEST_FILENAME} !-d -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^(.+)$ index.php/$1 [QSA,L] \ No newline at end of file +RewriteRule ^([^.]+)$ index.php?param=$1 [QSA,L] \ No newline at end of file diff --git a/MVC/.htaccess b/MVC/.htaccess new file mode 100644 index 0000000..efea1f1 --- /dev/null +++ b/MVC/.htaccess @@ -0,0 +1,5 @@ +RewriteEngine On + +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^(.+)$ index.php/$1 [QSA,L] \ No newline at end of file diff --git a/autoload.php b/MVC/autoload.php similarity index 100% rename from autoload.php rename to MVC/autoload.php diff --git a/public/index.php b/MVC/public/index.php similarity index 100% rename from public/index.php rename to MVC/public/index.php diff --git a/src/App/DB.php b/MVC/src/App/DB.php similarity index 63% rename from src/App/DB.php rename to MVC/src/App/DB.php index cc079b9..a61b502 100644 --- a/src/App/DB.php +++ b/MVC/src/App/DB.php @@ -17,15 +17,17 @@ private static function getDB() public static function execute($sql, $data = []) { $query = self::getDB()->prepare($sql); - $query->execute($data); - return $query->fetch($mode); + return $query->execute($data); } - public static function fetchAll($sql, $data = [], $mode = \PDO::FETCH_OBJ) + public static function fetch($sql, $data = []) { - $query = self::getDB()->prepare($sql); - $query->execute($data); - return $query->fetchAll($mode); + return self::execute($sql, $data)->fetch(\PDO::FETCH_OBJ); + } + + public static function fetchAll($sql, $data = []) + { + return self::execute($sql, $data)->fetchAll(\PDO::FETCH_OBJ); } public static function lastId() { diff --git a/MVC/src/App/Library.php b/MVC/src/App/Library.php new file mode 100644 index 0000000..a1ed5a2 --- /dev/null +++ b/MVC/src/App/Library.php @@ -0,0 +1,29 @@ +alert('{$msg}');"; + } + + public static function move($url = false) + { + echo ""; + exit; + } + + public static function access($bool, $msg, $url = false) + { + if (!$bool) { + self::alert($msg); + self::move($url); + } + } + + } +?> \ No newline at end of file diff --git a/src/App/Route.php b/MVC/src/App/Route.php similarity index 100% rename from src/App/Route.php rename to MVC/src/App/Route.php diff --git a/src/App/View.php b/MVC/src/App/View.php similarity index 100% rename from src/App/View.php rename to MVC/src/App/View.php diff --git a/src/Controller/MainController.php b/MVC/src/Controller/MainController.php similarity index 100% rename from src/Controller/MainController.php rename to MVC/src/Controller/MainController.php diff --git a/src/Controller/MasterController.php b/MVC/src/Controller/MasterController.php similarity index 100% rename from src/Controller/MasterController.php rename to MVC/src/Controller/MasterController.php diff --git a/src/Controller/UserController.php b/MVC/src/Controller/UserController.php similarity index 99% rename from src/Controller/UserController.php rename to MVC/src/Controller/UserController.php index bebe3a9..d4ad3ba 100644 --- a/src/Controller/UserController.php +++ b/MVC/src/Controller/UserController.php @@ -1,5 +1,6 @@ $userid, + 'password' => $pass, + 'password_chk' => $passchk, + 'username' => $username + ] = $_POST; + + Library::access($userid !== "" && $pass !== "" && $username !== "", "빈칸이 존재합니다."); + Library::access($pass == $passchk, "비밀번호 재입력의 값이 잘못되었습니다."); + + $sql = "INSERT INTO users(`id`, `name`, `password`) VALUES (?, ?, PASSWORD(?))"; + + Library::access(DB::execute($sql, [$userid, $username, $pass]), "DB 에러"); + + Library::alert("회원가입 완료."); + Library::move("./login.php"); +} + +?> @@ -11,32 +39,32 @@

-
-
+ +
- +
-
+
-
+
-
+
-
+
diff --git a/src/Views/User/login.php b/MVC/src/Views/User/login.php similarity index 93% rename from src/Views/User/login.php rename to MVC/src/Views/User/login.php index afa1b85..e1caf57 100644 --- a/src/Views/User/login.php +++ b/MVC/src/Views/User/login.php @@ -1,10 +1,22 @@ + 얼굴책 로그인 - +
@@ -26,16 +38,4 @@
- - - \ No newline at end of file + \ No newline at end of file diff --git a/src/Views/layout/foooter.php b/MVC/src/Views/layout/foooter.php similarity index 100% rename from src/Views/layout/foooter.php rename to MVC/src/Views/layout/foooter.php diff --git a/src/Views/layout/header.php b/MVC/src/Views/layout/header.php similarity index 100% rename from src/Views/layout/header.php rename to MVC/src/Views/layout/header.php diff --git a/src/Views/layout/main.php b/MVC/src/Views/layout/main.php similarity index 100% rename from src/Views/layout/main.php rename to MVC/src/Views/layout/main.php diff --git a/web.php b/MVC/web.php similarity index 99% rename from web.php rename to MVC/web.php index 2daa56b..582166f 100644 --- a/web.php +++ b/MVC/web.php @@ -11,4 +11,4 @@ Route::post('/User/login', 'UserController@loginprocess'); Route::get('/User/join', 'UserController@register'); Route::get('/User/login', 'UserController@login'); -} +} \ No newline at end of file diff --git a/actions/user.php b/actions/user.php new file mode 100644 index 0000000..5de1a9e --- /dev/null +++ b/actions/user.php @@ -0,0 +1,42 @@ + $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; +} \ No newline at end of file diff --git a/core/common.php b/core/common.php new file mode 100644 index 0000000..cdcdaaa --- /dev/null +++ b/core/common.php @@ -0,0 +1,11 @@ +alert('{$msg}');"; +} + +function move($url = false) +{ + echo ""; + 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); +} \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..839e4d8 --- /dev/null +++ b/index.php @@ -0,0 +1,16 @@ +$css, 'msg'=>$msg]; - header("Location: " . $target); - } - } -?> \ No newline at end of file diff --git a/src/Views/User/common.css b/src/Views/User/common.css deleted file mode 100644 index 45fcffc..0000000 --- a/src/Views/User/common.css +++ /dev/null @@ -1,3 +0,0 @@ -.container{display: flex; justify-content: center;} -.row{ line-height: 50px; } -.my-3{text-align: center; } \ No newline at end of file diff --git a/view/template/footer.php b/view/template/footer.php new file mode 100644 index 0000000..691287b --- /dev/null +++ b/view/template/footer.php @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/view/template/header.php b/view/template/header.php new file mode 100644 index 0000000..e31b123 --- /dev/null +++ b/view/template/header.php @@ -0,0 +1,20 @@ + + + + + + + Document + + + \ No newline at end of file diff --git a/view/template/main.php b/view/template/main.php new file mode 100644 index 0000000..c9fa250 --- /dev/null +++ b/view/template/main.php @@ -0,0 +1 @@ +얼굴책 메인페이지입니다. \ No newline at end of file diff --git a/view/user/join.php b/view/user/join.php new file mode 100644 index 0000000..98988ba --- /dev/null +++ b/view/user/join.php @@ -0,0 +1,51 @@ +
+

회원가입

+ +
+ 회원가입 작성 폼 + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ +
\ No newline at end of file diff --git a/view/user/js/captcha.js b/view/user/js/captcha.js new file mode 100644 index 0000000..e69de29 diff --git a/view/user/login.php b/view/user/login.php new file mode 100644 index 0000000..93f31b9 --- /dev/null +++ b/view/user/login.php @@ -0,0 +1,24 @@ +
+

로그인

+
+
+
+ 로그인 폼 작성 + +
+
+
+ + +
+
+ + +
+ +
+
+
+
+
+
\ No newline at end of file diff --git a/view/user/logout.php b/view/user/logout.php new file mode 100644 index 0000000..8248621 --- /dev/null +++ b/view/user/logout.php @@ -0,0 +1,4 @@ + Date: Wed, 7 Oct 2020 16:54:22 +0900 Subject: [PATCH 03/13] =?UTF-8?q?feat:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=BD=94=EB=93=9C=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MVC/.htaccess | 5 -- MVC/autoload.php | 18 ------ MVC/public/index.php | 14 ----- MVC/src/App/DB.php | 36 ------------ MVC/src/App/Library.php | 29 ---------- MVC/src/App/Route.php | 33 ----------- MVC/src/App/View.php | 13 ----- MVC/src/Controller/MainController.php | 14 ----- MVC/src/Controller/MasterController.php | 13 ----- MVC/src/Controller/UserController.php | 64 -------------------- MVC/src/Views/User/join.php | 77 ------------------------- MVC/src/Views/User/login.php | 41 ------------- MVC/src/Views/layout/foooter.php | 2 - MVC/src/Views/layout/header.php | 34 ----------- MVC/src/Views/layout/main.php | 2 - MVC/web.php | 14 ----- 16 files changed, 409 deletions(-) delete mode 100644 MVC/.htaccess delete mode 100644 MVC/autoload.php delete mode 100644 MVC/public/index.php delete mode 100644 MVC/src/App/DB.php delete mode 100644 MVC/src/App/Library.php delete mode 100644 MVC/src/App/Route.php delete mode 100644 MVC/src/App/View.php delete mode 100644 MVC/src/Controller/MainController.php delete mode 100644 MVC/src/Controller/MasterController.php delete mode 100644 MVC/src/Controller/UserController.php delete mode 100644 MVC/src/Views/User/join.php delete mode 100644 MVC/src/Views/User/login.php delete mode 100644 MVC/src/Views/layout/foooter.php delete mode 100644 MVC/src/Views/layout/header.php delete mode 100644 MVC/src/Views/layout/main.php delete mode 100644 MVC/web.php diff --git a/MVC/.htaccess b/MVC/.htaccess deleted file mode 100644 index efea1f1..0000000 --- a/MVC/.htaccess +++ /dev/null @@ -1,5 +0,0 @@ -RewriteEngine On - -RewriteCond %{REQUEST_FILENAME} !-d -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^(.+)$ index.php/$1 [QSA,L] \ No newline at end of file diff --git a/MVC/autoload.php b/MVC/autoload.php deleted file mode 100644 index 51f799b..0000000 --- a/MVC/autoload.php +++ /dev/null @@ -1,18 +0,0 @@ -prepare($sql); - return $query->execute($data); - } - - public static function fetch($sql, $data = []) - { - return self::execute($sql, $data)->fetch(\PDO::FETCH_OBJ); - } - - public static function fetchAll($sql, $data = []) - { - return self::execute($sql, $data)->fetchAll(\PDO::FETCH_OBJ); - } - public static function lastId() - { - return self::getDB()->lastInsertId(); - } -} \ No newline at end of file diff --git a/MVC/src/App/Library.php b/MVC/src/App/Library.php deleted file mode 100644 index a1ed5a2..0000000 --- a/MVC/src/App/Library.php +++ /dev/null @@ -1,29 +0,0 @@ -alert('{$msg}');"; - } - - public static function move($url = false) - { - echo ""; - exit; - } - - public static function access($bool, $msg, $url = false) - { - if (!$bool) { - self::alert($msg); - self::move($url); - } - } - - } -?> \ No newline at end of file diff --git a/MVC/src/App/Route.php b/MVC/src/App/Route.php deleted file mode 100644 index a039309..0000000 --- a/MVC/src/App/Route.php +++ /dev/null @@ -1,33 +0,0 @@ -{$action[1]}(); - return; - } - } - echo "잘못된 접근!"; - } -} \ No newline at end of file diff --git a/MVC/src/App/View.php b/MVC/src/App/View.php deleted file mode 100644 index c9bf939..0000000 --- a/MVC/src/App/View.php +++ /dev/null @@ -1,13 +0,0 @@ -'Hello World']; - $this->render("main",$datas); - } -} \ No newline at end of file diff --git a/MVC/src/Controller/MasterController.php b/MVC/src/Controller/MasterController.php deleted file mode 100644 index cb40038..0000000 --- a/MVC/src/Controller/MasterController.php +++ /dev/null @@ -1,13 +0,0 @@ -render("User/join"); - } - - public function registerProcess() - { - $userid = $_POST["userid"]; - $pass = $_POST["password"]; - $passchk =$_POST["passwordchk"]; - $username = $_POST["username"]; - - if($userid == "" || $pass == "" || $username = ""){ - Library::msgAndGo("입력하지 않은곳이 있습니다.", "../User/join"); - return; - } - if($pass != $passchk){ - Library::msgAndGo("비밀번호가 일치하지 않습니다.", "/User/join"); - return; - } - $sql = "INSERT INTO users(`id`, `name`, `password`, `level`) VALUES (?, ?, PASSWORD(?), ?)"; - - $result = DB::execute($sql, [$userid, $username, $pass, 1]); - - if($result != 1){ - Library::msgAndGo("올바른 값이 안들어갔습니다.", "../User/join"); - return; - } - Library::msgAndGo("회원가입이 완료됨. 로그인 바람.", "../User/login", "success"); - return; - } - } - - public function loginprocess(){ - $userid = $_POST["userid"]; - $pass = $_POST["password"]; - $sql = "SELECT * FROM users WHERE id = ? AND password = PASSWORD(?)"; - $user = DB::fetch($sql, [$userid, $pass]); - - if($user == null){ - Library::msgAndGo("비밀번호가 달라!", "../User/login"); - return; - } - $_SESSION["user"] = $user; - Library::msgAndGo("로그인 되었다!", "/", "success"); - return; - } - public function logout() - { - unset($_SESSION["user"]); - Library::msgAndGo("로그아웃 되었습니다.", "/", "success"); - return; - } -} \ No newline at end of file diff --git a/MVC/src/Views/User/join.php b/MVC/src/Views/User/join.php deleted file mode 100644 index 0fb7f9a..0000000 --- a/MVC/src/Views/User/join.php +++ /dev/null @@ -1,77 +0,0 @@ - $userid, - 'password' => $pass, - 'password_chk' => $passchk, - 'username' => $username - ] = $_POST; - - Library::access($userid !== "" && $pass !== "" && $username !== "", "빈칸이 존재합니다."); - Library::access($pass == $passchk, "비밀번호 재입력의 값이 잘못되었습니다."); - - $sql = "INSERT INTO users(`id`, `name`, `password`) VALUES (?, ?, PASSWORD(?))"; - - Library::access(DB::execute($sql, [$userid, $username, $pass]), "DB 에러"); - - Library::alert("회원가입 완료."); - Library::move("./login.php"); -} - -?> - - - - - - 얼굴책 가입 - - - -
-
-

-
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- -
-
-
-
-
-
- - \ No newline at end of file diff --git a/MVC/src/Views/User/login.php b/MVC/src/Views/User/login.php deleted file mode 100644 index e1caf57..0000000 --- a/MVC/src/Views/User/login.php +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - 얼굴책 로그인 - - - -
-
-

로그인

-
-
-
- - -
-
- - -
- -
-
-
-
- - \ No newline at end of file diff --git a/MVC/src/Views/layout/foooter.php b/MVC/src/Views/layout/foooter.php deleted file mode 100644 index 691287b..0000000 --- a/MVC/src/Views/layout/foooter.php +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/MVC/src/Views/layout/header.php b/MVC/src/Views/layout/header.php deleted file mode 100644 index e50c91f..0000000 --- a/MVC/src/Views/layout/header.php +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - Document - - -
-
- -
- -
out"> - -
- - -
- -
- - 로그아웃 -
- - - - - \ No newline at end of file diff --git a/MVC/src/Views/layout/main.php b/MVC/src/Views/layout/main.php deleted file mode 100644 index b34b38c..0000000 --- a/MVC/src/Views/layout/main.php +++ /dev/null @@ -1,2 +0,0 @@ -

-

메인페이지입니다.

\ No newline at end of file diff --git a/MVC/web.php b/MVC/web.php deleted file mode 100644 index 582166f..0000000 --- a/MVC/web.php +++ /dev/null @@ -1,14 +0,0 @@ - Date: Tue, 13 Oct 2020 20:57:45 +0900 Subject: [PATCH 04/13] 2020-10-13 --- actions/userSearch.php | 13 +++++++++++++ js/captcha.js | 13 +++++++++++++ view/template/header.php | 5 +++-- view/user/join.php | 24 ++++++++++++++++++------ view/user/js/captcha.js | 0 view/user/usersearch.php | 10 ++++++++++ 6 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 actions/userSearch.php create mode 100644 js/captcha.js delete mode 100644 view/user/js/captcha.js create mode 100644 view/user/usersearch.php diff --git a/actions/userSearch.php b/actions/userSearch.php new file mode 100644 index 0000000..70ac217 --- /dev/null +++ b/actions/userSearch.php @@ -0,0 +1,13 @@ + $searchbox, + 'searchbtn' => $searchbtn, + ] = $_POST; + + $user = fetchAll("INSERT INTO users(`id`, `name`) VALUES(?,?)", [$searchbox]); +} \ No newline at end of file diff --git a/js/captcha.js b/js/captcha.js new file mode 100644 index 0000000..63e8ec7 --- /dev/null +++ b/js/captcha.js @@ -0,0 +1,13 @@ +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(); diff --git a/view/template/header.php b/view/template/header.php index e31b123..df19105 100644 --- a/view/template/header.php +++ b/view/template/header.php @@ -1,5 +1,5 @@ - + \ No newline at end of file diff --git a/view/user/join.php b/view/user/join.php index 98988ba..9fc3475 100644 --- a/view/user/join.php +++ b/view/user/join.php @@ -4,7 +4,7 @@
회원가입 작성 폼 -
+
@@ -14,6 +14,13 @@ placeholder="email을 입력하세요">
+
+ +
+ +
+
@@ -29,23 +36,28 @@
- +
- + +
+
+
- +
- +
-
\ No newline at end of file +
+ \ No newline at end of file diff --git a/view/user/js/captcha.js b/view/user/js/captcha.js deleted file mode 100644 index e69de29..0000000 diff --git a/view/user/usersearch.php b/view/user/usersearch.php new file mode 100644 index 0000000..ec96e10 --- /dev/null +++ b/view/user/usersearch.php @@ -0,0 +1,10 @@ +
+ + +
+ + +
+ +
+ \ No newline at end of file From a16ec35597c04c7030f518ebc1139a9799b515d2 Mon Sep 17 00:00:00 2001 From: minsung03 Date: Wed, 14 Oct 2020 16:31:43 +0900 Subject: [PATCH 05/13] =?UTF-8?q?feat:=20captcha=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/captcha.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/captcha.js b/js/captcha.js index 63e8ec7..df85a61 100644 --- a/js/captcha.js +++ b/js/captcha.js @@ -11,3 +11,4 @@ const getCaptchaString = () => Array(6) .join(''); document.querySelector('#maincaptcha').value = getCaptchaString(); + From 151bc0bbf8748b0b17d9a198e4867bc32ef0f2af Mon Sep 17 00:00:00 2001 From: minsung03 Date: Wed, 14 Oct 2020 16:31:57 +0900 Subject: [PATCH 06/13] =?UTF-8?q?feat:=20search=20api=20=EC=A0=9C=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/search.php | 3 +++ core/common.php | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 api/search.php diff --git a/api/search.php b/api/search.php new file mode 100644 index 0000000..a06ece8 --- /dev/null +++ b/api/search.php @@ -0,0 +1,3 @@ + Date: Wed, 14 Oct 2020 16:32:13 +0900 Subject: [PATCH 07/13] =?UTF-8?q?refactor:=20include=EC=97=90=EC=84=9C=20r?= =?UTF-8?q?oot=20path=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index 839e4d8..044288f 100644 --- a/index.php +++ b/index.php @@ -3,14 +3,14 @@ define("HOME", __dir__); - include_once("./core/lib.php"); - include_once("./core/common.php"); + include_once(HOME . "/core/lib.php"); + include_once(HOME . "/core/common.php"); - include_once("./view/template/header.php"); + include_once(HOME . "/view/template/header.php"); if (isset($include_file)) { - include_once("./view/{$page}/{$include_file}.php"); + include_once(HOME . "/view/{$page}/{$include_file}.php"); } else { - include_once("./view/template/main.php"); + include_once(HOME . "/view/template/main.php"); } - include_once("./view/template/footer.php"); \ No newline at end of file + include_once(HOME . "/view/template/footer.php"); \ No newline at end of file From 89e9c5c2bed4f334844b211fba95f4b133c20b0a Mon Sep 17 00:00:00 2001 From: minsung03 Date: Wed, 14 Oct 2020 16:32:28 +0900 Subject: [PATCH 08/13] =?UTF-8?q?feat:=20search=20=EC=9E=91=EC=97=85=20?= =?UTF-8?q?=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/usersearch.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 js/usersearch.js diff --git a/js/usersearch.js b/js/usersearch.js new file mode 100644 index 0000000..eca81be --- /dev/null +++ b/js/usersearch.js @@ -0,0 +1,10 @@ +const form = document.getElementsByTagName("form")[0]; +form.addEventListener("submit", function(e) { + e.preventDefault(); + + const url = `/api/search?q=${e.target.search.value}`; + const box = document.getElementById("searchbox").value; + fetch(url) + .then(res => res.json()) + .then(console.log); +}) From a6b2e83f3ef6f0c724864035da022ef04c453435 Mon Sep 17 00:00:00 2001 From: minsung03 Date: Fri, 16 Oct 2020 19:56:15 +0900 Subject: [PATCH 09/13] 2020-10-16 --- actions/userSearch.php | 1 + js/profile.js | 9 +++++++++ js/usersearch.js | 24 +++++++++++++++++------- view/template/footer.php | 3 +++ view/user/usersearch.php | 2 ++ 5 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 js/profile.js diff --git a/actions/userSearch.php b/actions/userSearch.php index 70ac217..aa4182c 100644 --- a/actions/userSearch.php +++ b/actions/userSearch.php @@ -10,4 +10,5 @@ ] = $_POST; $user = fetchAll("INSERT INTO users(`id`, `name`) VALUES(?,?)", [$searchbox]); + } \ No newline at end of file diff --git a/js/profile.js b/js/profile.js new file mode 100644 index 0000000..c2a6fdb --- /dev/null +++ b/js/profile.js @@ -0,0 +1,9 @@ +function friend_box(obj) { + let id = document.createElement("div"); + + id.innerHTML = obj.id; + + document.querySelector(".result").appendChild(id); + + +}; \ No newline at end of file diff --git a/js/usersearch.js b/js/usersearch.js index eca81be..8c34f55 100644 --- a/js/usersearch.js +++ b/js/usersearch.js @@ -1,10 +1,20 @@ const form = document.getElementsByTagName("form")[0]; -form.addEventListener("submit", function(e) { +form.addEventListener("submit", function (e) { e.preventDefault(); - const url = `/api/search?q=${e.target.search.value}`; - const box = document.getElementById("searchbox").value; - fetch(url) - .then(res => res.json()) - .then(console.log); -}) + 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; +}) \ No newline at end of file diff --git a/view/template/footer.php b/view/template/footer.php index 691287b..a0a182b 100644 --- a/view/template/footer.php +++ b/view/template/footer.php @@ -1,2 +1,5 @@ +
+ + \ No newline at end of file diff --git a/view/user/usersearch.php b/view/user/usersearch.php index ec96e10..de64d73 100644 --- a/view/user/usersearch.php +++ b/view/user/usersearch.php @@ -7,4 +7,6 @@
+
+ \ No newline at end of file From 6973c65c38009a054ee0666f8ec1f7cf2b8e08a6 Mon Sep 17 00:00:00 2001 From: minsung03 Date: Mon, 19 Oct 2020 19:55:54 +0900 Subject: [PATCH 10/13] 2020-10-19 --- js/profile.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/profile.js b/js/profile.js index c2a6fdb..a913883 100644 --- a/js/profile.js +++ b/js/profile.js @@ -1,9 +1,8 @@ function friend_box(obj) { let id = document.createElement("div"); - + id.innerHTML = obj.id; document.querySelector(".result").appendChild(id); - }; \ No newline at end of file From be69079d22635b2aae84ab7fe6dc5a5a8f70e6c8 Mon Sep 17 00:00:00 2001 From: minsung03 Date: Tue, 20 Oct 2020 19:56:24 +0900 Subject: [PATCH 11/13] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=A0=9C=EC=9E=91=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/profile.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/js/profile.js b/js/profile.js index a913883..61a1b8f 100644 --- a/js/profile.js +++ b/js/profile.js @@ -1,8 +1,6 @@ function friend_box(obj) { let id = document.createElement("div"); - id.innerHTML = obj.id; - document.querySelector(".result").appendChild(id); }; \ No newline at end of file From 80066048374d3d7edbb96e73db3e289b0ffd16e4 Mon Sep 17 00:00:00 2001 From: minsung03 Date: Wed, 21 Oct 2020 12:25:04 +0900 Subject: [PATCH 12/13] =?UTF-8?q?feat=20=ED=94=84=EB=A1=9C=ED=95=84?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=A0=9C=EC=9E=91=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view/user/userprofile.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 view/user/userprofile.php diff --git a/view/user/userprofile.php b/view/user/userprofile.php new file mode 100644 index 0000000..c0f2128 --- /dev/null +++ b/view/user/userprofile.php @@ -0,0 +1,13 @@ + + +
+
+

+

+ +
+
\ No newline at end of file From d3fa26f6421219779d6eb1f4f5ee29a70ef7abf0 Mon Sep 17 00:00:00 2001 From: minsung03 Date: Wed, 21 Oct 2020 19:56:00 +0900 Subject: [PATCH 13/13] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=A0=9C=EC=9E=91=EA=B3=BC=20?= =?UTF-8?q?=EC=BA=A1=EC=B0=A8=20=EB=B3=B5=EB=B6=99=20=EB=B0=A9=EC=A7=80,?= =?UTF-8?q?=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20=EB=A6=AC=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/captcha.js | 6 ++++++ view/template/header.php | 3 ++- view/user/join.php | 2 +- view/user/userprofile.php | 13 ------------- 4 files changed, 9 insertions(+), 15 deletions(-) delete mode 100644 view/user/userprofile.php diff --git a/js/captcha.js b/js/captcha.js index df85a61..fc65d96 100644 --- a/js/captcha.js +++ b/js/captcha.js @@ -12,3 +12,9 @@ const getCaptchaString = () => Array(6) 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}; \ No newline at end of file diff --git a/view/template/header.php b/view/template/header.php index df19105..48d8330 100644 --- a/view/template/header.php +++ b/view/template/header.php @@ -5,11 +5,12 @@ - Document + Document
  • 사용자검색
  • +
  • 친구요청
  • HOME
  • name?>님 환영합니다.
  • diff --git a/view/user/join.php b/view/user/join.php index 9fc3475..4aa11f6 100644 --- a/view/user/join.php +++ b/view/user/join.php @@ -38,7 +38,7 @@
    - +
    diff --git a/view/user/userprofile.php b/view/user/userprofile.php deleted file mode 100644 index c0f2128..0000000 --- a/view/user/userprofile.php +++ /dev/null @@ -1,13 +0,0 @@ - - -
    -
    -

    -

    - -
    -
    \ No newline at end of file