-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.php
307 lines (283 loc) · 9.24 KB
/
code.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<? ob_start();?>
<meta charset="utf-8">
<?
class Code extends CI_Controller{
public function __construct(){
parent::__construct();
$this->load->database();
$this->load->model('cpms/codeModel');
$this->load->library('session');
}
public function index(){
$this->load->view('cpms/codeIndex');
}
public function login(){
$id=$this->input->post('id');
$pw=$this->input->post('pw');
$result=$this->codeModel->login($id,$pw);
if(count($result)==0){
echo "<script>alert('아이디와 비밀번호가 맞지 않습니다!')</script>";
echo "<script>location.href='/index.php/cpms/code'</script>";
}
else{
$data=array(
'uid'=>$result[0]->id,
'uname'=>$result[0]->name,
'ugroup'=>$result[0]->grp,
'uauth'=>$result[0]->authority
);
$this->session->set_userdata($data);
redirect('/cpms/code/cadiw','refresh');
}
}
public function cadiw(){
$udata=$this->session->all_userdata();
if(isset($udata['uid'])){
$this->load->view('cpms/cadiwHeader');
$this->load->view('cpms/cadiwNav');
$this->load->view('cpms/cadiwIndex');
}
else{
echo "<script>alert('로그인 해주세요!')</script>";
redirect('/cpms/code','refresh');
}
}
public function logout(){
$this->session->sess_destroy();
redirect('/cpms/code','location');
}
public function group(){
$udata=$this->session->all_userdata();
$group=$this->input->get('group');
if($udata['ugroup']!=$group){
echo "<script>alert('권한이 없습니다')</script>";
redirect('/cpms/code/cadiw','refresh');
}
else{
$this->load->view('cpms/cadiwGroupHeader');
$this->load->view('cpms/cadiwNav');
$this->load->view('cpms/cadiwGroupIndex');
}
}
public function board(){
$udata=$this->session->all_userdata();
if(isset($udata['uid'])){
$data['page_num'] = $this->uri->segment(4,0);
$data['per_page']=10;
$data['list']=$this->codeModel->board($data['per_page'],$data['page_num']);
$data['total_rows']=$this->codeModel->boardCount();
$comment=$this->codeModel->commentCount();
for($i=0;$i<count($data['list']);$i++){
$comment1[$i]=0;
for($j=0;$j<count($comment);$j++){
if($data['list'][$i]->bid==$comment[$j]->bid)
$comment1[$i]=$comment[$j]->bcount;
}
}
$data['comment']=$comment1;
$this->load->library('pagination');
$config['full_tag_open'] = '<div id="page">';
$config['base_url']='/index.php/cpms/code/board';
$config['total_rows']=$data['total_rows'];
$config['per_page'] = $data['per_page'];
$config['uri_segment'] = 4;
$config['next_link'] = '다음';
$config['next_tag_open'] = '<div class="page_num">';
$config['next_tag_close'] = '</div>';
$config['prev_link'] = '이전';
$config['prev_tag_open'] = '<div class="page_num">';
$config['prev_tag_close'] = '</div>';
$config['num_tag_open'] = '<div class="page_num">';
$config['num_tag_close'] = '</div>';
$config['cur_tag_open'] = '<div class="page_num">';
$config['cur_tag_close'] = '</div>';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$data['page_links'] = $this->pagination->create_links();
if($data['page_links']==null){
$data['page_links']='1';
}
$this->load->view('cpms/cadiwHeader');
$this->load->view('cpms/cadiwNav');
$this->load->view('cpms/board',$data);
}
else{
echo "<script>alert('로그인 해주세요!')</script>";
redirect('/cpms/code/cadiw','refresh');
}
}
public function boardWrite(){
$udata=$this->session->all_userdata();
if(isset($udata['uid'])){
$this->load->view('cpms/cadiwHeader');
$this->load->view('cpms/cadiwNav');
$this->load->view('cpms/boardWrite');
}
else{
echo "<script>alert('로그인해주세요!')</script>";
redirect('/cpms/code/cadiw','refresh');
}
}
public function boardInput(){
$udata=$this->session->all_userdata();
if(isset($udata['uid'])){
$btitle=$this->input->post('btitle');
$bcontent=$this->input->post('bcontent');
$this->codeModel->boardInput($udata['uid'],$btitle,$bcontent);
echo "<script>alert('글이 등록되었습니다')</script>";
redirect('/cpms/code/board','refresh');
}
else{
echo "<script>alert('로그인 해주세요!')</script>";
redirect('/cpms/code/cadiw','refresh');
}
}
public function boardView($no){
$udata=$this->session->all_userdata();
if(isset($udata['uid'])){
$result['list']=$this->codeModel->boardView($no);
$result['comment']=$this->codeModel->commentView($no);
$this->load->view('cpms/cadiwHeader');
$this->load->view('cpms/cadiwNav');
$this->load->view('cpms/boardView',$result);
}
else{
echo "<script>alert('로그인 해주세요!')</script>";
redirect('/cpms/code/cadiw','refresh');
}
}
public function boardUpdate($no){
$udata=$this->session->all_userdata();
if(isset($udata['uid'])){
$result['list']=$this->codeModel->boardView($no);
$this->load->view('cpms/cadiwHeader');
$this->load->view('cpms/cadiwNav');
$this->load->view('cpms/boardUpdate',$result);
}
else{
echo "<script>alert('로그인 해주세요!')</script>";
redirect('/cpms/code/cadiw','refresh');
}
}
public function boardUpdateSuccess(){
$udata=$this->session->all_userdata();
if(isset($udata['uid'])){
$bid=$this->input->post('bid');
$bcontent=$this->input->post('bcontent');
$this->codeModel->boardUpdate($bid,$bcontent);
echo "<script>alert('글이 수정되었습니다')</script>";
redirect('/cpms/code/board','refresh');
}
else{
echo "<script>alert('로그인 해주세요!')</script>";
redirect('/cpms/code/cadiw','refresh');
}
}
public function boardDelete(){
$udata=$this->session->all_userdata();
if(isset($udata['uid'])){
$bid=$this->input->post('bid');
$this->codeModel->boardDelete($bid);
echo "<script>alert('글이 삭제되었습니다')</script>";
redirect('/cpms/code/board','refresh');
}
else{
echo "<script>alert('로그인 해주세요!')</script>";
redirect('/cpms/code/cadiw','refresh');
}
}
public function boardSearch($option,$search){
$udata=$this->session->all_userdata();
if(isset($udata['uid'])){
$o=$option;
$s=$search;
$option=urldecode($option);
$search=urldecode($search);
$data['page_num'] = $this->uri->segment(6,0);
$data['per_page']=10;
if($option=='제목+내용'){
$data['list']=$this->codeModel->boardSearchAll($data['per_page'],$data['page_num'],$search);
$data['total_rows']=$this->codeModel->boardSearchAllCount($search);
}
else{
$data['list']=$this->codeModel->boardSearchTitle($data['per_page'],$data['page_num'],$search);
$data['total_rows']=$this->codeModel->boardSearchTitleCount($search);
}
$comment=$this->codeModel->commentCount();
for($i=0;$i<count($data['list']);$i++){
$comment1[$i]=0;
for($j=0;$j<count($comment);$j++){
if($data['list'][$i]->bid==$comment[$j]->bid)
$comment1[$i]=$comment[$j]->bcount;
}
}
$data['comment']=$comment1;
$this->load->library('pagination');
$config['full_tag_open'] = '<div id="page">';
$config['base_url']='/index.php/cpms/code/boardSearch/'.$o.'/'.$s.'';
$config['total_rows']=$data['total_rows'];
$config['per_page'] = $data['per_page'];
$config['uri_segment'] = 6;
$config['next_link'] = '다음';
$config['next_tag_open'] = '<div class="page_num">';
$config['next_tag_close'] = '</div>';
$config['prev_link'] = '이전';
$config['prev_tag_open'] = '<div class="page_num">';
$config['prev_tag_close'] = '</div>';
$config['num_tag_open'] = '<div class="page_num">';
$config['num_tag_close'] = '</div>';
$config['cur_tag_open'] = '<div class="page_num">';
$config['cur_tag_close'] = '</div>';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$data['page_links'] = $this->pagination->create_links();
if($data['page_links']==null){
$data['page_links']='1';
}
$this->load->view('cpms/cadiwHeader');
$this->load->view('cpms/cadiwNav');
$this->load->view('cpms/board',$data);
}
else{
echo "<script>alert('로그인 해주세요!')</script>";
redirect('/cpms/code/cadiw','refresh');
}
}
public function commentWrite(){
$udata=$this->session->all_userdata();
if(isset($udata['uid'])){
$content=$this->input->post('content');
$board_id=$this->input->post('board_id');
echo $board_id;
$this->codeModel->commentWrite($board_id,$udata['uid'],$content);
}
else{
echo "<script>alert('로그인 해주세요!')</script>";
redirect('/cpms/code/cadiw','refresh');
}
}
public function commentView(){
$udata=$this->session->all_userdata();
if(isset($udata['uid'])){
$bno=$this->input->post('bid');
$result['list']=$this->codeModel->commentView($bno);
$this->load->view('cpms/commentView',$result);
}
else{
echo "<script>alert('로그인 해주세요!')</script>";
redirect('/cpms/code/cadiw','refresh');
}
}
public function commentRemove(){
$udata=$this->session->all_userdata();
if(isset($udata['uid'])){
$cid=$this->input->post('cid');
$this->codeModel->commentRemove($cid);
}
else{
echo "<script>alert('로그인 해주세요!')</script>";
redirect('/cpms/code/cadiw','refresh');
}
}
}
?>