Advertisement
Guest User

Untitled

a guest
May 27th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. function drupalwiki_privatefile_imagecache($preset,$prv_id) {  
  2.   if(is_numeric($prv_id)) {
  3.     // Now actually check if we have access
  4.     if(_drupalwiki_privatefile_access_api('view',$prv_id)) {
  5.       $file = _drupalwiki_privatefile_load_file($prv_id);
  6.       _imagecache_cache($preset, $file->orig_src);
  7.     }
  8.     else {
  9.     return '';
  10.     // well this url is not valid
  11.     $accesspath = file_create_path('imagecache/'. $preset .'.403.png');
  12.     if (is_file($accesspath)) {
  13.       imagecache_transfer($accesspath);
  14.       exit;
  15.     }
  16.     header('HTTP/1.0 403 Forbidden');
  17.     exit;          
  18.     }    
  19.   }
  20.   else {
  21.     header('HTTP/1.0 404 Not found');
  22.     exit;
  23.   }
  24. }
  25.  
  26. function drupalwiki_privatefile_imagecache_prefixpath_alter(&$path,$base,$filepath, $absolute) {  
  27.   $matches = array();
  28.   if(preg_match("@privatefile/(\d)+@", $filepath, $matches)) {
  29.     // override completely
  30.     $path = 'privatefile';
  31.   }
  32.   // else this is no private file, dont change anything
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement