[解決] phpbb3 上傳的附加檔案, 若以中文開頭命名, 則無法正確顯示之問題

與 phpBB 3.0.x 相關主題。

版主: 版主管理群

michaelchain
星球公民
星球公民
文章: 129
註冊時間: 2006-10-17 03:13

文章 michaelchain »

这是IE的问题... 之前在phpbb2下我已经尝试了各种方法均无效... 所以放弃了.
※伺服器主機:Intel Core2 酷睿™2 E6300, 升級到4GB RAM了
※主機作業系統:CentOS 4 Linux
※我的 phpBB 版本:phpBB3.0.?
※我的網址: 中文PHPBB
ycl8000
星球普通子民
星球普通子民
文章: 12
註冊時間: 2007-03-01 09:27

Re: [問題]關於phpbb3 上傳附件中文檔名問題

文章 ycl8000 »

我在這個網站有看到解決這個問題的方法.
http://phpbbfans.web4chinese.com/forum/ ... p?f=5&t=74

不過我按照第二個方式修改,發現有些檔案不對,我想可能是版本的問題,
我用的是phpbb3正式版,原作者可能是某個RC版.
既然知道要改那裡了,我就用搜尋的,找到正確的檔案,經過測試後,
上傳開頭為中文的檔名,已能正常顯示。

我的環境是:phpbb3.0+php5

修改方法如下:
需要的文件有三個:
includes/functions_content.php.php
includes/functions_upload.php
includes/functions_posting.php

includes/functions_content.php
找到

代碼:

代碼: 選擇全部

'DOWNLOAD_NAME' => basename($attachment['real_filename']),
改成

代碼:

代碼: 選擇全部

'DOWNLOAD_NAME' => mybasename($attachment['real_filename']),
找到

