Passed
Push — master ( f418e9...b58333 )
by Anthony
04:11
created
libs/ckfinder/plugins/watermark/plugin.php 3 patches
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -15,174 +15,174 @@
 block discarded – undo
15 15
 
16 16
 class Watermark
17 17
 {
18
-    function onAfterFileUpload($currentFolder, $uploadedFile, $sFilePath)
19
-    {
20
-        global $config;
21
-        $watermarkSettings = $config['Plugin_Watermark'];
18
+	function onAfterFileUpload($currentFolder, $uploadedFile, $sFilePath)
19
+	{
20
+		global $config;
21
+		$watermarkSettings = $config['Plugin_Watermark'];
22 22
 
23
-        $this->createWatermark($sFilePath, $watermarkSettings['source'], $watermarkSettings['marginRight'],
24
-            $watermarkSettings['marginBottom'], $watermarkSettings['quality'], $watermarkSettings['transparency']);
23
+		$this->createWatermark($sFilePath, $watermarkSettings['source'], $watermarkSettings['marginRight'],
24
+			$watermarkSettings['marginBottom'], $watermarkSettings['quality'], $watermarkSettings['transparency']);
25 25
 
26
-        return true;
27
-    }
26
+		return true;
27
+	}
28 28
 
29
-    function createWatermark($sourceFile, $watermarkFile, $marginLeft = 5, $marginBottom = 5, $quality = 90, $transparency = 100)
30
-    {
31
-        if (!file_exists($watermarkFile)) {
32
-            $watermarkFile = dirname(__FILE__) . "/" . $watermarkFile;
33
-        }
34
-        if (!file_exists($watermarkFile)) {
35
-            return false;
36
-        }
29
+	function createWatermark($sourceFile, $watermarkFile, $marginLeft = 5, $marginBottom = 5, $quality = 90, $transparency = 100)
30
+	{
31
+		if (!file_exists($watermarkFile)) {
32
+			$watermarkFile = dirname(__FILE__) . "/" . $watermarkFile;
33
+		}
34
+		if (!file_exists($watermarkFile)) {
35
+			return false;
36
+		}
37 37
 
38
-        $watermarkImageAttr = @getimagesize($watermarkFile);
39
-        $sourceImageAttr = @getimagesize($sourceFile);
40
-        if ($sourceImageAttr === false || $watermarkImageAttr === false) {
41
-            return false;
42
-        }
38
+		$watermarkImageAttr = @getimagesize($watermarkFile);
39
+		$sourceImageAttr = @getimagesize($sourceFile);
40
+		if ($sourceImageAttr === false || $watermarkImageAttr === false) {
41
+			return false;
42
+		}
43 43
 
44
-        switch ($watermarkImageAttr['mime'])
45
-        {
46
-            case 'image/gif':
47
-                {
48
-                    if (@imagetypes() & IMG_GIF) {
49
-                        $oWatermarkImage = @imagecreatefromgif($watermarkFile);
50
-                    } else {
51
-                        $ermsg = 'GIF images are not supported';
52
-                    }
53
-                }
54
-                break;
55
-            case 'image/jpeg':
56
-                {
57
-                    if (@imagetypes() & IMG_JPG) {
58
-                        $oWatermarkImage = @imagecreatefromjpeg($watermarkFile) ;
59
-                    } else {
60
-                        $ermsg = 'JPEG images are not supported';
61
-                    }
62
-                }
63
-                break;
64
-            case 'image/png':
65
-                {
66
-                    if (@imagetypes() & IMG_PNG) {
67
-                        $oWatermarkImage = @imagecreatefrompng($watermarkFile) ;
68
-                    } else {
69
-                        $ermsg = 'PNG images are not supported';
70
-                    }
71
-                }
72
-                break;
73
-            case 'image/wbmp':
74
-                {
75
-                    if (@imagetypes() & IMG_WBMP) {
76
-                        $oWatermarkImage = @imagecreatefromwbmp($watermarkFile);
77
-                    } else {
78
-                        $ermsg = 'WBMP images are not supported';
79
-                    }
80
-                }
81
-                break;
82
-            default:
83
-                $ermsg = $watermarkImageAttr['mime'].' images are not supported';
84
-                break;
85
-        }
44
+		switch ($watermarkImageAttr['mime'])
45
+		{
46
+			case 'image/gif':
47
+				{
48
+					if (@imagetypes() & IMG_GIF) {
49
+						$oWatermarkImage = @imagecreatefromgif($watermarkFile);
50
+					} else {
51
+						$ermsg = 'GIF images are not supported';
52
+					}
53
+				}
54
+				break;
55
+			case 'image/jpeg':
56
+				{
57
+					if (@imagetypes() & IMG_JPG) {
58
+						$oWatermarkImage = @imagecreatefromjpeg($watermarkFile) ;
59
+					} else {
60
+						$ermsg = 'JPEG images are not supported';
61
+					}
62
+				}
63
+				break;
64
+			case 'image/png':
65
+				{
66
+					if (@imagetypes() & IMG_PNG) {
67
+						$oWatermarkImage = @imagecreatefrompng($watermarkFile) ;
68
+					} else {
69
+						$ermsg = 'PNG images are not supported';
70
+					}
71
+				}
72
+				break;
73
+			case 'image/wbmp':
74
+				{
75
+					if (@imagetypes() & IMG_WBMP) {
76
+						$oWatermarkImage = @imagecreatefromwbmp($watermarkFile);
77
+					} else {
78
+						$ermsg = 'WBMP images are not supported';
79
+					}
80
+				}
81
+				break;
82
+			default:
83
+				$ermsg = $watermarkImageAttr['mime'].' images are not supported';
84
+				break;
85
+		}
86 86
 
87
-        switch ($sourceImageAttr['mime'])
88
-        {
89
-            case 'image/gif':
90
-                {
91
-                    if (@imagetypes() & IMG_GIF) {
92
-                        $oImage = @imagecreatefromgif($sourceFile);
93
-                    } else {
94
-                        $ermsg = 'GIF images are not supported';
95
-                    }
96
-                }
97
-                break;
98
-            case 'image/jpeg':
99
-                {
100
-                    if (@imagetypes() & IMG_JPG) {
101
-                        $oImage = @imagecreatefromjpeg($sourceFile) ;
102
-                    } else {
103
-                        $ermsg = 'JPEG images are not supported';
104
-                    }
105
-                }
106
-                break;
107
-            case 'image/png':
108
-                {
109
-                    if (@imagetypes() & IMG_PNG) {
110
-                        $oImage = @imagecreatefrompng($sourceFile) ;
111
-                    } else {
112
-                        $ermsg = 'PNG images are not supported';
113
-                    }
114
-                }
115
-                break;
116
-            case 'image/wbmp':
117
-                {
118
-                    if (@imagetypes() & IMG_WBMP) {
119
-                        $oImage = @imagecreatefromwbmp($sourceFile);
120
-                    } else {
121
-                        $ermsg = 'WBMP images are not supported';
122
-                    }
123
-                }
124
-                break;
125
-            default:
126
-                $ermsg = $sourceImageAttr['mime'].' images are not supported';
127
-                break;
128
-        }
87
+		switch ($sourceImageAttr['mime'])
88
+		{
89
+			case 'image/gif':
90
+				{
91
+					if (@imagetypes() & IMG_GIF) {
92
+						$oImage = @imagecreatefromgif($sourceFile);
93
+					} else {
94
+						$ermsg = 'GIF images are not supported';
95
+					}
96
+				}
97
+				break;
98
+			case 'image/jpeg':
99
+				{
100
+					if (@imagetypes() & IMG_JPG) {
101
+						$oImage = @imagecreatefromjpeg($sourceFile) ;
102
+					} else {
103
+						$ermsg = 'JPEG images are not supported';
104
+					}
105
+				}
106
+				break;
107
+			case 'image/png':
108
+				{
109
+					if (@imagetypes() & IMG_PNG) {
110
+						$oImage = @imagecreatefrompng($sourceFile) ;
111
+					} else {
112
+						$ermsg = 'PNG images are not supported';
113
+					}
114
+				}
115
+				break;
116
+			case 'image/wbmp':
117
+				{
118
+					if (@imagetypes() & IMG_WBMP) {
119
+						$oImage = @imagecreatefromwbmp($sourceFile);
120
+					} else {
121
+						$ermsg = 'WBMP images are not supported';
122
+					}
123
+				}
124
+				break;
125
+			default:
126
+				$ermsg = $sourceImageAttr['mime'].' images are not supported';
127
+				break;
128
+		}
129 129
 
130
-        if (isset($ermsg) || false === $oImage || false === $oWatermarkImage) {
131
-            return false;
132
-        }
130
+		if (isset($ermsg) || false === $oImage || false === $oWatermarkImage) {
131
+			return false;
132
+		}
133 133
 
134
-        $watermark_width = $watermarkImageAttr[0];
135
-        $watermark_height = $watermarkImageAttr[1];
136
-        $dest_x = $sourceImageAttr[0] - $watermark_width - $marginLeft;
137
-        $dest_y = $sourceImageAttr[1] - $watermark_height - $marginBottom;
134
+		$watermark_width = $watermarkImageAttr[0];
135
+		$watermark_height = $watermarkImageAttr[1];
136
+		$dest_x = $sourceImageAttr[0] - $watermark_width - $marginLeft;
137
+		$dest_y = $sourceImageAttr[1] - $watermark_height - $marginBottom;
138 138
 
139
-        if ( $sourceImageAttr['mime'] == 'image/png')
140
-        {
141
-            if(function_exists('imagesavealpha') && function_exists('imagecolorallocatealpha') )
142
-            {
143
-                 $bg = imagecolorallocatealpha($oImage, 255, 255, 255, 127); // (PHP 4 >= 4.3.2, PHP 5)
144
-                 imagefill($oImage, 0, 0 , $bg);
145
-                 imagealphablending($oImage, false);
146
-                 imagesavealpha($oImage, true);  // (PHP 4 >= 4.3.2, PHP 5)
147
-            }
148
-        }
149
-        if ($watermarkImageAttr['mime'] == 'image/png') {
150
-            imagecopy($oImage, $oWatermarkImage, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height);
151
-        }
152
-        else {
153
-            imagecopymerge($oImage, $oWatermarkImage, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $transparency);
154
-        }
139
+		if ( $sourceImageAttr['mime'] == 'image/png')
140
+		{
141
+			if(function_exists('imagesavealpha') && function_exists('imagecolorallocatealpha') )
142
+			{
143
+				 $bg = imagecolorallocatealpha($oImage, 255, 255, 255, 127); // (PHP 4 >= 4.3.2, PHP 5)
144
+				 imagefill($oImage, 0, 0 , $bg);
145
+				 imagealphablending($oImage, false);
146
+				 imagesavealpha($oImage, true);  // (PHP 4 >= 4.3.2, PHP 5)
147
+			}
148
+		}
149
+		if ($watermarkImageAttr['mime'] == 'image/png') {
150
+			imagecopy($oImage, $oWatermarkImage, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height);
151
+		}
152
+		else {
153
+			imagecopymerge($oImage, $oWatermarkImage, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $transparency);
154
+		}
155 155
 
156
-        switch ($sourceImageAttr['mime'])
157
-        {
158
-            case 'image/gif':
159
-                imagegif($oImage, $sourceFile);
160
-                break;
161
-            case 'image/jpeg':
162
-                imagejpeg($oImage, $sourceFile, $quality);
163
-                break;
164
-            case 'image/png':
165
-                imagepng($oImage, $sourceFile);
166
-                break;
167
-            case 'image/wbmp':
168
-                imagewbmp($oImage, $sourceFile);
169
-                break;
170
-        }
156
+		switch ($sourceImageAttr['mime'])
157
+		{
158
+			case 'image/gif':
159
+				imagegif($oImage, $sourceFile);
160
+				break;
161
+			case 'image/jpeg':
162
+				imagejpeg($oImage, $sourceFile, $quality);
163
+				break;
164
+			case 'image/png':
165
+				imagepng($oImage, $sourceFile);
166
+				break;
167
+			case 'image/wbmp':
168
+				imagewbmp($oImage, $sourceFile);
169
+				break;
170
+		}
171 171
 
172
-        imageDestroy($oImage);
173
-        imageDestroy($oWatermarkImage);
174
-    }
172
+		imageDestroy($oImage);
173
+		imageDestroy($oWatermarkImage);
174
+	}
175 175
 }
