-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_create_zin_action.php
171 lines (134 loc) · 5.74 KB
/
admin_create_zin_action.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
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
include 'bbdd_db_conn.php';
$author = $_POST['author'];
$author = mysqli_real_escape_string($conn, $author);
$username = $_POST['username'];
$username = mysqli_real_escape_string($conn, $username);
$title = $_POST['title'];
$title = mysqli_real_escape_string($conn, $title);
$zin_detail = $_POST['zin_detail'];
$zin_detail = mysqli_real_escape_string($conn, $zin_detail);
$display = $_POST['display'];
$display = mysqli_real_escape_string($conn, $display);
$publish = $_POST['publish'];
$publish = mysqli_real_escape_string($conn, $publish);
$zin_column = $_POST['zin_column'];
$zin_column = mysqli_real_escape_string($conn, $zin_column);
$zin_color = $_POST['zin_color'];
$zin_color = mysqli_real_escape_string($conn, $zin_color);
$title_color = $_POST['title_color'];
$title_color = mysqli_real_escape_string($conn, $title_color);
$point_color = $_POST['point_color'];
$point_color = mysqli_real_escape_string($conn, $point_color);
$nav_color = $_POST['nav_color'];
$nav_color = mysqli_real_escape_string($conn, $nav_color);
$date = $_POST['date'];
$titleSql = "SELECT * FROM zin WHERE title='$title'";
$titleCheck = mysqli_query($conn, $titleSql);
$titleCheck = $titleCheck->fetch_array();
$dQuote = '"';
$sQuote = "'";
if($titleCheck >= 1){
echo "<script>alert('매거진 제목이 중복됩니다.'); history.back();</script>";
}else if(strpos($title, $dQuote) == true || strpos($title, $sQuote) == true) {
echo "<script>alert('사용불가능한 매거진 제목입니다.'); history.back();</script>";
}else if(preg_match('/[\x{3130}-\x{318F}\x{AC00}-\x{D7AF}]/u', $zinTitle) && mb_strlen($zinTitle, "UTF-8") >= 21) {
echo "<script>alert('사용불가능한 매거진 제목입니다.'); history.back();</script>";
}else if(!preg_match('/[\x{3130}-\x{318F}\x{AC00}-\x{D7AF}]/u', $zinTitle) && strlen($zinTitle) >= 25) {
echo "<script>alert('사용불가능한 매거진 제목입니다.'); history.back();</script>";
} else {
$uploadimg = include "admin_create_zin_files.php";
$image = $uploadimg['img'];
if($publish == "ready") {
$sql = "
INSERT INTO zin
(author, username, title, img, img_dir, zin_detail, display, publish, zin_column, zin_color, title_color, point_color, nav_color, date, created)
VALUES(
'{$author}',
'{$username}',
'{$title}',
'{$image}$filename',
'{$image}$target_file',
'{$zin_detail}',
'{$display}',
'{$publish}',
'{$zin_column}',
'{$zin_color}',
'{$title_color}',
'{$point_color}',
'{$nav_color}',
'{$date}',
NOW()
)";
} else if ($publish == "now") {
$sql = "
INSERT INTO zin
(author, username, title, img, img_dir, zin_detail, display, publish, zin_column, zin_color, title_color, point_color, nav_color, date, created)
VALUES(
'{$author}',
'{$username}',
'{$title}',
'{$image}$filename',
'{$image}$target_file',
'{$zin_detail}',
'{$display}',
'{$publish}',
'{$zin_column}',
'{$zin_color}',
'{$title_color}',
'{$point_color}',
'{$nav_color}',
'{$date}',
NOW()
)";
$updateSql=
"UPDATE zin SET
`publish`='ready'
WHERE `publish` = 'now' AND `publish` != 'standing' AND title != '$title'";
} else if ($publish == "standing") {
$sql = "
INSERT INTO zin
(author, username, title, img, img_dir, zin_detail, display, publish, zin_column, zin_color, title_color, point_color, nav_color, date, created)
VALUES(
'{$author}',
'{$username}',
'{$title}',
'{$image}$filename',
'{$image}$target_file',
'{$zin_detail}',
'{$display}',
'{$publish}',
'{$zin_column}',
'{$zin_color}',
'{$title_color}',
'{$point_color}',
'{$nav_color}',
'{$date}',
NOW()
)";
$updateSql=
"UPDATE zin SET
`publish`='ready'
WHERE `publish` = 'standing' AND `publish` != 'now' AND title != '$title'";
}
}
$result = mysqli_query($conn, $sql);
if(isset($updateSql)) {
$resultNow = mysqli_query($conn, $updateSql);
if($result === false){
echo '저장실패. 관리자에게 문의해주세요';
error_log(mysqli_error($conn));
}
else{
echo("<script>alert('현재 발행중 매거진이 생성되었습니다.');location.href='admin_zinList.php';</script>");
}
} else {
if($result === false){
echo '저장실패. 관리자에게 문의해주세요';
error_log(mysqli_error($conn));
}
else{
echo("<script>alert('매거진이 생성되었습니다.');location.href='admin_zinList.php';</script>");
}
}
?>