| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
require_once(dirname(dirname(__FILE__))."/includes.php"); |
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
run("userdetails:init"); |
|---|
| 10 |
run("profile:init"); |
|---|
| 11 |
run("files:init"); |
|---|
| 12 |
|
|---|
| 13 |
global $CFG; |
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
$id = optional_param('id',0,PARAM_INT); |
|---|
| 17 |
$w = optional_param('w',90,PARAM_INT); |
|---|
| 18 |
$h = optional_param('h',90,PARAM_INT); |
|---|
| 19 |
|
|---|
| 20 |
if (!empty($id)) { |
|---|
| 21 |
|
|---|
| 22 |
if ($file = get_record('files','ident',$id)) { |
|---|
| 23 |
if ($file->access == 'PUBLIC' || run("users:access_level_check",$file->access) == true) { |
|---|
| 24 |
|
|---|
| 25 |
require_once($CFG->dirroot . 'lib/filelib.php'); |
|---|
| 26 |
require_once($CFG->dirroot . 'lib/iconslib.php'); |
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
if (function_exists('apache_setenv')) { |
|---|
| 30 |
@apache_setenv('no-gzip', '1'); |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
if ($file->access == 'PUBLIC') { |
|---|
| 34 |
header("Pragma: public"); |
|---|
| 35 |
header("Cache-Control: public"); |
|---|
| 36 |
} else { |
|---|
| 37 |
|
|---|
| 38 |
// Also to override PHP's default "DON'T EVER CACHE THIS EVER" header |
|---|
| 39 |
header("Cache-Control: private"); |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
$mimetype = mimeinfo('type',$file->originalname); |
|---|
| 43 |
if ($mimetype == "image/jpeg" || $mimetype == "image/png" || $mimetype == "image/gif") { |
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 |
$phpthumbconfig = array(); |
|---|
| 47 |
$phpthumbconfig['w'] = $w; |
|---|
| 48 |
$phpthumbconfig['h'] = $h; |
|---|
| 49 |
|
|---|
| 50 |
$filelocation = file_cache($file); |
|---|
| 51 |
spit_phpthumb_image($filelocation, $phpthumbconfig); |
|---|
| 52 |
|
|---|
| 53 |
} else { |
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
header($_SERVER['SERVER_PROTOCOL'] . " 301 Moved Permanently"); |
|---|
| 57 |
header("Location: " . $CFG->wwwroot . '_files/file.png'); |
|---|
| 58 |
die(); |
|---|
| 59 |
|
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
} |
|---|
| 63 |
} |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|
| 66 |
?> |
|---|