176 176
 
177 177
 $watermark = new Watermark();
178 178
 $config['Hooks']['AfterFileUpload'][] = array($watermark, 'onAfterFileUpload');
179 179
 if (empty($config['Plugin_Watermark']))
180 180
 {
181
-    $config['Plugin_Watermark'] = array(
182
-        "source" => "logo.gif",
183
-        "marginRight" => 5,
184
-        "marginBottom" => 5,
185
-        "quality" => 90,
186
-        "transparency" => 80,
187
-    );
181
+	$config['Plugin_Watermark'] = array(
182
+		"source" => "logo.gif",
183
+		"marginRight" => 5,
184
+		"marginBottom" => 5,
185
+		"quality" => 90,
186
+		"transparency" => 80,
187
+	);
188 188
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     function createWatermark($sourceFile, $watermarkFile, $marginLeft = 5, $marginBottom = 5, $quality = 90, $transparency = 100)
30 30
     {
31 31
         if (!file_exists($watermarkFile)) {
32
-            $watermarkFile = dirname(__FILE__) . "/" . $watermarkFile;
32
+            $watermarkFile = dirname(__FILE__)."/".$watermarkFile;
33 33
         }
34 34
         if (!file_exists($watermarkFile)) {
35 35
             return false;
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
             case 'image/jpeg':
56 56
                 {
57 57
                     if (@imagetypes() & IMG_JPG) {
58
-                        $oWatermarkImage = @imagecreatefromjpeg($watermarkFile) ;
58
+                        $oWatermarkImage = @imagecreatefromjpeg($watermarkFile);
59 59
                     } else {
60 60
                         $ermsg = 'JPEG images are not supported';
61 61
                     }
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             case 'image/png':
65 65
                 {
66 66
                     if (@imagetypes() & IMG_PNG) {
67
-                        $oWatermarkImage = @imagecreatefrompng($watermarkFile) ;
67
+                        $oWatermarkImage = @imagecreatefrompng($watermarkFile);
68 68
                     } else {
69 69
                         $ermsg = 'PNG images are not supported';
70 70
                     }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             case 'image/jpeg':
99 99
                 {
100 100
                     if (@imagetypes() & IMG_JPG) {
101
-                        $oImage = @imagecreatefromjpeg($sourceFile) ;
101
+                        $oImage = @imagecreatefromjpeg($sourceFile);
102 102
                     } else {
103 103
                         $ermsg = 'JPEG images are not supported';
104 104
                     }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
             case 'image/png':
108 108
                 {
109 109
                     if (@imagetypes() & IMG_PNG) {
110
-                        $oImage = @imagecreatefrompng($sourceFile) ;
110
+                        $oImage = @imagecreatefrompng($sourceFile);
111 111
                     } else {
112 112
                         $ermsg = 'PNG images are not supported';
113 113
                     }
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
         $dest_x = $sourceImageAttr[0] - $watermark_width - $marginLeft;
137 137
         $dest_y = $sourceImageAttr[1] - $watermark_height - $marginBottom;
138 138
 
139
-        if ( $sourceImageAttr['mime'] == 'image/png')
139
+        if ($sourceImageAttr['mime'] == 'image/png')
140 140
         {
141
-            if(function_exists('imagesavealpha') && function_exists('imagecolorallocatealpha') )
141
+            if (function_exists('imagesavealpha') && function_exists('imagecolorallocatealpha'))
142 142
             {
143 143
                  $bg = imagecolorallocatealpha($oImage, 255, 255, 255, 127); // (PHP 4 >= 4.3.2, PHP 5)
144
-                 imagefill($oImage, 0, 0 , $bg);
144
+                 imagefill($oImage, 0, 0, $bg);
145 145
                  imagealphablending($oImage, false);
146
-                 imagesavealpha($oImage, true);  // (PHP 4 >= 4.3.2, PHP 5)
146
+                 imagesavealpha($oImage, true); // (PHP 4 >= 4.3.2, PHP 5)
147 147
             }
148 148
         }
149 149
         if ($watermarkImageAttr['mime'] == 'image/png') {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -148,8 +148,7 @@
 block discarded – undo
148 148
         }
149 149
         if ($watermarkImageAttr['mime'] == 'image/png') {
150 150
             imagecopy($oImage, $oWatermarkImage, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height);
151
-        }
152
-        else {
151
+        } else {
153 152
             imagecopymerge($oImage, $oWatermarkImage, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $transparency);
154 153
         }
155 154
 
Please login to merge, or discard this patch.
libs/ckfinder/plugins/imageresize/plugin.php 3 patches
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -21,221 +21,221 @@
 block discarded – undo
21 21
 
22 22
 class CKFinder_Connector_CommandHandler_ImageResize extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase
23 23
 {
24
-    /**
25
-     * @access private
26
-     */
27
-    function getConfig()
28
-    {
29
-        $config = array();
30
-        if (isset($GLOBALS['config']['plugin_imageresize'])) {
31
-            $config = $GLOBALS['config']['plugin_imageresize'];
32
-        }
33
-        if (!isset($config['smallThumb'])) {
34
-            $config['smallThumb'] = "90x90";
35
-        }
36
-        if (!isset($config['mediumThumb'])) {
37
-            $config['mediumThumb'] = "120x120";
38
-        }
39
-        if (!isset($config['largeThumb'])) {
40
-            $config['largeThumb'] = "180x180";
41
-        }
42
-        return $config;
43
-    }
44
-
45
-    /**
46
-     * handle request and build XML
47
-     * @access protected
48
-     *
49
-     */
50
-    function buildXml()
51
-    {
52
-        if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
53
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
54
-        }
55
-
56
-        $this->checkConnector();
57
-        $this->checkRequest();
58
-
59
-        //resizing to 1x1 is almost equal to deleting a file, that's why FILE_DELETE permissions are required
60
-        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_DELETE) || !$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) {
61
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
62
-        }
63
-
64
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
65
-        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
66
-
67
-        if (!isset($_POST["fileName"])) {
68
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
69
-        }
70
-
71
-        $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["fileName"]);
72
-
73
-        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
74
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
75
-        }
76
-
77
-        if (!$resourceTypeInfo->checkExtension($fileName, false)) {
78
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
79
-        }
80
-
81
-        $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
82
-
83
-        if (!file_exists($filePath) || !is_file($filePath)) {
84
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
85
-        }
86
-
87
-        $newWidth = trim($_POST['width']);
88
-        $newHeight = trim($_POST['height']);
89
-        $quality = 80;
90
-        $resizeOriginal = !empty($_POST['width']) && !empty($_POST['height']);
91
-
92
-        if ($resizeOriginal) {
93
-            if (!preg_match("/^\d+$/", $newWidth) || !preg_match("/^\d+$/", $newHeight) || !preg_match("/^\d+$/", $newWidth)) {
94
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
95
-            }
96
-            if (!isset($_POST["newFileName"])) {
97
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
98
-            }
99
-            $newFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["newFileName"]);
100
-            if (!$resourceTypeInfo->checkExtension($newFileName)) {
101
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
102
-            }
103
-            if (!CKFinder_Connector_Utils_FileSystem::checkFileName($newFileName) || $resourceTypeInfo->checkIsHiddenFile($newFileName)) {
104
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
105
-            }
106
-            $newFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $newFileName);
107
-            if (!is_writable(dirname($newFilePath))) {
108
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
109
-            }
110
-            if ($_POST['overwrite'] != "1" && file_exists($newFilePath)) {
111
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST);
112
-            }
113
-            $_imagesConfig = $_config->getImagesConfig();
114
-            $maxWidth = $_imagesConfig->getMaxWidth();
115
-            $maxHeight = $_imagesConfig->getMaxHeight();
116
-            // Shouldn't happen as the JavaScript validation should not allow this.
117
-            if ( ( $maxWidth > 0 && $newWidth > $maxWidth ) || ( $maxHeight > 0 && $newHeight > $maxHeight ) ) {
118
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
119
-            }
120
-        }
121
-
122
-        require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/Thumbnail.php";
123
-
124
-        if ($resizeOriginal) {
125
-            $result = CKFinder_Connector_CommandHandler_Thumbnail::createThumb($filePath, $newFilePath, $newWidth, $newHeight, $quality, false) ;
126
-            if (!$result) {
127
-                $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
128
-            }
129
-        }
130
-
131
-        $config = $this->getConfig();
132
-        $nameWithoutExt = preg_replace("/^(.+)\_\d+x\d+$/", "$1", CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($fileName));
133
-        $extension = CKFinder_Connector_Utils_FileSystem::getExtension($fileName);
134
-        foreach (array('small', 'medium', 'large') as $size) {
135
-            if (!empty($_POST[$size]) && $_POST[$size] == '1') {
136
-                $thumbName = $nameWithoutExt."_".$size.".".$extension;
137
-                $newFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $thumbName);
138
-                if (!empty($config[$size.'Thumb'])) {
139
-                    if (preg_match("/^(\d+)x(\d+)$/", $config[$size.'Thumb'], $matches)) {
140
-                        CKFinder_Connector_CommandHandler_Thumbnail::createThumb($filePath, $newFilePath, $matches[1], $matches[2], $quality, true) ;
141
-                    }
142
-                }
143
-            }
144
-        }
145
-
146
-    }
147
-
148
-    /**
149
-     * @access public
150
-     */
151
-    function onInitCommand( &$connectorNode )
152
-    {
153
-        // "@" protects against E_STRICT (Only variables should be assigned by reference)
154
-        @$pluginsInfo = &$connectorNode->getChild("PluginsInfo");
155
-        $imageresize = new CKFinder_Connector_Utils_XmlNode("imageresize");
156
-        $pluginsInfo->addChild($imageresize);
157
-        $config = $this->getConfig();
158
-        foreach (array('small', 'medium', 'large') as $size) {
159
-            if (!empty($config[$size.'Thumb'])) {
160
-                $imageresize->addAttribute($size.'Thumb', $config[$size.'Thumb']);
161
-            }
162
-        }
163
-        return true ;
164
-    }
165
-
166
-    /**
167
-     * @access public
168
-     */
169
-    function onBeforeExecuteCommand( &$command )
170
-    {
171
-        if ( $command == 'ImageResize' )
172
-        {
173
-            $this->sendResponse();
174
-            return false;
175
-        }
176
-
177
-        return true ;
178
-    }
24
+	/**
25
+	 * @access private
26
+	 */
27
+	function getConfig()
28
+	{
29
+		$config = array();
30
+		if (isset($GLOBALS['config']['plugin_imageresize'])) {
31
+			$config = $GLOBALS['config']['plugin_imageresize'];
32
+		}
33
+		if (!isset($config['smallThumb'])) {
34
+			$config['smallThumb'] = "90x90";
35
+		}
36
+		if (!isset($config['mediumThumb'])) {
37
+			$config['mediumThumb'] = "120x120";
38
+		}
39
+		if (!isset($config['largeThumb'])) {
40
+			$config['largeThumb'] = "180x180";
41
+		}
42
+		return $config;
43
+	}
44
+
45
+	/**
46
+	 * handle request and build XML
47
+	 * @access protected
48
+	 *
49
+	 */
50
+	function buildXml()
51
+	{
52
+		if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
53
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
54
+		}
55
+
56
+		$this->checkConnector();
57
+		$this->checkRequest();
58
+
59
+		//resizing to 1x1 is almost equal to deleting a file, that's why FILE_DELETE permissions are required
60
+		if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_DELETE) || !$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_UPLOAD)) {
61
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
62
+		}
63
+
64
+		$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
65
+		$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
66
+
67
+		if (!isset($_POST["fileName"])) {
68
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
69
+		}
70
+
71
+		$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["fileName"]);
72
+
73
+		if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
74
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
75
+		}
76
+
77
+		if (!$resourceTypeInfo->checkExtension($fileName, false)) {
78
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
79
+		}
80
+
81
+		$filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
82
+
83
+		if (!file_exists($filePath) || !is_file($filePath)) {
84
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
85
+		}
86
+
87
+		$newWidth = trim($_POST['width']);
88
+		$newHeight = trim($_POST['height']);
89
+		$quality = 80;
90
+		$resizeOriginal = !empty($_POST['width']) && !empty($_POST['height']);
91
+
92
+		if ($resizeOriginal) {
93
+			if (!preg_match("/^\d+$/", $newWidth) || !preg_match("/^\d+$/", $newHeight) || !preg_match("/^\d+$/", $newWidth)) {
94
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
95
+			}
96
+			if (!isset($_POST["newFileName"])) {
97
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
98
+			}
99
+			$newFileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["newFileName"]);
100
+			if (!$resourceTypeInfo->checkExtension($newFileName)) {
101
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
102
+			}
103
+			if (!CKFinder_Connector_Utils_FileSystem::checkFileName($newFileName) || $resourceTypeInfo->checkIsHiddenFile($newFileName)) {
104
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
105
+			}
106
+			$newFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $newFileName);
107
+			if (!is_writable(dirname($newFilePath))) {
108
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
109
+			}
110
+			if ($_POST['overwrite'] != "1" && file_exists($newFilePath)) {
111
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST);
112
+			}
113
+			$_imagesConfig = $_config->getImagesConfig();
114
+			$maxWidth = $_imagesConfig->getMaxWidth();
115
+			$maxHeight = $_imagesConfig->getMaxHeight();
116
+			// Shouldn't happen as the JavaScript validation should not allow this.
117
+			if ( ( $maxWidth > 0 && $newWidth > $maxWidth ) || ( $maxHeight > 0 && $newHeight > $maxHeight ) ) {
118
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
119
+			}
120
+		}
121
+
122
+		require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/Thumbnail.php";
123
+
124
+		if ($resizeOriginal) {
125
+			$result = CKFinder_Connector_CommandHandler_Thumbnail::createThumb($filePath, $newFilePath, $newWidth, $newHeight, $quality, false) ;
126
+			if (!$result) {
127
+				$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
128
+			}
129
+		}
130
+
131
+		$config = $this->getConfig();
132
+		$nameWithoutExt = preg_replace("/^(.+)\_\d+x\d+$/", "$1", CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($fileName));
133
+		$extension = CKFinder_Connector_Utils_FileSystem::getExtension($fileName);
134
+		foreach (array('small', 'medium', 'large') as $size) {
135
+			if (!empty($_POST[$size]) && $_POST[$size] == '1') {
136
+				$thumbName = $nameWithoutExt."_".$size.".".$extension;
137
+				$newFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $thumbName);
138
+				if (!empty($config[$size.'Thumb'])) {
139
+					if (preg_match("/^(\d+)x(\d+)$/", $config[$size.'Thumb'], $matches)) {
140
+						CKFinder_Connector_CommandHandler_Thumbnail::createThumb($filePath, $newFilePath, $matches[1], $matches[2], $quality, true) ;
141
+					}
142
+				}
143
+			}
144
+		}
145
+
146
+	}
147
+
148
+	/**
149
+	 * @access public
150
+	 */
151
+	function onInitCommand( &$connectorNode )
152
+	{
153
+		// "@" protects against E_STRICT (Only variables should be assigned by reference)
154
+		@$pluginsInfo = &$connectorNode->getChild("PluginsInfo");
155
+		$imageresize = new CKFinder_Connector_Utils_XmlNode("imageresize");
156
+		$pluginsInfo->addChild($imageresize);
157
+		$config = $this->getConfig();
158
+		foreach (array('small', 'medium', 'large') as $size) {
159
+			if (!empty($config[$size.'Thumb'])) {
160
+				$imageresize->addAttribute($size.'Thumb', $config[$size.'Thumb']);
161
+			}
162
+		}
163
+		return true ;
164
+	}
165
+
166
+	/**
167
+	 * @access public
168
+	 */
169
+	function onBeforeExecuteCommand( &$command )
170
+	{
171
+		if ( $command == 'ImageResize' )
172
+		{
173
+			$this->sendResponse();
174
+			return false;
175
+		}
176
+
177
+		return true ;
178
+	}
179 179
 }
