第一步 找到这个文件 /fckeditoreditorfilemanagerbrowserdefaultfrmresourceslist.html
将已经存在的代码修改为:
<font face="新宋体">oListManager.GetFolderRowHtml = function( folderName, folderPath )<br>
{<br>
// Build the link to view the folder.<br>
var sLink = '<a href="#" onclick="OpenFolder('' + ProtectPath( folderPath ) + '');return false;"><img alt="" src="images/Folder.gif" style="max-width:90%" style="max-width:90%" border="0"> ' ;<br>
<br>
var rLink = '</a><a href="#" title="Rename Folder" onclick="RenameFolder('' + folderName + '');return false;"><img src="images/rename.gif" style="max-width:90%" style="max-width:90%" border="0" alt="Rename Folder" title="Rename Folder"></a>' ;<br>
<br>
var dLink = '<a href="#" title="Delete Folder" onclick="DeleteFolder('' + folderName + '');return false;"><img src="images/delete.gif" style="max-width:90%" style="max-width:90%" border="0" alt="Delete Folder" title="Delete Folder">' ;<br>
<br>
var ssLink = rLink + dLink;<br>
return '<tr>' +<br>
'<td width="16"></td>
<td nowrap> ' +<br>
sLink +<br>
folderName +<br>
'</td>
<td align="right" nowrap>' + ssLink +<br>
'</td>
</tr>' ;<br>
}<br>
<br>
oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize )<br>
{<br>
var sIcon = oIcons.GetIcon( fileName ) ;<br>
<br>
// Build the link to view the file.<br>
var sLink = '</a><a href="#" onclick="OpenFile('' + ProtectPath( fileUrl ) + '');return false;"><img alt="" src="images/icons/'%20+%20sIcon%20+%20'.gif" style="max-width:90%" style="max-width:90%" border="0"> ' ;<br>
<br>
var vLink = '</a><a href="'%20+%20ProtectPath(%20fileUrl%20)%20+%20'" target="_blank" title="View file"><img src="images/view.gif" style="max-width:90%" style="max-width:90%" border="0" alt="View File" title="View File"></a>' ;<br>
<br>
var rLink = '<a href="#" title="Rename file" onclick="RenameFile('' + fileName + '');return false;"><img src="images/rename.gif" style="max-width:90%" style="max-width:90%" border="0" alt="Rename File" title="Rename File"></a>' ;<br>
<br>
var dLink = '<a href="#" title="Delete file" onclick="DeleteFile('' + fileName + '');return false;"><img src="images/delete.gif" style="max-width:90%" style="max-width:90%" border="0" alt="Delete File" title="Delete File"></a>' ;<br>
<br>
<br>
// Get the file icon.<br>
var ssLink = vLink + rLink + dLink;<br>
return '<tr>' +<br>
'<td width="16"></td>
<td> ' +<br>
sLink +<br>
fileName +<br>
'' +<br>
'</td>
<td align="right" nowrap> ' +<br>
fileSize +<br>
' KB' + ssLink +<br>
'</td>
</tr>' ;<br>
}<br>
<br>
function OpenFolder( folderPath )<br>
{<br>
// Load the resources list for this folder.<br>
window.parent.frames['frmFolders'].LoadFolders( (folderPath) ) ;<br>
}<br>
<br>
function OpenFile( fileUrl )<br>
{<br>
window.top.opener.SetUrl( fileUrl.replace( '#', '%23' ) ) ;<br>
window.top.close() ;<br>
window.top.opener.focus() ;<br>
}<br>
<br>
function DeleteFolder( folderUrl )<br>
{<br>
if ( !confirm( 'Do you really delete the folder "' + folderUrl + '" ?' ) ) return false;<br>
<br>
oConnector.SendCommand( 'DeleteFolder', 'FolderName=' + ( encodeURI(folderUrl) ) , DeleteFolderCallBack ) ;<br>
}<br>
<br>
function DeleteFolderCallBack( fckXml )<br>
{<br>
var oNode = fckXml.SelectSingleNode( 'Connector/Error' ) ;<br>
var iErrorNumber = parseInt( oNode.attributes.getNamedItem('number').value ) ;<br>
var sErrorDescription = String( oNode.attributes.getNamedItem('originalDescription').value ) ;<br>
<br>
switch ( iErrorNumber )<br>
{<br>
case 0 :<br>
Refresh() ;<br>
break ;<br>
case 201 :<br>
alert( 'You have no permissions to delete the folder' ) ;<br>
break ;<br>
case 202 :<br>
alert( 'Invalid folder name' + sErrorDescription ) ;<br>
break ;<br>
case 203 :<br>
alert( 'Folder not exists' + sErrorDescription ) ;<br>
break ;<br>
default :<br>
alert( 'Error deleting folder. nError number: ' + iErrorNumber + ' nError description: ' + sErrorDescription ) ;<br>
break ;<br>
}<br>
}<br>
<br>
function DeleteFile(fileUrl)<br>
{<br>
if ( !confirm( 'Do you really delete the file "' + fileUrl + '" ?' ) ) return false;<br>
<br>
oConnector.SendCommand( 'DeleteFile', 'FileName=' + encodeURI( fileUrl ) , DeleteFileCallBack ) ;<br>
}<br>
<br>
function DeleteFileCallBack( fckXml )<br>
{<br>
var oNode = fckXml.SelectSingleNode( 'Connector/Error' ) ;<br>
var iErrorNumber = parseInt( oNode.attributes.getNamedItem('number').value ) ;<br>
var sErrorDescription = String( oNode.attributes.getNamedItem('originalDescription').value ) ;<br>
<br>
switch ( iErrorNumber )<br>
{<br>
case 0 :<br>
Refresh() ;<br>
break ;<br>
case 301 :<br>
alert( 'You have no permissions to delete the file' ) ;<br>
break ;<br>
case 302 :<br>
alert( 'Invalid file name' + sErrorDescription ) ;<br>
break ;<br>
case 303 :<br>
alert( 'File not exists' + sErrorDescription ) ;<br>
break ;<br>
default :<br>
alert( 'Error deleting file. nError number: ' + iErrorNumber + ' nError description: ' + sErrorDescription ) ;<br>
break ;<br>
}<br>
}<br>
<br>
function RenameFolder( folderName )<br>
{<br>
var newName = prompt('Please enter the new folder name for "' + folderName + '":', folderName);<br>
<br>
if ((newName != null) && (newName != '') && (newName != folderName)) {<br>
oConnector.SendCommand( 'RenameFolder', "FolderName=" + encodeURI(folderName) + "&NewName=" + encodeURI ( newName ), RenameFolderCallBack ) ;<br>
}<br>
}<br>
<br>
function RenameFolderCallBack( fckXml )<br>
{<br>
var oNode = fckXml.SelectSingleNode( 'Connector/Error' ) ;<br>
var iErrorNumber = parseInt( oNode.attributes.getNamedItem('number').value ) ;<br>
var sErrorDescription = String( oNode.attributes.getNamedItem('originalDescription').value ) ;<br>
<br>
switch ( iErrorNumber )<br>
{<br>
case 0 :<br>
Refresh() ;<br>
break ;<br>
case 401 :<br>
alert( 'You have no permissions to rename the folder' ) ;<br>
break ;<br>
case 402 :<br>
alert( 'Invalid folder name' + sErrorDescription ) ;<br>
break ;<br>
case 403 :<br>
alert( 'is not Folder' + sErrorDescription ) ;<br>
break ;<br>
case 404 :<br>
alert( 'Folder not exists' + sErrorDescription ) ;<br>
break ;<br>
default :<br>
alert( 'Error renaming folder. nError number: ' + iErrorNumber + ' nError description: ' + sErrorDescription ) ;<br>
break ;<br>
}<br>
}<br>
<br>
function RenameFile( fileName )<br>
{<br>
var newName = prompt('Please enter the new file name for "' + fileName + '":', fileName);<br>
<br>
if ((newName != null) && (newName != '') && (newName != fileName)) {<br>
oConnector.SendCommand( 'RenameFile', "FileName=" + encodeURI( fileName ) + "&NewName=" + encodeURI( newName ), RenameFileCallBack ) ;<br>
}<br>
}<br>
<br>
function RenameFileCallBack( fckXml )<br>
{<br>
var oNode = fckXml.SelectSingleNode( 'Connector/Error' ) ;<br>
var iErrorNumber = parseInt( oNode.attributes.getNamedItem('number').value ) ;<br>
var sErrorDescription = String( oNode.attributes.getNamedItem('originalDescription').value ) ;<br>
<br>
switch ( iErrorNumber )<br>
{<br>
case 0 :<br>
Refresh() ;<br>
break ;<br>
case 501 :<br>
alert( 'You have no permissions to rename the file' ) ;<br>
break ;<br>
case 502 :<br>
alert( 'Invalid file name' + sErrorDescription ) ;<br>
break ;<br>
case 503 :<br>
alert( sErrorDescription + 'is not a file' ) ;<br>
break ;<br>
case 504 :<br>
alert( 'File not exists' + sErrorDescription ) ;<br>
break ;<br>
default :<br>
alert( 'Error renaming file. nError number: ' + ' nError description: ' + sErrorDescription ) ;<br>
break ;<br>
}<br>
}</font>
2。 第二步 找到这个文件 /fckeditoreditorfilemanagerbrowserdefaultfrmfolders.html
将函数OpenFolder(folderPath)最后一句修改为:
<font face="新宋体">var agent = navigator.userAgent;<br>
if(agent.indexOf('MSIE') != -1 || agent.indexOf('Trident') != -1) {<br>
window.parent.frames['frmResourcesList'].LoadResources( oConnector.ResourceType, (folderPath) ) ;<br>
}else{<br>
window.parent.frames['frmResourcesList'].LoadResources( oConnector.ResourceType, encodeURI(folderPath) ) ;<br>
}</font>
3。第三步,找到fckeditoreditorfilemanagerbrowserdefaultbrowser.html
添加函数:
<font face="新宋体">function selectBrowser(str) {<br>
var agent = navigator.userAgent;<br>
if(agent.indexOf('Gecko') != -1) {<br>
return encodeURIComponent(str);<br>
}else if(agent.indexOf('MSIE') != -1 || agent.indexOf('Trident') != -1) {<br>
return str;<br>
}else{<br>
return encodeURIComponent(str);<br>
}<br>
}</font>
第79行修改为: oConnector.ConnectorUrl += 'ServerPath=' + selectBrowser( sServerPath ) + '&' ;
第91行修改为: sUrl += '&CurrentFolder=' + selectBrowser( this.CurrentFolder ) ;
4。第四步 再找这个文件 fckeditoreditorfilemanagerconnectorsphpcommands.php
添加:
<font face="新宋体"> header('Content-Type:text/html;charset=UTF-8');<br>
function DeleteFolder( $resourceType, $currentFolder ) {<br>
$sFolderName = $_GET['FolderName']; <br>
$sErrorMsg = ''; <br>
$sServerDir = ServerMapFolder( $resourceType, $currentFolder . "/" . $sFolderName ,'DeleteFolder');<br>
/*if(empty($_cookie[xxxxxx])) {<br>
$sErrorNumber = "201"; //permissions<br>
}else */ if(empty($_GET['FolderName']) or (!is_dir($sServerDir))) {<br>
$sErrorNumber = "202"; //Invalid Folder Name.<br>
$sErrorMsg = $sFolderName;<br>
}else if(!file_exists($sServerDir)) {<br>
$sErrorNumber = "203"; // Folder not exists<br>
$sErrorMsg = $sFolderName;<br>
echo $sFolderName;exit();<br>
}else{<br>
if(@rmdir($sServerDir)) {<br>
$sErrorNumber = "0";//success<br>
}else{<br>
$sErrorNumber = "222";<br>
$sErrorMsg = "目录删除失败,原因:1。目录不为空n2。没有权限";<br>
}<br>
}<br>
echo '<error number="' . $sErrorNumber . '" originaldescription="' . ConvertToXmlAttribute( $sErrorMsg ) . '"></error>' ;<br>
}<br>
<br>
function DeleteFile( $resourceType, $currentFolder ) {<br>
$sFileName = iconv("utf-8","gbk",$_GET['FileName']);<br>
$sErrorMsg = "";<br>
<br>
$sServerDir = ServerMapFolder( $resourceType, $currentFolder . "/" . $sFileName ,'DeleteFile');<br>
/*if(empty($_COOKIE['hazysuser'])) {<br>
$sErrorNumber = "301"; //Security Error.<br>
}else*/ if( empty($_GET['FileName']) or (!is_file($sServerDir))) {<br>
$sErrorNumber = "302"; //Invalid File Name.<br>
$sErrorMsg = $sFileName;<br>
}else if(!file_exists($sServerDir)) {<br>
$sErrorNumber = "303"; //File not exists.<br>
$sErrorMsg = $sFileName;<br>
}else{<br>
if(@unlink($sServerDir)) {<br>
$sErrorNumber = "0";<br>
}else{<br>
$sErrorNumber = "333";<br>
$sErrorMsg = "无法删除此文件,原因:n1。没有权限。n2。必须在DOS下才能删除的特殊文件";<br>
}<br>
}<br>
echo '<error number="' . $sErrorNumber . '" . converttoxmlattribute></error>';<br>
}<br>
<br>
function RenameFolder( $resourceType, $currentFolder ) {<br>
$sErrorMsg = '';<br>
$sFolderName = urldecode(mb_convert_encoding($_GET['FolderName'],"gbk","utf-8"));<br>
$sNewName = urldecode(mb_convert_encoding($_GET['NewName'],"gbk","utf-8"));<br>
$sServerDir = ServerMapFolder( $resourceType, $currentFolder . "/" . $sFolderName ,'RenameFolder');<br>
$sNewDir = ServerMapFolder( $resourceType, $currentFolder . "/" . $sNewName ,'RenameFolder' );<br>
<br>
<br>
/*if( empty($_COOKIE[xxxxxx])) {<br>
$sErrorNumber = "401";<br>
}else */if ( empty($_GET['FolderName']) or empty($_GET['NewName']) ) {<br>
$sErrorNumber = "402";//Invalid Folder Name.<br>
$sErrorMsg = $sFolderName .' != '.$sNewName;<br>
/*}else if (!is_dir($sServerDir)) {<br>
$sErrorNumber = "403"; //is not Folder<br>
$sErrorMsg = $sFolderName.' is not Folder';<br>
}else if (!file_exists($sServerDir)) {<br>
$sErrorNumber = "404"; //Folder not exists.<br>
$sErrorMsg = $sFolderName;*/<br>
}else {<br>
if(rename($sServerDir,$sNewDir,stream_context_create() )) {<br>
$sErrorNumber = "0";<br>
}else{<br>
$sErrorNumber = "444";<br>
$sErrorMsg = "无法修改目录名称:".$sFolderName.'为'.$sNewName.'。';<br>
}<br>
}<br>
echo '<error number="' . $sErrorNumber . '" . converttoxmlattribute></error>';<br>
}<br>
<br>
function RenameFile( $resourceType, $currentFolder ) {<br>
$sFileName = iconv("utf-8","gbk",$_GET['FileName']);<br>
$sNewName = iconv("utf-8","gbk",$_GET['NewName']);<br>
$sErrorMsg = '';<br>
$sServerDir = ServerMapFolder( $resourceType, $currentFolder . "/" . $sFileName ,'RenameFile');<br>
$sNewDir = ServerMapFolder( $resourceType, $currentFolder . "/" . $sNewName ,'RenameFile');<br>
<br>
/*if(empty($_COOKIE[xxxxxx])) {<br>
$sErrorNumber = "501";<br>
}else */if( empty($_GET['FileName']) or empty($_GET['NewName']) ) {<br>
$sErrorNumber = "502";<br>
}else if(!is_file($sServerDir)) { <br>
$sErrorNumber = '503';<br>
$sErrorMsg = $sFileName .' is not a file';<br>
}else if(!file_exists($sServerDir)) {<br>
$sErrorNumber = '504';<br>
$sErrorMsg = $sFileName .' is not exists';<br>
}else{<br>
if(rename($sServerDir,$sNewDir)) {<br>
$sErrorNumber = "0";<br>
}else{<br>
$sErrorNumber = "555";<br>
$sErrorMsg = "无法重命名此文件:".$sServerDir;<br>
}<br>
}<br>
echo '<error number="' . $sErrorNumber . '" . converttoxmlattribute></error>';<br>
}</font>
修改function GetFoldersAndFiles( $resourceType, $currentFolder )函数,并添加以下内容:
<font face="新宋体">$agent = $_SERVER['HTTP_USER_AGENT'];<br>
if(stripos($agent,"gecko")>0) {<br>
$currentFolder = urldecode($currentFolder);<br>
}<br>
if(stripos($agent,"gecko")>0) { <br>
$sServerDir = iconv("utf-8","gbk",$sServerDir);<br>
}</font>
5。第五步 fckeditoreditorfilemanagerconnectorsphpconfig.php
第28行修改为:$Config['ConfigAllowedCommands'] = array('QuickUpload', 'FileUpload', 'GetFolders', 'GetFoldersAndFiles', 'CreateFolder','DeleteFolder','DeleteFile','RenameFolder','RenameFile') ;
6。第六步 fckeditoreditorfilemanagerconnectorsphpconnector.php
在相应地方添加以下代码:
<font face="新宋体"> case "DeleteFolder":<br>
DeleteFolder( $sResourceType, $sCurrentFolder );<br>
break ;<br>
case "DeleteFile":<br>
DeleteFile( $sResourceType, $sCurrentFolder );<br>
break ;<br>
case "RenameFolder":<br>
RenameFolder( $sResourceType, $sCurrentFolder );<br>
break ;<br>
case "RenameFile":<br>
RenameFile( $sResourceType, $sCurrentFolder );<br>
break ;</font>
7。第七步 fckeditoreditorfilemanagerconnectorsphpio.php
第70行函数function CreateServerFolder( $folderPath, $lastFolder = null )里添加:
$folderPath = iconv("utf-8","gbk",$folderPath);
8。第八步 fckeditoreditorfilemanagerconnectorsphputil.php
第50行修改为:
return (mb_convert_encoding(htmlspecialchars($value),"UTF-8","GBK")) ;
上面的为完全版,但要自己动手。在 http://www.uushare.com/user/littlenew/file/1942702里有免费版,不过里面某些代码已经加密,请勿破解,保证不含任何恶意代码,也不会有反向连接等一系列其它联网活动。
[url= http://www.hazytime.cn/article/article.asp?/6370-1-1.html]也可以到我的网站查看[/url]。
1。我的IE8在apache下不能浏览中文目录里的图片,怎么办?
在IE8的设置里选中:发送 UTF-8 URL
2。免费版本已经存在的问题:在firefox不能修改、删除文件,只能上传文件.
测试环境:windows 2003 + apache 2.2.11 + PHP5.3 + UTF-8(不带BOM)