image_view_counter: also saving with user ID with addview() for later use
This commit is contained in:
parent
93a431dce7
commit
b88f7a4d6b
1 changed files with 7 additions and 4 deletions
|
@ -47,6 +47,7 @@ class image_view_counter extends Extension {
|
||||||
$database->execute("CREATE TABLE image_views (
|
$database->execute("CREATE TABLE image_views (
|
||||||
id bigint(20) NOT NULL AUTO_INCREMENT,
|
id bigint(20) NOT NULL AUTO_INCREMENT,
|
||||||
image_id int(11) NOT NULL,
|
image_id int(11) NOT NULL,
|
||||||
|
user_id int(11) NOT NULL,
|
||||||
timestamp int(11) NOT NULL,
|
timestamp int(11) NOT NULL,
|
||||||
ipaddress varchar(255) NOT NULL,
|
ipaddress varchar(255) NOT NULL,
|
||||||
PRIMARY KEY (id))");
|
PRIMARY KEY (id))");
|
||||||
|
@ -57,14 +58,16 @@ class image_view_counter extends Extension {
|
||||||
# Adds a view to the item if needed
|
# Adds a view to the item if needed
|
||||||
private function addview($imgid)
|
private function addview($imgid)
|
||||||
{
|
{
|
||||||
global $database;
|
global $database, $user;
|
||||||
|
|
||||||
// don't add view if person already viewed recently
|
// don't add view if person already viewed recently
|
||||||
if ($this->can_add_view($imgid) == false) return;
|
if ($this->can_add_view($imgid) == false) return;
|
||||||
|
|
||||||
// Add view for current IP
|
// Add view for current IP
|
||||||
$database->execute("INSERT INTO image_views (image_id, timestamp, ipaddress)
|
$database->execute("INSERT INTO image_views (image_id, user_id, timestamp, ipaddress)
|
||||||
VALUES (:image_id, :timestamp, :ipaddress)", array(
|
VALUES (:image_id, :user_id, :timestamp, :ipaddress)", array(
|
||||||
"image_id" => $imgid,
|
"image_id" => $imgid,
|
||||||
|
"user_id" => $user->id,
|
||||||
"timestamp" => time(),
|
"timestamp" => time(),
|
||||||
"ipaddress" => $_SERVER['REMOTE_ADDR'],
|
"ipaddress" => $_SERVER['REMOTE_ADDR'],
|
||||||
));
|
));
|
||||||
|
|
Reference in a new issue