180 180
 
181 181
 class CKFinder_Connector_CommandHandler_ImageResizeInfo extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase
182 182
 {
183
-    /**
184
-     * handle request and build XML
185
-     * @access protected
186
-     *
187
-     */
188
-    function buildXml()
189
-    {
190
-        $this->checkConnector();
191
-        $this->checkRequest();
192
-
193
-        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) {
194
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
195
-        }
196
-
197
-        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
198
-
199
-        if (!isset($_GET["fileName"])) {
200
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
201
-        }
202
-
203
-        $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["fileName"]);
204
-
205
-        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
206
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
207
-        }
208
-
209
-        if (!$resourceTypeInfo->checkExtension($fileName, false)) {
210
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
211
-        }
212
-
213
-        $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
214
-
215
-        if (!file_exists($filePath) || !is_file($filePath)) {
216
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
217
-        }
218
-
219
-        list($width, $height) = getimagesize($filePath);
220
-        $oNode = new Ckfinder_Connector_Utils_XmlNode("ImageInfo");
221
-        $oNode->addAttribute("width", $width);
222
-        $oNode->addAttribute("height", $height);
223
-        $this->_connectorNode->addChild($oNode);
224
-    }
225
-
226
-    /**
227
-     * @access public
228
-     */
229
-    function onBeforeExecuteCommand( &$command )
230
-    {
231
-        if ( $command == 'ImageResizeInfo' )
232
-        {
233
-            $this->sendResponse();
234
-            return false;
235
-        }
236
-
237
-        return true ;
238
-    }
183
+	/**
184
+	 * handle request and build XML
185
+	 * @access protected
186
+	 *
187
+	 */
188
+	function buildXml()
189
+	{
190
+		$this->checkConnector();
191
+		$this->checkRequest();
192
+
193
+		if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) {
194
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
195
+		}
196
+
197
+		$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
198
+
199
+		if (!isset($_GET["fileName"])) {
200
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
201
+		}
202
+
203
+		$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["fileName"]);
204
+
205
+		if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
206
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
207
+		}
208
+
209
+		if (!$resourceTypeInfo->checkExtension($fileName, false)) {
210
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
211
+		}
212
+
213
+		$filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
214
+
215
+		if (!file_exists($filePath) || !is_file($filePath)) {
216
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
217
+		}
218
+
219
+		list($width, $height) = getimagesize($filePath);
220
+		$oNode = new Ckfinder_Connector_Utils_XmlNode("ImageInfo");
221
+		$oNode->addAttribute("width", $width);
222
+		$oNode->addAttribute("height", $height);
223
+		$this->_connectorNode->addChild($oNode);
224
+	}
225
+
226
+	/**
227
+	 * @access public
228
+	 */
229
+	function onBeforeExecuteCommand( &$command )
230
+	{
231
+		if ( $command == 'ImageResizeInfo' )
232
+		{
233
+			$this->sendResponse();
234
+			return false;
235
+		}
236
+
237
+		return true ;
238
+	}
239 239
 }
