1 | diff -ru FCKeditor_2.5-virgin/editor/filemanager/browser/default/frmupload.html FCKeditor_2.5-patched/editor/filemanager/browser/default/frmupload.html |
---|
2 | --- FCKeditor_2.5-virgin/editor/filemanager/browser/default/frmupload.html 2007-07-10 13:47:30.000000000 +0100 |
---|
3 | +++ FCKeditor_2.5-patched/editor/filemanager/browser/default/frmupload.html 2007-12-10 19:28:51.000000000 +0000 |
---|
4 | @@ -82,6 +82,17 @@ |
---|
5 | case 202 : |
---|
6 | alert( 'Invalid file' ) ; |
---|
7 | break ; |
---|
8 | + case 205 : |
---|
9 | + window.parent.frames['frmResourcesList'].Refresh() ; |
---|
10 | + alert( 'Your file has been successfully uploaded, and replaced the existing file with the same name.' ) ; |
---|
11 | + break ; |
---|
12 | + case 206 : |
---|
13 | + alert( 'A file of that name already exists, so the upload failed.' ) ; |
---|
14 | + break ; |
---|
15 | + case 207 : |
---|
16 | + window.parent.frames['frmResourcesList'].Refresh() ; |
---|
17 | + alert( 'Your file has been successfully uploaded. There was already a file of that name, so that previous file has been backed up by being renamed to "' + data + '".' ) ; |
---|
18 | + break ; |
---|
19 | default : |
---|
20 | alert( 'Error on file upload. Error number: ' + errorNumber ) ; |
---|
21 | break ; |
---|
22 | diff -ru FCKeditor_2.5-virgin/editor/filemanager/connectors/php/commands.php FCKeditor_2.5-patched/editor/filemanager/connectors/php/commands.php |
---|
23 | --- FCKeditor_2.5-virgin/editor/filemanager/connectors/php/commands.php 2007-10-02 19:15:16.000000000 +0100 |
---|
24 | +++ FCKeditor_2.5-patched/editor/filemanager/connectors/php/commands.php 2007-12-10 19:37:40.000000000 +0000 |
---|
25 | @@ -201,30 +201,66 @@ |
---|
26 | // Check if it is an allowed extension. |
---|
27 | if ( !$sErrorNumber && IsAllowedExt( $sExtension, $resourceType ) ) |
---|
28 | { |
---|
29 | - $iCounter = 0 ; |
---|
30 | - |
---|
31 | - while ( true ) |
---|
32 | - { |
---|
33 | - $sFilePath = $sServerDir . $sFileName ; |
---|
34 | - |
---|
35 | + // Assign the new file's name |
---|
36 | + $sFilePath = $sServerDir . $sFileName ; |
---|
37 | + $doUpload = true; |
---|
38 | + |
---|
39 | + // If the file already exists, select what behaviour should be adopted |
---|
40 | + if ( is_file( $sFilePath ) ) { |
---|
41 | + $sFilenameClashBehaviour = (isSet ($Config['FilenameClashBehaviour']) ? $Config['FilenameClashBehaviour'] : 'newname'); |
---|
42 | + switch ($sFilenameClashBehaviour) { |
---|
43 | + |
---|
44 | + // overwrites the version on the server with the same name |
---|
45 | + case 'overwrite': |
---|
46 | + $sErrorNumber = '205' ; |
---|
47 | + // Do nothing - move_uploaded_file will just overwrite naturally |
---|
48 | + break; |
---|
49 | + |
---|
50 | + // generate an error so that the file uploading fails |
---|
51 | + case false: |
---|
52 | + case 'false': // String version in case someone quotes the boolean text equivalent |
---|
53 | + $sErrorNumber = '206' ; |
---|
54 | + $doUpload = false; |
---|
55 | + break; |
---|
56 | + |
---|
57 | + // give the uploaded file a new name (this was the (unconfigurable) behaviour in FCKeditor2.5) - named as: originalName(number).extension |
---|
58 | + case 'newname': |
---|
59 | + $iCounter = 0 ; |
---|
60 | + while ( true ) |
---|
61 | + { |
---|
62 | + if ( is_file( $sFilePath ) ) |
---|
63 | + { |
---|
64 | + $iCounter++ ; |
---|
65 | + $sFileName = RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ; |
---|
66 | + $sErrorNumber = '201' ; |
---|
67 | + $sFilePath = $sServerDir . $sFileName ; |
---|
68 | + } |
---|
69 | + else |
---|
70 | + { |
---|
71 | + break ; |
---|
72 | + } |
---|
73 | + } |
---|
74 | + break; |
---|
75 | + |
---|
76 | + // (default behaviour) back up the version on the server to the same name + timestamp appended to the filename (after the extension) |
---|
77 | + case 'renameold': |
---|
78 | + default: |
---|
79 | + $timestamp = '.' . date ('Ymd-His'); |
---|
80 | + copy ($sFilePath, $sFilePath . $timestamp); |
---|
81 | + $sFileName = $sFileName . $timestamp; |
---|
82 | + $sErrorNumber = '207' ; |
---|
83 | + break; |
---|
84 | + } // End of switch statement |
---|
85 | + } |
---|
86 | + |
---|
87 | + // Now its name has been assigned, move the uploaded file into position |
---|
88 | + if ($doUpload) { |
---|
89 | + move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ; |
---|
90 | if ( is_file( $sFilePath ) ) |
---|
91 | { |
---|
92 | - $iCounter++ ; |
---|
93 | - $sFileName = RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ; |
---|
94 | - $sErrorNumber = '201' ; |
---|
95 | - } |
---|
96 | - else |
---|
97 | - { |
---|
98 | - move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ; |
---|
99 | - |
---|
100 | - if ( is_file( $sFilePath ) ) |
---|
101 | - { |
---|
102 | - $oldumask = umask(0) ; |
---|
103 | - chmod( $sFilePath, 0777 ) ; |
---|
104 | - umask( $oldumask ) ; |
---|
105 | - } |
---|
106 | - |
---|
107 | - break ; |
---|
108 | + $oldumask = umask(0) ; |
---|
109 | + chmod( $sFilePath, 0777 ) ; |
---|
110 | + umask( $oldumask ) ; |
---|
111 | } |
---|
112 | } |
---|
113 | } |
---|
114 | diff -ru FCKeditor_2.5-virgin/editor/filemanager/connectors/php/config.php FCKeditor_2.5-patched/editor/filemanager/connectors/php/config.php |
---|
115 | --- FCKeditor_2.5-virgin/editor/filemanager/connectors/php/config.php 2007-11-21 17:46:48.000000000 +0000 |
---|
116 | +++ FCKeditor_2.5-patched/editor/filemanager/connectors/php/config.php 2007-12-10 19:39:53.000000000 +0000 |
---|
117 | @@ -57,6 +57,14 @@ |
---|
118 | // following extensions only. |
---|
119 | $Config['HtmlExtensions'] = array("html", "htm", "xml", "xsd", "txt", "js") ; |
---|
120 | |
---|
121 | +// What to do if a file being uploaded has the same name as an existing file on the server |
---|
122 | +// 'renameold' - (default behaviour) backs up the version on the server to the same name + timestamp appended to the filename (after the extension) |
---|
123 | +// 'overwrite' - overwrites the version on the server with the same name |
---|
124 | +// 'newname' - gives the uploaded file a new name (this was the (unconfigurable) behaviour in FCKeditor2.2) |
---|
125 | +// false - generates an error so that the file uploading fails |
---|
126 | +$Config['FilenameClashBehaviour'] = 'renameold'; |
---|
127 | + |
---|
128 | + |
---|
129 | /* |
---|
130 | Configuration settings for each Resource Type |
---|
131 | |
---|
132 | diff -ru FCKeditor_2.5-virgin/editor/filemanager/connectors/test.html FCKeditor_2.5-patched/editor/filemanager/connectors/test.html |
---|
133 | --- FCKeditor_2.5-virgin/editor/filemanager/connectors/test.html 2007-07-10 13:47:30.000000000 +0100 |
---|
134 | +++ FCKeditor_2.5-patched/editor/filemanager/connectors/test.html 2007-12-10 19:29:44.000000000 +0000 |
---|
135 | @@ -84,6 +84,17 @@ |
---|
136 | case 202 : |
---|
137 | alert( 'Invalid file' ) ; |
---|
138 | break ; |
---|
139 | + case 205 : |
---|
140 | + GetFoldersAndFiles() ; |
---|
141 | + alert( 'Your file has been successfully uploaded, and replaced the existing file with the same name.' ) ; |
---|
142 | + break ; |
---|
143 | + case 206 : |
---|
144 | + alert( 'A file of that name already exists, so the upload failed.' ) ; |
---|
145 | + break ; |
---|
146 | + case 207 : |
---|
147 | + GetFoldersAndFiles() ; |
---|
148 | + alert( 'Your file has been successfully uploaded. There was already a file of that name, so that previous file has been backed up by being renamed to "' + data + '".' ) ; |
---|
149 | + break ; |
---|
150 | default : |
---|
151 | alert( 'Error on file upload. Error number: ' + errorNumber ) ; |
---|
152 | break ; |
---|
153 | diff -ru FCKeditor_2.5-virgin/editor/filemanager/connectors/uploadtest.html FCKeditor_2.5-patched/editor/filemanager/connectors/uploadtest.html |
---|
154 | --- FCKeditor_2.5-virgin/editor/filemanager/connectors/uploadtest.html 2007-08-31 16:08:32.000000000 +0100 |
---|
155 | +++ FCKeditor_2.5-patched/editor/filemanager/connectors/uploadtest.html 2007-12-10 19:29:29.000000000 +0000 |
---|
156 | @@ -73,6 +73,15 @@ |
---|
157 | case 203 : |
---|
158 | alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ; |
---|
159 | break ; |
---|
160 | + case 205 : |
---|
161 | + alert( 'Your file has been successfully uploaded, and replaced the existing file with the same name.' ) ; |
---|
162 | + break ; |
---|
163 | + case 206 : |
---|
164 | + alert( 'A file of that name already exists, so the upload failed.' ) ; |
---|
165 | + break ; |
---|
166 | + case 207 : |
---|
167 | + alert( 'Your file has been successfully uploaded. There was already a file of that name, so that previous file has been backed up by being renamed to "' + data + '".' ) ; |
---|
168 | + break ; |
---|
169 | default : |
---|
170 | alert( 'Error on file upload. Error number: ' + errorNumber ) ; |
---|
171 | break ; |
---|