Projet

Général

Profil

Paste
Télécharger (912 octets) Statistiques
| Branche: | Révision:

root / drupal7 / modules / statistics / statistics.php @ db2d93dd

1
<?php
2

    
3
/**
4
 * @file
5
 * Handles counts of node views via Ajax with minimal bootstrap.
6
 */
7

    
8
/**
9
* Root directory of Drupal installation.
10
*/
11
define('DRUPAL_ROOT', substr($_SERVER['SCRIPT_FILENAME'], 0, strpos($_SERVER['SCRIPT_FILENAME'], '/modules/statistics/statistics.php')));
12
// Change the directory to the Drupal root.
13
chdir(DRUPAL_ROOT);
14

    
15
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
16
drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
17
if (variable_get('statistics_count_content_views', 0) && variable_get('statistics_count_content_views_ajax', 0)) {
18
  $nid = $_POST['nid'];
19
  if (is_numeric($nid)) {
20
    db_merge('node_counter')
21
      ->key(array('nid' => $nid))
22
      ->fields(array(
23
        'daycount' => 1,
24
        'totalcount' => 1,
25
        'timestamp' => REQUEST_TIME,
26
      ))
27
      ->expression('daycount', 'daycount + 1')
28
      ->expression('totalcount', 'totalcount + 1')
29
      ->execute();
30
  }
31
}