240 240
 
241 241
 if (function_exists('imagecreate')) {
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * Include base XML command handler
19 19
  */
20
-require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
20
+require_once CKFINDER_CONNECTOR_LIB_DIR."/CommandHandler/XmlCommandHandlerBase.php";
21 21
 
22 22
 class CKFinder_Connector_CommandHandler_ImageResize extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase
23 23
 {
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
             $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
62 62
         }
63 63
 
64
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
64
+        $_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config");
65 65
         $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
66 66
 
67 67
         if (!isset($_POST["fileName"])) {
@@ -114,15 +114,15 @@  discard block
 block discarded – undo
114 114
             $maxWidth = $_imagesConfig->getMaxWidth();
115 115
             $maxHeight = $_imagesConfig->getMaxHeight();
116 116
             // Shouldn't happen as the JavaScript validation should not allow this.
117
-            if ( ( $maxWidth > 0 && $newWidth > $maxWidth ) || ( $maxHeight > 0 && $newHeight > $maxHeight ) ) {
117
+            if (($maxWidth > 0 && $newWidth > $maxWidth) || ($maxHeight > 0 && $newHeight > $maxHeight)) {
118 118
                 $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
119 119
             }
120 120
         }
121 121
 
122
-        require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/Thumbnail.php";
122
+        require_once CKFINDER_CONNECTOR_LIB_DIR."/CommandHandler/Thumbnail.php";
123 123
 
124 124
         if ($resizeOriginal) {
125
-            $result = CKFinder_Connector_CommandHandler_Thumbnail::createThumb($filePath, $newFilePath, $newWidth, $newHeight, $quality, false) ;
125
+            $result = CKFinder_Connector_CommandHandler_Thumbnail::createThumb($filePath, $newFilePath, $newWidth, $newHeight, $quality, false);
126 126
             if (!$result) {
127 127
                 $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
128 128
             }
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
                 $newFilePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $thumbName);
138 138
                 if (!empty($config[$size.'Thumb'])) {
139 139
                     if (preg_match("/^(\d+)x(\d+)$/", $config[$size.'Thumb'], $matches)) {
140
-                        CKFinder_Connector_CommandHandler_Thumbnail::createThumb($filePath, $newFilePath, $matches[1], $matches[2], $quality, true) ;
140
+                        CKFinder_Connector_CommandHandler_Thumbnail::createThumb($filePath, $newFilePath, $matches[1], $matches[2], $quality, true);
141 141
                     }
142 142
                 }
143 143
             }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
     /**
149 149
      * @access public
150 150
      */
151
-    function onInitCommand( &$connectorNode )
151
+    function onInitCommand(&$connectorNode)
152 152
     {
153 153
         // "@" protects against E_STRICT (Only variables should be assigned by reference)
154 154
         @$pluginsInfo = &$connectorNode->getChild("PluginsInfo");
@@ -160,21 +160,21 @@  discard block
 block discarded – undo
160 160
                 $imageresize->addAttribute($size.'Thumb', $config[$size.'Thumb']);
161 161
             }
162 162
         }
163
-        return true ;
163
+        return true;
164 164
     }
165 165
 
166 166
     /**
167 167
      * @access public
168 168
      */
169
-    function onBeforeExecuteCommand( &$command )
169
+    function onBeforeExecuteCommand(&$command)
170 170
     {
171
-        if ( $command == 'ImageResize' )
171
+        if ($command == 'ImageResize')
172 172
         {
173 173
             $this->sendResponse();
174 174
             return false;
175 175
         }
176 176
 
177
-        return true ;
177
+        return true;
178 178
     }
179 179
 }
180 180
 
@@ -226,15 +226,15 @@  discard block
 block discarded – undo
226 226
     /**
227 227
      * @access public
228 228
      */
229
-    function onBeforeExecuteCommand( &$command )
229
+    function onBeforeExecuteCommand(&$command)
230 230
     {
231
-        if ( $command == 'ImageResizeInfo' )
231
+        if ($command == 'ImageResizeInfo')
232 232
         {
233 233
             $this->sendResponse();
234 234
             return false;
235 235
         }
236 236
 
237
-        return true ;
237
+        return true;
238 238
     }
239 239
 }
240 240
 
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/plugins/fileeditor/plugin.php 3 patches
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -21,79 +21,79 @@
 block discarded – undo
21 21
 
22 22
 class CKFinder_Connector_CommandHandler_FileEditor extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase
23 23
 {
24
-    /**
25
-     * handle request and build XML
26
-     * @access protected
27
-     */
28
-    function buildXml()
29
-    {
30
-        if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
31
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
32
-        }
24
+	/**
25
+	 * handle request and build XML
26
+	 * @access protected
27
+	 */
28
+	function buildXml()
29
+	{
30
+		if (empty($_POST['CKFinderCommand']) || $_POST['CKFinderCommand'] != 'true') {
31
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
32
+		}
33 33
 
34
-        $this->checkConnector();
35
-        $this->checkRequest();
34
+		$this->checkConnector();
35
+		$this->checkRequest();
36 36
 
37
-        // Saving empty file is equal to deleting a file, that's why FILE_DELETE permissions are required
38
-        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_DELETE)) {
39
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
40
-        }
37
+		// Saving empty file is equal to deleting a file, that's why FILE_DELETE permissions are required
38
+		if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_DELETE)) {
39
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
40
+		}
41 41
 
42
-        if (!isset($_POST["fileName"])) {
43
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
44
-        }
45
-        if (!isset($_POST["content"])) {
46
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
47
-        }
42
+		if (!isset($_POST["fileName"])) {
43
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
44
+		}
45
+		if (!isset($_POST["content"])) {
46
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
47
+		}
48 48
 
49
-        $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["fileName"]);
50
-        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
49
+		$fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_POST["fileName"]);
50
+		$resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();
51 51
 
52
-        if (!$resourceTypeInfo->checkExtension($fileName)) {
53
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
54
-        }
52
+		if (!$resourceTypeInfo->checkExtension($fileName)) {
53
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION);
54
+		}
55 55
 
56
-        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
57
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
58
-        }
56
+		if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
57
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
58
+		}
59 59
 
60
-        $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
60
+		$filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);
61 61
 
62
-        if (!file_exists($filePath) || !is_file($filePath)) {
63
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
64
-        }
62
+		if (!file_exists($filePath) || !is_file($filePath)) {
63
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
64
+		}
65 65
 
66
-        if (!is_writable(dirname($filePath))) {
67
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
68
-        }
66
+		if (!is_writable(dirname($filePath))) {
67
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
68
+		}
69 69
 
70
-        $fp = @fopen($filePath, 'wb');
71
-        if ($fp === false || !flock($fp, LOCK_EX)) {
72
-            $result = false;
73
-        }
74
-        else {
75
-            $result = fwrite($fp, $_POST["content"]);
76
-            flock($fp, LOCK_UN);
77
-            fclose($fp);
78
-        }
79
-        if ($result === false) {
80
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
81
-        }
82
-    }
70
+		$fp = @fopen($filePath, 'wb');
71
+		if ($fp === false || !flock($fp, LOCK_EX)) {
72
+			$result = false;
73
+		}
74
+		else {
75
+			$result = fwrite($fp, $_POST["content"]);
76
+			flock($fp, LOCK_UN);
77
+			fclose($fp);
78
+		}
79
+		if ($result === false) {
80
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED);
81
+		}
82
+	}
83 83
 
84
-    /**
85
-     * @access public
86
-     */
87
-    function onBeforeExecuteCommand( &$command )
88
-    {
89
-        if ( $command == 'SaveFile' )
90
-        {
91
-            $this->sendResponse();
92
-            return false;
93
-        }
84
+	/**
85
+	 * @access public
86
+	 */
87
+	function onBeforeExecuteCommand( &$command )
88
+	{
89
+		if ( $command == 'SaveFile' )
90
+		{
91
+			$this->sendResponse();
92
+			return false;
93
+		}
94 94
 
95
-        return true ;
96
-    }
95
+		return true ;
96
+	}
97 97
 }
98 98
 
99 99
 $CommandHandler_FileEditor = new CKFinder_Connector_CommandHandler_FileEditor();
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * Include base XML command handler
19 19
  */
20
-require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/XmlCommandHandlerBase.php";
20
+require_once CKFINDER_CONNECTOR_LIB_DIR."/CommandHandler/XmlCommandHandlerBase.php";
21 21
 
22 22
 class CKFinder_Connector_CommandHandler_FileEditor extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase
23 23
 {
@@ -84,15 +84,15 @@  discard block
 block discarded – undo
84 84
     /**
85 85
      * @access public
86 86
      */
87
-    function onBeforeExecuteCommand( &$command )
87
+    function onBeforeExecuteCommand(&$command)
88 88
     {
89
-        if ( $command == 'SaveFile' )
89
+        if ($command == 'SaveFile')
90 90
         {
91 91
             $this->sendResponse();
92 92
             return false;
93 93
         }
94 94
 
95
-        return true ;
95
+        return true;
96 96
     }
97 97
 }
98 98
 
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
@@ -66,8 +68,7 @@  discard block
 block discarded – undo
66 68
 
67 69
             $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKEditorFuncNum']);
68 70
             echo "window.parent.CKEDITOR.tools.callFunction($funcNum, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" .str_replace("'", "\\'", $errorMessage). "');";
