「サイトファイル」の版間の差分
提供:MoodleDocs
Mitsuhiro Yoshida (トーク | 投稿記録) 編集の要約なし |
Mitsuhiro Yoshida (トーク | 投稿記録) 編集の要約なし |
||
(同じ利用者による、間の18版が非表示) | |||
1行目: | 1行目: | ||
{{Moodle 1.6}} | |||
[[Image:Multibyte_File_Name.gif|center]] | |||
下記の場合、Moodle設定ファイル「config.php」の中に後述の設定追加およびプログラムの修正をお試しください。 | |||
#日本語フォルダ名のフォルダを作成する (例 日本語フォルダ) | |||
#日本語ファイル名のファイルをアップロードする (例 日本語テキスト.txt) | |||
#アップロードした日本語ファイル名のファイルをInternet Explorerでダウンロードする | |||
== config.phpに記述する設定内容 == | |||
:;$CFG->unicodedb = true; | :;$CFG->unicodedb = true; | ||
:;$CFG->unicodecleanfilename = true; | :;$CFG->unicodecleanfilename = true; | ||
== プログラム「moodle/file.php」の修正 == | |||
修正対象プログラム: moodle/file.php<br /> | |||
修正箇所 :149行目<br /> | |||
備考:Internet Explorerで日本語ファイル名ファイルをダウンロードするため | |||
*変更前 | |||
$filename = $args[count($args)-1]; | |||
send_file($pathname, $filename, $lifetime, $CFG->filteruploadedfiles, false, $forcedownload); | |||
*変更後 | |||
$filename = $args[count($args)-1]; | |||
<b> $ua = $_SERVER['HTTP_USER_AGENT']; | |||
if (strstr($ua, "MSIE") && !strstr($ua, 'Opera')) { | |||
$filename = mb_convert_encoding($filename, "SJIS", get_string('thischarset')); | |||
} elseif (strstr($ua, "Safari")) { | |||
if (get_string('thischarset') == "UTF-8") { | |||
$filename = ""; | |||
} else { | |||
$filename = preg_replace('/[^\.a-zA-Z\d\_-]/', '_', $filename); | |||
} | |||
} else { | |||
$filename = mb_convert_encoding($filename, "UTF-8", get_string('thischarset')); | |||
} | |||
$filename = str_replace('#', '%23', $filename);</b> | |||
send_file($pathname, $filename, $lifetime, $CFG->filteruploadedfiles, false, $forcedownload); | |||
== プログラム「lib/filelib.php」の修正 == | |||
修正対象プログラム: lib/filelib.php<br /> | |||
修正箇所 :247行目<br /> | |||
備考:Internet Explorerで日本語ファイル名ファイルをダウンロードするため | |||
*変更前 | |||
if ($forcedownload) { | |||
@header('Content-Disposition: attachment; filename='.$filename); | |||
} else { | |||
@header('Content-Disposition: inline; filename='.$filename); | |||
} | |||
*変更後 | |||
if ($forcedownload) { | |||
<b>@header('Content-Disposition: attachment; filename="' . $filename . '"');</b> | |||
} else { | |||
<b>@header('Content-Disposition: inline; filename="' . $filename . '"');</b> | |||
} | |||
==関連情報== | ==関連情報== | ||
[[Category:管理者]] | [[Category:管理者]] | ||
[[en:Site_files]] |
2007年3月8日 (木) 05:30時点における最新版
Moodle 1.6
下記の場合、Moodle設定ファイル「config.php」の中に後述の設定追加およびプログラムの修正をお試しください。
- 日本語フォルダ名のフォルダを作成する (例 日本語フォルダ)
- 日本語ファイル名のファイルをアップロードする (例 日本語テキスト.txt)
- アップロードした日本語ファイル名のファイルをInternet Explorerでダウンロードする
config.phpに記述する設定内容
- $CFG->unicodedb = true;
- $CFG->unicodecleanfilename = true;
プログラム「moodle/file.php」の修正
修正対象プログラム: moodle/file.php
修正箇所 :149行目
備考:Internet Explorerで日本語ファイル名ファイルをダウンロードするため
- 変更前
$filename = $args[count($args)-1]; send_file($pathname, $filename, $lifetime, $CFG->filteruploadedfiles, false, $forcedownload);
- 変更後
$filename = $args[count($args)-1]; $ua = $_SERVER['HTTP_USER_AGENT']; if (strstr($ua, "MSIE") && !strstr($ua, 'Opera')) { $filename = mb_convert_encoding($filename, "SJIS", get_string('thischarset')); } elseif (strstr($ua, "Safari")) { if (get_string('thischarset') == "UTF-8") { $filename = ""; } else { $filename = preg_replace('/[^\.a-zA-Z\d\_-]/', '_', $filename); } } else { $filename = mb_convert_encoding($filename, "UTF-8", get_string('thischarset')); } $filename = str_replace('#', '%23', $filename); send_file($pathname, $filename, $lifetime, $CFG->filteruploadedfiles, false, $forcedownload);
プログラム「lib/filelib.php」の修正
修正対象プログラム: lib/filelib.php
修正箇所 :247行目
備考:Internet Explorerで日本語ファイル名ファイルをダウンロードするため
- 変更前
if ($forcedownload) { @header('Content-Disposition: attachment; filename='.$filename); } else { @header('Content-Disposition: inline; filename='.$filename); }
- 変更後
if ($forcedownload) { @header('Content-Disposition: attachment; filename="' . $filename . '"'); } else { @header('Content-Disposition: inline; filename="' . $filename . '"'); }