Passed
Branch master (ef3387)
by Anthony
09:36
created
libs/ckfinder/core/connector/php/php5/CommandHandler/Thumbnail.php 3 patches
Indentation   +288 added lines, -288 removed lines patch added patch discarded remove patch
@@ -27,297 +27,297 @@
 block discarded – undo
27 27
  */
28 28
 class CKFinder_Connector_CommandHandler_Thumbnail extends CKFinder_Connector_CommandHandler_CommandHandlerBase
29 29
 {
30
-    /**
31
-     * Command name
32
-     *
33
-     * @access private
34
-     * @var string
35
-     */
36
-    private $command = "Thumbnail";
37
-
38
-    /**
39
-     * handle request and send response
40
-     * @access public
41
-     *
42
-     */
43
-    public function sendResponse()
44
-    {
45
-        if (!function_exists('ob_list_handlers') || ob_list_handlers()) {
46
-            @ob_end_clean();
47
-        }
48
-        header("Content-Encoding: none");
49
-
50
-        $this->checkConnector();
51
-        $this->checkRequest();
52
-
53
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
54
-
55
-        $_thumbnails = $_config->getThumbnailsConfig();
56
-        if (!$_thumbnails->getIsEnabled()) {
57
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_THUMBNAILS_DISABLED);
58
-        }
59
-
60
-        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) {
61
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
62
-        }
63
-
64
-        if (!isset($_GET["FileName"])) {
65
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
66
-        }
67
-
68
-        $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["FileName"]);
69
-        $_resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
70
-
71
-        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName)) {
72
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
73
-        }
74
-
75
-        $sourceFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
76
-
77
-        if ($_resourceTypeInfo->checkIsHiddenFile($fileName) || !file_exists($sourceFilePath)) {
78
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
79
-        }
80
-
81
-        $thumbFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getThumbsServerPath(), $fileName);
82
-
83
-        // If the thumbnail file doesn't exists, create it now.
84
-        if (!file_exists($thumbFilePath)) {
85
-            if(!$this->createThumb($sourceFilePath, $thumbFilePath, $_thumbnails->getMaxWidth(), $_thumbnails->getMaxHeight(), $_thumbnails->getQuality(), true, $_thumbnails->getBmpSupported())) {
86
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
87
-            }
88
-        }
89
-
90
-        $size = filesize($thumbFilePath);
91
-        $sourceImageAttr = getimagesize($thumbFilePath);
92
-        $mime = $sourceImageAttr["mime"];
93
-
94
-        $rtime = isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])?@strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]):0;
95
-        $mtime =  filemtime($thumbFilePath);
96
-        $etag = dechex($mtime) . "-" . dechex($size);
97
-
98
-        $is304 = false;
99
-
100
-        if (isset($_SERVER["HTTP_IF_NONE_MATCH"]) && $_SERVER["HTTP_IF_NONE_MATCH"] === $etag) {
101
-            $is304 = true;
102
-        }
103
-        else if($rtime == $mtime) {
104
-            $is304 = true;
105
-        }
106
-
107
-        if ($is304) {
108
-            header("HTTP/1.0 304 Not Modified");
109
-            exit();
110
-        }
111
-
112
-        //header("Cache-Control: cache, must-revalidate");
113
-        //header("Pragma: public");
114
-        //header("Expires: 0");
115
-        header('Cache-control: public');
116
-        header('Etag: ' . $etag);
117
-        header("Content-type: " . $mime . "; name=\"" . CKFinder_Connector_Utils_Misc::mbBasename($thumbFilePath) . "\"");
118
-        header("Last-Modified: ".gmdate('D, d M Y H:i:s', $mtime) . " GMT");
119
-        //header("Content-type: application/octet-stream; name=\"{$file}\"");
120
-        //header("Content-Disposition: attachment; filename=\"{$file}\"");
121
-        header("Content-Length: ".$size);
122
-        readfile($thumbFilePath);
123
-        exit;
124
-    }
125
-
126
-    /**
127
-     * Create thumbnail
128
-     *
129
-     * @param string $sourceFile
130
-     * @param string $targetFile
131
-     * @param int $maxWidth
132
-     * @param int $maxHeight
133
-     * @param boolean $preserverAspectRatio
134
-     * @param boolean $bmpSupported
135
-     * @return boolean
136
-     * @static
137
-     * @access public
138
-     */
139
-    public static function createThumb($sourceFile, $targetFile, $maxWidth, $maxHeight, $quality, $preserverAspectRatio, $bmpSupported = false)
140
-    {
141
-        $sourceImageAttr = @getimagesize($sourceFile);
142
-        if ($sourceImageAttr === false) {
143
-            return false;
144
-        }
145
-        $sourceImageWidth = isset($sourceImageAttr[0]) ? $sourceImageAttr[0] : 0;
146
-        $sourceImageHeight = isset($sourceImageAttr[1]) ? $sourceImageAttr[1] : 0;
147
-        $sourceImageMime = isset($sourceImageAttr["mime"]) ? $sourceImageAttr["mime"] : "";
148
-        $sourceImageBits = isset($sourceImageAttr["bits"]) ? $sourceImageAttr["bits"] : 8;
149
-        $sourceImageChannels = isset($sourceImageAttr["channels"]) ? $sourceImageAttr["channels"] : 3;
150
-
151
-        if (!$sourceImageWidth || !$sourceImageHeight || !$sourceImageMime) {
152
-            return false;
153
-        }
154
-
155
-        $iFinalWidth = $maxWidth == 0 ? $sourceImageWidth : $maxWidth;
156
-        $iFinalHeight = $maxHeight == 0 ? $sourceImageHeight : $maxHeight;
157
-
158
-        if ($sourceImageWidth <= $iFinalWidth && $sourceImageHeight <= $iFinalHeight) {
159
-            if ($sourceFile != $targetFile) {
160
-                copy($sourceFile, $targetFile);
161
-            }
162
-            return true;
163
-        }
164
-
165
-        if ($preserverAspectRatio)
166
-        {
167
-            // Gets the best size for aspect ratio resampling
168
-            $oSize = CKFinder_Connector_CommandHandler_Thumbnail::GetAspectRatioSize($iFinalWidth, $iFinalHeight, $sourceImageWidth, $sourceImageHeight );
169
-        }
170
-        else {
171
-            $oSize = array('Width' => $iFinalWidth, 'Height' => $iFinalHeight);
172
-        }
173
-
174
-        CKFinder_Connector_Utils_Misc::setMemoryForImage($sourceImageWidth, $sourceImageHeight, $sourceImageBits, $sourceImageChannels);
175
-
176
-        switch ($sourceImageAttr['mime'])
177
-        {
178
-            case 'image/gif':
179
-                {
180
-                    if (@imagetypes() & IMG_GIF) {
181
-                        $oImage = @imagecreatefromgif($sourceFile);
182
-                    } else {
183
-                        $ermsg = 'GIF images are not supported';
184
-                    }
185
-                }
186
-                break;
187
-            case 'image/jpeg':
188
-                {
189
-                    if (@imagetypes() & IMG_JPG) {
190
-                        $oImage = @imagecreatefromjpeg($sourceFile) ;
191
-                    } else {
192
-                        $ermsg = 'JPEG images are not supported';
193
-                    }
194
-                }
195
-                break;
196
-            case 'image/png':
197
-                {
198
-                    if (@imagetypes() & IMG_PNG) {
199
-                        $oImage = @imagecreatefrompng($sourceFile) ;
200
-                    } else {
201
-                        $ermsg = 'PNG images are not supported';
202
-                    }
203
-                }
204
-                break;
205
-            case 'image/wbmp':
206
-                {
207
-                    if (@imagetypes() & IMG_WBMP) {
208
-                        $oImage = @imagecreatefromwbmp($sourceFile);
209
-                    } else {
210
-                        $ermsg = 'WBMP images are not supported';
211
-                    }
212
-                }
213
-                break;
214
-            case 'image/bmp':
215
-                {
216
-                    /*
30
+	/**
31
+	 * Command name
32
+	 *
33
+	 * @access private
34
+	 * @var string
35
+	 */
36
+	private $command = "Thumbnail";
37
+
38
+	/**
39
+	 * handle request and send response
40
+	 * @access public
41
+	 *
42
+	 */
43
+	public function sendResponse()
44
+	{
45
+		if (!function_exists('ob_list_handlers') || ob_list_handlers()) {
46
+			@ob_end_clean();
47
+		}
48
+		header("Content-Encoding: none");
49
+
50
+		$this->checkConnector();
51
+		$this->checkRequest();
52
+
53
+		$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
54
+
55
+		$_thumbnails = $_config->getThumbnailsConfig();
56
+		if (!$_thumbnails->getIsEnabled()) {
57
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_THUMBNAILS_DISABLED);
58
+		}
59
+
60
+		if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) {
61
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
62
+		}
63
+
64
+		if (!isset($_GET["FileName"])) {
65
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
66
+		}
67
+
68
+		$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["FileName"]);
69
+		$_resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
70
+
71
+		if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName)) {
72
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
73
+		}
74
+
75
+		$sourceFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
76
+
77
+		if ($_resourceTypeInfo->checkIsHiddenFile($fileName) || !file_exists($sourceFilePath)) {
78
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
79
+		}
80
+
81
+		$thumbFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getThumbsServerPath(), $fileName);
82
+
83
+		// If the thumbnail file doesn't exists, create it now.
84
+		if (!file_exists($thumbFilePath)) {
85
+			if(!$this->createThumb($sourceFilePath, $thumbFilePath, $_thumbnails->getMaxWidth(), $_thumbnails->getMaxHeight(), $_thumbnails->getQuality(), true, $_thumbnails->getBmpSupported())) {
86
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
87
+			}
88
+		}
89
+
90
+		$size = filesize($thumbFilePath);
91
+		$sourceImageAttr = getimagesize($thumbFilePath);
92
+		$mime = $sourceImageAttr["mime"];
93
+
94
+		$rtime = isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])?@strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]):0;
95
+		$mtime =  filemtime($thumbFilePath);
96
+		$etag = dechex($mtime) . "-" . dechex($size);
97
+
98
+		$is304 = false;
99
+
100
+		if (isset($_SERVER["HTTP_IF_NONE_MATCH"]) && $_SERVER["HTTP_IF_NONE_MATCH"] === $etag) {
101
+			$is304 = true;
102
+		}
103
+		else if($rtime == $mtime) {
104
+			$is304 = true;
105
+		}
106
+
107
+		if ($is304) {
108
+			header("HTTP/1.0 304 Not Modified");
109
+			exit();
110
+		}
111
+
112
+		//header("Cache-Control: cache, must-revalidate");
113
+		//header("Pragma: public");
114
+		//header("Expires: 0");
115
+		header('Cache-control: public');
116
+		header('Etag: ' . $etag);
117
+		header("Content-type: " . $mime . "; name=\"" . CKFinder_Connector_Utils_Misc::mbBasename($thumbFilePath) . "\"");
118
+		header("Last-Modified: ".gmdate('D, d M Y H:i:s', $mtime) . " GMT");
119
+		//header("Content-type: application/octet-stream; name=\"{$file}\"");
120
+		//header("Content-Disposition: attachment; filename=\"{$file}\"");
121
+		header("Content-Length: ".$size);
122
+		readfile($thumbFilePath);
123
+		exit;
124
+	}
125
+
126
+	/**
127
+	 * Create thumbnail
128
+	 *
129
+	 * @param string $sourceFile
130
+	 * @param string $targetFile
131
+	 * @param int $maxWidth
132
+	 * @param int $maxHeight
133
+	 * @param boolean $preserverAspectRatio
134
+	 * @param boolean $bmpSupported
135
+	 * @return boolean
136
+	 * @static
137
+	 * @access public
138
+	 */
139
+	public static function createThumb($sourceFile, $targetFile, $maxWidth, $maxHeight, $quality, $preserverAspectRatio, $bmpSupported = false)
140
+	{
141
+		$sourceImageAttr = @getimagesize($sourceFile);
142
+		if ($sourceImageAttr === false) {
143
+			return false;
144
+		}
145
+		$sourceImageWidth = isset($sourceImageAttr[0]) ? $sourceImageAttr[0] : 0;
146
+		$sourceImageHeight = isset($sourceImageAttr[1]) ? $sourceImageAttr[1] : 0;
147
+		$sourceImageMime = isset($sourceImageAttr["mime"]) ? $sourceImageAttr["mime"] : "";
148
+		$sourceImageBits = isset($sourceImageAttr["bits"]) ? $sourceImageAttr["bits"] : 8;
149
+		$sourceImageChannels = isset($sourceImageAttr["channels"]) ? $sourceImageAttr["channels"] : 3;
150
+
151
+		if (!$sourceImageWidth || !$sourceImageHeight || !$sourceImageMime) {
152
+			return false;
153
+		}
154
+
155
+		$iFinalWidth = $maxWidth == 0 ? $sourceImageWidth : $maxWidth;
156
+		$iFinalHeight = $maxHeight == 0 ? $sourceImageHeight : $maxHeight;
157
+
158
+		if ($sourceImageWidth <= $iFinalWidth && $sourceImageHeight <= $iFinalHeight) {
159
+			if ($sourceFile != $targetFile) {
160
+				copy($sourceFile, $targetFile);
161
+			}
162
+			return true;
163
+		}
164
+
165
+		if ($preserverAspectRatio)
166
+		{
167
+			// Gets the best size for aspect ratio resampling
168
+			$oSize = CKFinder_Connector_CommandHandler_Thumbnail::GetAspectRatioSize($iFinalWidth, $iFinalHeight, $sourceImageWidth, $sourceImageHeight );
169
+		}
170
+		else {
171
+			$oSize = array('Width' => $iFinalWidth, 'Height' => $iFinalHeight);
172
+		}
173
+
174
+		CKFinder_Connector_Utils_Misc::setMemoryForImage($sourceImageWidth, $sourceImageHeight, $sourceImageBits, $sourceImageChannels);
175
+
176
+		switch ($sourceImageAttr['mime'])
177
+		{
178
+			case 'image/gif':
179
+				{
180
+					if (@imagetypes() & IMG_GIF) {
181
+						$oImage = @imagecreatefromgif($sourceFile);
182
+					} else {
183
+						$ermsg = 'GIF images are not supported';
184
+					}
185
+				}
186
+				break;
187
+			case 'image/jpeg':
188
+				{
189
+					if (@imagetypes() & IMG_JPG) {
190
+						$oImage = @imagecreatefromjpeg($sourceFile) ;
191
+					} else {
192
+						$ermsg = 'JPEG images are not supported';
193
+					}
194
+				}
195
+				break;
196
+			case 'image/png':
197
+				{
198
+					if (@imagetypes() & IMG_PNG) {
199
+						$oImage = @imagecreatefrompng($sourceFile) ;
200
+					} else {
201
+						$ermsg = 'PNG images are not supported';
202
+					}
203
+				}
204
+				break;
205
+			case 'image/wbmp':
206
+				{
207
+					if (@imagetypes() & IMG_WBMP) {
208
+						$oImage = @imagecreatefromwbmp($sourceFile);
209
+					} else {
210
+						$ermsg = 'WBMP images are not supported';
211
+					}
212
+				}
213
+				break;
214
+			case 'image/bmp':
215
+				{
216
+					/*
217 217
                     * This is sad that PHP doesn't support bitmaps.
218 218
                     * Anyway, we will use our custom function at least to display thumbnails.
219 219
                     * We'll not resize images this way (if $sourceFile === $targetFile),
220 220
                     * because user defined imagecreatefrombmp and imagecreatebmp are horribly slow
221 221
                     */
222
-                    if ($bmpSupported && (@imagetypes() & IMG_JPG) && $sourceFile != $targetFile) {
223
-                        $oImage = CKFinder_Connector_Utils_Misc::imageCreateFromBmp($sourceFile);
224
-                    } else {
225
-                        $ermsg = 'BMP/JPG images are not supported';
226
-                    }
227
-                }
228
-                break;
229
-            default:
230
-                $ermsg = $sourceImageAttr['mime'].' images are not supported';
231
-                break;
232
-        }
233
-
234
-        if (isset($ermsg) || false === $oImage) {
235
-            return false;
236
-        }
237
-
238
-
239
-        $oThumbImage = imagecreatetruecolor($oSize["Width"], $oSize["Height"]);
240
-        //imagecopyresampled($oThumbImage, $oImage, 0, 0, 0, 0, $oSize["Width"], $oSize["Height"], $sourceImageWidth, $sourceImageHeight);
241
-        CKFinder_Connector_Utils_Misc::fastImageCopyResampled($oThumbImage, $oImage, 0, 0, 0, 0, $oSize["Width"], $oSize["Height"], $sourceImageWidth, $sourceImageHeight, (int)max(floor($quality/20), 1));
242
-
243
-        switch ($sourceImageAttr['mime'])
244
-        {
245
-            case 'image/gif':
246
-                imagegif($oThumbImage, $targetFile);
247
-                break;
248
-            case 'image/jpeg':
249
-            case 'image/bmp':
250
-                imagejpeg($oThumbImage, $targetFile, $quality);
251
-                break;
252
-            case 'image/png':
253
-                imagepng($oThumbImage, $targetFile);
254
-                break;
255
-            case 'image/wbmp':
256
-                imagewbmp($oThumbImage, $targetFile);
257
-                break;
258
-        }
259
-
260
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
261
-        if (file_exists($targetFile) && ($perms = $_config->getChmodFiles())) {
262
-            $oldUmask = umask(0);
263
-            chmod($targetFile, $perms);
264
-            umask($oldUmask);
265
-        }
266
-
267
-        imageDestroy($oImage);
268
-        imageDestroy($oThumbImage);
269
-
270
-        return true;
271
-    }
272
-
273
-
274
-
275
-    /**
276
-     * Return aspect ratio size, returns associative array:
277
-     * <pre>
278
-     * Array
279
-     * (
280
-     *      [Width] => 80
281
-     *      [Heigth] => 120
282
-     * )
283
-     * </pre>
284
-     *
285
-     * @param int $maxWidth
286
-     * @param int $maxHeight
287
-     * @param int $actualWidth
288
-     * @param int $actualHeight
289
-     * @return array
290
-     * @static
291
-     * @access public
292
-     */
293
-    public static function getAspectRatioSize($maxWidth, $maxHeight, $actualWidth, $actualHeight)
294
-    {
295
-        $oSize = array("Width"=>$maxWidth, "Height"=>$maxHeight);
296
-
297
-        // Calculates the X and Y resize factors
298
-        $iFactorX = (float)$maxWidth / (float)$actualWidth;
299
-        $iFactorY = (float)$maxHeight / (float)$actualHeight;
300
-
301
-        // If some dimension have to be scaled
302
-        if ($iFactorX != 1 || $iFactorY != 1)
303
-        {
304
-            // Uses the lower Factor to scale the oposite size
305
-            if ($iFactorX < $iFactorY) {
306
-                $oSize["Height"] = (int)round($actualHeight * $iFactorX);
307
-            }
308
-            else if ($iFactorX > $iFactorY) {
309
-                $oSize["Width"] = (int)round($actualWidth * $iFactorY);
310
-            }
311
-        }
312
-
313
-        if ($oSize["Height"] <= 0) {
314
-            $oSize["Height"] = 1;
315
-        }
316
-        if ($oSize["Width"] <= 0) {
317
-            $oSize["Width"] = 1;
318
-        }
319
-
320
-        // Returns the Size
321
-        return $oSize;
322
-    }
222
+					if ($bmpSupported && (@imagetypes() & IMG_JPG) && $sourceFile != $targetFile) {
223
+						$oImage = CKFinder_Connector_Utils_Misc::imageCreateFromBmp($sourceFile);
224
+					} else {
225
+						$ermsg = 'BMP/JPG images are not supported';
226
+					}
227
+				}
228
+				break;
229
+			default:
230
+				$ermsg = $sourceImageAttr['mime'].' images are not supported';
231
+				break;
232
+		}
233
+
234
+		if (isset($ermsg) || false === $oImage) {
235
+			return false;
236
+		}
237
+
238
+
239
+		$oThumbImage = imagecreatetruecolor($oSize["Width"], $oSize["Height"]);
240
+		//imagecopyresampled($oThumbImage, $oImage, 0, 0, 0, 0, $oSize["Width"], $oSize["Height"], $sourceImageWidth, $sourceImageHeight);
241
+		CKFinder_Connector_Utils_Misc::fastImageCopyResampled($oThumbImage, $oImage, 0, 0, 0, 0, $oSize["Width"], $oSize["Height"], $sourceImageWidth, $sourceImageHeight, (int)max(floor($quality/20), 1));
242
+
243
+		switch ($sourceImageAttr['mime'])
244
+		{
245
+			case 'image/gif':
246
+				imagegif($oThumbImage, $targetFile);
247
+				break;
248
+			case 'image/jpeg':
249
+			case 'image/bmp':
250
+				imagejpeg($oThumbImage, $targetFile, $quality);
251
+				break;
252
+			case 'image/png':
253
+				imagepng($oThumbImage, $targetFile);
254
+				break;
255
+			case 'image/wbmp':
256
+				imagewbmp($oThumbImage, $targetFile);
257
+				break;
258
+		}
259
+
260
+		$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
261
+		if (file_exists($targetFile) && ($perms = $_config->getChmodFiles())) {
262
+			$oldUmask = umask(0);
263
+			chmod($targetFile, $perms);
264
+			umask($oldUmask);
265
+		}
266
+
267
+		imageDestroy($oImage);
268
+		imageDestroy($oThumbImage);
269
+
270
+		return true;
271
+	}
272
+
273
+
274
+
275
+	/**
276
+	 * Return aspect ratio size, returns associative array:
277
+	 * <pre>
278
+	 * Array
279
+	 * (
280
+	 *      [Width] => 80
281
+	 *      [Heigth] => 120
282
+	 * )
283
+	 * </pre>
284
+	 *
285
+	 * @param int $maxWidth
286
+	 * @param int $maxHeight
287
+	 * @param int $actualWidth
288
+	 * @param int $actualHeight
289
+	 * @return array
290
+	 * @static
291
+	 * @access public
292
+	 */
293
+	public static function getAspectRatioSize($maxWidth, $maxHeight, $actualWidth, $actualHeight)
294
+	{
295
+		$oSize = array("Width"=>$maxWidth, "Height"=>$maxHeight);
296
+
297
+		// Calculates the X and Y resize factors
298
+		$iFactorX = (float)$maxWidth / (float)$actualWidth;
299
+		$iFactorY = (float)$maxHeight / (float)$actualHeight;
300
+
301
+		// If some dimension have to be scaled
302
+		if ($iFactorX != 1 || $iFactorY != 1)
303
+		{
304
+			// Uses the lower Factor to scale the oposite size
305
+			if ($iFactorX < $iFactorY) {
306
+				$oSize["Height"] = (int)round($actualHeight * $iFactorX);
307
+			}
308
+			else if ($iFactorX > $iFactorY) {
309
+				$oSize["Width"] = (int)round($actualWidth * $iFactorY);
310
+			}
311
+		}
312
+
313
+		if ($oSize["Height"] <= 0) {
314
+			$oSize["Height"] = 1;
315
+		}
316
+		if ($oSize["Width"] <= 0) {
317
+			$oSize["Width"] = 1;
318
+		}
319
+
320
+		// Returns the Size
321
+		return $oSize;
322
+	}
323 323
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
         $this->checkConnector();
