2016-01-08 21:00:02 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-25 10:47:09 +00:00
|
|
|
require_once ('vn/lib/method.php');
|
2016-01-08 21:00:02 +00:00
|
|
|
|
2016-08-25 10:47:09 +00:00
|
|
|
class VisitsSync extends Vn\Lib\Method
|
2016-01-08 21:00:02 +00:00
|
|
|
{
|
|
|
|
function run ()
|
2016-07-22 20:00:27 +00:00
|
|
|
{
|
|
|
|
$db = $this->getSysConn ();
|
|
|
|
$result = $db->query ("SELECT id, agent FROM visit_agent
|
|
|
|
WHERE version = '0.0' OR platform = 'unknown' OR cookies IS NULL ORDER BY id DESC");
|
|
|
|
|
|
|
|
$stmt = $db->prepare ('UPDATE visit_agent
|
|
|
|
SET platform = ?, browser = ?, version = ?, javascript = ?, cookies = ? WHERE id = ?');
|
2016-01-08 21:00:02 +00:00
|
|
|
|
|
|
|
if ($result && $stmt)
|
|
|
|
{
|
|
|
|
set_time_limit (0);
|
|
|
|
|
|
|
|
$stmt->bind_param('sssiii'
|
|
|
|
,$platform
|
|
|
|
,$browser
|
|
|
|
,$version
|
|
|
|
,$javascript
|
|
|
|
,$cookies
|
|
|
|
,$id
|
|
|
|
);
|
|
|
|
|
|
|
|
// Update the visit info using browscap
|
2016-08-25 10:47:09 +00:00
|
|
|
|
|
|
|
$count = 0;
|
2016-01-08 21:00:02 +00:00
|
|
|
|
|
|
|
while ($row = $result->fetch_assoc ())
|
|
|
|
{
|
|
|
|
$info = get_browser ($row['agent']);
|
|
|
|
$platform = $info->platform;
|
|
|
|
$browser = $info->browser;
|
|
|
|
$version = $info->version;
|
|
|
|
$javascript = $info->javascript;
|
|
|
|
$cookies = $info->cookies;
|
|
|
|
$id = $row['id'];
|
|
|
|
$stmt->execute ();
|
2016-08-25 10:47:09 +00:00
|
|
|
|
|
|
|
$count++;
|
2016-01-08 21:00:02 +00:00
|
|
|
}
|
|
|
|
|
2016-08-25 10:47:09 +00:00
|
|
|
echo "$count records updated";
|
2016-01-08 21:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($stmt)
|
|
|
|
$stmt->close ();
|
|
|
|
if ($result)
|
|
|
|
$result->free ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|