You are here

function cdn_exit in CDN 6

Same name and namespace in other branches
  1. 5 cdn.module \cdn_exit()
  2. 6.2 cdn.module \cdn_exit()
  3. 7.2 cdn.module \cdn_exit()

Implementation of hook_exit().

File

./cdn.module, line 163
Implementation of the core hooks, defines, public and private functions.

Code

function cdn_exit($destination = NULL) {
  require_once drupal_get_path('module', 'cdn') . '/cdn.stats.inc';

  // Try not to break non-HTML pages.
  if (function_exists('drupal_get_headers')) {
    $headers = drupal_get_headers();
    $formats = array(
      'xml',
      'javascript',
      'json',
      'plain',
      'image',
      'application',
      'csv',
      'x-comma-separated-values',
    );
    foreach ($formats as $format) {
      if (strstr($headers, $format)) {
        return;
      }
    }
  }
  if (!$destination && variable_get(CDN_STATUS_VARIABLE, CDN_DISABLED) != CDN_DISABLED && variable_get(CDN_STATS_VARIABLE, FALSE) && user_access(CDN_PERM_ACCESS_STATS)) {
    list($file_count, $cdn_file_count, $synced_files_per_server_count, $total_time, $synced_files, $unsynced_files, ) = _cdn_devel_page_stats();
    print theme('cdn_page_stats', $file_count, $cdn_file_count, $synced_files_per_server_count, $total_time, $synced_files, $unsynced_files);
  }
}