51 51
         $this->checkRequest();
52 52
 
53
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
53
+        $_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config");
54 54
 
55 55
         $_thumbnails = $_config->getThumbnailsConfig();
56 56
         if (!$_thumbnails->getIsEnabled()) {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
         // If the thumbnail file doesn't exists, create it now.
84 84
         if (!file_exists($thumbFilePath)) {
85
-            if(!$this->createThumb($sourceFilePath, $thumbFilePath, $_thumbnails->getMaxWidth(), $_thumbnails->getMaxHeight(), $_thumbnails->getQuality(), true, $_thumbnails->getBmpSupported())) {
85
+            if (!$this->createThumb($sourceFilePath, $thumbFilePath, $_thumbnails->getMaxWidth(), $_thumbnails->getMaxHeight(), $_thumbnails->getQuality(), true, $_thumbnails->getBmpSupported())) {
86 86
                 $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
87 87
             }
88 88
         }
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
         $sourceImageAttr = getimagesize($thumbFilePath);
92 92
         $mime = $sourceImageAttr["mime"];
93 93
 
94
-        $rtime = isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])?@strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]):0;
95
-        $mtime =  filemtime($thumbFilePath);
96
-        $etag = dechex($mtime) . "-" . dechex($size);
94
+        $rtime = isset($_SERVER["HTTP_IF_MODIFIED_SINCE"]) ? @strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]) : 0;
95
+        $mtime = filemtime($thumbFilePath);
96
+        $etag = dechex($mtime)."-".dechex($size);
97 97
 
