-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview_session.php
More file actions
49 lines (38 loc) · 1.12 KB
/
view_session.php
File metadata and controls
49 lines (38 loc) · 1.12 KB
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
<?php
/*
File: view_session.php
Author: Jaspers
Created by 2018-07-10
Goal: view.php 세션 - 조회수 증가(중복조회 방지)
Description:
*/
$cnt_list; // 세션 임시변수
// 세션 존재 유무
if(!isset($_SESSION['cnt_list'])){
$_SESSION["cnt_list"]= "";
}else{
$cnt_list = unserialize($_SESSION['cnt_list']);
}
$cnt_list_dummy = explode( ";", $cnt_list );
$view_cnt_ok = 0; //조회수를 올려도 되는지 저장하는 변수를 초기화
for($i = 0; $i < sizeof($cnt_list_dummy); $i++)
{
$target = $boardName . "_" . $article_id . "_" . $ip . "_" . $usrdate;
if( strcmp($cnt_list_dummy[$i], $target) == 0 ) // 일치하는 세션이 있다면
{
$view_cnt_ok = 1; // 존재:1 / 미존재:0
break;
}
}
if( $view_cnt_ok == 0 ) // 조회 여부 판단
{
$article = new Article();
$article->setID( $article_id );
$board->updateCount($boardName, $article); // 조회수 증가
//echo "증가" . $cnt_list . "<br>";
$cnt_list.= ";" . $boardName . "_" . $article_id . "_" . $ip . "_" . $usrdate;
$_SESSION["cnt_list"] = serialize($cnt_list);
}
else{
}
?>