69
-        }
70
-        else {
71
+        } else {
71 72
             if (!$uploaded) {
72 73
                 echo "window.parent.OnUploadCompleted(" . $number . ", '', '', '') ;";
73 74
             } else {
Please login to merge, or discard this patch.
libs/ckfinder/ckfinder.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * this file is part of the Source Code of CKFinder.
12 12
  */
13 13
 
14
-if ( version_compare( phpversion(), '5', '<' ) )
15
-	require_once 'core/ckfinder_php4.php' ;
14
+if (version_compare(phpversion(), '5', '<'))
15
+	require_once 'core/ckfinder_php4.php';
16 16
 else
17
-	require_once 'core/ckfinder_php5.php' ;
17
+	require_once 'core/ckfinder_php5.php';
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,8 @@
 block discarded – undo
11 11
  * this file is part of the Source Code of CKFinder.
12 12
  */
13 13
 
14
-if ( version_compare( phpversion(), '5', '<' ) )
14
+if ( version_compare( phpversion(), '5', '<' ) ) {
15 15
 	require_once 'core/ckfinder_php4.php' ;
16
-else
16
+} else {
17 17
 	require_once 'core/ckfinder_php5.php' ;
18
+}
Please login to merge, or discard this patch.
libs/ckfinder/config.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -21,16 +21,16 @@  discard block
 block discarded – undo
21 21
  */
22 22
 function CheckAuthentication()
23 23
 {
24
-    // WARNING : DO NOT simply return "true". By doing so, you are allowing
25
-    // "anyone" to upload and list the files in your server. You must implement
26
-    // some kind of session validation here. Even something very simple as...
24
+	// WARNING : DO NOT simply return "true". By doing so, you are allowing
25
+	// "anyone" to upload and list the files in your server. You must implement
26
+	// some kind of session validation here. Even something very simple as...
27 27
 
28
-        return true;
28
+		return true;
29 29
 
30 30
 
31
-    // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the
32
-    // user logs in your system. To be able to use session variables don't
33
-    // forget to add session_start() at the top of this file.
31
+	// ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the
32
+	// user logs in your system. To be able to use session variables don't
33
+	// forget to add session_start() at the top of this file.
34 34
 
35 35
     
36 36
 }
@@ -98,23 +98,23 @@  discard block
 block discarded – undo
98 98
 directory, no matter the resource type.
99 99
 */
100 100
 $config['Thumbnails'] = Array(
101
-        'url' => $baseUrl . '_thumbs',
102
-        'directory' => $baseDir . '_thumbs',
103
-        'enabled' => true,
104
-        'directAccess' => false,
105
-        'maxWidth' => 100,
106
-        'maxHeight' => 100,
107
-        'bmpSupported' => false,
108
-        'quality' => 80);
101
+		'url' => $baseUrl . '_thumbs',
102
+		'directory' => $baseDir . '_thumbs',
103
+		'enabled' => true,
104
+		'directAccess' => false,
105
+		'maxWidth' => 100,
106
+		'maxHeight' => 100,
107
+		'bmpSupported' => false,
108
+		'quality' => 80);
109 109
 
110 110
 /*
111 111
 Set the maximum size of uploaded images. If an uploaded image is larger, it
112 112
 gets scaled down proportionally. Set to 0 to disable this feature.
113 113
 */
114 114
 $config['Images'] = Array(
115
-        'maxWidth' => 700,
116
-        'maxHeight' => 1200,
117
-        'quality' => 80);
115
+		'maxWidth' => 700,
116
+		'maxHeight' => 1200,
117
+		'quality' => 80);
118 118
 
119 119
 /*
120 120
 RoleSessionVar : the session variable name that CKFinder must use to retrieve
@@ -140,19 +140,19 @@  discard block
 block discarded – undo
140 140
 */
141 141
 
142 142
 $config['AccessControl'][] = Array(
143
-        'role' => '*',
144
-        'resourceType' => '*',
145
-        'folder' => '/',
143
+		'role' => '*',
144
+		'resourceType' => '*',
145
+		'folder' => '/',
146 146
 
147
-        'folderView' => true,
148
-        'folderCreate' => true,
149
-        'folderRename' => true,
150
-        'folderDelete' => true,
147
+		'folderView' => true,
148
+		'folderCreate' => true,
149
+		'folderRename' => true,
150
+		'folderDelete' => true,
151 151
 
152
-        'fileView' => true,
153
-        'fileUpload' => true,
154
-        'fileRename' => true,
155
-        'fileDelete' => true);
152
+		'fileView' => true,
153
+		'fileUpload' => true,
154
+		'fileRename' => true,
155
+		'fileDelete' => true);
156 156
 
157 157
 /*
158 158
 For example, if you want to restrict the upload, rename or delete of files in
@@ -195,36 +195,36 @@  discard block
 block discarded – undo
195 195
 $config['DefaultResourceTypes'] = '';
196 196
 
197 197
 $config['ResourceType'][] = Array(
198
-        'name' => 'Files',              // Single quotes not allowed
199
-        'url' => $baseUrl . '/file/',
200
-        'directory' => $baseDir .  '/file/',
201
-        'maxSize' => 0,
202
-        'allowedExtensions' => '7z,aiff,asf,avi,bmp,csv,doc,docx,fla,flv,gif,gz,gzip,jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf,png,ppt,pptx,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,swf,sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,xlsx,zip,ai,psd',
203
-        'deniedExtensions' => '');
198
+		'name' => 'Files',              // Single quotes not allowed
199
+		'url' => $baseUrl . '/file/',
200
+		'directory' => $baseDir .  '/file/',
201
+		'maxSize' => 0,
202
+		'allowedExtensions' => '7z,aiff,asf,avi,bmp,csv,doc,docx,fla,flv,gif,gz,gzip,jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf,png,ppt,pptx,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,swf,sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,xlsx,zip,ai,psd',
203
+		'deniedExtensions' => '');
204 204
 
205 205
 $config['ResourceType'][] = Array(
206
-        'name' => 'Images',
207
-        'url' => $baseUrl .  '/image/',
208
-        'directory' => $baseDir .  '/image/',
209
-        'maxSize' => "16M",
210
-        'allowedExtensions' => 'bmp,gif,jpeg,jpg,png,',
211
-        'deniedExtensions' => '');
206
+		'name' => 'Images',
207
+		'url' => $baseUrl .  '/image/',
208
+		'directory' => $baseDir .  '/image/',
209
+		'maxSize' => "16M",
210
+		'allowedExtensions' => 'bmp,gif,jpeg,jpg,png,',
211
+		'deniedExtensions' => '');
212 212
 
213 213
 $config['ResourceType'][] = Array(
214
-        'name' => 'Flash',
215
-        'url' => $baseUrl .  '/flash/',
216
-        'directory' => $baseDir .  '/flash/',
217
-        'maxSize' => 0,
218
-        'allowedExtensions' => 'swf,flv',
219
-        'deniedExtensions' => '');
214
+		'name' => 'Flash',
215
+		'url' => $baseUrl .  '/flash/',
216
+		'directory' => $baseDir .  '/flash/',
217
+		'maxSize' => 0,
218
+		'allowedExtensions' => 'swf,flv',
219
+		'deniedExtensions' => '');
220 220
 
221 221
 $config['ResourceType'][] = Array(
222
-        'name' => 'Media',
223
-        'url' => $baseUrl .  '/media/',
224
-        'directory' => $baseDir .  '/media/',
225
-        'maxSize' => 0,
226
-        'allowedExtensions' => 'mp3,mp4,swf,flv,avi',
227
-        'deniedExtensions' => '');
222
+		'name' => 'Media',
223
+		'url' => $baseUrl .  '/media/',
224
+		'directory' => $baseDir .  '/media/',
225
+		'maxSize' => 0,
226
+		'allowedExtensions' => 'mp3,mp4,swf,flv,avi',
227
+		'deniedExtensions' => '');
228 228
 
229 229
 /*
230 230
  Due to security issues with Apache modules, it is recommended to leave the
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 directory, no matter the resource type.
99 99
 */