98 98
         $is304 = false;
99 99
 
100 100
         if (isset($_SERVER["HTTP_IF_NONE_MATCH"]) && $_SERVER["HTTP_IF_NONE_MATCH"] === $etag) {
101 101
             $is304 = true;
102 102
         }
103
-        else if($rtime == $mtime) {
103
+        else if ($rtime == $mtime) {
104 104
             $is304 = true;
105 105
         }
106 106
 
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
         //header("Pragma: public");
114 114
         //header("Expires: 0");
115 115
         header('Cache-control: public');
116
-        header('Etag: ' . $etag);
117
-        header("Content-type: " . $mime . "; name=\"" . CKFinder_Connector_Utils_Misc::mbBasename($thumbFilePath) . "\"");
118
-        header("Last-Modified: ".gmdate('D, d M Y H:i:s', $mtime) . " GMT");
116
+        header('Etag: '.$etag);
117
+        header("Content-type: ".$mime."; name=\"".CKFinder_Connector_Utils_Misc::mbBasename($thumbFilePath)."\"");
118
+        header("Last-Modified: ".gmdate('D, d M Y H:i:s', $mtime)." GMT");
119 119
         //header("Content-type: application/octet-stream; name=\"{$file}\"");
120 120
         //header("Content-Disposition: attachment; filename=\"{$file}\"");
121 121
         header("Content-Length: ".$size);
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
         if ($preserverAspectRatio)
166 166
         {
167 167
             // Gets the best size for aspect ratio resampling
168
-            $oSize = CKFinder_Connector_CommandHandler_Thumbnail::GetAspectRatioSize($iFinalWidth, $iFinalHeight, $sourceImageWidth, $sourceImageHeight );
168
+            $oSize = CKFinder_Connector_CommandHandler_Thumbnail::GetAspectRatioSize($iFinalWidth, $iFinalHeight, $sourceImageWidth, $sourceImageHeight);
169 169
         }
170 170
         else {
171 171
             $oSize = array('Width' => $iFinalWidth, 'Height' => $iFinalHeight);
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
             case 'image/jpeg':
188 188
                 {
189 189
                     if (@imagetypes() & IMG_JPG) {
190
-                        $oImage = @imagecreatefromjpeg($sourceFile) ;
190
+                        $oImage = @imagecreatefromjpeg($sourceFile);
191 191
                     } else {
192 192
                         $ermsg = 'JPEG images are not supported';
193 193
                     }
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
             case 'image/png':
197 197
                 {
198 198
                     if (@imagetypes() & IMG_PNG) {
199
-                        $oImage = @imagecreatefrompng($sourceFile) ;
199
+                        $oImage = @imagecreatefrompng($sourceFile);
200 200
                     } else {
201 201
                         $ermsg = 'PNG images are not supported';
202 202
                     }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 
239 239
         $oThumbImage = imagecreatetruecolor($oSize["Width"], $oSize["Height"]);
240 240
         //imagecopyresampled($oThumbImage, $oImage, 0, 0, 0, 0, $oSize["Width"], $oSize["Height"], $sourceImageWidth, $sourceImageHeight);
241
-        CKFinder_Connector_Utils_Misc::fastImageCopyResampled($oThumbImage, $oImage, 0, 0, 0, 0, $oSize["Width"], $oSize["Height"], $sourceImageWidth, $sourceImageHeight, (int)max(floor($quality/20), 1));
241
+        CKFinder_Connector_Utils_Misc::fastImageCopyResampled($oThumbImage, $oImage, 0, 0, 0, 0, $oSize["Width"], $oSize["Height"], $sourceImageWidth, $sourceImageHeight, (int)max(floor($quality / 20), 1));
242 242
 
243 243
         switch ($sourceImageAttr['mime'])
244 244
         {
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
                 break;
258 258
         }
259 259
 
260
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
260
+        $_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config");
261 261
         if (file_exists($targetFile) && ($perms = $_config->getChmodFiles())) {
262 262
             $oldUmask = umask(0);
263 263
             chmod($targetFile, $perms);
Please login to merge, or discard this patch.
Braces   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
 * modifying or distribute this file or part of its contents. The contents of
11 11
 * this file is part of the Source Code of CKFinder.
12 12
 */
13
-if (!defined('IN_CKFINDER')) exit;
13
+if (!defined('IN_CKFINDER')) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * @package CKFinder
@@ -99,8 +101,7 @@  discard block
 block discarded – undo
99 101
 
100 102
         if (isset($_SERVER["HTTP_IF_NONE_MATCH"]) && $_SERVER["HTTP_IF_NONE_MATCH"] === $etag) {
101 103
             $is304 = true;
102
-        }
103
-        else if($rtime == $mtime) {
104
+        } else if($rtime == $mtime) {
104 105
             $is304 = true;
105 106
         }
106 107
 
@@ -166,8 +167,7 @@  discard block
 block discarded – undo
166 167
         {
167 168
             // Gets the best size for aspect ratio resampling
168 169
             $oSize = CKFinder_Connector_CommandHandler_Thumbnail::GetAspectRatioSize($iFinalWidth, $iFinalHeight, $sourceImageWidth, $sourceImageHeight );
169
-        }
170
-        else {
170
+        } else {
171 171
             $oSize = array('Width' => $iFinalWidth, 'Height' => $iFinalHeight);
172 172
         }
173 173
 
@@ -304,8 +304,7 @@  discard block
 block discarded – undo
304 304
             // Uses the lower Factor to scale the oposite size
305 305
             if ($iFactorX < $iFactorY) {
306 306
                 $oSize["Height"] = (int)round($actualHeight * $iFactorX);
307
-            }
308
-            else if ($iFactorX > $iFactorY) {
307
+            } else if ($iFactorX > $iFactorY) {
309 308
                 $oSize["Width"] = (int)round($actualWidth * $iFactorY);
310 309
             }
311 310
         }
Please login to merge, or discard this patch.
libs/ckfinder/core/connector/php/php5/CommandHandler/DeleteFolder.php 3 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -32,44 +32,44 @@
 block discarded – undo
32 32
  */
33 33
 class CKFinder_Connector_CommandHandler_DeleteFolder extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase
34 34
 {
35
-    /**
36
-     * Command name
37
-     *
38
-     * @access private
39
-     * @var string
40
-     */
41
-    private $command = "DeleteFolder";
35
+	/**
36
+	 * Command name
37
+	 *
38
+	 * @access private
39
+	 * @var string
40
+	 */
41
+	private $command = "DeleteFolder";
42 42
 
43 43
 
44
-    /**
45
-     * handle request and build XML
46
-     * @access protected
47
-     *
48
-     */
49
-    protected function buildXml()
50
-    {
51
-        if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
52
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
53
-        }
44
+	/**
45
+	 * handle request and build XML
46
+	 * @access protected
47
+	 *
48
+	 */
49
+	protected function buildXml()
50
+	{
51
+		if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
52
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
53
+		}
54 54
 
55
-        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FOLDER_DELETE)) {
56
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
57
-        }
55
+		if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FOLDER_DELETE)) {
56
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
57
+		}
58 58
 
59
-        // The root folder cannot be deleted.
60
-        if ($this->_currentFolder->getClientPath() == "/") {
61
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
62
-        }
59
+		// The root folder cannot be deleted.
60
+		if ($this->_currentFolder->getClientPath() == "/") {
61
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
62
+		}
63 63
 
64
-        $folderServerPath = $this->_currentFolder->getServerPath();
65
-        if (!file_exists($folderServerPath) || !is_dir($folderServerPath)) {
66
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
67
-        }
64
+		$folderServerPath = $this->_currentFolder->getServerPath();
65
+		if (!file_exists($folderServerPath) || !is_dir($folderServerPath)) {
66
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
67
+		}
68 68
 
69
-        if (!CKFinder_Connector_Utils_FileSystem::unlink($folderServerPath)) {
70
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
71
-        }
69
+		if (!CKFinder_Connector_Utils_FileSystem::unlink($folderServerPath)) {
70
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
71
+		}
72 72
 
73
-        CKFinder_Connector_Utils_FileSystem::unlink($this->_currentFolder->getThumbsServerPath());
74
-    }
73
+		CKFinder_Connector_Utils_FileSystem::unlink($this->_currentFolder->getThumbsServerPath());
74
+	}
75 75
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 /**
22 22
  * Include base XML command handler
23 23
  */
