forked from fl4p/WP-Filebase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
thumbnail.php
47 lines (38 loc) · 1.29 KB
/
thumbnail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
if (!defined('WPFB')) {
exit;
}
/* make sure we loaded the pluggable functions */
require( ABSPATH . WPINC . '/pluggable.php' );
define('WPFB_NO_CORE_INIT', true);
wpfb_loadclass('Core', 'File', 'Category', 'Download');
$item = null;
if (isset($_GET['fid'])) {
$item = WPFB_File::GetFile(0 + $_GET['fid']);
} elseif (isset($_GET['cid'])) {
$item = WPFB_Category::GetCat(0 + $_GET['cid']);
}
if ($item == null || !$item->CurUserCanAccess(true)) {
header('X-Fallback-Thumb: 1');
$img_path = ABSPATH . WPINC . '/images/';
if (file_exists($img = $img_path . 'crystal/default.png')
|| file_exists($img = $img_path . 'media/default.png')
) {
WPFB_Download::SendFile($img, array('cache_max_age' => -1)); //was 3600 * 12
} else {
// single transparent pixel gif
header('Content-Type: image/gif');
header('Cache-Control: public');
echo base64_decode('R0lGODlhAQABAJAAAP8AAAAAACH5BAUQAAAALAAAAAABAAEAAAICBAEAOw==');
}
exit;
}
// if no thumbnail, redirect
if (empty($item->file_thumbnail) && empty($item->cat_icon)) {
header('Cache-Control: public');
wp_redirect($item->GetIconUrl(), 301/*permanently*/);
exit;
}
// send thumbnail
WPFB_Download::SendFile($item->GetThumbPath(), array('cache_max_age' => -1));
exit;