function cdn_file_server in CDN 5
Implementation of hook_file_server().
File
- ./
cdn.inc, line 11 - Basic functions for CDN integration and synchronization.
Code
function cdn_file_server($op, $file_path, $absolute_url = FALSE) {
switch ($op) {
case 'info':
return array(
'type' => t('Content Delivery Network'),
'description' => t('A content delivery network is a load-balanced network of static file
servers that are located at various places all over the planet.'),
'configuration_page' => 'admin/settings/cdn',
);
break;
case 'url':
// If debug mode is enabled and the user doesn't have the necessary
// permission to access files on the CDN when debug mode is enabled,
// return FALSE (i.e. pretend the file does not exist on the CDN).
if ((bool) variable_get('cdn_debug_mode', 0) && !user_access('access files on CDN when in debug mode')) {
return FALSE;
}
// URLs on a CDN are always absolute!
$url = cdn_file_url($file_path);
// If the user can access it, add this to the per-page statistics.
if (variable_get('cdn_dev_page_stats', 0) && user_access('access per-page statistics')) {
_cdn_devel_page_stats($file_path, !$url ? '' : $url, (bool) $url);
}
return $url;
break;
}
}