24
-require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
24
+require_once CKFINDER_CONNECTOR_LIB_DIR."/CommandHandler/XmlCommandHandlerBase.php";
25 25
 
26 26
 /**
27 27
  * Handle DeleteFolder command
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
  * modifying or distribute this file or part of its contents. The contents of
11 11
  * this file is part of the Source Code of CKFinder.
12 12
  */
13
-if (!defined('IN_CKFINDER')) exit;
13
+if (!defined('IN_CKFINDER')) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * @package CKFinder
Please login to merge, or discard this patch.
libs/ckfinder/core/connector/php/php5/CommandHandler/FileUpload.php 3 patches
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -27,175 +27,175 @@
 block discarded – undo
27 27
  */
28 28
 class CKFinder_Connector_CommandHandler_FileUpload extends CKFinder_Connector_CommandHandler_CommandHandlerBase
29 29
 {
30
-    /**
31
-     * Command name
32
-     *
33
-     * @access protected
34
-     * @var string
35
-     */
36
-    protected $command = "FileUpload";
37
-
38
-    /**
39
-     * send response (save uploaded file, resize if required)
40
-     * @access public
41
-     *
42
-     */
43
-    public function sendResponse()
44
-    {
45
-        $iErrorNumber = CKFINDER_CONNECTOR_ERROR_NONE;
46
-
47
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
48
-        $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
49
-        $oRegistry->set("FileUpload_fileName", "unknown file");
50
-
51
-        $uploadedFile = array_shift($_FILES);
52
-
53
-        if (!isset($uploadedFile['name'])) {
54
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID);
55
-        }
56
-
57
-        $sUnsafeFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(CKFinder_Connector_Utils_Misc::mbBasename($uploadedFile['name']));
58
-        $sFileName = str_replace(array(":", "*", "?", "|", "/"), "_", $sUnsafeFileName);
59
-        if ($_config->forceAscii()) {
60
-            $sFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sFileName);
61
-        }
62
-        if ($sFileName != $sUnsafeFileName) {
63
-          $iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;
64
-        }
65
-        $oRegistry->set("FileUpload_fileName", $sFileName);
66
-
67
-        $this->checkConnector();
68
-        $this->checkRequest();
69
-
70
-        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) {
71
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
72
-        }
73
-
74
-        $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
75
-        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($sFileName) || $_resourceTypeConfig->checkIsHiddenFile($sFileName)) {
76
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
77
-        }
78
-
79
-        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
80
-        if (!$resourceTypeInfo->checkExtension($sFileName)) {
81
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
82
-        }
83
-
84
-        $sFileNameOrginal = $sFileName;
85
-        $oRegistry->set("FileUpload_fileName", $sFileName);
86
-        $oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
87
-
88
-        $maxSize = $resourceTypeInfo->getMaxSize();
89
-        if (!$_config->checkSizeAfterScaling() && $maxSize && $uploadedFile['size']>$maxSize) {
90
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
91
-        }
92
-
93
-        $htmlExtensions = $_config->getHtmlExtensions();
94
-        $sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
95
-
96
-        if ($htmlExtensions
97
-        && !CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive($sExtension, $htmlExtensions)
98
-        && ($detectHtml = CKFinder_Connector_Utils_FileSystem::detectHtml($uploadedFile['tmp_name'])) === true ) {
99
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
100
-        }
101
-
102
-        $sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
103
-        $secureImageUploads = $_config->getSecureImageUploads();
104
-        if ($secureImageUploads
105
-        && ($isImageValid = CKFinder_Connector_Utils_FileSystem::isImageValid($uploadedFile['tmp_name'], $sExtension)) === false ) {
106
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
107
-        }
108
-
109
-        switch ($uploadedFile['error']) {
110
-            case UPLOAD_ERR_OK:
111
-                break;
112
-
113
-            case UPLOAD_ERR_INI_SIZE:
114
-            case UPLOAD_ERR_FORM_SIZE:
115
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
116
-                break;
117
-
118
-            case UPLOAD_ERR_PARTIAL:
119
-            case UPLOAD_ERR_NO_FILE:
120
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
121
-                break;
122
-
123
-            case UPLOAD_ERR_NO_TMP_DIR:
124
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_NO_TMP_DIR);
125
-                break;
126
-
127
-            case UPLOAD_ERR_CANT_WRITE:
128
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
129
-                break;
130
-
131
-            case UPLOAD_ERR_EXTENSION:
132
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
133
-                break;
134
-        }
135
-
136
-        $sServerDir = $this->_currentFolder->getServerPath();
137
-        $iCounter = 0;
138
-
139
-        while (true)
140
-        {
141
-            $sFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($sServerDir, $sFileName);
142
-
143
-            if (file_exists($sFilePath)) {
144
-                $iCounter++;
145
-                $sFileName =
146
-                CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($sFileNameOrginal) .
147
-                "(" . $iCounter . ")" . "." .
148
-                CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
149
-                $oRegistry->set("FileUpload_fileName", $sFileName);
150
-
151
-                $iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_FILE_RENAMED;
152
-            } else {
153
-                if (false === move_uploaded_file($uploadedFile['tmp_name'], $sFilePath)) {
154
-                    $iErrorNumber = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED;
155
-                }
156
-                else {
157
-                    if (isset($detectHtml) && $detectHtml === -1 && CKFinder_Connector_Utils_FileSystem::detectHtml($sFilePath) === true) {
158
-                        @unlink($sFilePath);
159
-                        $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
160
-                    }
161
-                    else if (isset($isImageValid) && $isImageValid === -1 && CKFinder_Connector_Utils_FileSystem::isImageValid($sFilePath, $sExtension) === false) {
162
-                        @unlink($sFilePath);
163
-                        $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
164
-                    }
165
-                }
166
-                if (is_file($sFilePath) && ($perms = $_config->getChmodFiles())) {
167
-                    $oldumask = umask(0);
168
-                    chmod($sFilePath, $perms);
169
-                    umask($oldumask);
170
-                }
171
-                break;
172
-            }
173
-        }
174
-
175
-        if (!$_config->checkSizeAfterScaling()) {
176
-            $this->_errorHandler->throwError($iErrorNumber, true, false);
177
-        }
178
-
179
-        //resize image if required
180
-        require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/Thumbnail.php";
181
-        $_imagesConfig = $_config->getImagesConfig();
182
-
183
-        if ($_imagesConfig->getMaxWidth()>0 && $_imagesConfig->getMaxHeight()>0 && $_imagesConfig->getQuality()>0) {
184
-            CKFinder_Connector_CommandHandler_Thumbnail::createThumb($sFilePath, $sFilePath, $_imagesConfig->getMaxWidth(), $_imagesConfig->getMaxHeight(), $_imagesConfig->getQuality(), true) ;
185
-        }
186
-
187
-        if ($_config->checkSizeAfterScaling()) {
188
-            //check file size after scaling, attempt to delete if too big
189
-            clearstatcache();
190
-            if ($maxSize && filesize($sFilePath)>$maxSize) {
191
-                @unlink($sFilePath);
192
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
193
-            }
194
-            else {
195
-                $this->_errorHandler->throwError($iErrorNumber, true, false);
196
-            }
197
-        }
198
-
199
-        CKFinder_Connector_Core_Hooks::run('AfterFileUpload', array(&$this->_currentFolder, &$uploadedFile, &$sFilePath));
200
-    }
30
+	/**
31
+	 * Command name
32
+	 *
33
+	 * @access protected
34
+	 * @var string
35
+	 */
36
+	protected $command = "FileUpload";
37
+
38
+	/**
39
+	 * send response (save uploaded file, resize if required)
40
+	 * @access public
41
+	 *
42
+	 */
43
+	public function sendResponse()
44
+	{
45
+		$iErrorNumber = CKFINDER_CONNECTOR_ERROR_NONE;
46
+
47
+		$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
48
+		$oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
49
+		$oRegistry->set("FileUpload_fileName", "unknown file");
50
+
51
+		$uploadedFile = array_shift($_FILES);
52
+
53
+		if (!isset($uploadedFile['name'])) {
54
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID);
55
+		}
56
+
57
+		$sUnsafeFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding(CKFinder_Connector_Utils_Misc::mbBasename($uploadedFile['name']));
58
+		$sFileName = str_replace(array(":", "*", "?", "|", "/"), "_", $sUnsafeFileName);
59
+		if ($_config->forceAscii()) {
60
+			$sFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sFileName);
61
+		}
62
+		if ($sFileName != $sUnsafeFileName) {
63
+		  $iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED;
64
+		}
65
+		$oRegistry->set("FileUpload_fileName", $sFileName);
66
+
67
+		$this->checkConnector();
68
+		$this->checkRequest();
69
+
70
+		if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) {
71
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
72
+		}
73
+
74
+		$_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
75
+		if (!CKFinder_Connector_Utils_FileSystem::checkFileName($sFileName) || $_resourceTypeConfig->checkIsHiddenFile($sFileName)) {
76
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
77
+		}
78
+
79
+		$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
80
+		if (!$resourceTypeInfo->checkExtension($sFileName)) {
81
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
82
+		}
83
+
84
+		$sFileNameOrginal = $sFileName;
85
+		$oRegistry->set("FileUpload_fileName", $sFileName);
86
+		$oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
87
+
88
+		$maxSize = $resourceTypeInfo->getMaxSize();
89
+		if (!$_config->checkSizeAfterScaling() && $maxSize && $uploadedFile['size']>$maxSize) {
90
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
91
+		}
92
+
93
+		$htmlExtensions = $_config->getHtmlExtensions();
94
+		$sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
95
+
96
+		if ($htmlExtensions
97
+		&& !CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive($sExtension, $htmlExtensions)
98
+		&& ($detectHtml = CKFinder_Connector_Utils_FileSystem::detectHtml($uploadedFile['tmp_name'])) === true ) {
99
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
100
+		}
101
+
102
+		$sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
103
+		$secureImageUploads = $_config->getSecureImageUploads();
104
+		if ($secureImageUploads
105
+		&& ($isImageValid = CKFinder_Connector_Utils_FileSystem::isImageValid($uploadedFile['tmp_name'], $sExtension)) === false ) {
106
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
107
+		}
108
+
109
+		switch ($uploadedFile['error']) {
110
+			case UPLOAD_ERR_OK:
111
+				break;
112
+
113
+			case UPLOAD_ERR_INI_SIZE:
114
+			case UPLOAD_ERR_FORM_SIZE:
115
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
116
+				break;
117
+
118
+			case UPLOAD_ERR_PARTIAL:
119
+			case UPLOAD_ERR_NO_FILE:
120
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
121
+				break;
122
+
123
+			case UPLOAD_ERR_NO_TMP_DIR:
124
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_NO_TMP_DIR);
125
+				break;
126
+
127
+			case UPLOAD_ERR_CANT_WRITE:
128
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
129
+				break;
130
+
131
+			case UPLOAD_ERR_EXTENSION:
132
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
133
+				break;
134
+		}
135
+
136
+		$sServerDir = $this->_currentFolder->getServerPath();
137
+		$iCounter = 0;
138
+
139
+		while (true)
140
+		{
141
+			$sFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($sServerDir, $sFileName);
142
+
143
+			if (file_exists($sFilePath)) {
144
+				$iCounter++;
145
+				$sFileName =
146
+				CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($sFileNameOrginal) .
147
+				"(" . $iCounter . ")" . "." .
148
+				CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
149
+				$oRegistry->set("FileUpload_fileName", $sFileName);
150
+
151
+				$iErrorNumber = CKFINDER_CONNECTOR_ERROR_UPLOADED_FILE_RENAMED;
152
+			} else {
153
+				if (false === move_uploaded_file($uploadedFile['tmp_name'], $sFilePath)) {
154
+					$iErrorNumber = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED;
155
+				}
156
+				else {
157
+					if (isset($detectHtml) && $detectHtml === -1 && CKFinder_Connector_Utils_FileSystem::detectHtml($sFilePath) === true) {
158
+						@unlink($sFilePath);
159
+						$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
160
+					}
161
+					else if (isset($isImageValid) && $isImageValid === -1 && CKFinder_Connector_Utils_FileSystem::isImageValid($sFilePath, $sExtension) === false) {
162
+						@unlink($sFilePath);
163
+						$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
164
+					}
165
+				}
166
+				if (is_file($sFilePath) && ($perms = $_config->getChmodFiles())) {
167
+					$oldumask = umask(0);
168
+					chmod($sFilePath, $perms);
169
+					umask($oldumask);
170
+				}
171
+				break;
172
+			}
173
+		}
174
+
175
+		if (!$_config->checkSizeAfterScaling()) {
176
+			$this->_errorHandler->throwError($iErrorNumber, true, false);
177
+		}
178
+
179
+		//resize image if required
180
+		require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/Thumbnail.php";
181
+		$_imagesConfig = $_config->getImagesConfig();
182
+
183
+		if ($_imagesConfig->getMaxWidth()>0 && $_imagesConfig->getMaxHeight()>0 && $_imagesConfig->getQuality()>0) {
184
+			CKFinder_Connector_CommandHandler_Thumbnail::createThumb($sFilePath, $sFilePath, $_imagesConfig->getMaxWidth(), $_imagesConfig->getMaxHeight(), $_imagesConfig->getQuality(), true) ;
185
+		}
186
+
187
+		if ($_config->checkSizeAfterScaling()) {
188
+			//check file size after scaling, attempt to delete if too big
189
+			clearstatcache();
190
+			if ($maxSize && filesize($sFilePath)>$maxSize) {
191
+				@unlink($sFilePath);
192
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
193
+			}
194
+			else {
195
+				$this->_errorHandler->throwError($iErrorNumber, true, false);
196
+			}
197
+		}
198
+
199
+		CKFinder_Connector_Core_Hooks::run('AfterFileUpload', array(&$this->_currentFolder, &$uploadedFile, &$sFilePath));
200
+	}
201 201
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $iErrorNumber = CKFINDER_CONNECTOR_ERROR_NONE;
46 46
 
