应用举例
在我BLOG里面<青岛旅行>引用了论坛上传的附件图片,但是我关闭了游客查看附件.这样其他人浏览我BLOG就只能看见"叉烧包"了.
(虽然点"叉烧包"论坛会引导访客进行登陆然后查看)
针对这样的应用,修改了一下附件显示程序,效果如下
修改attachment.php 96行
代码:
$forums->func->standard_error("cannotdownload");
改成
代码:
//$forums->func->standard_error("cannotdownload");
if(in_array($_INPUT['extension'], array( 'jpg', 'bmp', 'gif','png') )){
$showfile='images/cannotdownload.gif';
@header('Content-Type: '.$forums->cache['attachmenttype']['gif']['mimetype']);
@header('Cache-control: max-age=0');
@header('Expires: ' . gmdate("D, d M Y H:i:s", TIMENOW + 31536000) . ' GMT');
@header('Content-Disposition: inline; filename="' . urldecode('cannotdownload.gif') . '"');
@header('Content-Transfer-Encoding: binary');
@header('Content-Length: ' . (string)(filesize($showfile)));
@readfile($showfile);
}else{
$forums->func->standard_error("cannotdownload");
}
图片cannotdownload.gif放在images文件夹下 你可以自己定义图片.
仅对图片有效,对于其他附件,游客点击附件地址还是会引导游客登陆.