- Patch #8733 by Morbus Iff: fixed statistics module.
parent
0be1e6cff7
commit
f6b7f75512
|
@ -74,13 +74,13 @@ function statistics_exit() {
|
|||
|
||||
if (variable_get('statistics_count_content_views', 0)) {
|
||||
// We are counting content views.
|
||||
if ((arg(0) == 'node') && (arg(1) == 'view') && arg(2)) {
|
||||
if ((arg(0) == 'node') && arg(1)) {
|
||||
// A node has been viewed, so update the node's counters.
|
||||
db_query('UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d', time(), arg(2));
|
||||
db_query('UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d', time(), arg(1));
|
||||
// If we affected 0 rows, this is the first time viewing the node.
|
||||
if (!db_affected_rows()) {
|
||||
// We must create a new row to store counters for the new node.
|
||||
db_query('INSERT INTO {node_counter} (nid, daycount, totalcount, timestamp) VALUES(%d, 1, 1, %d)', arg(2), time());
|
||||
db_query('INSERT INTO {node_counter} (nid, daycount, totalcount, timestamp) VALUES(%d, 1, 1, %d)', arg(1), time());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,8 +91,8 @@ function statistics_exit() {
|
|||
$hostname = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
// Log this page access.
|
||||
if ((arg(0) == 'node') && (arg(1) == 'view') && arg(2)) {
|
||||
db_query("INSERT INTO {accesslog} (nid, url, hostname, uid, timestamp) values(%d, '%s', '%s', %d, %d)", arg(2), $referrer, $hostname, $user->uid, time());
|
||||
if ((arg(0) == 'node') && arg(1)) {
|
||||
db_query("INSERT INTO {accesslog} (nid, url, hostname, uid, timestamp) values(%d, '%s', '%s', %d, %d)", arg(1), $referrer, $hostname, $user->uid, time());
|
||||
}
|
||||
else {
|
||||
db_query("INSERT INTO {accesslog} (url, hostname, uid, timestamp) values('%s', '%s', %d, %d)", $referrer, $hostname, $user->uid, time());
|
||||
|
@ -121,7 +121,7 @@ function statistics_link($type, $node = 0, $main = 0) {
|
|||
|
||||
$links = array();
|
||||
|
||||
if ($type == 'node' && user_access('access statistics') && variable_get('statistics_display_counter', 0)) {
|
||||
if ($type != 'comment' && user_access('access statistics') && variable_get('statistics_display_counter', 0)) {
|
||||
$statistics = statistics_get($node->nid);
|
||||
if ($statistics) {
|
||||
if (user_access('administer statistics')) {
|
||||
|
|
|
@ -74,13 +74,13 @@ function statistics_exit() {
|
|||
|
||||
if (variable_get('statistics_count_content_views', 0)) {
|
||||
// We are counting content views.
|
||||
if ((arg(0) == 'node') && (arg(1) == 'view') && arg(2)) {
|
||||
if ((arg(0) == 'node') && arg(1)) {
|
||||
// A node has been viewed, so update the node's counters.
|
||||
db_query('UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d', time(), arg(2));
|
||||
db_query('UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d', time(), arg(1));
|
||||
// If we affected 0 rows, this is the first time viewing the node.
|
||||
if (!db_affected_rows()) {
|
||||
// We must create a new row to store counters for the new node.
|
||||
db_query('INSERT INTO {node_counter} (nid, daycount, totalcount, timestamp) VALUES(%d, 1, 1, %d)', arg(2), time());
|
||||
db_query('INSERT INTO {node_counter} (nid, daycount, totalcount, timestamp) VALUES(%d, 1, 1, %d)', arg(1), time());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,8 +91,8 @@ function statistics_exit() {
|
|||
$hostname = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
// Log this page access.
|
||||
if ((arg(0) == 'node') && (arg(1) == 'view') && arg(2)) {
|
||||
db_query("INSERT INTO {accesslog} (nid, url, hostname, uid, timestamp) values(%d, '%s', '%s', %d, %d)", arg(2), $referrer, $hostname, $user->uid, time());
|
||||
if ((arg(0) == 'node') && arg(1)) {
|
||||
db_query("INSERT INTO {accesslog} (nid, url, hostname, uid, timestamp) values(%d, '%s', '%s', %d, %d)", arg(1), $referrer, $hostname, $user->uid, time());
|
||||
}
|
||||
else {
|
||||
db_query("INSERT INTO {accesslog} (url, hostname, uid, timestamp) values('%s', '%s', %d, %d)", $referrer, $hostname, $user->uid, time());
|
||||
|
@ -121,7 +121,7 @@ function statistics_link($type, $node = 0, $main = 0) {
|
|||
|
||||
$links = array();
|
||||
|
||||
if ($type == 'node' && user_access('access statistics') && variable_get('statistics_display_counter', 0)) {
|
||||
if ($type != 'comment' && user_access('access statistics') && variable_get('statistics_display_counter', 0)) {
|
||||
$statistics = statistics_get($node->nid);
|
||||
if ($statistics) {
|
||||
if (user_access('administer statistics')) {
|
||||
|
|
Loading…
Reference in New Issue