creating user agent column for activities

This commit is contained in:
Matthieu Leproux
2022-06-21 13:56:34 +02:00
parent 0e0ab49fac
commit 3d69c6b093
4 changed files with 37 additions and 5 deletions

View File

@@ -556,9 +556,10 @@ function pwg_activity($object, $object_id, $action, $details=array())
}
}
if ('user' == $object and 'login' == $action)
$user_agent = null;
if ('user' == $object and 'login' == $action and isset($_SERVER['HTTP_USER_AGENT']))
{
$details['agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'unknown';
$user_agent = $_SERVER['HTTP_USER_AGENT'];
}
if ('photo' == $object and 'add' == $action and !isset($details['sync']))
@@ -568,7 +569,6 @@ function pwg_activity($object, $object_id, $action, $details=array())
{
$details['added_with'] = 'browser';
}
$details['agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'unknown';
}
if (in_array($object, array('album', 'photo')) and 'delete' == $action and isset($_GET['page']) and 'site_update' == $_GET['page'])
@@ -603,6 +603,7 @@ function pwg_activity($object, $object_id, $action, $details=array())
'session_idx' => session_id(),
'ip_address' => $ip_address,
'details' => $details_insert,
'user_agent' => $user_agent,
);
}

View File

@@ -445,7 +445,8 @@ SELECT
session_idx,
ip_address,
occured_on,
details
details,
user_agent
FROM '.ACTIVITY_TABLE.'
WHERE performed_by = '.$param['uid'].'
ORDER BY activity_id DESC LIMIT '.$page_size.' OFFSET '.$page_offset.';
@@ -463,7 +464,8 @@ SELECT
session_idx,
ip_address,
occured_on,
details
details,
user_agent
FROM '.ACTIVITY_TABLE.'
ORDER BY activity_id DESC LIMIT '.$page_size.' OFFSET '.$page_offset.';
;';
@@ -477,6 +479,11 @@ SELECT
$row['details'] = str_replace('`rank`', 'rank', $row['details']);
$details = @unserialize($row['details']);
if (isset($row['user_agent']))
{
$details['agent'] = $row['user_agent'];
}
if (isset($details['method']))
{
$detailsType = 'method';

View File

@@ -0,0 +1,23 @@
<?php
// +-----------------------------------------------------------------------+
// | This file is part of Piwigo. |
// | |
// | For copyright and license information, please view the COPYING.txt |
// | file that was distributed with this source code. |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}
$upgrade_description = 'Create dedicated user agent column for activity.';
pwg_query('
ALTER TABLE `'.PREFIX_TABLE.'activity`
ADD COLUMN `user_agent` varchar(255) default NULL
;');
echo "\n".$upgrade_description."\n";
?>

View File

@@ -19,6 +19,7 @@ CREATE TABLE `piwigo_activity` (
`ip_address` varchar(50) DEFAULT NULL,
`occured_on` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`details` varchar(255) DEFAULT NULL,
`user_agent` varchar(255) DEFAULT NULL,
PRIMARY KEY (`activity_id`)
) ENGINE=MyISAM;