Changeset 1615
- Timestamp:
- 2008-02-25 11:20:21 (2 years ago)
- Location:
- FCKeditor/trunk/editor/filemanager/connectors/php
- Files:
-
- 2 modified
-
commands.php (modified) (3 diffs)
-
util.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/trunk/editor/filemanager/connectors/php/commands.php
r1565 r1615 185 185 if ( isset( $Config['SecureImageUploads'] ) ) 186 186 { 187 if ( !IsImageValid( $oFile['tmp_name'], $sExtension ))187 if ( ( $isImageValid = IsImageValid( $oFile['tmp_name'], $sExtension ) ) === false ) 188 188 { 189 189 $sErrorNumber = '202' ; … … 193 193 if ( isset( $Config['HtmlExtensions'] ) ) 194 194 { 195 if ( !IsHtmlExtension( $sExtension, $Config['HtmlExtensions'] ) && DetectHtml( $oFile['tmp_name'] ) ) 195 if ( !IsHtmlExtension( $sExtension, $Config['HtmlExtensions'] ) && 196 ( $detectHtml = DetectHtml( $oFile['tmp_name'] ) ) === true ) 196 197 { 197 198 $sErrorNumber = '202' ; … … 228 229 } 229 230 } 231 232 if ( file_exists( $sFilePath ) ) 233 { 234 //previous checks failed, try once again 235 if ( isset( $isImageValid ) && $isImageValid === -1 && IsImageValid( $sFilePath, $sExtension ) === false ) 236 { 237 @unlink( $sFilePath ) ; 238 $sErrorNumber = '202' ; 239 } 240 else if ( isset( $detectHtml ) && $detectHtml === -1 && DetectHtml( $sFilePath ) === true ) 241 { 242 @unlink( $sFilePath ) ; 243 $sErrorNumber = '202' ; 244 } 245 } 230 246 } 231 247 else -
FCKeditor/trunk/editor/filemanager/connectors/php/util.php
r1565 r1615 87 87 function DetectHtml( $filePath ) 88 88 { 89 $fp = fopen( $filePath, 'rb' ) ; 89 $fp = @fopen( $filePath, 'rb' ) ; 90 91 //open_basedir restriction, see #1906 92 if ( $fp === false || !flock( $fp, LOCK_SH ) ) 93 { 94 return -1 ; 95 } 96 90 97 $chunk = fread( $fp, 1024 ) ; 98 flock( $fp, LOCK_UN ) ; 91 99 fclose( $fp ) ; 92 100 … … 150 158 function IsImageValid( $filePath, $extension ) 151 159 { 160 if (!@is_readable($filePath)) { 161 return -1; 162 } 163 152 164 $imageCheckExtensions = array('gif', 'jpeg', 'jpg', 'png', 'swf', 'psd', 'bmp', 'iff'); 153 165