手动安装未测试
不用升级数据库
1、把 attchftp.php 文件放在论坛根目录,并修改里面的值。
2、打开 include/common.inc.php,找到:
- require_once DISCUZ_ROOT.'./config.inc.php';
复制代码
在上面添加:
- require_once DISCUZ_ROOT.'./attchftp.php';
复制代码
3、打开 admin/forum.inc.php,找:
- $tids = 0;
- $query = $db->query("SELECT tid FROM {$tablepre}threads WHERE attachment>'0' AND fid='$fid'");
- while($thread = $db->fetch_array($query)) {
- $tids .= ','.$thread['tid'];
- }
- if($tids) {
- $query = $db->query("SELECT filename FROM {$tablepre}attachments WHERE tid IN ($tids)");
- while($attach = $db->fetch_array($query)) {
- @unlink($attachdir.'/'.$attach['filename']);
- }
- $db->query("DELETE FROM {$tablepre}attachments WHERE tid IN ($tids)");
- }
复制代码
修改成:
- $tids = 0;
- $query = $db->query("SELECT tid FROM {$tablepre}threads WHERE attachment>'0' AND fid='$fid'");
- while($thread = $db->fetch_array($query)) {
- $tids .= ','.$thread['tid'];
- }
- if($tids) {
- $query = $db->query("SELECT filename FROM {$tablepre}attachments WHERE tid IN ($tids)");
-
-
- while($attach = $db->fetch_array($query)) {
- if(!($ftplist['store']['on'])){
- @unlink($attachdir.'/'.$attach['filename']);
- }
- }
- $db->query("DELETE FROM {$tablepre}attachments WHERE tid IN ($tids)");
- }
-
- }
复制代码
4、打开 include/post.func.php,找到:
在上面加上:
- global $ftplist,$fid, $timestamp;
复制代码
再找:
- $target = $attachdir.'/'.stripslashes($attach['attachment']);
复制代码
在下面加上:
- if(!$ftplist['store']['on']) {
复制代码
再找:
- $attacharray[] = $attach;
- }
- } else {
- showmessage('post_attachment_save_error');
- }
复制代码
下面加上:
- } else {
- showmessage('post_attachment_save_error');
- }
- } else {
- $attach_fname = substr($filename, 0, 64) . '_' . random(12) . '.' . $extension;
- $ftp_store_hd = ftpconnect($ftplist['store']);
-
- if($attach_subdir) {
- if(!@ftp_chdir($ftp_store_hd, $attach_subdir)) {
- ftp_mkdir($ftp_store_hd, $attach_subdir);
- ftp_chdir($ftp_store_hd, $attach_subdir);
- }
- $attach_fname0 = $attach_subdir . '/' . $attach_fname;
- } else {
- $attach_fname0 = $attach_fname;
- }
- if(@ftp_put($ftp_store_hd, $attach_fname, $attach['tmp_name'], FTP_BINARY)) {
- @ftp_close($ftp_store_hd);
- $attach['filename'] = $attach['name'];
- $attach['filesize'] = $attach['size'];
- $attach['perm'] = $allowsetattachperm ? $attachperm[$key] : 0;
- $attach['description'] = cutstr(dhtmlspecialchars($attachdesc[$key]), 100);
- $attach['attachment'] = $attach_fname0;
- $attacharray[] = $attach;
- if($ftplist['backup']['on']){
- $ftp_backup_hd=ftpconnect($ftplist['backup']);
- if($attach_subdir) {
- if(!@ftp_chdir($ftp_backup_hd, $attach_subdir)) {
- ftp_mkdir($ftp_backup_hd, $attach_subdir);
- ftp_chdir($ftp_backup_hd, $attach_subdir);
- }
-
- }
- if(@ftp_put($ftp_backup_hd,$attach_fname,$attach['tmp_name'],FTP_BINARY)){
- @ftp_close($ftp_backup_hd);
- }
- }
-
-
- } else {
- showmessage('post_attachment_save_error');
- }
- }
复制代码
5、打开 include/editpost.inc.php,找:
- @unlink($attachdir.'/'.$attach['attachment']);
复制代码
有2处
都改成:
- if(!$ftplist['store']['on']) {
- @unlink($attachdir.'/'.$attach['attachment']);
- }
复制代码
6、打开topicadmin.php,找:
找(共两处):
- @unlink($attachdir.'/'.$attach['attachment']);
复制代码
改成:
- if(!$ftplist['store']['on']) {
- @unlink($attachdir.'/'.$attach['attachment']);
- }
复制代码
7、打开attachment.php,找:
- if(is_readable($filename) && $attachexists) {
复制代码
在上面添加:
- if(!$ftplist['store']['on']) {
复制代码
再找:
- else {
- showmessage('attachment_nonexistence');
- }
复制代码 在下面添加:
- } else {
- ob_end_clean();
- header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
- header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
- header('Cache-Control: private');
- header('Pragma: no-cache');
- header('Content-Encoding: none');
- if(!$download && $isimage) {
- header('Content-Disposition: '.(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ? 'inline; ' : 'attachment; ').'filename='.$attach['filename']);
- } else {
- header('Content-Disposition: attachment; filename='.$attach['filename']);
- }
- header('Content-Type: '.$attach['filetype']);
- if($download) {
- $result = ftpconnect($ftplist['store']);
- $ftp_path = dirname($attach[attachment]);
- $ftp_file = basename($attach[attachment]);
- ftp_chdir($result,$ftp_path);
- $tmpfile = tempnam( getcwd()."/", "temp" );
- if(ftp_get($result, $tmpfile, $ftp_file, FTP_BINARY)){
- ftp_quit($result);
- readfile($tmpfile);
- unlink($tmpfile);
- exit;
- } else {
- showmessage('attachment_nonexistence');
- }
- unlink($tmpfile);
- ftp_quit($result);
- } else {
- readfile($ftplist['store']['url'].'/'.$attach['attachment']);
- }
- if(!$isimage) {
- updatecredits($discuz_uid, $creditspolicy['getattach'], -1);
- }
- }
复制代码
8、完成。
attchftp.php同
[ 本帖最后由 plainer13 于 2006-5-13 15:13 编辑 ] |