47
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
48
-        $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
47
+        $_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config");
48
+        $oRegistry = & CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
49 49
         $oRegistry->set("FileUpload_fileName", "unknown file");
50 50
 
51 51
         $uploadedFile = array_shift($_FILES);
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         $oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
87 87
 
88 88
         $maxSize = $resourceTypeInfo->getMaxSize();
89
-        if (!$_config->checkSizeAfterScaling() && $maxSize && $uploadedFile['size']>$maxSize) {
89
+        if (!$_config->checkSizeAfterScaling() && $maxSize && $uploadedFile['size'] > $maxSize) {
90 90
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
91 91
         }
92 92
 
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
 
96 96
         if ($htmlExtensions
97 97
         && !CKFinder_Connector_Utils_Misc::inArrayCaseInsensitive($sExtension, $htmlExtensions)
98
-        && ($detectHtml = CKFinder_Connector_Utils_FileSystem::detectHtml($uploadedFile['tmp_name'])) === true ) {
98
+        && ($detectHtml = CKFinder_Connector_Utils_FileSystem::detectHtml($uploadedFile['tmp_name'])) === true) {
99 99
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
100 100
         }
101 101
 
102 102
         $sExtension = CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
103 103
         $secureImageUploads = $_config->getSecureImageUploads();
104 104
         if ($secureImageUploads
105
-        && ($isImageValid = CKFinder_Connector_Utils_FileSystem::isImageValid($uploadedFile['tmp_name'], $sExtension)) === false ) {
105
+        && ($isImageValid = CKFinder_Connector_Utils_FileSystem::isImageValid($uploadedFile['tmp_name'], $sExtension)) === false) {
106 106
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
107 107
         }
108 108
 
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
             if (file_exists($sFilePath)) {
144 144
                 $iCounter++;
145 145
                 $sFileName =
146
-                CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($sFileNameOrginal) .
147
-                "(" . $iCounter . ")" . "." .
146
+                CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($sFileNameOrginal).
147
+                "(".$iCounter.")".".".
148 148
                 CKFinder_Connector_Utils_FileSystem::getExtension($sFileNameOrginal);
149 149
                 $oRegistry->set("FileUpload_fileName", $sFileName);
150 150
 
@@ -177,17 +177,17 @@  discard block
 block discarded – undo
177 177
         }
178 178
 
179 179
         //resize image if required
180
-        require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/Thumbnail.php";
180
+        require_once CKFINDER_CONNECTOR_LIB_DIR."/CommandHandler/Thumbnail.php";
181 181
         $_imagesConfig = $_config->getImagesConfig();
182 182
 
183
-        if ($_imagesConfig->getMaxWidth()>0 && $_imagesConfig->getMaxHeight()>0 && $_imagesConfig->getQuality()>0) {
184
-            CKFinder_Connector_CommandHandler_Thumbnail::createThumb($sFilePath, $sFilePath, $_imagesConfig->getMaxWidth(), $_imagesConfig->getMaxHeight(), $_imagesConfig->getQuality(), true) ;
183
+        if ($_imagesConfig->getMaxWidth() > 0 && $_imagesConfig->getMaxHeight() > 0 && $_imagesConfig->getQuality() > 0) {
184
+            CKFinder_Connector_CommandHandler_Thumbnail::createThumb($sFilePath, $sFilePath, $_imagesConfig->getMaxWidth(), $_imagesConfig->getMaxHeight(), $_imagesConfig->getQuality(), true);
185 185
         }
186 186
 
187 187
         if ($_config->checkSizeAfterScaling()) {
188 188
             //check file size after scaling, attempt to delete if too big
189 189
             clearstatcache();
190
-            if ($maxSize && filesize($sFilePath)>$maxSize) {
190
+            if ($maxSize && filesize($sFilePath) > $maxSize) {
191 191
                 @unlink($sFilePath);
192 192
                 $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
193 193
             }
Please login to merge, or discard this patch.
Braces   +6 added lines, -7 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
  * modifying or distribute this file or part of its contents. The contents of
11 11
  * this file is part of the Source Code of CKFinder.
12 12
  */
13
-if (!defined('IN_CKFINDER')) exit;
13
+if (!defined('IN_CKFINDER')) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * @package CKFinder
@@ -152,13 +154,11 @@  discard block
 block discarded – undo
152 154
             } else {
153 155
                 if (false === move_uploaded_file($uploadedFile['tmp_name'], $sFilePath)) {
154 156
                     $iErrorNumber = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED;
155
-                }
156
-                else {
157
+                } else {
157 158
                     if (isset($detectHtml) && $detectHtml === -1 && CKFinder_Connector_Utils_FileSystem::detectHtml($sFilePath) === true) {
158 159
                         @unlink($sFilePath);
159 160
                         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE);
160
-                    }
161
-                    else if (isset($isImageValid) && $isImageValid === -1 && CKFinder_Connector_Utils_FileSystem::isImageValid($sFilePath, $sExtension) === false) {
161
+                    } else if (isset($isImageValid) && $isImageValid === -1 && CKFinder_Connector_Utils_FileSystem::isImageValid($sFilePath, $sExtension) === false) {
162 162
                         @unlink($sFilePath);
163 163
                         $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT);
164 164
                     }
@@ -190,8 +190,7 @@  discard block
 block discarded – undo
190 190
             if ($maxSize && filesize($sFilePath)>$maxSize) {
191 191
                 @unlink($sFilePath);
192 192
                 $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG);
193
-            }
194
-            else {
193
+            } else {
195 194
                 $this->_errorHandler->throwError($iErrorNumber, true, false);
196 195
             }
197 196
         }
Please login to merge, or discard this patch.
libs/ckfinder/core/connector/php/php5/CommandHandler/CommandHandlerBase.php 3 patches
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -29,99 +29,99 @@
 block discarded – undo
29 29
  */
30 30
 class CKFinder_Connector_CommandHandler_CommandHandlerBase
31 31
 {
32
-    /**
33
-     * CKFinder_Connector_Core_Connector object
34
-     *
35
-     * @access protected
36
-     * @var CKFinder_Connector_Core_Connector
37
-     */
38
-    protected $_connector;
39
-    /**
40
-     * CKFinder_Connector_Core_FolderHandler object
41
-     *
42
-     * @access protected
43
-     * @var CKFinder_Connector_Core_FolderHandler
44
-     */
45
-    protected $_currentFolder;
46
-    /**
47
-     * Error handler object
48
-     *
49
-     * @access protected
50
-     * @var CKFinder_Connector_ErrorHandler_Base|CKFinder_Connector_ErrorHandler_FileUpload|CKFinder_Connector_ErrorHandler_Http
51
-     */
52
-    protected $_errorHandler;
32
+	/**
33
+	 * CKFinder_Connector_Core_Connector object
34
+	 *
35
+	 * @access protected
36
+	 * @var CKFinder_Connector_Core_Connector
37
+	 */
38
+	protected $_connector;
39
+	/**
40
+	 * CKFinder_Connector_Core_FolderHandler object
41
+	 *
42
+	 * @access protected
43
+	 * @var CKFinder_Connector_Core_FolderHandler
44
+	 */
45
+	protected $_currentFolder;
46
+	/**
47
+	 * Error handler object
48
+	 *
49
+	 * @access protected
50
+	 * @var CKFinder_Connector_ErrorHandler_Base|CKFinder_Connector_ErrorHandler_FileUpload|CKFinder_Connector_ErrorHandler_Http
51
+	 */
52
+	protected $_errorHandler;
53 53
 
54
-    function __construct()
55
-    {
56
-        $this->_currentFolder =& CKFinder_Connector_Core_Factory::getInstance("Core_FolderHandler");
57
-        $this->_connector =& CKFinder_Connector_Core_Factory::getInstance("Core_Connector");
58
-        $this->_errorHandler =& $this->_connector->getErrorHandler();
59
-    }
54
+	function __construct()
55
+	{
56
+		$this->_currentFolder =& CKFinder_Connector_Core_Factory::getInstance("Core_FolderHandler");
57
+		$this->_connector =& CKFinder_Connector_Core_Factory::getInstance("Core_Connector");
58
+		$this->_errorHandler =& $this->_connector->getErrorHandler();
59
+	}
60 60
 
61
-    /**
62
-     * Get Folder Handler
63
-     *
64
-     * @access public
65
-     * @return CKFinder_Connector_Core_FolderHandler
66
-     */
67
-    public function getFolderHandler()
68
-    {
69
-        if (is_null($this->_currentFolder)) {
70
-            $this->_currentFolder =& CKFinder_Connector_Core_Factory::getInstance("Core_FolderHandler");
71
-        }
61
+	/**
62
+	 * Get Folder Handler
63
+	 *
64
+	 * @access public
65
+	 * @return CKFinder_Connector_Core_FolderHandler
66
+	 */
67
+	public function getFolderHandler()
68
+	{
69
+		if (is_null($this->_currentFolder)) {
70
+			$this->_currentFolder =& CKFinder_Connector_Core_Factory::getInstance("Core_FolderHandler");
71
+		}
72 72
 
73
-        return $this->_currentFolder;
74
-    }
73
+		return $this->_currentFolder;
74
+	}
75 75
 
76
-    /**
77
-     * Check whether Connector is enabled
78
-     * @access protected
79
-     *
80
-     */
81
-    protected function checkConnector()
82
-    {
83
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
84
-        if (!$_config->getIsEnabled()) {
85
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CONNECTOR_DISABLED);
86
-        }
87
-    }
76
+	/**
77
+	 * Check whether Connector is enabled
78
+	 * @access protected
79
+	 *
80
+	 */
81
+	protected function checkConnector()
82
+	{
83
+		$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
84
+		if (!$_config->getIsEnabled()) {
85
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CONNECTOR_DISABLED);
86
+		}
87
+	}
88 88
 
