Index: index.php =================================================================== --- index.php (.../vender/moodle_16_stable/files) (修订版 846) +++ index.php (.../trunk/files) (修订版 846) @@ -21,6 +21,8 @@ $save = optional_param('save', 0, PARAM_BOOL); $text = optional_param('text', '', PARAM_RAW); $confirm = optional_param('confirm', 0, PARAM_BOOL); + $charset = optional_param('charset', '', PARAM_CLEAN); + $submit = optional_param('submit', '', PARAM_RAW); if ($choose) { if (count(explode('.', $choose)) != 2) { @@ -437,6 +439,7 @@ break; case "zip": + $nativecharset = get_string('nativecharset', 'langconfig'); if (($name != '') and confirm_sesskey()) { html_header($course, $wdir); $name = clean_filename($name); @@ -446,7 +449,7 @@ $files[] = "$basedir/$file"; } - if (!zip_files($files,"$basedir$wdir/$name")) { + if (!zip_files($files,"$basedir$wdir/$name",$charset)) { error(get_string("zipfileserror","error")); } @@ -469,9 +472,26 @@ echo " "; echo " "; echo " "; - echo " "; echo " sesskey\" />"; + echo ""; + echo ""; + echo ""; + echo ""; + if ($nativecharset) { + echo ""; + echo ""; + echo ""; + echo ""; + } else { + echo ""; + } + echo "
".get_string("whattocallzip")."
".get_string("usecharset")."
"; echo " "; + echo " "; + echo "
"; echo ""; echo ""; echo "
"; @@ -491,32 +511,34 @@ break; case "unzip": - html_header($course, $wdir); - if (($file != '') and confirm_sesskey()) { - $strok = get_string("ok"); - $strunpacking = get_string("unpacking", "", $file); + if ($charset && $submit) { + html_header($course, $wdir); + if ($file != '' and confirm_sesskey()) { + $strok = get_string("ok"); + $strunpacking = get_string("unpacking", "", $file); - echo "

$strunpacking:

"; + echo "

$strunpacking:

"; - $file = basename($file); + $file = basename($file); - if (!unzip_file("$basedir$wdir/$file")) { - error(get_string("unzipfileserror","error")); + if (!unzip_file("$basedir$wdir/$file", '', true, $charset)) { + error(get_string("unzipfileserror","error")); + } + + echo "
"; + echo ' '; + echo " "; + echo " "; + echo " "; + echo " "; + echo ""; + echo "
"; + } else { + displaydir($wdir); } - - echo "
"; - echo ' '; - echo " "; - echo " "; - echo " "; - echo " "; - echo "
"; - echo "
"; - } else { - displaydir($wdir); + html_footer(); + break; } - html_footer(); - break; case "listzip": html_header($course, $wdir); @@ -525,9 +547,21 @@ $strsize = get_string("size"); $strmodified = get_string("modified"); $strok = get_string("ok"); + $strunzip = get_string("unzip"); + $strcancel = get_string("cancel"); $strlistfiles = get_string("listfiles", "", $file); + $struseothercharset = get_string("useothercharset"); + $nativecharset = get_string('nativecharset', 'langconfig'); echo "

$strlistfiles:

"; + if ($nativecharset != '') { + echo "

$struseothercharset:"; + echo ""; + echo "

"; + } $file = basename($file); include_once("$CFG->libdir/pclzip/pclzip.lib.php"); @@ -538,9 +572,18 @@ } else { echo ""; echo ""; + $has_invalid_filename = False; foreach ($list as $item) { echo ""; - print_cell("left", s($item['filename']), 'name'); + $item_filename = $item['filename']; + if ($charset && $charset != 'UTF-8') { + $item_filename = iconv($charset, 'UTF-8', $item['filename']); + } + if (!utf8_validate($item_filename)) { + $item_filename .= get_string('invalidfilename'); + $has_invalid_filename = True; + } + print_cell("left", s($item_filename), 'name'); if (! $item['folder']) { print_cell("right", display_size($item['size']), 'size'); } else { @@ -556,8 +599,17 @@ echo ' '; echo " "; echo " "; - echo " "; - echo " "; + if ($action != 'unzip') { + echo " "; + echo " "; + } else { + echo " "; + echo " sesskey\" />"; + echo " "; + echo " "; + echo " "; + echo " "; + } echo ""; echo ""; } else { 属性改变于:. ___________________________________________________________________ 名字:svn:ignore - CVS
$strname$strsize$strmodified