100 100
 $config['Thumbnails'] = Array(
101
-        'url' => $baseUrl . '_thumbs',
102
-        'directory' => $baseDir . '_thumbs',
101
+        'url' => $baseUrl.'_thumbs',
102
+        'directory' => $baseDir.'_thumbs',
103 103
         'enabled' => true,
104 104
         'directAccess' => false,
105 105
         'maxWidth' => 100,
@@ -195,33 +195,33 @@  discard block
 block discarded – undo
195 195
 $config['DefaultResourceTypes'] = '';
196 196
 
197 197
 $config['ResourceType'][] = Array(
198
-        'name' => 'Files',              // Single quotes not allowed
199
-        'url' => $baseUrl . '/file/',
200
-        'directory' => $baseDir .  '/file/',
198
+        'name' => 'Files', // Single quotes not allowed
199
+        'url' => $baseUrl.'/file/',
200
+        'directory' => $baseDir.'/file/',
201 201
         'maxSize' => 0,
202 202
         'allowedExtensions' => '7z,aiff,asf,avi,bmp,csv,doc,docx,fla,flv,gif,gz,gzip,jpeg,jpg,mid,mov,mp3,mp4,mpc,mpeg,mpg,ods,odt,pdf,png,ppt,pptx,pxd,qt,ram,rar,rm,rmi,rmvb,rtf,sdc,sitd,swf,sxc,sxw,tar,tgz,tif,tiff,txt,vsd,wav,wma,wmv,xls,xlsx,zip,ai,psd',
203 203
         'deniedExtensions' => '');
204 204
 
205 205
 $config['ResourceType'][] = Array(
206 206
         'name' => 'Images',
207
-        'url' => $baseUrl .  '/image/',
208
-        'directory' => $baseDir .  '/image/',
207
+        'url' => $baseUrl.'/image/',
208
+        'directory' => $baseDir.'/image/',
209 209
         'maxSize' => "16M",
210 210
         'allowedExtensions' => 'bmp,gif,jpeg,jpg,png,',
211 211
         'deniedExtensions' => '');
212 212
 
213 213
 $config['ResourceType'][] = Array(
214 214
         'name' => 'Flash',
215
-        'url' => $baseUrl .  '/flash/',
216
-        'directory' => $baseDir .  '/flash/',
215
+        'url' => $baseUrl.'/flash/',
216
+        'directory' => $baseDir.'/flash/',
217 217
         'maxSize' => 0,
218 218
         'allowedExtensions' => 'swf,flv',
219 219
         'deniedExtensions' => '');
220 220
 
221 221
 $config['ResourceType'][] = Array(
222 222
         'name' => 'Media',
223
-        'url' => $baseUrl .  '/media/',
224
-        'directory' => $baseDir .  '/media/',
223
+        'url' => $baseUrl.'/media/',
224
+        'directory' => $baseDir.'/media/',
225 225
         'maxSize' => 0,
226 226
         'allowedExtensions' => 'mp3,mp4,swf,flv,avi',
227 227
         'deniedExtensions' => '');
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
 Set to 0 to disable this feature.
300 300
 Note: not needed on Windows-based servers.
301 301
 */
302
-$config['ChmodFiles'] = 0777 ;
302
+$config['ChmodFiles'] = 0777;
303 303
 
304 304
 /*
305 305
 See comments above.
306 306
 Used when creating folders that does not exist.
307 307
 */
308
-$config['ChmodFolders'] = 0777 ;
308
+$config['ChmodFolders'] = 0777;
309 309
 
310 310
 /*
311 311
 Force ASCII names for files and folders.
Please login to merge, or discard this patch.
libs/ckfinder/core/connector/php/constants.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -55,19 +55,19 @@
 block discarded – undo
55 55
 define('CKFINDER_CONNECTOR_CONFIG_FILE_PATH',"./../../../config.php");
56 56
 
57 57
 if (version_compare(phpversion(), '6', '>=')) {
58
-    define('CKFINDER_CONNECTOR_PHP_MODE', 6);
58
+	define('CKFINDER_CONNECTOR_PHP_MODE', 6);
59 59
 }
60 60
 else if (version_compare(phpversion(), '5', '>=')) {
61
-    define('CKFINDER_CONNECTOR_PHP_MODE', 5);
61
+	define('CKFINDER_CONNECTOR_PHP_MODE', 5);
62 62
 }
63 63
 else {
64
-    define('CKFINDER_CONNECTOR_PHP_MODE', 4);
64
+	define('CKFINDER_CONNECTOR_PHP_MODE', 4);
65 65
 }
66 66
 
67 67
 if (CKFINDER_CONNECTOR_PHP_MODE == 4) {
68
-    define('CKFINDER_CONNECTOR_LIB_DIR', "./php4");
68
+	define('CKFINDER_CONNECTOR_LIB_DIR', "./php4");
69 69
 } else {
70
-    define('CKFINDER_CONNECTOR_LIB_DIR', "./php5");
70
+	define('CKFINDER_CONNECTOR_LIB_DIR', "./php5");
71 71
 }
72 72
 
73 73
 define('CKFINDER_CHARS', '123456789ABCDEFGHJKLMNPQRSTUVWXYZ');
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -23,36 +23,36 @@
 block discarded – undo
23 23
  * No errors
24 24
  */
25 25
 define('IN_CKFINDER', true);
26
-define('CKFINDER_CONNECTOR_ERROR_NONE',0);
27
-define('CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR',1);
28
-define('CKFINDER_CONNECTOR_ERROR_INVALID_COMMAND',10);
29
-define('CKFINDER_CONNECTOR_ERROR_TYPE_NOT_SPECIFIED',11);
30
-define('CKFINDER_CONNECTOR_ERROR_INVALID_TYPE',12);
31
-define('CKFINDER_CONNECTOR_ERROR_INVALID_NAME',102);
32
-define('CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED',103);
33
-define('CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED',104);
34
-define('CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION',105);
35
-define('CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST',109);
36
-define('CKFINDER_CONNECTOR_ERROR_UNKNOWN',110);
37
-define('CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST',115);
38
-define('CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND',116);
39
-define('CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND',117);
40
-define('CKFINDER_CONNECTOR_ERROR_SOURCE_AND_TARGET_PATH_EQUAL',118);
41
-define('CKFINDER_CONNECTOR_ERROR_UPLOADED_FILE_RENAMED',201);
42
-define('CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID',202);
43
-define('CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG',203);
44
-define('CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT',204);
45
-define('CKFINDER_CONNECTOR_ERROR_UPLOADED_NO_TMP_DIR',205);
46
-define('CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE',206);
47
-define('CKFINDER_CONNECTOR_ERROR_MOVE_FAILED',300);
48
-define('CKFINDER_CONNECTOR_ERROR_COPY_FAILED',301);
26
+define('CKFINDER_CONNECTOR_ERROR_NONE', 0);
27
+define('CKFINDER_CONNECTOR_ERROR_CUSTOM_ERROR', 1);
28
+define('CKFINDER_CONNECTOR_ERROR_INVALID_COMMAND', 10);
29
+define('CKFINDER_CONNECTOR_ERROR_TYPE_NOT_SPECIFIED', 11);
30
+define('CKFINDER_CONNECTOR_ERROR_INVALID_TYPE', 12);
31
+define('CKFINDER_CONNECTOR_ERROR_INVALID_NAME', 102);
32
+define('CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED', 103);
33
+define('CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED', 104);
34
+define('CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION', 105);
35
+define('CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST', 109);
36
+define('CKFINDER_CONNECTOR_ERROR_UNKNOWN', 110);
37
+define('CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST', 115);
38
+define('CKFINDER_CONNECTOR_ERROR_FOLDER_NOT_FOUND', 116);
39
+define('CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND', 117);
40
+define('CKFINDER_CONNECTOR_ERROR_SOURCE_AND_TARGET_PATH_EQUAL', 118);
41
+define('CKFINDER_CONNECTOR_ERROR_UPLOADED_FILE_RENAMED', 201);
42
+define('CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID', 202);
43
+define('CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG', 203);
44
+define('CKFINDER_CONNECTOR_ERROR_UPLOADED_CORRUPT', 204);
45
+define('CKFINDER_CONNECTOR_ERROR_UPLOADED_NO_TMP_DIR', 205);
46
+define('CKFINDER_CONNECTOR_ERROR_UPLOADED_WRONG_HTML_FILE', 206);
47
+define('CKFINDER_CONNECTOR_ERROR_MOVE_FAILED', 300);
48
+define('CKFINDER_CONNECTOR_ERROR_COPY_FAILED', 301);
49 49
 define('CKFINDER_CONNECTOR_ERROR_UPLOADED_INVALID_NAME_RENAMED', 207);
50
-define('CKFINDER_CONNECTOR_ERROR_CONNECTOR_DISABLED',500);
51
-define('CKFINDER_CONNECTOR_ERROR_THUMBNAILS_DISABLED',501);
50
+define('CKFINDER_CONNECTOR_ERROR_CONNECTOR_DISABLED', 500);
51
+define('CKFINDER_CONNECTOR_ERROR_THUMBNAILS_DISABLED', 501);
52 52
 
53
-define('CKFINDER_CONNECTOR_DEFAULT_USER_FILES_PATH',"/userfiles/");
54
-define('CKFINDER_CONNECTOR_LANG_PATH',"./lang");
55
-define('CKFINDER_CONNECTOR_CONFIG_FILE_PATH',"./../../../config.php");
53
+define('CKFINDER_CONNECTOR_DEFAULT_USER_FILES_PATH', "/userfiles/");
54
+define('CKFINDER_CONNECTOR_LANG_PATH', "./lang");
55
+define('CKFINDER_CONNECTOR_CONFIG_FILE_PATH', "./../../../config.php");
56 56
 
57 57
 if (version_compare(phpversion(), '6', '>=')) {
58 58
     define('CKFINDER_CONNECTOR_PHP_MODE', 6);
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,11 +56,9 @@
 block discarded – undo
56 56
 
57 57
 if (version_compare(phpversion(), '6', '>=')) {
58 58
     define('CKFINDER_CONNECTOR_PHP_MODE', 6);
59
-}
60
-else if (version_compare(phpversion(), '5', '>=')) {
59
+} else if (version_compare(phpversion(), '5', '>=')) {
61 60
     define('CKFINDER_CONNECTOR_PHP_MODE', 5);
62
-}
63
-else {
61
+} else {
64 62
     define('CKFINDER_CONNECTOR_PHP_MODE', 4);
65 63
 }
66 64
 
Please login to merge, or discard this patch.
libs/ckfinder/core/connector/php/connector.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
  * @return string
65 65
  */
66 66
 function resolveUrl($baseUrl) {
67
-    $fileSystem =& CKFinder_Connector_Core_Factory::getInstance("Utils_FileSystem");
68
-    return $fileSystem->getDocumentRootPath() . $baseUrl;
67
+	$fileSystem =& CKFinder_Connector_Core_Factory::getInstance("Utils_FileSystem");
68
+	return $fileSystem->getDocumentRootPath() . $baseUrl;
69 69
 }
70 70
 
71 71
 $utilsSecurity =& CKFinder_Connector_Core_Factory::getInstance("Utils_Security");
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
 $connector =& CKFinder_Connector_Core_Factory::getInstance("Core_Connector");
88 88
 
89 89
 if(isset($_GET['command'])) {
90
-    $connector->executeCommand($_GET['command']);
90
+	$connector->executeCommand($_GET['command']);
91 91
 }
92 92
 else {
93
-    $connector->handleInvalidCommand();
93
+	$connector->handleInvalidCommand();
94 94
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -41,19 +41,19 @@  discard block
 block discarded – undo
41 41
 /**
42 42
  * we need this class in each call
43 43
  */
44
-require_once CKFINDER_CONNECTOR_LIB_DIR . "/CommandHandler/CommandHandlerBase.php";
44
+require_once CKFINDER_CONNECTOR_LIB_DIR."/CommandHandler/CommandHandlerBase.php";
45 45
 /**
46 46
  * singleton factory
47 47
  */
48
-require_once CKFINDER_CONNECTOR_LIB_DIR . "/Core/Factory.php";
48
+require_once CKFINDER_CONNECTOR_LIB_DIR."/Core/Factory.php";
49 49
 /**
50 50
  * utils class
51 51
  */
52
-require_once CKFINDER_CONNECTOR_LIB_DIR . "/Utils/Misc.php";
52
+require_once CKFINDER_CONNECTOR_LIB_DIR."/Utils/Misc.php";
53 53
 /**
54 54
  * hooks class
55 55
  */
56
-require_once CKFINDER_CONNECTOR_LIB_DIR . "/Core/Hooks.php";
56
+require_once CKFINDER_CONNECTOR_LIB_DIR."/Core/Hooks.php";
57 57
 /**
58 58
  * Simple function required by config.php - discover the server side path
59 59
  * to the directory relative to the "$baseUrl" attribute
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
  * @return string
65 65
  */
66 66
 function resolveUrl($baseUrl) {
67
-    $fileSystem =& CKFinder_Connector_Core_Factory::getInstance("Utils_FileSystem");
68
-    return $fileSystem->getDocumentRootPath() . $baseUrl;
67
+    $fileSystem = & CKFinder_Connector_Core_Factory::getInstance("Utils_FileSystem");
68
+    return $fileSystem->getDocumentRootPath().$baseUrl;
69 69
 }
70 70
 
71
-$utilsSecurity =& CKFinder_Connector_Core_Factory::getInstance("Utils_Security");
71
+$utilsSecurity = & CKFinder_Connector_Core_Factory::getInstance("Utils_Security");
72 72
 $utilsSecurity->getRidOfMagicQuotes();
73 73
 
74 74
 /**
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 require_once CKFINDER_CONNECTOR_CONFIG_FILE_PATH;
85 85
 
86 86
 CKFinder_Connector_Core_Factory::initFactory();
87
-$connector =& CKFinder_Connector_Core_Factory::getInstance("Core_Connector");
87
+$connector = & CKFinder_Connector_Core_Factory::getInstance("Core_Connector");
88 88
 
89
-if(isset($_GET['command'])) {
89
+if (isset($_GET['command'])) {
90 90
     $connector->executeCommand($_GET['command']);
91 91
 }
92 92
 else {
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,7 +88,6 @@
 block discarded – undo
88 88
 
89 89
 if(isset($_GET['command'])) {
90 90
     $connector->executeCommand($_GET['command']);
91
-}
92
-else {
91
+} else {
93 92
     $connector->handleInvalidCommand();
94 93
 }
Please login to merge, or discard this patch.
libs/ckfinder/core/connector/php/php5/CommandHandler/CopyFiles.php 4 patches
Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -32,224 +32,224 @@
 block discarded – undo
32 32
  */
33 33
 class CKFinder_Connector_CommandHandler_CopyFiles extends CKFinder_Connector_CommandHandler_XmlCommandHandlerBase
34 34
 {
35
-    /**
36
-     * Command name
37
-     *
38
-     * @access private
39
-     * @var string
40
-     */
41
-    private $command = "CopyFiles";
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
-        $clientPath = $this->_currentFolder->getClientPath();
56
-        $sServerDir = $this->_currentFolder->getServerPath();
57
-        $currentResourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
58
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
59
-        $_aclConfig = $_config->getAccessControlConfig();
60
-        $aclMasks = array();
61
-        $_resourceTypeConfig = array();
62
-
63
-        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_RENAME | CKFINDER_CONNECTOR_ACL_FILE_UPLOAD | CKFINDER_CONNECTOR_ACL_FILE_DELETE)) {
64
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
65
-        }
66
-
67
-        // Create the "Errors" node.
68
-        $oErrorsNode = new CKFinder_Connector_Utils_XmlNode("Errors");
69
-        $errorCode = CKFINDER_CONNECTOR_ERROR_NONE;
70
-        $copied = 0;
71
-        $copiedAll = 0;
72
-        if (!empty($_POST['copied'])) {
73
-            $copiedAll = intval($_POST['copied']);
74
-        }
75
-        $checkedPaths = array();
76
-
77
-        $oCopyFilesNode = new Ckfinder_Connector_Utils_XmlNode("CopyFiles");
78
-
79
-        if (!empty($_POST['files']) && is_array($_POST['files'])) {
80
-            foreach ($_POST['files'] as $index => $arr) {
81
-                if (empty($arr['name'])) {
82
-                    continue;
83
-                }
84
-                if (!isset($arr['name'], $arr['type'], $arr['folder'])) {
85
-                    $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
86
-                }
87
-
88
-                // file name
89
-                $name = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['name']);
90
-                // resource type
91
-                $type = $arr['type'];
92
-                // client path
93
-                $path = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['folder']);
94
-                // options
95
-                $options = (!empty($arr['options'])) ? $arr['options'] : '';
96
-
97
-                $destinationFilePath = $sServerDir.$name;
98
-
99
-                // check #1 (path)
100
-                if (!CKFinder_Connector_Utils_FileSystem::checkFileName($name) || preg_match(CKFINDER_REGEX_INVALID_PATH, $path)) {
101
-                    $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
102
-                }
103
-
104
-                // get resource type config for current file
105
-                if (!isset($_resourceTypeConfig[$type])) {
106
-                    $_resourceTypeConfig[$type] = $_config->getResourceTypeConfig($type);
107
-                }
108
-
109
-                // check #2 (resource type)
110
-                if (is_null($_resourceTypeConfig[$type])) {
111
-                    $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
112
-                }
113
-
114
-                // check #3 (extension)
115
-                if (!$_resourceTypeConfig[$type]->checkExtension($name, false)) {
116
-                    $errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION;
117
-                    $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
118
-                    continue;
119
-                }
120
-
121
-                // check #4 (extension) - when moving to another resource type, double check extension
122
-                if ($currentResourceTypeConfig->getName() != $type) {
123
-                    if (!$currentResourceTypeConfig->checkExtension($name, false)) {
124
-                        $errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION;
125
-                        $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
126
-                        continue;
127
-                    }
128
-                }
129
-
130
-                // check #5 (hidden folders)
131
-                // cache results
132
-                if (empty($checkedPaths[$path])) {
133
-                    $checkedPaths[$path] = true;
134
-
135
-                    if ($_resourceTypeConfig[$type]->checkIsHiddenPath($path)) {
136
-                        $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
137
-                    }
138
-                }
139
-
140
-                $sourceFilePath = $_resourceTypeConfig[$type]->getDirectory().$path.$name;
141
-
142
-                // check #6 (hidden file name)
143
-                if ($currentResourceTypeConfig->checkIsHiddenFile($name)) {
144
-                    $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
145
-                }
146
-
147
-                // check #7 (Access Control, need file view permission to source files)
148
-                if (!isset($aclMasks[$type."@".$path])) {
149
-                    $aclMasks[$type."@".$path] = $_aclConfig->getComputedMask($type, $path);
150
-                }
151
-
152
-                $isAuthorized = (($aclMasks[$type."@".$path] & CKFINDER_CONNECTOR_ACL_FILE_VIEW) == CKFINDER_CONNECTOR_ACL_FILE_VIEW);
153
-                if (!$isAuthorized) {
154
-                    $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
155
-                }
156
-
157
-                // check #8 (invalid file name)
158
-                if (!file_exists($sourceFilePath) || !is_file($sourceFilePath)) {
159
-                    $errorCode = CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND;
160
-                    $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
161
-                    continue;
162
-                }
163
-
164
-                // check #9 (max size)
165
-                if ($currentResourceTypeConfig->getName() != $type) {
166
-                    $maxSize = $currentResourceTypeConfig->getMaxSize();
167
-                    $fileSize = filesize($sourceFilePath);
168
-                    if ($maxSize && $fileSize>$maxSize) {
169
-                        $errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG;
170
-                        $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
171
-                        continue;
172
-                    }
173
-                }
174
-
175
-                //$overwrite
176
-                // finally, no errors so far, we may attempt to copy a file
177
-                // protection against copying files to itself
178
-                if ($sourceFilePath == $destinationFilePath) {
179
-                    $errorCode = CKFINDER_CONNECTOR_ERROR_SOURCE_AND_TARGET_PATH_EQUAL;
180
-                    $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
181
-                    continue;
182
-                }
183
-                // check if file exists if we don't force overwriting
184
-                else if (file_exists($destinationFilePath) && strpos($options, "overwrite") === false) {
185
-                    if (strpos($options, "autorename") !== false) {
186
-                        $iCounter = 1;
187
-                        while (true)
188
-                        {
189
-                            $fileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($name) .
190
-                                "(" . $iCounter . ")" . "." .
191
-                                CKFinder_Connector_Utils_FileSystem::getExtension($name);
192
-
193
-                            $destinationFilePath = $sServerDir.$fileName;
194
-                            if (!file_exists($destinationFilePath)) {
195
-                                break;
196
-                            }
197
-                            else {
198
-                                $iCounter++;
199
-                            }
200
-                        }
201
-                        if (!@copy($sourceFilePath, $destinationFilePath)) {
202
-                            $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED;
203
-                            $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
204
-                            continue;
205
-                        }
206
-                        else {
207
-                            $copied++;
208
-                        }
209
-                    }
210
-                    else {
211
-                        $errorCode = CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST;
212
-                        $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
213
-                        continue;
214
-                    }
215
-                }
216
-                // copy() overwrites without warning
217
-                else {
218
-                    if (!@copy($sourceFilePath, $destinationFilePath)) {
219
-                        $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED;
220
-                        $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
221
-                        continue;
222
-                    }
223
-                    else {
224
-                        $copied++;
225
-                    }
226
-                }
227
-            }
228
-        }
229
-
230
-        $this->_connectorNode->addChild($oCopyFilesNode);
231
-        if ($errorCode != CKFINDER_CONNECTOR_ERROR_NONE) {
232
-            $this->_connectorNode->addChild($oErrorsNode);
233
-        }
234
-        $oCopyFilesNode->addAttribute("copied", $copied);
235
-        $oCopyFilesNode->addAttribute("copiedTotal", $copiedAll + $copied);
236
-
237
-        /**
238
-         * Note: actually we could have more than one error.
239
-         * This is just a flag for CKFinder interface telling it to check all errors.
240
-         */
241
-        if ($errorCode != CKFINDER_CONNECTOR_ERROR_NONE) {
242
-            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_COPY_FAILED);
243
-        }
244
-    }
245
-
246
-    private function appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path)
247
-    {
248
-        $oErrorNode = new CKFinder_Connector_Utils_XmlNode("Error");
249
-        $oErrorNode->addAttribute("code", $errorCode);
250
-        $oErrorNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name));
251
-        $oErrorNode->addAttribute("type", $type);
252
-        $oErrorNode->addAttribute("folder", $path);
253
-        $oErrorsNode->addChild($oErrorNode);
254
-    }
35
+	/**
36
+	 * Command name
37
+	 *
38
+	 * @access private
39
+	 * @var string
40
+	 */
41
+	private $command = "CopyFiles";
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
+		$clientPath = $this->_currentFolder->getClientPath();
56
+		$sServerDir = $this->_currentFolder->getServerPath();
57
+		$currentResourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
58
+		$_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
59
+		$_aclConfig = $_config->getAccessControlConfig();
60
+		$aclMasks = array();
61
+		$_resourceTypeConfig = array();
62
+
63
+		if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_RENAME | CKFINDER_CONNECTOR_ACL_FILE_UPLOAD | CKFINDER_CONNECTOR_ACL_FILE_DELETE)) {
64
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
65
+		}
66
+
67
+		// Create the "Errors" node.
68
+		$oErrorsNode = new CKFinder_Connector_Utils_XmlNode("Errors");
69
+		$errorCode = CKFINDER_CONNECTOR_ERROR_NONE;
70
+		$copied = 0;
71
+		$copiedAll = 0;
72
+		if (!empty($_POST['copied'])) {
73
+			$copiedAll = intval($_POST['copied']);
74
+		}
75
+		$checkedPaths = array();
76
+
77
+		$oCopyFilesNode = new Ckfinder_Connector_Utils_XmlNode("CopyFiles");
78
+
79
+		if (!empty($_POST['files']) && is_array($_POST['files'])) {
80
+			foreach ($_POST['files'] as $index => $arr) {
81
+				if (empty($arr['name'])) {
82
+					continue;
83
+				}
84
+				if (!isset($arr['name'], $arr['type'], $arr['folder'])) {
85
+					$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
86
+				}
87
+
88
+				// file name
89
+				$name = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['name']);
90
+				// resource type
91
+				$type = $arr['type'];
92
+				// client path
93
+				$path = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($arr['folder']);
94
+				// options
95
+				$options = (!empty($arr['options'])) ? $arr['options'] : '';
96
+
97
+				$destinationFilePath = $sServerDir.$name;
98
+
99
+				// check #1 (path)
100
+				if (!CKFinder_Connector_Utils_FileSystem::checkFileName($name) || preg_match(CKFINDER_REGEX_INVALID_PATH, $path)) {
101
+					$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
102
+				}
103
+
104
+				// get resource type config for current file
105
+				if (!isset($_resourceTypeConfig[$type])) {
106
+					$_resourceTypeConfig[$type] = $_config->getResourceTypeConfig($type);
107
+				}
108
+
109
+				// check #2 (resource type)
110
+				if (is_null($_resourceTypeConfig[$type])) {
111
+					$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
112
+				}
113
+
114
+				// check #3 (extension)
115
+				if (!$_resourceTypeConfig[$type]->checkExtension($name, false)) {
116
+					$errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION;
117
+					$this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
118
+					continue;
119
+				}
120
+
121
+				// check #4 (extension) - when moving to another resource type, double check extension
122
+				if ($currentResourceTypeConfig->getName() != $type) {
123
+					if (!$currentResourceTypeConfig->checkExtension($name, false)) {
124
+						$errorCode = CKFINDER_CONNECTOR_ERROR_INVALID_EXTENSION;
125
+						$this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
126
+						continue;
127
+					}
128
+				}
129
+
130
+				// check #5 (hidden folders)
131
+				// cache results
132
+				if (empty($checkedPaths[$path])) {
133
+					$checkedPaths[$path] = true;
134
+
135
+					if ($_resourceTypeConfig[$type]->checkIsHiddenPath($path)) {
136
+						$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
137
+					}
138
+				}
139
+
140
+				$sourceFilePath = $_resourceTypeConfig[$type]->getDirectory().$path.$name;
141
+
142
+				// check #6 (hidden file name)
143
+				if ($currentResourceTypeConfig->checkIsHiddenFile($name)) {
144
+					$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
145
+				}
146
+
147
+				// check #7 (Access Control, need file view permission to source files)
148
+				if (!isset($aclMasks[$type."@".$path])) {
149
+					$aclMasks[$type."@".$path] = $_aclConfig->getComputedMask($type, $path);
150
+				}
151
+
152
+				$isAuthorized = (($aclMasks[$type."@".$path] & CKFINDER_CONNECTOR_ACL_FILE_VIEW) == CKFINDER_CONNECTOR_ACL_FILE_VIEW);
153
+				if (!$isAuthorized) {
154
+					$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
155
+				}
156
+
157
+				// check #8 (invalid file name)
158
+				if (!file_exists($sourceFilePath) || !is_file($sourceFilePath)) {
159
+					$errorCode = CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND;
160
+					$this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
161
+					continue;
162
+				}
163
+
164
+				// check #9 (max size)
165
+				if ($currentResourceTypeConfig->getName() != $type) {
166
+					$maxSize = $currentResourceTypeConfig->getMaxSize();
167
+					$fileSize = filesize($sourceFilePath);
168
+					if ($maxSize && $fileSize>$maxSize) {
169
+						$errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG;
170
+						$this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
171
+						continue;
172
+					}
173
+				}
174
+
175
+				//$overwrite
176
+				// finally, no errors so far, we may attempt to copy a file
177
+				// protection against copying files to itself
178
+				if ($sourceFilePath == $destinationFilePath) {
179
+					$errorCode = CKFINDER_CONNECTOR_ERROR_SOURCE_AND_TARGET_PATH_EQUAL;
180
+					$this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
181
+					continue;
182
+				}
183
+				// check if file exists if we don't force overwriting
184
+				else if (file_exists($destinationFilePath) && strpos($options, "overwrite") === false) {
185
+					if (strpos($options, "autorename") !== false) {
186
+						$iCounter = 1;
187
+						while (true)
188
+						{
189
+							$fileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($name) .
190
+								"(" . $iCounter . ")" . "." .
191
+								CKFinder_Connector_Utils_FileSystem::getExtension($name);
192
+
193
+							$destinationFilePath = $sServerDir.$fileName;
194
+							if (!file_exists($destinationFilePath)) {
195
+								break;
196
+							}
197
+							else {
198
+								$iCounter++;
199
+							}
200
+						}
201
+						if (!@copy($sourceFilePath, $destinationFilePath)) {
202
+							$errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED;
203
+							$this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
204
+							continue;
205
+						}
206
+						else {
207
+							$copied++;
208
+						}
209
+					}
210
+					else {
211
+						$errorCode = CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST;
212
+						$this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
213
+						continue;
214
+					}
215
+				}
216
+				// copy() overwrites without warning
217
+				else {
218
+					if (!@copy($sourceFilePath, $destinationFilePath)) {
219
+						$errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED;
220
+						$this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
221
+						continue;
222
+					}
223
+					else {
224
+						$copied++;
225
+					}
226
+				}
227
+			}
228
+		}
229
+
230
+		$this->_connectorNode->addChild($oCopyFilesNode);
231
+		if ($errorCode != CKFINDER_CONNECTOR_ERROR_NONE) {
232
+			$this->_connectorNode->addChild($oErrorsNode);
233
+		}
234
+		$oCopyFilesNode->addAttribute("copied", $copied);
235
+		$oCopyFilesNode->addAttribute("copiedTotal", $copiedAll + $copied);
236
+
237
+		/**
238
+		 * Note: actually we could have more than one error.
239
+		 * This is just a flag for CKFinder interface telling it to check all errors.
240
+		 */
241
+		if ($errorCode != CKFINDER_CONNECTOR_ERROR_NONE) {
242
+			$this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_COPY_FAILED);
243
+		}
244
+	}
245
+
246
+	private function appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path)
247
+	{
248
+		$oErrorNode = new CKFinder_Connector_Utils_XmlNode("Error");
249
+		$oErrorNode->addAttribute("code", $errorCode);
250
+		$oErrorNode->addAttribute("name", CKFinder_Connector_Utils_FileSystem::convertToConnectorEncoding($name));
251
+		$oErrorNode->addAttribute("type", $type);
252
+		$oErrorNode->addAttribute("folder", $path);
253
+		$oErrorsNode->addChild($oErrorNode);
254
+	}
255 255
 }