89
-    /**
90
-     * Check request
91
-     * @access protected
92
-     *
93
-     */
94
-    protected function checkRequest()
95
-    {
96
-        if (preg_match(CKFINDER_REGEX_INVALID_PATH, $this->_currentFolder->getClientPath())) {
97
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
98
-        }
89
+	/**
90
+	 * Check request
91
+	 * @access protected
92
+	 *
93
+	 */
94
+	protected function checkRequest()
95
+	{
96
+		if (preg_match(CKFINDER_REGEX_INVALID_PATH, $this->_currentFolder->getClientPath())) {
97
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
98
+		}
99 99
 
100
-        $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
100
+		$_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
101 101
 
102
-        if (is_null($_resourceTypeConfig)) {
103
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_TYPE);
104
-        }
102
+		if (is_null($_resourceTypeConfig)) {
103
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_TYPE);
104
+		}
105 105
 
106
-        $_clientPath = $this->_currentFolder->getClientPath();
107
-        $_clientPathParts = explode("/", trim($_clientPath, "/"));
108
-        if ($_clientPathParts) {
109
-            foreach ($_clientPathParts as $_part) {
110
-                if ($_resourceTypeConfig->checkIsHiddenFolder($_part)) {
111
-                    $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
112
-                }
113
-            }
114
-        }
106
+		$_clientPath = $this->_currentFolder->getClientPath();
107
+		$_clientPathParts = explode("/", trim($_clientPath, "/"));
108
+		if ($_clientPathParts) {
109
+			foreach ($_clientPathParts as $_part) {
110
+				if ($_resourceTypeConfig->checkIsHiddenFolder($_part)) {
111
+					$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
112
+				}
113
+			}
114
+		}
115 115
 
116
-        if (!is_dir($this->_currentFolder->getServerPath())) {
117
-            if ($_clientPath == "/") {
118
-                if (!CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively($this->_currentFolder->getServerPath())) {
116
+		if (!is_dir($this->_currentFolder->getServerPath())) {
117
+			if ($_clientPath == "/") {
118
+				if (!CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively($this->_currentFolder->getServerPath())) {
119 119
 
120
-                }
121
-            }
122
-            else {
123
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
124
-            }
125
-        }
126
-    }
120
+				}
121
+			}
122
+			else {
123
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
124
+			}
125
+		}
126
+	}
127 127
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 
54 54
     function __construct()
55 55
     {
56
-        $this->_currentFolder =& CKFinder_Connector_Core_Factory::getInstance("Core_FolderHandler");
57
-        $this->_connector =& CKFinder_Connector_Core_Factory::getInstance("Core_Connector");
58
-        $this->_errorHandler =& $this->_connector->getErrorHandler();
56
+        $this->_currentFolder = & CKFinder_Connector_Core_Factory::getInstance("Core_FolderHandler");
57
+        $this->_connector = & CKFinder_Connector_Core_Factory::getInstance("Core_Connector");
58
+        $this->_errorHandler = & $this->_connector->getErrorHandler();
59 59
     }
60 60
 
61 61
     /**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     public function getFolderHandler()
68 68
     {
69 69
         if (is_null($this->_currentFolder)) {
70
-            $this->_currentFolder =& CKFinder_Connector_Core_Factory::getInstance("Core_FolderHandler");
70
+            $this->_currentFolder = & CKFinder_Connector_Core_Factory::getInstance("Core_FolderHandler");
71 71
         }
72 72
 
73 73
         return $this->_currentFolder;
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     protected function checkConnector()
82 82
     {
83
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
83
+        $_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config");
84 84
         if (!$_config->getIsEnabled()) {
85 85
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_CONNECTOR_DISABLED);
86 86
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
  * modifying or distribute this file or part of its contents. The contents of
11 11
  * this file is part of the Source Code of CKFinder.
12 12
  */
13
-if (!defined('IN_CKFINDER')) exit;
13
+if (!defined('IN_CKFINDER')) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * @package CKFinder
@@ -118,8 +120,7 @@  discard block
 block discarded – undo
118 120
                 if (!CKFinder_Connector_Utils_FileSystem::createDirectoryRecursively($this->_currentFolder->getServerPath())) {
119 121
 
120 122
                 }
121
-            }
122
-            else {
123
+            } else {
123 124
                 $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
124 125
             }
125 126
         }
Please login to merge, or discard this patch.
libs/ckfinder/core/connector/php/php5/CommandHandler/RenameFile.php 3 patches
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -32,96 +32,96 @@
 block discarded – undo
32 32
  */
33 33
 class CKFinder_Connector_CommandHandler_RenameFile extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase
34 34
 {
35
-    /**
36
-     * Command name
37
-     *
38
-     * @access private
39
-     * @var string
40
-     */
41
-    private $command = "RenameFile";
42
-
43
-
44
-    /**
45
-     * handle request and build XML
46
-     * @access protected
47
-     *
48
-     */
49
-    protected function buildXml()
50
-    {
51
-        if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
52
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
53
-        }
54
-
55
-        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_RENAME)) {
56
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
57
-        }
58
-
59
-        if (!isset($_GET["fileName"])) {
60
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
61
-        }
62
-        if (!isset($_GET["newFileName"])) {
63
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
64
-        }
65
-
66
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
67
-        $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["fileName"]);
68
-        $newFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["newFileName"]);
69
-
70
-        $oRenamedFileNode = new Ckfinder_Connector_Utils_XmlNode("RenamedFile");
71
-        $this->_connectorNode->addChild($oRenamedFileNode);
72
-        $oRenamedFileNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($fileName));
73
-
74
-        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
75
-        if (!$resourceTypeInfo->checkExtension($newFileName)) {
76
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
77
-        }
78
-
79
-        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
80
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
81
-        }
82
-
83
-        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($newFileName) || $resourceTypeInfo->checkIsHiddenFile($newFileName)) {
84
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
85
-        }
86
-
87
-        if (!$resourceTypeInfo->checkExtension($fileName, false)) {
88
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
89
-        }
90
-
91
-        if ($_config->forceAscii()) {
92
-            $newFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($newFileName);
93
-        }
94
-
95
-        $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
96
-        $newFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $newFileName);
97
-
98
-        $bMoved = false;
99
-
100
-        if (!file_exists($filePath)) {
101
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
102
-        }
103
-
104
-        if (!is_writable(dirname($newFilePath))) {
105
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
106
-        }
107
-
108
-        if (!is_writable($filePath)) {
109
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
110
-        }
111
-
112
-        if (file_exists($newFilePath)) {
113
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST);
114
-        }
115
-
116
-        $bMoved = @rename($filePath, $newFilePath);
117
-
118
-        if (!$bMoved) {
119
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNKNOWN, "File " . CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($fileName) . "has not been renamed");
120
-        } else {
121
-            $oRenamedFileNode->addAttribute("newName", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($newFileName));
122
-
123
-            $thumbPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getThumbsServerPath(), $fileName);
124
-            CKFinder_Connector_Utils_FileSystem::unlink($thumbPath);
125
-        }
126
-    }
35
+	/**
36
+	 * Command name
37
+	 *
38
+	 * @access private
39
+	 * @var string
40
+	 */
41
+	private $command = "RenameFile";
42
+
43
+
44
+	/**
45
+	 * handle request and build XML
46
+	 * @access protected
47
+	 *
48
+	 */
49
+	protected function buildXml()
50
+	{
51
+		if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
52
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
53
+		}
54
+
55
+		if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_RENAME)) {
56
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
57
+		}
58
+
59
+		if (!isset($_GET["fileName"])) {
60
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
61
+		}
62
+		if (!isset($_GET["newFileName"])) {
63
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
64
+		}
65
+
66
+		$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
67
+		$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["fileName"]);
68
+		$newFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["newFileName"]);
69
+
70
+		$oRenamedFileNode = new Ckfinder_Connector_Utils_XmlNode("RenamedFile");
71
+		$this->_connectorNode->addChild($oRenamedFileNode);
72
+		$oRenamedFileNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($fileName));
73
+
74
+		$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
75
+		if (!$resourceTypeInfo->checkExtension($newFileName)) {
76
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
77
+		}
78
+
79
+		if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
80
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
81
+		}
82
+
83
+		if (!CKFinder_Connector_Utils_FileSystem::checkFileName($newFileName) || $resourceTypeInfo->checkIsHiddenFile($newFileName)) {
84
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
85
+		}
86
+
87
+		if (!$resourceTypeInfo->checkExtension($fileName, false)) {
88
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
89
+		}
90
+
91
+		if ($_config->forceAscii()) {
92
+			$newFileName = CKFinder_Connector_Utils_FileSystem::convertToAscii($newFileName);
93
+		}
94
+
95
+		$filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
96
+		$newFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $newFileName);
97
+
98
+		$bMoved = false;
99
+
100
+		if (!file_exists($filePath)) {
101
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
102
+		}
103
+
104
+		if (!is_writable(dirname($newFilePath))) {
105
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
106
+		}
107
+
108
+		if (!is_writable($filePath)) {
109
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
110
+		}
111
+
112
+		if (file_exists($newFilePath)) {
113
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST);
114
+		}
115
+
116
+		$bMoved = @rename($filePath, $newFilePath);
117
+
118
+		if (!$bMoved) {
119
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNKNOWN, "File " . CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($fileName) . "has not been renamed");
120
+		} else {
121
+			$oRenamedFileNode->addAttribute("newName", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($newFileName));
122
+
123
+			$thumbPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getThumbsServerPath(), $fileName);
124
+			CKFinder_Connector_Utils_FileSystem::unlink($thumbPath);
125
+		}
126
+	}
127 127
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 /**
22 22
  * Include base XML command handler
23 23
  */
