-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprotected_session.php
75 lines (61 loc) · 1.86 KB
/
protected_session.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
<?php
/*
File: protected_session.php
Author: Jaspers
Created by 2018-07-11
Goal: view.php, modify.php 세션 - 보호 게시물
Description:
2018-07-13 / Jasper / Protected Session (View, Modify) 구분
*/
session_start(); //세션 열기
// 보호글 일 때
if ( strcmp( $article->getMode(), 'protected' ) == 0 )
{
$protected_list; // 세션 임시변수
// 세션 존재 유무
if(!isset($_SESSION['protected_list'])){
$_SESSION["protected_list"]= "";
}else{
$protected_list = unserialize($_SESSION['protected_list']); // 세션 불러오기
}
$protected_list_dummy = explode( ";", $protected_list );
$board_cnt_ok = 0; // 보호글 탐색
for($i = 0; $i < sizeof($protected_list_dummy); $i++)
{
$target = $boardName . "_" . $article_id . "_" . $usrdate;
if( strcmp($protected_list_dummy[$i], $target) == 0 ) // 일치하는 세션이 있다면
{
$board_cnt_ok++; // 존재:1 / 미존재:0
break;
}
}
if( $board_cnt_ok == 0 ) // 보호 섹션으로 이동
{
if ( empty ($boardName) &&
empty ($article_id) ){
header("Location: about:blank;");
}
if ( !empty ($page_id) ){
header("Location: protected.php?name=$boardName&page=$page_id&id=$article_id");
}
if ( empty ($page_id) ){
header("Location: protected.php?name=$boardName&id=$article_id");
}
}
// 사용 후 일회성 세션 폐기
if( $board_cnt_ok == 1 )
{
echo strpos($_SERVER["PHP_SELF"], "modfiy");
if ( strpos($_SERVER["PHP_SELF"], "view") != false ){
if ( !empty ($page_id) && !empty($refresh_id) ){
unset( $_SESSION["protected_list"] );
}
}
if ( strpos($_SERVER["PHP_SELF"], "modify") != false ){
if ( !empty ($page_id) ){
unset( $_SESSION["protected_list"] );
}
}
}
}
?>