Please login to merge, or discard this patch.
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -259,6 +259,10 @@
 block discarded – undo
259 259
         }
260 260
     }
261 261
 
262
+    /**
263
+     * @param integer $errorCode
264
+     * @param string $path
265
+     */
262 266
     private function appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path)
263 267
     {
264 268
         $oErrorNode = new CKFinder_Connector_Utils_XmlNode("Error");
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 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 MoveFiles command
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
         $clientPath = $this->_currentFolder->getClientPath();
56 56
         $sServerDir = $this->_currentFolder->getServerPath();
57 57
         $currentResourceTypeConfig = $this->_currentFolder->getResourceTypeConfig();
58
-        $_config =& CKFinder_Connector_Core_Factory::getInstance("Core_Config");
58
+        $_config = & CKFinder_Connector_Core_Factory::getInstance("Core_Config");
59 59
         $_aclConfig = $_config->getAccessControlConfig();
60 60
         $aclMasks = array();
61 61
         $_resourceTypeConfig = array();
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                 if ($currentResourceTypeConfig->getName() != $type) {
166 166
                     $maxSize = $currentResourceTypeConfig->getMaxSize();
167 167
                     $fileSize = filesize($sourceFilePath);
168
-                    if ($maxSize && $fileSize>$maxSize) {
168
+                    if ($maxSize && $fileSize > $maxSize) {
169 169
                         $errorCode = CKFINDER_CONNECTOR_ERROR_UPLOADED_TOO_BIG;
170 170
                         $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
171 171
                         continue;
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
                         $iCounter = 1;
204 204
                         while (true)
205 205
                         {
206
-                            $fileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($name) .
207
-                                "(" . $iCounter . ")" . "." .
206
+                            $fileName = CKFinder_Connector_Utils_FileSystem::getFileNameWithoutExtension($name).
207
+                                "(".$iCounter.")".".".
208 208
                                 CKFinder_Connector_Utils_FileSystem::getExtension($name);
209 209
 
210 210
                             $destinationFilePath = $sServerDir.$fileName;
Please login to merge, or discard this patch.
Braces   +7 added lines, -9 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
@@ -193,8 +195,7 @@  discard block
 block discarded – undo
193 195
                             $destinationFilePath = $sServerDir.$fileName;
194 196
                             if (!file_exists($destinationFilePath)) {
195 197
                                 break;
196
-                            }
197
-                            else {
198
+                            } else {
198 199
                                 $iCounter++;
199 200
                             }
200 201
                         }
@@ -202,12 +203,10 @@  discard block
 block discarded – undo
202 203
                             $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED;
203 204
                             $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
204 205
                             continue;
205
-                        }
206
-                        else {
206
+                        } else {
207 207
                             $copied++;
208 208
                         }
209
-                    }
210
-                    else {
209
+                    } else {
211 210
                         $errorCode = CKFINDER_CONNECTOR_ERROR_ALREADY_EXIST;
212 211
                         $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
213 212
                         continue;
@@ -219,8 +218,7 @@  discard block
 block discarded – undo
219 218
                         $errorCode = CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED;
220 219
                         $this->appendErrorNode($oErrorsNode, $errorCode, $name, $type, $path);
221 220
                         continue;
222
-                    }
223
-                    else {
221
+                    } else {
224 222
                         $copied++;
225 223
                     }
226 224
                 }
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 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.