2012-04-26 04:05:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Handles counts of node views via AJAX with minimal bootstrap.
|
|
|
|
*/
|
|
|
|
|
2014-06-05 17:53:24 +00:00
|
|
|
// Change the directory to the Drupal root.
|
2012-04-26 04:05:27 +00:00
|
|
|
chdir('../../..');
|
|
|
|
|
2014-06-05 17:53:24 +00:00
|
|
|
// Load the Drupal bootstrap.
|
|
|
|
require_once dirname(dirname(__DIR__)) . '/vendor/autoload.php';
|
|
|
|
require_once dirname(dirname(__DIR__)) . '/includes/bootstrap.inc';
|
|
|
|
drupal_bootstrap(DRUPAL_BOOTSTRAP_KERNEL);
|
2012-08-07 19:49:48 +00:00
|
|
|
|
2014-06-05 17:53:24 +00:00
|
|
|
if (\Drupal::config('statistics.settings')->get('count_content_views')) {
|
2012-08-09 20:21:01 +00:00
|
|
|
$nid = filter_input(INPUT_POST, 'nid', FILTER_VALIDATE_INT);
|
|
|
|
if ($nid) {
|
2014-02-11 11:27:02 +00:00
|
|
|
\Drupal::database()->merge('node_counter')
|
2014-03-05 19:57:36 +00:00
|
|
|
->key('nid', $nid)
|
2012-04-26 04:05:27 +00:00
|
|
|
->fields(array(
|
|
|
|
'daycount' => 1,
|
|
|
|
'totalcount' => 1,
|
|
|
|
'timestamp' => REQUEST_TIME,
|
|
|
|
))
|
|
|
|
->expression('daycount', 'daycount + 1')
|
|
|
|
->expression('totalcount', 'totalcount + 1')
|
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|