代碼:
/**
* Check if extension is allowed to be posted.

前面添加

代碼:

代碼: 選擇全部

function mybasename($path)
{
$paths = explode('/', $path);
$temps = explode('\\', $paths[count($paths)-1]);
$basename = $temps[count($temps)-1];
return $basename;
}
includes/functions_upload.php
找到

代碼:
/**
* File Class
* @access private

前面添加

代碼:

代碼: 選擇全部

function mybasename($path)
{
$paths = explode('/', $path);
$temps = explode('\\', $paths[count($paths)-1]);
$basename = $temps[count($temps)-1];
return $basename;
}
找到

代碼:

代碼: 選擇全部

$name = trim(htmlspecialchars($this->basename($upload_ary['name'])));
改成

代碼:

代碼: 選擇全部

$name = trim(htmlspecialchars($this->mybasename($upload_ary['name'])));
includes/functions_posting.php
找到

代碼:

代碼: 選擇全部

$attach_row['real_filename'] = basename($attach_row['real_filename']);
改成

代碼:

代碼: 選擇全部

$attach_row['real_filename'] = mybasename($attach_row['real_filename']);
找到

代碼:

代碼: 選擇全部

'FILENAME' => basename($attach_row['real_filename']),
改成

代碼:

代碼: 選擇全部

'FILENAME' => mybasename($attach_row['real_filename']),
找到

代碼:

代碼: 選擇全部

$s_inline_attachment_options .= '<option value="' . $i . '">' . basename($attachment['real_filename']) . '</option>';
改成

代碼:

代碼: 選擇全部

$s_inline_attachment_options .= '<option value="' . $i . '">' . mybasename($attachment['real_filename']) . '</option>';
原作者有提到:
重複添加了兩個一樣的函數, 比較愚蠢的做法, 但是沒有找到可以不用include而又能跨類調用的函數形式, 如果有更好的方法請幫忙改進.
所以如果有更好的方法,請大家幫忙改進.
jcasper
星球公民
星球公民
文章: 88
註冊時間: 2008-02-02 00:26
來自: 台南的鄉間小路
聯繫:

Re: [問題]關於phpbb3 上傳附件中文檔名問題

文章 jcasper »

恩 最近第一次在自己論壇上傳附加檔案
也遇到這問題說
所幸有上面大大的教學
就解決問題了
連自己測試按連結下載時
檔名的儲存也都正常唷
●主機連結: http://jc-sky.com
●主機作業系統:Linux (Apache 2.2.8 + PHP 5.2.5 + MySQL 5.0.45)
●上網方式:Seednet ADSL
●phpBB3 版本:phpBB 3.0.0
●phpBB3 使用風格:prosilver
●domain(網域名稱) : http://jc-sky.com
●phpBB3 連結網址: http://jc-sky.com/phpBB3
頭像
心靈捕手
默默耕耘的老師
默默耕耘的老師
文章: 8510
註冊時間: 2004-04-30 01:54
來自: Taiwan

[整理] 解決 phpbb3 上傳的附加檔案, 若以中文開頭命名, 則無法正確顯示之問題

文章 心靈捕手 »

使用環境: phpBB 3.0.2 + PHP 5.2.6

#
#-----[ OPEN ]-----
#
includes/functions_content.php

#
#-----[ FIND ]-----
#

代碼: 選擇全部

			'DOWNLOAD_NAME'		=> basename($attachment['real_filename']),
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

			'DOWNLOAD_NAME'		=> mybasename($attachment['real_filename']),
#
#-----[ FIND ]-----
#

代碼: 選擇全部

/**
* Check if extension is allowed to be posted.
#
#-----[ BEFORE, ADD ]-----
#

代碼: 選擇全部

function mybasename($path)
{
$paths = explode('/', $path);
$temps = explode('\\', $paths[count($paths)-1]);
$basename = $temps[count($temps)-1];
return $basename;
}
#
#-----[ OPEN ]-----
#
includes/functions_posting.php

#
#-----[ FIND ]-----
#

代碼: 選擇全部

			$s_inline_attachment_options .= '<option value="' . $i . '">' . basename($attachment['real_filename']) . '</option>';
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

			$s_inline_attachment_options .= '<option value="' . $i . '">' . mybasename($attachment['real_filename']) . '</option>';
#
#-----[ FIND ]-----
#

代碼: 選擇全部

			$attach_row['real_filename'] = basename($attach_row['real_filename']);
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

			$attach_row['real_filename'] = mybasename($attach_row['real_filename']);
#
#-----[ FIND ]-----
#

代碼: 選擇全部

				'FILENAME'			=> basename($attach_row['real_filename']),
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

				'FILENAME'			=> mybasename($attach_row['real_filename']),
#
#-----[ FIND ]-----
#

代碼: 選擇全部

				'A_FILENAME'		=> addslashes(basename($attach_row['real_filename'])),
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

				'A_FILENAME'		=> addslashes(mybasename($attach_row['real_filename'])),
#
#-----[ OPEN ]-----
#
includes/functions_upload.php

#
#-----[ FIND ]-----
#

代碼: 選擇全部

/**
* File Class
* @access private
#
#-----[ BEFORE, ADD ]-----
#

代碼: 選擇全部

function mybasename($path)
{
$paths = explode('/', $path);
$temps = explode('\\', $paths[count($paths)-1]);
$basename = $temps[count($temps)-1];
return $basename;
}
#
#-----[ FIND ]-----
#

代碼: 選擇全部

		$name = trim(htmlspecialchars(basename($upload_ary['name'])));
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

		$name = trim(htmlspecialchars(mybasename($upload_ary['name'])));
#
#-----[ SAVE & CLOSE ]-----
#

--
資料來源:
http://phpbb-tw.net/phpbb/viewtopic.php ... 94#p262794
http://www.phpbbchina.com/forum/viewtop ... f=5&t=1294
施比受有福,祝福您好運! ^_^
歡迎光臨★★心靈捕手★★ :: 討論區
https://wang5555.dnsfor.me/phpBB3/
頭像
心靈捕手
默默耕耘的老師
默默耕耘的老師
文章: 8510
註冊時間: 2004-04-30 01:54
來自: Taiwan

Re: [整理] 解決 phpbb3 上傳的附加檔案, 若以中文開頭命名, 則無法正確顯示之問題

文章 心靈捕手 »

心靈捕手 寫:使用環境: phpBB 3.0.2 + PHP 5.2.6

#
#-----[ OPEN ]-----
#
includes/functions_content.php

#
#-----[ FIND ]-----
#

代碼: 選擇全部

			'DOWNLOAD_NAME'		=> basename($attachment['real_filename']),
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

			'DOWNLOAD_NAME'		=> mybasename($attachment['real_filename']),
#
#-----[ FIND ]-----
#

代碼: 選擇全部

/**
* Check if extension is allowed to be posted.
#
#-----[ BEFORE, ADD ]-----
#

代碼: 選擇全部

function mybasename($path)
{
$paths = explode('/', $path);
$temps = explode('\\', $paths[count($paths)-1]);
$basename = $temps[count($temps)-1];
return $basename;
}
#
#-----[ OPEN ]-----
#
includes/functions_posting.php

#
#-----[ FIND ]-----
#

代碼: 選擇全部

			$s_inline_attachment_options .= '<option value="' . $i . '">' . basename($attachment['real_filename']) . '</option>';
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

			$s_inline_attachment_options .= '<option value="' . $i . '">' . mybasename($attachment['real_filename']) . '</option>';
#
#-----[ FIND ]-----
#

代碼: 選擇全部

			$attach_row['real_filename'] = basename($attach_row['real_filename']);
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

			$attach_row['real_filename'] = mybasename($attach_row['real_filename']);
#
#-----[ FIND ]-----
#

代碼: 選擇全部

				'FILENAME'			=> basename($attach_row['real_filename']),
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

				'FILENAME'			=> mybasename($attach_row['real_filename']),
#
#-----[ FIND ]-----
#

代碼: 選擇全部

				'A_FILENAME'		=> addslashes(basename($attach_row['real_filename'])),
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

				'A_FILENAME'		=> addslashes(mybasename($attach_row['real_filename'])),
#
#-----[ OPEN ]-----
#
includes/functions_upload.php

#
#-----[ FIND ]-----
#

代碼: 選擇全部

/**
* File Class
* @access private
#
#-----[ BEFORE, ADD ]-----
#

代碼: 選擇全部

function mybasename($path)
{
$paths = explode('/', $path);
$temps = explode('\\', $paths[count($paths)-1]);
$basename = $temps[count($temps)-1];
return $basename;
}
#
#-----[ FIND ]-----
#

代碼: 選擇全部

		$name = trim(htmlspecialchars(basename($upload_ary['name'])));
#
#-----[ REPLACE WITH ]-----
#

代碼: 選擇全部

		$name = trim(htmlspecialchars(mybasename($upload_ary['name'])));
#
#-----[ SAVE & CLOSE ]-----
#

--
資料來源:
http://phpbb-tw.net/phpbb/viewtopic.php ... 94#p262794
http://www.phpbbchina.com/forum/viewtop ... f=5&t=1294
目前, 最新 phpBB 3.0.6RC1 版, 已經修正了此一問題.
也就是說, 不必此修正, 亦可上傳中文命名之附加檔案.
施比受有福,祝福您好運! ^_^
歡迎光臨★★心靈捕手★★ :: 討論區
https://wang5555.dnsfor.me/phpBB3/
回覆文章

回到「3.0」