SMF中文附件問題

Home Home
引用 | 編輯 笑笑
2008-06-27 09:51
樓主
推文 x0
因為之前幫朋友弄的網站是用 SMF 架論壇的,不過他一直有一個問題,就是附件是中文檔名時,就無法下載,本來一直找不到問題,後來去更新了 1.1.5 版,還是有一樣的問題,最後上 Google 找到了解決方式,如果有相同問題的,可以試著改看看

打開
./sources/display.php
搜索:
程式碼:
複製程式
   $filename = getAttachmentFilename($real_filename, $_REQUEST['attach']);
在下邊添加:
程式碼:
複製程式
   // fix IE attachmentfilename encoding bug add by d9tx
   if(strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strstr($_SERVER['HTTP_USER_AGENT'], 'Internet Explorer'))
   $real_filename=urlencode($real_filename);

編輯
Subs-Post.php

尋找
複製程式
db_query(" 
INSERT INTO {$db_prefix}attachments 
(ID_MSG, filename, size, width, height) 
VALUES (" . (int) $attachmentOptions['post'] . ", SUBSTRING('" . $attachmentOptions['name'] . "', 1, 255), " . (int) $attachmentOptions['size'] . ', ' . (empty($attachmentOptions['width']) ? Ɔ' : (int) $attachmentOptions['width']) . ', ' . (empty($attachmentOptions['height']) ? Ɔ' : (int) $attachmentOptions['height']) . ')', __FILE__, __LINE__); 
$attachmentOptions['id'] = db_insert_id(); 

在上面這一段文字的上方,加入下面這二行就ok了。

複製程式
$a="_"; 
$attachmentOptions['name']=$a.$attachmentOptions['name'];

其主要功能就是在前面加入_文字,_文字也可以用其它英文代替,例如$a="A";

以上方法參考 http://openlyu.com/forums/index.php/topic,3074.0.html

獻花 x0