-
Notifications
You must be signed in to change notification settings - Fork 1
/
save_history.php
executable file
·80 lines (69 loc) · 1.52 KB
/
save_history.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
<?php
define('PHPWG_ROOT_PATH','../../');
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
include_once(PHPWG_ROOT_PATH.'include/functions_picture.inc.php');
check_status(ACCESS_GUEST);
if (!isset($_POST['imgid'])
or !($imgid = explode('img-', $_POST['imgid']))
or !is_numeric(@$imgid[1]))
{
die;
}
$image_id = pwg_db_real_escape_string($imgid[1]);
$query = 'UPDATE '.IMAGES_TABLE.' SET hit=hit+1, lastmodified = lastmodified WHERE id = '.$image_id.';';
pwg_query($query);
$do_log = $conf['log'];
if (is_admin())
{
$do_log = $conf['history_admin'];
}
if (is_a_guest())
{
$do_log = $conf['history_guest'];
}
if (!$do_log)
{
exit();
}
if (!empty($_POST['section']))
{
$page['section'] = pwg_db_real_escape_string($_POST['section']);
}
if (!empty($_POST['catid']))
{
$page['category']['id'] = pwg_db_real_escape_string($_POST['catid']);
}
if ('tags'==@$page['section'] and !empty($_POST['tagids']))
{
$tags_string = pwg_db_real_escape_string($_POST['tagids']);
}
$query = '
INSERT INTO '.HISTORY_TABLE.'
(
date,
time,
user_id,
IP,
section,
category_id,
image_id,
image_type,
tag_ids,
lightbox
)
VALUES
(
CURDATE(),
CURTIME(),
'.$user['id'].',
\''.$_SERVER['REMOTE_ADDR'].'\',
'.(isset($page['section']) ? "'".$page['section']."'" : 'NULL').',
'.(isset($page['category']['id']) ? $page['category']['id'] : 'NULL').',
'.$image_id.',
"picture",
'.(isset($tags_string) ? "'".$tags_string."'" : 'NULL').',
"true"
)
;';
pwg_query($query);
?>