diff --git a/src/messenger/webim/install/dbinfo.php b/src/messenger/webim/install/dbinfo.php index dc053acb..f10803d1 100644 --- a/src/messenger/webim/install/dbinfo.php +++ b/src/messenger/webim/install/dbinfo.php @@ -136,6 +136,12 @@ $dbtables = array( "visittime" => "datetime NOT NULL DEFAULT 0", "visitorid" => "INT", ), + + "${mysqlprefix}visitedpagestatistics" => array( + "pageid" => "INT NOT NULL auto_increment PRIMARY KEY", + "address" => "varchar(1024)", + "visittime" => "datetime NOT NULL DEFAULT 0" + ), ); $dbtables_indexes = array( @@ -162,6 +168,7 @@ $dbtables_can_update = array( "${mysqlprefix}chatresponses" => array("vctitle"), "${mysqlprefix}chatsitevisitor" => array(), "${mysqlprefix}visitedpage" => array(), + "${mysqlprefix}visitedpagestatistics" => array(), ); function show_install_err($text) diff --git a/src/messenger/webim/libs/track.php b/src/messenger/webim/libs/track.php index 91dabfd2..63d056eb 100644 --- a/src/messenger/webim/libs/track.php +++ b/src/messenger/webim/libs/track.php @@ -91,6 +91,8 @@ function track_visit_page($visitorid, $page, $link) perform_query(sprintf("insert into ${mysqlprefix}visitedpage (visitorid, address, visittime) values ('%s', '%s', CURRENT_TIMESTAMP)", db_escape_string($visitorid), db_escape_string($page)), $link); + perform_query(sprintf("insert into ${mysqlprefix}visitedpagestatistics (address, visittime) values ('%s', CURRENT_TIMESTAMP)", + db_escape_string($page)), $link); } } diff --git a/src/messenger/webim/operator/statistics.php b/src/messenger/webim/operator/statistics.php index bfa02c7a..a2dc4dab 100644 --- a/src/messenger/webim/operator/statistics.php +++ b/src/messenger/webim/operator/statistics.php @@ -83,7 +83,7 @@ $page['reportByAgent'] = select_multi_assoc("select vclocalename as name, COUNT( "where agentId = operatorid AND unix_timestamp(dtmcreated) >= $start AND unix_timestamp(dtmcreated) < $end group by operatorid", $link); $page['reportByPage'] = select_multi_assoc("SELECT COUNT(p.pageid) as visittimes, p.address, COUNT(t.threadid) as chattimes " . - "FROM ${mysqlprefix}visitedpage p LEFT OUTER JOIN ${mysqlprefix}chatthread t ON (p.address = t.referer AND DATE(p.visittime) = DATE(t.dtmcreated)) " . + "FROM ${mysqlprefix}visitedpagestatistics p LEFT OUTER JOIN ${mysqlprefix}chatthread t ON (p.address = t.referer AND DATE(p.visittime) = DATE(t.dtmcreated)) " . "WHERE unix_timestamp(p.visittime) >= $start AND unix_timestamp(p.visittime) < $end GROUP BY p.address", $link); $page['showresults'] = count($errors) == 0; diff --git a/src/messenger/webim/operator/update.php b/src/messenger/webim/operator/update.php index cf55ec2f..ac36d9bd 100644 --- a/src/messenger/webim/operator/update.php +++ b/src/messenger/webim/operator/update.php @@ -214,7 +214,7 @@ function print_visitors() $link = connect(); -// Remove old visitors' tracks +// Remove old visitors $query = "DELETE FROM ${mysqlprefix}chatsitevisitor WHERE (UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(lasttime)) > " . $settings['tracking_lifetime'] . " AND (threadid IS NULL OR (SELECT count(*) FROM ${mysqlprefix}chatthread WHERE threadid = ${mysqlprefix}chatsitevisitor.threadid" . " AND istate <> $state_closed AND istate <> $state_left) = 0)"; @@ -232,6 +232,11 @@ function print_visitors() " AND istate <> $state_closed AND istate <> $state_left) = 0"; perform_query($query, $link); +// Remove old visitors' tracks + $query = "DELETE FROM ${mysqlprefix}visitedpage WHERE (UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(visittime)) > " . $settings['tracking_lifetime'] . + " AND visitorid NOT IN (SELECT visitorid FROM ${mysqlprefix}chatsitevisitor)"; + perform_query($query, $link); + $output = array(); $query = "SELECT visitorid, userid, username, unix_timestamp(firsttime), unix_timestamp(lasttime), " .