24
-require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
24
+require_once CKFINDER_CONNECTOR_LIB_DIR."/CommandHandler/XmlCommandHandlerBase.php";
25 25
 
26 26
 /**
27 27
  * Handle RenameFile command
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
64 64
         }
65 65
 
66
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
66
+        $_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config");
67 67
         $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["fileName"]);
68 68
         $newFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["newFileName"]);
69 69
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
         $bMoved = @rename($filePath, $newFilePath);
117 117
 
118 118
         if (!$bMoved) {
119
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNKNOWN, "File " . CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($fileName) . "has not been renamed");
119
+            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNKNOWN, "File ".CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($fileName)."has not been renamed");
120 120
         } else {
121 121
             $oRenamedFileNode->addAttribute("newName", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($newFileName));
122 122
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
 * modifying or distribute this file or part of its contents. The contents of
11 11
 * this file is part of the Source Code of CKFinder.
12 12
 */
13
-if (!defined('IN_CKFINDER')) exit;
13
+if (!defined('IN_CKFINDER')) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * @package CKFinder
Please login to merge, or discard this patch.
libs/ckfinder/core/connector/php/php5/CommandHandler/CreateFolder.php 3 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -32,67 +32,67 @@
 block discarded – undo
32 32
  */
33 33
 class CKFinder_Connector_CommandHandler_CreateFolder extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase
34 34
 {
35
-    /**
36
-     * Command name
37
-     *
38
-     * @access private
39
-     * @var string
40
-     */
41
-    private $command = "CreateFolder";
35
+	/**
36
+	 * Command name
37
+	 *
38
+	 * @access private
39
+	 * @var string
40
+	 */
41
+	private $command = "CreateFolder";
42 42
 
43
-    /**
44
-     * handle request and build XML
45
-     * @access protected
46
-     *
47
-     */
48
-    protected function buildXml()
49
-    {
50
-        if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
51
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
52
-        }
43
+	/**
44
+	 * handle request and build XML
45
+	 * @access protected
46
+	 *
47
+	 */
48
+	protected function buildXml()
49
+	{
50
+		if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
51
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
52
+		}
53 53
 
54
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
55
-        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FOLDER_CREATE)) {
56
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
57
-        }
54
+		$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
55
+		if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FOLDER_CREATE)) {
56
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
57
+		}
58 58
 
59
-        $_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
60
-        $sNewFolderName = isset($_GET["NewFolderName"]) ? $_GET["NewFolderName"] : "";
61
-        $sNewFolderName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($sNewFolderName);
62
-        if ($_config->forceAscii()) {
63
-            $sNewFolderName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sNewFolderName);
64
-        }
59
+		$_resourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
60
+		$sNewFolderName = isset($_GET["NewFolderName"]) ? $_GET["NewFolderName"] : "";
61
+		$sNewFolderName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($sNewFolderName);
62
+		if ($_config->forceAscii()) {
63
+			$sNewFolderName = CKFinder_Connector_Utils_FileSystem::convertToAscii($sNewFolderName);
64
+		}
65 65
 
66
-        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($sNewFolderName) || $_resourceTypeConfig->checkIsHiddenFolder($sNewFolderName)) {
67
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
68
-        }
66
+		if (!CKFinder_Connector_Utils_FileSystem::checkFileName($sNewFolderName) || $_resourceTypeConfig->checkIsHiddenFolder($sNewFolderName)) {
67
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
68
+		}
69 69
 
70
-        $sServerDir = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $sNewFolderName);
71
-        if (!is_writeable($this->_currentFolder->getServerPath())) {
72
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
73
-        }
70
+		$sServerDir = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $sNewFolderName);
71
+		if (!is_writeable($this->_currentFolder->getServerPath())) {
72
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
73
+		}
74 74
 
75
-        $bCreated = false;
75
+		$bCreated = false;
76 76
 
77
-        if (file_exists($sServerDir)) {
78
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST);
79
-        }
77
+		if (file_exists($sServerDir)) {
78
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST);
79
+		}
80 80
 
81
-        if ($perms = $_config->getChmodFolders()) {
82
-            $oldUmask = umask(0);
83
-            $bCreated = @mkdir($sServerDir, $perms);
84
-            umask($oldUmask);
85
-        }
86
-        else {
87
-            $bCreated = @mkdir($sServerDir);
88
-        }
81
+		if ($perms = $_config->getChmodFolders()) {
82
+			$oldUmask = umask(0);
83
+			$bCreated = @mkdir($sServerDir, $perms);
84
+			umask($oldUmask);
85
+		}
86
+		else {
87
+			$bCreated = @mkdir($sServerDir);
88
+		}
89 89
 
90
-        if (!$bCreated) {
91
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
92
-        } else {
93
-            $oNewFolderNode = new Ckfinder_Connector_Utils_XmlNode("NewFolder");
94
-            $this->_connectorNode->addChild($oNewFolderNode);
95
-            $oNewFolderNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($sNewFolderName));
96
-        }
97
-    }
90
+		if (!$bCreated) {
91
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
92
+		} else {
93
+			$oNewFolderNode = new Ckfinder_Connector_Utils_XmlNode("NewFolder");
94
+			$this->_connectorNode->addChild($oNewFolderNode);
95
+			$oNewFolderNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($sNewFolderName));
96
+		}
97
+	}
98 98
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 /**
22 22
  * Include base XML command handler
23 23
  */
24
-require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
24
+require_once CKFINDER_CONNECTOR_LIB_DIR."/CommandHandler/XmlCommandHandlerBase.php";
25 25
 
26 26
 /**
27 27
  * Handle CreateFolder command
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
52 52
         }
53 53
 
54
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
54
+        $_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config");
55 55
         if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FOLDER_CREATE)) {
56 56
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
57 57
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
10 10
  * modifying or distribute this file or part of its contents. The contents of
11 11
  * this file is part of the Source Code of CKFinder.
12 12
  */
13
-if (!defined('IN_CKFINDER')) exit;
13
+if (!defined('IN_CKFINDER')) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * @package CKFinder
@@ -82,8 +84,7 @@  discard block
 block discarded – undo
82 84
             $oldUmask = umask(0);
83 85
             $bCreated = @mkdir($sServerDir, $perms);
84 86
             umask($oldUmask);
85
-        }
86
-        else {
87
+        } else {
87 88
             $bCreated = @mkdir($sServerDir);
88 89
         }
89 90
 
Please login to merge, or discard this patch.
libs/ckfinder/core/connector/php/php5/CommandHandler/QuickUpload.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@
 block discarded – undo
32 32
  */
33 33
 class CKFinder_Connector_CommandHandler_QuickUpload extends CKFinder_Connector_CommandHandler_FileUpload
34 34
 {
35
-    /**
36
-     * Command name
37
-     *
38
-     * @access protected
39
-     * @var string
40
-     */
41
-    protected $command = "QuickUpload";
35
+	/**
36
+	 * Command name
37
+	 *
38
+	 * @access protected
39
+	 * @var string
40
+	 */
41
+	protected $command = "QuickUpload";
42 42
 
43
-    function sendResponse()
44
-    {
45
-        $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
46
-        $oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
43
+	function sendResponse()
44
+	{
45
+		$oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
46
+		$oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
47 47
 
48
-        return parent::sendResponse();
49
-    }
48
+		return parent::sendResponse();
49
+	}
50 50
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 /**
22 22
  * Include file upload command handler
23 23
  */
24
-require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/FileUpload.php";
24
+require_once CKFINDER_CONNECTOR_LIB_DIR."/CommandHandler/FileUpload.php";
25 25
 
26 26
 /**
27 27
  * Handle QuickUpload command
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 
43 43
     function sendResponse()
44 44
     {
45
-        $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
45
+        $oRegistry = & CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
46 46
         $oRegistry->set("FileUpload_url", $this->_currentFolder->getUrl());
47 47
 
48 48
         return parent::sendResponse();
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
  * modifying or distribute this file or part of its contents. The contents of
11 11
  * this file is part of the Source Code of CKFinder.
12 12
  */
13
-if (!defined('IN_CKFINDER')) exit;
13
+if (!defined('IN_CKFINDER')) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * @package CKFinder
Please login to merge, or discard this patch.
libs/ckfinder/core/connector/php/php5/CommandHandler/GetFolders.php 3 patches
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -32,74 +32,74 @@
 block discarded – undo
32 32
  */
33 33
 class CKFinder_Connector_CommandHandler_GetFolders extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase
34 34
 {
35
-    /**
36
-     * Command name
37
-     *
38
-     * @access private
39
-     * @var string
40
-     */
41
-    private $command = "GetFolders";
35
+	/**
36
+	 * Command name
37
+	 *
38
+	 * @access private
39
+	 * @var string
40
+	 */
41
+	private $command = "GetFolders";
42 42
 
43
-    /**
44
-     * handle request and build XML
45
-     * @access protected
46
-     *
47
-     */
48
-    protected function buildXml()
49
-    {
50
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
51
-        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FOLDER_VIEW)) {
52
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
53
-        }
43
+	/**
44
+	 * handle request and build XML
45
+	 * @access protected
46
+	 *
47
+	 */
48
+	protected function buildXml()
49
+	{
50
+		$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
51
+		if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FOLDER_VIEW)) {
52
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
53
+		}
54 54
 
