-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomment_ok.php
94 lines (74 loc) · 2.25 KB
/
comment_ok.php
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
<?php
/*
File: comment_ok.php
Author: Jaspers
Created by 2018-07-11
Description: view.php에서 사용됨.
2018-07-12 / Jaspers / 비밀번호 정규식 적용
*/
$comment;
$pattern = $boardFn->passwordPattern();
$count = -1;
$SUCCESS = 8;
$memoErr = $authorErr = $passwdErr = $passwdChkErr = "";
$memo = $author = $passwd = $passwd2 = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["memo"])) {
$memoErr = "Required Memo";
$count++;
}else {
$memo = $boardFn->test_input($_POST["memo"]);
}
if (empty($_POST["author"])) {
$authorErr = "Author is required";
$count++;
}else {
$author = $boardFn->test_input($_POST["author"]);
}
if (empty($_POST["passwd"])) {
$passwdErr = "Password is required";
$count++;
}else {
$passwd = $boardFn->test_input($_POST["passwd"]);
if(!preg_match($pattern , $passwd)){
$passwd = "";
$passwdErr = "8~15,대소문자,특수문자조합<br>(8-15, uppercase and lowercase letters,<br> special characters combined)";
}
}
if (empty($_POST["passwd2"])) {
$passwdChkErr = "Password Check Error";
$count++;
}else {
$passwd2 = $boardFn->test_input($_POST["passwd2"]);
if ( $passwd != $passwd2 ){
$passwdChkErr = "Password Check Error";
}
if(!preg_match($pattern , $passwd2)){
$passwd2 = "";
$passwdChkErr = "8~15,대소문자,특수문자조합<br>(8-15, uppercase and lowercase letters,<br> special characters combined)";
}
}
}
// 내용 비어있는지 확인
if ( !empty($memo) &&
!empty($author) &&
!empty($passwd) ){
$count = $SUCCESS;
}
// 댓글 담기
if ( $count == $SUCCESS )
{
$comment = new Comment();
$comment->setArticle_ID($article_id);
$comment->setMemo($memo);
$comment->setAuthor($author);
$comment->setPassword($passwd);
$comment->setIP($_SERVER["REMOTE_ADDR"]);
$comment->setRegidate(date("Y-m-d H:i:s"));
$result = $board->writeComment($boardName, $comment);
$result = $board->updateReplyCount($boardName, $article_id);
if ( $result == 1) {
header("Location: view.php?name=$boardName&page=$page_id&id=$article_id");
}
}
?>