diff --git a/upload/source/include/portalcp/portalcp_diy.php b/upload/source/include/portalcp/portalcp_diy.php index e048b3722392c700ad3c103cadeb70c737d57097..cd789945928ea157dd9c9c7c83e2b49f9185fda6 100644 --- a/upload/source/include/portalcp/portalcp_diy.php +++ b/upload/source/include/portalcp/portalcp_diy.php @@ -275,7 +275,7 @@ if($op == 'blockclass') { $str = serialize($diycontent); dheader('Content-Length: '.strlen($str)); dheader('Content-Disposition: attachment; filename='.$filename.'.txt'); - dheader('Content-Type: text/plant'); + dheader('Content-Type: text/plain'); } else { require_once libfile('class/xml'); $str = array2xml($diycontent, true); diff --git a/upload/source/include/spacecp/spacecp_pm.php b/upload/source/include/spacecp/spacecp_pm.php index fcce618038579c88a8fea248b042a68cb50735ba..3daa15cc19ba20629bbfe233a7d16d2f3aea752c 100644 --- a/upload/source/include/spacecp/spacecp_pm.php +++ b/upload/source/include/spacecp/spacecp_pm.php @@ -501,12 +501,12 @@ if($_GET['op'] == 'checknewpm') { $contents = nl2br($contents); $filesize = strlen($contents); - $filename = '"'.(strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'Trident') || strexists($_SERVER['HTTP_USER_AGENT'], 'Edge')) ? urlencode($filename) : $filename).'"'; + $filenameencode = strtolower(CHARSET) == 'utf-8' ? rawurlencode($filename) : rawurlencode(diconv($filename, CHARSET, 'UTF-8')); dheader('Date: '.gmdate('D, d M Y H:i:s', $val['dateline']).' GMT'); dheader('Last-Modified: '.gmdate('D, d M Y H:i:s', $val['dateline']).' GMT'); dheader('Content-Encoding: none'); - dheader('Content-Disposition: attachment; filename='.$filename); + dheader('Content-Disposition: attachment; filename="'.(($filename == $filenameencode) ? $filename.'"' : $filenameencode.'"; filename*=utf-8\'\''.$filenameencode)); dheader('Content-Type: application/octet-stream'); dheader('Content-Length: '.$filesize); diff --git a/upload/source/module/forum/forum_attachment.php b/upload/source/module/forum/forum_attachment.php index 76130bcd851243dc31659a409ed1a7a45a5218ac..8277a1242dcb5eb63f8371ee43ab1b5357e348b0 100644 --- a/upload/source/module/forum/forum_attachment.php +++ b/upload/source/module/forum/forum_attachment.php @@ -244,16 +244,16 @@ $mimetype = ext_to_mimetype($attach['filename']); $filesize = !$attach['remote'] ? filesize($filename) : $attach['filesize']; // 如果range_end没有传入,更新range_end if ($has_range_header && !$range_end) $range_end = $filesize - 1; -$attach['filename'] = '"'.(strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'Trident') || strexists($_SERVER['HTTP_USER_AGENT'], 'Edge')) ? urlencode($attach['filename']) : $attach['filename']).'"'; +$filenameencode = strtolower(CHARSET) == 'utf-8' ? rawurlencode($attach['filename']) : rawurlencode(diconv($attach['filename'], CHARSET, 'UTF-8')); dheader('Date: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT'); dheader('Last-Modified: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT'); dheader('Content-Encoding: none'); if($isimage && !empty($_GET['noupdate']) || !empty($_GET['request'])) { - dheader('Content-Disposition: inline; filename='.$attach['filename']); + dheader('Content-Disposition: inline; filename="'.(($attach['filename'] == $filenameencode) ? $attach['filename'].'"' : $filenameencode.'"; filename*=utf-8\'\''.$filenameencode)); } else { - dheader('Content-Disposition: attachment; filename='.$attach['filename']); + dheader('Content-Disposition: attachment; filename="'.(($attach['filename'] == $filenameencode) ? $attach['filename'].'"' : $filenameencode.'"; filename*=utf-8\'\''.$filenameencode)); } if($isimage) { dheader('Content-Type: image'); diff --git a/upload/source/module/forum/forum_misc.php b/upload/source/module/forum/forum_misc.php index 9e5ab49cebc621ff97a7b892f6b188ab8386ddb7..342b65ed5f1ea7b24effab328bbc842168802ab2 100644 --- a/upload/source/module/forum/forum_misc.php +++ b/upload/source/module/forum/forum_misc.php @@ -425,13 +425,9 @@ IconIndex=1 $filename = $_G['setting']['bbname'].'.url'; } - if(!(strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'Trident') || strexists($_SERVER['HTTP_USER_AGENT'], 'Edge'))) { - $filename = diconv($filename, CHARSET, 'UTF-8'); - } else { - $filename = diconv($filename, CHARSET, 'GBK'); - } + $filenameencode = strtolower(CHARSET) == 'utf-8' ? rawurlencode($filename) : rawurlencode(diconv($filename, CHARSET, 'UTF-8')); dheader('Content-type: application/octet-stream'); - dheader('Content-Disposition: attachment; filename="'.$filename.'"'); + dheader('Content-Disposition: attachment; filename="'.(($filename == $filenameencode) ? $filename.'"' : $filenameencode.'"; filename*=utf-8\'\''.$filenameencode)); echo $shortcut; exit; } elseif($_GET['action'] == 'livelastpost') { diff --git a/upload/source/module/misc/misc_stat.php b/upload/source/module/misc/misc_stat.php index 8aa95345dabc746d30a3cb61d368c519a601ecbb..fb5241bc68ad0e80d3b6b1323fcb3f04c899c47f 100644 --- a/upload/source/module/misc/misc_stat.php +++ b/upload/source/module/misc/misc_stat.php @@ -42,12 +42,13 @@ if($op == 'basic') { extract($statvars); if($_GET['exportexcel']) { $filename = 'stat_modworks_'.($username ? $username.'_' : '').$starttime.'_'.$endtime.'.csv'; + $filenameencode = strtolower(CHARSET) == 'utf-8' ? rawurlencode($filename) : rawurlencode(diconv($filename, CHARSET, 'UTF-8')); include template('forum/stat_misc_export'); $csvstr = ob_get_contents(); ob_end_clean(); header('Content-Encoding: none'); header('Content-Type: application/octet-stream'); - header('Content-Disposition: attachment; filename='.$filename); + header('Content-Disposition: attachment; filename="'.(($filename == $filenameencode) ? $filename.'"' : $filenameencode.'"; filename*=utf-8\'\''.$filenameencode)); header('Pragma: no-cache'); header('Expires: 0'); if($_G['charset'] != 'gbk') { diff --git a/upload/source/module/portal/portal_attachment.php b/upload/source/module/portal/portal_attachment.php index cf0b9a22a57f41b071998b37946444683ad56f22..d173d292986b8eb85489dcc7e502333ee82e0ab5 100644 --- a/upload/source/module/portal/portal_attachment.php +++ b/upload/source/module/portal/portal_attachment.php @@ -62,12 +62,12 @@ if($operation == 'delete') { } $filesize = $attach['filesize']; - $attach['filename'] = '"'.(strtolower(CHARSET) == 'utf-8' && (strexists($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strexists($_SERVER['HTTP_USER_AGENT'], 'Trident') || strexists($_SERVER['HTTP_USER_AGENT'], 'Edge')) ? urlencode($attach['filename']) : $attach['filename']).'"'; + $filenameencode = strtolower(CHARSET) == 'utf-8' ? rawurlencode($attach['filename']) : rawurlencode(diconv($attach['filename'], CHARSET, 'UTF-8')); dheader('Date: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT'); dheader('Last-Modified: '.gmdate('D, d M Y H:i:s', $attach['dateline']).' GMT'); dheader('Content-Encoding: none'); - dheader('Content-Disposition: attachment; filename='.$attach['filename']); + dheader('Content-Disposition: attachment; filename="'.(($attach['filename'] == $filenameencode) ? $attach['filename'].'"' : $filenameencode.'"; filename*=utf-8\'\''.$filenameencode)); dheader('Content-Type: '.$attach['filetype']); dheader('Content-Length: '.$filesize);