55
-        // Map the virtual path to the local server path.
56
-        $_sServerDir = $this->_currentFolder->getServerPath();
55
+		// Map the virtual path to the local server path.
56
+		$_sServerDir = $this->_currentFolder->getServerPath();
57 57
 
58
-        if (!is_dir($_sServerDir)) {
59
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
60
-        }
58
+		if (!is_dir($_sServerDir)) {
59
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND);
60
+		}
61 61
 
62
-        // Create the "Folders" node.
63
-        $oFoldersNode = new Ckfinder_Connector_Utils_XmlNode("Folders");
64
-        $this->_connectorNode->addChild($oFoldersNode);
62
+		// Create the "Folders" node.
63
+		$oFoldersNode = new Ckfinder_Connector_Utils_XmlNode("Folders");
64
+		$this->_connectorNode->addChild($oFoldersNode);
65 65
 
66
-        $files = array();
67
-        if ($dh = @opendir($_sServerDir)) {
68
-            while (($file = readdir($dh)) !== false) {
69
-                if ($file != "." && $file != ".." && is_dir($_sServerDir . $file)) {
70
-                    $files[] = $file;
71
-                }
72
-            }
73
-            closedir($dh);
74
-        } else {
75
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
76
-        }
66
+		$files = array();
67
+		if ($dh = @opendir($_sServerDir)) {
68
+			while (($file = readdir($dh)) !== false) {
69
+				if ($file != "." && $file != ".." && is_dir($_sServerDir . $file)) {
70
+					$files[] = $file;
71
+				}
72
+			}
73
+			closedir($dh);
74
+		} else {
75
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
76
+		}
77 77
 
78
-        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
78
+		$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
79 79
 
80
-        if (sizeof($files)>0) {
81
-            natcasesort($files);
82
-            $i=0;
83
-            foreach ($files as $file) {
84
-                $oAcl = $_config->getAccessControlConfig();
85
-                $aclMask = $oAcl->getComputedMask($this->_currentFolder->getResourceTypeName(), $this->_currentFolder->getClientPath() . $file . "/");
80
+		if (sizeof($files)>0) {
81
+			natcasesort($files);
82
+			$i=0;
83
+			foreach ($files as $file) {
84
+				$oAcl = $_config->getAccessControlConfig();
85
+				$aclMask = $oAcl->getComputedMask($this->_currentFolder->getResourceTypeName(), $this->_currentFolder->getClientPath() . $file . "/");
86 86
 
87
-                if (($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) != CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) {
88
-                    continue;
89
-                }
90
-                if ($resourceTypeInfo->checkIsHiddenFolder($file)) {
91
-                    continue;
92
-                }
87
+				if (($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) != CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) {
88
+					continue;
89
+				}
90
+				if ($resourceTypeInfo->checkIsHiddenFolder($file)) {
91
+					continue;
92
+				}
93 93
 
94
-                // Create the "Folder" node.
95
-                $oFolderNode[$i] = new Ckfinder_Connector_Utils_XmlNode("Folder");
96
-                $oFoldersNode->addChild($oFolderNode[$i]);
97
-                $oFolderNode[$i]->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($file));
98
-                $oFolderNode[$i]->addAttribute("hasChildren", CKFinder_Connector_Utils_FileSystem::hasChildren($_sServerDir . $file) ? "true" : "false");
99
-                $oFolderNode[$i]->addAttribute("acl", $aclMask);
94
+				// Create the "Folder" node.
95
+				$oFolderNode[$i] = new Ckfinder_Connector_Utils_XmlNode("Folder");
96
+				$oFoldersNode->addChild($oFolderNode[$i]);
97
+				$oFolderNode[$i]->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($file));
98
+				$oFolderNode[$i]->addAttribute("hasChildren", CKFinder_Connector_Utils_FileSystem::hasChildren($_sServerDir . $file) ? "true" : "false");
99
+				$oFolderNode[$i]->addAttribute("acl", $aclMask);
100 100
 
101
-                $i++;
102
-            }
103
-        }
104
-    }
101
+				$i++;
102
+			}
103
+		}
104
+	}
105 105
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 /**
22 22
  * Include base XML command handler
23 23
  */
24
-require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
24
+require_once CKFINDER_CONNECTOR_LIB_DIR."/CommandHandler/XmlCommandHandlerBase.php";
25 25
 
26 26
 /**
27 27
  * Handle GetFolders command
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     protected function buildXml()
49 49
     {
50
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
50
+        $_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config");
51 51
         if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FOLDER_VIEW)) {
52 52
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
53 53
         }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $files = array();
67 67
         if ($dh = @opendir($_sServerDir)) {
68 68
             while (($file = readdir($dh)) !== false) {
69
-                if ($file != "." && $file != ".." && is_dir($_sServerDir . $file)) {
69
+                if ($file != "." && $file != ".." && is_dir($_sServerDir.$file)) {
70 70
                     $files[] = $file;
71 71
                 }
72 72
             }
@@ -77,12 +77,12 @@  discard block
 block discarded – undo
77 77
 
78 78
         $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
79 79
 
80
-        if (sizeof($files)>0) {
80
+        if (sizeof($files) > 0) {
81 81
             natcasesort($files);
82
-            $i=0;
82
+            $i = 0;
83 83
             foreach ($files as $file) {
84 84
                 $oAcl = $_config->getAccessControlConfig();
85
-                $aclMask = $oAcl->getComputedMask($this->_currentFolder->getResourceTypeName(), $this->_currentFolder->getClientPath() . $file . "/");
85
+                $aclMask = $oAcl->getComputedMask($this->_currentFolder->getResourceTypeName(), $this->_currentFolder->getClientPath().$file."/");
86 86
 
87 87
                 if (($aclMask & CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) != CKFINDER_CONNECTOR_ACL_FOLDER_VIEW) {
88 88
                     continue;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
                 $oFolderNode[$i] = new Ckfinder_Connector_Utils_XmlNode("Folder");
96 96
                 $oFoldersNode->addChild($oFolderNode[$i]);
97 97
                 $oFolderNode[$i]->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($file));
98
-                $oFolderNode[$i]->addAttribute("hasChildren", CKFinder_Connector_Utils_FileSystem::hasChildren($_sServerDir . $file) ? "true" : "false");
98
+                $oFolderNode[$i]->addAttribute("hasChildren", CKFinder_Connector_Utils_FileSystem::hasChildren($_sServerDir.$file) ? "true" : "false");
99 99
                 $oFolderNode[$i]->addAttribute("acl", $aclMask);
100 100
 
101 101
                 $i++;
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
  * modifying or distribute this file or part of its contents. The contents of
11 11
  * this file is part of the Source Code of CKFinder.
12 12
  */
13
-if (!defined('IN_CKFINDER')) exit;
13
+if (!defined('IN_CKFINDER')) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * @package CKFinder
Please login to merge, or discard this patch.
libs/ckfinder/core/connector/php/php5/CommandHandler/DeleteFile.php 3 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -32,68 +32,68 @@
 block discarded – undo
32 32
  */
33 33
 class CKFinder_Connector_CommandHandler_DeleteFile extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase
34 34
 {
35
-    /**
36
-     * Command name
37
-     *
38
-     * @access private
39
-     * @var string
40
-     */
41
-    private $command = "DeleteFile";
42
-
43
-
44
-    /**
45
-     * handle request and build XML
46
-     * @access protected
47
-     *
48
-     */
49
-    protected function buildXml()
50
-    {
51
-        if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
52
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
53
-        }
54
-
55
-        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_DELETE)) {
56
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
57
-        }
58
-
59
-        if (!isset($_GET["FileName"])) {
60
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
61
-        }
62
-
63
-        $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["FileName"]);
64
-        $_resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
65
-
66
-        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $_resourceTypeInfo->checkIsHiddenFile($fileName)) {
67
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
68
-        }
69
-
70
-        if (!$_resourceTypeInfo->checkExtension($fileName, false)) {
71
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
72
-        }
73
-
74
-        $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
75
-
76
-        $bDeleted = false;
77
-
78
-        if (!file_exists($filePath)) {
79
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
80
-        }
81
-
82
-        if (!@unlink($filePath)) {
83
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
84
-        } else {
85
-            $bDeleted = true;
86
-        }
87
-
88
-        if ($bDeleted) {
89
-            $thumbPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getThumbsServerPath(), $fileName);
90
-
91
-            @unlink($thumbPath);
92
-
93
-            $oDeleteFileNode = new Ckfinder_Connector_Utils_XmlNode("DeletedFile");
94
-            $this->_connectorNode->addChild($oDeleteFileNode);
95
-
96
-            $oDeleteFileNode->addAttribute("name", $fileName);
97
-        }
98
-    }
35
+	/**
36
+	 * Command name
37
+	 *
38
+	 * @access private
39
+	 * @var string
40
+	 */
41
+	private $command = "DeleteFile";
42
+
43
+
44
+	/**
45
+	 * handle request and build XML
46
+	 * @access protected
47
+	 *
48
+	 */
49
+	protected function buildXml()
50
+	{
51
+		if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
52
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
53
+		}
54
+
55
+		if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_DELETE)) {
56
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
57
+		}
58
+
59
+		if (!isset($_GET["FileName"])) {
60
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
61
+		}
62
+
63
+		$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["FileName"]);
64
+		$_resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
65
+
66
+		if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $_resourceTypeInfo->checkIsHiddenFile($fileName)) {
67
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
68
+		}
69
+
70
+		if (!$_resourceTypeInfo->checkExtension($fileName, false)) {
71
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
72
+		}
73
+
74
+		$filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
75
+
76
+		$bDeleted = false;
77
+
78
+		if (!file_exists($filePath)) {
79
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
80
+		}
81
+
82
+		if (!@unlink($filePath)) {
83
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
84
+		} else {
85
+			$bDeleted = true;
86
+		}
87
+
88
+		if ($bDeleted) {
89
+			$thumbPath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getThumbsServerPath(), $fileName);
90
+
91
+			@unlink($thumbPath);
92
+
93
+			$oDeleteFileNode = new Ckfinder_Connector_Utils_XmlNode("DeletedFile");
94
+			$this->_connectorNode->addChild($oDeleteFileNode);
95
+
96
+			$oDeleteFileNode->addAttribute("name", $fileName);
97
+		}
98
+	}
99 99
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
 /**
22 22
  * Include base XML command handler
23 23
  */
24
-require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
24
+require_once CKFINDER_CONNECTOR_LIB_DIR."/CommandHandler/XmlCommandHandlerBase.php";
25 25
 
26 26
 /**
27 27
  * Handle DeleteFile command
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
  * modifying or distribute this file or part of its contents. The contents of
11 11
  * this file is part of the Source Code of CKFinder.
12 12
  */
13
-if (!defined('IN_CKFINDER')) exit;
13
+if (!defined('IN_CKFINDER')) {
14
+	exit;
15
+}
14 16
 
15 17
 /**
16 18
  * @package CKFinder
Please login to merge, or discard this patch.