-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcount.php
More file actions
78 lines (63 loc) · 2.57 KB
/
count.php
File metadata and controls
78 lines (63 loc) · 2.57 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
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
<?php
// if(!isset($_SESSION)) session_start();
require_once "pdo.php";
if(isset($_COOKIE['old_count']) && $_SESSION['visit_count'] - $_COOKIE['old_count'] >1000-2 ){
setcookie("limit", "limit exceeded" , time() + (86400), "/");
setcookie("old_count", $_SESSION['visit_count'] , time() + (86400*365), "/");
}
if(isset($_SESSION['visit_count'])){
$sql = "SELECT * from user_count where session_id = :id";
$stmt = $pdo->prepare($sql);
$stmt->execute(array(
':id'=> session_id()
));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if($row!=false){
$sqle = "UPDATE user_count SET visit=:v where user_id = :uid ";
$stmte = $pdo->prepare($sqle);
$mapping = array(
':v' => $_SESSION['visit_count'],
':uid'=>$row['user_id']
);
$stmte->execute($mapping);
if(isset($_SESSION['search']) ) {
$sqls = "UPDATE user_count SET search=:s where user_id = :uid ";
$stmts = $pdo->prepare($sqls);
if($row['search']==null){
$mappings = array(
':s' => $_SESSION['search'],
':uid'=>$row['user_id']
);
}
else{
$mappings = array(
':s' => $row['search'].",". $_SESSION['search'],
':uid'=>$row['user_id']
);
}
$stmts->execute($mappings);
}
unset($_SESSION['search']);
}
else{
$sqle = "INSERT INTO user_count (session_id,visit,ip_address) values (:sid, :v,:ip)";
$stmte = $pdo->prepare($sqle);
$mapping = array(
':v' => $_SESSION['visit_count'],
':sid'=> session_id(),
':ip' => $_SESSION['ip_address']
);
$stmte->execute($mapping);
if(isset($_SESSION['search']) ) {
$sqls = "UPDATE user_count SET search=:s where user_id = :uid ";
$stmts = $pdo->prepare($sqls);
$mappings = array(
':s' => $row['search'].",". $_SESSION['search'],
':uid'=>$row['user_id']
);
$stmts->execute($mappings);
}
unset($_SESSION['search']);
}
}
?>