Projet

Général

Profil

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

root / drupal7 / modules / statistics / statistics.php @ 01dfd3b5

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
  if (isset($_POST['nid'])) {
19
    $nid = $_POST['nid'];
20
    if (is_numeric($nid)) {
21
      db_merge('node_counter')
22
        ->key(array('nid' => $nid))
23
        ->fields(array(
24
          'daycount' => 1,
25
          'totalcount' => 1,
26
          'timestamp' => REQUEST_TIME,
27
        ))
28
        ->expression('daycount', 'daycount + 1')
29
        ->expression('totalcount', 'totalcount + 1')
30
        ->execute();
31
    }
32
  }
33
}