⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 attachment.php

📁 xm2sv1.0寻梦二手网 v1.0,一个经过我调试的PHP原代码,有机会大家多交流哈
💻 PHP
字号:
<?php

/*
	[DISCUZ!] attachment.php - attachment downloading
	This is NOT a freeware, use is subject to license terms

	Version: 2.0.0
	Author: Crossday (info@discuz.net)
	Copyright: Crossday Studio (www.crossday.com)
	Last Modified: 2002/12/6 17:00
*/

require './include/common.php';

$discuz_action = 14;

$query = $db->query("SELECT a.*, t.fid FROM $table_attachments a LEFT JOIN $table_threads t ON a.tid=t.tid WHERE aid='$aid'");
$attach = $db->fetch_array($query);
if($allowgetattach && $attach['creditsrequire'] && $attach['creditsrequire'] > $credit && !$ismoderator) {
	showmessage('attachment_nopermission');
}

$query = $db->query("SELECT * FROM $table_forums WHERE fid='$attach[fid]'");
$forum = $db->fetch_array($query);
if(!$forum['getattachperm'] && !$allowgetattach) {
	showmessage('group_nopermission');
} elseif($forum['getattachperm'] && !strstr($forum['getattachperm'], "\t$groupid\t")) {
	showmessage('attachment_forum_nopermission');
}

$db->query("UPDATE $table_attachments SET downloads=downloads+1 WHERE aid='$aid'");
$filename = $discuz_root.$attachdir.'/'.$attach['attachment'];

if(is_readable($filename) && $attach) {
	$filesize = filesize($filename);

	ob_end_clean();
	header('Content-Encoding: none');
	header('Cache-Control: private');
	header('Content-Length: '.$filesize);
	header('Content-Disposition: '.(strpos($HTTP_SERVER_VARS['HTTP_USER_AGENT'], 'MSIE') ? 'inline; ' : 'attachment; ').'filename='.$attach['filename']);
	header('Content-Type: '.$attach['filetype']);

	@$fp = fopen($filename, 'rb');
	@flock($fp, 3);
	$attachment = @fread($fp, $filesize);
	@fclose($fp);
	echo $attachment;
} else {
	showmessage('attachment_nonexistence');
}

?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -