GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — 2.8 ( 41d2f7...b9ed1f )
by Thorsten
25:52 queued 10:52
created
phpmyfaq/admin/editor/plugins/ajaxfilemanager/inc/class.file.php 4 patches
Doc Comments   +9 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,6 +88,7 @@  discard block
 block discarded – undo
88 88
 		 * check if a file or folder writable
89 89
 		 *
90 90
 		 * @param file path $path
91
+		 * @param string $path
91 92
 		 * @return boolean
92 93
 		 */
93 94
 	function isWritable($path=null)
@@ -124,6 +125,7 @@  discard block
 block discarded – undo
124 125
 	/**
125 126
 	 * Returns true if the files is readable.
126 127
 	 *
128
+	 * @param string $path
127 129
 	 * @return boolean true if the files is readable.
128 130
 	 */
129 131
 	function isReadable($path =null) 
@@ -151,6 +153,7 @@  discard block
 block discarded – undo
151 153
 		 * @path the path for the new folder
152 154
 		 * @mask
153 155
 		 * @dirOwner
156
+		 * @param string $path
154 157
 		 * @return boolean
155 158
 		 */
156 159
 		function mkdir($path = null, $mask=null, $dirOwner='') 
@@ -177,7 +180,8 @@  discard block
 block discarded – undo
177 180
 	 * change the own of a file or folder
178 181
 	 *
179 182
 	 * @param the file path $path
180
-	 * @param  $owner
183
+	 * @param  string $owner
184
+	 * @param string $path
181 185
 	 */
182 186
 	function chown($path, $owner) 
183 187
 	{
@@ -305,7 +309,7 @@  discard block
 block discarded – undo
305 309
     /**
306 310
      * get file information
307 311
      *
308
-     * @return array
312
+     * @return string
309 313
      */
310 314
     function getFileInfo()
311 315
     {
@@ -358,6 +362,9 @@  discard block
 block discarded – undo
358 362
 		return false;
359 363
 	}
360 364
 	
365
+	/**
366
+	 * @param string $info
367
+	 */
361 368
 	function _debug($info)
362 369
 	{
363 370
 		if($this->debug)
Please login to merge, or discard this patch.
Indentation   +382 added lines, -382 removed lines patch added patch discarded remove patch
@@ -1,264 +1,264 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
3
-	{
4
-		die('Permission denied');
5
-	}
2
+    if(!defined('AJAX_INIT_DONE'))
3
+    {
4
+        die('Permission denied');
5
+    }
6 6
 ?><?php
7
-	/**
8
-	 * file modification
9
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
10
-	 * @link www.phpletter.com
11
-	 * @since 22/April/2007
12
-	 *
13
-	 */
14
-	class file
15
-	{
16
-		var $fileInfo = "";
17
-		var $filePath = "";
18
-		var $fileStat = "";
19
-		var $mask = '0775';
20
-		var $debug = false;
21
-		var $errors = array();
22
-		/**
23
-		 * constructor
24
-		 *
25
-		 * @param string $path the path to a file or folder
26
-		 */
27
-		function __construct($path = null)
28
-		{
29
-			if(!is_null($path))
30
-			{
31
-			if(file_exists($path))
32
-			{
33
-				$this->filePath = $path;
34
-				if(is_file($this->filePath))
35
-				{
36
-					$this->fileStat = @stat($path);
37
-					$this->fileInfo['size'] = $this->fileStat[7];
38
-					$this->fileInfo['atime'] = $this->fileStat[8];
39
-					$this->fileInfo['ctime'] = $this->fileStat[10];	
40
-					$this->fileInfo['mtime'] = $this->fileStat[9];
41
-					$this->fileInfo['path'] = $path;
42
-					$this->fileInfo['name'] = basename($path);	
43
-					$this->fileInfo['is_writable'] = $this->isWritable();
44
-					$this->fileInfo['is_readable'] = $this->isReadable();
45
-					$imageSize = @getimagesize($path);
46
-					if(is_array($imageSize) && !empty($imageSize))
47
-					{
48
-						$this->fileInfo['is_image'] = 1;
49
-						$this->fileInfo['x'] = $imageSize[0];
50
-						$this->fileInfo['y'] = $imageSize[1];
51
-					}else 
52
-					{
53
-						$this->fileInfo['is_image'] = 0;
54
-					}
7
+    /**
8
+     * file modification
9
+     * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
10
+     * @link www.phpletter.com
11
+     * @since 22/April/2007
12
+     *
13
+     */
14
+    class file
15
+    {
16
+        var $fileInfo = "";
17
+        var $filePath = "";
18
+        var $fileStat = "";
19
+        var $mask = '0775';
20
+        var $debug = false;
21
+        var $errors = array();
22
+        /**
23
+         * constructor
24
+         *
25
+         * @param string $path the path to a file or folder
26
+         */
27
+        function __construct($path = null)
28
+        {
29
+            if(!is_null($path))
30
+            {
31
+            if(file_exists($path))
32
+            {
33
+                $this->filePath = $path;
34
+                if(is_file($this->filePath))
35
+                {
36
+                    $this->fileStat = @stat($path);
37
+                    $this->fileInfo['size'] = $this->fileStat[7];
38
+                    $this->fileInfo['atime'] = $this->fileStat[8];
39
+                    $this->fileInfo['ctime'] = $this->fileStat[10];	
40
+                    $this->fileInfo['mtime'] = $this->fileStat[9];
41
+                    $this->fileInfo['path'] = $path;
42
+                    $this->fileInfo['name'] = basename($path);	
43
+                    $this->fileInfo['is_writable'] = $this->isWritable();
44
+                    $this->fileInfo['is_readable'] = $this->isReadable();
45
+                    $imageSize = @getimagesize($path);
46
+                    if(is_array($imageSize) && !empty($imageSize))
47
+                    {
48
+                        $this->fileInfo['is_image'] = 1;
49
+                        $this->fileInfo['x'] = $imageSize[0];
50
+                        $this->fileInfo['y'] = $imageSize[1];
51
+                    }else 
52
+                    {
53
+                        $this->fileInfo['is_image'] = 0;
54
+                    }
55 55
 					
56
-				}elseif(is_dir($this->filePath))
57
-				{
58
-					$this->fileStat = @stat($path);
59
-					$this->fileInfo['name'] = basename($path);
60
-					$this->fileInfo['path'] = $path;
61
-					$this->fileInfo['atime'] = $this->fileStat[8];
62
-					$this->fileInfo['ctime'] = $this->fileStat[10];	
63
-					$this->fileInfo['mtime'] = $this->fileStat[9];
64
-					$this->fileInfo['is_writable'] = $this->isWritable();
65
-					$this->fileInfo['is_readable'] = $this->isReadable();					
66
-				}
67
-			}else 
68
-			{
69
-				trigger_error('File does not exist ', E_USER_NOTICE);	
70
-			}				
71
-			}
56
+                }elseif(is_dir($this->filePath))
57
+                {
58
+                    $this->fileStat = @stat($path);
59
+                    $this->fileInfo['name'] = basename($path);
60
+                    $this->fileInfo['path'] = $path;
61
+                    $this->fileInfo['atime'] = $this->fileStat[8];
62
+                    $this->fileInfo['ctime'] = $this->fileStat[10];	
63
+                    $this->fileInfo['mtime'] = $this->fileStat[9];
64
+                    $this->fileInfo['is_writable'] = $this->isWritable();
65
+                    $this->fileInfo['is_readable'] = $this->isReadable();					
66
+                }
67
+            }else 
68
+            {
69
+                trigger_error('File does not exist ', E_USER_NOTICE);	
70
+            }				
71
+            }
72 72
 
73 73
 
74 74
 			
75
-		}
76
-		/**
77
-		 * contructor
78
-		 *
79
-		 * @param string $path
80
-		 */
81
-		function file($path=null)
82
-		{
83
-			$this->__construct($path);
84
-		}
75
+        }
76
+        /**
77
+         * contructor
78
+         *
79
+         * @param string $path
80
+         */
81
+        function file($path=null)
82
+        {
83
+            $this->__construct($path);
84
+        }
85 85
 		
86 86
 		
87
-		/**
88
-		 * check if a file or folder writable
89
-		 *
90
-		 * @param file path $path
91
-		 * @return boolean
92
-		 */
93
-	function isWritable($path=null)
94
-	{
95
-		$path = (is_null($path)?$this->filePath:$path);		
96
-		if (DIRECTORY_SEPARATOR == "\\")
97
-		{
98
-			$path = slashToBackslash($path);
99
-			if(is_file($path))
100
-			{
101
-				$fp = @fopen($path,'ab');
102
-				if($fp)
103
-				{
104
-					@fclose($fp);
105
-					return true;
106
-				}
107
-			}elseif(is_dir($path))
108
-			{
109
-					$path = addTrailingSlash($path);
110
-					$tmp = uniqid(time());
111
-					if (@touch($path . $tmp)) 
112
-					{
113
-						@unlink($path . $tmp);
114
-						return true;
115
-					}			
116
-			}
117
-			return false;			
118
-		}else 
119
-		{
120
-			return @is_writable(slashToBackslash($path));
121
-		}
87
+        /**
88
+         * check if a file or folder writable
89
+         *
90
+         * @param file path $path
91
+         * @return boolean
92
+         */
93
+    function isWritable($path=null)
94
+    {
95
+        $path = (is_null($path)?$this->filePath:$path);		
96
+        if (DIRECTORY_SEPARATOR == "\\")
97
+        {
98
+            $path = slashToBackslash($path);
99
+            if(is_file($path))
100
+            {
101
+                $fp = @fopen($path,'ab');
102
+                if($fp)
103
+                {
104
+                    @fclose($fp);
105
+                    return true;
106
+                }
107
+            }elseif(is_dir($path))
108
+            {
109
+                    $path = addTrailingSlash($path);
110
+                    $tmp = uniqid(time());
111
+                    if (@touch($path . $tmp)) 
112
+                    {
113
+                        @unlink($path . $tmp);
114
+                        return true;
115
+                    }			
116
+            }
117
+            return false;			
118
+        }else 
119
+        {
120
+            return @is_writable(slashToBackslash($path));
121
+        }
122 122
 
123
-	}
124
-	/**
125
-	 * Returns true if the files is readable.
126
-	 *
127
-	 * @return boolean true if the files is readable.
128
-	 */
129
-	function isReadable($path =null) 
130
-	{
131
-		$path = is_null($path)?$this->filePath:$path;
132
-		return @is_readable(slashToBackslash($path));
133
-	}		
134
-	/**
135
-	 * change the modified time
136
-	 *
137
-	 * @param string $path
138
-	 * @param string $time
139
-	 * @return boolean
140
-	 */
141
-	function setLastModified($path=null, $time) 
142
-	{
143
-		$path = is_null($path)?$this->filePath:$path;
144
-		$time = is_null($time)?time():$time;
145
-		return @touch(slashToBackslash($path), $time);
146
-	}
123
+    }
124
+    /**
125
+     * Returns true if the files is readable.
126
+     *
127
+     * @return boolean true if the files is readable.
128
+     */
129
+    function isReadable($path =null) 
130
+    {
131
+        $path = is_null($path)?$this->filePath:$path;
132
+        return @is_readable(slashToBackslash($path));
133
+    }		
134
+    /**
135
+     * change the modified time
136
+     *
137
+     * @param string $path
138
+     * @param string $time
139
+     * @return boolean
140
+     */
141
+    function setLastModified($path=null, $time) 
142
+    {
143
+        $path = is_null($path)?$this->filePath:$path;
144
+        $time = is_null($time)?time():$time;
145
+        return @touch(slashToBackslash($path), $time);
146
+    }
147 147
 
148
-		/**
149
-		 * create a new folder
150
-		 *
151
-		 * @path the path for the new folder
152
-		 * @mask
153
-		 * @dirOwner
154
-		 * @return boolean
155
-		 */
156
-		function mkdir($path = null, $mask=null, $dirOwner='') 
157
-		{
158
-			$path = is_null($path)?$this->filePath:$path;
159
-			if(!file_exists($path))
160
-			{
161
-				$mask = is_null($mask)?$this->mask:$mask;				
162
-				$status = @mkdir(slashToBackslash($path));			
163
-				if ($mask)
164
-				{
165
-					@chmod(slashToBackslash($path), intval($mask, 8));
166
-				}					
167
-				if($dirOwner)
168
-				{
169
-					$this->chown(slashToBackslash($path), $dirOwner);
170
-				}
171
-				return $status;				
172
-			}
173
-			return true;
148
+        /**
149
+         * create a new folder
150
+         *
151
+         * @path the path for the new folder
152
+         * @mask
153
+         * @dirOwner
154
+         * @return boolean
155
+         */
156
+        function mkdir($path = null, $mask=null, $dirOwner='') 
157
+        {
158
+            $path = is_null($path)?$this->filePath:$path;
159
+            if(!file_exists($path))
160
+            {
161
+                $mask = is_null($mask)?$this->mask:$mask;				
162
+                $status = @mkdir(slashToBackslash($path));			
163
+                if ($mask)
164
+                {
165
+                    @chmod(slashToBackslash($path), intval($mask, 8));
166
+                }					
167
+                if($dirOwner)
168
+                {
169
+                    $this->chown(slashToBackslash($path), $dirOwner);
170
+                }
171
+                return $status;				
172
+            }
173
+            return true;
174 174
 
175
-		}	
176
-	/**
177
-	 * change the own of a file or folder
178
-	 *
179
-	 * @param the file path $path
180
-	 * @param  $owner
181
-	 */
182
-	function chown($path, $owner) 
183
-	{
184
-		if(!empty($owner))
185
-		{
186
-			$owners = explode(":", $owner);
187
-			if(!empty($owners[0]))
188
-				@chown($path, $owners[0]);
189
-			if(!empty($owners[1]))
190
-				@chgrp($path, $owner[1]);
191
-		}
192
-	}	
175
+        }	
176
+    /**
177
+     * change the own of a file or folder
178
+     *
179
+     * @param the file path $path
180
+     * @param  $owner
181
+     */
182
+    function chown($path, $owner) 
183
+    {
184
+        if(!empty($owner))
185
+        {
186
+            $owners = explode(":", $owner);
187
+            if(!empty($owners[0]))
188
+                @chown($path, $owners[0]);
189
+            if(!empty($owners[1]))
190
+                @chgrp($path, $owner[1]);
191
+        }
192
+    }	
193 193
 
194 194
     /**
195
-         * Copy a file, or recursively copy a folder and its contents
196
-         * @author      Aidan Lister <[email protected]>
197
-         * @author      Paul Scott
198
-         * @version     1.0.1
199
-         * @param       string   $source    Source path
200
-         * @param       string   $dest      Destination path
201
-         * @return      bool     Returns TRUE on success, FALSE on failure
202
-         */
195
+     * Copy a file, or recursively copy a folder and its contents
196
+     * @author      Aidan Lister <[email protected]>
197
+     * @author      Paul Scott
198
+     * @version     1.0.1
199
+     * @param       string   $source    Source path
200
+     * @param       string   $dest      Destination path
201
+     * @return      bool     Returns TRUE on success, FALSE on failure
202
+     */
203 203
     function copyTo($source, $dest)
204 204
     {
205
-    	$source = removeTrailingSlash(backslashToSlash($source));
206
-    	$dest = removeTrailingSlash(backslashToSlash($dest));
207
-	 		if(!file_exists($dest) || !is_dir($dest))
208
-			{
209
-				if(!$this->mkdir($dest))
210
-				{
211
-					$this->_debug('Unable to create folder (' . $dest . ")");
212
-					return false;
213
-				}					
214
-			}
215
-					// Copy in to your self?
216
-				if (getAbsPath($source) ==  getAbsPath($dest))
217
-				{
218
-					$this->_debug('Unable to copy itself. source: ' . getAbsPath($source) . "; dest: " . getAbsPath($dest));
219
-					return false;		
220
-				}
205
+        $source = removeTrailingSlash(backslashToSlash($source));
206
+        $dest = removeTrailingSlash(backslashToSlash($dest));
207
+                if(!file_exists($dest) || !is_dir($dest))
208
+            {
209
+                if(!$this->mkdir($dest))
210
+                {
211
+                    $this->_debug('Unable to create folder (' . $dest . ")");
212
+                    return false;
213
+                }					
214
+            }
215
+                    // Copy in to your self?
216
+                if (getAbsPath($source) ==  getAbsPath($dest))
217
+                {
218
+                    $this->_debug('Unable to copy itself. source: ' . getAbsPath($source) . "; dest: " . getAbsPath($dest));
219
+                    return false;		
220
+                }
221 221
         // Simple copy for a file
222 222
         if (is_file($source))
223 223
         {        	
224
-        		$dest = addTrailingSlash($dest) . (basename($source));
225
-        	if(file_exists($dest))
226
-        	{
227
-        		return false;
228
-        	}else {
224
+                $dest = addTrailingSlash($dest) . (basename($source));
225
+            if(file_exists($dest))
226
+            {
227
+                return false;
228
+            }else {
229 229
         		
230
-        		return copy($source, $dest);
231
-        	}
230
+                return copy($source, $dest);
231
+            }
232 232
             
233 233
             
234 234
         }elseif(is_dir($source))
235 235
         {
236
-	        // Loop through the folder
237
-	           if(file_exists(addTrailingSlash($dest) . basename($source)))
238
-	           {
239
-	           	return false;
240
-	           }else 
241
-	           {
242
-			 		if(!file_exists(addTrailingSlash($dest) . basename($source)) || !is_dir(addTrailingSlash($dest) . basename($source)))
243
-					{
244
-						if(!$this->mkdir(addTrailingSlash($dest) . basename($source)))
245
-						{
246
-							$this->_debug('Unable to create folder (' . addTrailingSlash($dest) . basename($source) . ")");
247
-							return false;
248
-						}					
249
-					}	        	
250
-		        $handle = opendir($source);
251
-		        while(false !== ($readdir = readdir($handle)))
252
-		        {
253
-		            if($readdir != '.' && $readdir != '..')
254
-		            {	  
255
-		            	$path = addTrailingSlash($source).'/'.$readdir;    
256
-		            	$this->copyTo($path, addTrailingSlash($dest) . basename($source));
257
-		            }
258
-		        }
259
-		         closedir($handle);
260
-		        return true;	           	
261
-	           }
236
+            // Loop through the folder
237
+                if(file_exists(addTrailingSlash($dest) . basename($source)))
238
+                {
239
+                    return false;
240
+                }else 
241
+                {
242
+                        if(!file_exists(addTrailingSlash($dest) . basename($source)) || !is_dir(addTrailingSlash($dest) . basename($source)))
243
+                    {
244
+                        if(!$this->mkdir(addTrailingSlash($dest) . basename($source)))
245
+                        {
246
+                            $this->_debug('Unable to create folder (' . addTrailingSlash($dest) . basename($source) . ")");
247
+                            return false;
248
+                        }					
249
+                    }	        	
250
+                $handle = opendir($source);
251
+                while(false !== ($readdir = readdir($handle)))
252
+                {
253
+                    if($readdir != '.' && $readdir != '..')
254
+                    {	  
255
+                        $path = addTrailingSlash($source).'/'.$readdir;    
256
+                        $this->copyTo($path, addTrailingSlash($dest) . basename($source));
257
+                    }
258
+                }
259
+                    closedir($handle);
260
+                return true;	           	
261
+                }
262 262
 	
263 263
         }		   
264 264
         return false;
@@ -273,34 +273,34 @@  discard block
 block discarded – undo
273 273
     function getNextAvailableFileName($fileToMove, $destFolder)
274 274
     {
275 275
     	
276
-    	$folderPath = addslashes(backslashToSlash(getParentPath($fileToMove)));
277
-    	$destFolder = addslashes(backslashToSlash(getParentPath($destFolder)));
278
-    	$finalPath = $destFolder . basename($fileToMove);
279
-    	if(file_exists($fileToMove))
280
-    	{
281
-    		if(is_file())
282
-    		{
283
-    			$fileExt = getFileExt($fileToMove);
284
-    			$fileBaseName = basename($fileToMove, '.' . $fileExt);
285
-    			$count = 1;
286
-    			while(file_exists($destFolder . $fileBaseName . $count . "." . $fileExt))
287
-    			{
288
-    				$count++;
289
-    			}
290
-    			$filePath = $destFolder . $fileBaseName . $count . "." . $fileExt;
291
-    		}elseif(is_dir())
292
-    		{
293
-    			$folderName = basename($fileToMove);
294
-     			$count = 1;
295
-    			while(file_exists($destFolder . $folderName . $count))
296
-    			{
297
-    				$count++;
298
-    			}
299
-    			$filePath = $destFolder . $fileBaseName . $count;   			
300
-    		}
276
+        $folderPath = addslashes(backslashToSlash(getParentPath($fileToMove)));
277
+        $destFolder = addslashes(backslashToSlash(getParentPath($destFolder)));
278
+        $finalPath = $destFolder . basename($fileToMove);
279
+        if(file_exists($fileToMove))
280
+        {
281
+            if(is_file())
282
+            {
283
+                $fileExt = getFileExt($fileToMove);
284
+                $fileBaseName = basename($fileToMove, '.' . $fileExt);
285
+                $count = 1;
286
+                while(file_exists($destFolder . $fileBaseName . $count . "." . $fileExt))
287
+                {
288
+                    $count++;
289
+                }
290
+                $filePath = $destFolder . $fileBaseName . $count . "." . $fileExt;
291
+            }elseif(is_dir())
292
+            {
293
+                $folderName = basename($fileToMove);
294
+                    $count = 1;
295
+                while(file_exists($destFolder . $folderName . $count))
296
+                {
297
+                    $count++;
298
+                }
299
+                $filePath = $destFolder . $fileBaseName . $count;   			
300
+            }
301 301
     		
302
-    	}
303
-		return $finalPath;
302
+        }
303
+        return $finalPath;
304 304
     }
305 305
     /**
306 306
      * get file information
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
      */
310 310
     function getFileInfo()
311 311
     {
312
-    	return $this->fileInfo;
312
+        return $this->fileInfo;
313 313
     }
314 314
     /**
315 315
      * close 
@@ -317,136 +317,136 @@  discard block
 block discarded – undo
317 317
      */
318 318
     function close()
319 319
     {
320
-    	$this->fileInfo = null;
321
-    	$this->fileStat = null;
320
+        $this->fileInfo = null;
321
+        $this->fileStat = null;
322 322
     }
323
- 	/**
324
-	 * delete a file or a folder and all contents within that folder
325
-	 *
326
-	 * @param string $path
327
-	 * @return boolean
328
-	 */
329
-	function delete($path = null)
330
-	{
331
-		$path = is_null($path)?$this->filePath:$path;
332
-		if(file_exists($path))
333
-		{
334
-			if(is_file($path))
335
-			{
336
-				return @unlink($path);
337
-			}elseif(is_dir($path))
338
-			{
339
-				return $this->__recursive_remove_directory($path);
340
-			}
323
+        /**
324
+         * delete a file or a folder and all contents within that folder
325
+         *
326
+         * @param string $path
327
+         * @return boolean
328
+         */
329
+    function delete($path = null)
330
+    {
331
+        $path = is_null($path)?$this->filePath:$path;
332
+        if(file_exists($path))
333
+        {
334
+            if(is_file($path))
335
+            {
336
+                return @unlink($path);
337
+            }elseif(is_dir($path))
338
+            {
339
+                return $this->__recursive_remove_directory($path);
340
+            }
341 341
 			
342
-		}
343
-		return false;
344
-	}
345
-	/**
346
-	 * empty a folder
347
-	 *
348
-	 * @param string $path
349
-	 * @return boolean
350
-	 */
351
-	function emptyFolder($path)
352
-	{
353
-		$path = is_null($path)?$this->filePath:"";
354
-		if(file_exists($path) && is_dir($path))
355
-		{
356
-			return $this->__recursive_remove_directory($path, true);
357
-		}
358
-		return false;
359
-	}
342
+        }
343
+        return false;
344
+    }
345
+    /**
346
+     * empty a folder
347
+     *
348
+     * @param string $path
349
+     * @return boolean
350
+     */
351
+    function emptyFolder($path)
352
+    {
353
+        $path = is_null($path)?$this->filePath:"";
354
+        if(file_exists($path) && is_dir($path))
355
+        {
356
+            return $this->__recursive_remove_directory($path, true);
357
+        }
358
+        return false;
359
+    }
360 360
 	
361
-	function _debug($info)
362
-	{
363
-		if($this->debug)
364
-		{
365
-			echo $info . "<br>\n";
366
-		}else 
367
-		{
368
-			$this->errors[] = $info;
369
-		}
370
-	}
361
+    function _debug($info)
362
+    {
363
+        if($this->debug)
364
+        {
365
+            echo $info . "<br>\n";
366
+        }else 
367
+        {
368
+            $this->errors[] = $info;
369
+        }
370
+    }
371 371
 /**
372
- * recursive_remove_directory( directory to delete, empty )
373
- * expects path to directory and optional TRUE / FALSE to empty
374
- * of course PHP has to have the rights to delete the directory
375
- * you specify and all files and folders inside the directory
376
- * 
377
- * to use this function to totally remove a directory, write:
378
- * recursive_remove_directory('path/to/directory/to/delete');
379
- * to use this function to empty a directory, write:
380
- *	recursive_remove_directory('path/to/full_directory',TRUE);
381
- * @param string $directory
382
- * @param boolean $empty
383
- * @return boolean
384
- */
385
- function __recursive_remove_directory($directory, $empty=FALSE)
386
- {
387
-     // if the path has a slash at the end we remove it here
388
-     if(substr($directory,-1) == '/')
389
-     {
390
-         $directory = substr($directory,0,-1);
391
-     }
372
+     * recursive_remove_directory( directory to delete, empty )
373
+     * expects path to directory and optional TRUE / FALSE to empty
374
+     * of course PHP has to have the rights to delete the directory
375
+     * you specify and all files and folders inside the directory
376
+     * 
377
+     * to use this function to totally remove a directory, write:
378
+     * recursive_remove_directory('path/to/directory/to/delete');
379
+     * to use this function to empty a directory, write:
380
+     *	recursive_remove_directory('path/to/full_directory',TRUE);
381
+     * @param string $directory
382
+     * @param boolean $empty
383
+     * @return boolean
384
+     */
385
+    function __recursive_remove_directory($directory, $empty=FALSE)
386
+    {
387
+        // if the path has a slash at the end we remove it here
388
+        if(substr($directory,-1) == '/')
389
+        {
390
+            $directory = substr($directory,0,-1);
391
+        }
392 392
   
393
-     // if the path is not valid or is not a directory ...
394
-     if(!file_exists($directory) || !is_dir($directory))
395
-     {
396
-         // ... we return false and exit the function
397
-         return FALSE;
393
+        // if the path is not valid or is not a directory ...
394
+        if(!file_exists($directory) || !is_dir($directory))
395
+        {
396
+            // ... we return false and exit the function
397
+            return FALSE;
398 398
   
399
-     // ... if the path is not readable
400
-     }elseif(!is_readable($directory))
401
-     {
402
-         // ... we return false and exit the function
403
-         return FALSE;
399
+        // ... if the path is not readable
400
+        }elseif(!is_readable($directory))
401
+        {
402
+            // ... we return false and exit the function
403
+            return FALSE;
404 404
   
405
-     // ... else if the path is readable
406
-     }else{
405
+        // ... else if the path is readable
406
+        }else{
407 407
   
408
-         // we open the directory
409
-         $handle = @opendir($directory);
408
+            // we open the directory
409
+            $handle = @opendir($directory);
410 410
   
411
-         // and scan through the items inside
412
-         while (FALSE !== ($item = @readdir($handle)))
413
-         {
414
-             // if the filepointer is not the current directory
415
-             // or the parent directory
416
-             if($item != '.' && $item != '..')
417
-             {
418
-                 // we build the new path to delete
419
-                 $path = $directory.'/'.$item;
411
+            // and scan through the items inside
412
+            while (FALSE !== ($item = @readdir($handle)))
413
+            {
414
+                // if the filepointer is not the current directory
415
+                // or the parent directory
416
+                if($item != '.' && $item != '..')
417
+                {
418
+                    // we build the new path to delete
419
+                    $path = $directory.'/'.$item;
420 420
   
421
-                 // if the new path is a directory
422
-                 if(is_dir($path))                  {
423
-                     // we call this function with the new path
424
-                     $this->__recursive_remove_directory($path);
421
+                    // if the new path is a directory
422
+                    if(is_dir($path))                  {
423
+                        // we call this function with the new path
424
+                        $this->__recursive_remove_directory($path);
425 425
   
426
-                 // if the new path is a file
427
-                 }else{
426
+                    // if the new path is a file
427
+                    }else{
428 428
                     // we remove the file
429 429
                     @unlink($path);
430
-                 }
431
-             }
432
-         }
433
-         // close the directory
434
-         @closedir($handle);
430
+                    }
431
+                }
432
+            }
433
+            // close the directory
434
+            @closedir($handle);
435 435
   
436 436
         // if the option to empty is not set to true
437
-         if($empty == FALSE)
438
-         {
439
-             // try to delete the now empty directory
440
-             if(!@rmdir($directory))
441
-             {
442
-                 // return false if not possible
443
-                 return FALSE;
444
-             }
445
-         }
446
-         // return success
447
-         return TRUE;
448
-     }
449
- }   		
450
-	}
437
+            if($empty == FALSE)
438
+            {
439
+                // try to delete the now empty directory
440
+                if(!@rmdir($directory))
441
+                {
442
+                    // return false if not possible
443
+                    return FALSE;
444
+                }
445
+            }
446
+            // return success
447
+            return TRUE;
448
+        }
449
+    }   		
450
+    }
451 451
 
452 452
 ?>
453 453
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
2
+	if (!defined('AJAX_INIT_DONE'))
3 3
 	{
4 4
 		die('Permission denied');
5 5
 	}
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 		 */
27 27
 		function __construct($path = null)
28 28
 		{
29
-			if(!is_null($path))
29
+			if (!is_null($path))
30 30
 			{
31
-			if(file_exists($path))
31
+			if (file_exists($path))
32 32
 			{
33 33
 				$this->filePath = $path;
34
-				if(is_file($this->filePath))
34
+				if (is_file($this->filePath))
35 35
 				{
36 36
 					$this->fileStat = @stat($path);
37 37
 					$this->fileInfo['size'] = $this->fileStat[7];
@@ -43,17 +43,17 @@  discard block
 block discarded – undo
43 43
 					$this->fileInfo['is_writable'] = $this->isWritable();
44 44
 					$this->fileInfo['is_readable'] = $this->isReadable();
45 45
 					$imageSize = @getimagesize($path);
46
-					if(is_array($imageSize) && !empty($imageSize))
46
+					if (is_array($imageSize) && !empty($imageSize))
47 47
 					{
48 48
 						$this->fileInfo['is_image'] = 1;
49 49
 						$this->fileInfo['x'] = $imageSize[0];
50 50
 						$this->fileInfo['y'] = $imageSize[1];
51
-					}else 
51
+					} else 
52 52
 					{
53 53
 						$this->fileInfo['is_image'] = 0;
54 54
 					}
55 55
 					
56
-				}elseif(is_dir($this->filePath))
56
+				}elseif (is_dir($this->filePath))
57 57
 				{
58 58
 					$this->fileStat = @stat($path);
59 59
 					$this->fileInfo['name'] = basename($path);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 					$this->fileInfo['is_writable'] = $this->isWritable();
65 65
 					$this->fileInfo['is_readable'] = $this->isReadable();					
66 66
 				}
67
-			}else 
67
+			} else 
68 68
 			{
69 69
 				trigger_error('File does not exist ', E_USER_NOTICE);	
70 70
 			}				
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 		 *
79 79
 		 * @param string $path
80 80
 		 */
81
-		function file($path=null)
81
+		function file($path = null)
82 82
 		{
83 83
 			$this->__construct($path);
84 84
 		}
@@ -90,32 +90,32 @@  discard block
 block discarded – undo
90 90
 		 * @param file path $path
91 91
 		 * @return boolean
92 92
 		 */
93
-	function isWritable($path=null)
93
+	function isWritable($path = null)
94 94
 	{
95
-		$path = (is_null($path)?$this->filePath:$path);		
95
+		$path = (is_null($path) ? $this->filePath : $path);		
96 96
 		if (DIRECTORY_SEPARATOR == "\\")
97 97
 		{
98 98
 			$path = slashToBackslash($path);
99
-			if(is_file($path))
99
+			if (is_file($path))
100 100
 			{
101
-				$fp = @fopen($path,'ab');
102
-				if($fp)
101
+				$fp = @fopen($path, 'ab');
102
+				if ($fp)
103 103
 				{
104 104
 					@fclose($fp);
105 105
 					return true;
106 106
 				}
107
-			}elseif(is_dir($path))
107
+			}elseif (is_dir($path))
108 108
 			{
109 109
 					$path = addTrailingSlash($path);
110 110
 					$tmp = uniqid(time());
111
-					if (@touch($path . $tmp)) 
111
+					if (@touch($path.$tmp)) 
112 112
 					{
113
-						@unlink($path . $tmp);
113
+						@unlink($path.$tmp);
114 114
 						return true;
115 115
 					}			
116 116
 			}
117 117
 			return false;			
118
-		}else 
118
+		} else 
119 119
 		{
120 120
 			return @is_writable(slashToBackslash($path));
121 121
 		}
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 	 *
127 127
 	 * @return boolean true if the files is readable.
128 128
 	 */
129
-	function isReadable($path =null) 
129
+	function isReadable($path = null) 
130 130
 	{
131
-		$path = is_null($path)?$this->filePath:$path;
131
+		$path = is_null($path) ? $this->filePath : $path;
132 132
 		return @is_readable(slashToBackslash($path));
133 133
 	}		
134 134
 	/**
@@ -138,10 +138,10 @@  discard block
 block discarded – undo
138 138
 	 * @param string $time
139 139
 	 * @return boolean
140 140
 	 */
141
-	function setLastModified($path=null, $time) 
141
+	function setLastModified($path = null, $time) 
142 142
 	{
143
-		$path = is_null($path)?$this->filePath:$path;
144
-		$time = is_null($time)?time():$time;
143
+		$path = is_null($path) ? $this->filePath : $path;
144
+		$time = is_null($time) ? time() : $time;
145 145
 		return @touch(slashToBackslash($path), $time);
146 146
 	}
147 147
 
@@ -153,18 +153,18 @@  discard block
 block discarded – undo
153 153
 		 * @dirOwner
154 154
 		 * @return boolean
155 155
 		 */
156
-		function mkdir($path = null, $mask=null, $dirOwner='') 
156
+		function mkdir($path = null, $mask = null, $dirOwner = '') 
157 157
 		{
158
-			$path = is_null($path)?$this->filePath:$path;
159
-			if(!file_exists($path))
158
+			$path = is_null($path) ? $this->filePath : $path;
159
+			if (!file_exists($path))
160 160
 			{
161
-				$mask = is_null($mask)?$this->mask:$mask;				
161
+				$mask = is_null($mask) ? $this->mask : $mask;				
162 162
 				$status = @mkdir(slashToBackslash($path));			
163 163
 				if ($mask)
164 164
 				{
165 165
 					@chmod(slashToBackslash($path), intval($mask, 8));
166 166
 				}					
167
-				if($dirOwner)
167
+				if ($dirOwner)
168 168
 				{
169 169
 					$this->chown(slashToBackslash($path), $dirOwner);
170 170
 				}
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	function chown($path, $owner) 
183 183
 	{
184
-		if(!empty($owner))
184
+		if (!empty($owner))
185 185
 		{
186 186
 			$owners = explode(":", $owner);
187
-			if(!empty($owners[0]))
187
+			if (!empty($owners[0]))
188 188
 				@chown($path, $owners[0]);
189
-			if(!empty($owners[1]))
189
+			if (!empty($owners[1]))
190 190
 				@chgrp($path, $owner[1]);
191 191
 		}
192 192
 	}	
@@ -204,56 +204,56 @@  discard block
 block discarded – undo
204 204
     {
205 205
     	$source = removeTrailingSlash(backslashToSlash($source));
206 206
     	$dest = removeTrailingSlash(backslashToSlash($dest));
207
-	 		if(!file_exists($dest) || !is_dir($dest))
207
+	 		if (!file_exists($dest) || !is_dir($dest))
208 208
 			{
209
-				if(!$this->mkdir($dest))
209
+				if (!$this->mkdir($dest))
210 210
 				{
211
-					$this->_debug('Unable to create folder (' . $dest . ")");
211
+					$this->_debug('Unable to create folder ('.$dest.")");
212 212
 					return false;
213 213
 				}					
214 214
 			}
215 215
 					// Copy in to your self?
216
-				if (getAbsPath($source) ==  getAbsPath($dest))
216
+				if (getAbsPath($source) == getAbsPath($dest))
217 217
 				{
218
-					$this->_debug('Unable to copy itself. source: ' . getAbsPath($source) . "; dest: " . getAbsPath($dest));
218
+					$this->_debug('Unable to copy itself. source: '.getAbsPath($source)."; dest: ".getAbsPath($dest));
219 219
 					return false;		
220 220
 				}
221 221
         // Simple copy for a file
222 222
         if (is_file($source))
223 223
         {        	
224
-        		$dest = addTrailingSlash($dest) . (basename($source));
225
-        	if(file_exists($dest))
224
+        		$dest = addTrailingSlash($dest).(basename($source));
225
+        	if (file_exists($dest))
226 226
         	{
227 227
         		return false;
228
-        	}else {
228
+        	} else {
229 229
         		
230 230
         		return copy($source, $dest);
231 231
         	}
232 232
             
233 233
             
234
-        }elseif(is_dir($source))
234
+        }elseif (is_dir($source))
235 235
         {
236 236
 	        // Loop through the folder
237
-	           if(file_exists(addTrailingSlash($dest) . basename($source)))
237
+	           if (file_exists(addTrailingSlash($dest).basename($source)))
238 238
 	           {
239 239
 	           	return false;
240
-	           }else 
240
+	           } else 
241 241
 	           {
242
-			 		if(!file_exists(addTrailingSlash($dest) . basename($source)) || !is_dir(addTrailingSlash($dest) . basename($source)))
242
+			 		if (!file_exists(addTrailingSlash($dest).basename($source)) || !is_dir(addTrailingSlash($dest).basename($source)))
243 243
 					{
244
-						if(!$this->mkdir(addTrailingSlash($dest) . basename($source)))
244
+						if (!$this->mkdir(addTrailingSlash($dest).basename($source)))
245 245
 						{
246
-							$this->_debug('Unable to create folder (' . addTrailingSlash($dest) . basename($source) . ")");
246
+							$this->_debug('Unable to create folder ('.addTrailingSlash($dest).basename($source).")");
247 247
 							return false;
248 248
 						}					
249 249
 					}	        	
250 250
 		        $handle = opendir($source);
251
-		        while(false !== ($readdir = readdir($handle)))
251
+		        while (false !== ($readdir = readdir($handle)))
252 252
 		        {
253
-		            if($readdir != '.' && $readdir != '..')
253
+		            if ($readdir != '.' && $readdir != '..')
254 254
 		            {	  
255 255
 		            	$path = addTrailingSlash($source).'/'.$readdir;    
256
-		            	$this->copyTo($path, addTrailingSlash($dest) . basename($source));
256
+		            	$this->copyTo($path, addTrailingSlash($dest).basename($source));
257 257
 		            }
258 258
 		        }
259 259
 		         closedir($handle);
@@ -275,28 +275,28 @@  discard block
 block discarded – undo
275 275
     	
276 276
     	$folderPath = addslashes(backslashToSlash(getParentPath($fileToMove)));
277 277
     	$destFolder = addslashes(backslashToSlash(getParentPath($destFolder)));
278
-    	$finalPath = $destFolder . basename($fileToMove);
279
-    	if(file_exists($fileToMove))
278
+    	$finalPath = $destFolder.basename($fileToMove);
279
+    	if (file_exists($fileToMove))
280 280
     	{
281
-    		if(is_file())
281
+    		if (is_file())
282 282
     		{
283 283
     			$fileExt = getFileExt($fileToMove);
284
-    			$fileBaseName = basename($fileToMove, '.' . $fileExt);
284
+    			$fileBaseName = basename($fileToMove, '.'.$fileExt);
285 285
     			$count = 1;
286
-    			while(file_exists($destFolder . $fileBaseName . $count . "." . $fileExt))
286
+    			while (file_exists($destFolder.$fileBaseName.$count.".".$fileExt))
287 287
     			{
288 288
     				$count++;
289 289
     			}
290
-    			$filePath = $destFolder . $fileBaseName . $count . "." . $fileExt;
291
-    		}elseif(is_dir())
290
+    			$filePath = $destFolder.$fileBaseName.$count.".".$fileExt;
291
+    		}elseif (is_dir())
292 292
     		{
293 293
     			$folderName = basename($fileToMove);
294 294
      			$count = 1;
295
-    			while(file_exists($destFolder . $folderName . $count))
295
+    			while (file_exists($destFolder.$folderName.$count))
296 296
     			{
297 297
     				$count++;
298 298
     			}
299
-    			$filePath = $destFolder . $fileBaseName . $count;   			
299
+    			$filePath = $destFolder.$fileBaseName.$count;   			
300 300
     		}
301 301
     		
302 302
     	}
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
 	 */
329 329
 	function delete($path = null)
330 330
 	{
331
-		$path = is_null($path)?$this->filePath:$path;
332
-		if(file_exists($path))
331
+		$path = is_null($path) ? $this->filePath : $path;
332
+		if (file_exists($path))
333 333
 		{
334
-			if(is_file($path))
334
+			if (is_file($path))
335 335
 			{
336 336
 				return @unlink($path);
337
-			}elseif(is_dir($path))
337
+			}elseif (is_dir($path))
338 338
 			{
339 339
 				return $this->__recursive_remove_directory($path);
340 340
 			}
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
 	 */
351 351
 	function emptyFolder($path)
352 352
 	{
353
-		$path = is_null($path)?$this->filePath:"";
354
-		if(file_exists($path) && is_dir($path))
353
+		$path = is_null($path) ? $this->filePath : "";
354
+		if (file_exists($path) && is_dir($path))
355 355
 		{
356 356
 			return $this->__recursive_remove_directory($path, true);
357 357
 		}
@@ -360,10 +360,10 @@  discard block
 block discarded – undo
360 360
 	
361 361
 	function _debug($info)
362 362
 	{
363
-		if($this->debug)
363
+		if ($this->debug)
364 364
 		{
365
-			echo $info . "<br>\n";
366
-		}else 
365
+			echo $info."<br>\n";
366
+		} else 
367 367
 		{
368 368
 			$this->errors[] = $info;
369 369
 		}
@@ -382,28 +382,28 @@  discard block
 block discarded – undo
382 382
  * @param boolean $empty
383 383
  * @return boolean
384 384
  */
385
- function __recursive_remove_directory($directory, $empty=FALSE)
385
+ function __recursive_remove_directory($directory, $empty = FALSE)
386 386
  {
387 387
      // if the path has a slash at the end we remove it here
388
-     if(substr($directory,-1) == '/')
388
+     if (substr($directory, -1) == '/')
389 389
      {
390
-         $directory = substr($directory,0,-1);
390
+         $directory = substr($directory, 0, -1);
391 391
      }
392 392
   
393 393
      // if the path is not valid or is not a directory ...
394
-     if(!file_exists($directory) || !is_dir($directory))
394
+     if (!file_exists($directory) || !is_dir($directory))
395 395
      {
396 396
          // ... we return false and exit the function
397 397
          return FALSE;
398 398
   
399 399
      // ... if the path is not readable
400
-     }elseif(!is_readable($directory))
400
+     }elseif (!is_readable($directory))
401 401
      {
402 402
          // ... we return false and exit the function
403 403
          return FALSE;
404 404
   
405 405
      // ... else if the path is readable
406
-     }else{
406
+     } else {
407 407
   
408 408
          // we open the directory
409 409
          $handle = @opendir($directory);
@@ -413,18 +413,18 @@  discard block
 block discarded – undo
413 413
          {
414 414
              // if the filepointer is not the current directory
415 415
              // or the parent directory
416
-             if($item != '.' && $item != '..')
416
+             if ($item != '.' && $item != '..')
417 417
              {
418 418
                  // we build the new path to delete
419 419
                  $path = $directory.'/'.$item;
420 420
   
421 421
                  // if the new path is a directory
422
-                 if(is_dir($path))                  {
422
+                 if (is_dir($path)) {
423 423
                      // we call this function with the new path
424 424
                      $this->__recursive_remove_directory($path);
425 425
   
426 426
                  // if the new path is a file
427
-                 }else{
427
+                 } else {
428 428
                     // we remove the file
429 429
                     @unlink($path);
430 430
                  }
@@ -434,10 +434,10 @@  discard block
 block discarded – undo
434 434
          @closedir($handle);
435 435
   
436 436
         // if the option to empty is not set to true
437
-         if($empty == FALSE)
437
+         if ($empty == FALSE)
438 438
          {
439 439
              // try to delete the now empty directory
440
-             if(!@rmdir($directory))
440
+             if (!@rmdir($directory))
441 441
              {
442 442
                  // return false if not possible
443 443
                  return FALSE;
Please login to merge, or discard this patch.
Braces   +20 added lines, -18 removed lines patch added patch discarded remove patch
@@ -48,12 +48,12 @@  discard block
 block discarded – undo
48 48
 						$this->fileInfo['is_image'] = 1;
49 49
 						$this->fileInfo['x'] = $imageSize[0];
50 50
 						$this->fileInfo['y'] = $imageSize[1];
51
-					}else 
51
+					} else 
52 52
 					{
53 53
 						$this->fileInfo['is_image'] = 0;
54 54
 					}
55 55
 					
56
-				}elseif(is_dir($this->filePath))
56
+				} elseif(is_dir($this->filePath))
57 57
 				{
58 58
 					$this->fileStat = @stat($path);
59 59
 					$this->fileInfo['name'] = basename($path);
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 					$this->fileInfo['is_writable'] = $this->isWritable();
65 65
 					$this->fileInfo['is_readable'] = $this->isReadable();					
66 66
 				}
67
-			}else 
67
+			} else 
68 68
 			{
69 69
 				trigger_error('File does not exist ', E_USER_NOTICE);	
70 70
 			}				
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 					@fclose($fp);
105 105
 					return true;
106 106
 				}
107
-			}elseif(is_dir($path))
107
+			} elseif(is_dir($path))
108 108
 			{
109 109
 					$path = addTrailingSlash($path);
110 110
 					$tmp = uniqid(time());
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 					}			
116 116
 			}
117 117
 			return false;			
118
-		}else 
118
+		} else 
119 119
 		{
120 120
 			return @is_writable(slashToBackslash($path));
121 121
 		}
@@ -184,10 +184,12 @@  discard block
 block discarded – undo
184 184
 		if(!empty($owner))
185 185
 		{
186 186
 			$owners = explode(":", $owner);
187
-			if(!empty($owners[0]))
188
-				@chown($path, $owners[0]);
189
-			if(!empty($owners[1]))
190
-				@chgrp($path, $owner[1]);
187
+			if(!empty($owners[0])) {
188
+							@chown($path, $owners[0]);
189
+			}
190
+			if(!empty($owners[1])) {
191
+							@chgrp($path, $owner[1]);
192
+			}
191 193
 		}
192 194
 	}	
193 195
 
@@ -225,19 +227,19 @@  discard block
 block discarded – undo
225 227
         	if(file_exists($dest))
226 228
         	{
227 229
         		return false;
228
-        	}else {
230
+        	} else {
229 231
         		
230 232
         		return copy($source, $dest);
231 233
         	}
232 234
             
233 235
             
234
-        }elseif(is_dir($source))
236
+        } elseif(is_dir($source))
235 237
         {
236 238
 	        // Loop through the folder
237 239
 	           if(file_exists(addTrailingSlash($dest) . basename($source)))
238 240
 	           {
239 241
 	           	return false;
240
-	           }else 
242
+	           } else 
241 243
 	           {
242 244
 			 		if(!file_exists(addTrailingSlash($dest) . basename($source)) || !is_dir(addTrailingSlash($dest) . basename($source)))
243 245
 					{
@@ -288,7 +290,7 @@  discard block
 block discarded – undo
288 290
     				$count++;
289 291
     			}
290 292
     			$filePath = $destFolder . $fileBaseName . $count . "." . $fileExt;
291
-    		}elseif(is_dir())
293
+    		} elseif(is_dir())
292 294
     		{
293 295
     			$folderName = basename($fileToMove);
294 296
      			$count = 1;
@@ -334,7 +336,7 @@  discard block
 block discarded – undo
334 336
 			if(is_file($path))
335 337
 			{
336 338
 				return @unlink($path);
337
-			}elseif(is_dir($path))
339
+			} elseif(is_dir($path))
338 340
 			{
339 341
 				return $this->__recursive_remove_directory($path);
340 342
 			}
@@ -363,7 +365,7 @@  discard block
 block discarded – undo
363 365
 		if($this->debug)
364 366
 		{
365 367
 			echo $info . "<br>\n";
366
-		}else 
368
+		} else 
367 369
 		{
368 370
 			$this->errors[] = $info;
369 371
 		}
@@ -397,13 +399,13 @@  discard block
 block discarded – undo
397 399
          return FALSE;
398 400
   
399 401
      // ... if the path is not readable
400
-     }elseif(!is_readable($directory))
402
+     } elseif(!is_readable($directory))
401 403
      {
402 404
          // ... we return false and exit the function
403 405
          return FALSE;
404 406
   
405 407
      // ... else if the path is readable
406
-     }else{
408
+     } else{
407 409
   
408 410
          // we open the directory
409 411
          $handle = @opendir($directory);
@@ -424,7 +426,7 @@  discard block
 block discarded – undo
424 426
                      $this->__recursive_remove_directory($path);
425 427
   
426 428
                  // if the new path is a file
427
-                 }else{
429
+                 } else{
428 430
                     // we remove the file
429 431
                     @unlink($path);
430 432
                  }
Please login to merge, or discard this patch.
phpmyfaq/admin/editor/plugins/ajaxfilemanager/inc/class.history.php 4 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,6 @@  discard block
 block discarded – undo
47 47
 		/**
48 48
 		 * keep tracks of each changes made to an image
49 49
 		 *
50
-		 * @param string $key
51 50
 		 * @param string $info   array('name', 'restorable', 'is_original')
52 51
 		 */
53 52
 		function add($info)
@@ -57,7 +56,7 @@  discard block
 block discarded – undo
57 56
 		/**
58 57
 		 * get the lastest changes for restore
59 58
 		 *
60
-		 * @return array array('name', 'restorable', 'is_original')
59
+		 * @return integer array('name', 'restorable', 'is_original')
61 60
 		 */
62 61
 		function getNumRestorable()
63 62
 		{
Please login to merge, or discard this patch.
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -1,160 +1,160 @@
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
3
-	{
4
-		die('Permission denied');
5
-	}
2
+    if(!defined('AJAX_INIT_DONE'))
3
+    {
4
+        die('Permission denied');
5
+    }
6 6
 ?><?php
7
-	/**
8
-	 * class history
9
-	 * this class used to keep records of any changed to uploaded images under a session
10
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
11
-	 * @link www.phpletter.com
12
-	 * @since 22/May/2007
13
-	 *
14
-	 */
15
-	class History
16
-	{
17
-		var $history = array(); //keep all changes
18
-		var $path = ''; //path to the iamge
19
-		var $session = null;
20
-		/**
21
-		 * constructor
22
-		 *
23
-		 * @param string $path the path to the image 
24
-		 * @param object $session an instance of session class
25
-		 */
26
-		function __construct($path, &$session)
27
-		{
28
-			$this->path = $path;
29
-			$this->session = &$session;
30
-			if(!isset($_SESSION[$this->path]))
31
-			{
32
-				$_SESSION[$this->path] = array();
33
-			}
7
+    /**
8
+     * class history
9
+     * this class used to keep records of any changed to uploaded images under a session
10
+     * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
11
+     * @link www.phpletter.com
12
+     * @since 22/May/2007
13
+     *
14
+     */
15
+    class History
16
+    {
17
+        var $history = array(); //keep all changes
18
+        var $path = ''; //path to the iamge
19
+        var $session = null;
20
+        /**
21
+         * constructor
22
+         *
23
+         * @param string $path the path to the image 
24
+         * @param object $session an instance of session class
25
+         */
26
+        function __construct($path, &$session)
27
+        {
28
+            $this->path = $path;
29
+            $this->session = &$session;
30
+            if(!isset($_SESSION[$this->path]))
31
+            {
32
+                $_SESSION[$this->path] = array();
33
+            }
34 34
 			
35
-		}
36
-		/**
37
-		 * constructor
38
-		 *
39
-		 * @param string $path the path to the image 
40
-		 * @param object $session an instance of session class
41
-		 */		
42
-		function History($path, &$session)
43
-		{
44
-			$this->__construct($path, $session);
45
-		}
35
+        }
36
+        /**
37
+         * constructor
38
+         *
39
+         * @param string $path the path to the image 
40
+         * @param object $session an instance of session class
41
+         */		
42
+        function History($path, &$session)
43
+        {
44
+            $this->__construct($path, $session);
45
+        }
46 46
 
47
-		/**
48
-		 * keep tracks of each changes made to an image
49
-		 *
50
-		 * @param string $key
51
-		 * @param string $info   array('name', 'restorable', 'is_original')
52
-		 */
53
-		function add($info)
54
-		{
55
-			$_SESSION[$this->path][] = $info;
56
-		}
57
-		/**
58
-		 * get the lastest changes for restore
59
-		 *
60
-		 * @return array array('name', 'restorable', 'is_original')
61
-		 */
62
-		function getNumRestorable()
63
-		{
64
-			$output = 0;
65
-			if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]))
66
-			{
67
-				foreach($_SESSION[$this->path] as $k=>$v)
68
-				{
69
-					if(!empty($v['restorable']) && empty($v['is_original']))
70
-					{
71
-						if(file_exists($this->session->getSessionDir() . $v['name']))
72
-						{
73
-							$output++;
74
-						}else 
75
-						{
47
+        /**
48
+         * keep tracks of each changes made to an image
49
+         *
50
+         * @param string $key
51
+         * @param string $info   array('name', 'restorable', 'is_original')
52
+         */
53
+        function add($info)
54
+        {
55
+            $_SESSION[$this->path][] = $info;
56
+        }
57
+        /**
58
+         * get the lastest changes for restore
59
+         *
60
+         * @return array array('name', 'restorable', 'is_original')
61
+         */
62
+        function getNumRestorable()
63
+        {
64
+            $output = 0;
65
+            if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]))
66
+            {
67
+                foreach($_SESSION[$this->path] as $k=>$v)
68
+                {
69
+                    if(!empty($v['restorable']) && empty($v['is_original']))
70
+                    {
71
+                        if(file_exists($this->session->getSessionDir() . $v['name']))
72
+                        {
73
+                            $output++;
74
+                        }else 
75
+                        {
76 76
 							
77
-						}
77
+                        }
78 78
 						
79
-					}
80
-				}
81
-			}
82
-			return $output;
83
-		}
79
+                    }
80
+                }
81
+            }
82
+            return $output;
83
+        }
84 84
 
85
-		/**
86
-		 * get the path of image which keep the lastest changes
87
-		 *
88
-		 * @return  return empty array when failed
89
-		 */
90
-		function getLastestRestorable()
91
-		{
92
-			if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]) && sizeof($_SESSION[$this->path]))
93
-			{	
94
-				$sessionImages = array_reverse($_SESSION[$this->path], true);
95
-				$lastestKey = '';
96
-				foreach($sessionImages as $k=>$v)
97
-				{
98
-					if($v['restorable'] && empty($v['is_original']) && file_exists($this->session->getSessionDir() . $v['name']))
99
-					{
100
-						return $sessionImages[$k];
101
-					}
102
-				}							
85
+        /**
86
+         * get the path of image which keep the lastest changes
87
+         *
88
+         * @return  return empty array when failed
89
+         */
90
+        function getLastestRestorable()
91
+        {
92
+            if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]) && sizeof($_SESSION[$this->path]))
93
+            {	
94
+                $sessionImages = array_reverse($_SESSION[$this->path], true);
95
+                $lastestKey = '';
96
+                foreach($sessionImages as $k=>$v)
97
+                {
98
+                    if($v['restorable'] && empty($v['is_original']) && file_exists($this->session->getSessionDir() . $v['name']))
99
+                    {
100
+                        return $sessionImages[$k];
101
+                    }
102
+                }							
103 103
 				
104
-			}
105
-			return  array();
104
+            }
105
+            return  array();
106 106
 			
107
-		}
108
-		/**
109
-		 * get the original image which is kept in the session folder
110
-		 *
111
-		 * @return array
112
-		 */
113
-		function getOriginalImage()
114
-		{
115
-			$outputs = array();
116
-			if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]))
117
-			{
118
-				$sessionImages = array_reverse($_SESSION[$this->path], true);
119
-				foreach($sessionImages as $k=>$v)
120
-				{
121
-					if(!empty($v['is_original']))
122
-					{
123
-						if(file_exists($this->session->getSessionDir() . $v['name']))
124
-						{
125
-							return array('info'=>$_SESSION[$this->path][$k], 'key'=>$k);
126
-						}
107
+        }
108
+        /**
109
+         * get the original image which is kept in the session folder
110
+         *
111
+         * @return array
112
+         */
113
+        function getOriginalImage()
114
+        {
115
+            $outputs = array();
116
+            if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]))
117
+            {
118
+                $sessionImages = array_reverse($_SESSION[$this->path], true);
119
+                foreach($sessionImages as $k=>$v)
120
+                {
121
+                    if(!empty($v['is_original']))
122
+                    {
123
+                        if(file_exists($this->session->getSessionDir() . $v['name']))
124
+                        {
125
+                            return array('info'=>$_SESSION[$this->path][$k], 'key'=>$k);
126
+                        }
127 127
 						
128
-					}
129
-				}
130
-			}	
131
-			return $outputs;
128
+                    }
129
+                }
130
+            }	
131
+            return $outputs;
132 132
 				
133
-		}
134
-		/**
135
-		 * remove the lastest restorable state
136
-		 *
137
-		 * @return boolean
138
-		 */
139
-		function restore()
140
-		{
141
-			if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]) && sizeof($_SESSION[$this->path]))
142
-			{
143
-				$sessionImages = array_reverse($_SESSION[$this->path], true);
144
-				$lastestKey = '';
145
-				foreach($sessionImages as $k=>$v)
146
-				{
147
-					if($v['restorable'] && empty($v['is_original']))
148
-					{
149
-						unset($_SESSION[$k]);
150
-						return true;
151
-					}
152
-				}
153
-			}
154
-			return false;		
155
-		}
133
+        }
134
+        /**
135
+         * remove the lastest restorable state
136
+         *
137
+         * @return boolean
138
+         */
139
+        function restore()
140
+        {
141
+            if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]) && sizeof($_SESSION[$this->path]))
142
+            {
143
+                $sessionImages = array_reverse($_SESSION[$this->path], true);
144
+                $lastestKey = '';
145
+                foreach($sessionImages as $k=>$v)
146
+                {
147
+                    if($v['restorable'] && empty($v['is_original']))
148
+                    {
149
+                        unset($_SESSION[$k]);
150
+                        return true;
151
+                    }
152
+                }
153
+            }
154
+            return false;		
155
+        }
156 156
 
157 157
 		
158 158
 		
159
-	}
159
+    }
160 160
 ?>
161 161
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
2
+	if (!defined('AJAX_INIT_DONE'))
3 3
 	{
4 4
 		die('Permission denied');
5 5
 	}
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		{
28 28
 			$this->path = $path;
29 29
 			$this->session = &$session;
30
-			if(!isset($_SESSION[$this->path]))
30
+			if (!isset($_SESSION[$this->path]))
31 31
 			{
32 32
 				$_SESSION[$this->path] = array();
33 33
 			}
@@ -62,16 +62,16 @@  discard block
 block discarded – undo
62 62
 		function getNumRestorable()
63 63
 		{
64 64
 			$output = 0;
65
-			if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]))
65
+			if (isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]))
66 66
 			{
67
-				foreach($_SESSION[$this->path] as $k=>$v)
67
+				foreach ($_SESSION[$this->path] as $k=>$v)
68 68
 				{
69
-					if(!empty($v['restorable']) && empty($v['is_original']))
69
+					if (!empty($v['restorable']) && empty($v['is_original']))
70 70
 					{
71
-						if(file_exists($this->session->getSessionDir() . $v['name']))
71
+						if (file_exists($this->session->getSessionDir().$v['name']))
72 72
 						{
73 73
 							$output++;
74
-						}else 
74
+						} else 
75 75
 						{
76 76
 							
77 77
 						}
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 		 */
90 90
 		function getLastestRestorable()
91 91
 		{
92
-			if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]) && sizeof($_SESSION[$this->path]))
92
+			if (isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]) && sizeof($_SESSION[$this->path]))
93 93
 			{	
94 94
 				$sessionImages = array_reverse($_SESSION[$this->path], true);
95 95
 				$lastestKey = '';
96
-				foreach($sessionImages as $k=>$v)
96
+				foreach ($sessionImages as $k=>$v)
97 97
 				{
98
-					if($v['restorable'] && empty($v['is_original']) && file_exists($this->session->getSessionDir() . $v['name']))
98
+					if ($v['restorable'] && empty($v['is_original']) && file_exists($this->session->getSessionDir().$v['name']))
99 99
 					{
100 100
 						return $sessionImages[$k];
101 101
 					}
@@ -113,14 +113,14 @@  discard block
 block discarded – undo
113 113
 		function getOriginalImage()
114 114
 		{
115 115
 			$outputs = array();
116
-			if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]))
116
+			if (isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]))
117 117
 			{
118 118
 				$sessionImages = array_reverse($_SESSION[$this->path], true);
119
-				foreach($sessionImages as $k=>$v)
119
+				foreach ($sessionImages as $k=>$v)
120 120
 				{
121
-					if(!empty($v['is_original']))
121
+					if (!empty($v['is_original']))
122 122
 					{
123
-						if(file_exists($this->session->getSessionDir() . $v['name']))
123
+						if (file_exists($this->session->getSessionDir().$v['name']))
124 124
 						{
125 125
 							return array('info'=>$_SESSION[$this->path][$k], 'key'=>$k);
126 126
 						}
@@ -138,13 +138,13 @@  discard block
 block discarded – undo
138 138
 		 */
139 139
 		function restore()
140 140
 		{
141
-			if(isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]) && sizeof($_SESSION[$this->path]))
141
+			if (isset($_SESSION[$this->path]) && is_array($_SESSION[$this->path]) && sizeof($_SESSION[$this->path]))
142 142
 			{
143 143
 				$sessionImages = array_reverse($_SESSION[$this->path], true);
144 144
 				$lastestKey = '';
145
-				foreach($sessionImages as $k=>$v)
145
+				foreach ($sessionImages as $k=>$v)
146 146
 				{
147
-					if($v['restorable'] && empty($v['is_original']))
147
+					if ($v['restorable'] && empty($v['is_original']))
148 148
 					{
149 149
 						unset($_SESSION[$k]);
150 150
 						return true;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@
 block discarded – undo
71 71
 						if(file_exists($this->session->getSessionDir() . $v['name']))
72 72
 						{
73 73
 							$output++;
74
-						}else 
74
+						} else 
75 75
 						{
76 76
 							
77 77
 						}
Please login to merge, or discard this patch.
phpmyfaq/admin/editor/plugins/ajaxfilemanager/inc/class.image.php 4 patches
Doc Comments   +4 added lines, -7 removed lines patch added patch discarded remove patch
@@ -85,7 +85,6 @@  discard block
 block discarded – undo
85 85
 	    /**
86 86
 		 * append to errors array and shown the each error when the debug turned on  
87 87
 		 * 
88
-		 * @param  string $string
89 88
 		 * @return void
90 89
      * @access private
91 90
      * @copyright this function originally come from Andy's php 
@@ -349,7 +348,7 @@  discard block
 block discarded – undo
349 348
      * @param boolean $unchangeIfsmaller keep the orignial size if the orignial smaller than the new size
350 349
      * 
351 350
      *
352
-     * @return mixed none or PEAR_error
351
+     * @return boolean none or PEAR_error
353 352
      */
354 353
 	function resize( $new_x, $new_y, $constraint= false, $unchangeIfsmaller=false)
355 354
 	{
@@ -414,11 +413,9 @@  discard block
 block discarded – undo
414 413
  	/**
415 414
      * resize the image and return the thumbnail image  details array("width"=>, "height"=>, "name")
416 415
      *
417
-     * @param string $fileName 
418 416
      * @param int $new_x the thumbnail width
419 417
      * @param int $new_y the thumbnail height
420
-     * @param string $mode can be save, view and both
421
-     * @return unknown
418
+     * @return boolean
422 419
      */
423 420
 	function _resize( $new_x, $new_y) 
424 421
 	{
@@ -576,7 +573,7 @@  discard block
 block discarded – undo
576 573
     /**
577 574
      * flip horizontal
578 575
      *
579
-     * @return string
576
+     * @return boolean
580 577
      */
581 578
     function flipHorizontal()
582 579
     {
@@ -791,7 +788,7 @@  discard block
 block discarded – undo
791 788
      *  @access private
792 789
      *  @param $dst_w width
793 790
      * 	@param $dst_h height
794
-     * 	@return boolean
791
+     * 	@return boolean|null
795 792
      * 	@copyright original from noname at nivelzero dot ro
796 793
      */
797 794
     function _createFinalImageHandler($dst_w, $dst_h)
Please login to merge, or discard this patch.
Indentation   +379 added lines, -379 removed lines patch added patch discarded remove patch
@@ -1,98 +1,98 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
3
-	{
4
-		die('Permission denied');
5
-	}
2
+    if(!defined('AJAX_INIT_DONE'))
3
+    {
4
+        die('Permission denied');
5
+    }
6 6
 ?><?php
7
-	/**
8
-	 * this class provide functions to edit an image, e.g. resize, rotate, flip, crop
9
-	 * @author Logan Cai cailongqun [at] yahoo [dot] com [dot] cn
10
-	 * @link  www.phpletter.com
11
-	 * @version 0.9
12
-	 * @since 14/May/2007
13
-	 * @name Image
14
-	 * 
15
-	 */
7
+    /**
8
+     * this class provide functions to edit an image, e.g. resize, rotate, flip, crop
9
+     * @author Logan Cai cailongqun [at] yahoo [dot] com [dot] cn
10
+     * @link  www.phpletter.com
11
+     * @version 0.9
12
+     * @since 14/May/2007
13
+     * @name Image
14
+     * 
15
+     */
16 16
 	
17 17
 	
18 18
 	
19 19
 	
20
-	class Image
21
-	{
22
-		var $_debug = false; 
23
-		var $_errors = array();
24
-		var $gdInfo = array(); //keep all information of GD extension
25
-		var $_imgOrig = null; //the hanlder of original image
26
-		var $_imgFinal = null; //the handler of final image
27
-		var $imageFile  = null;  
20
+    class Image
21
+    {
22
+        var $_debug = false; 
23
+        var $_errors = array();
24
+        var $gdInfo = array(); //keep all information of GD extension
25
+        var $_imgOrig = null; //the hanlder of original image
26
+        var $_imgFinal = null; //the handler of final image
27
+        var $imageFile  = null;  
28 28
     var $transparentColorRed = null;
29 29
     var $transparentColorGreen = null;
30 30
     var $transparentColorBlue = null;		 
31 31
     var $chmod = 0755;
32 32
     var $_imgInfoOrig = array(
33
-    	'name'=>'',
34
-    	'ext'=>'',
35
-    	'size'=>'',
36
-    	'width'=>'',
37
-    	'height'=>'',
38
-    	'type'=>'',
39
-    	'path'=>'',
33
+        'name'=>'',
34
+        'ext'=>'',
35
+        'size'=>'',
36
+        'width'=>'',
37
+        'height'=>'',
38
+        'type'=>'',
39
+        'path'=>'',
40 40
     );    
41 41
     var $_imgInfoFinal = array(
42
-    	'name'=>'',
43
-    	'ext'=>'',
44
-    	'size'=>'',
45
-    	'width'=>'',
46
-    	'height'=>'', 
47
-    	'type'=>'',   
48
-    	'path'=>'',
42
+        'name'=>'',
43
+        'ext'=>'',
44
+        'size'=>'',
45
+        'width'=>'',
46
+        'height'=>'', 
47
+        'type'=>'',   
48
+        'path'=>'',
49 49
     );		
50
-		var $_imgQuality = 90;
51
-		/**
52
-		 * constructor
53
-		 *
54
-		 * @param boolean $debug
55
-		 * @return Image
56
-		 */
50
+        var $_imgQuality = 90;
51
+        /**
52
+         * constructor
53
+         *
54
+         * @param boolean $debug
55
+         * @return Image
56
+         */
57 57
 		
58
-		function __construct($debug = false)
59
-		{
60
-			$this->enableDebug($debug);
61
-			$this->gdInfo = $this->getGDInfo();			
62
-		}
63
-		function Image($debug = false)
64
-		{
65
-			$this->__construct($debug);
66
-		}
67
-		/**
68
-		 * enable to debug
69
-		 *
70
-		 * @param boolean $value
71
-		 */
72
-		function enableDebug($value)
73
-		{
74
-			$this->_debug = ($value?true:false);
75
-		}
76
-		/**
77
-		 * check if debug enable
78
-		 * @return boolean
79
-		 */
80
-		function _isDebugEnable()
81
-		{
82
-			return $this->_debug;
83
-		}
58
+        function __construct($debug = false)
59
+        {
60
+            $this->enableDebug($debug);
61
+            $this->gdInfo = $this->getGDInfo();			
62
+        }
63
+        function Image($debug = false)
64
+        {
65
+            $this->__construct($debug);
66
+        }
67
+        /**
68
+         * enable to debug
69
+         *
70
+         * @param boolean $value
71
+         */
72
+        function enableDebug($value)
73
+        {
74
+            $this->_debug = ($value?true:false);
75
+        }
76
+        /**
77
+         * check if debug enable
78
+         * @return boolean
79
+         */
80
+        function _isDebugEnable()
81
+        {
82
+            return $this->_debug;
83
+        }
84 84
 
85
-	    /**
86
-		 * append to errors array and shown the each error when the debug turned on  
87
-		 * 
88
-		 * @param  string $string
89
-		 * @return void
90
-     * @access private
91
-     * @copyright this function originally come from Andy's php 
92
-	 */
85
+        /**
86
+         * append to errors array and shown the each error when the debug turned on  
87
+         * 
88
+         * @param  string $string
89
+         * @return void
90
+         * @access private
91
+         * @copyright this function originally come from Andy's php 
92
+         */
93 93
     function _debug($value)
94 94
     {
95
-    		$this->_errors[] = $value;
95
+            $this->_errors[] = $value;
96 96
         if ($this->_debug) 
97 97
         {
98 98
             echo $value . "<br />\n";
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
      */
105 105
     function showErrors()
106 106
     {
107
-    	if(sizeof($this->_errors))
108
-    	{
109
-    		foreach($this->_errors as $error)
110
-    		{
111
-    			echo $error . "<br />\n";
112
-    		}
113
-    	}
107
+        if(sizeof($this->_errors))
108
+        {
109
+            foreach($this->_errors as $error)
110
+            {
111
+                echo $error . "<br />\n";
112
+            }
113
+        }
114 114
     }
115 115
     /**
116 116
      * Load an image from the file system.
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         }
131 131
         if($ext == "gif")
132 132
         {
133
-             // the following part gets the transparency color for a gif file
133
+                // the following part gets the transparency color for a gif file
134 134
             // this code is from the PHP manual and is written by
135 135
             // fred at webblake dot net and webmaster at webnetwizard dotco dotuk, thanks!
136 136
             $fp = @fopen($filename, "rb");
@@ -153,22 +153,22 @@  discard block
 block discarded – undo
153 153
             return false;
154 154
         }else 
155 155
         {
156
-        	$this->imageFile = $filename;
157
-			    $this->_imgInfoOrig = array(
158
-			    	'name'=>basename($filename),
159
-			    	'ext'=>$ext,
160
-			    	'size'=>filesize($filename),
161
-			    	'path'=>$filename,
162
-			    );        	
163
-			    $imgInfo = $this->_getImageInfo($filename);
164
-			    if(sizeof($imgInfo))
165
-			    {
166
-			    	foreach($imgInfo as $k=>$v)
167
-			    	{
168
-			    		$this->_imgInfoOrig[$k] = $v;
169
-			    		$this->_imgInfoFinal[$k] = $v;
170
-			    	}
171
-			    }
156
+            $this->imageFile = $filename;
157
+                $this->_imgInfoOrig = array(
158
+                    'name'=>basename($filename),
159
+                    'ext'=>$ext,
160
+                    'size'=>filesize($filename),
161
+                    'path'=>$filename,
162
+                );        	
163
+                $imgInfo = $this->_getImageInfo($filename);
164
+                if(sizeof($imgInfo))
165
+                {
166
+                    foreach($imgInfo as $k=>$v)
167
+                    {
168
+                        $this->_imgInfoOrig[$k] = $v;
169
+                        $this->_imgInfoFinal[$k] = $v;
170
+                    }
171
+                }
172 172
 			    
173 173
         }
174 174
         return true;
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
      */
185 185
     function loadImageFromString($string)
186 186
     {
187
-    		$this->imageFile = $filename;
187
+            $this->imageFile = $filename;
188 188
         $this->_imgOrig = imagecreatefromstring($string);
189 189
         if (!$this->_imgOrig) {
190 190
             $this->_debug('The image (supplied as a string) could not be created.');
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
             return false;
240 240
         }else 
241 241
         {
242
-        	$this->_imgInfoFinal['size'] = @filesize($filename);
243
-        	@chmod($filename, intval($this->chmod, 8));
242
+            $this->_imgInfoFinal['size'] = @filesize($filename);
243
+            @chmod($filename, intval($this->chmod, 8));
244 244
         }
245 245
 
246 246
         return true;
@@ -290,16 +290,16 @@  discard block
 block discarded – undo
290 290
     }    
291 291
     
292 292
     /**
293
-	 * Used for cropping image
294
-	 * 
295
-	 * @param  int $dst_x
296
-	 * @param  int $dst_y
297
-	 * @param  int $dst_w
298
-	 * @param  int $dst_h
299
-	 * @return bool
293
+     * Used for cropping image
294
+     * 
295
+     * @param  int $dst_x
296
+     * @param  int $dst_y
297
+     * @param  int $dst_w
298
+     * @param  int $dst_h
299
+     * @return bool
300 300
      * @access public
301 301
      * @copyright this function originally come from Andy's php 
302
-	 */  
302
+     */  
303 303
     function crop($dst_x, $dst_y, $dst_w, $dst_h)
304 304
     {
305 305
         if ($this->_imgOrig == null) {
@@ -317,18 +317,18 @@  discard block
 block discarded – undo
317 317
         $this->_createFinalImageHandler($dst_w, $dst_h);
318 318
         if ($this->gdInfo['Truecolor Support']) 
319 319
         {
320
-            	if(!@imagecopyresampled($this->_imgFinal, $this->_imgOrig, 0, 0, $dst_x, $dst_y, $dst_w, $dst_h, $dst_w, $dst_h))
321
-            	{
322
-            		$this->_debug('Unable crop the image.');
323
-            		return false;
324
-            	}            
320
+                if(!@imagecopyresampled($this->_imgFinal, $this->_imgOrig, 0, 0, $dst_x, $dst_y, $dst_w, $dst_h, $dst_w, $dst_h))
321
+                {
322
+                    $this->_debug('Unable crop the image.');
323
+                    return false;
324
+                }            
325 325
         } else 
326 326
         {
327
-          	if(!@imagecopyresized($this->_imgFinal, $this->_imgOrig, 0, 0, $dst_x, $dst_y, $dst_w, $dst_h, $dst_w, $dst_h))
328
-          	{
329
-           		$this->_debug('Unable crop the image.');
330
-          		return false;           		
331
-          	}
327
+                if(!@imagecopyresized($this->_imgFinal, $this->_imgOrig, 0, 0, $dst_x, $dst_y, $dst_w, $dst_h, $dst_w, $dst_h))
328
+                {
329
+                    $this->_debug('Unable crop the image.');
330
+                    return false;           		
331
+                }
332 332
             
333 333
         }
334 334
         $this->_imgInfoFinal['width'] = $dst_w;
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
     }
338 338
   
339 339
     
340
-	/**
340
+    /**
341 341
      * Resize the Image in the X and/or Y direction
342 342
      * If either is 0 it will be scaled proportionally
343 343
      *
@@ -351,123 +351,123 @@  discard block
 block discarded – undo
351 351
      *
352 352
      * @return mixed none or PEAR_error
353 353
      */
354
-	function resize( $new_x, $new_y, $constraint= false, $unchangeIfsmaller=false)
355
-	{
356
-		if(!$this->_imgOrig)
357
-		{
358
-			$this->_debug('No image fould.');
359
-			return false;
360
-		}		
354
+    function resize( $new_x, $new_y, $constraint= false, $unchangeIfsmaller=false)
355
+    {
356
+        if(!$this->_imgOrig)
357
+        {
358
+            $this->_debug('No image fould.');
359
+            return false;
360
+        }		
361 361
 		
362
-		$new_x = intval($new_x);
363
-		$new_y = intval($new_y);
364
-		if($new_x <=0 || $new_y <= 0)
365
-		{
366
-			$this->_debug('either of new width or height can be zeor or less.');
367
-		}else 
368
-		{
362
+        $new_x = intval($new_x);
363
+        $new_y = intval($new_y);
364
+        if($new_x <=0 || $new_y <= 0)
365
+        {
366
+            $this->_debug('either of new width or height can be zeor or less.');
367
+        }else 
368
+        {
369 369
 		
370
-			if($constraint)
371
-			{
372
-				if($new_x < 1 && $new_y < 1)
373
-				{
374
-					$new_x = $this->_imgInfoOrig['width'];
375
-					$new_y = $this->_imgInfoOrig['height'];
376
-				}elseif($new_x < 1)
377
-				{
378
-					$new_x = floor($new_y / $this->_imgInfoOrig['height'] * $this->_imgInfoOrig['width']);
370
+            if($constraint)
371
+            {
372
+                if($new_x < 1 && $new_y < 1)
373
+                {
374
+                    $new_x = $this->_imgInfoOrig['width'];
375
+                    $new_y = $this->_imgInfoOrig['height'];
376
+                }elseif($new_x < 1)
377
+                {
378
+                    $new_x = floor($new_y / $this->_imgInfoOrig['height'] * $this->_imgInfoOrig['width']);
379 379
 	
380
-				}elseif($new_y < 1)
381
-				{
382
-					$new_y = floor($new_x / $this->_imgInfoOrig['width'] * $this->_imgInfoOrig['height']);
383
-				}else
384
-				{
385
-					$scale = min($new_x/$this->_imgInfoOrig['width'], $new_y/$this->_imgInfoOrig['height']) ;
386
-					$new_x = floor($scale*$this->_imgInfoOrig['width']);
387
-					$new_y = floor($scale*$this->_imgInfoOrig['height']);
388
-				}						
389
-			}
390
-			if($unchangeIfsmaller)
391
-			{
392
-				if($this->_imgInfoOrig['width'] < $new_x && $this->_imgInfoOrig['height'] < $new_y )
393
-				{
394
-					$new_x = $this->_imgInfoOrig['width'];
395
-					$new_y = $this->_imgInfoOrig['height'];
396
-				}
397
-			}
380
+                }elseif($new_y < 1)
381
+                {
382
+                    $new_y = floor($new_x / $this->_imgInfoOrig['width'] * $this->_imgInfoOrig['height']);
383
+                }else
384
+                {
385
+                    $scale = min($new_x/$this->_imgInfoOrig['width'], $new_y/$this->_imgInfoOrig['height']) ;
386
+                    $new_x = floor($scale*$this->_imgInfoOrig['width']);
387
+                    $new_y = floor($scale*$this->_imgInfoOrig['height']);
388
+                }						
389
+            }
390
+            if($unchangeIfsmaller)
391
+            {
392
+                if($this->_imgInfoOrig['width'] < $new_x && $this->_imgInfoOrig['height'] < $new_y )
393
+                {
394
+                    $new_x = $this->_imgInfoOrig['width'];
395
+                    $new_y = $this->_imgInfoOrig['height'];
396
+                }
397
+            }
398 398
 		
399 399
 			
400 400
 			
401
-			if(is_null($this->_imgOrig))
402
-			{
403
-				$this->loadImage($filePath);
404
-			}
405
-			if(sizeof($this->_errors) == 0)
406
-			{
407
-				return $this->_resize($new_x, $new_y);
408
-			}			
409
-		}
401
+            if(is_null($this->_imgOrig))
402
+            {
403
+                $this->loadImage($filePath);
404
+            }
405
+            if(sizeof($this->_errors) == 0)
406
+            {
407
+                return $this->_resize($new_x, $new_y);
408
+            }			
409
+        }
410 410
 
411
-		return false;
411
+        return false;
412 412
 		
413
-	} // End resize    
414
- 	/**
415
-     * resize the image and return the thumbnail image  details array("width"=>, "height"=>, "name")
416
-     *
417
-     * @param string $fileName 
418
-     * @param int $new_x the thumbnail width
419
-     * @param int $new_y the thumbnail height
420
-     * @param string $mode can be save, view and both
421
-     * @return unknown
422
-     */
423
-	function _resize( $new_x, $new_y) 
424
-	{
425
-		$this->_createFinalImageHandler($new_x, $new_y);
413
+    } // End resize    
414
+        /**
415
+         * resize the image and return the thumbnail image  details array("width"=>, "height"=>, "name")
416
+         *
417
+         * @param string $fileName 
418
+         * @param int $new_x the thumbnail width
419
+         * @param int $new_y the thumbnail height
420
+         * @param string $mode can be save, view and both
421
+         * @return unknown
422
+         */
423
+    function _resize( $new_x, $new_y) 
424
+    {
425
+        $this->_createFinalImageHandler($new_x, $new_y);
426 426
     // hacks fot transparency of png24 files
427 427
     if ($this->_imgInfoOrig['type'] == 'png') 
428 428
     {    
429 429
         @imagealphablending($this->_imgFinal, false);
430
-				if(function_exists('ImageCopyResampled'))
431
-				{
432
-					@imagecopyresampled($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
433
-				} else {
434
-					@imagecopyresized($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
435
-				} 
430
+                if(function_exists('ImageCopyResampled'))
431
+                {
432
+                    @imagecopyresampled($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
433
+                } else {
434
+                    @imagecopyresized($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
435
+                } 
436 436
         @imagesavealpha($this->_imgFinal, true);
437 437
 
438 438
     }else 
439 439
     {//for the rest image
440
-			if(function_exists('ImageCopyResampled'))
441
-			{
442
-				@imagecopyresampled($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
443
-			} else {
444
-				@imagecopyresized($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
445
-			}    	
440
+            if(function_exists('ImageCopyResampled'))
441
+            {
442
+                @imagecopyresampled($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
443
+            } else {
444
+                @imagecopyresized($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
445
+            }    	
446 446
     }
447 447
 
448 448
 		
449
-		$this->_imgInfoFinal['width'] = $new_x;
450
-		$this->_imgInfoFinal['height'] = $new_y;
451
-		$this->_imgInfoFinal['name'] = basename($this->_imgInfoOrig['name']);
452
-		$this->_imgInfoFinal['path'] = $this->_imgInfoOrig['path'];		
453
-		if($this->_imgFinal)
454
-		{
455
-			return true;
456
-		}else 
457
-		{			
458
-			$this->_debug('Unable to resize the image on the fly.');
459
-			return false;
449
+        $this->_imgInfoFinal['width'] = $new_x;
450
+        $this->_imgInfoFinal['height'] = $new_y;
451
+        $this->_imgInfoFinal['name'] = basename($this->_imgInfoOrig['name']);
452
+        $this->_imgInfoFinal['path'] = $this->_imgInfoOrig['path'];		
453
+        if($this->_imgFinal)
454
+        {
455
+            return true;
456
+        }else 
457
+        {			
458
+            $this->_debug('Unable to resize the image on the fly.');
459
+            return false;
460 460
 							
461
-		}
461
+        }
462 462
 
463
-	}   
463
+    }   
464 464
     /**
465
-	 * Get the extension of a file name
466
-	 * 
467
-	 * @param  string $file
468
- 	 * @return string
465
+     * Get the extension of a file name
466
+     * 
467
+     * @param  string $file
468
+     * @return string
469 469
      * @copyright this function originally come from Andy's php 
470
-	 */
470
+     */
471 471
     function _getExtension($file)
472 472
     {
473 473
         $ext = '';
@@ -477,29 +477,29 @@  discard block
 block discarded – undo
477 477
         return $ext;
478 478
     }
479 479
 
480
-	    /**
481
-		 * Validate whether image reading/writing routines are valid.
482
-		 * 
483
-		 * @param  string $filename
484
-		 * @param  string $extension
485
-		 * @param  string $function
486
-		 * @param  bool   $write
487
-		 * @return bool
488
-     * @access private
489
-     * @copyright this function originally come from Andy's php 
490
-	 */
480
+        /**
481
+         * Validate whether image reading/writing routines are valid.
482
+         * 
483
+         * @param  string $filename
484
+         * @param  string $extension
485
+         * @param  string $function
486
+         * @param  bool   $write
487
+         * @return bool
488
+         * @access private
489
+         * @copyright this function originally come from Andy's php 
490
+         */
491 491
     function _isSupported($filename, $extension, $function, $write = false)
492 492
     {
493 493
 
494
-       $giftype = ($write) ? ' Create Support' : ' Read Support';
494
+        $giftype = ($write) ? ' Create Support' : ' Read Support';
495 495
         $support = strtoupper($extension) . ($extension == 'gif' ? $giftype : ' Support');
496 496
 
497 497
         if (isset($this->gdInfo['JPG Support']) && ($extension=='jpg' || $extension=='jpeg')) 
498 498
         {
499
-        	$extension='jpg';
499
+            $extension='jpg';
500 500
         }else if (isset($this->gdInfo['JPEG Support']) && ($extension=='jpg' || $extension=='jpeg')) 
501 501
         {
502
-        	$extension='jpeg';
502
+            $extension='jpeg';
503 503
         }
504 504
         if (!isset($this->gdInfo[$support]) || $this->gdInfo[$support] == false) {
505 505
             $request = ($write) ? 'saving' : 'reading';
@@ -522,47 +522,47 @@  discard block
 block discarded – undo
522 522
      */
523 523
     function flip($direction="horizontal")
524 524
     {
525
-				$this->_createFinalImageHandler($this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
526
-			if($direction != "vertical")
527
-			{
528
-				$dst_x = 0;
529
-				$dst_y = 0;
530
-				$src_x = $this->_imgInfoOrig['width'] -1;
531
-				$src_y = 0;
532
-				$dst_w = $this->_imgInfoOrig['width'];
533
-				$dst_h = $this->_imgInfoOrig['height'];
534
-				$src_w = 0 - $this->_imgInfoOrig['width'];
535
-				$src_h = $this->_imgInfoOrig['height'];
525
+                $this->_createFinalImageHandler($this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
526
+            if($direction != "vertical")
527
+            {
528
+                $dst_x = 0;
529
+                $dst_y = 0;
530
+                $src_x = $this->_imgInfoOrig['width'] -1;
531
+                $src_y = 0;
532
+                $dst_w = $this->_imgInfoOrig['width'];
533
+                $dst_h = $this->_imgInfoOrig['height'];
534
+                $src_w = 0 - $this->_imgInfoOrig['width'];
535
+                $src_h = $this->_imgInfoOrig['height'];
536 536
 				
537
-			}else 
538
-			{
539
-				$dst_x = 0;
540
-				$dst_y = 0;
541
-				$src_x = 0;
542
-				$src_y = $this->_imgInfoOrig['height'] - 1;
543
-				$dst_w = $this->_imgInfoOrig['width'];
544
-				$dst_h = $this->_imgInfoOrig['height'];
545
-				$src_w = $this->_imgInfoOrig['width'];
546
-				$src_h = 0 - $this->_imgInfoOrig['height'];				
547
-			}			
548
-				if(function_exists('ImageCopyResampled')){
549
-					imagecopyresampled($this->_imgFinal, $this->_imgOrig, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
550
-				} else {
551
-					imagecopyresized($this->_imgFinal, $this->_imgOrig, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
552
-				}
553
-				$this->_imgInfoFinal['width'] = $dst_w;
554
-				$this->_imgInfoFinal['height'] = $dst_h;
555
-				$this->_imgInfoFinal['name'] = basename($this->imageFile);
556
-				$this->_imgInfoFinal['path'] = $this->imageFile;		
557
-				if($this->_imgFinal)
558
-				{
559
-					return true;
560
-				}else 
561
-				{			
562
-					$this->_debug('Unable to resize the image on the fly.');	
563
-					return false;
537
+            }else 
538
+            {
539
+                $dst_x = 0;
540
+                $dst_y = 0;
541
+                $src_x = 0;
542
+                $src_y = $this->_imgInfoOrig['height'] - 1;
543
+                $dst_w = $this->_imgInfoOrig['width'];
544
+                $dst_h = $this->_imgInfoOrig['height'];
545
+                $src_w = $this->_imgInfoOrig['width'];
546
+                $src_h = 0 - $this->_imgInfoOrig['height'];				
547
+            }			
548
+                if(function_exists('ImageCopyResampled')){
549
+                    imagecopyresampled($this->_imgFinal, $this->_imgOrig, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
550
+                } else {
551
+                    imagecopyresized($this->_imgFinal, $this->_imgOrig, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
552
+                }
553
+                $this->_imgInfoFinal['width'] = $dst_w;
554
+                $this->_imgInfoFinal['height'] = $dst_h;
555
+                $this->_imgInfoFinal['name'] = basename($this->imageFile);
556
+                $this->_imgInfoFinal['path'] = $this->imageFile;		
557
+                if($this->_imgFinal)
558
+                {
559
+                    return true;
560
+                }else 
561
+                {			
562
+                    $this->_debug('Unable to resize the image on the fly.');	
563
+                    return false;
564 564
 								
565
-				}   	
565
+                }   	
566 566
     }
567 567
     /**
568 568
      * flip vertically
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
      */
572 572
     function flipVertical()
573 573
     {
574
-    	return $this->flip('vertical');
574
+        return $this->flip('vertical');
575 575
     }
576 576
     /**
577 577
      * flip horizontal
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
      */
581 581
     function flipHorizontal()
582 582
     {
583
-    	return $this->flip('horizontal');
583
+        return $this->flip('horizontal');
584 584
     }
585 585
 
586 586
 
@@ -600,13 +600,13 @@  discard block
 block discarded – undo
600 600
             $outputs = gd_info();
601 601
             if(isset($outputs['JPEG Support']))
602 602
             {
603
-            	$outputs['JPG Support'] = $outputs['JPEG Support'];
603
+                $outputs['JPG Support'] = $outputs['JPEG Support'];
604 604
             }else 
605 605
             {
606
-	            if(isset($outputs['JPG Support']))
607
-	            {
608
-	            	$outputs['JPEG Support'] = $outputs['JPG Support'];
609
-	            }
606
+                if(isset($outputs['JPG Support']))
607
+                {
608
+                    $outputs['JPEG Support'] = $outputs['JPG Support'];
609
+                }
610 610
             }
611 611
             
612 612
             
@@ -663,24 +663,24 @@  discard block
 block discarded – undo
663 663
                 $outputs['Version'] = array('major' => isset($foo[0])?$foo[0]:'', 'minor' => isset($foo[1])?$foo[1]:'', 'patch' => isset($foo[2])?$foo:"");
664 664
             }
665 665
         }
666
-		//print_r($outputs);
666
+        //print_r($outputs);
667 667
         return ($versionOnly) ? $outputs['Version'] : $outputs;
668 668
     }    
669 669
     
670 670
     /**
671
-	 * Destroy the resources used by the images.
672
-	 * 
673
-	 * @param  bool $original
674
-	 * @return void
671
+     * Destroy the resources used by the images.
672
+     * 
673
+     * @param  bool $original
674
+     * @return void
675 675
      * @access public
676 676
      * @copyright this function originally come from Andy's php 
677
-	 */
677
+     */
678 678
     function DestroyImages($original = true)
679 679
     {
680
-    		if(!is_null($this->_imgFinal))
681
-    		{
682
-    			@imagedestroy($this->_imgFinal);
683
-    		}        
680
+            if(!is_null($this->_imgFinal))
681
+            {
682
+                @imagedestroy($this->_imgFinal);
683
+            }        
684 684
         $this->_imgFinal = null;
685 685
         if ($original && !is_null($this->_imgOrig)) {
686 686
             @imagedestroy($this->_imgOrig);
@@ -688,102 +688,102 @@  discard block
 block discarded – undo
688 688
         }
689 689
     } 
690 690
     
691
-	function getImageInfo($imagePath)
692
-	{
693
-		return $this->_getImageInfo($imagePath);
694
-	}
695
-	/**
691
+    function getImageInfo($imagePath)
692
+    {
693
+        return $this->_getImageInfo($imagePath);
694
+    }
695
+    /**
696 696
      * get image information, e.g. width, height, type
697 697
      * @access public
698 698
      * @return array
699 699
      */
700
-	function _getImageInfo($imagePath)
701
-	{
702
-		$outputs = array();
703
-		$imageInfo = @getimagesize($imagePath);
704
-		if ($imageInfo && is_array($imageInfo))
705
-		{
706
-			switch($imageInfo[2]){
707
-				case 1:
708
-					$type = 'gif';
709
-					break;
710
-				case 2:
711
-					$type = 'jpeg';
712
-					break;
713
-				case 3:
714
-					$type = 'png';
715
-					break;
716
-				case 4:
717
-					$type = 'swf';
718
-					break;
719
-				case 5:
720
-					$type = 'psd';
721
-				case 6:
722
-					$type = 'bmp';
723
-				case 7:
724
-				case 8:
725
-					$type = 'tiff';
726
-				default:
727
-					$type = '';
728
-			}
729
-			$outputs['width'] = $imageInfo[0];
730
-			$outputs['height'] = $imageInfo[1];
731
-			$outputs['type'] = $type;
732
-			$outputs['ext'] = $this->_getExtension($imagePath);
733
-		} else {
734
-			$this->_debug('Unable locate the image or read images information.');
735
-		}
736
-		return $outputs;
700
+    function _getImageInfo($imagePath)
701
+    {
702
+        $outputs = array();
703
+        $imageInfo = @getimagesize($imagePath);
704
+        if ($imageInfo && is_array($imageInfo))
705
+        {
706
+            switch($imageInfo[2]){
707
+                case 1:
708
+                    $type = 'gif';
709
+                    break;
710
+                case 2:
711
+                    $type = 'jpeg';
712
+                    break;
713
+                case 3:
714
+                    $type = 'png';
715
+                    break;
716
+                case 4:
717
+                    $type = 'swf';
718
+                    break;
719
+                case 5:
720
+                    $type = 'psd';
721
+                case 6:
722
+                    $type = 'bmp';
723
+                case 7:
724
+                case 8:
725
+                    $type = 'tiff';
726
+                default:
727
+                    $type = '';
728
+            }
729
+            $outputs['width'] = $imageInfo[0];
730
+            $outputs['height'] = $imageInfo[1];
731
+            $outputs['type'] = $type;
732
+            $outputs['ext'] = $this->_getExtension($imagePath);
733
+        } else {
734
+            $this->_debug('Unable locate the image or read images information.');
735
+        }
736
+        return $outputs;
737 737
 		
738
-	}
739
-	  function rotate($angle, $bgColor=0)
738
+    }
739
+        function rotate($angle, $bgColor=0)
740 740
     {
741
-    	$angle = intval($angle) -360;
742
-    		while($angle <0)
743
-    		{
744
-    			$angle += 360;
745
-    		}
741
+        $angle = intval($angle) -360;
742
+            while($angle <0)
743
+            {
744
+                $angle += 360;
745
+            }
746 746
  
747 747
 		
748
-         if($this->_imgFinal = imagerotate($this->_imgOrig, $angle, 0))
749
-         {
750
-         	return true;
751
-         }else 
752
-         {
753
-         	return false;
754
-         }
748
+            if($this->_imgFinal = imagerotate($this->_imgOrig, $angle, 0))
749
+            {
750
+                return true;
751
+            }else 
752
+            {
753
+                return false;
754
+            }
755 755
  
756 756
        
757 757
     }
758
-	/**
759
-	 * get the original image info
760
-	 *
761
-	 * @return array
762
-	 */
763
-	function getOriginalImageInfo()
764
-	{
765
-		return $this->_imgInfoOrig;
766
-	}
767
-	/**
768
-	 * return the final image info
769
-	 *
770
-	 * @return array
771
-	 */
772
-	function getFinalImageInfo()
773
-	{
774
-		if($this->_imgInfoFinal['width'] == '')
775
-		{
776
-			if(is_null($this->_imgFinal))
777
-			{
778
-				$this->_imgInfoFinal = $this->_imgInfoOrig;
779
-			}else 
780
-			{
781
-				$this->_imgInfoFinal['width'] = @imagesx($this->_imgFinal);
782
-				$this->_imgInfoFinal['height'] = @imagesy($this->_imgFinal);
783
-			}
784
-		}
785
-		return $this->_imgInfoFinal;
786
-	}
758
+    /**
759
+     * get the original image info
760
+     *
761
+     * @return array
762
+     */
763
+    function getOriginalImageInfo()
764
+    {
765
+        return $this->_imgInfoOrig;
766
+    }
767
+    /**
768
+     * return the final image info
769
+     *
770
+     * @return array
771
+     */
772
+    function getFinalImageInfo()
773
+    {
774
+        if($this->_imgInfoFinal['width'] == '')
775
+        {
776
+            if(is_null($this->_imgFinal))
777
+            {
778
+                $this->_imgInfoFinal = $this->_imgInfoOrig;
779
+            }else 
780
+            {
781
+                $this->_imgInfoFinal['width'] = @imagesx($this->_imgFinal);
782
+                $this->_imgInfoFinal['height'] = @imagesy($this->_imgFinal);
783
+            }
784
+        }
785
+        return $this->_imgInfoFinal;
786
+    }
787 787
 	
788 788
     /**
789 789
      *  create final image handler
@@ -796,12 +796,12 @@  discard block
 block discarded – undo
796 796
      */
797 797
     function _createFinalImageHandler($dst_w, $dst_h)
798 798
     {
799
-		 		if(function_exists('ImageCreateTrueColor'))
800
-		 		{
801
-					$this->_imgFinal = @imagecreatetruecolor($dst_w,$dst_h);
802
-				} else {
803
-					$this->_imgFinal = @imagecreate($dst_w,$dst_h);
804
-				}   
799
+                    if(function_exists('ImageCreateTrueColor'))
800
+                    {
801
+                    $this->_imgFinal = @imagecreatetruecolor($dst_w,$dst_h);
802
+                } else {
803
+                    $this->_imgFinal = @imagecreate($dst_w,$dst_h);
804
+                }   
805 805
         if (!is_null($this->transparentColorRed) && !is_null($this->transparentColorGreen) && !is_null($this->transparentColorBlue)) {
806 806
         
807 807
             $transparent = @imagecolorallocate($targetImageIdentifier, $this->transparentColorRed, $this->transparentColorGreen, $this->transparentColorBlue);
@@ -810,6 +810,6 @@  discard block
 block discarded – undo
810 810
         }
811 811
         
812 812
     }	
813
-	}
813
+    }
814 814
 	
815 815
 ?>
816 816
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
2
+	if (!defined('AJAX_INIT_DONE'))
3 3
 	{
4 4
 		die('Permission denied');
5 5
 	}
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		var $gdInfo = array(); //keep all information of GD extension
25 25
 		var $_imgOrig = null; //the hanlder of original image
26 26
 		var $_imgFinal = null; //the handler of final image
27
-		var $imageFile  = null;  
27
+		var $imageFile = null;  
28 28
     var $transparentColorRed = null;
29 29
     var $transparentColorGreen = null;
30 30
     var $transparentColorBlue = null;		 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		 */
72 72
 		function enableDebug($value)
73 73
 		{
74
-			$this->_debug = ($value?true:false);
74
+			$this->_debug = ($value ? true : false);
75 75
 		}
76 76
 		/**
77 77
 		 * check if debug enable
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
     		$this->_errors[] = $value;
96 96
         if ($this->_debug) 
97 97
         {
98
-            echo $value . "<br />\n";
98
+            echo $value."<br />\n";
99 99
         }
100 100
     }		
101 101
     /**
@@ -104,11 +104,11 @@  discard block
 block discarded – undo
104 104
      */
105 105
     function showErrors()
106 106
     {
107
-    	if(sizeof($this->_errors))
107
+    	if (sizeof($this->_errors))
108 108
     	{
109
-    		foreach($this->_errors as $error)
109
+    		foreach ($this->_errors as $error)
110 110
     		{
111
-    			echo $error . "<br />\n";
111
+    			echo $error."<br />\n";
112 112
     		}
113 113
     	}
114 114
     }
@@ -123,26 +123,26 @@  discard block
 block discarded – undo
123 123
     function loadImage($filename)
124 124
     {
125 125
         $ext  = strtolower($this->_getExtension($filename));
126
-        $func = 'imagecreatefrom' . ($ext == 'jpg' ? 'jpeg' : $ext);
126
+        $func = 'imagecreatefrom'.($ext == 'jpg' ? 'jpeg' : $ext);
127 127
         if (!$this->_isSupported($filename, $ext, $func, false)) {
128 128
 
129 129
             return false;
130 130
         }
131
-        if($ext == "gif")
131
+        if ($ext == "gif")
132 132
         {
133 133
              // the following part gets the transparency color for a gif file
134 134
             // this code is from the PHP manual and is written by
135 135
             // fred at webblake dot net and webmaster at webnetwizard dotco dotuk, thanks!
136 136
             $fp = @fopen($filename, "rb");
137 137
             $result = @fread($fp, 13);
138
-            $colorFlag = ord(substr($result,10,1)) >> 7;
139
-            $background = ord(substr($result,11));
138
+            $colorFlag = ord(substr($result, 10, 1)) >> 7;
139
+            $background = ord(substr($result, 11));
140 140
             if ($colorFlag) {
141
-                $tableSizeNeeded = ($background + 1) * 3;
141
+                $tableSizeNeeded = ($background + 1)*3;
142 142
                 $result = @fread($fp, $tableSizeNeeded);
143
-                $this->transparentColorRed = ord(substr($result, $background * 3, 1));
144
-                $this->transparentColorGreen = ord(substr($result, $background * 3 + 1, 1));
145
-                $this->transparentColorBlue = ord(substr($result, $background * 3 + 2, 1));
143
+                $this->transparentColorRed = ord(substr($result, $background*3, 1));
144
+                $this->transparentColorGreen = ord(substr($result, $background*3 + 1, 1));
145
+                $this->transparentColorBlue = ord(substr($result, $background*3 + 2, 1));
146 146
             }
147 147
             fclose($fp);
148 148
             // -- here ends the code related to transparency handling   	
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         if ($this->_imgOrig == null) {
152 152
             $this->_debug("The image could not be created from the '$filename' file using the '$func' function.");
153 153
             return false;
154
-        }else 
154
+        } else 
155 155
         {
156 156
         	$this->imageFile = $filename;
157 157
 			    $this->_imgInfoOrig = array(
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 			    	'path'=>$filename,
162 162
 			    );        	
163 163
 			    $imgInfo = $this->_getImageInfo($filename);
164
-			    if(sizeof($imgInfo))
164
+			    if (sizeof($imgInfo))
165 165
 			    {
166
-			    	foreach($imgInfo as $k=>$v)
166
+			    	foreach ($imgInfo as $k=>$v)
167 167
 			    	{
168 168
 			    		$this->_imgInfoOrig[$k] = $v;
169 169
 			    		$this->_imgInfoFinal[$k] = $v;
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
         }
213 213
 
214 214
         $ext  = ($forcetype == '') ? $this->_getExtension($filename) : strtolower($forcetype);
215
-        $func = 'image' . ($ext == 'jpg' ? 'jpeg' : $ext);
215
+        $func = 'image'.($ext == 'jpg' ? 'jpeg' : $ext);
216 216
         if (!$this->_isSupported($filename, $ext, $func, true)) 
217 217
         {
218 218
             return false;
219 219
         }
220 220
         $saved = false;
221
-        switch($ext) 
221
+        switch ($ext) 
222 222
         {
223 223
             case 'gif':
224 224
                 if ($this->gdInfo['Truecolor Support'] && imageistruecolor($this->_imgFinal)) 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         {
238 238
             $this->_debug("The image could not be saved to the '$filename' file as the file type '$ext' using the '$func' function.");
239 239
             return false;
240
-        }else 
240
+        } else 
241 241
         {
242 242
         	$this->_imgInfoFinal['size'] = @filesize($filename);
243 243
         	@chmod($filename, intval($this->chmod, 8));
@@ -260,19 +260,19 @@  discard block
 block discarded – undo
260 260
             $this->_debug('There is no cropped image to show.');
261 261
             return false;
262 262
         }
263
-        $type = (!empty($type)?$type:$this->_imgInfoOrig['ext']);
264
-        $quality = (!empty($quality)?$quality:$this->_imgQuality);
263
+        $type = (!empty($type) ? $type : $this->_imgInfoOrig['ext']);
264
+        $quality = (!empty($quality) ? $quality : $this->_imgQuality);
265 265
 				
266 266
         $type = strtolower($type);
267
-        $func = 'image' . ($type == 'jpg' ? 'jpeg' : $type);
268
-        $head = 'image/' . ($type == 'jpg' ? 'jpeg' : $type);
267
+        $func = 'image'.($type == 'jpg' ? 'jpeg' : $type);
268
+        $head = 'image/'.($type == 'jpg' ? 'jpeg' : $type);
269 269
         
270 270
         if (!$this->_isSupported('[showing file]', $type, $func, false)) {
271 271
             return false;
272 272
         }
273 273
 
274 274
         header("Content-type: $head");
275
-        switch($type) 
275
+        switch ($type) 
276 276
         {
277 277
             case 'gif':
278 278
                 if ($this->gdInfo['Truecolor Support'] && imageistruecolor($this->_imgFinal)) 
@@ -317,14 +317,14 @@  discard block
 block discarded – undo
317 317
         $this->_createFinalImageHandler($dst_w, $dst_h);
318 318
         if ($this->gdInfo['Truecolor Support']) 
319 319
         {
320
-            	if(!@imagecopyresampled($this->_imgFinal, $this->_imgOrig, 0, 0, $dst_x, $dst_y, $dst_w, $dst_h, $dst_w, $dst_h))
320
+            	if (!@imagecopyresampled($this->_imgFinal, $this->_imgOrig, 0, 0, $dst_x, $dst_y, $dst_w, $dst_h, $dst_w, $dst_h))
321 321
             	{
322 322
             		$this->_debug('Unable crop the image.');
323 323
             		return false;
324 324
             	}            
325 325
         } else 
326 326
         {
327
-          	if(!@imagecopyresized($this->_imgFinal, $this->_imgOrig, 0, 0, $dst_x, $dst_y, $dst_w, $dst_h, $dst_w, $dst_h))
327
+          	if (!@imagecopyresized($this->_imgFinal, $this->_imgOrig, 0, 0, $dst_x, $dst_y, $dst_w, $dst_h, $dst_w, $dst_h))
328 328
           	{
329 329
            		$this->_debug('Unable crop the image.');
330 330
           		return false;           		
@@ -351,9 +351,9 @@  discard block
 block discarded – undo
351 351
      *
352 352
      * @return mixed none or PEAR_error
353 353
      */
354
-	function resize( $new_x, $new_y, $constraint= false, $unchangeIfsmaller=false)
354
+	function resize($new_x, $new_y, $constraint = false, $unchangeIfsmaller = false)
355 355
 	{
356
-		if(!$this->_imgOrig)
356
+		if (!$this->_imgOrig)
357 357
 		{
358 358
 			$this->_debug('No image fould.');
359 359
 			return false;
@@ -361,35 +361,35 @@  discard block
 block discarded – undo
361 361
 		
362 362
 		$new_x = intval($new_x);
363 363
 		$new_y = intval($new_y);
364
-		if($new_x <=0 || $new_y <= 0)
364
+		if ($new_x <= 0 || $new_y <= 0)
365 365
 		{
366 366
 			$this->_debug('either of new width or height can be zeor or less.');
367
-		}else 
367
+		} else 
368 368
 		{
369 369
 		
370
-			if($constraint)
370
+			if ($constraint)
371 371
 			{
372
-				if($new_x < 1 && $new_y < 1)
372
+				if ($new_x < 1 && $new_y < 1)
373 373
 				{
374 374
 					$new_x = $this->_imgInfoOrig['width'];
375 375
 					$new_y = $this->_imgInfoOrig['height'];
376
-				}elseif($new_x < 1)
376
+				}elseif ($new_x < 1)
377 377
 				{
378
-					$new_x = floor($new_y / $this->_imgInfoOrig['height'] * $this->_imgInfoOrig['width']);
378
+					$new_x = floor($new_y/$this->_imgInfoOrig['height']*$this->_imgInfoOrig['width']);
379 379
 	
380
-				}elseif($new_y < 1)
380
+				}elseif ($new_y < 1)
381 381
 				{
382
-					$new_y = floor($new_x / $this->_imgInfoOrig['width'] * $this->_imgInfoOrig['height']);
383
-				}else
382
+					$new_y = floor($new_x/$this->_imgInfoOrig['width']*$this->_imgInfoOrig['height']);
383
+				} else
384 384
 				{
385
-					$scale = min($new_x/$this->_imgInfoOrig['width'], $new_y/$this->_imgInfoOrig['height']) ;
385
+					$scale = min($new_x/$this->_imgInfoOrig['width'], $new_y/$this->_imgInfoOrig['height']);
386 386
 					$new_x = floor($scale*$this->_imgInfoOrig['width']);
387 387
 					$new_y = floor($scale*$this->_imgInfoOrig['height']);
388 388
 				}						
389 389
 			}
390
-			if($unchangeIfsmaller)
390
+			if ($unchangeIfsmaller)
391 391
 			{
392
-				if($this->_imgInfoOrig['width'] < $new_x && $this->_imgInfoOrig['height'] < $new_y )
392
+				if ($this->_imgInfoOrig['width'] < $new_x && $this->_imgInfoOrig['height'] < $new_y)
393 393
 				{
394 394
 					$new_x = $this->_imgInfoOrig['width'];
395 395
 					$new_y = $this->_imgInfoOrig['height'];
@@ -398,11 +398,11 @@  discard block
 block discarded – undo
398 398
 		
399 399
 			
400 400
 			
401
-			if(is_null($this->_imgOrig))
401
+			if (is_null($this->_imgOrig))
402 402
 			{
403 403
 				$this->loadImage($filePath);
404 404
 			}
405
-			if(sizeof($this->_errors) == 0)
405
+			if (sizeof($this->_errors) == 0)
406 406
 			{
407 407
 				return $this->_resize($new_x, $new_y);
408 408
 			}			
@@ -420,14 +420,14 @@  discard block
 block discarded – undo
420 420
      * @param string $mode can be save, view and both
421 421
      * @return unknown
422 422
      */
423
-	function _resize( $new_x, $new_y) 
423
+	function _resize($new_x, $new_y) 
424 424
 	{
425 425
 		$this->_createFinalImageHandler($new_x, $new_y);
426 426
     // hacks fot transparency of png24 files
427 427
     if ($this->_imgInfoOrig['type'] == 'png') 
428 428
     {    
429 429
         @imagealphablending($this->_imgFinal, false);
430
-				if(function_exists('ImageCopyResampled'))
430
+				if (function_exists('ImageCopyResampled'))
431 431
 				{
432 432
 					@imagecopyresampled($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
433 433
 				} else {
@@ -435,9 +435,9 @@  discard block
 block discarded – undo
435 435
 				} 
436 436
         @imagesavealpha($this->_imgFinal, true);
437 437
 
438
-    }else 
438
+    } else 
439 439
     {//for the rest image
440
-			if(function_exists('ImageCopyResampled'))
440
+			if (function_exists('ImageCopyResampled'))
441 441
 			{
442 442
 				@imagecopyresampled($this->_imgFinal, $this->_imgOrig, 0, 0, 0, 0, $new_x, $new_y, $this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
443 443
 			} else {
@@ -450,10 +450,10 @@  discard block
 block discarded – undo
450 450
 		$this->_imgInfoFinal['height'] = $new_y;
451 451
 		$this->_imgInfoFinal['name'] = basename($this->_imgInfoOrig['name']);
452 452
 		$this->_imgInfoFinal['path'] = $this->_imgInfoOrig['path'];		
453
-		if($this->_imgFinal)
453
+		if ($this->_imgFinal)
454 454
 		{
455 455
 			return true;
456
-		}else 
456
+		} else 
457 457
 		{			
458 458
 			$this->_debug('Unable to resize the image on the fly.');
459 459
 			return false;
@@ -492,14 +492,14 @@  discard block
 block discarded – undo
492 492
     {
493 493
 
494 494
        $giftype = ($write) ? ' Create Support' : ' Read Support';
495
-        $support = strtoupper($extension) . ($extension == 'gif' ? $giftype : ' Support');
495
+        $support = strtoupper($extension).($extension == 'gif' ? $giftype : ' Support');
496 496
 
497
-        if (isset($this->gdInfo['JPG Support']) && ($extension=='jpg' || $extension=='jpeg')) 
497
+        if (isset($this->gdInfo['JPG Support']) && ($extension == 'jpg' || $extension == 'jpeg')) 
498 498
         {
499
-        	$extension='jpg';
500
-        }else if (isset($this->gdInfo['JPEG Support']) && ($extension=='jpg' || $extension=='jpeg')) 
499
+        	$extension = 'jpg';
500
+        } else if (isset($this->gdInfo['JPEG Support']) && ($extension == 'jpg' || $extension == 'jpeg')) 
501 501
         {
502
-        	$extension='jpeg';
502
+        	$extension = 'jpeg';
503 503
         }
504 504
         if (!isset($this->gdInfo[$support]) || $this->gdInfo[$support] == false) {
505 505
             $request = ($write) ? 'saving' : 'reading';
@@ -520,21 +520,21 @@  discard block
 block discarded – undo
520 520
      * @param string $direction
521 521
      * @return boolean
522 522
      */
523
-    function flip($direction="horizontal")
523
+    function flip($direction = "horizontal")
524 524
     {
525 525
 				$this->_createFinalImageHandler($this->_imgInfoOrig['width'], $this->_imgInfoOrig['height']);
526
-			if($direction != "vertical")
526
+			if ($direction != "vertical")
527 527
 			{
528 528
 				$dst_x = 0;
529 529
 				$dst_y = 0;
530
-				$src_x = $this->_imgInfoOrig['width'] -1;
530
+				$src_x = $this->_imgInfoOrig['width'] - 1;
531 531
 				$src_y = 0;
532 532
 				$dst_w = $this->_imgInfoOrig['width'];
533 533
 				$dst_h = $this->_imgInfoOrig['height'];
534 534
 				$src_w = 0 - $this->_imgInfoOrig['width'];
535 535
 				$src_h = $this->_imgInfoOrig['height'];
536 536
 				
537
-			}else 
537
+			} else 
538 538
 			{
539 539
 				$dst_x = 0;
540 540
 				$dst_y = 0;
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 				$src_w = $this->_imgInfoOrig['width'];
546 546
 				$src_h = 0 - $this->_imgInfoOrig['height'];				
547 547
 			}			
548
-				if(function_exists('ImageCopyResampled')){
548
+				if (function_exists('ImageCopyResampled')) {
549 549
 					imagecopyresampled($this->_imgFinal, $this->_imgOrig, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
550 550
 				} else {
551 551
 					imagecopyresized($this->_imgFinal, $this->_imgOrig, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
@@ -554,10 +554,10 @@  discard block
 block discarded – undo
554 554
 				$this->_imgInfoFinal['height'] = $dst_h;
555 555
 				$this->_imgInfoFinal['name'] = basename($this->imageFile);
556 556
 				$this->_imgInfoFinal['path'] = $this->imageFile;		
557
-				if($this->_imgFinal)
557
+				if ($this->_imgFinal)
558 558
 				{
559 559
 					return true;
560
-				}else 
560
+				} else 
561 561
 				{			
562 562
 					$this->_debug('Unable to resize the image on the fly.');	
563 563
 					return false;
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
         if (function_exists('gd_info')) 
599 599
         {
600 600
             $outputs = gd_info();
601
-            if(isset($outputs['JPEG Support']))
601
+            if (isset($outputs['JPEG Support']))
602 602
             {
603 603
             	$outputs['JPG Support'] = $outputs['JPEG Support'];
604
-            }else 
604
+            } else 
605 605
             {
606
-	            if(isset($outputs['JPG Support']))
606
+	            if (isset($outputs['JPG Support']))
607 607
 	            {
608 608
 	            	$outputs['JPEG Support'] = $outputs['JPG Support'];
609 609
 	            }
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
             $match = array();
661 661
             if (preg_match('/([0-9\.]+)/', $outputs['GD Version'], $match)) {
662 662
                 $foo = explode('.', $match[0]);
663
-                $outputs['Version'] = array('major' => isset($foo[0])?$foo[0]:'', 'minor' => isset($foo[1])?$foo[1]:'', 'patch' => isset($foo[2])?$foo:"");
663
+                $outputs['Version'] = array('major' => isset($foo[0]) ? $foo[0] : '', 'minor' => isset($foo[1]) ? $foo[1] : '', 'patch' => isset($foo[2]) ? $foo : "");
664 664
             }
665 665
         }
666 666
 		//print_r($outputs);
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 	 */
678 678
     function DestroyImages($original = true)
679 679
     {
680
-    		if(!is_null($this->_imgFinal))
680
+    		if (!is_null($this->_imgFinal))
681 681
     		{
682 682
     			@imagedestroy($this->_imgFinal);
683 683
     		}        
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 		$imageInfo = @getimagesize($imagePath);
704 704
 		if ($imageInfo && is_array($imageInfo))
705 705
 		{
706
-			switch($imageInfo[2]){
706
+			switch ($imageInfo[2]) {
707 707
 				case 1:
708 708
 					$type = 'gif';
709 709
 					break;
@@ -736,19 +736,19 @@  discard block
 block discarded – undo
736 736
 		return $outputs;
737 737
 		
738 738
 	}
739
-	  function rotate($angle, $bgColor=0)
739
+	  function rotate($angle, $bgColor = 0)
740 740
     {
741
-    	$angle = intval($angle) -360;
742
-    		while($angle <0)
741
+    	$angle = intval($angle) - 360;
742
+    		while ($angle < 0)
743 743
     		{
744 744
     			$angle += 360;
745 745
     		}
746 746
  
747 747
 		
748
-         if($this->_imgFinal = imagerotate($this->_imgOrig, $angle, 0))
748
+         if ($this->_imgFinal = imagerotate($this->_imgOrig, $angle, 0))
749 749
          {
750 750
          	return true;
751
-         }else 
751
+         } else 
752 752
          {
753 753
          	return false;
754 754
          }
@@ -771,12 +771,12 @@  discard block
 block discarded – undo
771 771
 	 */
772 772
 	function getFinalImageInfo()
773 773
 	{
774
-		if($this->_imgInfoFinal['width'] == '')
774
+		if ($this->_imgInfoFinal['width'] == '')
775 775
 		{
776
-			if(is_null($this->_imgFinal))
776
+			if (is_null($this->_imgFinal))
777 777
 			{
778 778
 				$this->_imgInfoFinal = $this->_imgInfoOrig;
779
-			}else 
779
+			} else 
780 780
 			{
781 781
 				$this->_imgInfoFinal['width'] = @imagesx($this->_imgFinal);
782 782
 				$this->_imgInfoFinal['height'] = @imagesy($this->_imgFinal);
@@ -796,11 +796,11 @@  discard block
 block discarded – undo
796 796
      */
797 797
     function _createFinalImageHandler($dst_w, $dst_h)
798 798
     {
799
-		 		if(function_exists('ImageCreateTrueColor'))
799
+		 		if (function_exists('ImageCreateTrueColor'))
800 800
 		 		{
801
-					$this->_imgFinal = @imagecreatetruecolor($dst_w,$dst_h);
801
+					$this->_imgFinal = @imagecreatetruecolor($dst_w, $dst_h);
802 802
 				} else {
803
-					$this->_imgFinal = @imagecreate($dst_w,$dst_h);
803
+					$this->_imgFinal = @imagecreate($dst_w, $dst_h);
804 804
 				}   
805 805
         if (!is_null($this->transparentColorRed) && !is_null($this->transparentColorGreen) && !is_null($this->transparentColorBlue)) {
806 806
         
Please login to merge, or discard this patch.
Braces   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         if ($this->_imgOrig == null) {
152 152
             $this->_debug("The image could not be created from the '$filename' file using the '$func' function.");
153 153
             return false;
154
-        }else 
154
+        } else 
155 155
         {
156 156
         	$this->imageFile = $filename;
157 157
 			    $this->_imgInfoOrig = array(
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         {
238 238
             $this->_debug("The image could not be saved to the '$filename' file as the file type '$ext' using the '$func' function.");
239 239
             return false;
240
-        }else 
240
+        } else 
241 241
         {
242 242
         	$this->_imgInfoFinal['size'] = @filesize($filename);
243 243
         	@chmod($filename, intval($this->chmod, 8));
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 		if($new_x <=0 || $new_y <= 0)
365 365
 		{
366 366
 			$this->_debug('either of new width or height can be zeor or less.');
367
-		}else 
367
+		} else 
368 368
 		{
369 369
 		
370 370
 			if($constraint)
@@ -373,14 +373,14 @@  discard block
 block discarded – undo
373 373
 				{
374 374
 					$new_x = $this->_imgInfoOrig['width'];
375 375
 					$new_y = $this->_imgInfoOrig['height'];
376
-				}elseif($new_x < 1)
376
+				} elseif($new_x < 1)
377 377
 				{
378 378
 					$new_x = floor($new_y / $this->_imgInfoOrig['height'] * $this->_imgInfoOrig['width']);
379 379
 	
380
-				}elseif($new_y < 1)
380
+				} elseif($new_y < 1)
381 381
 				{
382 382
 					$new_y = floor($new_x / $this->_imgInfoOrig['width'] * $this->_imgInfoOrig['height']);
383
-				}else
383
+				} else
384 384
 				{
385 385
 					$scale = min($new_x/$this->_imgInfoOrig['width'], $new_y/$this->_imgInfoOrig['height']) ;
386 386
 					$new_x = floor($scale*$this->_imgInfoOrig['width']);
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 				} 
436 436
         @imagesavealpha($this->_imgFinal, true);
437 437
 
438
-    }else 
438
+    } else 
439 439
     {//for the rest image
440 440
 			if(function_exists('ImageCopyResampled'))
441 441
 			{
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 		if($this->_imgFinal)
454 454
 		{
455 455
 			return true;
456
-		}else 
456
+		} else 
457 457
 		{			
458 458
 			$this->_debug('Unable to resize the image on the fly.');
459 459
 			return false;
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
         if (isset($this->gdInfo['JPG Support']) && ($extension=='jpg' || $extension=='jpeg')) 
498 498
         {
499 499
         	$extension='jpg';
500
-        }else if (isset($this->gdInfo['JPEG Support']) && ($extension=='jpg' || $extension=='jpeg')) 
500
+        } else if (isset($this->gdInfo['JPEG Support']) && ($extension=='jpg' || $extension=='jpeg')) 
501 501
         {
502 502
         	$extension='jpeg';
503 503
         }
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 				$src_w = 0 - $this->_imgInfoOrig['width'];
535 535
 				$src_h = $this->_imgInfoOrig['height'];
536 536
 				
537
-			}else 
537
+			} else 
538 538
 			{
539 539
 				$dst_x = 0;
540 540
 				$dst_y = 0;
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 				if($this->_imgFinal)
558 558
 				{
559 559
 					return true;
560
-				}else 
560
+				} else 
561 561
 				{			
562 562
 					$this->_debug('Unable to resize the image on the fly.');	
563 563
 					return false;
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
             if(isset($outputs['JPEG Support']))
602 602
             {
603 603
             	$outputs['JPG Support'] = $outputs['JPEG Support'];
604
-            }else 
604
+            } else 
605 605
             {
606 606
 	            if(isset($outputs['JPG Support']))
607 607
 	            {
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
          if($this->_imgFinal = imagerotate($this->_imgOrig, $angle, 0))
749 749
          {
750 750
          	return true;
751
-         }else 
751
+         } else 
752 752
          {
753 753
          	return false;
754 754
          }
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 			if(is_null($this->_imgFinal))
777 777
 			{
778 778
 				$this->_imgInfoFinal = $this->_imgInfoOrig;
779
-			}else 
779
+			} else 
780 780
 			{
781 781
 				$this->_imgInfoFinal['width'] = @imagesx($this->_imgFinal);
782 782
 				$this->_imgInfoFinal['height'] = @imagesy($this->_imgFinal);
Please login to merge, or discard this patch.
phpmyfaq/admin/editor/plugins/ajaxfilemanager/inc/class.manager.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -268,6 +268,7 @@
 block discarded – undo
268 268
 		 * return the file type of a file.
269 269
 		 *
270 270
 		 * @param string file name
271
+		 * @param string $fileName
271 272
 		 * @return array
272 273
 		 */
273 274
 		function getFileType($fileName, $checkIfDir = false) 
Please login to merge, or discard this patch.
Indentation   +326 added lines, -326 removed lines patch added patch discarded remove patch
@@ -1,378 +1,378 @@
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
3
-	{
4
-		die('Permission denied');
5
-	}
2
+    if(!defined('AJAX_INIT_DONE'))
3
+    {
4
+        die('Permission denied');
5
+    }
6 6
 ?><?php
7 7
 /**
8
-	 * file listing
9
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
10
-	 * @link www.phpletter.com
11
-	 * @since 22/April/2007
12
-	 *
13
-	 */
8
+     * file listing
9
+     * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
10
+     * @link www.phpletter.com
11
+     * @since 22/April/2007
12
+     *
13
+     */
14 14
 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.file.php");
15 15
 class manager
16 16
 {
17
-	var $currentFolderPath;
18
-	var $sessionAction = null; //object to session action
19
-	var $flags = array('no'=>'noFlag', 'cut'=>'cutFlag', 'copy'=>'copyFlag');
20
-	var $forceFolderOnTop = false; //forced to have folder shown on the top of the list
21
-	var $currentFolderInfo = array(
22
-	'name'=>'',
23
-	'subdir'=>0,
24
-	'file'=>0,
25
-	'ctime'=>'',
26
-	'mtime'=>'',
27
-	'is_readable'=>'',
28
-	'is_writable'=>'',
29
-	'size'=>0,
30
-	'path'=>'',
31
-	'type'=>'folder',
32
-	'flag'=>'noFlag',
33
-	'friendly_path'=>'',
34
-	);
17
+    var $currentFolderPath;
18
+    var $sessionAction = null; //object to session action
19
+    var $flags = array('no'=>'noFlag', 'cut'=>'cutFlag', 'copy'=>'copyFlag');
20
+    var $forceFolderOnTop = false; //forced to have folder shown on the top of the list
21
+    var $currentFolderInfo = array(
22
+    'name'=>'',
23
+    'subdir'=>0,
24
+    'file'=>0,
25
+    'ctime'=>'',
26
+    'mtime'=>'',
27
+    'is_readable'=>'',
28
+    'is_writable'=>'',
29
+    'size'=>0,
30
+    'path'=>'',
31
+    'type'=>'folder',
32
+    'flag'=>'noFlag',
33
+    'friendly_path'=>'',
34
+    );
35 35
 	
36
-	var $lastVisitedFolderPathIndex = 'ajax_last_visited_folder';
37
-	var $folderPathIndex = "path";
38
-	var $calculateSubdir = true;
39
-	var $fileTypes = array(
40
-			array(array("exe", "com"), "fileExe", SEARCH_TYPE_EXE, 0),
41
-			array(array("gif", "jpg", "png", "bmp", "tif"), "filePicture", SEARCH_TYPE_IMG, 1),
42
-			array(array("zip", "sit", "rar", "gz", "tar"), "fileZip", SEARCH_TYPE_ARCHIVE, 0),
43
-			array(array("htm", "html", "php", "jsp", "asp", 'js', 'css'), "fileCode", SEARCH_TYPE_HTML, 1),
44
-			array(array("mov", "ram", "rm", "asx", "dcr", "wmv"), "fileVideo", SEARCH_TYPE_VIDEO, 1),
45
-			array(array("mpg", "avi", "asf", "mpeg"), "fileVideo", SEARCH_TYPE_MOVIE, 1),
46
-			array(array("aif", "aiff", "wav", "mp3", "wma"), "fileMusic", SEARCH_TYPE_MUSIC, 1),
47
-			array(array("swf", 'flv'), "fileFlash", SEARCH_TYPE_FLASH, 1),
48
-			array(array("ppt"), "filePPT", SEARCH_TYPE_PPT, 0),
49
-			array(array("rtf"), "fileRTF", SEARCH_TYPE_DOC, 0),
50
-			array(array("doc"), "fileWord", SEARCH_TYPE_WORD, 0),
51
-			array(array("pdf"), "fileAcrobat", SEARCH_TYPE_PDF, 0),
52
-			array(array("xls", "csv"), "fileExcel", SEARCH_TYPE_EXCEL, 0),
53
-			array(array("txt"), "fileText", SEARCH_TYPE_TEXT, 1),
54
-			array(array("xml", "xsl", "dtd"), "fileXml", SEARCH_TYPE_XML, 1)
55
-	);
36
+    var $lastVisitedFolderPathIndex = 'ajax_last_visited_folder';
37
+    var $folderPathIndex = "path";
38
+    var $calculateSubdir = true;
39
+    var $fileTypes = array(
40
+            array(array("exe", "com"), "fileExe", SEARCH_TYPE_EXE, 0),
41
+            array(array("gif", "jpg", "png", "bmp", "tif"), "filePicture", SEARCH_TYPE_IMG, 1),
42
+            array(array("zip", "sit", "rar", "gz", "tar"), "fileZip", SEARCH_TYPE_ARCHIVE, 0),
43
+            array(array("htm", "html", "php", "jsp", "asp", 'js', 'css'), "fileCode", SEARCH_TYPE_HTML, 1),
44
+            array(array("mov", "ram", "rm", "asx", "dcr", "wmv"), "fileVideo", SEARCH_TYPE_VIDEO, 1),
45
+            array(array("mpg", "avi", "asf", "mpeg"), "fileVideo", SEARCH_TYPE_MOVIE, 1),
46
+            array(array("aif", "aiff", "wav", "mp3", "wma"), "fileMusic", SEARCH_TYPE_MUSIC, 1),
47
+            array(array("swf", 'flv'), "fileFlash", SEARCH_TYPE_FLASH, 1),
48
+            array(array("ppt"), "filePPT", SEARCH_TYPE_PPT, 0),
49
+            array(array("rtf"), "fileRTF", SEARCH_TYPE_DOC, 0),
50
+            array(array("doc"), "fileWord", SEARCH_TYPE_WORD, 0),
51
+            array(array("pdf"), "fileAcrobat", SEARCH_TYPE_PDF, 0),
52
+            array(array("xls", "csv"), "fileExcel", SEARCH_TYPE_EXCEL, 0),
53
+            array(array("txt"), "fileText", SEARCH_TYPE_TEXT, 1),
54
+            array(array("xml", "xsl", "dtd"), "fileXml", SEARCH_TYPE_XML, 1)
55
+    );
56 56
 	
57
-	/**
58
-		 * constructor
59
-		 * @path the path to a folder
60
-		 * @calculateSubdir force to get the subdirectories information
61
-		 */		
62
-	function __construct($path = null, $calculateSubdir=true)
63
-	{
57
+    /**
58
+     * constructor
59
+     * @path the path to a folder
60
+     * @calculateSubdir force to get the subdirectories information
61
+     */		
62
+    function __construct($path = null, $calculateSubdir=true)
63
+    {
64 64
 
65
-		$this->calculateSubdir = $calculateSubdir;
66
-		if(defined('CONFIG_SYS_FOLDER_SHOWN_ON_TOP'))
67
-		{
68
-			$this->forceFolderOnTop = CONFIG_SYS_FOLDER_SHOWN_ON_TOP;
69
-		}
70
-		if(!is_null($path))
71
-		{
72
-			$this->currentFolderPath = $path;
65
+        $this->calculateSubdir = $calculateSubdir;
66
+        if(defined('CONFIG_SYS_FOLDER_SHOWN_ON_TOP'))
67
+        {
68
+            $this->forceFolderOnTop = CONFIG_SYS_FOLDER_SHOWN_ON_TOP;
69
+        }
70
+        if(!is_null($path))
71
+        {
72
+            $this->currentFolderPath = $path;
73 73
 
74
-		}elseif(isset($_GET[$this->folderPathIndex]) && file_exists($_GET[$this->folderPathIndex]) && !is_file($_GET[$this->folderPathIndex]) )
75
-		{
76
-			$this->currentFolderPath = $_GET[$this->folderPathIndex];
77
-		}
78
-		elseif(isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex]))
79
-		{
80
-			$this->currentFolderPath = $_SESSION[$this->lastVisitedFolderPathIndex];
81
-		}else
82
-		{
83
-			$this->currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
84
-		}
74
+        }elseif(isset($_GET[$this->folderPathIndex]) && file_exists($_GET[$this->folderPathIndex]) && !is_file($_GET[$this->folderPathIndex]) )
75
+        {
76
+            $this->currentFolderPath = $_GET[$this->folderPathIndex];
77
+        }
78
+        elseif(isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex]))
79
+        {
80
+            $this->currentFolderPath = $_SESSION[$this->lastVisitedFolderPathIndex];
81
+        }else
82
+        {
83
+            $this->currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
84
+        }
85 85
 		
86
-		$this->currentFolderPath = (isUnderRoot($this->currentFolderPath)?backslashToSlash((addTrailingSlash($this->currentFolderPath))):CONFIG_SYS_DEFAULT_PATH);
86
+        $this->currentFolderPath = (isUnderRoot($this->currentFolderPath)?backslashToSlash((addTrailingSlash($this->currentFolderPath))):CONFIG_SYS_DEFAULT_PATH);
87 87
 		
88
-		if($this->calculateSubdir)
89
-		{// keep track of this folder path in session 
90
-			$_SESSION[$this->lastVisitedFolderPathIndex] = $this->currentFolderPath;
91
-		}
92
-		if(is_dir($this->currentFolderPath))
93
-		{
94
-			$file = new file($this->currentFolderPath);
95
-			$folderInfo = $file->getFileInfo();
96
-			if(sizeof($folderInfo))
97
-			{
98
-				$this->currentFolderInfo['name']=basename($this->currentFolderPath);
99
-				$this->currentFolderInfo['subdir']=0;
100
-				$this->currentFolderInfo['file']=0;
101
-				$this->currentFolderInfo['ctime']=$folderInfo['ctime'];
102
-				$this->currentFolderInfo['mtime']=$folderInfo['mtime'];
103
-				$this->currentFolderInfo['is_readable']=$folderInfo['is_readable'];
104
-				$this->currentFolderInfo['is_writable']=$folderInfo['is_writable'];	
105
-				$this->currentFolderInfo['path']  = $this->currentFolderPath;
106
-				$this->currentFolderInfo['friendly_path'] = transformFilePath($this->currentFolderPath);
107
-				$this->currentFolderInfo['type'] = "folder";
108
-				$this->currentFolderInfo['cssClass']='folder';
88
+        if($this->calculateSubdir)
89
+        {// keep track of this folder path in session 
90
+            $_SESSION[$this->lastVisitedFolderPathIndex] = $this->currentFolderPath;
91
+        }
92
+        if(is_dir($this->currentFolderPath))
93
+        {
94
+            $file = new file($this->currentFolderPath);
95
+            $folderInfo = $file->getFileInfo();
96
+            if(sizeof($folderInfo))
97
+            {
98
+                $this->currentFolderInfo['name']=basename($this->currentFolderPath);
99
+                $this->currentFolderInfo['subdir']=0;
100
+                $this->currentFolderInfo['file']=0;
101
+                $this->currentFolderInfo['ctime']=$folderInfo['ctime'];
102
+                $this->currentFolderInfo['mtime']=$folderInfo['mtime'];
103
+                $this->currentFolderInfo['is_readable']=$folderInfo['is_readable'];
104
+                $this->currentFolderInfo['is_writable']=$folderInfo['is_writable'];	
105
+                $this->currentFolderInfo['path']  = $this->currentFolderPath;
106
+                $this->currentFolderInfo['friendly_path'] = transformFilePath($this->currentFolderPath);
107
+                $this->currentFolderInfo['type'] = "folder";
108
+                $this->currentFolderInfo['cssClass']='folder';
109 109
 				
110
-				//$this->currentFolderInfo['flag'] = $folderInfo['flag'];
111
-			}			
112
-		}
113
-		if($calculateSubdir && !file_exists($this->currentFolderPath))
114
-		{
115
-			die(ERR_FOLDER_NOT_FOUND . $this->currentFolderPath);
116
-		}
110
+                //$this->currentFolderInfo['flag'] = $folderInfo['flag'];
111
+            }			
112
+        }
113
+        if($calculateSubdir && !file_exists($this->currentFolderPath))
114
+        {
115
+            die(ERR_FOLDER_NOT_FOUND . $this->currentFolderPath);
116
+        }
117 117
 
118 118
 
119 119
 	
120
-	}
120
+    }
121 121
 	
122
-	function setSessionAction(&$session)
123
-	{
124
-		$this->sessionAction = $session;	
125
-	}
126
-	/**
127
-		 * constructor
128
-		 */
129
-	function manager($path = null, $calculateSubdir=true)
130
-	{
131
-		$this->__construct($path, $calculateSubdir);
132
-	}
133
-	/**
134
-		 * get current folder path
135
-		 * @return  string
136
-		 */
137
-	function getCurrentFolderPath()
138
-	{
139
-		return $this->currentFolderPath;
140
-	}
141
-	/**
142
-		 * get the list of files and folders under this current fold
143
-		 *	@return array
144
-		 */
145
-	function getFileList()
146
-	{
147
-		$outputs = array();
148
-		$files = array();
149
-		$folders = array();
150
-		$tem = array();
151
-		$dirHandler = @opendir($this->currentFolderPath);
152
-		if($dirHandler)
153
-		{
154
-			while(false !== ($file = readdir($dirHandler)))
155
-			{
156
-				if($file != '.' && $file != '..')
157
-				{
158
-					$flag = $this->flags['no'];
122
+    function setSessionAction(&$session)
123
+    {
124
+        $this->sessionAction = $session;	
125
+    }
126
+    /**
127
+     * constructor
128
+     */
129
+    function manager($path = null, $calculateSubdir=true)
130
+    {
131
+        $this->__construct($path, $calculateSubdir);
132
+    }
133
+    /**
134
+     * get current folder path
135
+     * @return  string
136
+     */
137
+    function getCurrentFolderPath()
138
+    {
139
+        return $this->currentFolderPath;
140
+    }
141
+    /**
142
+     * get the list of files and folders under this current fold
143
+     *	@return array
144
+     */
145
+    function getFileList()
146
+    {
147
+        $outputs = array();
148
+        $files = array();
149
+        $folders = array();
150
+        $tem = array();
151
+        $dirHandler = @opendir($this->currentFolderPath);
152
+        if($dirHandler)
153
+        {
154
+            while(false !== ($file = readdir($dirHandler)))
155
+            {
156
+                if($file != '.' && $file != '..')
157
+                {
158
+                    $flag = $this->flags['no'];
159 159
 				
160
-					if($this->sessionAction->getFolder() == $this->currentFolderPath)
161
-					{//check if any flag associated with this folder or file
162
-						$folder = addTrailingSlash(backslashToSlash($this->currentFolderPath));
163
-						if(in_array($folder . $file, $this->sessionAction->get()))
164
-						{
165
-							if($this->sessionAction->getAction() == "copy")
166
-							{
167
-								$flag = $this->flags['copy'];
168
-							}else 
169
-							{
170
-								$flag = $this->flags['cut'];
171
-							}
172
-						}
173
-					}					
174
-					$path=$this->currentFolderPath.$file;
175
-					if(is_dir($path) && isListingDocument($path) )
176
-					{
177
-						$this->currentFolderInfo['subdir']++;
178
-						if(!$this->calculateSubdir)
179
-						{			
180
-						}else 
181
-						{
160
+                    if($this->sessionAction->getFolder() == $this->currentFolderPath)
161
+                    {//check if any flag associated with this folder or file
162
+                        $folder = addTrailingSlash(backslashToSlash($this->currentFolderPath));
163
+                        if(in_array($folder . $file, $this->sessionAction->get()))
164
+                        {
165
+                            if($this->sessionAction->getAction() == "copy")
166
+                            {
167
+                                $flag = $this->flags['copy'];
168
+                            }else 
169
+                            {
170
+                                $flag = $this->flags['cut'];
171
+                            }
172
+                        }
173
+                    }					
174
+                    $path=$this->currentFolderPath.$file;
175
+                    if(is_dir($path) && isListingDocument($path) )
176
+                    {
177
+                        $this->currentFolderInfo['subdir']++;
178
+                        if(!$this->calculateSubdir)
179
+                        {			
180
+                        }else 
181
+                        {
182 182
 							
183
-								$folder = $this->getFolderInfo($path);
184
-								$folder['flag'] = $flag;
185
-								$folders[$file] = $folder;
186
-								$outputs[$file] = $folders[$file];							
187
-						}
183
+                                $folder = $this->getFolderInfo($path);
184
+                                $folder['flag'] = $flag;
185
+                                $folders[$file] = $folder;
186
+                                $outputs[$file] = $folders[$file];							
187
+                        }
188 188
 
189 189
 						
190
-					}elseif(is_file($path) && isListingDocument($path))
191
-					{
190
+                    }elseif(is_file($path) && isListingDocument($path))
191
+                    {
192 192
 
193
-							$obj = new file($path);
194
-							$tem = $obj->getFileInfo();
195
-							if(sizeof($tem))
196
-							{
197
-								$fileType = $this->getFileType($file);
198
-								foreach($fileType as $k=>$v)
199
-								{
200
-									$tem[$k] = $v;
201
-								}
202
-								$this->currentFolderInfo['size'] += $tem['size'];
203
-								$this->currentFolderInfo['file']++;		
204
-								$tem['path'] = backslashToSlash($path);		
205
-								$tem['type'] = "file";
206
-								$tem['flag'] = $flag;
207
-								$files[$file] = $tem;
208
-								$outputs[$file] = $tem;
209
-								$tem = array();
210
-								$obj->close();
193
+                            $obj = new file($path);
194
+                            $tem = $obj->getFileInfo();
195
+                            if(sizeof($tem))
196
+                            {
197
+                                $fileType = $this->getFileType($file);
198
+                                foreach($fileType as $k=>$v)
199
+                                {
200
+                                    $tem[$k] = $v;
201
+                                }
202
+                                $this->currentFolderInfo['size'] += $tem['size'];
203
+                                $this->currentFolderInfo['file']++;		
204
+                                $tem['path'] = backslashToSlash($path);		
205
+                                $tem['type'] = "file";
206
+                                $tem['flag'] = $flag;
207
+                                $files[$file] = $tem;
208
+                                $outputs[$file] = $tem;
209
+                                $tem = array();
210
+                                $obj->close();
211 211
 								
212
-							}							
212
+                            }							
213 213
 
214 214
 				
215
-					}
215
+                    }
216 216
 					
217
-				}
218
-			}
219
-			if($this->forceFolderOnTop)
220
-			{
221
-				uksort($folders, "strnatcasecmp");
222
-				uksort($files, "strnatcasecmp");
223
-				$outputs = array();
224
-				foreach($folders as $v)
225
-				{
226
-					$outputs[] = $v;
227
-				}
228
-				foreach ($files as $v)
229
-				{
230
-					$outputs[] = $v;
231
-				}
232
-			}else 
233
-			{
234
-				uksort($outputs, "strnatcasecmp");
235
-			}
217
+                }
218
+            }
219
+            if($this->forceFolderOnTop)
220
+            {
221
+                uksort($folders, "strnatcasecmp");
222
+                uksort($files, "strnatcasecmp");
223
+                $outputs = array();
224
+                foreach($folders as $v)
225
+                {
226
+                    $outputs[] = $v;
227
+                }
228
+                foreach ($files as $v)
229
+                {
230
+                    $outputs[] = $v;
231
+                }
232
+            }else 
233
+            {
234
+                uksort($outputs, "strnatcasecmp");
235
+            }
236 236
 			
237
-			@closedir($dirHandler);
238
-		}else
239
-		{
240
-			trigger_error('Unable to locate the folder ' . $this->currentFolderPath, E_NOTICE);
241
-		}
242
-		return $outputs;
243
-	}
237
+            @closedir($dirHandler);
238
+        }else
239
+        {
240
+            trigger_error('Unable to locate the folder ' . $this->currentFolderPath, E_NOTICE);
241
+        }
242
+        return $outputs;
243
+    }
244 244
 
245 245
 
246
-	/**
247
-	 * get current or the specified dir information
248
-	 *
249
-	 * @param string $path
250
-	 * @return array
251
-	 */
252
-	function getFolderInfo($path=null)
253
-	{
254
-		if(is_null($path))
255
-		{
256
-			return $this->currentFolderInfo;
257
-		}else 
258
-		{
259
-			$obj = new manager($path, false);
260
-			$obj->setSessionAction($this->sessionAction);
261
-			$obj->getFileList();
262
-			return $obj->getFolderInfo();			
263
-		}
246
+    /**
247
+     * get current or the specified dir information
248
+     *
249
+     * @param string $path
250
+     * @return array
251
+     */
252
+    function getFolderInfo($path=null)
253
+    {
254
+        if(is_null($path))
255
+        {
256
+            return $this->currentFolderInfo;
257
+        }else 
258
+        {
259
+            $obj = new manager($path, false);
260
+            $obj->setSessionAction($this->sessionAction);
261
+            $obj->getFileList();
262
+            return $obj->getFolderInfo();			
263
+        }
264 264
 
265
-	}
265
+    }
266 266
 
267
-		/**
268
-		 * return the file type of a file.
269
-		 *
270
-		 * @param string file name
271
-		 * @return array
272
-		 */
273
-		function getFileType($fileName, $checkIfDir = false) 
274
-		{
267
+        /**
268
+         * return the file type of a file.
269
+         *
270
+         * @param string file name
271
+         * @return array
272
+         */
273
+        function getFileType($fileName, $checkIfDir = false) 
274
+        {
275 275
 			
276
-			$ext = strtolower($this->_getExtension($fileName, $checkIfDir));
276
+            $ext = strtolower($this->_getExtension($fileName, $checkIfDir));
277 277
 			
278
-			foreach ($this->fileTypes as $fileType) 
279
-			{
280
-				if(in_array($ext, $fileType[0]))
281
-				{
282
-					return array("cssClass" => $fileType[1], "fileType" => $fileType[2], "preview" => $fileType[3], 'test'=>5);
283
-				}
284
-			}
285
-			if(!empty($fileName))
286
-			{//this is folder
287
-				if(empty($ext))
288
-				{
289
-					if(is_dir($fileName))
290
-					{
278
+            foreach ($this->fileTypes as $fileType) 
279
+            {
280
+                if(in_array($ext, $fileType[0]))
281
+                {
282
+                    return array("cssClass" => $fileType[1], "fileType" => $fileType[2], "preview" => $fileType[3], 'test'=>5);
283
+                }
284
+            }
285
+            if(!empty($fileName))
286
+            {//this is folder
287
+                if(empty($ext))
288
+                {
289
+                    if(is_dir($fileName))
290
+                    {
291 291
 
292
-						return array("cssClass" => ($checkIfDir && $this->isDirEmpty($fileName)?'folderEmpty':"folder") , "fileType" => "Folder", "preview" => 0, 'test'=>1);
293
-					}else 
294
-					{
295
-						return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>2);
296
-					}
297
-				}else 
298
-				{
299
-					return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>3, 'ext'=>$ext , 'filename'=>$fileName);
300
-				}
292
+                        return array("cssClass" => ($checkIfDir && $this->isDirEmpty($fileName)?'folderEmpty':"folder") , "fileType" => "Folder", "preview" => 0, 'test'=>1);
293
+                    }else 
294
+                    {
295
+                        return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>2);
296
+                    }
297
+                }else 
298
+                {
299
+                    return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>3, 'ext'=>$ext , 'filename'=>$fileName);
300
+                }
301 301
 				
302
-			}else
303
-			{//this is unknown file
304
-				return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>4);
305
-			}
302
+            }else
303
+            {//this is unknown file
304
+                return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>4);
305
+            }
306 306
 		
307 307
 		
308
-		}
308
+        }
309 309
 
310
-	/**
311
-		 * return the predefined file types
312
-		 *
313
-		 * @return arrray
314
-		 */
315
-	function getFileTypes()
316
-	{
317
-		return $this->fileTypes;
318
-	}
319
-	/**
320
-		 * print out the file types
321
-		 *
322
-		 */
323
-	function printFileTypes()
324
-	{
325
-		foreach($fileTypes as $fileType)
326
-		{
327
-			if(isset($fileType[0]) && is_array($fileType[0]))
328
-			{
329
-				foreach($fileType[0] as $type)
330
-				{
331
-					echo $type. ",";
332
-				}
333
-			}
334
-		}
335
-	}
310
+    /**
311
+     * return the predefined file types
312
+     *
313
+     * @return arrray
314
+     */
315
+    function getFileTypes()
316
+    {
317
+        return $this->fileTypes;
318
+    }
319
+    /**
320
+     * print out the file types
321
+     *
322
+     */
323
+    function printFileTypes()
324
+    {
325
+        foreach($fileTypes as $fileType)
326
+        {
327
+            if(isset($fileType[0]) && is_array($fileType[0]))
328
+            {
329
+                foreach($fileType[0] as $type)
330
+                {
331
+                    echo $type. ",";
332
+                }
333
+            }
334
+        }
335
+    }
336 336
 
337 337
     /**
338
-	 * Get the extension of a file name
339
-	 * 
340
-	 * @param  string $file
341
- 	 * @return string
338
+     * Get the extension of a file name
339
+     * 
340
+     * @param  string $file
341
+     * @return string
342 342
      * @copyright this function originally come from Andy's php 
343
-	 */
343
+     */
344 344
     function _getExtension($file, $checkIfDir = false)
345 345
     {
346
-    	if($checkIfDir && file_exists($file) && is_dir($file))
347
-    	{
348
-    		return '';
349
-    	}else 
350
-    	{
351
-    		return @substr(@strrchr($file, "."), 1);
352
-    	}
346
+        if($checkIfDir && file_exists($file) && is_dir($file))
347
+        {
348
+            return '';
349
+        }else 
350
+        {
351
+            return @substr(@strrchr($file, "."), 1);
352
+        }
353 353
     	
354 354
     	
355 355
     }	
356 356
 
357
-	function isDirEmpty($path)
358
-	{
359
-		$dirHandler = @opendir($path);
360
-		if($dirHandler)
361
-		{
362
-			while(false !== ($file = readdir($dirHandler)))
363
-			{
364
-				if($file != '.' && $file != '..')
365
-				{
366
-					@closedir($dirHandler);
367
-					return false;
357
+    function isDirEmpty($path)
358
+    {
359
+        $dirHandler = @opendir($path);
360
+        if($dirHandler)
361
+        {
362
+            while(false !== ($file = readdir($dirHandler)))
363
+            {
364
+                if($file != '.' && $file != '..')
365
+                {
366
+                    @closedir($dirHandler);
367
+                    return false;
368 368
 					
369
-				}
370
-			}
369
+                }
370
+            }
371 371
 			
372
-			@closedir($dirHandler);
372
+            @closedir($dirHandler);
373 373
 				
374
-		}	
375
-		return true;	
376
-	}
374
+        }	
375
+        return true;	
376
+    }
377 377
 }
378 378
 ?>
379 379
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
2
+	if (!defined('AJAX_INIT_DONE'))
3 3
 	{
4 4
 		die('Permission denied');
5 5
 	}
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	 * @since 22/April/2007
12 12
 	 *
13 13
 	 */
14
-require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.file.php");
14
+require_once(dirname(__FILE__).DIRECTORY_SEPARATOR."class.file.php");
15 15
 class manager
16 16
 {
17 17
 	var $currentFolderPath;
@@ -59,60 +59,60 @@  discard block
 block discarded – undo
59 59
 		 * @path the path to a folder
60 60
 		 * @calculateSubdir force to get the subdirectories information
61 61
 		 */		
62
-	function __construct($path = null, $calculateSubdir=true)
62
+	function __construct($path = null, $calculateSubdir = true)
63 63
 	{
64 64
 
65 65
 		$this->calculateSubdir = $calculateSubdir;
66
-		if(defined('CONFIG_SYS_FOLDER_SHOWN_ON_TOP'))
66
+		if (defined('CONFIG_SYS_FOLDER_SHOWN_ON_TOP'))
67 67
 		{
68 68
 			$this->forceFolderOnTop = CONFIG_SYS_FOLDER_SHOWN_ON_TOP;
69 69
 		}
70
-		if(!is_null($path))
70
+		if (!is_null($path))
71 71
 		{
72 72
 			$this->currentFolderPath = $path;
73 73
 
74
-		}elseif(isset($_GET[$this->folderPathIndex]) && file_exists($_GET[$this->folderPathIndex]) && !is_file($_GET[$this->folderPathIndex]) )
74
+		}elseif (isset($_GET[$this->folderPathIndex]) && file_exists($_GET[$this->folderPathIndex]) && !is_file($_GET[$this->folderPathIndex]))
75 75
 		{
76 76
 			$this->currentFolderPath = $_GET[$this->folderPathIndex];
77 77
 		}
78
-		elseif(isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex]))
78
+		elseif (isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex]))
79 79
 		{
80 80
 			$this->currentFolderPath = $_SESSION[$this->lastVisitedFolderPathIndex];
81
-		}else
81
+		} else
82 82
 		{
83 83
 			$this->currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
84 84
 		}
85 85
 		
86
-		$this->currentFolderPath = (isUnderRoot($this->currentFolderPath)?backslashToSlash((addTrailingSlash($this->currentFolderPath))):CONFIG_SYS_DEFAULT_PATH);
86
+		$this->currentFolderPath = (isUnderRoot($this->currentFolderPath) ? backslashToSlash((addTrailingSlash($this->currentFolderPath))) : CONFIG_SYS_DEFAULT_PATH);
87 87
 		
88
-		if($this->calculateSubdir)
88
+		if ($this->calculateSubdir)
89 89
 		{// keep track of this folder path in session 
90 90
 			$_SESSION[$this->lastVisitedFolderPathIndex] = $this->currentFolderPath;
91 91
 		}
92
-		if(is_dir($this->currentFolderPath))
92
+		if (is_dir($this->currentFolderPath))
93 93
 		{
94 94
 			$file = new file($this->currentFolderPath);
95 95
 			$folderInfo = $file->getFileInfo();
96
-			if(sizeof($folderInfo))
96
+			if (sizeof($folderInfo))
97 97
 			{
98
-				$this->currentFolderInfo['name']=basename($this->currentFolderPath);
99
-				$this->currentFolderInfo['subdir']=0;
100
-				$this->currentFolderInfo['file']=0;
101
-				$this->currentFolderInfo['ctime']=$folderInfo['ctime'];
102
-				$this->currentFolderInfo['mtime']=$folderInfo['mtime'];
103
-				$this->currentFolderInfo['is_readable']=$folderInfo['is_readable'];
104
-				$this->currentFolderInfo['is_writable']=$folderInfo['is_writable'];	
105
-				$this->currentFolderInfo['path']  = $this->currentFolderPath;
98
+				$this->currentFolderInfo['name'] = basename($this->currentFolderPath);
99
+				$this->currentFolderInfo['subdir'] = 0;
100
+				$this->currentFolderInfo['file'] = 0;
101
+				$this->currentFolderInfo['ctime'] = $folderInfo['ctime'];
102
+				$this->currentFolderInfo['mtime'] = $folderInfo['mtime'];
103
+				$this->currentFolderInfo['is_readable'] = $folderInfo['is_readable'];
104
+				$this->currentFolderInfo['is_writable'] = $folderInfo['is_writable'];	
105
+				$this->currentFolderInfo['path'] = $this->currentFolderPath;
106 106
 				$this->currentFolderInfo['friendly_path'] = transformFilePath($this->currentFolderPath);
107 107
 				$this->currentFolderInfo['type'] = "folder";
108
-				$this->currentFolderInfo['cssClass']='folder';
108
+				$this->currentFolderInfo['cssClass'] = 'folder';
109 109
 				
110 110
 				//$this->currentFolderInfo['flag'] = $folderInfo['flag'];
111 111
 			}			
112 112
 		}
113
-		if($calculateSubdir && !file_exists($this->currentFolderPath))
113
+		if ($calculateSubdir && !file_exists($this->currentFolderPath))
114 114
 		{
115
-			die(ERR_FOLDER_NOT_FOUND . $this->currentFolderPath);
115
+			die(ERR_FOLDER_NOT_FOUND.$this->currentFolderPath);
116 116
 		}
117 117
 
118 118
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	/**
127 127
 		 * constructor
128 128
 		 */
129
-	function manager($path = null, $calculateSubdir=true)
129
+	function manager($path = null, $calculateSubdir = true)
130 130
 	{
131 131
 		$this->__construct($path, $calculateSubdir);
132 132
 	}
@@ -149,35 +149,35 @@  discard block
 block discarded – undo
149 149
 		$folders = array();
150 150
 		$tem = array();
151 151
 		$dirHandler = @opendir($this->currentFolderPath);
152
-		if($dirHandler)
152
+		if ($dirHandler)
153 153
 		{
154
-			while(false !== ($file = readdir($dirHandler)))
154
+			while (false !== ($file = readdir($dirHandler)))
155 155
 			{
156
-				if($file != '.' && $file != '..')
156
+				if ($file != '.' && $file != '..')
157 157
 				{
158 158
 					$flag = $this->flags['no'];
159 159
 				
160
-					if($this->sessionAction->getFolder() == $this->currentFolderPath)
160
+					if ($this->sessionAction->getFolder() == $this->currentFolderPath)
161 161
 					{//check if any flag associated with this folder or file
162 162
 						$folder = addTrailingSlash(backslashToSlash($this->currentFolderPath));
163
-						if(in_array($folder . $file, $this->sessionAction->get()))
163
+						if (in_array($folder.$file, $this->sessionAction->get()))
164 164
 						{
165
-							if($this->sessionAction->getAction() == "copy")
165
+							if ($this->sessionAction->getAction() == "copy")
166 166
 							{
167 167
 								$flag = $this->flags['copy'];
168
-							}else 
168
+							} else 
169 169
 							{
170 170
 								$flag = $this->flags['cut'];
171 171
 							}
172 172
 						}
173 173
 					}					
174
-					$path=$this->currentFolderPath.$file;
175
-					if(is_dir($path) && isListingDocument($path) )
174
+					$path = $this->currentFolderPath.$file;
175
+					if (is_dir($path) && isListingDocument($path))
176 176
 					{
177 177
 						$this->currentFolderInfo['subdir']++;
178
-						if(!$this->calculateSubdir)
178
+						if (!$this->calculateSubdir)
179 179
 						{			
180
-						}else 
180
+						} else 
181 181
 						{
182 182
 							
183 183
 								$folder = $this->getFolderInfo($path);
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 						}
188 188
 
189 189
 						
190
-					}elseif(is_file($path) && isListingDocument($path))
190
+					}elseif (is_file($path) && isListingDocument($path))
191 191
 					{
192 192
 
193 193
 							$obj = new file($path);
194 194
 							$tem = $obj->getFileInfo();
195
-							if(sizeof($tem))
195
+							if (sizeof($tem))
196 196
 							{
197 197
 								$fileType = $this->getFileType($file);
198
-								foreach($fileType as $k=>$v)
198
+								foreach ($fileType as $k=>$v)
199 199
 								{
200 200
 									$tem[$k] = $v;
201 201
 								}
@@ -216,12 +216,12 @@  discard block
 block discarded – undo
216 216
 					
217 217
 				}
218 218
 			}
219
-			if($this->forceFolderOnTop)
219
+			if ($this->forceFolderOnTop)
220 220
 			{
221 221
 				uksort($folders, "strnatcasecmp");
222 222
 				uksort($files, "strnatcasecmp");
223 223
 				$outputs = array();
224
-				foreach($folders as $v)
224
+				foreach ($folders as $v)
225 225
 				{
226 226
 					$outputs[] = $v;
227 227
 				}
@@ -229,15 +229,15 @@  discard block
 block discarded – undo
229 229
 				{
230 230
 					$outputs[] = $v;
231 231
 				}
232
-			}else 
232
+			} else 
233 233
 			{
234 234
 				uksort($outputs, "strnatcasecmp");
235 235
 			}
236 236
 			
237 237
 			@closedir($dirHandler);
238
-		}else
238
+		} else
239 239
 		{
240
-			trigger_error('Unable to locate the folder ' . $this->currentFolderPath, E_NOTICE);
240
+			trigger_error('Unable to locate the folder '.$this->currentFolderPath, E_NOTICE);
241 241
 		}
242 242
 		return $outputs;
243 243
 	}
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
 	 * @param string $path
250 250
 	 * @return array
251 251
 	 */
252
-	function getFolderInfo($path=null)
252
+	function getFolderInfo($path = null)
253 253
 	{
254
-		if(is_null($path))
254
+		if (is_null($path))
255 255
 		{
256 256
 			return $this->currentFolderInfo;
257
-		}else 
257
+		} else 
258 258
 		{
259 259
 			$obj = new manager($path, false);
260 260
 			$obj->setSessionAction($this->sessionAction);
@@ -277,29 +277,29 @@  discard block
 block discarded – undo
277 277
 			
278 278
 			foreach ($this->fileTypes as $fileType) 
279 279
 			{
280
-				if(in_array($ext, $fileType[0]))
280
+				if (in_array($ext, $fileType[0]))
281 281
 				{
282 282
 					return array("cssClass" => $fileType[1], "fileType" => $fileType[2], "preview" => $fileType[3], 'test'=>5);
283 283
 				}
284 284
 			}
285
-			if(!empty($fileName))
285
+			if (!empty($fileName))
286 286
 			{//this is folder
287
-				if(empty($ext))
287
+				if (empty($ext))
288 288
 				{
289
-					if(is_dir($fileName))
289
+					if (is_dir($fileName))
290 290
 					{
291 291
 
292
-						return array("cssClass" => ($checkIfDir && $this->isDirEmpty($fileName)?'folderEmpty':"folder") , "fileType" => "Folder", "preview" => 0, 'test'=>1);
293
-					}else 
292
+						return array("cssClass" => ($checkIfDir && $this->isDirEmpty($fileName) ? 'folderEmpty' : "folder"), "fileType" => "Folder", "preview" => 0, 'test'=>1);
293
+					} else 
294 294
 					{
295 295
 						return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>2);
296 296
 					}
297
-				}else 
297
+				} else 
298 298
 				{
299
-					return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>3, 'ext'=>$ext , 'filename'=>$fileName);
299
+					return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>3, 'ext'=>$ext, 'filename'=>$fileName);
300 300
 				}
301 301
 				
302
-			}else
302
+			} else
303 303
 			{//this is unknown file
304 304
 				return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>4);
305 305
 			}
@@ -322,13 +322,13 @@  discard block
 block discarded – undo
322 322
 		 */
323 323
 	function printFileTypes()
324 324
 	{
325
-		foreach($fileTypes as $fileType)
325
+		foreach ($fileTypes as $fileType)
326 326
 		{
327
-			if(isset($fileType[0]) && is_array($fileType[0]))
327
+			if (isset($fileType[0]) && is_array($fileType[0]))
328 328
 			{
329
-				foreach($fileType[0] as $type)
329
+				foreach ($fileType[0] as $type)
330 330
 				{
331
-					echo $type. ",";
331
+					echo $type.",";
332 332
 				}
333 333
 			}
334 334
 		}
@@ -343,10 +343,10 @@  discard block
 block discarded – undo
343 343
 	 */
344 344
     function _getExtension($file, $checkIfDir = false)
345 345
     {
346
-    	if($checkIfDir && file_exists($file) && is_dir($file))
346
+    	if ($checkIfDir && file_exists($file) && is_dir($file))
347 347
     	{
348 348
     		return '';
349
-    	}else 
349
+    	} else 
350 350
     	{
351 351
     		return @substr(@strrchr($file, "."), 1);
352 352
     	}
@@ -357,11 +357,11 @@  discard block
 block discarded – undo
357 357
 	function isDirEmpty($path)
358 358
 	{
359 359
 		$dirHandler = @opendir($path);
360
-		if($dirHandler)
360
+		if ($dirHandler)
361 361
 		{
362
-			while(false !== ($file = readdir($dirHandler)))
362
+			while (false !== ($file = readdir($dirHandler)))
363 363
 			{
364
-				if($file != '.' && $file != '..')
364
+				if ($file != '.' && $file != '..')
365 365
 				{
366 366
 					@closedir($dirHandler);
367 367
 					return false;
Please login to merge, or discard this patch.
Braces   +13 added lines, -14 removed lines patch added patch discarded remove patch
@@ -71,14 +71,13 @@  discard block
 block discarded – undo
71 71
 		{
72 72
 			$this->currentFolderPath = $path;
73 73
 
74
-		}elseif(isset($_GET[$this->folderPathIndex]) && file_exists($_GET[$this->folderPathIndex]) && !is_file($_GET[$this->folderPathIndex]) )
74
+		} elseif(isset($_GET[$this->folderPathIndex]) && file_exists($_GET[$this->folderPathIndex]) && !is_file($_GET[$this->folderPathIndex]) )
75 75
 		{
76 76
 			$this->currentFolderPath = $_GET[$this->folderPathIndex];
77
-		}
78
-		elseif(isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex]))
77
+		} elseif(isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex]))
79 78
 		{
80 79
 			$this->currentFolderPath = $_SESSION[$this->lastVisitedFolderPathIndex];
81
-		}else
80
+		} else
82 81
 		{
83 82
 			$this->currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
84 83
 		}
@@ -165,7 +164,7 @@  discard block
 block discarded – undo
165 164
 							if($this->sessionAction->getAction() == "copy")
166 165
 							{
167 166
 								$flag = $this->flags['copy'];
168
-							}else 
167
+							} else 
169 168
 							{
170 169
 								$flag = $this->flags['cut'];
171 170
 							}
@@ -177,7 +176,7 @@  discard block
 block discarded – undo
177 176
 						$this->currentFolderInfo['subdir']++;
178 177
 						if(!$this->calculateSubdir)
179 178
 						{			
180
-						}else 
179
+						} else 
181 180
 						{
182 181
 							
183 182
 								$folder = $this->getFolderInfo($path);
@@ -187,7 +186,7 @@  discard block
 block discarded – undo
187 186
 						}
188 187
 
189 188
 						
190
-					}elseif(is_file($path) && isListingDocument($path))
189
+					} elseif(is_file($path) && isListingDocument($path))
191 190
 					{
192 191
 
193 192
 							$obj = new file($path);
@@ -229,13 +228,13 @@  discard block
 block discarded – undo
229 228
 				{
230 229
 					$outputs[] = $v;
231 230
 				}
232
-			}else 
231
+			} else 
233 232
 			{
234 233
 				uksort($outputs, "strnatcasecmp");
235 234
 			}
236 235
 			
237 236
 			@closedir($dirHandler);
238
-		}else
237
+		} else
239 238
 		{
240 239
 			trigger_error('Unable to locate the folder ' . $this->currentFolderPath, E_NOTICE);
241 240
 		}
@@ -254,7 +253,7 @@  discard block
 block discarded – undo
254 253
 		if(is_null($path))
255 254
 		{
256 255
 			return $this->currentFolderInfo;
257
-		}else 
256
+		} else 
258 257
 		{
259 258
 			$obj = new manager($path, false);
260 259
 			$obj->setSessionAction($this->sessionAction);
@@ -290,16 +289,16 @@  discard block
 block discarded – undo
290 289
 					{
291 290
 
292 291
 						return array("cssClass" => ($checkIfDir && $this->isDirEmpty($fileName)?'folderEmpty':"folder") , "fileType" => "Folder", "preview" => 0, 'test'=>1);
293
-					}else 
292
+					} else 
294 293
 					{
295 294
 						return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>2);
296 295
 					}
297
-				}else 
296
+				} else 
298 297
 				{
299 298
 					return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>3, 'ext'=>$ext , 'filename'=>$fileName);
300 299
 				}
301 300
 				
302
-			}else
301
+			} else
303 302
 			{//this is unknown file
304 303
 				return array("cssClass" => "fileUnknown", "fileType" => SEARCH_TYPE_UNKNOWN, "preview" => 0, 'test'=>4);
305 304
 			}
@@ -346,7 +345,7 @@  discard block
 block discarded – undo
346 345
     	if($checkIfDir && file_exists($file) && is_dir($file))
347 346
     	{
348 347
     		return '';
349
-    	}else 
348
+    	} else 
350 349
     	{
351 350
     		return @substr(@strrchr($file, "."), 1);
352 351
     	}
Please login to merge, or discard this patch.
phpmyfaq/admin/editor/plugins/ajaxfilemanager/inc/class.pagination.php 4 patches
Doc Comments   +3 added lines, -5 removed lines patch added patch discarded remove patch
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 	/**
218 218
 	 * get the first item number
219 219
 	 *
220
-	 * @return interger the first item number displayed within current page
220
+	 * @return integer the first item number displayed within current page
221 221
 	 */
222 222
 	function getFirstItem()
223 223
 	{
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	/**
234 234
 	 * get the last item number displayed within current page
235 235
 	 *
236
-	 * @return interger the last item number
236
+	 * @return integer the last item number
237 237
 	 */
238 238
 	function getLastItem()
239 239
 	{
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 * used for Query . e.g SELECT SQL_CALC_FOUND_ROWS *
277 277
 	 * 						FROM mytable LIMIT getPageOffset(), getItemsPerPage()
278 278
 	 *
279
-	 * @return iner
279
+	 * @return integer
280 280
 	 */
281 281
 	function getPageOffset()
282 282
 	{
@@ -341,7 +341,6 @@  discard block
 block discarded – undo
341 341
 	/**
342 342
 	 * get the previous page url if anywhere
343 343
 	 *
344
-	 * @param array $excludedQueryStrings excluded the value from $_GET
345 344
 	 * @return string the previous page url
346 345
 	 */
347 346
 	function getPreviousUrl()
@@ -368,7 +367,6 @@  discard block
 block discarded – undo
368 367
 	/**
369 368
 	 * get the next page url if anywhere
370 369
 	 *
371
-	 * @param array $excludedQueryStrings excluded the value from $_GET
372 370
 	 * @return string the next page url
373 371
 	 */
374 372
 	function getNextUrl()
Please login to merge, or discard this patch.
Indentation   +581 added lines, -581 removed lines patch added patch discarded remove patch
@@ -1,589 +1,589 @@
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
3
-	{
4
-		die('Permission denied');
5
-	}
2
+    if(!defined('AJAX_INIT_DONE'))
3
+    {
4
+        die('Permission denied');
5
+    }
6 6
 ?><?php
7 7
 /**
8
- * Pagination Class
9
- * @author Logan Cai  (cailongqun [at] yahoo [dot] com [dot] cn)
10
- * @since 27/Nov/20006
11
- *
12
- */
8
+     * Pagination Class
9
+     * @author Logan Cai  (cailongqun [at] yahoo [dot] com [dot] cn)
10
+     * @since 27/Nov/20006
11
+     *
12
+     */
13 13
 class pagination
14 14
 {
15
-	var $totalItems = 0;
16
-	var $itemsPerPage = 30;
17
-	var $currentPage = 1;
18
-	var $friendlyUrl = false;
19
-	var $baseUrl = "";
20
-	var $pageIndex = "page";
21
-	var $groupLimit = 5;
22
-	var $excludedQueryStrings = array();
23
-	var $totalPages = 0;
24
-	var $url = "";
25
-	var $previousText = "Previous";
26
-	var $nextText = "Next";
27
-	var $lastText = "Last";
28
-	var $firstText = "First";
29
-	var $limitIndex ='limit';
30
-	var $limits = array(5, 10, 20, 30, 50, 80, 150, 999);
31
-
32
-
33
-	/**
34
-	 * Contructor
35
-	 *
36
-	 * @param boolean $friendlyUrl set the returned url
37
-	 * as search engine friendly or Normal Url
38
-	 */
39
-	function pagination($friendlyUrl=false)
40
-	{
41
-		$this->friendlyUrl = $friendlyUrl;
42
-		$this->__resetCurrentPage();
43
-	}
44
-
45
-	/**
46
-	 * set maximum number of items per page
47
-	 *
48
-	 * @param integer $value maximum number of items per page
49
-	 */
50
-	function setLimit($value)
51
-	{
52
-		$this->itemsPerPage = intval($value);
53
-	}
54
-	/**
55
-	 * get maximum number of items per page
56
-	 *
57
-	 * @return integer
58
-	 */
59
-	function getLimit()
60
-	{
61
-		return $this->itemsPerPage;
62
-	}
63
-
64
-	/**
65
-	 * set the total number of items
66
-	 *
67
-	 * @param integer $value the total number of items
68
-	 */
69
-	function setTotal($value)
70
-	{
71
-		$this->totalItems = intval($value);
72
-	}
73
-	/**
74
-	 * get the total number of items
75
-	 *
76
-	 * @return integer total number of items
77
-	 */
78
-	function getTotal()
79
-	{
80
-		return $this->totalItems;
81
-	}
82
-	/**
83
-	 * get total pages will be used to display all records
84
-	 *
85
-	 */
86
-	function getTotalPages()
87
-	{
88
-
89
-		$output = floor(($this->totalItems / $this->itemsPerPage ));
90
-		if($this->totalItems % $this->itemsPerPage)
91
-		{
92
-			$output++;
93
-		}
94
-		return $output;
95
-	}
96
-
97
-	/**
98
-	 * Set the index of URL Query String
99
-	 *
100
-	 * @param string $value e.g. page
101
-	 */
102
-	function setPageIndex($value)
103
-	{
104
-		$this->pageIndex = $value;
105
-		$this->__resetCurrentPage();
106
-	}
107
-
108
-
109
-	function getPageIndex()
110
-	{
111
-		return $this->pageIndex;
112
-	}
113
-	/**
114
-	 * initiate or reset the current page number
115
-	 *
116
-	 */
117
-	function __resetCurrentPage()
118
-	{
119
-		$this->currentPage = ((isset($_GET[$this->pageIndex]) && intval($_GET[$this->pageIndex]) > 0)?intval($_GET[$this->pageIndex]):1);
120
-	}
121
-
122
-	/**
123
-	 * set the base url used in the links, default is $PHP_SELF
124
-	 *
125
-	 * @param string $value the base url
126
-	 */
127
-	function setUrl($value="")
128
-	{
129
-		if(empty($value))
130
-		{
131
-			if($this->friendlyUrl)
132
-			{
133
-				$this->url = "http://" . $_SERVER['HTTP_HOST'] . "/";
134
-			}else
135
-			{
136
-				$this->url = $_SERVER['PHP_SELF'];
137
-			}
138
-		}else
139
-		{
140
-			$this->url = $value;
141
-		}
142
-
143
-	}
144
-
145
-	/**
146
-	 * get the base url variable
147
-	 *
148
-	 * @return string the base url
149
-	 */
150
-	function getUrl()
151
-	{
152
-
153
-		if(empty($this->url))
154
-		{
155
-			$this->setUrl();
156
-
157
-		}
158
-		return $this->url;
159
-	}
160
-
161
-	/**
162
-	 * set base url for pagination links after exculed those keys
163
-	 * identified on excluded query strings
164
-	 */
165
-	function __setBaseUrl()
166
-	{
167
-
168
-		if(empty($this->url))
169
-		{
170
-			$this->getUrl();
171
-		}
172
-
173
-		if($this->friendlyUrl)
174
-		{
175
-			$this->baseUrl = $this->getUrl();
176
-		}else
177
-		{
178
-
179
-			$appendingQueryStrings = array();
180
-			$this->excludedQueryStrings[$this->pageIndex] =$this->pageIndex;
181
-			foreach($_GET as $k=>$v)
182
-			{
183
-				if((array_search($k, $this->excludedQueryStrings) === false ))
184
-				{
185
-					$appendingQueryStrings[$k] = $k . "=" . $v;
186
-				}
187
-			}
188
-			if(sizeof($appendingQueryStrings))
189
-			{
190
-				$this->baseUrl = $this->__appendQueryString($this->url, implode("&", $appendingQueryStrings));
191
-			}else
192
-			{
193
-				$this->baseUrl = $this->getUrl();
194
-			}
195
-
196
-		}
197
-
198
-
199
-	}
200
-	/**
201
-	 * get base url for pagination links aftr excluded those key
202
-	 * identified on excluded query strings
203
-	 *
204
-	 */
205
-	function __getBaseUrl()
206
-	{
207
-
208
-		if(empty($this->baseUrl))
209
-		{
210
-
211
-			$this->__setBaseUrl();
212
-		}
213
-		return $this->baseUrl;
214
-	}
215
-
216
-
217
-	/**
218
-	 * get the first item number
219
-	 *
220
-	 * @return interger the first item number displayed within current page
221
-	 */
222
-	function getFirstItem()
223
-	{
224
-		$output = 0;
225
-		$temStartItemNumber = (($this->currentPage - 1) * $this->itemsPerPage + 1);
226
-		if($this->totalItems && $temStartItemNumber <= $this->totalItems )
227
-		{
228
-
229
-			$output = $temStartItemNumber;
230
-		}
231
-		return $output;
232
-	}
233
-	/**
234
-	 * get the last item number displayed within current page
235
-	 *
236
-	 * @return interger the last item number
237
-	 */
238
-	function getLastItem()
239
-	{
240
-		$output = 0;
241
-		$temEndItemNumber = (($this->currentPage) * $this->itemsPerPage);
242
-		if($this->totalItems)
243
-		{
244
-			if($temEndItemNumber <= $this->totalItems)
245
-			{
246
-				$output = $temEndItemNumber;
247
-			}else
248
-			{
249
-				$output = $this->totalItems;
250
-			}
251
-
252
-		}
253
-		return $output;
254
-	}
255
-	/**
256
-	 * set  page groupings limit
257
-	 * used for previous 1 2 3 4 5 next
258
-	 *
259
-	 * @param unknown_type $value
260
-	 */
261
-	function setGroupLimit($value)
262
-	{
263
-		$this->groupLimit = intval($value);
264
-	}
265
-	/**
266
-	 * get page grouping limit
267
-	 *
268
-	 * @return integer the page grouping limit
269
-	 */
270
-	function getGroupLimit()
271
-	{
272
-		return $this->groupLimit;
273
-	}
274
-	/**
275
-	 * get the page offset number
276
-	 * used for Query . e.g SELECT SQL_CALC_FOUND_ROWS *
277
-	 * 						FROM mytable LIMIT getPageOffset(), getItemsPerPage()
278
-	 *
279
-	 * @return iner
280
-	 */
281
-	function getPageOffset()
282
-	{
283
-		return (($this->currentPage - 1)  * $this->itemsPerPage);
284
-	}
285
-	/**
286
-	 * get the last url if any
287
-	 * @return  string the last url
288
-	 */
289
-	function getLastUrl()
290
-	{
291
-
292
-		$url = "";
293
-		$totalPages = $this->getTotalPages();
294
-		if($this->currentPage < $totalPages)
295
-		{
296
-			$url = $this->__getBaseUrl();
297
-
298
-			if($this->friendlyUrl)
299
-			{
300
-				$url .= $this->pageIndex . $totalPages . "/";
301
-			}else
302
-			{
303
-				$url = $this->__appendQueryString($url, $this->pageIndex . "=" . $totalPages);
304
-			}
305
-			$url = sprintf('<a href="%s" class="pagination_last"><span>%s</span></a>',
306
-			$url,
307
-			$this->lastText);
308
-		}
309
-		return $url;
310
-	}
311
-
312
-
313
-
314
-
315
-	/**
316
-	 * get the first url if any
317
-	 * @return string the first url
318
-	 */
319
-
320
-	function getFirstUrl()
321
-	{
322
-		$url = "";
323
-		if($this->currentPage > 1)
324
-		{
325
-			$url = $this->__getBaseUrl();
326
-			if($this->friendlyUrl)
327
-			{
328
-				$url .= $this->pageIndex .  "1/";
329
-			}else
330
-			{
331
-				$url = $this->__appendQueryString($url, $this->pageIndex . "=1");
332
-			}
333
-			$url = sprintf('<a href="%s" class="pagination_first"><span>%s</span></a>',
334
-			$url,
335
-			$this->firstText);
336
-
337
-		}
338
-		return $url;
339
-	}
340
-
341
-	/**
342
-	 * get the previous page url if anywhere
343
-	 *
344
-	 * @param array $excludedQueryStrings excluded the value from $_GET
345
-	 * @return string the previous page url
346
-	 */
347
-	function getPreviousUrl()
348
-	{
349
-		$url = "";
350
-		if($this->currentPage > 1 && $this->totalItems > 0 )
351
-		{
352
-			$url = $this->__getBaseUrl();
353
-			if($this->friendlyUrl)
354
-			{
355
-				$url .= $this->pageIndex . ($this->currentPage - 1) . "/";
356
-			}else
357
-			{
358
-				$url = $this->__appendQueryString($url, $this->pageIndex . "=" . ($this->currentPage -1));
359
-			}
360
-			$url = sprintf('<a href="%s" class="pagination_previous"><span>%s</span></a>',
361
-			$url,
362
-			$this->previousText);
363
-
364
-		}
365
-
366
-		return $url;
367
-	}
368
-	/**
369
-	 * get the next page url if anywhere
370
-	 *
371
-	 * @param array $excludedQueryStrings excluded the value from $_GET
372
-	 * @return string the next page url
373
-	 */
374
-	function getNextUrl()
375
-	{
376
-		$url = "";
377
-		if($this->totalItems > ($this->currentPage * $this->itemsPerPage))
378
-		{
379
-			$url = $this->__getBaseUrl();
380
-			if($this->friendlyUrl)
381
-			{
382
-				$url .= $this->pageIndex . ($this->currentPage + 1) . "/";
383
-			}else
384
-			{
385
-				$url = $this->__appendQueryString($url, $this->pageIndex . "=" . ($this->currentPage + 1));
386
-			}
387
-			$url = sprintf('<a href="%s" class="pagination_next"><span>%s</span></a>',
388
-			$url,
389
-			$this->nextText);
390
-		}
391
-		return $url;
392
-
393
-	}
394
-
395
-	/**
396
-	 * get the group page links  e.g. 1,2,3,4,5
397
-	 * return format
398
-	 * <a class="pagination_group" href='yoururl'>1</a>
399
-	 * <a class="pagination_group active" href='#'>2</a>
400
-	 * <a class="pagination_group" href='yoururl'>3</a>
401
-	 */
402
-	function getGroupUrls()
403
-	{
404
-		$output = "";
405
-		if($this->totalItems > 0)
406
-		{
407
-			$displayedPages = 0;
408
-			$url = $this->__getBaseUrl();
409
-			$totalPages = $this->getTotalPages();
410
-			// find halfway point
411
-			$groupLimitHalf = floor($this->groupLimit / 2);
412
-			// determine what item/page we start with
413
-			$itemStart = $this->currentPage - $groupLimitHalf;
414
-			$itemStart = ($itemStart > 0 && $itemStart <= $totalPages)?$itemStart:1;
415
-			$itemEnd = $itemStart;
416
-
417
-			while($itemEnd < ($itemStart + $this->groupLimit - 1) && $itemEnd < $totalPages)
418
-			{
419
-				$itemEnd++;
420
-			}
421
-
422
-
423
-			if($totalPages > ($itemEnd - $itemStart))
424
-			{
425
-				for($i = $itemStart; $i > 1 && ($itemEnd - $itemStart + 1) < $this->groupLimit; $i--)
426
-				{
427
-					$itemStart--;
428
-				}
429
-			}
430
-
431
-			for($item = $itemStart; $item <= $itemEnd; $item++)
432
-			{
433
-				if($item != $this->currentPage)
434
-				{//it is not the active link
435
-					if($this->friendlyUrl)
436
-					{
437
-						$temUrl = $url . $this->pageIndex . $item .   "/";
438
-					}else
439
-					{
440
-						$temUrl  = $this->__appendQueryString($url, $this->pageIndex . "=" . $item);
441
-					}
442
-					$output .= sprintf(' <a class="pagination_group" href="%s"><span>%d</span></a> ', $temUrl, $item);
443
-				}else
444
-				{//active link
445
-					$output .= sprintf(' <a class="pagination_group pagination_active" href="#"><span>%d</span></a> ', $item);
446
-				}
447
-			}
448
-		}
449
-		return $output;
450
-	}
451
-	/**
452
-	 * set the text of previous page link
453
-	 *
454
-	 * @param string $value
455
-	 */
456
-	function setPreviousText($value)
457
-	{
458
-		$this->previousText = $value;
459
-	}
460
-	/**
461
-	 * set the text of first page link
462
-	 *
463
-	 * @param string $value
464
-	 */
465
-	function setFirstText($value)
466
-	{
467
-		$this->firstText = $value;
468
-	}
469
-	/**
470
-	 * set the text of next page link
471
-	 *
472
-	 * @param string $value
473
-	 */
474
-
475
-	function setNextText($value)
476
-	{
477
-		$this->nextText = $value;
478
-	}
479
-	/**
480
-	 * set the text of last page link
481
-	 *
482
-	 * @param string $value
483
-	 */
484
-	function setLastText($value)
485
-	{
486
-		$this->lastText = $value;
487
-	}
488
-
489
-	/**
490
-	 * set the excluded query string from $_GET;
491
-	 *
492
-	 * @param array the lists of the query string keys
493
-	 */
494
-
495
-	function setExcludedQueryString($values = array())
496
-	{
497
-		$this->excludedQueryStrings = $values;
498
-	}
499
-
500
-	function getExcludedQueryString()
501
-	{
502
-		return $this->excludedQueryStrings;
503
-	}
504
-
505
-
506
-	/**
507
-	 * add extra query stiring to a url
508
-	 * @param string $baseUrl
509
-	 * @param string $extra the query string added to the base url
510
-	 */
511
-	function __appendQueryString($baseUrl, $extra)
512
-	{
513
-		$output = trim($baseUrl);
514
-		if(strpos($baseUrl, "?") !== false)
515
-		{
516
-			$output .= "&" . $extra;
517
-		}else
518
-		{
519
-			$output .= "?" . $extra;
520
-		}
521
-		return $output;
522
-	}
523
-	/**
524
-	 * return the html
525
-	 *
526
-	 * @param integer $type
527
-	 */
528
-	function getPaginationHTML($type=1, $cssClass="pagination")
529
-	{
530
-		$output = '';
531
-		$output .= "<div class=\"pagination_content\"><p class=\"$cssClass\">\n";
532
-		switch($type)
533
-		{
534
-			case "2":
535
-				$output .= "<span class=\"pagination_summany\">" . $this->getFirstItem() . " to " . $this->getLastItem() . " of " . $this->getTotal() . " results.</span> ";	
536
-			if($previousUrl = $this->getPreviousUrl())
537
-			{
538
-				$output .= " " . $previousUrl;
539
-			}
540
-
541
-			if($nextUrl = $this->getNextUrl())
542
-			{
543
-				$output .= " " . $nextUrl;
544
-			}							
545
-				break;
546
-			case 1:
547
-				//get full summary pagination
548
-			default:
549
-				$output .= "<span class=\"pagination_summany\">" . $this->getFirstItem() . "/" . $this->getLastItem() . " (" . $this->getTotal() . ")</span> ";
550
-			if($firstUrl = $this->getFirstUrl())
551
-			{
552
-				$output .= " " . $firstUrl;
553
-			}
554
-			if($previousUrl = $this->getPreviousUrl())
555
-			{
556
-				$output .= " " . $previousUrl;
557
-			}
558
-
559
-			if($groupUrls = $this->getGroupUrls())
560
-			{
561
-				$output .= " " . $groupUrls;
562
-			}
563
-			if($nextUrl = $this->getNextUrl())
564
-			{
565
-				$output .= " " . $nextUrl;
566
-			}
567
-			if($lastUrl = $this->getLastUrl())
568
-			{
569
-				$output .= " " . $lastUrl;
570
-			}
571
-			$itemPerPage = '';
572
-			$itemPerPage .= "<select name=\"" . $this->limitIndex . "\" id=\"limit\" class=\"input inputLimit\" onchange=\"changePaginationLimit();\">\n";
573
-			foreach ($this->limits as $v)
574
-			{
575
-				$itemPerPage .= "<option value=\"" . $v . "\" " . ($v==$this->itemsPerPage?'selected="selected"':'') . ">" . $v . "</option>\n";
576
-			}
577
-			$itemPerPage .= "</select>\n"; 
578
-			$output .= "<span class=\"pagination_items_per_page\">";
579
-			$output .= sprintf(PAGINATION_ITEMS_PER_PAGE, $itemPerPage);
580
-			$output .= "</span>";
581
-			$output .= "<span class=\"pagination_parent\"><a href=\"#\" onclick=\"goParentFolder();\" id=\"pagination_parent_link\" title=\"" . PAGINATION_GO_PARENT . "\">&nbsp;</a></span>";
582
-		}
583
-
584
-		$output .= "</p></div>";
585
-		return $output;
586
-	}
15
+    var $totalItems = 0;
16
+    var $itemsPerPage = 30;
17
+    var $currentPage = 1;
18
+    var $friendlyUrl = false;
19
+    var $baseUrl = "";
20
+    var $pageIndex = "page";
21
+    var $groupLimit = 5;
22
+    var $excludedQueryStrings = array();
23
+    var $totalPages = 0;
24
+    var $url = "";
25
+    var $previousText = "Previous";
26
+    var $nextText = "Next";
27
+    var $lastText = "Last";
28
+    var $firstText = "First";
29
+    var $limitIndex ='limit';
30
+    var $limits = array(5, 10, 20, 30, 50, 80, 150, 999);
31
+
32
+
33
+    /**
34
+     * Contructor
35
+     *
36
+     * @param boolean $friendlyUrl set the returned url
37
+     * as search engine friendly or Normal Url
38
+     */
39
+    function pagination($friendlyUrl=false)
40
+    {
41
+        $this->friendlyUrl = $friendlyUrl;
42
+        $this->__resetCurrentPage();
43
+    }
44
+
45
+    /**
46
+     * set maximum number of items per page
47
+     *
48
+     * @param integer $value maximum number of items per page
49
+     */
50
+    function setLimit($value)
51
+    {
52
+        $this->itemsPerPage = intval($value);
53
+    }
54
+    /**
55
+     * get maximum number of items per page
56
+     *
57
+     * @return integer
58
+     */
59
+    function getLimit()
60
+    {
61
+        return $this->itemsPerPage;
62
+    }
63
+
64
+    /**
65
+     * set the total number of items
66
+     *
67
+     * @param integer $value the total number of items
68
+     */
69
+    function setTotal($value)
70
+    {
71
+        $this->totalItems = intval($value);
72
+    }
73
+    /**
74
+     * get the total number of items
75
+     *
76
+     * @return integer total number of items
77
+     */
78
+    function getTotal()
79
+    {
80
+        return $this->totalItems;
81
+    }
82
+    /**
83
+     * get total pages will be used to display all records
84
+     *
85
+     */
86
+    function getTotalPages()
87
+    {
88
+
89
+        $output = floor(($this->totalItems / $this->itemsPerPage ));
90
+        if($this->totalItems % $this->itemsPerPage)
91
+        {
92
+            $output++;
93
+        }
94
+        return $output;
95
+    }
96
+
97
+    /**
98
+     * Set the index of URL Query String
99
+     *
100
+     * @param string $value e.g. page
101
+     */
102
+    function setPageIndex($value)
103
+    {
104
+        $this->pageIndex = $value;
105
+        $this->__resetCurrentPage();
106
+    }
107
+
108
+
109
+    function getPageIndex()
110
+    {
111
+        return $this->pageIndex;
112
+    }
113
+    /**
114
+     * initiate or reset the current page number
115
+     *
116
+     */
117
+    function __resetCurrentPage()
118
+    {
119
+        $this->currentPage = ((isset($_GET[$this->pageIndex]) && intval($_GET[$this->pageIndex]) > 0)?intval($_GET[$this->pageIndex]):1);
120
+    }
121
+
122
+    /**
123
+     * set the base url used in the links, default is $PHP_SELF
124
+     *
125
+     * @param string $value the base url
126
+     */
127
+    function setUrl($value="")
128
+    {
129
+        if(empty($value))
130
+        {
131
+            if($this->friendlyUrl)
132
+            {
133
+                $this->url = "http://" . $_SERVER['HTTP_HOST'] . "/";
134
+            }else
135
+            {
136
+                $this->url = $_SERVER['PHP_SELF'];
137
+            }
138
+        }else
139
+        {
140
+            $this->url = $value;
141
+        }
142
+
143
+    }
144
+
145
+    /**
146
+     * get the base url variable
147
+     *
148
+     * @return string the base url
149
+     */
150
+    function getUrl()
151
+    {
152
+
153
+        if(empty($this->url))
154
+        {
155
+            $this->setUrl();
156
+
157
+        }
158
+        return $this->url;
159
+    }
160
+
161
+    /**
162
+     * set base url for pagination links after exculed those keys
163
+     * identified on excluded query strings
164
+     */
165
+    function __setBaseUrl()
166
+    {
167
+
168
+        if(empty($this->url))
169
+        {
170
+            $this->getUrl();
171
+        }
172
+
173
+        if($this->friendlyUrl)
174
+        {
175
+            $this->baseUrl = $this->getUrl();
176
+        }else
177
+        {
178
+
179
+            $appendingQueryStrings = array();
180
+            $this->excludedQueryStrings[$this->pageIndex] =$this->pageIndex;
181
+            foreach($_GET as $k=>$v)
182
+            {
183
+                if((array_search($k, $this->excludedQueryStrings) === false ))
184
+                {
185
+                    $appendingQueryStrings[$k] = $k . "=" . $v;
186
+                }
187
+            }
188
+            if(sizeof($appendingQueryStrings))
189
+            {
190
+                $this->baseUrl = $this->__appendQueryString($this->url, implode("&", $appendingQueryStrings));
191
+            }else
192
+            {
193
+                $this->baseUrl = $this->getUrl();
194
+            }
195
+
196
+        }
197
+
198
+
199
+    }
200
+    /**
201
+     * get base url for pagination links aftr excluded those key
202
+     * identified on excluded query strings
203
+     *
204
+     */
205
+    function __getBaseUrl()
206
+    {
207
+
208
+        if(empty($this->baseUrl))
209
+        {
210
+
211
+            $this->__setBaseUrl();
212
+        }
213
+        return $this->baseUrl;
214
+    }
215
+
216
+
217
+    /**
218
+     * get the first item number
219
+     *
220
+     * @return interger the first item number displayed within current page
221
+     */
222
+    function getFirstItem()
223
+    {
224
+        $output = 0;
225
+        $temStartItemNumber = (($this->currentPage - 1) * $this->itemsPerPage + 1);
226
+        if($this->totalItems && $temStartItemNumber <= $this->totalItems )
227
+        {
228
+
229
+            $output = $temStartItemNumber;
230
+        }
231
+        return $output;
232
+    }
233
+    /**
234
+     * get the last item number displayed within current page
235
+     *
236
+     * @return interger the last item number
237
+     */
238
+    function getLastItem()
239
+    {
240
+        $output = 0;
241
+        $temEndItemNumber = (($this->currentPage) * $this->itemsPerPage);
242
+        if($this->totalItems)
243
+        {
244
+            if($temEndItemNumber <= $this->totalItems)
245
+            {
246
+                $output = $temEndItemNumber;
247
+            }else
248
+            {
249
+                $output = $this->totalItems;
250
+            }
251
+
252
+        }
253
+        return $output;
254
+    }
255
+    /**
256
+     * set  page groupings limit
257
+     * used for previous 1 2 3 4 5 next
258
+     *
259
+     * @param unknown_type $value
260
+     */
261
+    function setGroupLimit($value)
262
+    {
263
+        $this->groupLimit = intval($value);
264
+    }
265
+    /**
266
+     * get page grouping limit
267
+     *
268
+     * @return integer the page grouping limit
269
+     */
270
+    function getGroupLimit()
271
+    {
272
+        return $this->groupLimit;
273
+    }
274
+    /**
275
+     * get the page offset number
276
+     * used for Query . e.g SELECT SQL_CALC_FOUND_ROWS *
277
+     * 						FROM mytable LIMIT getPageOffset(), getItemsPerPage()
278
+     *
279
+     * @return iner
280
+     */
281
+    function getPageOffset()
282
+    {
283
+        return (($this->currentPage - 1)  * $this->itemsPerPage);
284
+    }
285
+    /**
286
+     * get the last url if any
287
+     * @return  string the last url
288
+     */
289
+    function getLastUrl()
290
+    {
291
+
292
+        $url = "";
293
+        $totalPages = $this->getTotalPages();
294
+        if($this->currentPage < $totalPages)
295
+        {
296
+            $url = $this->__getBaseUrl();
297
+
298
+            if($this->friendlyUrl)
299
+            {
300
+                $url .= $this->pageIndex . $totalPages . "/";
301
+            }else
302
+            {
303
+                $url = $this->__appendQueryString($url, $this->pageIndex . "=" . $totalPages);
304
+            }
305
+            $url = sprintf('<a href="%s" class="pagination_last"><span>%s</span></a>',
306
+            $url,
307
+            $this->lastText);
308
+        }
309
+        return $url;
310
+    }
311
+
312
+
313
+
314
+
315
+    /**
316
+     * get the first url if any
317
+     * @return string the first url
318
+     */
319
+
320
+    function getFirstUrl()
321
+    {
322
+        $url = "";
323
+        if($this->currentPage > 1)
324
+        {
325
+            $url = $this->__getBaseUrl();
326
+            if($this->friendlyUrl)
327
+            {
328
+                $url .= $this->pageIndex .  "1/";
329
+            }else
330
+            {
331
+                $url = $this->__appendQueryString($url, $this->pageIndex . "=1");
332
+            }
333
+            $url = sprintf('<a href="%s" class="pagination_first"><span>%s</span></a>',
334
+            $url,
335
+            $this->firstText);
336
+
337
+        }
338
+        return $url;
339
+    }
340
+
341
+    /**
342
+     * get the previous page url if anywhere
343
+     *
344
+     * @param array $excludedQueryStrings excluded the value from $_GET
345
+     * @return string the previous page url
346
+     */
347
+    function getPreviousUrl()
348
+    {
349
+        $url = "";
350
+        if($this->currentPage > 1 && $this->totalItems > 0 )
351
+        {
352
+            $url = $this->__getBaseUrl();
353
+            if($this->friendlyUrl)
354
+            {
355
+                $url .= $this->pageIndex . ($this->currentPage - 1) . "/";
356
+            }else
357
+            {
358
+                $url = $this->__appendQueryString($url, $this->pageIndex . "=" . ($this->currentPage -1));
359
+            }
360
+            $url = sprintf('<a href="%s" class="pagination_previous"><span>%s</span></a>',
361
+            $url,
362
+            $this->previousText);
363
+
364
+        }
365
+
366
+        return $url;
367
+    }
368
+    /**
369
+     * get the next page url if anywhere
370
+     *
371
+     * @param array $excludedQueryStrings excluded the value from $_GET
372
+     * @return string the next page url
373
+     */
374
+    function getNextUrl()
375
+    {
376
+        $url = "";
377
+        if($this->totalItems > ($this->currentPage * $this->itemsPerPage))
378
+        {
379
+            $url = $this->__getBaseUrl();
380
+            if($this->friendlyUrl)
381
+            {
382
+                $url .= $this->pageIndex . ($this->currentPage + 1) . "/";
383
+            }else
384
+            {
385
+                $url = $this->__appendQueryString($url, $this->pageIndex . "=" . ($this->currentPage + 1));
386
+            }
387
+            $url = sprintf('<a href="%s" class="pagination_next"><span>%s</span></a>',
388
+            $url,
389
+            $this->nextText);
390
+        }
391
+        return $url;
392
+
393
+    }
394
+
395
+    /**
396
+     * get the group page links  e.g. 1,2,3,4,5
397
+     * return format
398
+     * <a class="pagination_group" href='yoururl'>1</a>
399
+     * <a class="pagination_group active" href='#'>2</a>
400
+     * <a class="pagination_group" href='yoururl'>3</a>
401
+     */
402
+    function getGroupUrls()
403
+    {
404
+        $output = "";
405
+        if($this->totalItems > 0)
406
+        {
407
+            $displayedPages = 0;
408
+            $url = $this->__getBaseUrl();
409
+            $totalPages = $this->getTotalPages();
410
+            // find halfway point
411
+            $groupLimitHalf = floor($this->groupLimit / 2);
412
+            // determine what item/page we start with
413
+            $itemStart = $this->currentPage - $groupLimitHalf;
414
+            $itemStart = ($itemStart > 0 && $itemStart <= $totalPages)?$itemStart:1;
415
+            $itemEnd = $itemStart;
416
+
417
+            while($itemEnd < ($itemStart + $this->groupLimit - 1) && $itemEnd < $totalPages)
418
+            {
419
+                $itemEnd++;
420
+            }
421
+
422
+
423
+            if($totalPages > ($itemEnd - $itemStart))
424
+            {
425
+                for($i = $itemStart; $i > 1 && ($itemEnd - $itemStart + 1) < $this->groupLimit; $i--)
426
+                {
427
+                    $itemStart--;
428
+                }
429
+            }
430
+
431
+            for($item = $itemStart; $item <= $itemEnd; $item++)
432
+            {
433
+                if($item != $this->currentPage)
434
+                {//it is not the active link
435
+                    if($this->friendlyUrl)
436
+                    {
437
+                        $temUrl = $url . $this->pageIndex . $item .   "/";
438
+                    }else
439
+                    {
440
+                        $temUrl  = $this->__appendQueryString($url, $this->pageIndex . "=" . $item);
441
+                    }
442
+                    $output .= sprintf(' <a class="pagination_group" href="%s"><span>%d</span></a> ', $temUrl, $item);
443
+                }else
444
+                {//active link
445
+                    $output .= sprintf(' <a class="pagination_group pagination_active" href="#"><span>%d</span></a> ', $item);
446
+                }
447
+            }
448
+        }
449
+        return $output;
450
+    }
451
+    /**
452
+     * set the text of previous page link
453
+     *
454
+     * @param string $value
455
+     */
456
+    function setPreviousText($value)
457
+    {
458
+        $this->previousText = $value;
459
+    }
460
+    /**
461
+     * set the text of first page link
462
+     *
463
+     * @param string $value
464
+     */
465
+    function setFirstText($value)
466
+    {
467
+        $this->firstText = $value;
468
+    }
469
+    /**
470
+     * set the text of next page link
471
+     *
472
+     * @param string $value
473
+     */
474
+
475
+    function setNextText($value)
476
+    {
477
+        $this->nextText = $value;
478
+    }
479
+    /**
480
+     * set the text of last page link
481
+     *
482
+     * @param string $value
483
+     */
484
+    function setLastText($value)
485
+    {
486
+        $this->lastText = $value;
487
+    }
488
+
489
+    /**
490
+     * set the excluded query string from $_GET;
491
+     *
492
+     * @param array the lists of the query string keys
493
+     */
494
+
495
+    function setExcludedQueryString($values = array())
496
+    {
497
+        $this->excludedQueryStrings = $values;
498
+    }
499
+
500
+    function getExcludedQueryString()
501
+    {
502
+        return $this->excludedQueryStrings;
503
+    }
504
+
505
+
506
+    /**
507
+     * add extra query stiring to a url
508
+     * @param string $baseUrl
509
+     * @param string $extra the query string added to the base url
510
+     */
511
+    function __appendQueryString($baseUrl, $extra)
512
+    {
513
+        $output = trim($baseUrl);
514
+        if(strpos($baseUrl, "?") !== false)
515
+        {
516
+            $output .= "&" . $extra;
517
+        }else
518
+        {
519
+            $output .= "?" . $extra;
520
+        }
521
+        return $output;
522
+    }
523
+    /**
524
+     * return the html
525
+     *
526
+     * @param integer $type
527
+     */
528
+    function getPaginationHTML($type=1, $cssClass="pagination")
529
+    {
530
+        $output = '';
531
+        $output .= "<div class=\"pagination_content\"><p class=\"$cssClass\">\n";
532
+        switch($type)
533
+        {
534
+            case "2":
535
+                $output .= "<span class=\"pagination_summany\">" . $this->getFirstItem() . " to " . $this->getLastItem() . " of " . $this->getTotal() . " results.</span> ";	
536
+            if($previousUrl = $this->getPreviousUrl())
537
+            {
538
+                $output .= " " . $previousUrl;
539
+            }
540
+
541
+            if($nextUrl = $this->getNextUrl())
542
+            {
543
+                $output .= " " . $nextUrl;
544
+            }							
545
+                break;
546
+            case 1:
547
+                //get full summary pagination
548
+            default:
549
+                $output .= "<span class=\"pagination_summany\">" . $this->getFirstItem() . "/" . $this->getLastItem() . " (" . $this->getTotal() . ")</span> ";
550
+            if($firstUrl = $this->getFirstUrl())
551
+            {
552
+                $output .= " " . $firstUrl;
553
+            }
554
+            if($previousUrl = $this->getPreviousUrl())
555
+            {
556
+                $output .= " " . $previousUrl;
557
+            }
558
+
559
+            if($groupUrls = $this->getGroupUrls())
560
+            {
561
+                $output .= " " . $groupUrls;
562
+            }
563
+            if($nextUrl = $this->getNextUrl())
564
+            {
565
+                $output .= " " . $nextUrl;
566
+            }
567
+            if($lastUrl = $this->getLastUrl())
568
+            {
569
+                $output .= " " . $lastUrl;
570
+            }
571
+            $itemPerPage = '';
572
+            $itemPerPage .= "<select name=\"" . $this->limitIndex . "\" id=\"limit\" class=\"input inputLimit\" onchange=\"changePaginationLimit();\">\n";
573
+            foreach ($this->limits as $v)
574
+            {
575
+                $itemPerPage .= "<option value=\"" . $v . "\" " . ($v==$this->itemsPerPage?'selected="selected"':'') . ">" . $v . "</option>\n";
576
+            }
577
+            $itemPerPage .= "</select>\n"; 
578
+            $output .= "<span class=\"pagination_items_per_page\">";
579
+            $output .= sprintf(PAGINATION_ITEMS_PER_PAGE, $itemPerPage);
580
+            $output .= "</span>";
581
+            $output .= "<span class=\"pagination_parent\"><a href=\"#\" onclick=\"goParentFolder();\" id=\"pagination_parent_link\" title=\"" . PAGINATION_GO_PARENT . "\">&nbsp;</a></span>";
582
+        }
583
+
584
+        $output .= "</p></div>";
585
+        return $output;
586
+    }
587 587
 
588 588
 }
589 589
 ?>
590 590
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
2
+	if (!defined('AJAX_INIT_DONE'))
3 3
 	{
4 4
 		die('Permission denied');
5 5
 	}
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	var $nextText = "Next";
27 27
 	var $lastText = "Last";
28 28
 	var $firstText = "First";
29
-	var $limitIndex ='limit';
29
+	var $limitIndex = 'limit';
30 30
 	var $limits = array(5, 10, 20, 30, 50, 80, 150, 999);
31 31
 
32 32
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 * @param boolean $friendlyUrl set the returned url
37 37
 	 * as search engine friendly or Normal Url
38 38
 	 */
39
-	function pagination($friendlyUrl=false)
39
+	function pagination($friendlyUrl = false)
40 40
 	{
41 41
 		$this->friendlyUrl = $friendlyUrl;
42 42
 		$this->__resetCurrentPage();
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	function getTotalPages()
87 87
 	{
88 88
 
89
-		$output = floor(($this->totalItems / $this->itemsPerPage ));
90
-		if($this->totalItems % $this->itemsPerPage)
89
+		$output = floor(($this->totalItems/$this->itemsPerPage));
90
+		if ($this->totalItems%$this->itemsPerPage)
91 91
 		{
92 92
 			$output++;
93 93
 		}
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	function __resetCurrentPage()
118 118
 	{
119
-		$this->currentPage = ((isset($_GET[$this->pageIndex]) && intval($_GET[$this->pageIndex]) > 0)?intval($_GET[$this->pageIndex]):1);
119
+		$this->currentPage = ((isset($_GET[$this->pageIndex]) && intval($_GET[$this->pageIndex]) > 0) ? intval($_GET[$this->pageIndex]) : 1);
120 120
 	}
121 121
 
122 122
 	/**
@@ -124,18 +124,18 @@  discard block
 block discarded – undo
124 124
 	 *
125 125
 	 * @param string $value the base url
126 126
 	 */
127
-	function setUrl($value="")
127
+	function setUrl($value = "")
128 128
 	{
129
-		if(empty($value))
129
+		if (empty($value))
130 130
 		{
131
-			if($this->friendlyUrl)
131
+			if ($this->friendlyUrl)
132 132
 			{
133
-				$this->url = "http://" . $_SERVER['HTTP_HOST'] . "/";
134
-			}else
133
+				$this->url = "http://".$_SERVER['HTTP_HOST']."/";
134
+			} else
135 135
 			{
136 136
 				$this->url = $_SERVER['PHP_SELF'];
137 137
 			}
138
-		}else
138
+		} else
139 139
 		{
140 140
 			$this->url = $value;
141 141
 		}
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 	function getUrl()
151 151
 	{
152 152
 
153
-		if(empty($this->url))
153
+		if (empty($this->url))
154 154
 		{
155 155
 			$this->setUrl();
156 156
 
@@ -165,30 +165,30 @@  discard block
 block discarded – undo
165 165
 	function __setBaseUrl()
166 166
 	{
167 167
 
168
-		if(empty($this->url))
168
+		if (empty($this->url))
169 169
 		{
170 170
 			$this->getUrl();
171 171
 		}
172 172
 
173
-		if($this->friendlyUrl)
173
+		if ($this->friendlyUrl)
174 174
 		{
175 175
 			$this->baseUrl = $this->getUrl();
176
-		}else
176
+		} else
177 177
 		{
178 178
 
179 179
 			$appendingQueryStrings = array();
180
-			$this->excludedQueryStrings[$this->pageIndex] =$this->pageIndex;
181
-			foreach($_GET as $k=>$v)
180
+			$this->excludedQueryStrings[$this->pageIndex] = $this->pageIndex;
181
+			foreach ($_GET as $k=>$v)
182 182
 			{
183
-				if((array_search($k, $this->excludedQueryStrings) === false ))
183
+				if ((array_search($k, $this->excludedQueryStrings) === false))
184 184
 				{
185
-					$appendingQueryStrings[$k] = $k . "=" . $v;
185
+					$appendingQueryStrings[$k] = $k."=".$v;
186 186
 				}
187 187
 			}
188
-			if(sizeof($appendingQueryStrings))
188
+			if (sizeof($appendingQueryStrings))
189 189
 			{
190 190
 				$this->baseUrl = $this->__appendQueryString($this->url, implode("&", $appendingQueryStrings));
191
-			}else
191
+			} else
192 192
 			{
193 193
 				$this->baseUrl = $this->getUrl();
194 194
 			}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 	function __getBaseUrl()
206 206
 	{
207 207
 
208
-		if(empty($this->baseUrl))
208
+		if (empty($this->baseUrl))
209 209
 		{
210 210
 
211 211
 			$this->__setBaseUrl();
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	function getFirstItem()
223 223
 	{
224 224
 		$output = 0;
225
-		$temStartItemNumber = (($this->currentPage - 1) * $this->itemsPerPage + 1);
226
-		if($this->totalItems && $temStartItemNumber <= $this->totalItems )
225
+		$temStartItemNumber = (($this->currentPage - 1)*$this->itemsPerPage + 1);
226
+		if ($this->totalItems && $temStartItemNumber <= $this->totalItems)
227 227
 		{
228 228
 
229 229
 			$output = $temStartItemNumber;
@@ -238,13 +238,13 @@  discard block
 block discarded – undo
238 238
 	function getLastItem()
239 239
 	{
240 240
 		$output = 0;
241
-		$temEndItemNumber = (($this->currentPage) * $this->itemsPerPage);
242
-		if($this->totalItems)
241
+		$temEndItemNumber = (($this->currentPage)*$this->itemsPerPage);
242
+		if ($this->totalItems)
243 243
 		{
244
-			if($temEndItemNumber <= $this->totalItems)
244
+			if ($temEndItemNumber <= $this->totalItems)
245 245
 			{
246 246
 				$output = $temEndItemNumber;
247
-			}else
247
+			} else
248 248
 			{
249 249
 				$output = $this->totalItems;
250 250
 			}
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 */
281 281
 	function getPageOffset()
282 282
 	{
283
-		return (($this->currentPage - 1)  * $this->itemsPerPage);
283
+		return (($this->currentPage - 1)*$this->itemsPerPage);
284 284
 	}
285 285
 	/**
286 286
 	 * get the last url if any
@@ -291,16 +291,16 @@  discard block
 block discarded – undo
291 291
 
292 292
 		$url = "";
293 293
 		$totalPages = $this->getTotalPages();
294
-		if($this->currentPage < $totalPages)
294
+		if ($this->currentPage < $totalPages)
295 295
 		{
296 296
 			$url = $this->__getBaseUrl();
297 297
 
298
-			if($this->friendlyUrl)
298
+			if ($this->friendlyUrl)
299 299
 			{
300
-				$url .= $this->pageIndex . $totalPages . "/";
301
-			}else
300
+				$url .= $this->pageIndex.$totalPages."/";
301
+			} else
302 302
 			{
303
-				$url = $this->__appendQueryString($url, $this->pageIndex . "=" . $totalPages);
303
+				$url = $this->__appendQueryString($url, $this->pageIndex."=".$totalPages);
304 304
 			}
305 305
 			$url = sprintf('<a href="%s" class="pagination_last"><span>%s</span></a>',
306 306
 			$url,
@@ -320,15 +320,15 @@  discard block
 block discarded – undo
320 320
 	function getFirstUrl()
321 321
 	{
322 322
 		$url = "";
323
-		if($this->currentPage > 1)
323
+		if ($this->currentPage > 1)
324 324
 		{
325 325
 			$url = $this->__getBaseUrl();
326
-			if($this->friendlyUrl)
326
+			if ($this->friendlyUrl)
327 327
 			{
328
-				$url .= $this->pageIndex .  "1/";
329
-			}else
328
+				$url .= $this->pageIndex."1/";
329
+			} else
330 330
 			{
331
-				$url = $this->__appendQueryString($url, $this->pageIndex . "=1");
331
+				$url = $this->__appendQueryString($url, $this->pageIndex."=1");
332 332
 			}
333 333
 			$url = sprintf('<a href="%s" class="pagination_first"><span>%s</span></a>',
334 334
 			$url,
@@ -347,15 +347,15 @@  discard block
 block discarded – undo
347 347
 	function getPreviousUrl()
348 348
 	{
349 349
 		$url = "";
350
-		if($this->currentPage > 1 && $this->totalItems > 0 )
350
+		if ($this->currentPage > 1 && $this->totalItems > 0)
351 351
 		{
352 352
 			$url = $this->__getBaseUrl();
353
-			if($this->friendlyUrl)
353
+			if ($this->friendlyUrl)
354 354
 			{
355
-				$url .= $this->pageIndex . ($this->currentPage - 1) . "/";
356
-			}else
355
+				$url .= $this->pageIndex.($this->currentPage - 1)."/";
356
+			} else
357 357
 			{
358
-				$url = $this->__appendQueryString($url, $this->pageIndex . "=" . ($this->currentPage -1));
358
+				$url = $this->__appendQueryString($url, $this->pageIndex."=".($this->currentPage - 1));
359 359
 			}
360 360
 			$url = sprintf('<a href="%s" class="pagination_previous"><span>%s</span></a>',
361 361
 			$url,
@@ -374,15 +374,15 @@  discard block
 block discarded – undo
374 374
 	function getNextUrl()
375 375
 	{
376 376
 		$url = "";
377
-		if($this->totalItems > ($this->currentPage * $this->itemsPerPage))
377
+		if ($this->totalItems > ($this->currentPage*$this->itemsPerPage))
378 378
 		{
379 379
 			$url = $this->__getBaseUrl();
380
-			if($this->friendlyUrl)
380
+			if ($this->friendlyUrl)
381 381
 			{
382
-				$url .= $this->pageIndex . ($this->currentPage + 1) . "/";
383
-			}else
382
+				$url .= $this->pageIndex.($this->currentPage + 1)."/";
383
+			} else
384 384
 			{
385
-				$url = $this->__appendQueryString($url, $this->pageIndex . "=" . ($this->currentPage + 1));
385
+				$url = $this->__appendQueryString($url, $this->pageIndex."=".($this->currentPage + 1));
386 386
 			}
387 387
 			$url = sprintf('<a href="%s" class="pagination_next"><span>%s</span></a>',
388 388
 			$url,
@@ -402,45 +402,45 @@  discard block
 block discarded – undo
402 402
 	function getGroupUrls()
403 403
 	{
404 404
 		$output = "";
405
-		if($this->totalItems > 0)
405
+		if ($this->totalItems > 0)
406 406
 		{
407 407
 			$displayedPages = 0;
408 408
 			$url = $this->__getBaseUrl();
409 409
 			$totalPages = $this->getTotalPages();
410 410
 			// find halfway point
411
-			$groupLimitHalf = floor($this->groupLimit / 2);
411
+			$groupLimitHalf = floor($this->groupLimit/2);
412 412
 			// determine what item/page we start with
413 413
 			$itemStart = $this->currentPage - $groupLimitHalf;
414
-			$itemStart = ($itemStart > 0 && $itemStart <= $totalPages)?$itemStart:1;
414
+			$itemStart = ($itemStart > 0 && $itemStart <= $totalPages) ? $itemStart : 1;
415 415
 			$itemEnd = $itemStart;
416 416
 
417
-			while($itemEnd < ($itemStart + $this->groupLimit - 1) && $itemEnd < $totalPages)
417
+			while ($itemEnd < ($itemStart + $this->groupLimit - 1) && $itemEnd < $totalPages)
418 418
 			{
419 419
 				$itemEnd++;
420 420
 			}
421 421
 
422 422
 
423
-			if($totalPages > ($itemEnd - $itemStart))
423
+			if ($totalPages > ($itemEnd - $itemStart))
424 424
 			{
425
-				for($i = $itemStart; $i > 1 && ($itemEnd - $itemStart + 1) < $this->groupLimit; $i--)
425
+				for ($i = $itemStart; $i > 1 && ($itemEnd - $itemStart + 1) < $this->groupLimit; $i--)
426 426
 				{
427 427
 					$itemStart--;
428 428
 				}
429 429
 			}
430 430
 
431
-			for($item = $itemStart; $item <= $itemEnd; $item++)
431
+			for ($item = $itemStart; $item <= $itemEnd; $item++)
432 432
 			{
433
-				if($item != $this->currentPage)
433
+				if ($item != $this->currentPage)
434 434
 				{//it is not the active link
435
-					if($this->friendlyUrl)
435
+					if ($this->friendlyUrl)
436 436
 					{
437
-						$temUrl = $url . $this->pageIndex . $item .   "/";
438
-					}else
437
+						$temUrl = $url.$this->pageIndex.$item."/";
438
+					} else
439 439
 					{
440
-						$temUrl  = $this->__appendQueryString($url, $this->pageIndex . "=" . $item);
440
+						$temUrl = $this->__appendQueryString($url, $this->pageIndex."=".$item);
441 441
 					}
442 442
 					$output .= sprintf(' <a class="pagination_group" href="%s"><span>%d</span></a> ', $temUrl, $item);
443
-				}else
443
+				} else
444 444
 				{//active link
445 445
 					$output .= sprintf(' <a class="pagination_group pagination_active" href="#"><span>%d</span></a> ', $item);
446 446
 				}
@@ -511,12 +511,12 @@  discard block
 block discarded – undo
511 511
 	function __appendQueryString($baseUrl, $extra)
512 512
 	{
513 513
 		$output = trim($baseUrl);
514
-		if(strpos($baseUrl, "?") !== false)
514
+		if (strpos($baseUrl, "?") !== false)
515 515
 		{
516
-			$output .= "&" . $extra;
517
-		}else
516
+			$output .= "&".$extra;
517
+		} else
518 518
 		{
519
-			$output .= "?" . $extra;
519
+			$output .= "?".$extra;
520 520
 		}
521 521
 		return $output;
522 522
 	}
@@ -525,60 +525,60 @@  discard block
 block discarded – undo
525 525
 	 *
526 526
 	 * @param integer $type
527 527
 	 */
528
-	function getPaginationHTML($type=1, $cssClass="pagination")
528
+	function getPaginationHTML($type = 1, $cssClass = "pagination")
529 529
 	{
530 530
 		$output = '';
531 531
 		$output .= "<div class=\"pagination_content\"><p class=\"$cssClass\">\n";
532
-		switch($type)
532
+		switch ($type)
533 533
 		{
534 534
 			case "2":
535
-				$output .= "<span class=\"pagination_summany\">" . $this->getFirstItem() . " to " . $this->getLastItem() . " of " . $this->getTotal() . " results.</span> ";	
536
-			if($previousUrl = $this->getPreviousUrl())
535
+				$output .= "<span class=\"pagination_summany\">".$this->getFirstItem()." to ".$this->getLastItem()." of ".$this->getTotal()." results.</span> ";	
536
+			if ($previousUrl = $this->getPreviousUrl())
537 537
 			{
538
-				$output .= " " . $previousUrl;
538
+				$output .= " ".$previousUrl;
539 539
 			}
540 540
 
541
-			if($nextUrl = $this->getNextUrl())
541
+			if ($nextUrl = $this->getNextUrl())
542 542
 			{
543
-				$output .= " " . $nextUrl;
543
+				$output .= " ".$nextUrl;
544 544
 			}							
545 545
 				break;
546 546
 			case 1:
547 547
 				//get full summary pagination
548 548
 			default:
549
-				$output .= "<span class=\"pagination_summany\">" . $this->getFirstItem() . "/" . $this->getLastItem() . " (" . $this->getTotal() . ")</span> ";
550
-			if($firstUrl = $this->getFirstUrl())
549
+				$output .= "<span class=\"pagination_summany\">".$this->getFirstItem()."/".$this->getLastItem()." (".$this->getTotal().")</span> ";
550
+			if ($firstUrl = $this->getFirstUrl())
551 551
 			{
552
-				$output .= " " . $firstUrl;
552
+				$output .= " ".$firstUrl;
553 553
 			}
554
-			if($previousUrl = $this->getPreviousUrl())
554
+			if ($previousUrl = $this->getPreviousUrl())
555 555
 			{
556
-				$output .= " " . $previousUrl;
556
+				$output .= " ".$previousUrl;
557 557
 			}
558 558
 
559
-			if($groupUrls = $this->getGroupUrls())
559
+			if ($groupUrls = $this->getGroupUrls())
560 560
 			{
561
-				$output .= " " . $groupUrls;
561
+				$output .= " ".$groupUrls;
562 562
 			}
563
-			if($nextUrl = $this->getNextUrl())
563
+			if ($nextUrl = $this->getNextUrl())
564 564
 			{
565
-				$output .= " " . $nextUrl;
565
+				$output .= " ".$nextUrl;
566 566
 			}
567
-			if($lastUrl = $this->getLastUrl())
567
+			if ($lastUrl = $this->getLastUrl())
568 568
 			{
569
-				$output .= " " . $lastUrl;
569
+				$output .= " ".$lastUrl;
570 570
 			}
571 571
 			$itemPerPage = '';
572
-			$itemPerPage .= "<select name=\"" . $this->limitIndex . "\" id=\"limit\" class=\"input inputLimit\" onchange=\"changePaginationLimit();\">\n";
572
+			$itemPerPage .= "<select name=\"".$this->limitIndex."\" id=\"limit\" class=\"input inputLimit\" onchange=\"changePaginationLimit();\">\n";
573 573
 			foreach ($this->limits as $v)
574 574
 			{
575
-				$itemPerPage .= "<option value=\"" . $v . "\" " . ($v==$this->itemsPerPage?'selected="selected"':'') . ">" . $v . "</option>\n";
575
+				$itemPerPage .= "<option value=\"".$v."\" ".($v == $this->itemsPerPage ? 'selected="selected"' : '').">".$v."</option>\n";
576 576
 			}
577 577
 			$itemPerPage .= "</select>\n"; 
578 578
 			$output .= "<span class=\"pagination_items_per_page\">";
579 579
 			$output .= sprintf(PAGINATION_ITEMS_PER_PAGE, $itemPerPage);
580 580
 			$output .= "</span>";
581
-			$output .= "<span class=\"pagination_parent\"><a href=\"#\" onclick=\"goParentFolder();\" id=\"pagination_parent_link\" title=\"" . PAGINATION_GO_PARENT . "\">&nbsp;</a></span>";
581
+			$output .= "<span class=\"pagination_parent\"><a href=\"#\" onclick=\"goParentFolder();\" id=\"pagination_parent_link\" title=\"".PAGINATION_GO_PARENT."\">&nbsp;</a></span>";
582 582
 		}
583 583
 
584 584
 		$output .= "</p></div>";
Please login to merge, or discard this patch.
Braces   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
 			if($this->friendlyUrl)
132 132
 			{
133 133
 				$this->url = "http://" . $_SERVER['HTTP_HOST'] . "/";
134
-			}else
134
+			} else
135 135
 			{
136 136
 				$this->url = $_SERVER['PHP_SELF'];
137 137
 			}
138
-		}else
138
+		} else
139 139
 		{
140 140
 			$this->url = $value;
141 141
 		}
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		if($this->friendlyUrl)
174 174
 		{
175 175
 			$this->baseUrl = $this->getUrl();
176
-		}else
176
+		} else
177 177
 		{
178 178
 
179 179
 			$appendingQueryStrings = array();
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 			if(sizeof($appendingQueryStrings))
189 189
 			{
190 190
 				$this->baseUrl = $this->__appendQueryString($this->url, implode("&", $appendingQueryStrings));
191
-			}else
191
+			} else
192 192
 			{
193 193
 				$this->baseUrl = $this->getUrl();
194 194
 			}
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 			if($temEndItemNumber <= $this->totalItems)
245 245
 			{
246 246
 				$output = $temEndItemNumber;
247
-			}else
247
+			} else
248 248
 			{
249 249
 				$output = $this->totalItems;
250 250
 			}
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 			if($this->friendlyUrl)
299 299
 			{
300 300
 				$url .= $this->pageIndex . $totalPages . "/";
301
-			}else
301
+			} else
302 302
 			{
303 303
 				$url = $this->__appendQueryString($url, $this->pageIndex . "=" . $totalPages);
304 304
 			}
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 			if($this->friendlyUrl)
327 327
 			{
328 328
 				$url .= $this->pageIndex .  "1/";
329
-			}else
329
+			} else
330 330
 			{
331 331
 				$url = $this->__appendQueryString($url, $this->pageIndex . "=1");
332 332
 			}
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 			if($this->friendlyUrl)
354 354
 			{
355 355
 				$url .= $this->pageIndex . ($this->currentPage - 1) . "/";
356
-			}else
356
+			} else
357 357
 			{
358 358
 				$url = $this->__appendQueryString($url, $this->pageIndex . "=" . ($this->currentPage -1));
359 359
 			}
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 			if($this->friendlyUrl)
381 381
 			{
382 382
 				$url .= $this->pageIndex . ($this->currentPage + 1) . "/";
383
-			}else
383
+			} else
384 384
 			{
385 385
 				$url = $this->__appendQueryString($url, $this->pageIndex . "=" . ($this->currentPage + 1));
386 386
 			}
@@ -435,12 +435,12 @@  discard block
 block discarded – undo
435 435
 					if($this->friendlyUrl)
436 436
 					{
437 437
 						$temUrl = $url . $this->pageIndex . $item .   "/";
438
-					}else
438
+					} else
439 439
 					{
440 440
 						$temUrl  = $this->__appendQueryString($url, $this->pageIndex . "=" . $item);
441 441
 					}
442 442
 					$output .= sprintf(' <a class="pagination_group" href="%s"><span>%d</span></a> ', $temUrl, $item);
443
-				}else
443
+				} else
444 444
 				{//active link
445 445
 					$output .= sprintf(' <a class="pagination_group pagination_active" href="#"><span>%d</span></a> ', $item);
446 446
 				}
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 		if(strpos($baseUrl, "?") !== false)
515 515
 		{
516 516
 			$output .= "&" . $extra;
517
-		}else
517
+		} else
518 518
 		{
519 519
 			$output .= "?" . $extra;
520 520
 		}
Please login to merge, or discard this patch.
phpmyfaq/admin/editor/plugins/ajaxfilemanager/inc/class.session.php 4 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     }
72 72
     /**
73 73
      * session init
74
-     * @return boolean
74
+     * @return boolean|null
75 75
      */
76 76
     function init() 
77 77
     {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
     /**
191 191
      * log action taken by the gc
192 192
      *
193
-     * @param unknown_type $msg
193
+     * @param string $msg
194 194
      */
195 195
     function _log($msg)
196 196
     {
Please login to merge, or discard this patch.
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -1,17 +1,17 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
3
-	{
4
-		die('Permission denied');
5
-	}
2
+    if(!defined('AJAX_INIT_DONE'))
3
+    {
4
+        die('Permission denied');
5
+    }
6 6
 ?><?php
7 7
 
8
-	/**
9
-	 * this class provide a function like session handling engine
10
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
11
-	 * @link www.phpletter.com
12
-	 * @since 22/May/2007
13
-	 *
14
-	 */
8
+    /**
9
+     * this class provide a function like session handling engine
10
+     * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
11
+     * @link www.phpletter.com
12
+     * @since 22/May/2007
13
+     *
14
+     */
15 15
 
16 16
 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.file.php");
17 17
 class Session 
@@ -24,11 +24,11 @@  discard block
 block discarded – undo
24 24
     var $sessionFile = null;
25 25
     var $ext = '.txt';
26 26
     var $gcCounter = 5; //call gc to delete expired session each ten request
27
-		var $gcCounterFileName = 'gc_counter.ajax.php';
28
-		var $gcCounterFile = null;
29
-		var $gcLogFileName = 'gc_log.ajax.php';
30
-		var $gcLogFile = null;
31
-		var $debug = true; //turn it on when you want to see gc log
27
+        var $gcCounterFileName = 'gc_counter.ajax.php';
28
+        var $gcCounterFile = null;
29
+        var $gcLogFileName = 'gc_log.ajax.php';
30
+        var $gcLogFile = null;
31
+        var $debug = true; //turn it on when you want to see gc log
32 32
 		
33 33
 		
34 34
     /**
@@ -37,37 +37,37 @@  discard block
 block discarded – undo
37 37
      */
38 38
     function __construct()
39 39
     {
40
-    	//check if the session folder read and writable
41
-    		$dir = new file();
42
-	        if(!file_exists(CONFIG_SYS_DIR_SESSION_PATH))
43
-	        {
44
-	           if(!$dir->mkdir(CONFIG_SYS_DIR_SESSION_PATH))
45
-	           {
46
-	              die('Unable to create session folder.');
47
-	           }
48
-	        }
49
-    		if(!$dir->isReadable(CONFIG_SYS_DIR_SESSION_PATH))
50
-    		{
51
-    			die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not readable.");
52
-    		}    		
53
-    		if(!$dir->isWritable(CONFIG_SYS_DIR_SESSION_PATH))
54
-    		{
55
-    			die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not writable.");
56
-    		}
57
-    	$this->dir = backslashToSlash(addTrailingSlash(CONFIG_SYS_DIR_SESSION_PATH));
40
+        //check if the session folder read and writable
41
+            $dir = new file();
42
+            if(!file_exists(CONFIG_SYS_DIR_SESSION_PATH))
43
+            {
44
+                if(!$dir->mkdir(CONFIG_SYS_DIR_SESSION_PATH))
45
+                {
46
+                    die('Unable to create session folder.');
47
+                }
48
+            }
49
+            if(!$dir->isReadable(CONFIG_SYS_DIR_SESSION_PATH))
50
+            {
51
+                die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not readable.");
52
+            }    		
53
+            if(!$dir->isWritable(CONFIG_SYS_DIR_SESSION_PATH))
54
+            {
55
+                die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not writable.");
56
+            }
57
+        $this->dir = backslashToSlash(addTrailingSlash(CONFIG_SYS_DIR_SESSION_PATH));
58 58
         $this->lifeTime = get_cfg_var("session.gc_maxlifetime");  
59 59
         $this->gcCounterFile = $this->dir . $this->gcCounterFileName; 
60 60
         $this->gcLogFile = $this->dir  . $this->gcLogFileName;
61
-       	$this->sessionDir = backslashToSlash($this->dir.session_id().DIRECTORY_SEPARATOR);
61
+            $this->sessionDir = backslashToSlash($this->dir.session_id().DIRECTORY_SEPARATOR);
62 62
         $this->init();    	
63 63
     }
64
-     /**
65
-     * constructor
66
-     *
67
-     */   
64
+        /**
65
+         * constructor
66
+         *
67
+         */   
68 68
     function Session() 
69 69
     {
70
-    		$this->__construct();        
70
+            $this->__construct();        
71 71
     }
72 72
     /**
73 73
      * session init
@@ -82,25 +82,25 @@  discard block
 block discarded – undo
82 82
     
83 83
     function gc()
84 84
     {
85
-     		//init the counter file
85
+                //init the counter file
86 86
         $fp = @fopen($this->gcCounterFile, 'a+');
87 87
         if($fp)
88 88
         {
89
-        	$count = intval(fgets($fp, 999999)) + 1;
90
-        	if($count > $this->gcCounter || rand(0, 23) == date('h'))
91
-        	{
92
-        		$this->_gc();
93
-        		$count = 0;
94
-        	}
95
-        	@ftruncate($fp, 0);
96
-        	if(!@fputs($fp, $count))
97
-        	{
98
-        		die(SESSION_COUNTER_FILE_WRITE_FAILED);
99
-        	}
100
-        	@fclose($fp);
89
+            $count = intval(fgets($fp, 999999)) + 1;
90
+            if($count > $this->gcCounter || rand(0, 23) == date('h'))
91
+            {
92
+                $this->_gc();
93
+                $count = 0;
94
+            }
95
+            @ftruncate($fp, 0);
96
+            if(!@fputs($fp, $count))
97
+            {
98
+                die(SESSION_COUNTER_FILE_WRITE_FAILED);
99
+            }
100
+            @fclose($fp);
101 101
         }else 
102 102
         {
103
-        	die(SESSION_COUNTER_FILE_CREATE_FAILED);
103
+            die(SESSION_COUNTER_FILE_CREATE_FAILED);
104 104
         }   	
105 105
     }
106 106
 
@@ -110,81 +110,81 @@  discard block
 block discarded – undo
110 110
      */
111 111
     function _gc() 
112 112
     {
113
-			//remove expired file from session folder
114
-	 		$dirHandler = @opendir($this->dir);
115
-	 		$output = '';
116
-	 		$output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
117
-	 		$fo = new file();
118
-			if($dirHandler)
119
-			{
120
-				while(false !== ($file = readdir($dirHandler)))
121
-				{
122
-					if($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id() )
123
-					{						
124
-						$path=$this->dir.$file;
125
-						$output .= $path ;
126
-						//check if this is a expired session file
127
-						if(filemtime($path) + $this->lifeTime < time())
128
-						{							
129
-							if($fo->delete($path))
130
-							{
131
-								$output .= ' Deleted at ' . date('d/M/Y H:i:s');
132
-							}else 
133
-							{
134
-								$output .= " Failed at " . date('d/M/Y H:i:s');
135
-							}																			
136
-						}
137
-						$output .= "\n";
113
+            //remove expired file from session folder
114
+                $dirHandler = @opendir($this->dir);
115
+                $output = '';
116
+                $output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
117
+                $fo = new file();
118
+            if($dirHandler)
119
+            {
120
+                while(false !== ($file = readdir($dirHandler)))
121
+                {
122
+                    if($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id() )
123
+                    {						
124
+                        $path=$this->dir.$file;
125
+                        $output .= $path ;
126
+                        //check if this is a expired session file
127
+                        if(filemtime($path) + $this->lifeTime < time())
128
+                        {							
129
+                            if($fo->delete($path))
130
+                            {
131
+                                $output .= ' Deleted at ' . date('d/M/Y H:i:s');
132
+                            }else 
133
+                            {
134
+                                $output .= " Failed at " . date('d/M/Y H:i:s');
135
+                            }																			
136
+                        }
137
+                        $output .= "\n";
138 138
 											
139
-					}
140
-				}
141
-				if($this->debug)
142
-				{
143
-					$this->_log($output);
144
-				}
139
+                    }
140
+                }
141
+                if($this->debug)
142
+                {
143
+                    $this->_log($output);
144
+                }
145 145
 				
146
-				@closedir($dirHandler);
146
+                @closedir($dirHandler);
147 147
 
148
-			} 
149
-			if(CONFIG_SYS_DEMO_ENABLE)
150
-			{
151
-				//remove expired files from uploaded folder
152
-		 		$dirHandler = @opendir(CONFIG_SYS_ROOT_PATH);
153
-		 		$output = '';
154
-		 		$output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
155
-		 		$fo = new file();
156
-				if($dirHandler)
157
-				{
158
-					while(false !== ($file = readdir($dirHandler)))
159
-					{
160
-						if($file != '.' && $file != '..')
161
-						{						
162
-							$path=CONFIG_SYS_ROOT_PATH.$file;
163
-							$output .= $path ;
164
-							//check if this is a expired session file
165
-							if(filemtime($path) + $this->lifeTime < time())
166
-							{							
167
-								if($fo->delete($path))
168
-								{
169
-									$output .= ' Deleted at ' . date('d/M/Y H:i:s');
170
-								}else 
171
-								{
172
-									$output .= " Failed at " . date('d/M/Y H:i:s');
173
-								}																			
174
-							}
175
-							$output .= "\n";
148
+            } 
149
+            if(CONFIG_SYS_DEMO_ENABLE)
150
+            {
151
+                //remove expired files from uploaded folder
152
+                    $dirHandler = @opendir(CONFIG_SYS_ROOT_PATH);
153
+                    $output = '';
154
+                    $output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
155
+                    $fo = new file();
156
+                if($dirHandler)
157
+                {
158
+                    while(false !== ($file = readdir($dirHandler)))
159
+                    {
160
+                        if($file != '.' && $file != '..')
161
+                        {						
162
+                            $path=CONFIG_SYS_ROOT_PATH.$file;
163
+                            $output .= $path ;
164
+                            //check if this is a expired session file
165
+                            if(filemtime($path) + $this->lifeTime < time())
166
+                            {							
167
+                                if($fo->delete($path))
168
+                                {
169
+                                    $output .= ' Deleted at ' . date('d/M/Y H:i:s');
170
+                                }else 
171
+                                {
172
+                                    $output .= " Failed at " . date('d/M/Y H:i:s');
173
+                                }																			
174
+                            }
175
+                            $output .= "\n";
176 176
 												
177
-						}
178
-					}
179
-					if($this->debug)
180
-					{
181
-						$this->_log($output);
182
-					}
177
+                        }
178
+                    }
179
+                    if($this->debug)
180
+                    {
181
+                        $this->_log($output);
182
+                    }
183 183
 					
184
-					@closedir($dirHandler);
184
+                    @closedir($dirHandler);
185 185
 	
186
-				}					
187
-			}
186
+                }					
187
+            }
188 188
 		    
189 189
     }
190 190
     /**
@@ -194,14 +194,14 @@  discard block
 block discarded – undo
194 194
      */
195 195
     function _log($msg)
196 196
     {
197
-    	$msg = "<?php die(); ?>\n" . $msg;
198
-    	$fp = @fopen($this->gcLogFile, 'w+');
199
-    	if($fp)
200
-    	{
201
-    		@ftruncate($fp, 0);
202
-    		!@fputs($fp, $msg);
203
-    		@fclose($fp);
204
-    	}
197
+        $msg = "<?php die(); ?>\n" . $msg;
198
+        $fp = @fopen($this->gcLogFile, 'w+');
199
+        if($fp)
200
+        {
201
+            @ftruncate($fp, 0);
202
+            !@fputs($fp, $msg);
203
+            @fclose($fp);
204
+        }
205 205
     }
206 206
     
207 207
     /**
@@ -211,21 +211,21 @@  discard block
 block discarded – undo
211 211
      */
212 212
     function getSessionDir()
213 213
     {
214
-    	if(!file_exists($this->sessionDir) && !is_dir($this->sessionDir))
215
-    	{
216
-    		$dir = new file();
217
-    		if(!$dir->mkdir($this->sessionDir))
218
-    		{
219
-    			return '';
220
-    		}
221
-    	}else 
222
-    	{
223
-	     	if(!@is_dir($this->sessionDir))
224
-	    	{
225
-	    		return '';
226
-	    	}   		
227
-    	}
228
-    	return $this->sessionDir;
214
+        if(!file_exists($this->sessionDir) && !is_dir($this->sessionDir))
215
+        {
216
+            $dir = new file();
217
+            if(!$dir->mkdir($this->sessionDir))
218
+            {
219
+                return '';
220
+            }
221
+        }else 
222
+        {
223
+                if(!@is_dir($this->sessionDir))
224
+            {
225
+                return '';
226
+            }   		
227
+        }
228
+        return $this->sessionDir;
229 229
     }
230 230
     
231 231
 
Please login to merge, or discard this patch.
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
2
+	if (!defined('AJAX_INIT_DONE'))
3 3
 	{
4 4
 		die('Permission denied');
5 5
 	}
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	 *
14 14
 	 */
15 15
 
16
-require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "class.file.php");
16
+require_once(dirname(__FILE__).DIRECTORY_SEPARATOR."class.file.php");
17 17
 class Session 
18 18
 {
19 19
     var $lifeTime;
@@ -39,25 +39,25 @@  discard block
 block discarded – undo
39 39
     {
40 40
     	//check if the session folder read and writable
41 41
     		$dir = new file();
42
-	        if(!file_exists(CONFIG_SYS_DIR_SESSION_PATH))
42
+	        if (!file_exists(CONFIG_SYS_DIR_SESSION_PATH))
43 43
 	        {
44
-	           if(!$dir->mkdir(CONFIG_SYS_DIR_SESSION_PATH))
44
+	           if (!$dir->mkdir(CONFIG_SYS_DIR_SESSION_PATH))
45 45
 	           {
46 46
 	              die('Unable to create session folder.');
47 47
 	           }
48 48
 	        }
49
-    		if(!$dir->isReadable(CONFIG_SYS_DIR_SESSION_PATH))
49
+    		if (!$dir->isReadable(CONFIG_SYS_DIR_SESSION_PATH))
50 50
     		{
51
-    			die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not readable.");
51
+    			die('Permission denied: '.CONFIG_SYS_DIR_SESSION_PATH." is not readable.");
52 52
     		}    		
53
-    		if(!$dir->isWritable(CONFIG_SYS_DIR_SESSION_PATH))
53
+    		if (!$dir->isWritable(CONFIG_SYS_DIR_SESSION_PATH))
54 54
     		{
55
-    			die('Permission denied: ' . CONFIG_SYS_DIR_SESSION_PATH . " is not writable.");
55
+    			die('Permission denied: '.CONFIG_SYS_DIR_SESSION_PATH." is not writable.");
56 56
     		}
57 57
     	$this->dir = backslashToSlash(addTrailingSlash(CONFIG_SYS_DIR_SESSION_PATH));
58 58
         $this->lifeTime = get_cfg_var("session.gc_maxlifetime");  
59
-        $this->gcCounterFile = $this->dir . $this->gcCounterFileName; 
60
-        $this->gcLogFile = $this->dir  . $this->gcLogFileName;
59
+        $this->gcCounterFile = $this->dir.$this->gcCounterFileName; 
60
+        $this->gcLogFile = $this->dir.$this->gcLogFileName;
61 61
        	$this->sessionDir = backslashToSlash($this->dir.session_id().DIRECTORY_SEPARATOR);
62 62
         $this->init();    	
63 63
     }
@@ -84,21 +84,21 @@  discard block
 block discarded – undo
84 84
     {
85 85
      		//init the counter file
86 86
         $fp = @fopen($this->gcCounterFile, 'a+');
87
-        if($fp)
87
+        if ($fp)
88 88
         {
89 89
         	$count = intval(fgets($fp, 999999)) + 1;
90
-        	if($count > $this->gcCounter || rand(0, 23) == date('h'))
90
+        	if ($count > $this->gcCounter || rand(0, 23) == date('h'))
91 91
         	{
92 92
         		$this->_gc();
93 93
         		$count = 0;
94 94
         	}
95 95
         	@ftruncate($fp, 0);
96
-        	if(!@fputs($fp, $count))
96
+        	if (!@fputs($fp, $count))
97 97
         	{
98 98
         		die(SESSION_COUNTER_FILE_WRITE_FAILED);
99 99
         	}
100 100
         	@fclose($fp);
101
-        }else 
101
+        } else 
102 102
         {
103 103
         	die(SESSION_COUNTER_FILE_CREATE_FAILED);
104 104
         }   	
@@ -113,32 +113,32 @@  discard block
 block discarded – undo
113 113
 			//remove expired file from session folder
114 114
 	 		$dirHandler = @opendir($this->dir);
115 115
 	 		$output = '';
116
-	 		$output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
116
+	 		$output .= "gc start at ".date('d/M/Y H:i:s')."\n";
117 117
 	 		$fo = new file();
118
-			if($dirHandler)
118
+			if ($dirHandler)
119 119
 			{
120
-				while(false !== ($file = readdir($dirHandler)))
120
+				while (false !== ($file = readdir($dirHandler)))
121 121
 				{
122
-					if($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id() )
122
+					if ($file != '.' && $file != '..' && $file != $this->gcCounterFileName && $file != $this->gcLogFileName && $file != session_id())
123 123
 					{						
124
-						$path=$this->dir.$file;
125
-						$output .= $path ;
124
+						$path = $this->dir.$file;
125
+						$output .= $path;
126 126
 						//check if this is a expired session file
127
-						if(filemtime($path) + $this->lifeTime < time())
127
+						if (filemtime($path) + $this->lifeTime < time())
128 128
 						{							
129
-							if($fo->delete($path))
129
+							if ($fo->delete($path))
130 130
 							{
131
-								$output .= ' Deleted at ' . date('d/M/Y H:i:s');
132
-							}else 
131
+								$output .= ' Deleted at '.date('d/M/Y H:i:s');
132
+							} else 
133 133
 							{
134
-								$output .= " Failed at " . date('d/M/Y H:i:s');
134
+								$output .= " Failed at ".date('d/M/Y H:i:s');
135 135
 							}																			
136 136
 						}
137 137
 						$output .= "\n";
138 138
 											
139 139
 					}
140 140
 				}
141
-				if($this->debug)
141
+				if ($this->debug)
142 142
 				{
143 143
 					$this->_log($output);
144 144
 				}
@@ -146,37 +146,37 @@  discard block
 block discarded – undo
146 146
 				@closedir($dirHandler);
147 147
 
148 148
 			} 
149
-			if(CONFIG_SYS_DEMO_ENABLE)
149
+			if (CONFIG_SYS_DEMO_ENABLE)
150 150
 			{
151 151
 				//remove expired files from uploaded folder
152 152
 		 		$dirHandler = @opendir(CONFIG_SYS_ROOT_PATH);
153 153
 		 		$output = '';
154
-		 		$output .= "gc start at " . date('d/M/Y H:i:s') . "\n";
154
+		 		$output .= "gc start at ".date('d/M/Y H:i:s')."\n";
155 155
 		 		$fo = new file();
156
-				if($dirHandler)
156
+				if ($dirHandler)
157 157
 				{
158
-					while(false !== ($file = readdir($dirHandler)))
158
+					while (false !== ($file = readdir($dirHandler)))
159 159
 					{
160
-						if($file != '.' && $file != '..')
160
+						if ($file != '.' && $file != '..')
161 161
 						{						
162
-							$path=CONFIG_SYS_ROOT_PATH.$file;
163
-							$output .= $path ;
162
+							$path = CONFIG_SYS_ROOT_PATH.$file;
163
+							$output .= $path;
164 164
 							//check if this is a expired session file
165
-							if(filemtime($path) + $this->lifeTime < time())
165
+							if (filemtime($path) + $this->lifeTime < time())
166 166
 							{							
167
-								if($fo->delete($path))
167
+								if ($fo->delete($path))
168 168
 								{
169
-									$output .= ' Deleted at ' . date('d/M/Y H:i:s');
170
-								}else 
169
+									$output .= ' Deleted at '.date('d/M/Y H:i:s');
170
+								} else 
171 171
 								{
172
-									$output .= " Failed at " . date('d/M/Y H:i:s');
172
+									$output .= " Failed at ".date('d/M/Y H:i:s');
173 173
 								}																			
174 174
 							}
175 175
 							$output .= "\n";
176 176
 												
177 177
 						}
178 178
 					}
179
-					if($this->debug)
179
+					if ($this->debug)
180 180
 					{
181 181
 						$this->_log($output);
182 182
 					}
@@ -194,9 +194,9 @@  discard block
 block discarded – undo
194 194
      */
195 195
     function _log($msg)
196 196
     {
197
-    	$msg = "<?php die(); ?>\n" . $msg;
197
+    	$msg = "<?php die(); ?>\n".$msg;
198 198
     	$fp = @fopen($this->gcLogFile, 'w+');
199
-    	if($fp)
199
+    	if ($fp)
200 200
     	{
201 201
     		@ftruncate($fp, 0);
202 202
     		!@fputs($fp, $msg);
@@ -211,16 +211,16 @@  discard block
 block discarded – undo
211 211
      */
212 212
     function getSessionDir()
213 213
     {
214
-    	if(!file_exists($this->sessionDir) && !is_dir($this->sessionDir))
214
+    	if (!file_exists($this->sessionDir) && !is_dir($this->sessionDir))
215 215
     	{
216 216
     		$dir = new file();
217
-    		if(!$dir->mkdir($this->sessionDir))
217
+    		if (!$dir->mkdir($this->sessionDir))
218 218
     		{
219 219
     			return '';
220 220
     		}
221
-    	}else 
221
+    	} else 
222 222
     	{
223
-	     	if(!@is_dir($this->sessionDir))
223
+	     	if (!@is_dir($this->sessionDir))
224 224
 	    	{
225 225
 	    		return '';
226 226
 	    	}   		
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
         		die(SESSION_COUNTER_FILE_WRITE_FAILED);
99 99
         	}
100 100
         	@fclose($fp);
101
-        }else 
101
+        } else 
102 102
         {
103 103
         	die(SESSION_COUNTER_FILE_CREATE_FAILED);
104 104
         }   	
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 							if($fo->delete($path))
130 130
 							{
131 131
 								$output .= ' Deleted at ' . date('d/M/Y H:i:s');
132
-							}else 
132
+							} else 
133 133
 							{
134 134
 								$output .= " Failed at " . date('d/M/Y H:i:s');
135 135
 							}																			
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 								if($fo->delete($path))
168 168
 								{
169 169
 									$output .= ' Deleted at ' . date('d/M/Y H:i:s');
170
-								}else 
170
+								} else 
171 171
 								{
172 172
 									$output .= " Failed at " . date('d/M/Y H:i:s');
173 173
 								}																			
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
     		{
219 219
     			return '';
220 220
     		}
221
-    	}else 
221
+    	} else 
222 222
     	{
223 223
 	     	if(!@is_dir($this->sessionDir))
224 224
 	    	{
Please login to merge, or discard this patch.
phpmyfaq/admin/editor/plugins/ajaxfilemanager/inc/class.upload.php 4 patches
Doc Comments   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -173,7 +173,6 @@  discard block
 block discarded – undo
173 173
 	/**
174 174
 	 * get a file extension
175 175
 	 *
176
-	 * @param string $fileName the path to a file or just the file name
177 176
 	 */	
178 177
 	function getFileExt()
179 178
 	{
@@ -186,7 +185,7 @@  discard block
 block discarded – undo
186 185
 		 * @param string $dest  the path to the directory which the uploaded file will be moved to
187 186
 		 * @param string $fileBaseName the base name which the uploaded file will be renamed to
188 187
 		 * @param unknown_type $overwrite
189
-		 * @return unknown
188
+		 * @return boolean
190 189
 		 */
191 190
 	function moveUploadedFile($dest, $fileBaseName = '', $overwrite=false)
192 191
 	{
@@ -320,8 +319,8 @@  discard block
 block discarded – undo
320 319
      *
321 320
      * @access public
322 321
      *
323
-     * @param mixed $new_x 
324
-     * @param mixed $new_y 
322
+     * @param integer $new_x 
323
+     * @param integer $new_y 
325 324
      * @param string $thumb_suffix
326 325
      *
327 326
      * @return mixed none or PEAR_error
@@ -410,7 +409,8 @@  discard block
 block discarded – undo
410 409
 	/**
411 410
      *
412 411
      * @access public
413
-     * @return void
412
+     * @param string $image
413
+     * @return boolean|null
414 414
      */
415 415
 	function _get_image_details($image)
416 416
 	{
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 	/**
545 545
 	 * return the directory path witch the file uploaded to
546 546
 	 *
547
-	 * @return unknown
547
+	 * @return string
548 548
 	 */
549 549
 	function getDirPath()
550 550
 	{
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
 	/**
582 582
 	 * get uploaded file size
583 583
 	 *
584
-	 * @return string
584
+	 * @return integer
585 585
 	 */
586 586
 	function getFileSize()
587 587
 	{
Please login to merge, or discard this patch.
Indentation   +540 added lines, -540 removed lines patch added patch discarded remove patch
@@ -1,228 +1,228 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
3
-	{
4
-		die('Permission denied');
5
-	}
2
+    if(!defined('AJAX_INIT_DONE'))
3
+    {
4
+        die('Permission denied');
5
+    }
6 6
 ?><?php
7
-	/**
8
-	 * This class provide all file upload functionalities
9
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
10
-	 * @link www.phpletter.com
11
-	 * @since 22/April/2007
12
-	 *
13
-	 */
7
+    /**
8
+     * This class provide all file upload functionalities
9
+     * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
10
+     * @link www.phpletter.com
11
+     * @since 22/April/2007
12
+     *
13
+     */
14 14
 class Upload
15 15
 {
16
-	var $fileType = ""; //the file type
17
-	var $originalFileName = "";
18
-	var $fileName = ""; //the file final name
19
-	var $fileExtension = "";
20
-	var $img_x = 0;
21
-	var $img_y = 0;
22
-	var $img_new_x = 0;
23
-	var $img_new_y = 0;
24
-	var $imgHandler = null;
25
-	var $fileBaseName = ""; //file name without the file extension and .
26
-	var $filePath = ""; //the file path which the file uploaded to
27
-	var $fileSize = 0;
28
-	var $validImageExts = array("gif", "jpg", "png");
29
-	var $errors = array();
30
-	var $_value  = null;  //an array holding the uploaded file details
31
-	var $dirPath = "";
32
-	var $invalidFileExt = array(); //var $invalidFileExt = array('php,inc,asp,aspx');
33
-	var $errCode = "";
34
-	var $safeMode;
35
-	var $uploadFileMode = 0755;
36
-	var $errorCodes = array(
37
-		0=>'the file uploaded with success',
38
-		1=>'The uploaded file exceeds the upload_max_filesize directive in php.ini',
39
-		2=>'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form',
40
-		3=>'The uploaded file was only partially uploaded',
41
-		4=>'No file was uploaded.',
42
-		6=>'Missing a temporary folder',
43
-		7=>'Failed to write file to disk',
44
-		8=>'File upload stopped by extension',
45
-		999=>'No error code avaiable',
46
-	);
16
+    var $fileType = ""; //the file type
17
+    var $originalFileName = "";
18
+    var $fileName = ""; //the file final name
19
+    var $fileExtension = "";
20
+    var $img_x = 0;
21
+    var $img_y = 0;
22
+    var $img_new_x = 0;
23
+    var $img_new_y = 0;
24
+    var $imgHandler = null;
25
+    var $fileBaseName = ""; //file name without the file extension and .
26
+    var $filePath = ""; //the file path which the file uploaded to
27
+    var $fileSize = 0;
28
+    var $validImageExts = array("gif", "jpg", "png");
29
+    var $errors = array();
30
+    var $_value  = null;  //an array holding the uploaded file details
31
+    var $dirPath = "";
32
+    var $invalidFileExt = array(); //var $invalidFileExt = array('php,inc,asp,aspx');
33
+    var $errCode = "";
34
+    var $safeMode;
35
+    var $uploadFileMode = 0755;
36
+    var $errorCodes = array(
37
+        0=>'the file uploaded with success',
38
+        1=>'The uploaded file exceeds the upload_max_filesize directive in php.ini',
39
+        2=>'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form',
40
+        3=>'The uploaded file was only partially uploaded',
41
+        4=>'No file was uploaded.',
42
+        6=>'Missing a temporary folder',
43
+        7=>'Failed to write file to disk',
44
+        8=>'File upload stopped by extension',
45
+        999=>'No error code avaiable',
46
+    );
47 47
 	
48 48
 
49
-	function Upload()
50
-	{
51
-		//doing nothing
52
-	}
49
+    function Upload()
50
+    {
51
+        //doing nothing
52
+    }
53 53
 	
54
-	function isFileUploaded($indexInPost="file")
55
-	{
54
+    function isFileUploaded($indexInPost="file")
55
+    {
56 56
 		
57
-		$this->errCode = isset($_FILES[$indexInPost]['error'])?$_FILES[$indexInPost]['error']:999;
58
-		if((isset($_FILES[$indexInPost]['error']) && $_FILES[$indexInPost] == 0) ||
59
-		(!empty($_FILES[$indexInPost]['tmp_name']) && $_FILES[$indexInPost]['tmp_name'] != 'none')
60
-		)
61
-		{
62
-			$this->_value = $_FILES[$indexInPost];
63
-			$this->fileSize = @filesize($this->_value['tmp_name']);
64
-			$this->originalFileName = $this->_value['name'];
65
-			$this->fileType = $this->_value['type'];
57
+        $this->errCode = isset($_FILES[$indexInPost]['error'])?$_FILES[$indexInPost]['error']:999;
58
+        if((isset($_FILES[$indexInPost]['error']) && $_FILES[$indexInPost] == 0) ||
59
+        (!empty($_FILES[$indexInPost]['tmp_name']) && $_FILES[$indexInPost]['tmp_name'] != 'none')
60
+        )
61
+        {
62
+            $this->_value = $_FILES[$indexInPost];
63
+            $this->fileSize = @filesize($this->_value['tmp_name']);
64
+            $this->originalFileName = $this->_value['name'];
65
+            $this->fileType = $this->_value['type'];
66 66
 			
67
-			return true;
68
-		}else 
69
-		{
67
+            return true;
68
+        }else 
69
+        {
70 70
 			
71
-			array_push($this->errors, 'Unable to upload file');
72
-			return false;
73
-		}		
74
-	}
71
+            array_push($this->errors, 'Unable to upload file');
72
+            return false;
73
+        }		
74
+    }
75 75
 	
76
-	function getErrorCodeMsg()
77
-	{
78
-		return (isset($this->errorCodes[$this->errCode])?$this->errorCodes[$this->errCode]:"");
79
-	}
80
-	/**
81
-	 * check if the uploaded file extension is allowed against the validFile Extension
82
-	 * or against the invalid extension list when the list of valid file extension is not set
83
-	 *
84
-	 * @param array $validFileExt
85
-	 * @return boolean
86
-	 */
87
-	function isPermittedFileExt($validFileExt = array())
88
-	{
89
-		$tem = array();
90
-
91
-		if(sizeof($validFileExt))
92
-		{
93
-			foreach($validFileExt as $k=>$v)
94
-			{
95
-				$tem[$k] = strtolower(trim($v));
96
-			}
97
-		}
98
-		$validFileExt = $tem;
99
-
100
-		if(sizeof($validFileExt) && sizeof($this->invalidFileExt))
101
-		{
102
-			foreach($validFileExt as  $k=>$ext)
103
-			{
104
-				if(array_search(strtolower($ext), $this->invalidFileExt) !== false)
105
-				{
106
-					unset($validFileExt[$k]);
107
-				}
108
-			}
109
-		}
76
+    function getErrorCodeMsg()
77
+    {
78
+        return (isset($this->errorCodes[$this->errCode])?$this->errorCodes[$this->errCode]:"");
79
+    }
80
+    /**
81
+     * check if the uploaded file extension is allowed against the validFile Extension
82
+     * or against the invalid extension list when the list of valid file extension is not set
83
+     *
84
+     * @param array $validFileExt
85
+     * @return boolean
86
+     */
87
+    function isPermittedFileExt($validFileExt = array())
88
+    {
89
+        $tem = array();
90
+
91
+        if(sizeof($validFileExt))
92
+        {
93
+            foreach($validFileExt as $k=>$v)
94
+            {
95
+                $tem[$k] = strtolower(trim($v));
96
+            }
97
+        }
98
+        $validFileExt = $tem;
99
+
100
+        if(sizeof($validFileExt) && sizeof($this->invalidFileExt))
101
+        {
102
+            foreach($validFileExt as  $k=>$ext)
103
+            {
104
+                if(array_search(strtolower($ext), $this->invalidFileExt) !== false)
105
+                {
106
+                    unset($validFileExt[$k]);
107
+                }
108
+            }
109
+        }
110 110
 		
111 111
 	
112 112
 
113 113
 		
114
-		if(sizeof($validFileExt))
115
-		{
116
-			if(array_search(strtolower($this->getFileExt()), $validFileExt) !== false)
117
-			{
118
-				return true;
119
-			}
120
-		}elseif(array_search(strtolower($this->getFileExt()), $this->invalidFileExt) === false)
121
-		{
122
-			return true;
123
-		}
114
+        if(sizeof($validFileExt))
115
+        {
116
+            if(array_search(strtolower($this->getFileExt()), $validFileExt) !== false)
117
+            {
118
+                return true;
119
+            }
120
+        }elseif(array_search(strtolower($this->getFileExt()), $this->invalidFileExt) === false)
121
+        {
122
+            return true;
123
+        }
124 124
 
125 125
 		
126
-		$this->deleteUploadedFile();
127
-		return false;
126
+        $this->deleteUploadedFile();
127
+        return false;
128 128
 		
129
-	}
130
-	/**
131
-	 * check if the uploaded file size is too big
132
-	 *
133
-	 * @param integer $maxSize
134
-	 */
135
-	function isSizeTooBig($maxSize="")
136
-	{
137
-		if($this->fileSize > $maxSize)
138
-		{
139
-			$this->deleteUploadedFile();
140
-			return true;
141
-		}else 
142
-		{
143
-			return false;
144
-		}
145
-	}
146
-	/**
147
-	 * set the invali file extensions
148
-	 *
149
-	 * @param array $invalidFileExt
150
-	 */
151
-	function setInvalidFileExt($invalidFileExt=array())
152
-	{
153
-		$tem = array();
154
-		if(sizeof($invalidFileExt))
155
-		{
156
-			foreach($invalidFileExt as $k=>$v)
157
-			{
158
-				$tem[$k]= strtolower(trim($v));
159
-			}
160
-		}
129
+    }
130
+    /**
131
+     * check if the uploaded file size is too big
132
+     *
133
+     * @param integer $maxSize
134
+     */
135
+    function isSizeTooBig($maxSize="")
136
+    {
137
+        if($this->fileSize > $maxSize)
138
+        {
139
+            $this->deleteUploadedFile();
140
+            return true;
141
+        }else 
142
+        {
143
+            return false;
144
+        }
145
+    }
146
+    /**
147
+     * set the invali file extensions
148
+     *
149
+     * @param array $invalidFileExt
150
+     */
151
+    function setInvalidFileExt($invalidFileExt=array())
152
+    {
153
+        $tem = array();
154
+        if(sizeof($invalidFileExt))
155
+        {
156
+            foreach($invalidFileExt as $k=>$v)
157
+            {
158
+                $tem[$k]= strtolower(trim($v));
159
+            }
160
+        }
161 161
 		
162
-		$this->invalidFileExt = $tem;
163
-	}
164
-	/**
165
-	 * get file type
166
-	 *
167
-	 * @return string
168
-	 */
169
-	function getFileType()
170
-	{
171
-		return $this->fileType;
172
-	}
173
-	/**
174
-	 * get a file extension
175
-	 *
176
-	 * @param string $fileName the path to a file or just the file name
177
-	 */	
178
-	function getFileExt()
179
-	{
180
-		//return strtolower(substr(strrchr($this->fileName, "."), 1));
181
-		return substr(strrchr($this->originalFileName, "."), 1);
182
-	}
183
-	/**
184
-		 * move the uploaded file to a specific location
185
-		 *
186
-		 * @param string $dest  the path to the directory which the uploaded file will be moved to
187
-		 * @param string $fileBaseName the base name which the uploaded file will be renamed to
188
-		 * @param unknown_type $overwrite
189
-		 * @return unknown
190
-		 */
191
-	function moveUploadedFile($dest, $fileBaseName = '', $overwrite=false)
192
-	{
193
-		//ensure the directory path ending with /
194
-		if ($dest != ''  && substr($dest, -1) != '/') {
195
-			$dest .= '/';
196
-		}
197
-		$this->dirPath = $dest;
198
-		$fileName =  basename($this->_value['name']);
199
-
200
-		$dotIndex = strrpos($fileName, '.');
201
-		$this->fileExtension = '';
202
-		if(is_int($dotIndex))
203
-		{
204
-			$this->fileExtension = substr($fileName, $dotIndex);
205
-			$this->fileBaseName = substr($fileName, 0, $dotIndex);
206
-		}
207
-		if(!empty($fileBaseName))
208
-		{
209
-			$this->fileBaseName = $fileBaseName;
210
-		}
211
-		$fileName = $this->fileBaseName . $this->fileExtension;
212
-		$filePath = $dest . $fileName;
213
-
214
-		if(!$overwrite && file_exists($filePath) && is_file($filePath))
215
-		{//rename
216
-
217
-			$counter = 0;
218
-			while(file_exists($dest.$fileName) && is_file($dest .$fileName))
219
-			{
220
-				$counter++;
221
-				$fileName = $this->fileBaseName.'_'.$counter.$this->fileExtension;
222
-			}
223
-			$this->fileBaseName .= "_" . $counter;
224
-
225
-		}
162
+        $this->invalidFileExt = $tem;
163
+    }
164
+    /**
165
+     * get file type
166
+     *
167
+     * @return string
168
+     */
169
+    function getFileType()
170
+    {
171
+        return $this->fileType;
172
+    }
173
+    /**
174
+     * get a file extension
175
+     *
176
+     * @param string $fileName the path to a file or just the file name
177
+     */	
178
+    function getFileExt()
179
+    {
180
+        //return strtolower(substr(strrchr($this->fileName, "."), 1));
181
+        return substr(strrchr($this->originalFileName, "."), 1);
182
+    }
183
+    /**
184
+     * move the uploaded file to a specific location
185
+     *
186
+     * @param string $dest  the path to the directory which the uploaded file will be moved to
187
+     * @param string $fileBaseName the base name which the uploaded file will be renamed to
188
+     * @param unknown_type $overwrite
189
+     * @return unknown
190
+     */
191
+    function moveUploadedFile($dest, $fileBaseName = '', $overwrite=false)
192
+    {
193
+        //ensure the directory path ending with /
194
+        if ($dest != ''  && substr($dest, -1) != '/') {
195
+            $dest .= '/';
196
+        }
197
+        $this->dirPath = $dest;
198
+        $fileName =  basename($this->_value['name']);
199
+
200
+        $dotIndex = strrpos($fileName, '.');
201
+        $this->fileExtension = '';
202
+        if(is_int($dotIndex))
203
+        {
204
+            $this->fileExtension = substr($fileName, $dotIndex);
205
+            $this->fileBaseName = substr($fileName, 0, $dotIndex);
206
+        }
207
+        if(!empty($fileBaseName))
208
+        {
209
+            $this->fileBaseName = $fileBaseName;
210
+        }
211
+        $fileName = $this->fileBaseName . $this->fileExtension;
212
+        $filePath = $dest . $fileName;
213
+
214
+        if(!$overwrite && file_exists($filePath) && is_file($filePath))
215
+        {//rename
216
+
217
+            $counter = 0;
218
+            while(file_exists($dest.$fileName) && is_file($dest .$fileName))
219
+            {
220
+                $counter++;
221
+                $fileName = $this->fileBaseName.'_'.$counter.$this->fileExtension;
222
+            }
223
+            $this->fileBaseName .= "_" . $counter;
224
+
225
+        }
226 226
 
227 227
         // Don't allow .htaccess to be uploaded
228 228
         if (strpos($this->_value['tmp_name'], '.htaccess')) {
@@ -254,67 +254,67 @@  discard block
 block discarded – undo
254 254
             return false;
255 255
         }
256 256
 
257
-		if (@move_uploaded_file($this->_value['tmp_name'], $dest . $fileName)) {
258
-			@chmod($dest . $fileName, $this->uploadFileMode);
259
-			$this->fileName = $fileName;
260
-			$this->filePath = $dest . $fileName;
261
-			return true;
262
-		} else {
263
-			return false;
264
-		}
265
-	}
266
-
267
-
268
-	/**
269
-		 * check if the uploaded is permitted to upload
270
-		 *
271
-		 * @param mixed $invalidImageExts invalid image extension
272
-		 * @param bool $delete force to delete the uploaded file
273
-		 */	
274
-	function isImage($invalidImageExts = array(), $delete = true)
275
-	{
276
-		if(!is_array($invalidImageExts) && !empty($invalidImageExts))
277
-		{
278
-			$invalidImageExts = explode(",", $invalidImageExts);
279
-		}
280
-		foreach ($invalidImageExts as $k=>$v)
281
-		{
282
-			$invalidImageExts[$k] = strtolower(trim($v));
283
-		}
284
-		foreach ($this->validImageExts as $k=>$v)
285
-		{
286
-			$ValidImageExts[$k] = strtolower(trim($v));
287
-		}
288
-		if(sizeof($invalidImageExts))
289
-		{
290
-			foreach ($ValidImageExts as $k=>$v)
291
-			{
292
-				if(array_search(strtolower($v), $invalidImageExts) !== false)
293
-				{
294
-					unset($ValidImageExts[$k]);
295
-				}
296
-			}
297
-		}
298
-		if(array_search(strtolower($this->getFileExt()), $ValidImageExts)!==false)
299
-		{
300
-			$this->_get_image_details($this->filePath);
301
-			if(!empty($this->fileType))
302
-			{
303
-				return true;
304
-			}
305
-		}else
306
-		{
307
-			if($delete)
308
-			{
309
-				$this->deleteUploadedFile();
310
-			}
311
-		}
312
-
313
-		array($this->errors, "This file is not a image type file.");
314
-		return false;
315
-	}
316
-
317
-	/**
257
+        if (@move_uploaded_file($this->_value['tmp_name'], $dest . $fileName)) {
258
+            @chmod($dest . $fileName, $this->uploadFileMode);
259
+            $this->fileName = $fileName;
260
+            $this->filePath = $dest . $fileName;
261
+            return true;
262
+        } else {
263
+            return false;
264
+        }
265
+    }
266
+
267
+
268
+    /**
269
+     * check if the uploaded is permitted to upload
270
+     *
271
+     * @param mixed $invalidImageExts invalid image extension
272
+     * @param bool $delete force to delete the uploaded file
273
+     */	
274
+    function isImage($invalidImageExts = array(), $delete = true)
275
+    {
276
+        if(!is_array($invalidImageExts) && !empty($invalidImageExts))
277
+        {
278
+            $invalidImageExts = explode(",", $invalidImageExts);
279
+        }
280
+        foreach ($invalidImageExts as $k=>$v)
281
+        {
282
+            $invalidImageExts[$k] = strtolower(trim($v));
283
+        }
284
+        foreach ($this->validImageExts as $k=>$v)
285
+        {
286
+            $ValidImageExts[$k] = strtolower(trim($v));
287
+        }
288
+        if(sizeof($invalidImageExts))
289
+        {
290
+            foreach ($ValidImageExts as $k=>$v)
291
+            {
292
+                if(array_search(strtolower($v), $invalidImageExts) !== false)
293
+                {
294
+                    unset($ValidImageExts[$k]);
295
+                }
296
+            }
297
+        }
298
+        if(array_search(strtolower($this->getFileExt()), $ValidImageExts)!==false)
299
+        {
300
+            $this->_get_image_details($this->filePath);
301
+            if(!empty($this->fileType))
302
+            {
303
+                return true;
304
+            }
305
+        }else
306
+        {
307
+            if($delete)
308
+            {
309
+                $this->deleteUploadedFile();
310
+            }
311
+        }
312
+
313
+        array($this->errors, "This file is not a image type file.");
314
+        return false;
315
+    }
316
+
317
+    /**
318 318
      * Resize the Image in the X and/or Y direction
319 319
      * If either is 0 it will be scaled proportionally
320 320
      *
@@ -326,23 +326,23 @@  discard block
 block discarded – undo
326 326
      *
327 327
      * @return mixed none or PEAR_error
328 328
      */
329
-	function resize($filePath, $thumb_suffix="", $new_x = 0, $new_y = 0)
330
-	{
329
+    function resize($filePath, $thumb_suffix="", $new_x = 0, $new_y = 0)
330
+    {
331 331
 		
332
-		if(empty($filePath))
333
-		{
334
-			$filePath = $this->dirPath . $this->fileBaseName . $thumb_suffix  . $this->fileExtension;
335
-		}
336
-		// 0 means keep original size
337
-		if ($this->img_x > $this->img_y)
338
-		$new_y = intval($new_x/$this->img_x*$this->img_y);
339
-		else if ($this->img_y > $this->img_x)
340
-		$new_x = intval($new_y/$this->img_y*$this->img_x);
341
-		// Now do the library specific resizing.
342
-		return $this->_resize($filePath,$new_x, $new_y);
343
-	} // End resize
344
-
345
-	/**
332
+        if(empty($filePath))
333
+        {
334
+            $filePath = $this->dirPath . $this->fileBaseName . $thumb_suffix  . $this->fileExtension;
335
+        }
336
+        // 0 means keep original size
337
+        if ($this->img_x > $this->img_y)
338
+        $new_y = intval($new_x/$this->img_x*$this->img_y);
339
+        else if ($this->img_y > $this->img_x)
340
+        $new_x = intval($new_y/$this->img_y*$this->img_x);
341
+        // Now do the library specific resizing.
342
+        return $this->_resize($filePath,$new_x, $new_y);
343
+    } // End resize
344
+
345
+    /**
346 346
      * resize the image and return the thumbnail image  details array("width"=>, "height"=>, "name")
347 347
      *
348 348
      * @param string $fileName 
@@ -350,275 +350,275 @@  discard block
 block discarded – undo
350 350
      * @param int $new_y the thumbnail height
351 351
      * @return unknown
352 352
      */
353
-	function _resize($fileName, $new_x, $new_y) {
354
-		$functionName = 'ImageCreateFrom' . $this->fileType;
355
-
356
-
357
-		if(function_exists($functionName))
358
-		{
359
-			$this->imgHandler = $functionName($this->filePath);
360
-		}else
361
-		{
362
-			array_push($this->errors, $functionName . " function is unavailable");
363
-			return false;
364
-		}
365
-
366
-		if(function_exists('ImageCreateTrueColor')){
367
-			$new_img =ImageCreateTrueColor($new_x,$new_y);
368
-		} else {
369
-			$new_img =ImageCreate($new_x,$new_y);
370
-		}
371
-		if(function_exists('ImageCopyResampled')){
372
-			ImageCopyResampled($new_img, $this->imgHandler, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y);
373
-		} else {
374
-			ImageCopyResized($new_img, $this->imgHandler, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y);
375
-		}
376
-		if($this->_imageSave($new_img, $fileName, 80))
377
-		{
378
-			return array("width"=>$new_x, "height"=>$new_y, "name"=>basename($fileName));
379
-		}else
380
-		{
381
-
382
-			array_push($this->errors, "Unable to resize the image");
383
-			return false;
384
-		}
385
-
386
-	}
387
-	/**
388
-		 * save the thumbnail file and destroy the opened image
389
-		 *
390
-		 * @param resource $newImageHandler
391
-		 * @param string $fileName
392
-		 * @param int $quality
393
-		 * @return boolean
394
-		 */
395
-	function _imageSave($newImageHandler, $fileName, $quality = 90)
396
-	{
397
-		$functionName = 'image' . $this->fileType;
398
-		if($functionName($newImageHandler, $fileName, $quality))
399
-		{
400
-			imagedestroy($newImageHandler);
401
-			return true;
402
-		}else
403
-		{
404
-			imagedestroy($newImageHandler);
405
-			array_push($this->errors, "Unable to save the thumbnail file.");
406
-			return false;
407
-		}
408
-
409
-	}
410
-	/**
353
+    function _resize($fileName, $new_x, $new_y) {
354
+        $functionName = 'ImageCreateFrom' . $this->fileType;
355
+
356
+
357
+        if(function_exists($functionName))
358
+        {
359
+            $this->imgHandler = $functionName($this->filePath);
360
+        }else
361
+        {
362
+            array_push($this->errors, $functionName . " function is unavailable");
363
+            return false;
364
+        }
365
+
366
+        if(function_exists('ImageCreateTrueColor')){
367
+            $new_img =ImageCreateTrueColor($new_x,$new_y);
368
+        } else {
369
+            $new_img =ImageCreate($new_x,$new_y);
370
+        }
371
+        if(function_exists('ImageCopyResampled')){
372
+            ImageCopyResampled($new_img, $this->imgHandler, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y);
373
+        } else {
374
+            ImageCopyResized($new_img, $this->imgHandler, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y);
375
+        }
376
+        if($this->_imageSave($new_img, $fileName, 80))
377
+        {
378
+            return array("width"=>$new_x, "height"=>$new_y, "name"=>basename($fileName));
379
+        }else
380
+        {
381
+
382
+            array_push($this->errors, "Unable to resize the image");
383
+            return false;
384
+        }
385
+
386
+    }
387
+    /**
388
+     * save the thumbnail file and destroy the opened image
389
+     *
390
+     * @param resource $newImageHandler
391
+     * @param string $fileName
392
+     * @param int $quality
393
+     * @return boolean
394
+     */
395
+    function _imageSave($newImageHandler, $fileName, $quality = 90)
396
+    {
397
+        $functionName = 'image' . $this->fileType;
398
+        if($functionName($newImageHandler, $fileName, $quality))
399
+        {
400
+            imagedestroy($newImageHandler);
401
+            return true;
402
+        }else
403
+        {
404
+            imagedestroy($newImageHandler);
405
+            array_push($this->errors, "Unable to save the thumbnail file.");
406
+            return false;
407
+        }
408
+
409
+    }
410
+    /**
411 411
      *
412 412
      * @access public
413 413
      * @return void
414 414
      */
415
-	function _get_image_details($image)
416
-	{
417
-
418
-		//echo $image;
419
-		$data = @GetImageSize($image);
420
-		#1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order,
421
-		# 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC
422
-		if (is_array($data)){
423
-			switch($data[2]){
424
-				case 1:
425
-					$type = 'gif';
426
-					break;
427
-				case 2:
428
-					$type = 'jpeg';
429
-					break;
430
-				case 3:
431
-					$type = 'png';
432
-					break;
433
-				case 4:
434
-					$type = 'swf';
435
-					break;
436
-				case 5:
437
-					$type = 'psd';
438
-				case 6:
439
-					$type = 'bmp';
440
-				case 7:
441
-				case 8:
442
-					$type = 'tiff';
443
-				default:
444
-					array_push($this->errors, "We do not recognize this image format");
445
-
446
-			}
447
-			$this->img_x = $data[0];
448
-			$this->img_y = $data[1];
449
-			$this->fileType = $type;
450
-
451
-			return true;
452
-		} else {
453
-			array_push($this->errors, "Cannot fetch image or images details.");
454
-			return null;
455
-		}
456
-	}
457
-	/**
458
-	 * caculate the thumbnail details from the original image file 
459
-	 *
460
-	 * @param string $originalImageName  
461
-	 * @param int $originaleImageWidth
462
-	 * @param int $originalImageHeight
463
-	 * @param string $thumbnailSuffix
464
-	 * @param int $thumbnailWidth
465
-	 * @param int $thumbnailHeight
466
-	 * @return array array("name"=>"image name", "width"=>"image width", "height"=>"image height")
467
-	 */
468
-	function getThumbInfo($originalImageName, $originaleImageWidth, $originalImageHeight, $thumbnailSuffix, $thumbnailWidth, $thumbnailHeight)
469
-	{
470
-		$outputs = array("name"=>"", "width"=>0, "height"=>0);
471
-		$thumbnailWidth	= intval($thumbnailWidth);
472
-		$thumbnailHeight = intval($thumbnailHeight);
473
-		if(!empty($originalImageName) && !empty($originaleImageWidth) && !empty($originalImageHeight))
474
-		{
475
-			$dotIndex = strrpos($originalImageName, '.');
476
-			//begin to get the thumbnail image name
477
-			$fileExtension = '';
478
-			$fileBaseName = '';
479
-			if(is_int($dotIndex))
480
-			{
481
-				$fileExtension = substr($originalImageName, $dotIndex);
482
-				$fileBaseName = substr($originalImageName, 0, $dotIndex);
483
-			}
484
-			$outputs['name'] = $fileBaseName . $thumbnailSuffix . $fileExtension;
485
-			//start to get the thumbnail width & height
486
-			if($thumbnailWidth < 1 && $thumbnailHeight < 1)
487
-			{
488
-				$thumbnailWidth =$originaleImageWidth;
489
-				$thumbnailHeight = $originalImageHeight;
490
-			}elseif($thumbnailWidth < 1)
491
-			{
492
-				$thumbnailWidth = floor($thumbnailHeight / $originalImageHeight * $originaleImageWidth);
493
-
494
-			}elseif($thumbnailHeight < 1)
495
-			{
496
-				$thumbnailHeight = floor($thumbnailWidth / $originaleImageWidth * $originalImageHeight);
497
-			}else
498
-			{
499
-				$scale = min($thumbnailWidth/$originaleImageWidth, $thumbnailHeight/$originalImageHeight);
500
-				$thumbnailWidth = floor($scale*$originaleImageWidth);
501
-				$thumbnailHeight = floor($scale*$originalImageHeight);
502
-			}
503
-			$outputs['width'] = $thumbnailWidth;
504
-			$outputs['height'] = $thumbnailHeight;
505
-		}
506
-		return $outputs;
507
-
508
-	}
415
+    function _get_image_details($image)
416
+    {
417
+
418
+        //echo $image;
419
+        $data = @GetImageSize($image);
420
+        #1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order,
421
+        # 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC
422
+        if (is_array($data)){
423
+            switch($data[2]){
424
+                case 1:
425
+                    $type = 'gif';
426
+                    break;
427
+                case 2:
428
+                    $type = 'jpeg';
429
+                    break;
430
+                case 3:
431
+                    $type = 'png';
432
+                    break;
433
+                case 4:
434
+                    $type = 'swf';
435
+                    break;
436
+                case 5:
437
+                    $type = 'psd';
438
+                case 6:
439
+                    $type = 'bmp';
440
+                case 7:
441
+                case 8:
442
+                    $type = 'tiff';
443
+                default:
444
+                    array_push($this->errors, "We do not recognize this image format");
445
+
446
+            }
447
+            $this->img_x = $data[0];
448
+            $this->img_y = $data[1];
449
+            $this->fileType = $type;
450
+
451
+            return true;
452
+        } else {
453
+            array_push($this->errors, "Cannot fetch image or images details.");
454
+            return null;
455
+        }
456
+    }
457
+    /**
458
+     * caculate the thumbnail details from the original image file 
459
+     *
460
+     * @param string $originalImageName  
461
+     * @param int $originaleImageWidth
462
+     * @param int $originalImageHeight
463
+     * @param string $thumbnailSuffix
464
+     * @param int $thumbnailWidth
465
+     * @param int $thumbnailHeight
466
+     * @return array array("name"=>"image name", "width"=>"image width", "height"=>"image height")
467
+     */
468
+    function getThumbInfo($originalImageName, $originaleImageWidth, $originalImageHeight, $thumbnailSuffix, $thumbnailWidth, $thumbnailHeight)
469
+    {
470
+        $outputs = array("name"=>"", "width"=>0, "height"=>0);
471
+        $thumbnailWidth	= intval($thumbnailWidth);
472
+        $thumbnailHeight = intval($thumbnailHeight);
473
+        if(!empty($originalImageName) && !empty($originaleImageWidth) && !empty($originalImageHeight))
474
+        {
475
+            $dotIndex = strrpos($originalImageName, '.');
476
+            //begin to get the thumbnail image name
477
+            $fileExtension = '';
478
+            $fileBaseName = '';
479
+            if(is_int($dotIndex))
480
+            {
481
+                $fileExtension = substr($originalImageName, $dotIndex);
482
+                $fileBaseName = substr($originalImageName, 0, $dotIndex);
483
+            }
484
+            $outputs['name'] = $fileBaseName . $thumbnailSuffix . $fileExtension;
485
+            //start to get the thumbnail width & height
486
+            if($thumbnailWidth < 1 && $thumbnailHeight < 1)
487
+            {
488
+                $thumbnailWidth =$originaleImageWidth;
489
+                $thumbnailHeight = $originalImageHeight;
490
+            }elseif($thumbnailWidth < 1)
491
+            {
492
+                $thumbnailWidth = floor($thumbnailHeight / $originalImageHeight * $originaleImageWidth);
493
+
494
+            }elseif($thumbnailHeight < 1)
495
+            {
496
+                $thumbnailHeight = floor($thumbnailWidth / $originaleImageWidth * $originalImageHeight);
497
+            }else
498
+            {
499
+                $scale = min($thumbnailWidth/$originaleImageWidth, $thumbnailHeight/$originalImageHeight);
500
+                $thumbnailWidth = floor($scale*$originaleImageWidth);
501
+                $thumbnailHeight = floor($scale*$originalImageHeight);
502
+            }
503
+            $outputs['width'] = $thumbnailWidth;
504
+            $outputs['height'] = $thumbnailHeight;
505
+        }
506
+        return $outputs;
507
+
508
+    }
509 509
 	
510 510
 
511
-	/**
511
+    /**
512 512
      * get the uploaded file
513 513
      */
514
-	function deleteUploadedFile()
515
-	{
516
-		@unlink($this->filePath);
517
-	}
518
-	/**
519
-	 * destroy the tmp file
520
-	 *
521
-	 */
522
-	function finish()
523
-	{
524
-		@unlink($this->_value['tmp_name']);
525
-	}
514
+    function deleteUploadedFile()
515
+    {
516
+        @unlink($this->filePath);
517
+    }
518
+    /**
519
+     * destroy the tmp file
520
+     *
521
+     */
522
+    function finish()
523
+    {
524
+        @unlink($this->_value['tmp_name']);
525
+    }
526 526
 	
527
-	function displayError()
528
-	{
529
-		if(sizeof($this->errors))
530
-		{
531
-			echo "<pre>";
532
-			print_r($this->errors);
533
-			echo "</pre>";
534
-		}
535
-	}
536
-	/**
537
-	 * get the path which the file uploaded to
538
-	 *
539
-	 */
540
-	function getFilePath()
541
-	{
542
-		return $this->filePath;
543
-	}
544
-	/**
545
-	 * return the directory path witch the file uploaded to
546
-	 *
547
-	 * @return unknown
548
-	 */
549
-	function getDirPath()
550
-	{
551
-		return $this->dirPath;
552
-	}
527
+    function displayError()
528
+    {
529
+        if(sizeof($this->errors))
530
+        {
531
+            echo "<pre>";
532
+            print_r($this->errors);
533
+            echo "</pre>";
534
+        }
535
+    }
536
+    /**
537
+     * get the path which the file uploaded to
538
+     *
539
+     */
540
+    function getFilePath()
541
+    {
542
+        return $this->filePath;
543
+    }
544
+    /**
545
+     * return the directory path witch the file uploaded to
546
+     *
547
+     * @return unknown
548
+     */
549
+    function getDirPath()
550
+    {
551
+        return $this->dirPath;
552
+    }
553 553
 	
554
-	function getFileBaseName()
555
-	{
556
-		return $this->fileBaseName;
557
-	}
554
+    function getFileBaseName()
555
+    {
556
+        return $this->fileBaseName;
557
+    }
558 558
 	
559
-	function getFileName()
560
-	{
561
-		return $this->fileName;
562
-	}
563
-	/**
564
-	 * get image width
565
-	 *
566
-	 * @return integer
567
-	 */
568
-	function getImageWidth()
569
-	{
570
-		return $this->img_x;
571
-	}
572
-	/**
573
-	 * get image height
574
-	 *
575
-	 * @return integer
576
-	 */
577
-	function getImageHeight()
578
-	{
579
-		return $this->img_y;
580
-	}
581
-	/**
582
-	 * get uploaded file size
583
-	 *
584
-	 * @return string
585
-	 */
586
-	function getFileSize()
587
-	{
588
-		return $this->fileSize;
589
-	}
590
-	/**
591
-	 * delete the uploaded image file & associated thumnails
592
-	 *
593
-	 * @param string $dirPath
594
-	 * @param string $originalImageName
595
-	 * @param string $arrayThumbnailSuffix
596
-	 */
597
-	function deleteFileAndThumbs($dirPath, $originalImageName, $arrayThumbnailSuffix)
598
-	{
599
-		//ensure the directory path ending with /
600
-		if ($dirPath != ''  && substr($dirPath, -1) != '/') {
601
-			$dirPath .= '/';
602
-		}			
603
-		if(!empty($originalImageName) && file_exists($dirPath . $originalImageName) && is_file($dirPath . $originalImageName))
604
-		{
605
-			@unlink($dirPath . $originalImageName);
606
-			foreach($arrayThumbnailSuffix as $v)
607
-			{
608
-				$dotIndex = strrpos($originalImageName, '.');
609
-				//begin to get the thumbnail image name
610
-				$fileExtension = '';
611
-				$fileBaseName = '';
612
-				if(is_int($dotIndex))
613
-				{
614
-					$fileExtension = substr($originalImageName, $dotIndex);
615
-					$fileBaseName = substr($originalImageName, 0, $dotIndex);
616
-				}
617
-				@unlink($dirPath . $fileBaseName . $v . $fileExtension);			
618
-			}			
619
-		}
559
+    function getFileName()
560
+    {
561
+        return $this->fileName;
562
+    }
563
+    /**
564
+     * get image width
565
+     *
566
+     * @return integer
567
+     */
568
+    function getImageWidth()
569
+    {
570
+        return $this->img_x;
571
+    }
572
+    /**
573
+     * get image height
574
+     *
575
+     * @return integer
576
+     */
577
+    function getImageHeight()
578
+    {
579
+        return $this->img_y;
580
+    }
581
+    /**
582
+     * get uploaded file size
583
+     *
584
+     * @return string
585
+     */
586
+    function getFileSize()
587
+    {
588
+        return $this->fileSize;
589
+    }
590
+    /**
591
+     * delete the uploaded image file & associated thumnails
592
+     *
593
+     * @param string $dirPath
594
+     * @param string $originalImageName
595
+     * @param string $arrayThumbnailSuffix
596
+     */
597
+    function deleteFileAndThumbs($dirPath, $originalImageName, $arrayThumbnailSuffix)
598
+    {
599
+        //ensure the directory path ending with /
600
+        if ($dirPath != ''  && substr($dirPath, -1) != '/') {
601
+            $dirPath .= '/';
602
+        }			
603
+        if(!empty($originalImageName) && file_exists($dirPath . $originalImageName) && is_file($dirPath . $originalImageName))
604
+        {
605
+            @unlink($dirPath . $originalImageName);
606
+            foreach($arrayThumbnailSuffix as $v)
607
+            {
608
+                $dotIndex = strrpos($originalImageName, '.');
609
+                //begin to get the thumbnail image name
610
+                $fileExtension = '';
611
+                $fileBaseName = '';
612
+                if(is_int($dotIndex))
613
+                {
614
+                    $fileExtension = substr($originalImageName, $dotIndex);
615
+                    $fileBaseName = substr($originalImageName, 0, $dotIndex);
616
+                }
617
+                @unlink($dirPath . $fileBaseName . $v . $fileExtension);			
618
+            }			
619
+        }
620 620
 	
621 621
 
622
-	}
622
+    }
623 623
 }
624 624
 ?>
625 625
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
2
+	if (!defined('AJAX_INIT_DONE'))
3 3
 	{
4 4
 		die('Permission denied');
5 5
 	}
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	var $fileSize = 0;
28 28
 	var $validImageExts = array("gif", "jpg", "png");
29 29
 	var $errors = array();
30
-	var $_value  = null;  //an array holding the uploaded file details
30
+	var $_value  = null; //an array holding the uploaded file details
31 31
 	var $dirPath = "";
32 32
 	var $invalidFileExt = array(); //var $invalidFileExt = array('php,inc,asp,aspx');
33 33
 	var $errCode = "";
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
 		//doing nothing
52 52
 	}
53 53
 	
54
-	function isFileUploaded($indexInPost="file")
54
+	function isFileUploaded($indexInPost = "file")
55 55
 	{
56 56
 		
57
-		$this->errCode = isset($_FILES[$indexInPost]['error'])?$_FILES[$indexInPost]['error']:999;
58
-		if((isset($_FILES[$indexInPost]['error']) && $_FILES[$indexInPost] == 0) ||
57
+		$this->errCode = isset($_FILES[$indexInPost]['error']) ? $_FILES[$indexInPost]['error'] : 999;
58
+		if ((isset($_FILES[$indexInPost]['error']) && $_FILES[$indexInPost] == 0) ||
59 59
 		(!empty($_FILES[$indexInPost]['tmp_name']) && $_FILES[$indexInPost]['tmp_name'] != 'none')
60 60
 		)
61 61
 		{
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 			$this->fileType = $this->_value['type'];
66 66
 			
67 67
 			return true;
68
-		}else 
68
+		} else 
69 69
 		{
70 70
 			
71 71
 			array_push($this->errors, 'Unable to upload file');
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 	
76 76
 	function getErrorCodeMsg()
77 77
 	{
78
-		return (isset($this->errorCodes[$this->errCode])?$this->errorCodes[$this->errCode]:"");
78
+		return (isset($this->errorCodes[$this->errCode]) ? $this->errorCodes[$this->errCode] : "");
79 79
 	}
80 80
 	/**
81 81
 	 * check if the uploaded file extension is allowed against the validFile Extension
@@ -88,20 +88,20 @@  discard block
 block discarded – undo
88 88
 	{
89 89
 		$tem = array();
90 90
 
91
-		if(sizeof($validFileExt))
91
+		if (sizeof($validFileExt))
92 92
 		{
93
-			foreach($validFileExt as $k=>$v)
93
+			foreach ($validFileExt as $k=>$v)
94 94
 			{
95 95
 				$tem[$k] = strtolower(trim($v));
96 96
 			}
97 97
 		}
98 98
 		$validFileExt = $tem;
99 99
 
100
-		if(sizeof($validFileExt) && sizeof($this->invalidFileExt))
100
+		if (sizeof($validFileExt) && sizeof($this->invalidFileExt))
101 101
 		{
102
-			foreach($validFileExt as  $k=>$ext)
102
+			foreach ($validFileExt as  $k=>$ext)
103 103
 			{
104
-				if(array_search(strtolower($ext), $this->invalidFileExt) !== false)
104
+				if (array_search(strtolower($ext), $this->invalidFileExt) !== false)
105 105
 				{
106 106
 					unset($validFileExt[$k]);
107 107
 				}
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
 	
112 112
 
113 113
 		
114
-		if(sizeof($validFileExt))
114
+		if (sizeof($validFileExt))
115 115
 		{
116
-			if(array_search(strtolower($this->getFileExt()), $validFileExt) !== false)
116
+			if (array_search(strtolower($this->getFileExt()), $validFileExt) !== false)
117 117
 			{
118 118
 				return true;
119 119
 			}
120
-		}elseif(array_search(strtolower($this->getFileExt()), $this->invalidFileExt) === false)
120
+		}elseif (array_search(strtolower($this->getFileExt()), $this->invalidFileExt) === false)
121 121
 		{
122 122
 			return true;
123 123
 		}
@@ -132,13 +132,13 @@  discard block
 block discarded – undo
132 132
 	 *
133 133
 	 * @param integer $maxSize
134 134
 	 */
135
-	function isSizeTooBig($maxSize="")
135
+	function isSizeTooBig($maxSize = "")
136 136
 	{
137
-		if($this->fileSize > $maxSize)
137
+		if ($this->fileSize > $maxSize)
138 138
 		{
139 139
 			$this->deleteUploadedFile();
140 140
 			return true;
141
-		}else 
141
+		} else 
142 142
 		{
143 143
 			return false;
144 144
 		}
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 	 *
149 149
 	 * @param array $invalidFileExt
150 150
 	 */
151
-	function setInvalidFileExt($invalidFileExt=array())
151
+	function setInvalidFileExt($invalidFileExt = array())
152 152
 	{
153 153
 		$tem = array();
154
-		if(sizeof($invalidFileExt))
154
+		if (sizeof($invalidFileExt))
155 155
 		{
156
-			foreach($invalidFileExt as $k=>$v)
156
+			foreach ($invalidFileExt as $k=>$v)
157 157
 			{
158
-				$tem[$k]= strtolower(trim($v));
158
+				$tem[$k] = strtolower(trim($v));
159 159
 			}
160 160
 		}
161 161
 		
@@ -188,39 +188,39 @@  discard block
 block discarded – undo
188 188
 		 * @param unknown_type $overwrite
189 189
 		 * @return unknown
190 190
 		 */
191
-	function moveUploadedFile($dest, $fileBaseName = '', $overwrite=false)
191
+	function moveUploadedFile($dest, $fileBaseName = '', $overwrite = false)
192 192
 	{
193 193
 		//ensure the directory path ending with /
194
-		if ($dest != ''  && substr($dest, -1) != '/') {
194
+		if ($dest != '' && substr($dest, -1) != '/') {
195 195
 			$dest .= '/';
196 196
 		}
197 197
 		$this->dirPath = $dest;
198
-		$fileName =  basename($this->_value['name']);
198
+		$fileName = basename($this->_value['name']);
199 199
 
200 200
 		$dotIndex = strrpos($fileName, '.');
201 201
 		$this->fileExtension = '';
202
-		if(is_int($dotIndex))
202
+		if (is_int($dotIndex))
203 203
 		{
204 204
 			$this->fileExtension = substr($fileName, $dotIndex);
205 205
 			$this->fileBaseName = substr($fileName, 0, $dotIndex);
206 206
 		}
207
-		if(!empty($fileBaseName))
207
+		if (!empty($fileBaseName))
208 208
 		{
209 209
 			$this->fileBaseName = $fileBaseName;
210 210
 		}
211
-		$fileName = $this->fileBaseName . $this->fileExtension;
212
-		$filePath = $dest . $fileName;
211
+		$fileName = $this->fileBaseName.$this->fileExtension;
212
+		$filePath = $dest.$fileName;
213 213
 
214
-		if(!$overwrite && file_exists($filePath) && is_file($filePath))
214
+		if (!$overwrite && file_exists($filePath) && is_file($filePath))
215 215
 		{//rename
216 216
 
217 217
 			$counter = 0;
218
-			while(file_exists($dest.$fileName) && is_file($dest .$fileName))
218
+			while (file_exists($dest.$fileName) && is_file($dest.$fileName))
219 219
 			{
220 220
 				$counter++;
221 221
 				$fileName = $this->fileBaseName.'_'.$counter.$this->fileExtension;
222 222
 			}
223
-			$this->fileBaseName .= "_" . $counter;
223
+			$this->fileBaseName .= "_".$counter;
224 224
 
225 225
 		}
226 226
 
@@ -254,10 +254,10 @@  discard block
 block discarded – undo
254 254
             return false;
255 255
         }
256 256
 
257
-		if (@move_uploaded_file($this->_value['tmp_name'], $dest . $fileName)) {
258
-			@chmod($dest . $fileName, $this->uploadFileMode);
257
+		if (@move_uploaded_file($this->_value['tmp_name'], $dest.$fileName)) {
258
+			@chmod($dest.$fileName, $this->uploadFileMode);
259 259
 			$this->fileName = $fileName;
260
-			$this->filePath = $dest . $fileName;
260
+			$this->filePath = $dest.$fileName;
261 261
 			return true;
262 262
 		} else {
263 263
 			return false;
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 		 */	
274 274
 	function isImage($invalidImageExts = array(), $delete = true)
275 275
 	{
276
-		if(!is_array($invalidImageExts) && !empty($invalidImageExts))
276
+		if (!is_array($invalidImageExts) && !empty($invalidImageExts))
277 277
 		{
278 278
 			$invalidImageExts = explode(",", $invalidImageExts);
279 279
 		}
@@ -285,26 +285,26 @@  discard block
 block discarded – undo
285 285
 		{
286 286
 			$ValidImageExts[$k] = strtolower(trim($v));
287 287
 		}
288
-		if(sizeof($invalidImageExts))
288
+		if (sizeof($invalidImageExts))
289 289
 		{
290 290
 			foreach ($ValidImageExts as $k=>$v)
291 291
 			{
292
-				if(array_search(strtolower($v), $invalidImageExts) !== false)
292
+				if (array_search(strtolower($v), $invalidImageExts) !== false)
293 293
 				{
294 294
 					unset($ValidImageExts[$k]);
295 295
 				}
296 296
 			}
297 297
 		}
298
-		if(array_search(strtolower($this->getFileExt()), $ValidImageExts)!==false)
298
+		if (array_search(strtolower($this->getFileExt()), $ValidImageExts) !== false)
299 299
 		{
300 300
 			$this->_get_image_details($this->filePath);
301
-			if(!empty($this->fileType))
301
+			if (!empty($this->fileType))
302 302
 			{
303 303
 				return true;
304 304
 			}
305
-		}else
305
+		} else
306 306
 		{
307
-			if($delete)
307
+			if ($delete)
308 308
 			{
309 309
 				$this->deleteUploadedFile();
310 310
 			}
@@ -326,12 +326,12 @@  discard block
 block discarded – undo
326 326
      *
327 327
      * @return mixed none or PEAR_error
328 328
      */
329
-	function resize($filePath, $thumb_suffix="", $new_x = 0, $new_y = 0)
329
+	function resize($filePath, $thumb_suffix = "", $new_x = 0, $new_y = 0)
330 330
 	{
331 331
 		
332
-		if(empty($filePath))
332
+		if (empty($filePath))
333 333
 		{
334
-			$filePath = $this->dirPath . $this->fileBaseName . $thumb_suffix  . $this->fileExtension;
334
+			$filePath = $this->dirPath.$this->fileBaseName.$thumb_suffix.$this->fileExtension;
335 335
 		}
336 336
 		// 0 means keep original size
337 337
 		if ($this->img_x > $this->img_y)
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 		else if ($this->img_y > $this->img_x)
340 340
 		$new_x = intval($new_y/$this->img_y*$this->img_x);
341 341
 		// Now do the library specific resizing.
342
-		return $this->_resize($filePath,$new_x, $new_y);
342
+		return $this->_resize($filePath, $new_x, $new_y);
343 343
 	} // End resize
344 344
 
345 345
 	/**
@@ -351,32 +351,32 @@  discard block
 block discarded – undo
351 351
      * @return unknown
352 352
      */
353 353
 	function _resize($fileName, $new_x, $new_y) {
354
-		$functionName = 'ImageCreateFrom' . $this->fileType;
354
+		$functionName = 'ImageCreateFrom'.$this->fileType;
355 355
 
356 356
 
357
-		if(function_exists($functionName))
357
+		if (function_exists($functionName))
358 358
 		{
359 359
 			$this->imgHandler = $functionName($this->filePath);
360
-		}else
360
+		} else
361 361
 		{
362
-			array_push($this->errors, $functionName . " function is unavailable");
362
+			array_push($this->errors, $functionName." function is unavailable");
363 363
 			return false;
364 364
 		}
365 365
 
366
-		if(function_exists('ImageCreateTrueColor')){
367
-			$new_img =ImageCreateTrueColor($new_x,$new_y);
366
+		if (function_exists('ImageCreateTrueColor')) {
367
+			$new_img = ImageCreateTrueColor($new_x, $new_y);
368 368
 		} else {
369
-			$new_img =ImageCreate($new_x,$new_y);
369
+			$new_img = ImageCreate($new_x, $new_y);
370 370
 		}
371
-		if(function_exists('ImageCopyResampled')){
371
+		if (function_exists('ImageCopyResampled')) {
372 372
 			ImageCopyResampled($new_img, $this->imgHandler, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y);
373 373
 		} else {
374 374
 			ImageCopyResized($new_img, $this->imgHandler, 0, 0, 0, 0, $new_x, $new_y, $this->img_x, $this->img_y);
375 375
 		}
376
-		if($this->_imageSave($new_img, $fileName, 80))
376
+		if ($this->_imageSave($new_img, $fileName, 80))
377 377
 		{
378 378
 			return array("width"=>$new_x, "height"=>$new_y, "name"=>basename($fileName));
379
-		}else
379
+		} else
380 380
 		{
381 381
 
382 382
 			array_push($this->errors, "Unable to resize the image");
@@ -394,12 +394,12 @@  discard block
 block discarded – undo
394 394
 		 */
395 395
 	function _imageSave($newImageHandler, $fileName, $quality = 90)
396 396
 	{
397
-		$functionName = 'image' . $this->fileType;
398
-		if($functionName($newImageHandler, $fileName, $quality))
397
+		$functionName = 'image'.$this->fileType;
398
+		if ($functionName($newImageHandler, $fileName, $quality))
399 399
 		{
400 400
 			imagedestroy($newImageHandler);
401 401
 			return true;
402
-		}else
402
+		} else
403 403
 		{
404 404
 			imagedestroy($newImageHandler);
405 405
 			array_push($this->errors, "Unable to save the thumbnail file.");
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
 		$data = @GetImageSize($image);
420 420
 		#1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order,
421 421
 		# 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC
422
-		if (is_array($data)){
423
-			switch($data[2]){
422
+		if (is_array($data)) {
423
+			switch ($data[2]) {
424 424
 				case 1:
425 425
 					$type = 'gif';
426 426
 					break;
@@ -468,33 +468,33 @@  discard block
 block discarded – undo
468 468
 	function getThumbInfo($originalImageName, $originaleImageWidth, $originalImageHeight, $thumbnailSuffix, $thumbnailWidth, $thumbnailHeight)
469 469
 	{
470 470
 		$outputs = array("name"=>"", "width"=>0, "height"=>0);
471
-		$thumbnailWidth	= intval($thumbnailWidth);
471
+		$thumbnailWidth = intval($thumbnailWidth);
472 472
 		$thumbnailHeight = intval($thumbnailHeight);
473
-		if(!empty($originalImageName) && !empty($originaleImageWidth) && !empty($originalImageHeight))
473
+		if (!empty($originalImageName) && !empty($originaleImageWidth) && !empty($originalImageHeight))
474 474
 		{
475 475
 			$dotIndex = strrpos($originalImageName, '.');
476 476
 			//begin to get the thumbnail image name
477 477
 			$fileExtension = '';
478 478
 			$fileBaseName = '';
479
-			if(is_int($dotIndex))
479
+			if (is_int($dotIndex))
480 480
 			{
481 481
 				$fileExtension = substr($originalImageName, $dotIndex);
482 482
 				$fileBaseName = substr($originalImageName, 0, $dotIndex);
483 483
 			}
484
-			$outputs['name'] = $fileBaseName . $thumbnailSuffix . $fileExtension;
484
+			$outputs['name'] = $fileBaseName.$thumbnailSuffix.$fileExtension;
485 485
 			//start to get the thumbnail width & height
486
-			if($thumbnailWidth < 1 && $thumbnailHeight < 1)
486
+			if ($thumbnailWidth < 1 && $thumbnailHeight < 1)
487 487
 			{
488
-				$thumbnailWidth =$originaleImageWidth;
488
+				$thumbnailWidth = $originaleImageWidth;
489 489
 				$thumbnailHeight = $originalImageHeight;
490
-			}elseif($thumbnailWidth < 1)
490
+			}elseif ($thumbnailWidth < 1)
491 491
 			{
492
-				$thumbnailWidth = floor($thumbnailHeight / $originalImageHeight * $originaleImageWidth);
492
+				$thumbnailWidth = floor($thumbnailHeight/$originalImageHeight*$originaleImageWidth);
493 493
 
494
-			}elseif($thumbnailHeight < 1)
494
+			}elseif ($thumbnailHeight < 1)
495 495
 			{
496
-				$thumbnailHeight = floor($thumbnailWidth / $originaleImageWidth * $originalImageHeight);
497
-			}else
496
+				$thumbnailHeight = floor($thumbnailWidth/$originaleImageWidth*$originalImageHeight);
497
+			} else
498 498
 			{
499 499
 				$scale = min($thumbnailWidth/$originaleImageWidth, $thumbnailHeight/$originalImageHeight);
500 500
 				$thumbnailWidth = floor($scale*$originaleImageWidth);
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 	
527 527
 	function displayError()
528 528
 	{
529
-		if(sizeof($this->errors))
529
+		if (sizeof($this->errors))
530 530
 		{
531 531
 			echo "<pre>";
532 532
 			print_r($this->errors);
@@ -597,24 +597,24 @@  discard block
 block discarded – undo
597 597
 	function deleteFileAndThumbs($dirPath, $originalImageName, $arrayThumbnailSuffix)
598 598
 	{
599 599
 		//ensure the directory path ending with /
600
-		if ($dirPath != ''  && substr($dirPath, -1) != '/') {
600
+		if ($dirPath != '' && substr($dirPath, -1) != '/') {
601 601
 			$dirPath .= '/';
602 602
 		}			
603
-		if(!empty($originalImageName) && file_exists($dirPath . $originalImageName) && is_file($dirPath . $originalImageName))
603
+		if (!empty($originalImageName) && file_exists($dirPath.$originalImageName) && is_file($dirPath.$originalImageName))
604 604
 		{
605
-			@unlink($dirPath . $originalImageName);
606
-			foreach($arrayThumbnailSuffix as $v)
605
+			@unlink($dirPath.$originalImageName);
606
+			foreach ($arrayThumbnailSuffix as $v)
607 607
 			{
608 608
 				$dotIndex = strrpos($originalImageName, '.');
609 609
 				//begin to get the thumbnail image name
610 610
 				$fileExtension = '';
611 611
 				$fileBaseName = '';
612
-				if(is_int($dotIndex))
612
+				if (is_int($dotIndex))
613 613
 				{
614 614
 					$fileExtension = substr($originalImageName, $dotIndex);
615 615
 					$fileBaseName = substr($originalImageName, 0, $dotIndex);
616 616
 				}
617
-				@unlink($dirPath . $fileBaseName . $v . $fileExtension);			
617
+				@unlink($dirPath.$fileBaseName.$v.$fileExtension);			
618 618
 			}			
619 619
 		}
620 620
 	
Please login to merge, or discard this patch.
Braces   +15 added lines, -14 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 			$this->fileType = $this->_value['type'];
66 66
 			
67 67
 			return true;
68
-		}else 
68
+		} else 
69 69
 		{
70 70
 			
71 71
 			array_push($this->errors, 'Unable to upload file');
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			{
118 118
 				return true;
119 119
 			}
120
-		}elseif(array_search(strtolower($this->getFileExt()), $this->invalidFileExt) === false)
120
+		} elseif(array_search(strtolower($this->getFileExt()), $this->invalidFileExt) === false)
121 121
 		{
122 122
 			return true;
123 123
 		}
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 		{
139 139
 			$this->deleteUploadedFile();
140 140
 			return true;
141
-		}else 
141
+		} else 
142 142
 		{
143 143
 			return false;
144 144
 		}
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 			{
303 303
 				return true;
304 304
 			}
305
-		}else
305
+		} else
306 306
 		{
307 307
 			if($delete)
308 308
 			{
@@ -334,10 +334,11 @@  discard block
 block discarded – undo
334 334
 			$filePath = $this->dirPath . $this->fileBaseName . $thumb_suffix  . $this->fileExtension;
335 335
 		}
336 336
 		// 0 means keep original size
337
-		if ($this->img_x > $this->img_y)
338
-		$new_y = intval($new_x/$this->img_x*$this->img_y);
339
-		else if ($this->img_y > $this->img_x)
340
-		$new_x = intval($new_y/$this->img_y*$this->img_x);
337
+		if ($this->img_x > $this->img_y) {
338
+				$new_y = intval($new_x/$this->img_x*$this->img_y);
339
+		} else if ($this->img_y > $this->img_x) {
340
+				$new_x = intval($new_y/$this->img_y*$this->img_x);
341
+		}
341 342
 		// Now do the library specific resizing.
342 343
 		return $this->_resize($filePath,$new_x, $new_y);
343 344
 	} // End resize
@@ -357,7 +358,7 @@  discard block
 block discarded – undo
357 358
 		if(function_exists($functionName))
358 359
 		{
359 360
 			$this->imgHandler = $functionName($this->filePath);
360
-		}else
361
+		} else
361 362
 		{
362 363
 			array_push($this->errors, $functionName . " function is unavailable");
363 364
 			return false;
@@ -376,7 +377,7 @@  discard block
 block discarded – undo
376 377
 		if($this->_imageSave($new_img, $fileName, 80))
377 378
 		{
378 379
 			return array("width"=>$new_x, "height"=>$new_y, "name"=>basename($fileName));
379
-		}else
380
+		} else
380 381
 		{
381 382
 
382 383
 			array_push($this->errors, "Unable to resize the image");
@@ -399,7 +400,7 @@  discard block
 block discarded – undo
399 400
 		{
400 401
 			imagedestroy($newImageHandler);
401 402
 			return true;
402
-		}else
403
+		} else
403 404
 		{
404 405
 			imagedestroy($newImageHandler);
405 406
 			array_push($this->errors, "Unable to save the thumbnail file.");
@@ -487,14 +488,14 @@  discard block
 block discarded – undo
487 488
 			{
488 489
 				$thumbnailWidth =$originaleImageWidth;
489 490
 				$thumbnailHeight = $originalImageHeight;
490
-			}elseif($thumbnailWidth < 1)
491
+			} elseif($thumbnailWidth < 1)
491 492
 			{
492 493
 				$thumbnailWidth = floor($thumbnailHeight / $originalImageHeight * $originaleImageWidth);
493 494
 
494
-			}elseif($thumbnailHeight < 1)
495
+			} elseif($thumbnailHeight < 1)
495 496
 			{
496 497
 				$thumbnailHeight = floor($thumbnailWidth / $originaleImageWidth * $originalImageHeight);
497
-			}else
498
+			} else
498 499
 			{
499 500
 				$scale = min($thumbnailWidth/$originaleImageWidth, $thumbnailHeight/$originalImageHeight);
500 501
 				$thumbnailWidth = floor($scale*$originaleImageWidth);
Please login to merge, or discard this patch.
phpmyfaq/admin/editor/plugins/ajaxfilemanager/inc/function.base.php 4 patches
Doc Comments   +23 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,6 +17,12 @@  discard block
 block discarded – undo
17 17
  */
18 18
 if (!function_exists("stripos")) 
19 19
 {
20
+  /**
21
+   * @param string $str
22
+   * @param string $needle
23
+   *
24
+   * @return string
25
+   */
20 26
   function stripos($str,$needle,$offset=0)
21 27
   {
22 28
       return @strpos(strtolower($str),strtolower($needle),$offset);
@@ -420,6 +426,9 @@  discard block
 block discarded – undo
420 426
 		}
421 427
 	}
422 428
 
429
+/**
430
+ * @param string $path
431
+ */
423 432
 function myRealPath($path) {
424 433
 
425 434
 		if(strpos($path, ':/') !== false)
@@ -567,7 +576,7 @@  discard block
 block discarded – undo
567 576
 /**
568 577
  * get site root path
569 578
  *
570
- * @return String.
579
+ * @return string
571 580
  */
572 581
 function getRootPath() {
573 582
 		$output = '';
@@ -620,7 +629,8 @@  discard block
 block discarded – undo
620 629
 	/**
621 630
 	 * get a file extension
622 631
 	 *
623
-	 * @param string $fileName the path to a file or just the file name
632
+	 * @param string $filePath
633
+	 * @return string
624 634
 	 */	
625 635
 	function getFileExt($filePath)
626 636
 	{
@@ -789,7 +799,7 @@  discard block
 block discarded – undo
789 799
      *
790 800
      * @param string $pattern regular expression, separated by , if multiple
791 801
      * @param string $string
792
-     * @return booolean
802
+     * @return boolean
793 803
      */
794 804
         function isValidPattern( $pattern, $string)
795 805
         {
@@ -822,7 +832,7 @@  discard block
 block discarded – undo
822 832
      *
823 833
      * @param string $pattern regular expression, separated by , if multiple
824 834
      * @param string $string
825
-     * @return booolean
835
+     * @return boolean
826 836
      */
827 837
         function isInvalidPattern( $pattern, $string)
828 838
         {
@@ -866,6 +876,10 @@  discard block
 block discarded – undo
866 876
 		}
867 877
 		if (!function_exists('mime_content_type')) 
868 878
 		{
879
+
880
+		   /**
881
+		    * @param string $f
882
+		    */
869 883
 		   function mime_content_type ( $f )
870 884
 		   {
871 885
 		       return trim ( @exec ('file -bi ' . escapeshellarg ( $f ) ) ) ;
@@ -1139,6 +1153,11 @@  discard block
 block discarded – undo
1139 1153
   
1140 1154
        if(!function_exists("imagerotate"))
1141 1155
         {
1156
+
1157
+            /**
1158
+             * @param resource|null $src_img
1159
+             * @param integer $angle
1160
+             */
1142 1161
             function imagerotate($src_img, $angle, $bicubic=false)
1143 1162
             {
1144 1163
     // convert degrees to radians
Please login to merge, or discard this patch.
Indentation   +815 added lines, -815 removed lines patch added patch discarded remove patch
@@ -1,52 +1,52 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
3
-	{
4
-		die('Permission denied');
5
-	}
2
+    if(!defined('AJAX_INIT_DONE'))
3
+    {
4
+        die('Permission denied');
5
+    }
6 6
 ?><?php
7
-	/**
8
-	 * function avaialble to the file manager
9
-	 * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
10
-	 * @link www.phpletter.com
11
-	 * @since 22/April/2007
12
-	 *
13
-	 */
7
+    /**
8
+     * function avaialble to the file manager
9
+     * @author Logan Cai (cailongqun [at] yahoo [dot] com [dot] cn)
10
+     * @link www.phpletter.com
11
+     * @since 22/April/2007
12
+     *
13
+     */
14 14
 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "config.php");
15 15
 /**
16
- * force to ensure existence of stripos
17
- */
16
+     * force to ensure existence of stripos
17
+     */
18 18
 if (!function_exists("stripos")) 
19 19
 {
20
-  function stripos($str,$needle,$offset=0)
21
-  {
22
-      return @strpos(strtolower($str),strtolower($needle),$offset);
23
-  }
20
+    function stripos($str,$needle,$offset=0)
21
+    {
22
+        return @strpos(strtolower($str),strtolower($needle),$offset);
23
+    }
24 24
 }
25
-	/**
26
-	 * get the current Url but not the query string specified in $excls
27
-	 *
28
-	 * @param array $excls specify those unwanted query string
29
-	 * @return string
30
-	 */
31
-	function getCurrentUrl($excls=array())
32
-	{
33
-		$output = $_SERVER['PHP_SELF'];
34
-		$count = 1;
35
-		foreach($_GET as $k=>$v)
36
-		{
37
-			if(array_search($k, $excls) ===false)
38
-			{
39
-				$strAppend = "&";
40
-				if($count == 1)
41
-				{
42
-					$strAppend = "?";
43
-					$count++;
44
-				}
45
-				$output .= $strAppend . urlencode($k) . "=" . urlencode($v);
46
-			}
47
-		}
48
-		return $output;
49
-	}
25
+    /**
26
+     * get the current Url but not the query string specified in $excls
27
+     *
28
+     * @param array $excls specify those unwanted query string
29
+     * @return string
30
+     */
31
+    function getCurrentUrl($excls=array())
32
+    {
33
+        $output = $_SERVER['PHP_SELF'];
34
+        $count = 1;
35
+        foreach($_GET as $k=>$v)
36
+        {
37
+            if(array_search($k, $excls) ===false)
38
+            {
39
+                $strAppend = "&";
40
+                if($count == 1)
41
+                {
42
+                    $strAppend = "?";
43
+                    $count++;
44
+                }
45
+                $output .= $strAppend . urlencode($k) . "=" . urlencode($v);
46
+            }
47
+        }
48
+        return $output;
49
+    }
50 50
 
51 51
 /**
52 52
  * print out an array
@@ -55,71 +55,71 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function displayArray($array, $comments='')
57 57
 {
58
-	echo "<pre>";
59
-	echo $comments;
60
-	print_r($array);
61
-	echo $comments;
62
-	echo "</pre>";
58
+    echo "<pre>";
59
+    echo $comments;
60
+    print_r($array);
61
+    echo $comments;
62
+    echo "</pre>";
63 63
 }
64 64
 
65 65
 
66 66
 
67
-	/**
68
-	 * check if a file extension is permitted
69
-	 *
70
-	 * @param string $filePath
71
-	 * @param array $validExts
72
-	 * @param array $invalidExts
73
-	 * @return boolean
74
-	 */
75
-	function isValidExt($filePath, $validExts, $invalidExts=array())
76
-	{
77
-		$tem = array();
67
+    /**
68
+     * check if a file extension is permitted
69
+     *
70
+     * @param string $filePath
71
+     * @param array $validExts
72
+     * @param array $invalidExts
73
+     * @return boolean
74
+     */
75
+    function isValidExt($filePath, $validExts, $invalidExts=array())
76
+    {
77
+        $tem = array();
78 78
 
79
-		if(sizeof($validExts))
80
-		{
81
-			foreach($validExts as $k=>$v)
82
-			{
83
-				$tem[$k] = strtolower(trim($v));
84
-			}
85
-		}
86
-		$validExts = $tem;
87
-		$tem = array();
88
-		if(sizeof($invalidExts))
89
-		{
90
-			foreach($invalidExts as $k=>$v)
91
-			{
92
-				$tem[$k] = strtolower(trim($v));
93
-			}
94
-		}
95
-		$invalidExts = $tem;
96
-		if(sizeof($validExts) && sizeof($invalidExts))
97
-		{
98
-			foreach($validExts as  $k=>$ext)
99
-			{
100
-				if(array_search($ext, $invalidExts) !== false)
101
-				{
102
-					unset($validExts[$k]);
103
-				}
104
-			}
105
-		}
106
-		if(sizeof($validExts))
107
-		{
108
-			if(array_search(strtolower(getFileExt($filePath)), $validExts) !== false)
109
-			{
110
-				return true;
111
-			}else 
112
-			{
113
-				return false;
114
-			}
115
-		}elseif(array_search(strtolower(getFileExt($filePath)), $invalidExts) === false)
116
-		{
117
-			return true;
118
-		}else 
119
-		{
120
-			return false;
121
-		}
122
-	}
79
+        if(sizeof($validExts))
80
+        {
81
+            foreach($validExts as $k=>$v)
82
+            {
83
+                $tem[$k] = strtolower(trim($v));
84
+            }
85
+        }
86
+        $validExts = $tem;
87
+        $tem = array();
88
+        if(sizeof($invalidExts))
89
+        {
90
+            foreach($invalidExts as $k=>$v)
91
+            {
92
+                $tem[$k] = strtolower(trim($v));
93
+            }
94
+        }
95
+        $invalidExts = $tem;
96
+        if(sizeof($validExts) && sizeof($invalidExts))
97
+        {
98
+            foreach($validExts as  $k=>$ext)
99
+            {
100
+                if(array_search($ext, $invalidExts) !== false)
101
+                {
102
+                    unset($validExts[$k]);
103
+                }
104
+            }
105
+        }
106
+        if(sizeof($validExts))
107
+        {
108
+            if(array_search(strtolower(getFileExt($filePath)), $validExts) !== false)
109
+            {
110
+                return true;
111
+            }else 
112
+            {
113
+                return false;
114
+            }
115
+        }elseif(array_search(strtolower(getFileExt($filePath)), $invalidExts) === false)
116
+        {
117
+            return true;
118
+        }else 
119
+        {
120
+            return false;
121
+        }
122
+    }
123 123
 
124 124
 
125 125
 
@@ -132,31 +132,31 @@  discard block
 block discarded – undo
132 132
  */
133 133
 function relToAbs($value) 
134 134
 {
135
-	return backslashToSlash(preg_replace("/(\\\\)/","\\", getRealPath($value)));
135
+    return backslashToSlash(preg_replace("/(\\\\)/","\\", getRealPath($value)));
136 136
 
137 137
 }
138 138
 
139
-	function getRelativeFileUrl($value, $relativeTo)
140
-	{
141
-		$output = '';
142
-		$wwwroot = removeTrailingSlash(backslashToSlash(getRootPath()));
143
-		$urlprefix = '';
144
-		$urlsuffix = '';
145
-		$value = backslashToSlash(getRealPath($value));
146
-		$pos = strpos($value, $wwwroot);
147
-		if ($pos !== false && $pos == 0)
148
-		{
149
-			$output  = $urlprefix . substr($value, strlen($wwwroot)) . $urlsuffix;
150
-		}
151
-	}
139
+    function getRelativeFileUrl($value, $relativeTo)
140
+    {
141
+        $output = '';
142
+        $wwwroot = removeTrailingSlash(backslashToSlash(getRootPath()));
143
+        $urlprefix = '';
144
+        $urlsuffix = '';
145
+        $value = backslashToSlash(getRealPath($value));
146
+        $pos = strpos($value, $wwwroot);
147
+        if ($pos !== false && $pos == 0)
148
+        {
149
+            $output  = $urlprefix . substr($value, strlen($wwwroot)) . $urlsuffix;
150
+        }
151
+    }
152 152
 /**
153
- * replace slash with backslash
154
- *
155
- * @param string $value the path to the file
156
- * @return string
157
- */
153
+     * replace slash with backslash
154
+     *
155
+     * @param string $value the path to the file
156
+     * @return string
157
+     */
158 158
 function slashToBackslash($value) {
159
-	return str_replace("/", DIRECTORY_SEPARATOR, $value);
159
+    return str_replace("/", DIRECTORY_SEPARATOR, $value);
160 160
 }
161 161
 
162 162
 /**
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
  * @return string
167 167
  */
168 168
 function backslashToSlash($value) {
169
-	return str_replace(DIRECTORY_SEPARATOR, "/", $value);
169
+    return str_replace(DIRECTORY_SEPARATOR, "/", $value);
170 170
 }
171 171
 
172 172
 /**
@@ -176,11 +176,11 @@  discard block
 block discarded – undo
176 176
  * @return string
177 177
  */
178 178
 function removeTrailingSlash($value) {
179
-	if(preg_match('@^.+/$@i', $value))
180
-	{
181
-		$value = substr($value, 0, strlen($value)-1);
182
-	}
183
-	return $value;
179
+    if(preg_match('@^.+/$@i', $value))
180
+    {
181
+        $value = substr($value, 0, strlen($value)-1);
182
+    }
183
+    return $value;
184 184
 }
185 185
 
186 186
 /**
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
  */
192 192
 function addTrailingSlash($value) 
193 193
 {
194
-	if(preg_match('@^.*[^/]{1}$@i', $value))
195
-	{
196
-		$value .= '/';
197
-	}
198
-	return $value;
194
+    if(preg_match('@^.*[^/]{1}$@i', $value))
195
+    {
196
+        $value .= '/';
197
+    }
198
+    return $value;
199 199
 }
200 200
 
201 201
 /**
@@ -205,33 +205,33 @@  discard block
 block discarded – undo
205 205
  * @return string
206 206
  */
207 207
 function transformFilePath($value) {
208
-	$rootPath = addTrailingSlash(backslashToSlash(getRealPath(CONFIG_SYS_ROOT_PATH)));
209
-	$value = addTrailingSlash(backslashToSlash(getRealPath($value)));
210
-	if(!empty($rootPath) && ($i = strpos($value, $rootPath)) !== false)
211
-	{
212
-		$value = ($i == 0?substr($value, strlen($rootPath)):"/");		
213
-	}
214
-	$value = prependSlash($value);
215
-	return $value;
208
+    $rootPath = addTrailingSlash(backslashToSlash(getRealPath(CONFIG_SYS_ROOT_PATH)));
209
+    $value = addTrailingSlash(backslashToSlash(getRealPath($value)));
210
+    if(!empty($rootPath) && ($i = strpos($value, $rootPath)) !== false)
211
+    {
212
+        $value = ($i == 0?substr($value, strlen($rootPath)):"/");		
213
+    }
214
+    $value = prependSlash($value);
215
+    return $value;
216 216
 }
217 217
 /**
218
- * prepend slash 
219
- *
220
- * @param string $value
221
- * @return string
222
- */
218
+     * prepend slash 
219
+     *
220
+     * @param string $value
221
+     * @return string
222
+     */
223 223
 function prependSlash($value)
224 224
 {
225
-		if (($value && $value[0] != '/') || !$value )
226
-		{
227
-			$value = "/" . $value;
228
-		}			
229
-		return $value;	
225
+        if (($value && $value[0] != '/') || !$value )
226
+        {
227
+            $value = "/" . $value;
228
+        }			
229
+        return $value;	
230 230
 }
231 231
 
232 232
 
233
-	function writeInfo($data, $die = false)
234
-	{
233
+    function writeInfo($data, $die = false)
234
+    {
235 235
 		
236 236
 /*		$fp = @fopen(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'data.php', 'w+');
237 237
 		$data  = '<?php
@@ -245,187 +245,187 @@  discard block
 block discarded – undo
245 245
 			die();
246 246
 		}*/
247 247
 		
248
-	}
248
+    }
249 249
 
250 250
 /**
251 251
  * no cachable header
252 252
  */
253 253
 function addNoCacheHeaders() {
254
-	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
255
-	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
256
-	header("Cache-Control: no-store, no-cache, must-revalidate");
257
-	header("Cache-Control: post-check=0, pre-check=0", false);
258
-	header("Pragma: no-cache");
254
+    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
255
+    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
256
+    header("Cache-Control: no-store, no-cache, must-revalidate");
257
+    header("Cache-Control: post-check=0, pre-check=0", false);
258
+    header("Pragma: no-cache");
259 259
 }
260
-	/**
261
-	 * add extra query stiring to a url
262
-	 * @param string $baseUrl
263
-	 * @param string $extra the query string added to the base url
264
-	 */
265
-	function appendQueryString($baseUrl, $extra)
266
-	{
267
-		$output = $baseUrl;
268
-		if(!empty($extra))
269
-		{
270
-			if(strpos($baseUrl, "?") !== false)
271
-			{
272
-				$output .= "&" . $extra;
273
-			}else
274
-			{
275
-				$output .= "?" . $extra;
276
-			}			
277
-		}
260
+    /**
261
+     * add extra query stiring to a url
262
+     * @param string $baseUrl
263
+     * @param string $extra the query string added to the base url
264
+     */
265
+    function appendQueryString($baseUrl, $extra)
266
+    {
267
+        $output = $baseUrl;
268
+        if(!empty($extra))
269
+        {
270
+            if(strpos($baseUrl, "?") !== false)
271
+            {
272
+                $output .= "&" . $extra;
273
+            }else
274
+            {
275
+                $output .= "?" . $extra;
276
+            }			
277
+        }
278 278
 
279
-		return $output;
280
-	}
281
-	/**
282
-	 * make the query strin from $_GET, but excluding those specified by $excluded
283
-	 *
284
-	 * @param array $excluded
285
-	 * @return string
286
-	 */
287
-	function makeQueryString($excluded=array())
288
-	{
289
-		$output = '';
290
-		$count = 1;
291
-		foreach($_GET as $k=>$v)
292
-		{
293
-			if(array_search($k, $excluded) === false)
294
-			{
295
-				$output .= ($count>1?'&':'') . (urlencode($k) . "=" . urlencode($v));
296
-				$count++;
297
-			}
298
-		}
299
-		return $output;
300
-	}
301
-	/**
302
-	 * get parent path from specific path
303
-	 *
304
-	 * @param string $value
305
-	 * @return string
306
-	 */
307
-	function getParentPath($value)
308
-	{
309
-		$value = removeTrailingSlash(backslashToSlash($value));
310
-		if(false !== ($index = strrpos($value, "/")) )
311
-		{
312
-			return substr($value, 0, $index);
313
-		}
279
+        return $output;
280
+    }
281
+    /**
282
+     * make the query strin from $_GET, but excluding those specified by $excluded
283
+     *
284
+     * @param array $excluded
285
+     * @return string
286
+     */
287
+    function makeQueryString($excluded=array())
288
+    {
289
+        $output = '';
290
+        $count = 1;
291
+        foreach($_GET as $k=>$v)
292
+        {
293
+            if(array_search($k, $excluded) === false)
294
+            {
295
+                $output .= ($count>1?'&':'') . (urlencode($k) . "=" . urlencode($v));
296
+                $count++;
297
+            }
298
+        }
299
+        return $output;
300
+    }
301
+    /**
302
+     * get parent path from specific path
303
+     *
304
+     * @param string $value
305
+     * @return string
306
+     */
307
+    function getParentPath($value)
308
+    {
309
+        $value = removeTrailingSlash(backslashToSlash($value));
310
+        if(false !== ($index = strrpos($value, "/")) )
311
+        {
312
+            return substr($value, 0, $index);
313
+        }
314 314
 
315
-	}
315
+    }
316 316
 
317 317
 
318
-	/**
319
-	 * check if the file/folder is sit under the root
320
-	 *
321
-	 * @param string $value
322
-	 * @return  boolean
323
-	 */
324
-	function isUnderRoot($value)
325
-	{
326
-		$roorPath = strtolower(addTrailingSlash(backslashToSlash(getRealPath(CONFIG_SYS_ROOT_PATH))));
327
-		if(file_exists($value) && @strpos(strtolower(addTrailingSlash(backslashToSlash(getRealPath($value)))), $roorPath) === 0 )
328
-		{
329
-			return true;
330
-		}
331
-		return false;
332
-	}
333
-	/**
334
-	 * check if a file under the session folder
335
-	 *
336
-	 * @param string $value
337
-	 * @return boolean
338
-	 */
339
-	function isUnderSession($value)
340
-	{
341
-		global $session;
342
-		$sessionPath = strtolower(addTrailingSlash(backslashToSlash(getRealPath($session->getSessionDir()))));
343
-		if(file_exists($value) && @strpos(strtolower(addTrailingSlash(backslashToSlash(getRealPath($value)))), $sessionPath) === 0 )
344
-		{
345
-			return true;
346
-		}
347
-		return false;		
348
-	}
318
+    /**
319
+     * check if the file/folder is sit under the root
320
+     *
321
+     * @param string $value
322
+     * @return  boolean
323
+     */
324
+    function isUnderRoot($value)
325
+    {
326
+        $roorPath = strtolower(addTrailingSlash(backslashToSlash(getRealPath(CONFIG_SYS_ROOT_PATH))));
327
+        if(file_exists($value) && @strpos(strtolower(addTrailingSlash(backslashToSlash(getRealPath($value)))), $roorPath) === 0 )
328
+        {
329
+            return true;
330
+        }
331
+        return false;
332
+    }
333
+    /**
334
+     * check if a file under the session folder
335
+     *
336
+     * @param string $value
337
+     * @return boolean
338
+     */
339
+    function isUnderSession($value)
340
+    {
341
+        global $session;
342
+        $sessionPath = strtolower(addTrailingSlash(backslashToSlash(getRealPath($session->getSessionDir()))));
343
+        if(file_exists($value) && @strpos(strtolower(addTrailingSlash(backslashToSlash(getRealPath($value)))), $sessionPath) === 0 )
344
+        {
345
+            return true;
346
+        }
347
+        return false;		
348
+    }
349 349
 	
350 350
 	
351
-	/**
352
-	 * get thumbnail width and height
353
-	 *
354
-	 * @param integer $originaleImageWidth
355
-	 * @param integer $originalImageHeight
356
-	 * @param integer $thumbnailWidth
357
-	 * @param integer $thumbnailHeight
358
-	 * @return array()
359
-	 */
360
-	function getThumbWidthHeight( $originaleImageWidth, $originalImageHeight, $thumbnailWidth, $thumbnailHeight)
361
-	{
362
-		$outputs = array( "width"=>0, "height"=>0);
363
-		$thumbnailWidth	= intval($thumbnailWidth);
364
-		$thumbnailHeight = intval($thumbnailHeight);
365
-		if(!empty($originaleImageWidth) && !empty($originalImageHeight))
366
-		{
367
-			//start to get the thumbnail width & height
368
-        	if(($thumbnailWidth < 1 && $thumbnailHeight < 1) || ($thumbnailWidth > $originaleImageWidth && $thumbnailHeight > $originalImageHeight ))
369
-        	{
370
-        		$thumbnailWidth =$originaleImageWidth;
371
-        		$thumbnailHeight = $originalImageHeight;
372
-        	}elseif($thumbnailWidth < 1)
373
-        	{
374
-        		$thumbnailWidth = floor($thumbnailHeight / $originalImageHeight * $originaleImageWidth);
351
+    /**
352
+     * get thumbnail width and height
353
+     *
354
+     * @param integer $originaleImageWidth
355
+     * @param integer $originalImageHeight
356
+     * @param integer $thumbnailWidth
357
+     * @param integer $thumbnailHeight
358
+     * @return array()
359
+     */
360
+    function getThumbWidthHeight( $originaleImageWidth, $originalImageHeight, $thumbnailWidth, $thumbnailHeight)
361
+    {
362
+        $outputs = array( "width"=>0, "height"=>0);
363
+        $thumbnailWidth	= intval($thumbnailWidth);
364
+        $thumbnailHeight = intval($thumbnailHeight);
365
+        if(!empty($originaleImageWidth) && !empty($originalImageHeight))
366
+        {
367
+            //start to get the thumbnail width & height
368
+            if(($thumbnailWidth < 1 && $thumbnailHeight < 1) || ($thumbnailWidth > $originaleImageWidth && $thumbnailHeight > $originalImageHeight ))
369
+            {
370
+                $thumbnailWidth =$originaleImageWidth;
371
+                $thumbnailHeight = $originalImageHeight;
372
+            }elseif($thumbnailWidth < 1)
373
+            {
374
+                $thumbnailWidth = floor($thumbnailHeight / $originalImageHeight * $originaleImageWidth);
375 375
 
376
-        	}elseif($thumbnailHeight < 1)
377
-        	{
378
-        		$thumbnailHeight = floor($thumbnailWidth / $originaleImageWidth * $originalImageHeight);
379
-        	}else
380
-        	{
381
-        		$scale = min($thumbnailWidth/$originaleImageWidth, $thumbnailHeight/$originalImageHeight);
382
-				$thumbnailWidth = floor($scale*$originaleImageWidth);
383
-				$thumbnailHeight = floor($scale*$originalImageHeight);
384
-        	}
385
-			$outputs['width'] = $thumbnailWidth;
386
-			$outputs['height'] = $thumbnailHeight;
387
-		}
388
-		return $outputs;
376
+            }elseif($thumbnailHeight < 1)
377
+            {
378
+                $thumbnailHeight = floor($thumbnailWidth / $originaleImageWidth * $originalImageHeight);
379
+            }else
380
+            {
381
+                $scale = min($thumbnailWidth/$originaleImageWidth, $thumbnailHeight/$originalImageHeight);
382
+                $thumbnailWidth = floor($scale*$originaleImageWidth);
383
+                $thumbnailHeight = floor($scale*$originalImageHeight);
384
+            }
385
+            $outputs['width'] = $thumbnailWidth;
386
+            $outputs['height'] = $thumbnailHeight;
387
+        }
388
+        return $outputs;
389 389
 
390
-	}
390
+    }
391 391
 /**
392
- * turn to absolute path from relative path
393
- *
394
- * @param string $value
395
- * @return string
396
- */
392
+     * turn to absolute path from relative path
393
+     *
394
+     * @param string $value
395
+     * @return string
396
+     */
397 397
 function getAbsPath($value) {
398
-	if (substr($value, 0, 1) == "/")
399
-		return slashToBackslash(DIR_AJAX_ROOT . $value);
398
+    if (substr($value, 0, 1) == "/")
399
+        return slashToBackslash(DIR_AJAX_ROOT . $value);
400 400
 
401
-	return slashToBackslash(dirname(__FILE__) . "/" . $value);
401
+    return slashToBackslash(dirname(__FILE__) . "/" . $value);
402 402
 }
403 403
 
404
-	/**
405
-	 * get file/folder base name
406
-	 *
407
-	 * @param string $value
408
-	 * @return string
409
-	 */
410
-	function getBaseName($value)
411
-	{
412
-		$value = removeTrailingSlash(backslashToSlash($value));
404
+    /**
405
+     * get file/folder base name
406
+     *
407
+     * @param string $value
408
+     * @return string
409
+     */
410
+    function getBaseName($value)
411
+    {
412
+        $value = removeTrailingSlash(backslashToSlash($value));
413 413
 
414
-		if(false !== ($index = strrpos($value, "/")) )
415
-		{
416
-			return substr($value, $index + 1);
417
-		}else
418
-		{
419
-			return $value;
420
-		}
421
-	}
414
+        if(false !== ($index = strrpos($value, "/")) )
415
+        {
416
+            return substr($value, $index + 1);
417
+        }else
418
+        {
419
+            return $value;
420
+        }
421
+    }
422 422
 
423 423
 function myRealPath($path) {
424 424
 
425
-		if(strpos($path, ':/') !== false)
426
-		{
427
-			return $path;
428
-		}
425
+        if(strpos($path, ':/') !== false)
426
+        {
427
+            return $path;
428
+        }
429 429
     // check if path begins with "/" ie. is absolute
430 430
     // if it isnt concat with script path
431 431
     
@@ -439,9 +439,9 @@  discard block
 block discarded – undo
439 439
     $newpath=array();
440 440
     for ($i=0; $i<sizeof($path); $i++) {
441 441
         if ($path[$i]==='' || $path[$i]==='.') continue;
442
-           if ($path[$i]==='..') {
443
-              array_pop($newpath);
444
-              continue;
442
+            if ($path[$i]==='..') {
443
+                array_pop($newpath);
444
+                continue;
445 445
         }
446 446
         array_push($newpath, $path[$i]);
447 447
     }
@@ -454,49 +454,49 @@  discard block
 block discarded – undo
454 454
     }
455 455
     else return FALSE;
456 456
 }
457
-	/**
458
-	 * calcuate realpath for a relative path
459
-	 *
460
-	 * @param string $value a relative path
461
-	 * @return string absolute path of the input
462
-	 */
463
- function getRealPath($value)
464
- {
465
- 		$output = '';
466
- 	 if(($path = realpath($value)) && $path != $value)
467
- 	 {
468
- 	 	$output = $path;
469
- 	 }else 
470
- 	 {
471
- 	 	$output = myRealPath($value);
472
- 	 }
473
- 	 return $output;
457
+    /**
458
+     * calcuate realpath for a relative path
459
+     *
460
+     * @param string $value a relative path
461
+     * @return string absolute path of the input
462
+     */
463
+    function getRealPath($value)
464
+    {
465
+            $output = '';
466
+        if(($path = realpath($value)) && $path != $value)
467
+        {
468
+            $output = $path;
469
+        }else 
470
+        {
471
+            $output = myRealPath($value);
472
+        }
473
+        return $output;
474 474
  	
475
- }
476
-	/**
477
-	 * get file url
478
-	 *
479
-	 * @param string $value
480
-	 * @return string
481
-	 */
482
-	function getFileUrl($value)
483
-	{
484
-		$wwwroot = removeTrailingSlash(backslashToSlash(getRootPath()));
475
+    }
476
+    /**
477
+     * get file url
478
+     *
479
+     * @param string $value
480
+     * @return string
481
+     */
482
+    function getFileUrl($value)
483
+    {
484
+        $wwwroot = removeTrailingSlash(backslashToSlash(getRootPath()));
485 485
 
486
-		$urlprefix = '';
487
-		$urlsuffix = '';
486
+        $urlprefix = '';
487
+        $urlsuffix = '';
488 488
 
489
-		$value = backslashToSlash(getRealPath($value));
489
+        $value = backslashToSlash(getRealPath($value));
490 490
 
491
-		$pos = stripos($value, $wwwroot);
492
-		if ($pos !== false )
493
-		{
494
-			$output  = $urlprefix . substr($value, $pos + strlen($wwwroot)) . $urlsuffix;
495
-		}else 
496
-		{
497
-			$output = $value;
498
-		}
499
-		$protocol = (isset($_SERVER["HTTPS"]) &&  $_SERVER["HTTPS"] == 'on' ? 'https' : 'http');
491
+        $pos = stripos($value, $wwwroot);
492
+        if ($pos !== false )
493
+        {
494
+            $output  = $urlprefix . substr($value, $pos + strlen($wwwroot)) . $urlsuffix;
495
+        }else 
496
+        {
497
+            $output = $value;
498
+        }
499
+        $protocol = (isset($_SERVER["HTTPS"]) &&  $_SERVER["HTTPS"] == 'on' ? 'https' : 'http');
500 500
 
501 501
         // Pick up URL up to /admin and exclude /admin  . This is the phpMyFAQ directory
502 502
         $pmfBase = strrev(
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 
524 524
         return $pmfBase . $pmfRest ;
525 525
 
526
-	}
526
+    }
527 527
 	
528 528
 /**
529 529
  * 
@@ -533,36 +533,36 @@  discard block
 block discarded – undo
533 533
  */
534 534
 function transformFileSize($size) {
535 535
 
536
-	if ($size > 1048576)
537
-	{
538
-		return round($size / 1048576, 1) . " MB";
539
-	}elseif ($size > 1024)
540
-	{
541
-		return round($size / 1024, 1) . " KB";
542
-	}elseif($size == '')
543
-	{
544
-		return $size;
545
-	}else
546
-	{
547
-		return $size . " b";
548
-	}	
536
+    if ($size > 1048576)
537
+    {
538
+        return round($size / 1048576, 1) . " MB";
539
+    }elseif ($size > 1024)
540
+    {
541
+        return round($size / 1024, 1) . " KB";
542
+    }elseif($size == '')
543
+    {
544
+        return $size;
545
+    }else
546
+    {
547
+        return $size . " b";
548
+    }	
549 549
 }
550 550
 	
551
-	/**
552
-	 * remove beginging slash
553
-	 *
554
-	 * @param string $value
555
-	 * @return string
556
-	 */
557
-	function removeBeginingSlash($value)
558
-	{
559
-		$value = backslashToSlash($value);
560
-		if(strpos($value, "/") === 0)
561
-		{
562
-			$value = substr($value, 1);
563
-		}
564
-		return $value;
565
-	}
551
+    /**
552
+     * remove beginging slash
553
+     *
554
+     * @param string $value
555
+     * @return string
556
+     */
557
+    function removeBeginingSlash($value)
558
+    {
559
+        $value = backslashToSlash($value);
560
+        if(strpos($value, "/") === 0)
561
+        {
562
+            $value = substr($value, 1);
563
+        }
564
+        return $value;
565
+    }
566 566
 	
567 567
 /**
568 568
  * get site root path
@@ -570,220 +570,220 @@  discard block
 block discarded – undo
570 570
  * @return String.
571 571
  */
572 572
 function getRootPath() {
573
-		$output = '';
573
+        $output = '';
574 574
 
575
-		if (defined('CONFIG_WEBSITE_DOCUMENT_ROOT') && CONFIG_WEBSITE_DOCUMENT_ROOT)
576
-		{
575
+        if (defined('CONFIG_WEBSITE_DOCUMENT_ROOT') && CONFIG_WEBSITE_DOCUMENT_ROOT)
576
+        {
577 577
 
578
-			return slashToBackslash(CONFIG_WEBSITE_DOCUMENT_ROOT);
579
-		}
580
-		if(isset($_SERVER['DOCUMENT_ROOT']) && ($output = relToAbs($_SERVER['DOCUMENT_ROOT'])) != '' )
581
-		{
578
+            return slashToBackslash(CONFIG_WEBSITE_DOCUMENT_ROOT);
579
+        }
580
+        if(isset($_SERVER['DOCUMENT_ROOT']) && ($output = relToAbs($_SERVER['DOCUMENT_ROOT'])) != '' )
581
+        {
582 582
 
583
-			return $output;
584
-		}elseif(isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["SCRIPT_FILENAME"]) && ($output = str_replace(backslashToSlash($_SERVER["SCRIPT_NAME"]), '', backslashToSlash($_SERVER["SCRIPT_FILENAME"]))) && is_dir($output))
585
-		{
583
+            return $output;
584
+        }elseif(isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["SCRIPT_FILENAME"]) && ($output = str_replace(backslashToSlash($_SERVER["SCRIPT_NAME"]), '', backslashToSlash($_SERVER["SCRIPT_FILENAME"]))) && is_dir($output))
585
+        {
586 586
 
587
-			return slashToBackslash($output);
588
-		}elseif(isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["PATH_TRANSLATED"]) && ($output = str_replace(backslashToSlash($_SERVER["SCRIPT_NAME"]), '', str_replace("//", "/", backslashToSlash($_SERVER["PATH_TRANSLATED"])))) && is_dir($output))
589
-		{
587
+            return slashToBackslash($output);
588
+        }elseif(isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["PATH_TRANSLATED"]) && ($output = str_replace(backslashToSlash($_SERVER["SCRIPT_NAME"]), '', str_replace("//", "/", backslashToSlash($_SERVER["PATH_TRANSLATED"])))) && is_dir($output))
589
+        {
590 590
 
591
-			return $output;
592
-		}else 
593
-		{
594
-			return '';
595
-		}	
591
+            return $output;
592
+        }else 
593
+        {
594
+            return '';
595
+        }	
596 596
 
597
-	return null;
597
+    return null;
598 598
 }
599 599
 
600 600
 	
601
-	/**
602
-	 * add beginging slash
603
-	 *
604
-	 * @param string $value
605
-	 * @return string
606
-	 */	
607
-	function addBeginingSlash($value)
608
-	{
609
-		if(strpos($value, "/") !== 0 && !empty($value))
610
-		{
611
-			$value .= "/" . $value;
612
-		}
613
-		return $value;		
614
-	}
601
+    /**
602
+     * add beginging slash
603
+     *
604
+     * @param string $value
605
+     * @return string
606
+     */	
607
+    function addBeginingSlash($value)
608
+    {
609
+        if(strpos($value, "/") !== 0 && !empty($value))
610
+        {
611
+            $value .= "/" . $value;
612
+        }
613
+        return $value;		
614
+    }
615 615
 
616 616
 
617 617
 	
618 618
 
619 619
 	
620
-	/**
621
-	 * get a file extension
622
-	 *
623
-	 * @param string $fileName the path to a file or just the file name
624
-	 */	
625
-	function getFileExt($filePath)
626
-	{
627
-		return @substr(@strrchr($filePath, "."), 1);
628
-	}
620
+    /**
621
+     * get a file extension
622
+     *
623
+     * @param string $fileName the path to a file or just the file name
624
+     */	
625
+    function getFileExt($filePath)
626
+    {
627
+        return @substr(@strrchr($filePath, "."), 1);
628
+    }
629 629
 	
630
-		/**
631
-		 * reuturn the relative path between two url
632
-		 *
633
-		 * @param string $start_dir
634
-		 * @param string $final_dir
635
-		 * @return string
636
-		 */
630
+        /**
631
+         * reuturn the relative path between two url
632
+         *
633
+         * @param string $start_dir
634
+         * @param string $final_dir
635
+         * @return string
636
+         */
637 637
     function getRelativePath($start_dir, $final_dir){
638
-      //
639
-      $firstPathParts = explode(DIRECTORY_SEPARATOR, $start_dir);
640
-      $secondPathParts = explode(DIRECTORY_SEPARATOR, $final_dir);
641
-      //
642
-      $sameCounter = 0;
643
-      for($i = 0; $i < min( count($firstPathParts), count($secondPathParts) ); $i++) {
644
-          if( strtolower($firstPathParts[$i]) !== strtolower($secondPathParts[$i]) ) {
645
-              break;
646
-          }
647
-          $sameCounter++;
648
-      }
649
-      if( $sameCounter == 0 ) {
650
-          return $final_dir;
651
-      }
652
-      //
653
-      $newPath = '';
654
-      for($i = $sameCounter; $i < count($firstPathParts); $i++) {
655
-          if( $i > $sameCounter ) {
656
-              $newPath .= DIRECTORY_SEPARATOR;
657
-          }
658
-          $newPath .= "..";
659
-      }
660
-      if( count($newPath) == 0 ) {
661
-          $newPath = ".";
662
-      }
663
-      for($i = $sameCounter; $i < count($secondPathParts); $i++) {
664
-          $newPath .= DIRECTORY_SEPARATOR;
665
-          $newPath .= $secondPathParts[$i];
666
-      }
667
-      //
668
-      return $newPath;
669
-  }
670
-  /**
671
-   * get the php server memory limit
672
-   * @return integer
673
-   *
674
-   */
675
-  function getMemoryLimit()
676
-  {
638
+        //
639
+        $firstPathParts = explode(DIRECTORY_SEPARATOR, $start_dir);
640
+        $secondPathParts = explode(DIRECTORY_SEPARATOR, $final_dir);
641
+        //
642
+        $sameCounter = 0;
643
+        for($i = 0; $i < min( count($firstPathParts), count($secondPathParts) ); $i++) {
644
+            if( strtolower($firstPathParts[$i]) !== strtolower($secondPathParts[$i]) ) {
645
+                break;
646
+            }
647
+            $sameCounter++;
648
+        }
649
+        if( $sameCounter == 0 ) {
650
+            return $final_dir;
651
+        }
652
+        //
653
+        $newPath = '';
654
+        for($i = $sameCounter; $i < count($firstPathParts); $i++) {
655
+            if( $i > $sameCounter ) {
656
+                $newPath .= DIRECTORY_SEPARATOR;
657
+            }
658
+            $newPath .= "..";
659
+        }
660
+        if( count($newPath) == 0 ) {
661
+            $newPath = ".";
662
+        }
663
+        for($i = $sameCounter; $i < count($secondPathParts); $i++) {
664
+            $newPath .= DIRECTORY_SEPARATOR;
665
+            $newPath .= $secondPathParts[$i];
666
+        }
667
+        //
668
+        return $newPath;
669
+    }
670
+    /**
671
+     * get the php server memory limit
672
+     * @return integer
673
+     *
674
+     */
675
+    function getMemoryLimit()
676
+    {
677 677
     $output = @ini_get('memory_limit') or $output = -1 ;
678 678
     if(intval($output) < 0)
679 679
     {//unlimited
680
-    	$output = 999999999999999999;
680
+        $output = 999999999999999999;
681 681
     }
682 682
     elseif(strpos('g', strtolower($output)) !== false)
683 683
     {
684
-    	$output = intval($output) * 1024 * 1024 * 1024;
684
+        $output = intval($output) * 1024 * 1024 * 1024;
685 685
     }elseif(strpos('k', strtolower($output)) !== false)
686 686
     {
687
-    	$output = intval($output) * 1024 ;
687
+        $output = intval($output) * 1024 ;
688 688
     }else
689 689
     {
690
-    	$output = intval($output) * 1024 * 1024;
690
+        $output = intval($output) * 1024 * 1024;
691 691
     }
692 692
     
693 693
     return $output;  	
694
-  }
695
-	/**
696
-	 * get file content
697
-	 *
698
-	 * @param string $path
699
-	 */
700
-  function getFileContent($path)
701
-  {
702
-  	return @file_get_contents($path);
703
-  	//return str_replace(array("\r", "\n", '"', "\t"), array('', "\\n", '\"', "\\t"), @file_get_contents($path));
704
-  }
705
-         /**
706
-          * get the list of folder under a specified folder
707
-          * which will be used for drop-down menu
708
-          * @param string $path the path of the specified folder
709
-          * @param array $outputs
710
-          * @param string $indexNumber
711
-          * @param string $prefixNumber the prefix before the index number
712
-          * @param string $prefixName the prefix before the folder name
713
-          * @return array
714
-          */
715
-         function getFolderListing($path,$indexNumber=null, $prefixNumber =' ', $prefixName =' - ',  $outputs=array())
716
-         {
717
-                   $path = removeTrailingSlash(backslashToSlash($path));
718
-                   if(is_null($indexNumber))
719
-                   {
720
-                   	$outputs[IMG_LBL_ROOT_FOLDER] = removeTrailingSlash(backslashToSlash($path));
721
-                   }
722
-                   $fh = @opendir($path);
723
-                   if($fh)
724
-                   {
694
+    }
695
+    /**
696
+     * get file content
697
+     *
698
+     * @param string $path
699
+     */
700
+    function getFileContent($path)
701
+    {
702
+        return @file_get_contents($path);
703
+        //return str_replace(array("\r", "\n", '"', "\t"), array('', "\\n", '\"', "\\t"), @file_get_contents($path));
704
+    }
705
+            /**
706
+             * get the list of folder under a specified folder
707
+             * which will be used for drop-down menu
708
+             * @param string $path the path of the specified folder
709
+             * @param array $outputs
710
+             * @param string $indexNumber
711
+             * @param string $prefixNumber the prefix before the index number
712
+             * @param string $prefixName the prefix before the folder name
713
+             * @return array
714
+             */
715
+            function getFolderListing($path,$indexNumber=null, $prefixNumber =' ', $prefixName =' - ',  $outputs=array())
716
+            {
717
+                    $path = removeTrailingSlash(backslashToSlash($path));
718
+                    if(is_null($indexNumber))
719
+                    {
720
+                        $outputs[IMG_LBL_ROOT_FOLDER] = removeTrailingSlash(backslashToSlash($path));
721
+                    }
722
+                    $fh = @opendir($path);
723
+                    if($fh)
724
+                    {
725 725
                             $count = 1;                          
726 726
                             while($file = @readdir($fh))
727 727
                             {
728
-                                     $newPath = removeTrailingSlash(backslashToSlash($path . "/" . $file));
729
-                                     if(isListingDocument($newPath) && $file != '.' && $file != '..' && is_dir($newPath))
730
-                                     {                                          
731
-                                               if(!empty($indexNumber))
732
-                                               {//this is not root folder
728
+                                        $newPath = removeTrailingSlash(backslashToSlash($path . "/" . $file));
729
+                                        if(isListingDocument($newPath) && $file != '.' && $file != '..' && is_dir($newPath))
730
+                                        {                                          
731
+                                                if(!empty($indexNumber))
732
+                                                {//this is not root folder
733 733
                                                					
734 734
                                                         $outputs[$prefixNumber . $indexNumber . "." . $count . $prefixName . $file] = $newPath;
735 735
                                                         getFolderListing($newPath,  $prefixNumber . $indexNumber . "." . $count , $prefixNumber, $prefixName, $outputs);                                                 
736
-                                               }else 
737
-                                               {//this is root folder
736
+                                                }else 
737
+                                                {//this is root folder
738 738
 
739 739
                                                         $outputs[$count . $prefixName . $file] = $newPath;
740 740
                                                         getFolderListing($newPath, $count, $prefixNumber, $prefixName, $outputs);
741
-                                               }
742
-                                               $count++;
743
-                                     }                                    
741
+                                                }
742
+                                                $count++;
743
+                                        }                                    
744 744
                             }
745 745
                             @closedir($fh);
746
-                   }
747
-                   return $outputs;
748
-         }
746
+                    }
747
+                    return $outputs;
748
+            }
749 749
 
750 750
          
751
-         /**
752
-          * get the valid text editor extension 
753
-          * which is calcualte from the CONFIG_EDITABALE_VALID_EXTS 
754
-          * exclude those specified in CONFIG_UPLOAD_INVALID_EXTS
755
-          * and those are not specified in CONFIG_UPLOAD_VALID_EXTS
756
-          *
757
-          * @return array
758
-          */
759
-         function getValidTextEditorExts()
760
-         {
761
-         	$validEditorExts = explode(',', CONFIG_EDITABLE_VALID_EXTS);
762
-         	if(CONFIG_UPLOAD_VALID_EXTS)
763
-         	{//exclude those exts not shown on CONFIG_UPLOAD_VALID_EXTS
764
-         		$validUploadExts = explode(',', CONFIG_UPLOAD_VALID_EXTS);
765
-         		foreach($validEditorExts as $k=>$v)
766
-         		{
767
-         			if(array_search($v, $validUploadExts) === false)
768
-         			{
769
-         				unset($validEditorExts[$k]);
770
-         			}
771
-         		}        		
772
-         	}
773
-         	if(CONFIG_UPLOAD_INVALID_EXTS)
774
-         	{//exlcude those exists in CONFIG_UPLOAD_INVALID_EXTS
775
-         		$invalidUploadExts = explode(',', CONFIG_UPLOAD_INVALID_EXTS);
776
-         		foreach($validEditorExts as $k=>$v)
777
-         		{
778
-         			if(array_search($v, $invalidUploadExts) !== false)
779
-         			{
780
-         				unset($validEditorExts[$k]);
781
-         			}
782
-         		}
783
-         	}
784
-         	return $validEditorExts;        	
751
+            /**
752
+             * get the valid text editor extension 
753
+             * which is calcualte from the CONFIG_EDITABALE_VALID_EXTS 
754
+             * exclude those specified in CONFIG_UPLOAD_INVALID_EXTS
755
+             * and those are not specified in CONFIG_UPLOAD_VALID_EXTS
756
+             *
757
+             * @return array
758
+             */
759
+            function getValidTextEditorExts()
760
+            {
761
+                $validEditorExts = explode(',', CONFIG_EDITABLE_VALID_EXTS);
762
+                if(CONFIG_UPLOAD_VALID_EXTS)
763
+                {//exclude those exts not shown on CONFIG_UPLOAD_VALID_EXTS
764
+                    $validUploadExts = explode(',', CONFIG_UPLOAD_VALID_EXTS);
765
+                    foreach($validEditorExts as $k=>$v)
766
+                    {
767
+                        if(array_search($v, $validUploadExts) === false)
768
+                        {
769
+                            unset($validEditorExts[$k]);
770
+                        }
771
+                    }        		
772
+                }
773
+                if(CONFIG_UPLOAD_INVALID_EXTS)
774
+                {//exlcude those exists in CONFIG_UPLOAD_INVALID_EXTS
775
+                    $invalidUploadExts = explode(',', CONFIG_UPLOAD_INVALID_EXTS);
776
+                    foreach($validEditorExts as $k=>$v)
777
+                    {
778
+                        if(array_search($v, $invalidUploadExts) !== false)
779
+                        {
780
+                            unset($validEditorExts[$k]);
781
+                        }
782
+                    }
783
+                }
784
+                return $validEditorExts;        	
785 785
          	
786
-         }
786
+            }
787 787
     /**
788 788
      * check if file name or folder name is valid against a regular expression 
789 789
      *
@@ -850,294 +850,294 @@  discard block
 block discarded – undo
850 850
         }  
851 851
    			
852 852
 
853
-		/**
854
-		 * cut the file down to fit the list page
855
-		 *
856
-		 * @param string $fileName
857
-		 */
858
-		function shortenFileName($fileName, $maxLeng=17, $indicate = '...')
859
-		{
860
-			if(strlen($fileName) > $maxLeng)
861
-			{
862
-				$fileName = substr($fileName, 0, $maxLeng - strlen($indicate)) . $indicate;
863
-			}
864
-			return $fileName;
853
+        /**
854
+         * cut the file down to fit the list page
855
+         *
856
+         * @param string $fileName
857
+         */
858
+        function shortenFileName($fileName, $maxLeng=17, $indicate = '...')
859
+        {
860
+            if(strlen($fileName) > $maxLeng)
861
+            {
862
+                $fileName = substr($fileName, 0, $maxLeng - strlen($indicate)) . $indicate;
863
+            }
864
+            return $fileName;
865 865
 			
866
-		}
867
-		if (!function_exists('mime_content_type')) 
868
-		{
869
-		   function mime_content_type ( $f )
870
-		   {
871
-		       return trim ( @exec ('file -bi ' . escapeshellarg ( $f ) ) ) ;
872
-		   }
873
-		}		
866
+        }
867
+        if (!function_exists('mime_content_type')) 
868
+        {
869
+            function mime_content_type ( $f )
870
+            {
871
+                return trim ( @exec ('file -bi ' . escapeshellarg ( $f ) ) ) ;
872
+            }
873
+        }		
874 874
 		
875
-         /**
876
-          * check if such document is allowed to shown on the list
877
-          *
878
-          * @param string $path the path to the document
879
-          * @return boolean
880
-          */
881
-         function isListingDocument($path)
882
-         {
883
-         	$file = basename($path);
884
-         	if(CONFIG_SYS_PATTERN_FORMAT == 'list')
885
-         	{// comma delimited vague file/folder name
875
+            /**
876
+             * check if such document is allowed to shown on the list
877
+             *
878
+             * @param string $path the path to the document
879
+             * @return boolean
880
+             */
881
+            function isListingDocument($path)
882
+            {
883
+                $file = basename($path);
884
+                if(CONFIG_SYS_PATTERN_FORMAT == 'list')
885
+                {// comma delimited vague file/folder name
886 886
 
887 887
 
888 888
 
889 889
 			    		
890
-      			if(is_dir($path))
891
-      			{
892
- 				$includeDir = trimlrm(CONFIG_SYS_INC_DIR_PATTERN);
893
-				$excludeDir = trimlrm(CONFIG_SYS_EXC_DIR_PATTERN);     				
894
-				$found_includeDir = strpos($includeDir, $file);
895
-				$found_excludeDir = strpos($excludeDir, $file);      				
896
-      				if((!CONFIG_SYS_INC_DIR_PATTERN || (!($found_includeDir === FALSE))) && (!CONFIG_SYS_EXC_DIR_PATTERN || (($found_excludeDir === FALSE))))
897
-      				{
898
-      					return true;
899
-      				}else 
900
-      				{
901
-      					return false;
902
-      				}
903
-      			}elseif(is_file($path))
904
-      			{
905
-				$includeFile = trimlrm(CONFIG_SYS_INC_FILE_PATTERN);
906
-				$excludeFile = trimlrm(CONFIG_SYS_EXC_FILE_PATTERN);            				
907
-				$found_includeFile = strpos($includeFile, $file);
908
-				$found_excludeFile = strpos($excludeFile, $file);	      				
909
-      				if((!CONFIG_SYS_INC_FILE_PATTERN || (!($found_includeFile === FALSE))) && (!CONFIG_SYS_EXC_FILE_PATTERN ||   (($found_excludeFile === FALSE))))
910
-      				{
911
-      					return true;
912
-      				}else 
913
-      				{
914
-      					return false;
915
-      				}
916
-      			}
917
-         	}elseif(CONFIG_SYS_PATTERN_FORMAT == 'csv')
918
-         	{//comma delimited file/folder name
890
+                    if(is_dir($path))
891
+                    {
892
+                    $includeDir = trimlrm(CONFIG_SYS_INC_DIR_PATTERN);
893
+                $excludeDir = trimlrm(CONFIG_SYS_EXC_DIR_PATTERN);     				
894
+                $found_includeDir = strpos($includeDir, $file);
895
+                $found_excludeDir = strpos($excludeDir, $file);      				
896
+                        if((!CONFIG_SYS_INC_DIR_PATTERN || (!($found_includeDir === FALSE))) && (!CONFIG_SYS_EXC_DIR_PATTERN || (($found_excludeDir === FALSE))))
897
+                        {
898
+                            return true;
899
+                        }else 
900
+                        {
901
+                            return false;
902
+                        }
903
+                    }elseif(is_file($path))
904
+                    {
905
+                $includeFile = trimlrm(CONFIG_SYS_INC_FILE_PATTERN);
906
+                $excludeFile = trimlrm(CONFIG_SYS_EXC_FILE_PATTERN);            				
907
+                $found_includeFile = strpos($includeFile, $file);
908
+                $found_excludeFile = strpos($excludeFile, $file);	      				
909
+                        if((!CONFIG_SYS_INC_FILE_PATTERN || (!($found_includeFile === FALSE))) && (!CONFIG_SYS_EXC_FILE_PATTERN ||   (($found_excludeFile === FALSE))))
910
+                        {
911
+                            return true;
912
+                        }else 
913
+                        {
914
+                            return false;
915
+                        }
916
+                    }
917
+                }elseif(CONFIG_SYS_PATTERN_FORMAT == 'csv')
918
+                {//comma delimited file/folder name
919 919
          		
920
-         		if(is_dir($path))
921
-         		{
920
+                    if(is_dir($path))
921
+                    {
922 922
          		
923
-	 				$includeDir = trimlrm(CONFIG_SYS_INC_DIR_PATTERN);
924
-					$excludeDir = trimlrm(CONFIG_SYS_EXC_DIR_PATTERN);
923
+                        $includeDir = trimlrm(CONFIG_SYS_INC_DIR_PATTERN);
924
+                    $excludeDir = trimlrm(CONFIG_SYS_EXC_DIR_PATTERN);
925 925
 					        
926
-					if(!empty($includeDir) && !empty($excludeDir))
927
-					{
926
+                    if(!empty($includeDir) && !empty($excludeDir))
927
+                    {
928 928
 						
929
-						$validDir = explode(',', $includeDir);
929
+                        $validDir = explode(',', $includeDir);
930 930
 						
931
-						$invalidDir = explode(",", $excludeDir);
931
+                        $invalidDir = explode(",", $excludeDir);
932 932
 
933
-						if(array_search(basename($path), $validDir) !== false && array_search(basename($path), $invalidDir) === false)
934
-						{
935
-							return true;
936
-						}else 
937
-						{
938
-							return false;
939
-						}
940
-					}elseif(!empty($includeDir))
941
-					{
942
-						$validDir = explode(',', $includeDir);
943
-						if(array_search(basename($path), $validDir) !== false)
944
-						{
945
-							return true;
946
-						}else 
947
-						{
948
-							return false;
949
-						}
933
+                        if(array_search(basename($path), $validDir) !== false && array_search(basename($path), $invalidDir) === false)
934
+                        {
935
+                            return true;
936
+                        }else 
937
+                        {
938
+                            return false;
939
+                        }
940
+                    }elseif(!empty($includeDir))
941
+                    {
942
+                        $validDir = explode(',', $includeDir);
943
+                        if(array_search(basename($path), $validDir) !== false)
944
+                        {
945
+                            return true;
946
+                        }else 
947
+                        {
948
+                            return false;
949
+                        }
950 950
 						
951
-					}elseif(!empty($excludeFile))
952
-					{
953
-						$invalidDir = explode(",", $excludeDir);
954
-						if(array_search(basename($path), $invalidDir) === false)
955
-						{
956
-							return true;
957
-						}else 
958
-						{
959
-							return false;
960
-						}
961
-					}
962
-					return true;
951
+                    }elseif(!empty($excludeFile))
952
+                    {
953
+                        $invalidDir = explode(",", $excludeDir);
954
+                        if(array_search(basename($path), $invalidDir) === false)
955
+                        {
956
+                            return true;
957
+                        }else 
958
+                        {
959
+                            return false;
960
+                        }
961
+                    }
962
+                    return true;
963 963
 					
964
-         		}elseif(is_file($path))
965
-         		{
966
-				$includeFile = trimlrm(CONFIG_SYS_INC_FILE_PATTERN);
967
-				$excludeFile = trimlrm(CONFIG_SYS_EXC_FILE_PATTERN);   
968
-				if(!empty($includeFile) && !empty($excludeFile))
969
-				{
970
-					$validFile = explode(',', $includeFile);
971
-					$invalidFile = explode(',', $excludeFile);
972
-					if(array_search(basename($path), $validFile) !== false && array_search(basename($path), $invalidFile) === false)
973
-					{
974
-						return true;
975
-					}else 
976
-					{
977
-						return false;
978
-					}
979
-				}elseif(!empty($includeFile))
980
-				{
981
-					$validFile = explode(',', $includeFile);
982
-					if(array_search(basename($path), $validFile) !== false)
983
-					{
984
-						return true;
985
-					}else 
986
-					{
987
-						return false;
988
-					}
989
-				}elseif(!empty($excludeFile))
990
-				{
991
-					$invalidFile = explode(',', $excludeFile);
992
-					if(array_search(basename($path), $invalidFile) === false)
993
-					{
994
-						return true;
995
-					}else 
996
-					{
997
-						return false;
998
-					}
999
-				}
1000
-				return true;
1001
-         		}
1002
-         	}
1003
-         	else 
1004
-         	{//regular expression
1005
-	          	if(is_dir($path) )
1006
-	         	{
1007
-	         		if(isValidPattern(CONFIG_SYS_INC_DIR_PATTERN, $path) && !isInvalidPattern(CONFIG_SYS_EXC_DIR_PATTERN, $path))
1008
-	         		{
1009
-	         			 return true;	
1010
-	         		}else 
1011
-	         		{
1012
-	         			return false;
1013
-	         		}
964
+                    }elseif(is_file($path))
965
+                    {
966
+                $includeFile = trimlrm(CONFIG_SYS_INC_FILE_PATTERN);
967
+                $excludeFile = trimlrm(CONFIG_SYS_EXC_FILE_PATTERN);   
968
+                if(!empty($includeFile) && !empty($excludeFile))
969
+                {
970
+                    $validFile = explode(',', $includeFile);
971
+                    $invalidFile = explode(',', $excludeFile);
972
+                    if(array_search(basename($path), $validFile) !== false && array_search(basename($path), $invalidFile) === false)
973
+                    {
974
+                        return true;
975
+                    }else 
976
+                    {
977
+                        return false;
978
+                    }
979
+                }elseif(!empty($includeFile))
980
+                {
981
+                    $validFile = explode(',', $includeFile);
982
+                    if(array_search(basename($path), $validFile) !== false)
983
+                    {
984
+                        return true;
985
+                    }else 
986
+                    {
987
+                        return false;
988
+                    }
989
+                }elseif(!empty($excludeFile))
990
+                {
991
+                    $invalidFile = explode(',', $excludeFile);
992
+                    if(array_search(basename($path), $invalidFile) === false)
993
+                    {
994
+                        return true;
995
+                    }else 
996
+                    {
997
+                        return false;
998
+                    }
999
+                }
1000
+                return true;
1001
+                    }
1002
+                }
1003
+                else 
1004
+                {//regular expression
1005
+                    if(is_dir($path) )
1006
+                    {
1007
+                        if(isValidPattern(CONFIG_SYS_INC_DIR_PATTERN, $path) && !isInvalidPattern(CONFIG_SYS_EXC_DIR_PATTERN, $path))
1008
+                        {
1009
+                            return true;	
1010
+                        }else 
1011
+                        {
1012
+                            return false;
1013
+                        }
1014 1014
 	         	
1015
-	         	}elseif(is_file($path))
1016
-	         	{
1017
-	         		if(isValidPattern(CONFIG_SYS_INC_FILE_PATTERN, $path) && !isInvalidPattern(CONFIG_SYS_EXC_FILE_PATTERN, $path)  )
1018
-	         		{
1019
-	         			return true;
1020
-	         		}else 
1021
-	         		{
1022
-	         			return false;
1023
-	         		}
1024
-	         	}
1025
-         	}
1026
-         	return false;
1015
+                    }elseif(is_file($path))
1016
+                    {
1017
+                        if(isValidPattern(CONFIG_SYS_INC_FILE_PATTERN, $path) && !isInvalidPattern(CONFIG_SYS_EXC_FILE_PATTERN, $path)  )
1018
+                        {
1019
+                            return true;
1020
+                        }else 
1021
+                        {
1022
+                            return false;
1023
+                        }
1024
+                    }
1025
+                }
1026
+                return false;
1027 1027
 
1028
-         }		
1028
+            }		
1029 1029
 		
1030
-		/**
1031
-		 * force to down the specified file
1032
-		 *
1033
-		 * @param string $path
1034
-		 * 
1035
-		 */
1036
-		function downloadFile($path, $newFileName=null)
1037
-		{
1038
-				if(file_exists($path) && is_file($path))
1039
-				{	
1040
-					$mimeContentType = 'application/octet-stream';
1041
-					if(function_exists('finfo_open'))
1042
-					{
1043
-						if(($fp = @finfo_open($path)))
1044
-						{
1045
-							$mimeContentType = @finfo_file($fp, basename($path));
1046
-							@finfo_close($fp);
1047
-						}
1030
+        /**
1031
+         * force to down the specified file
1032
+         *
1033
+         * @param string $path
1034
+         * 
1035
+         */
1036
+        function downloadFile($path, $newFileName=null)
1037
+        {
1038
+                if(file_exists($path) && is_file($path))
1039
+                {	
1040
+                    $mimeContentType = 'application/octet-stream';
1041
+                    if(function_exists('finfo_open'))
1042
+                    {
1043
+                        if(($fp = @finfo_open($path)))
1044
+                        {
1045
+                            $mimeContentType = @finfo_file($fp, basename($path));
1046
+                            @finfo_close($fp);
1047
+                        }
1048 1048
 						
1049
-					}elseif(($temMimeContentType = @mime_content_type($path)) && !empty($temMimeContentType))
1050
-					{
1051
-						$mimeContentType = $temMimeContentType;
1052
-					}
1049
+                    }elseif(($temMimeContentType = @mime_content_type($path)) && !empty($temMimeContentType))
1050
+                    {
1051
+                        $mimeContentType = $temMimeContentType;
1052
+                    }
1053 1053
 					
1054 1054
  					
1055 1055
 					
1056 1056
 						
1057 1057
 
1058
-			// START ANDR� SILVA DOWNLOAD CODE
1059
-			// required for IE, otherwise Content-disposition is ignored
1060
-			if(ini_get('zlib.output_compression'))
1061
-			  ini_set('zlib.output_compression', 'Off');
1062
-			header("Pragma: public"); // required
1063
-			header("Expires: 0");
1064
-			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
1065
-			header("Cache-Control: private",false); // required for certain browsers 
1066
-			header("Content-Type: " . $mimeContentType );
1067
-			// change, added quotes to allow spaces in filenames, by Rajkumar Singh
1068
-			header("Content-Disposition: attachment; filename=\"".(is_null($newFileName)?basename($path):$newFileName)."\";" );
1069
-			header("Content-Transfer-Encoding: binary");
1070
-			header("Content-Length: ".filesize($path));
1058
+            // START ANDR� SILVA DOWNLOAD CODE
1059
+            // required for IE, otherwise Content-disposition is ignored
1060
+            if(ini_get('zlib.output_compression'))
1061
+                ini_set('zlib.output_compression', 'Off');
1062
+            header("Pragma: public"); // required
1063
+            header("Expires: 0");
1064
+            header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
1065
+            header("Cache-Control: private",false); // required for certain browsers 
1066
+            header("Content-Type: " . $mimeContentType );
1067
+            // change, added quotes to allow spaces in filenames, by Rajkumar Singh
1068
+            header("Content-Disposition: attachment; filename=\"".(is_null($newFileName)?basename($path):$newFileName)."\";" );
1069
+            header("Content-Transfer-Encoding: binary");
1070
+            header("Content-Length: ".filesize($path));
1071 1071
 		
1072
-			readfile($path);
1073
-			exit();
1074
-			// END ANDR� SILVA DOWNLOAD CODE												
1075
-				}
1072
+            readfile($path);
1073
+            exit();
1074
+            // END ANDR� SILVA DOWNLOAD CODE												
1075
+                }
1076 1076
 		
1077
-		}
1077
+        }
1078 1078
 
1079
-  /**
1080
-   * remove all white spaces
1081
-   *
1082
-   * @param string $hayStack 
1083
-   * @param string $whiteSpaceChars
1084
-   * @return string
1085
-   */
1086
-  function trimlrm ($hayStack, $whiteSpaceChars="\t\n\r\0\x0B")
1087
-  {
1088
-  	return str_replace($whiteSpaceChars, '', trim($hayStack));
1089
-  }		
1079
+    /**
1080
+     * remove all white spaces
1081
+     *
1082
+     * @param string $hayStack 
1083
+     * @param string $whiteSpaceChars
1084
+     * @return string
1085
+     */
1086
+    function trimlrm ($hayStack, $whiteSpaceChars="\t\n\r\0\x0B")
1087
+    {
1088
+        return str_replace($whiteSpaceChars, '', trim($hayStack));
1089
+    }		
1090 1090
   
1091
-  /**
1092
-   * get the parent path of the specified path
1093
-   *
1094
-   * @param string $path
1095
-   * @return string 
1096
-   */
1097
-  function getParentFolderPath($path)
1098
-  {
1099
-  	$realPath = addTrailingSlash(backslashToSlash(getRealPath($path)));
1100
-  	$parentRealPath =  addTrailingSlash(backslashToSlash(dirname($realPath)));
1101
-  	$differentPath = addTrailingSlash(substr($realPath, strlen($parentRealPath)));
1102
-  	$parentPath = substr($path, 0, strlen(addTrailingSlash(backslashToSlash($path))) - strlen($differentPath));
1103
-  	if(isUnderRoot($parentPath))
1104
-  	{
1105
-  		return $parentPath;
1106
-  	}else 
1107
-  	{
1108
-  		return CONFIG_SYS_DEFAULT_PATH;
1109
-  	}
1110
-  }
1091
+    /**
1092
+     * get the parent path of the specified path
1093
+     *
1094
+     * @param string $path
1095
+     * @return string 
1096
+     */
1097
+    function getParentFolderPath($path)
1098
+    {
1099
+        $realPath = addTrailingSlash(backslashToSlash(getRealPath($path)));
1100
+        $parentRealPath =  addTrailingSlash(backslashToSlash(dirname($realPath)));
1101
+        $differentPath = addTrailingSlash(substr($realPath, strlen($parentRealPath)));
1102
+        $parentPath = substr($path, 0, strlen(addTrailingSlash(backslashToSlash($path))) - strlen($differentPath));
1103
+        if(isUnderRoot($parentPath))
1104
+        {
1105
+            return $parentPath;
1106
+        }else 
1107
+        {
1108
+            return CONFIG_SYS_DEFAULT_PATH;
1109
+        }
1110
+    }
1111 1111
   
1112
-  function getCurrentFolderPath()
1113
-  {
1114
-  		$folderPathIndex = 'path';
1115
-  		$lastVisitedFolderPathIndex = 'ajax_last_visited_folder';
1116
-		if(isset($_GET[$folderPathIndex]) && file_exists($_GET[$folderPathIndex]) && !is_file($_GET[$folderPathIndex]) )
1117
-		{
1118
-			$currentFolderPath = $_GET[$folderPathIndex];
1119
-		}
1120
-		elseif(isset($_SESSION[$lastVisitedFolderPathIndex]) && file_exists($_SESSION[$lastVisitedFolderPathIndex]) && !is_file($_SESSION[$lastVisitedFolderPathIndex]))
1121
-		{
1122
-			$currentFolderPath = $_SESSION[$lastVisitedFolderPathIndex];
1123
-		}else
1124
-		{
1125
-			$currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
1126
-		}
1112
+    function getCurrentFolderPath()
1113
+    {
1114
+            $folderPathIndex = 'path';
1115
+            $lastVisitedFolderPathIndex = 'ajax_last_visited_folder';
1116
+        if(isset($_GET[$folderPathIndex]) && file_exists($_GET[$folderPathIndex]) && !is_file($_GET[$folderPathIndex]) )
1117
+        {
1118
+            $currentFolderPath = $_GET[$folderPathIndex];
1119
+        }
1120
+        elseif(isset($_SESSION[$lastVisitedFolderPathIndex]) && file_exists($_SESSION[$lastVisitedFolderPathIndex]) && !is_file($_SESSION[$lastVisitedFolderPathIndex]))
1121
+        {
1122
+            $currentFolderPath = $_SESSION[$lastVisitedFolderPathIndex];
1123
+        }else
1124
+        {
1125
+            $currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
1126
+        }
1127 1127
 		
1128
-		$currentFolderPath = (isUnderRoot($currentFolderPath)?backslashToSlash((addTrailingSlash($currentFolderPath))):CONFIG_SYS_DEFAULT_PATH);
1128
+        $currentFolderPath = (isUnderRoot($currentFolderPath)?backslashToSlash((addTrailingSlash($currentFolderPath))):CONFIG_SYS_DEFAULT_PATH);
1129 1129
 		
1130
-		//keep track of this folder path in session 
1131
-		$_SESSION[$lastVisitedFolderPathIndex] = $currentFolderPath;
1130
+        //keep track of this folder path in session 
1131
+        $_SESSION[$lastVisitedFolderPathIndex] = $currentFolderPath;
1132 1132
 		
1133 1133
 
1134
-		if(!file_exists($currentFolderPath))
1135
-		{
1136
-			die(ERR_FOLDER_NOT_FOUND . $currentFolderPath);
1137
-		}  	
1138
-  }
1134
+        if(!file_exists($currentFolderPath))
1135
+        {
1136
+            die(ERR_FOLDER_NOT_FOUND . $currentFolderPath);
1137
+        }  	
1138
+    }
1139 1139
   
1140
-       if(!function_exists("imagerotate"))
1140
+        if(!function_exists("imagerotate"))
1141 1141
         {
1142 1142
             function imagerotate($src_img, $angle, $bicubic=false)
1143 1143
             {
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
     $sinangle = sin($angle);
1161 1161
    
1162 1162
     for ($y = 0; $y < $src_y; $y++) {
1163
-      for ($x = 0; $x < $src_x; $x++) {
1163
+        for ($x = 0; $x < $src_x; $x++) {
1164 1164
     // rotate...
1165 1165
     $old_x = (($center_x-$x) * $cosangle + ($center_y-$y) * $sinangle)
1166 1166
       + $center_x;
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
    
1170 1170
     if ( $old_x >= 0 && $old_x < $src_x
1171 1171
          && $old_y >= 0 && $old_y < $src_y ) {
1172
-      if ($bicubic == true) {
1172
+        if ($bicubic == true) {
1173 1173
         $sY  = $old_y + 1;
1174 1174
         $siY  = $old_y;
1175 1175
         $siY2 = $old_y - 1;
@@ -1187,15 +1187,15 @@  discard block
 block discarded – undo
1187 1187
         $b = ($c1['blue']  + $c2['blue']  + $c3['blue']  + $c4['blue'] ) >> 2;
1188 1188
         $a = ($c1['alpha']  + $c2['alpha']  + $c3['alpha']  + $c4['alpha'] ) >> 2;
1189 1189
         $color = imagecolorallocatealpha($src_img, $r,$g,$b,$a);
1190
-      } else {
1190
+        } else {
1191 1191
         $color = imagecolorat($src_img, $old_x, $old_y);
1192
-      }
1192
+        }
1193 1193
     } else {
1194
-          // this line sets the background colour
1195
-      $color = imagecolorallocatealpha($src_img, 255, 255, 255, 127);
1194
+            // this line sets the background colour
1195
+        $color = imagecolorallocatealpha($src_img, 255, 255, 255, 127);
1196 1196
     }
1197 1197
     imagesetpixel($rotate, $x, $y, $color);
1198
-      }
1198
+        }
1199 1199
     }
1200 1200
     return $rotate;          	
1201 1201
 /*                $src_x = @imagesx($src_img);
Please login to merge, or discard this patch.
Spacing   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-	if(!defined('AJAX_INIT_DONE'))
2
+	if (!defined('AJAX_INIT_DONE'))
3 3
 	{
4 4
 		die('Permission denied');
5 5
 	}
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
 	 * @since 22/April/2007
12 12
 	 *
13 13
 	 */
14
-require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "config.php");
14
+require_once(dirname(__FILE__).DIRECTORY_SEPARATOR."config.php");
15 15
 /**
16 16
  * force to ensure existence of stripos
17 17
  */
18 18
 if (!function_exists("stripos")) 
19 19
 {
20
-  function stripos($str,$needle,$offset=0)
20
+  function stripos($str, $needle, $offset = 0)
21 21
   {
22
-      return @strpos(strtolower($str),strtolower($needle),$offset);
22
+      return @strpos(strtolower($str), strtolower($needle), $offset);
23 23
   }
24 24
 }
25 25
 	/**
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
 	 * @param array $excls specify those unwanted query string
29 29
 	 * @return string
30 30
 	 */
31
-	function getCurrentUrl($excls=array())
31
+	function getCurrentUrl($excls = array())
32 32
 	{
33 33
 		$output = $_SERVER['PHP_SELF'];
34 34
 		$count = 1;
35
-		foreach($_GET as $k=>$v)
35
+		foreach ($_GET as $k=>$v)
36 36
 		{
37
-			if(array_search($k, $excls) ===false)
37
+			if (array_search($k, $excls) === false)
38 38
 			{
39 39
 				$strAppend = "&";
40
-				if($count == 1)
40
+				if ($count == 1)
41 41
 				{
42 42
 					$strAppend = "?";
43 43
 					$count++;
44 44
 				}
45
-				$output .= $strAppend . urlencode($k) . "=" . urlencode($v);
45
+				$output .= $strAppend.urlencode($k)."=".urlencode($v);
46 46
 			}
47 47
 		}
48 48
 		return $output;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
  *
54 54
  * @param array $array
55 55
  */
56
-function displayArray($array, $comments='')
56
+function displayArray($array, $comments = '')
57 57
 {
58 58
 	echo "<pre>";
59 59
 	echo $comments;
@@ -72,50 +72,50 @@  discard block
 block discarded – undo
72 72
 	 * @param array $invalidExts
73 73
 	 * @return boolean
74 74
 	 */
75
-	function isValidExt($filePath, $validExts, $invalidExts=array())
75
+	function isValidExt($filePath, $validExts, $invalidExts = array())
76 76
 	{
77 77
 		$tem = array();
78 78
 
79
-		if(sizeof($validExts))
79
+		if (sizeof($validExts))
80 80
 		{
81
-			foreach($validExts as $k=>$v)
81
+			foreach ($validExts as $k=>$v)
82 82
 			{
83 83
 				$tem[$k] = strtolower(trim($v));
84 84
 			}
85 85
 		}
86 86
 		$validExts = $tem;
87 87
 		$tem = array();
88
-		if(sizeof($invalidExts))
88
+		if (sizeof($invalidExts))
89 89
 		{
90
-			foreach($invalidExts as $k=>$v)
90
+			foreach ($invalidExts as $k=>$v)
91 91
 			{
92 92
 				$tem[$k] = strtolower(trim($v));
93 93
 			}
94 94
 		}
95 95
 		$invalidExts = $tem;
96
-		if(sizeof($validExts) && sizeof($invalidExts))
96
+		if (sizeof($validExts) && sizeof($invalidExts))
97 97
 		{
98
-			foreach($validExts as  $k=>$ext)
98
+			foreach ($validExts as  $k=>$ext)
99 99
 			{
100
-				if(array_search($ext, $invalidExts) !== false)
100
+				if (array_search($ext, $invalidExts) !== false)
101 101
 				{
102 102
 					unset($validExts[$k]);
103 103
 				}
104 104
 			}
105 105
 		}
106
-		if(sizeof($validExts))
106
+		if (sizeof($validExts))
107 107
 		{
108
-			if(array_search(strtolower(getFileExt($filePath)), $validExts) !== false)
108
+			if (array_search(strtolower(getFileExt($filePath)), $validExts) !== false)
109 109
 			{
110 110
 				return true;
111
-			}else 
111
+			} else 
112 112
 			{
113 113
 				return false;
114 114
 			}
115
-		}elseif(array_search(strtolower(getFileExt($filePath)), $invalidExts) === false)
115
+		}elseif (array_search(strtolower(getFileExt($filePath)), $invalidExts) === false)
116 116
 		{
117 117
 			return true;
118
-		}else 
118
+		} else 
119 119
 		{
120 120
 			return false;
121 121
 		}
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
  */
133 133
 function relToAbs($value) 
134 134
 {
135
-	return backslashToSlash(preg_replace("/(\\\\)/","\\", getRealPath($value)));
135
+	return backslashToSlash(preg_replace("/(\\\\)/", "\\", getRealPath($value)));
136 136
 
137 137
 }
138 138
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 		$pos = strpos($value, $wwwroot);
147 147
 		if ($pos !== false && $pos == 0)
148 148
 		{
149
-			$output  = $urlprefix . substr($value, strlen($wwwroot)) . $urlsuffix;
149
+			$output = $urlprefix.substr($value, strlen($wwwroot)).$urlsuffix;
150 150
 		}
151 151
 	}
152 152
 /**
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
  * @return string
177 177
  */
178 178
 function removeTrailingSlash($value) {
179
-	if(preg_match('@^.+/$@i', $value))
179
+	if (preg_match('@^.+/$@i', $value))
180 180
 	{
181
-		$value = substr($value, 0, strlen($value)-1);
181
+		$value = substr($value, 0, strlen($value) - 1);
182 182
 	}
183 183
 	return $value;
184 184
 }
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
  */
192 192
 function addTrailingSlash($value) 
193 193
 {
194
-	if(preg_match('@^.*[^/]{1}$@i', $value))
194
+	if (preg_match('@^.*[^/]{1}$@i', $value))
195 195
 	{
196 196
 		$value .= '/';
197 197
 	}
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
 function transformFilePath($value) {
208 208
 	$rootPath = addTrailingSlash(backslashToSlash(getRealPath(CONFIG_SYS_ROOT_PATH)));
209 209
 	$value = addTrailingSlash(backslashToSlash(getRealPath($value)));
210
-	if(!empty($rootPath) && ($i = strpos($value, $rootPath)) !== false)
210
+	if (!empty($rootPath) && ($i = strpos($value, $rootPath)) !== false)
211 211
 	{
212
-		$value = ($i == 0?substr($value, strlen($rootPath)):"/");		
212
+		$value = ($i == 0 ? substr($value, strlen($rootPath)) : "/");		
213 213
 	}
214 214
 	$value = prependSlash($value);
215 215
 	return $value;
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
  */
223 223
 function prependSlash($value)
224 224
 {
225
-		if (($value && $value[0] != '/') || !$value )
225
+		if (($value && $value[0] != '/') || !$value)
226 226
 		{
227
-			$value = "/" . $value;
227
+			$value = "/".$value;
228 228
 		}			
229 229
 		return $value;	
230 230
 }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
  */
253 253
 function addNoCacheHeaders() {
254 254
 	header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
255
-	header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
255
+	header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
256 256
 	header("Cache-Control: no-store, no-cache, must-revalidate");
257 257
 	header("Cache-Control: post-check=0, pre-check=0", false);
258 258
 	header("Pragma: no-cache");
@@ -265,14 +265,14 @@  discard block
 block discarded – undo
265 265
 	function appendQueryString($baseUrl, $extra)
266 266
 	{
267 267
 		$output = $baseUrl;
268
-		if(!empty($extra))
268
+		if (!empty($extra))
269 269
 		{
270
-			if(strpos($baseUrl, "?") !== false)
270
+			if (strpos($baseUrl, "?") !== false)
271 271
 			{
272
-				$output .= "&" . $extra;
273
-			}else
272
+				$output .= "&".$extra;
273
+			} else
274 274
 			{
275
-				$output .= "?" . $extra;
275
+				$output .= "?".$extra;
276 276
 			}			
277 277
 		}
278 278
 
@@ -284,15 +284,15 @@  discard block
 block discarded – undo
284 284
 	 * @param array $excluded
285 285
 	 * @return string
286 286
 	 */
287
-	function makeQueryString($excluded=array())
287
+	function makeQueryString($excluded = array())
288 288
 	{
289 289
 		$output = '';
290 290
 		$count = 1;
291
-		foreach($_GET as $k=>$v)
291
+		foreach ($_GET as $k=>$v)
292 292
 		{
293
-			if(array_search($k, $excluded) === false)
293
+			if (array_search($k, $excluded) === false)
294 294
 			{
295
-				$output .= ($count>1?'&':'') . (urlencode($k) . "=" . urlencode($v));
295
+				$output .= ($count > 1 ? '&' : '').(urlencode($k)."=".urlencode($v));
296 296
 				$count++;
297 297
 			}
298 298
 		}
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	function getParentPath($value)
308 308
 	{
309 309
 		$value = removeTrailingSlash(backslashToSlash($value));
310
-		if(false !== ($index = strrpos($value, "/")) )
310
+		if (false !== ($index = strrpos($value, "/")))
311 311
 		{
312 312
 			return substr($value, 0, $index);
313 313
 		}
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	function isUnderRoot($value)
325 325
 	{
326 326
 		$roorPath = strtolower(addTrailingSlash(backslashToSlash(getRealPath(CONFIG_SYS_ROOT_PATH))));
327
-		if(file_exists($value) && @strpos(strtolower(addTrailingSlash(backslashToSlash(getRealPath($value)))), $roorPath) === 0 )
327
+		if (file_exists($value) && @strpos(strtolower(addTrailingSlash(backslashToSlash(getRealPath($value)))), $roorPath) === 0)
328 328
 		{
329 329
 			return true;
330 330
 		}
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	{
341 341
 		global $session;
342 342
 		$sessionPath = strtolower(addTrailingSlash(backslashToSlash(getRealPath($session->getSessionDir()))));
343
-		if(file_exists($value) && @strpos(strtolower(addTrailingSlash(backslashToSlash(getRealPath($value)))), $sessionPath) === 0 )
343
+		if (file_exists($value) && @strpos(strtolower(addTrailingSlash(backslashToSlash(getRealPath($value)))), $sessionPath) === 0)
344 344
 		{
345 345
 			return true;
346 346
 		}
@@ -357,26 +357,26 @@  discard block
 block discarded – undo
357 357
 	 * @param integer $thumbnailHeight
358 358
 	 * @return array()
359 359
 	 */
360
-	function getThumbWidthHeight( $originaleImageWidth, $originalImageHeight, $thumbnailWidth, $thumbnailHeight)
360
+	function getThumbWidthHeight($originaleImageWidth, $originalImageHeight, $thumbnailWidth, $thumbnailHeight)
361 361
 	{
362
-		$outputs = array( "width"=>0, "height"=>0);
363
-		$thumbnailWidth	= intval($thumbnailWidth);
362
+		$outputs = array("width"=>0, "height"=>0);
363
+		$thumbnailWidth = intval($thumbnailWidth);
364 364
 		$thumbnailHeight = intval($thumbnailHeight);
365
-		if(!empty($originaleImageWidth) && !empty($originalImageHeight))
365
+		if (!empty($originaleImageWidth) && !empty($originalImageHeight))
366 366
 		{
367 367
 			//start to get the thumbnail width & height
368
-        	if(($thumbnailWidth < 1 && $thumbnailHeight < 1) || ($thumbnailWidth > $originaleImageWidth && $thumbnailHeight > $originalImageHeight ))
368
+        	if (($thumbnailWidth < 1 && $thumbnailHeight < 1) || ($thumbnailWidth > $originaleImageWidth && $thumbnailHeight > $originalImageHeight))
369 369
         	{
370
-        		$thumbnailWidth =$originaleImageWidth;
370
+        		$thumbnailWidth = $originaleImageWidth;
371 371
         		$thumbnailHeight = $originalImageHeight;
372
-        	}elseif($thumbnailWidth < 1)
372
+        	}elseif ($thumbnailWidth < 1)
373 373
         	{
374
-        		$thumbnailWidth = floor($thumbnailHeight / $originalImageHeight * $originaleImageWidth);
374
+        		$thumbnailWidth = floor($thumbnailHeight/$originalImageHeight*$originaleImageWidth);
375 375
 
376
-        	}elseif($thumbnailHeight < 1)
376
+        	}elseif ($thumbnailHeight < 1)
377 377
         	{
378
-        		$thumbnailHeight = floor($thumbnailWidth / $originaleImageWidth * $originalImageHeight);
379
-        	}else
378
+        		$thumbnailHeight = floor($thumbnailWidth/$originaleImageWidth*$originalImageHeight);
379
+        	} else
380 380
         	{
381 381
         		$scale = min($thumbnailWidth/$originaleImageWidth, $thumbnailHeight/$originalImageHeight);
382 382
 				$thumbnailWidth = floor($scale*$originaleImageWidth);
@@ -396,9 +396,9 @@  discard block
 block discarded – undo
396 396
  */
397 397
 function getAbsPath($value) {
398 398
 	if (substr($value, 0, 1) == "/")
399
-		return slashToBackslash(DIR_AJAX_ROOT . $value);
399
+		return slashToBackslash(DIR_AJAX_ROOT.$value);
400 400
 
401
-	return slashToBackslash(dirname(__FILE__) . "/" . $value);
401
+	return slashToBackslash(dirname(__FILE__)."/".$value);
402 402
 }
403 403
 
404 404
 	/**
@@ -411,10 +411,10 @@  discard block
 block discarded – undo
411 411
 	{
412 412
 		$value = removeTrailingSlash(backslashToSlash($value));
413 413
 
414
-		if(false !== ($index = strrpos($value, "/")) )
414
+		if (false !== ($index = strrpos($value, "/")))
415 415
 		{
416 416
 			return substr($value, $index + 1);
417
-		}else
417
+		} else
418 418
 		{
419 419
 			return $value;
420 420
 		}
@@ -422,30 +422,30 @@  discard block
 block discarded – undo
422 422
 
423 423
 function myRealPath($path) {
424 424
 
425
-		if(strpos($path, ':/') !== false)
425
+		if (strpos($path, ':/') !== false)
426 426
 		{
427 427
 			return $path;
428 428
 		}
429 429
     // check if path begins with "/" ie. is absolute
430 430
     // if it isnt concat with script path
431 431
     
432
-    if (strpos($path,"/") !== 0 ) {
433
-        $base=dirname($_SERVER['SCRIPT_FILENAME']);
434
-        $path=$base."/".$path;
432
+    if (strpos($path, "/") !== 0) {
433
+        $base = dirname($_SERVER['SCRIPT_FILENAME']);
434
+        $path = $base."/".$path;
435 435
     }
436 436
  
437 437
     // canonicalize
438
-    $path=explode('/', $path);
439
-    $newpath=array();
440
-    for ($i=0; $i<sizeof($path); $i++) {
441
-        if ($path[$i]==='' || $path[$i]==='.') continue;
442
-           if ($path[$i]==='..') {
438
+    $path = explode('/', $path);
439
+    $newpath = array();
440
+    for ($i = 0; $i < sizeof($path); $i++) {
441
+        if ($path[$i] === '' || $path[$i] === '.') continue;
442
+           if ($path[$i] === '..') {
443 443
               array_pop($newpath);
444 444
               continue;
445 445
         }
446 446
         array_push($newpath, $path[$i]);
447 447
     }
448
-    $finalpath="/".implode('/', $newpath);
448
+    $finalpath = "/".implode('/', $newpath);
449 449
 
450 450
     clearstatcache();
451 451
     // check then return valid path or filename
@@ -463,10 +463,10 @@  discard block
 block discarded – undo
463 463
  function getRealPath($value)
464 464
  {
465 465
  		$output = '';
466
- 	 if(($path = realpath($value)) && $path != $value)
466
+ 	 if (($path = realpath($value)) && $path != $value)
467 467
  	 {
468 468
  	 	$output = $path;
469
- 	 }else 
469
+ 	 } else 
470 470
  	 {
471 471
  	 	$output = myRealPath($value);
472 472
  	 }
@@ -489,14 +489,14 @@  discard block
 block discarded – undo
489 489
 		$value = backslashToSlash(getRealPath($value));
490 490
 
491 491
 		$pos = stripos($value, $wwwroot);
492
-		if ($pos !== false )
492
+		if ($pos !== false)
493 493
 		{
494
-			$output  = $urlprefix . substr($value, $pos + strlen($wwwroot)) . $urlsuffix;
495
-		}else 
494
+			$output = $urlprefix.substr($value, $pos + strlen($wwwroot)).$urlsuffix;
495
+		} else 
496 496
 		{
497 497
 			$output = $value;
498 498
 		}
499
-		$protocol = (isset($_SERVER["HTTPS"]) &&  $_SERVER["HTTPS"] == 'on' ? 'https' : 'http');
499
+		$protocol = (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on' ? 'https' : 'http');
500 500
 
501 501
         // Pick up URL up to /admin and exclude /admin  . This is the phpMyFAQ directory
502 502
         $pmfBase = strrev(
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
                 stristr(strrev(backslashToSlash($_SERVER['HTTP_REFERER'])), 'nimda/')
507 507
             )
508 508
         );
509
-        if ($pmfBase == $_SERVER['HTTP_HOST'])    {
509
+        if ($pmfBase == $_SERVER['HTTP_HOST']) {
510 510
             // phpMyFAQ is not in a subdirectory of a domain
511 511
             $pmfRest = str_replace($_SERVER['DOCUMENT_ROOT'], '', stristr($output, $_SERVER['DOCUMENT_ROOT']));
512 512
         } else {
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
             );
522 522
         }
523 523
 
524
-        return $pmfBase . $pmfRest ;
524
+        return $pmfBase.$pmfRest;
525 525
 
526 526
 	}
527 527
 	
@@ -535,16 +535,16 @@  discard block
 block discarded – undo
535 535
 
536 536
 	if ($size > 1048576)
537 537
 	{
538
-		return round($size / 1048576, 1) . " MB";
538
+		return round($size/1048576, 1)." MB";
539 539
 	}elseif ($size > 1024)
540 540
 	{
541
-		return round($size / 1024, 1) . " KB";
542
-	}elseif($size == '')
541
+		return round($size/1024, 1)." KB";
542
+	}elseif ($size == '')
543 543
 	{
544 544
 		return $size;
545
-	}else
545
+	} else
546 546
 	{
547
-		return $size . " b";
547
+		return $size." b";
548 548
 	}	
549 549
 }
550 550
 	
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 	function removeBeginingSlash($value)
558 558
 	{
559 559
 		$value = backslashToSlash($value);
560
-		if(strpos($value, "/") === 0)
560
+		if (strpos($value, "/") === 0)
561 561
 		{
562 562
 			$value = substr($value, 1);
563 563
 		}
@@ -577,19 +577,19 @@  discard block
 block discarded – undo
577 577
 
578 578
 			return slashToBackslash(CONFIG_WEBSITE_DOCUMENT_ROOT);
579 579
 		}
580
-		if(isset($_SERVER['DOCUMENT_ROOT']) && ($output = relToAbs($_SERVER['DOCUMENT_ROOT'])) != '' )
580
+		if (isset($_SERVER['DOCUMENT_ROOT']) && ($output = relToAbs($_SERVER['DOCUMENT_ROOT'])) != '')
581 581
 		{
582 582
 
583 583
 			return $output;
584
-		}elseif(isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["SCRIPT_FILENAME"]) && ($output = str_replace(backslashToSlash($_SERVER["SCRIPT_NAME"]), '', backslashToSlash($_SERVER["SCRIPT_FILENAME"]))) && is_dir($output))
584
+		}elseif (isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["SCRIPT_FILENAME"]) && ($output = str_replace(backslashToSlash($_SERVER["SCRIPT_NAME"]), '', backslashToSlash($_SERVER["SCRIPT_FILENAME"]))) && is_dir($output))
585 585
 		{
586 586
 
587 587
 			return slashToBackslash($output);
588
-		}elseif(isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["PATH_TRANSLATED"]) && ($output = str_replace(backslashToSlash($_SERVER["SCRIPT_NAME"]), '', str_replace("//", "/", backslashToSlash($_SERVER["PATH_TRANSLATED"])))) && is_dir($output))
588
+		}elseif (isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["PATH_TRANSLATED"]) && ($output = str_replace(backslashToSlash($_SERVER["SCRIPT_NAME"]), '', str_replace("//", "/", backslashToSlash($_SERVER["PATH_TRANSLATED"])))) && is_dir($output))
589 589
 		{
590 590
 
591 591
 			return $output;
592
-		}else 
592
+		} else 
593 593
 		{
594 594
 			return '';
595 595
 		}	
@@ -606,9 +606,9 @@  discard block
 block discarded – undo
606 606
 	 */	
607 607
 	function addBeginingSlash($value)
608 608
 	{
609
-		if(strpos($value, "/") !== 0 && !empty($value))
609
+		if (strpos($value, "/") !== 0 && !empty($value))
610 610
 		{
611
-			$value .= "/" . $value;
611
+			$value .= "/".$value;
612 612
 		}
613 613
 		return $value;		
614 614
 	}
@@ -634,33 +634,33 @@  discard block
 block discarded – undo
634 634
 		 * @param string $final_dir
635 635
 		 * @return string
636 636
 		 */
637
-    function getRelativePath($start_dir, $final_dir){
637
+    function getRelativePath($start_dir, $final_dir) {
638 638
       //
639 639
       $firstPathParts = explode(DIRECTORY_SEPARATOR, $start_dir);
640 640
       $secondPathParts = explode(DIRECTORY_SEPARATOR, $final_dir);
641 641
       //
642 642
       $sameCounter = 0;
643
-      for($i = 0; $i < min( count($firstPathParts), count($secondPathParts) ); $i++) {
644
-          if( strtolower($firstPathParts[$i]) !== strtolower($secondPathParts[$i]) ) {
643
+      for ($i = 0; $i < min(count($firstPathParts), count($secondPathParts)); $i++) {
644
+          if (strtolower($firstPathParts[$i]) !== strtolower($secondPathParts[$i])) {
645 645
               break;
646 646
           }
647 647
           $sameCounter++;
648 648
       }
649
-      if( $sameCounter == 0 ) {
649
+      if ($sameCounter == 0) {
650 650
           return $final_dir;
651 651
       }
652 652
       //
653 653
       $newPath = '';
654
-      for($i = $sameCounter; $i < count($firstPathParts); $i++) {
655
-          if( $i > $sameCounter ) {
654
+      for ($i = $sameCounter; $i < count($firstPathParts); $i++) {
655
+          if ($i > $sameCounter) {
656 656
               $newPath .= DIRECTORY_SEPARATOR;
657 657
           }
658 658
           $newPath .= "..";
659 659
       }
660
-      if( count($newPath) == 0 ) {
660
+      if (count($newPath) == 0) {
661 661
           $newPath = ".";
662 662
       }
663
-      for($i = $sameCounter; $i < count($secondPathParts); $i++) {
663
+      for ($i = $sameCounter; $i < count($secondPathParts); $i++) {
664 664
           $newPath .= DIRECTORY_SEPARATOR;
665 665
           $newPath .= $secondPathParts[$i];
666 666
       }
@@ -674,20 +674,20 @@  discard block
 block discarded – undo
674 674
    */
675 675
   function getMemoryLimit()
676 676
   {
677
-    $output = @ini_get('memory_limit') or $output = -1 ;
678
-    if(intval($output) < 0)
677
+    $output = @ini_get('memory_limit') or $output = -1;
678
+    if (intval($output) < 0)
679 679
     {//unlimited
680 680
     	$output = 999999999999999999;
681 681
     }
682
-    elseif(strpos('g', strtolower($output)) !== false)
682
+    elseif (strpos('g', strtolower($output)) !== false)
683 683
     {
684
-    	$output = intval($output) * 1024 * 1024 * 1024;
685
-    }elseif(strpos('k', strtolower($output)) !== false)
684
+    	$output = intval($output)*1024*1024*1024;
685
+    }elseif (strpos('k', strtolower($output)) !== false)
686 686
     {
687
-    	$output = intval($output) * 1024 ;
688
-    }else
687
+    	$output = intval($output)*1024;
688
+    } else
689 689
     {
690
-    	$output = intval($output) * 1024 * 1024;
690
+    	$output = intval($output)*1024*1024;
691 691
     }
692 692
     
693 693
     return $output;  	
@@ -712,31 +712,31 @@  discard block
 block discarded – undo
712 712
           * @param string $prefixName the prefix before the folder name
713 713
           * @return array
714 714
           */
715
-         function getFolderListing($path,$indexNumber=null, $prefixNumber =' ', $prefixName =' - ',  $outputs=array())
715
+         function getFolderListing($path, $indexNumber = null, $prefixNumber = ' ', $prefixName = ' - ', $outputs = array())
716 716
          {
717 717
                    $path = removeTrailingSlash(backslashToSlash($path));
718
-                   if(is_null($indexNumber))
718
+                   if (is_null($indexNumber))
719 719
                    {
720 720
                    	$outputs[IMG_LBL_ROOT_FOLDER] = removeTrailingSlash(backslashToSlash($path));
721 721
                    }
722 722
                    $fh = @opendir($path);
723
-                   if($fh)
723
+                   if ($fh)
724 724
                    {
725 725
                             $count = 1;                          
726
-                            while($file = @readdir($fh))
726
+                            while ($file = @readdir($fh))
727 727
                             {
728
-                                     $newPath = removeTrailingSlash(backslashToSlash($path . "/" . $file));
729
-                                     if(isListingDocument($newPath) && $file != '.' && $file != '..' && is_dir($newPath))
728
+                                     $newPath = removeTrailingSlash(backslashToSlash($path."/".$file));
729
+                                     if (isListingDocument($newPath) && $file != '.' && $file != '..' && is_dir($newPath))
730 730
                                      {                                          
731
-                                               if(!empty($indexNumber))
731
+                                               if (!empty($indexNumber))
732 732
                                                {//this is not root folder
733 733
                                                					
734
-                                                        $outputs[$prefixNumber . $indexNumber . "." . $count . $prefixName . $file] = $newPath;
735
-                                                        getFolderListing($newPath,  $prefixNumber . $indexNumber . "." . $count , $prefixNumber, $prefixName, $outputs);                                                 
736
-                                               }else 
734
+                                                        $outputs[$prefixNumber.$indexNumber.".".$count.$prefixName.$file] = $newPath;
735
+                                                        getFolderListing($newPath, $prefixNumber.$indexNumber.".".$count, $prefixNumber, $prefixName, $outputs);                                                 
736
+                                               } else 
737 737
                                                {//this is root folder
738 738
 
739
-                                                        $outputs[$count . $prefixName . $file] = $newPath;
739
+                                                        $outputs[$count.$prefixName.$file] = $newPath;
740 740
                                                         getFolderListing($newPath, $count, $prefixNumber, $prefixName, $outputs);
741 741
                                                }
742 742
                                                $count++;
@@ -759,23 +759,23 @@  discard block
 block discarded – undo
759 759
          function getValidTextEditorExts()
760 760
          {
761 761
          	$validEditorExts = explode(',', CONFIG_EDITABLE_VALID_EXTS);
762
-         	if(CONFIG_UPLOAD_VALID_EXTS)
762
+         	if (CONFIG_UPLOAD_VALID_EXTS)
763 763
          	{//exclude those exts not shown on CONFIG_UPLOAD_VALID_EXTS
764 764
          		$validUploadExts = explode(',', CONFIG_UPLOAD_VALID_EXTS);
765
-         		foreach($validEditorExts as $k=>$v)
765
+         		foreach ($validEditorExts as $k=>$v)
766 766
          		{
767
-         			if(array_search($v, $validUploadExts) === false)
767
+         			if (array_search($v, $validUploadExts) === false)
768 768
          			{
769 769
          				unset($validEditorExts[$k]);
770 770
          			}
771 771
          		}        		
772 772
          	}
773
-         	if(CONFIG_UPLOAD_INVALID_EXTS)
773
+         	if (CONFIG_UPLOAD_INVALID_EXTS)
774 774
          	{//exlcude those exists in CONFIG_UPLOAD_INVALID_EXTS
775 775
          		$invalidUploadExts = explode(',', CONFIG_UPLOAD_INVALID_EXTS);
776
-         		foreach($validEditorExts as $k=>$v)
776
+         		foreach ($validEditorExts as $k=>$v)
777 777
          		{
778
-         			if(array_search($v, $invalidUploadExts) !== false)
778
+         			if (array_search($v, $invalidUploadExts) !== false)
779 779
          			{
780 780
          				unset($validEditorExts[$k]);
781 781
          			}
@@ -791,24 +791,24 @@  discard block
 block discarded – undo
791 791
      * @param string $string
792 792
      * @return booolean
793 793
      */
794
-        function isValidPattern( $pattern, $string)
794
+        function isValidPattern($pattern, $string)
795 795
         {
796
-            if(($pattern)=== '')
796
+            if (($pattern) === '')
797 797
             {
798 798
                 return true;
799 799
             }
800
-            else if (strpos($pattern,",")!==false)
800
+            else if (strpos($pattern, ",") !== false)
801 801
             {
802 802
                 $regExps = explode(',', $pattern);
803 803
                 foreach ($regExps as $regExp => $value)
804 804
                 {
805
-                    if(eregi($value, $string))
805
+                    if (eregi($value, $string))
806 806
                     {
807 807
                         return true;
808 808
                     }
809 809
                 }               
810 810
             }
811
-            else if(eregi($pattern, $string))
811
+            else if (eregi($pattern, $string))
812 812
             {
813 813
                 return true;
814 814
             }
@@ -824,24 +824,24 @@  discard block
 block discarded – undo
824 824
      * @param string $string
825 825
      * @return booolean
826 826
      */
827
-        function isInvalidPattern( $pattern, $string)
827
+        function isInvalidPattern($pattern, $string)
828 828
         {
829
-            if(($pattern)=== '')
829
+            if (($pattern) === '')
830 830
             {
831 831
                 return false;
832 832
             }
833
-            else if (strpos($pattern,",")!==false)
833
+            else if (strpos($pattern, ",") !== false)
834 834
             {
835 835
                 $regExps = explode(',', $pattern);
836 836
                 foreach ($regExps as $regExp => $value)
837 837
                 {
838
-                    if(eregi($value, $string))
838
+                    if (eregi($value, $string))
839 839
                     {
840 840
                         return true;
841 841
                     }
842 842
                 }               
843 843
             }
844
-            else if(eregi($pattern, $string))
844
+            else if (eregi($pattern, $string))
845 845
             {
846 846
                 return true;
847 847
             }
@@ -855,20 +855,20 @@  discard block
 block discarded – undo
855 855
 		 *
856 856
 		 * @param string $fileName
857 857
 		 */
858
-		function shortenFileName($fileName, $maxLeng=17, $indicate = '...')
858
+		function shortenFileName($fileName, $maxLeng = 17, $indicate = '...')
859 859
 		{
860
-			if(strlen($fileName) > $maxLeng)
860
+			if (strlen($fileName) > $maxLeng)
861 861
 			{
862
-				$fileName = substr($fileName, 0, $maxLeng - strlen($indicate)) . $indicate;
862
+				$fileName = substr($fileName, 0, $maxLeng - strlen($indicate)).$indicate;
863 863
 			}
864 864
 			return $fileName;
865 865
 			
866 866
 		}
867 867
 		if (!function_exists('mime_content_type')) 
868 868
 		{
869
-		   function mime_content_type ( $f )
869
+		   function mime_content_type($f)
870 870
 		   {
871
-		       return trim ( @exec ('file -bi ' . escapeshellarg ( $f ) ) ) ;
871
+		       return trim(@exec('file -bi '.escapeshellarg($f)));
872 872
 		   }
873 873
 		}		
874 874
 		
@@ -881,118 +881,118 @@  discard block
 block discarded – undo
881 881
          function isListingDocument($path)
882 882
          {
883 883
          	$file = basename($path);
884
-         	if(CONFIG_SYS_PATTERN_FORMAT == 'list')
884
+         	if (CONFIG_SYS_PATTERN_FORMAT == 'list')
885 885
          	{// comma delimited vague file/folder name
886 886
 
887 887
 
888 888
 
889 889
 			    		
890
-      			if(is_dir($path))
890
+      			if (is_dir($path))
891 891
       			{
892 892
  				$includeDir = trimlrm(CONFIG_SYS_INC_DIR_PATTERN);
893 893
 				$excludeDir = trimlrm(CONFIG_SYS_EXC_DIR_PATTERN);     				
894 894
 				$found_includeDir = strpos($includeDir, $file);
895 895
 				$found_excludeDir = strpos($excludeDir, $file);      				
896
-      				if((!CONFIG_SYS_INC_DIR_PATTERN || (!($found_includeDir === FALSE))) && (!CONFIG_SYS_EXC_DIR_PATTERN || (($found_excludeDir === FALSE))))
896
+      				if ((!CONFIG_SYS_INC_DIR_PATTERN || (!($found_includeDir === FALSE))) && (!CONFIG_SYS_EXC_DIR_PATTERN || (($found_excludeDir === FALSE))))
897 897
       				{
898 898
       					return true;
899
-      				}else 
899
+      				} else 
900 900
       				{
901 901
       					return false;
902 902
       				}
903
-      			}elseif(is_file($path))
903
+      			}elseif (is_file($path))
904 904
       			{
905 905
 				$includeFile = trimlrm(CONFIG_SYS_INC_FILE_PATTERN);
906 906
 				$excludeFile = trimlrm(CONFIG_SYS_EXC_FILE_PATTERN);            				
907 907
 				$found_includeFile = strpos($includeFile, $file);
908 908
 				$found_excludeFile = strpos($excludeFile, $file);	      				
909
-      				if((!CONFIG_SYS_INC_FILE_PATTERN || (!($found_includeFile === FALSE))) && (!CONFIG_SYS_EXC_FILE_PATTERN ||   (($found_excludeFile === FALSE))))
909
+      				if ((!CONFIG_SYS_INC_FILE_PATTERN || (!($found_includeFile === FALSE))) && (!CONFIG_SYS_EXC_FILE_PATTERN || (($found_excludeFile === FALSE))))
910 910
       				{
911 911
       					return true;
912
-      				}else 
912
+      				} else 
913 913
       				{
914 914
       					return false;
915 915
       				}
916 916
       			}
917
-         	}elseif(CONFIG_SYS_PATTERN_FORMAT == 'csv')
917
+         	}elseif (CONFIG_SYS_PATTERN_FORMAT == 'csv')
918 918
          	{//comma delimited file/folder name
919 919
          		
920
-         		if(is_dir($path))
920
+         		if (is_dir($path))
921 921
          		{
922 922
          		
923 923
 	 				$includeDir = trimlrm(CONFIG_SYS_INC_DIR_PATTERN);
924 924
 					$excludeDir = trimlrm(CONFIG_SYS_EXC_DIR_PATTERN);
925 925
 					        
926
-					if(!empty($includeDir) && !empty($excludeDir))
926
+					if (!empty($includeDir) && !empty($excludeDir))
927 927
 					{
928 928
 						
929 929
 						$validDir = explode(',', $includeDir);
930 930
 						
931 931
 						$invalidDir = explode(",", $excludeDir);
932 932
 
933
-						if(array_search(basename($path), $validDir) !== false && array_search(basename($path), $invalidDir) === false)
933
+						if (array_search(basename($path), $validDir) !== false && array_search(basename($path), $invalidDir) === false)
934 934
 						{
935 935
 							return true;
936
-						}else 
936
+						} else 
937 937
 						{
938 938
 							return false;
939 939
 						}
940
-					}elseif(!empty($includeDir))
940
+					}elseif (!empty($includeDir))
941 941
 					{
942 942
 						$validDir = explode(',', $includeDir);
943
-						if(array_search(basename($path), $validDir) !== false)
943
+						if (array_search(basename($path), $validDir) !== false)
944 944
 						{
945 945
 							return true;
946
-						}else 
946
+						} else 
947 947
 						{
948 948
 							return false;
949 949
 						}
950 950
 						
951
-					}elseif(!empty($excludeFile))
951
+					}elseif (!empty($excludeFile))
952 952
 					{
953 953
 						$invalidDir = explode(",", $excludeDir);
954
-						if(array_search(basename($path), $invalidDir) === false)
954
+						if (array_search(basename($path), $invalidDir) === false)
955 955
 						{
956 956
 							return true;
957
-						}else 
957
+						} else 
958 958
 						{
959 959
 							return false;
960 960
 						}
961 961
 					}
962 962
 					return true;
963 963
 					
964
-         		}elseif(is_file($path))
964
+         		}elseif (is_file($path))
965 965
          		{
966 966
 				$includeFile = trimlrm(CONFIG_SYS_INC_FILE_PATTERN);
967 967
 				$excludeFile = trimlrm(CONFIG_SYS_EXC_FILE_PATTERN);   
968
-				if(!empty($includeFile) && !empty($excludeFile))
968
+				if (!empty($includeFile) && !empty($excludeFile))
969 969
 				{
970 970
 					$validFile = explode(',', $includeFile);
971 971
 					$invalidFile = explode(',', $excludeFile);
972
-					if(array_search(basename($path), $validFile) !== false && array_search(basename($path), $invalidFile) === false)
972
+					if (array_search(basename($path), $validFile) !== false && array_search(basename($path), $invalidFile) === false)
973 973
 					{
974 974
 						return true;
975
-					}else 
975
+					} else 
976 976
 					{
977 977
 						return false;
978 978
 					}
979
-				}elseif(!empty($includeFile))
979
+				}elseif (!empty($includeFile))
980 980
 				{
981 981
 					$validFile = explode(',', $includeFile);
982
-					if(array_search(basename($path), $validFile) !== false)
982
+					if (array_search(basename($path), $validFile) !== false)
983 983
 					{
984 984
 						return true;
985
-					}else 
985
+					} else 
986 986
 					{
987 987
 						return false;
988 988
 					}
989
-				}elseif(!empty($excludeFile))
989
+				}elseif (!empty($excludeFile))
990 990
 				{
991 991
 					$invalidFile = explode(',', $excludeFile);
992
-					if(array_search(basename($path), $invalidFile) === false)
992
+					if (array_search(basename($path), $invalidFile) === false)
993 993
 					{
994 994
 						return true;
995
-					}else 
995
+					} else 
996 996
 					{
997 997
 						return false;
998 998
 					}
@@ -1002,22 +1002,22 @@  discard block
 block discarded – undo
1002 1002
          	}
1003 1003
          	else 
1004 1004
          	{//regular expression
1005
-	          	if(is_dir($path) )
1005
+	          	if (is_dir($path))
1006 1006
 	         	{
1007
-	         		if(isValidPattern(CONFIG_SYS_INC_DIR_PATTERN, $path) && !isInvalidPattern(CONFIG_SYS_EXC_DIR_PATTERN, $path))
1007
+	         		if (isValidPattern(CONFIG_SYS_INC_DIR_PATTERN, $path) && !isInvalidPattern(CONFIG_SYS_EXC_DIR_PATTERN, $path))
1008 1008
 	         		{
1009 1009
 	         			 return true;	
1010
-	         		}else 
1010
+	         		} else 
1011 1011
 	         		{
1012 1012
 	         			return false;
1013 1013
 	         		}
1014 1014
 	         	
1015
-	         	}elseif(is_file($path))
1015
+	         	}elseif (is_file($path))
1016 1016
 	         	{
1017
-	         		if(isValidPattern(CONFIG_SYS_INC_FILE_PATTERN, $path) && !isInvalidPattern(CONFIG_SYS_EXC_FILE_PATTERN, $path)  )
1017
+	         		if (isValidPattern(CONFIG_SYS_INC_FILE_PATTERN, $path) && !isInvalidPattern(CONFIG_SYS_EXC_FILE_PATTERN, $path))
1018 1018
 	         		{
1019 1019
 	         			return true;
1020
-	         		}else 
1020
+	         		} else 
1021 1021
 	         		{
1022 1022
 	         			return false;
1023 1023
 	         		}
@@ -1033,20 +1033,20 @@  discard block
 block discarded – undo
1033 1033
 		 * @param string $path
1034 1034
 		 * 
1035 1035
 		 */
1036
-		function downloadFile($path, $newFileName=null)
1036
+		function downloadFile($path, $newFileName = null)
1037 1037
 		{
1038
-				if(file_exists($path) && is_file($path))
1038
+				if (file_exists($path) && is_file($path))
1039 1039
 				{	
1040 1040
 					$mimeContentType = 'application/octet-stream';
1041
-					if(function_exists('finfo_open'))
1041
+					if (function_exists('finfo_open'))
1042 1042
 					{
1043
-						if(($fp = @finfo_open($path)))
1043
+						if (($fp = @finfo_open($path)))
1044 1044
 						{
1045 1045
 							$mimeContentType = @finfo_file($fp, basename($path));
1046 1046
 							@finfo_close($fp);
1047 1047
 						}
1048 1048
 						
1049
-					}elseif(($temMimeContentType = @mime_content_type($path)) && !empty($temMimeContentType))
1049
+					}elseif (($temMimeContentType = @mime_content_type($path)) && !empty($temMimeContentType))
1050 1050
 					{
1051 1051
 						$mimeContentType = $temMimeContentType;
1052 1052
 					}
@@ -1057,15 +1057,15 @@  discard block
 block discarded – undo
1057 1057
 
1058 1058
 			// START ANDR� SILVA DOWNLOAD CODE
1059 1059
 			// required for IE, otherwise Content-disposition is ignored
1060
-			if(ini_get('zlib.output_compression'))
1060
+			if (ini_get('zlib.output_compression'))
1061 1061
 			  ini_set('zlib.output_compression', 'Off');
1062 1062
 			header("Pragma: public"); // required
1063 1063
 			header("Expires: 0");
1064 1064
 			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
1065
-			header("Cache-Control: private",false); // required for certain browsers 
1066
-			header("Content-Type: " . $mimeContentType );
1065
+			header("Cache-Control: private", false); // required for certain browsers 
1066
+			header("Content-Type: ".$mimeContentType);
1067 1067
 			// change, added quotes to allow spaces in filenames, by Rajkumar Singh
1068
-			header("Content-Disposition: attachment; filename=\"".(is_null($newFileName)?basename($path):$newFileName)."\";" );
1068
+			header("Content-Disposition: attachment; filename=\"".(is_null($newFileName) ? basename($path) : $newFileName)."\";");
1069 1069
 			header("Content-Transfer-Encoding: binary");
1070 1070
 			header("Content-Length: ".filesize($path));
1071 1071
 		
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
    * @param string $whiteSpaceChars
1084 1084
    * @return string
1085 1085
    */
1086
-  function trimlrm ($hayStack, $whiteSpaceChars="\t\n\r\0\x0B")
1086
+  function trimlrm($hayStack, $whiteSpaceChars = "\t\n\r\0\x0B")
1087 1087
   {
1088 1088
   	return str_replace($whiteSpaceChars, '', trim($hayStack));
1089 1089
   }		
@@ -1097,13 +1097,13 @@  discard block
 block discarded – undo
1097 1097
   function getParentFolderPath($path)
1098 1098
   {
1099 1099
   	$realPath = addTrailingSlash(backslashToSlash(getRealPath($path)));
1100
-  	$parentRealPath =  addTrailingSlash(backslashToSlash(dirname($realPath)));
1100
+  	$parentRealPath = addTrailingSlash(backslashToSlash(dirname($realPath)));
1101 1101
   	$differentPath = addTrailingSlash(substr($realPath, strlen($parentRealPath)));
1102 1102
   	$parentPath = substr($path, 0, strlen(addTrailingSlash(backslashToSlash($path))) - strlen($differentPath));
1103
-  	if(isUnderRoot($parentPath))
1103
+  	if (isUnderRoot($parentPath))
1104 1104
   	{
1105 1105
   		return $parentPath;
1106
-  	}else 
1106
+  	} else 
1107 1107
   	{
1108 1108
   		return CONFIG_SYS_DEFAULT_PATH;
1109 1109
   	}
@@ -1113,37 +1113,37 @@  discard block
 block discarded – undo
1113 1113
   {
1114 1114
   		$folderPathIndex = 'path';
1115 1115
   		$lastVisitedFolderPathIndex = 'ajax_last_visited_folder';
1116
-		if(isset($_GET[$folderPathIndex]) && file_exists($_GET[$folderPathIndex]) && !is_file($_GET[$folderPathIndex]) )
1116
+		if (isset($_GET[$folderPathIndex]) && file_exists($_GET[$folderPathIndex]) && !is_file($_GET[$folderPathIndex]))
1117 1117
 		{
1118 1118
 			$currentFolderPath = $_GET[$folderPathIndex];
1119 1119
 		}
1120
-		elseif(isset($_SESSION[$lastVisitedFolderPathIndex]) && file_exists($_SESSION[$lastVisitedFolderPathIndex]) && !is_file($_SESSION[$lastVisitedFolderPathIndex]))
1120
+		elseif (isset($_SESSION[$lastVisitedFolderPathIndex]) && file_exists($_SESSION[$lastVisitedFolderPathIndex]) && !is_file($_SESSION[$lastVisitedFolderPathIndex]))
1121 1121
 		{
1122 1122
 			$currentFolderPath = $_SESSION[$lastVisitedFolderPathIndex];
1123
-		}else
1123
+		} else
1124 1124
 		{
1125 1125
 			$currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
1126 1126
 		}
1127 1127
 		
1128
-		$currentFolderPath = (isUnderRoot($currentFolderPath)?backslashToSlash((addTrailingSlash($currentFolderPath))):CONFIG_SYS_DEFAULT_PATH);
1128
+		$currentFolderPath = (isUnderRoot($currentFolderPath) ? backslashToSlash((addTrailingSlash($currentFolderPath))) : CONFIG_SYS_DEFAULT_PATH);
1129 1129
 		
1130 1130
 		//keep track of this folder path in session 
1131 1131
 		$_SESSION[$lastVisitedFolderPathIndex] = $currentFolderPath;
1132 1132
 		
1133 1133
 
1134
-		if(!file_exists($currentFolderPath))
1134
+		if (!file_exists($currentFolderPath))
1135 1135
 		{
1136
-			die(ERR_FOLDER_NOT_FOUND . $currentFolderPath);
1136
+			die(ERR_FOLDER_NOT_FOUND.$currentFolderPath);
1137 1137
 		}  	
1138 1138
   }
1139 1139
   
1140
-       if(!function_exists("imagerotate"))
1140
+       if (!function_exists("imagerotate"))
1141 1141
         {
1142
-            function imagerotate($src_img, $angle, $bicubic=false)
1142
+            function imagerotate($src_img, $angle, $bicubic = false)
1143 1143
             {
1144 1144
     // convert degrees to radians
1145 1145
     
1146
-    $angle =  (360 - $angle) + 180;
1146
+    $angle = (360 - $angle) + 180;
1147 1147
     $angle = deg2rad($angle);
1148 1148
    
1149 1149
     $src_x = imagesx($src_img);
@@ -1162,13 +1162,13 @@  discard block
 block discarded – undo
1162 1162
     for ($y = 0; $y < $src_y; $y++) {
1163 1163
       for ($x = 0; $x < $src_x; $x++) {
1164 1164
     // rotate...
1165
-    $old_x = (($center_x-$x) * $cosangle + ($center_y-$y) * $sinangle)
1165
+    $old_x = (($center_x - $x)*$cosangle + ($center_y - $y)*$sinangle)
1166 1166
       + $center_x;
1167
-    $old_y = (($center_y-$y) * $cosangle - ($center_x-$x) * $sinangle)
1167
+    $old_y = (($center_y - $y)*$cosangle - ($center_x - $x)*$sinangle)
1168 1168
       + $center_y;
1169 1169
    
1170
-    if ( $old_x >= 0 && $old_x < $src_x
1171
-         && $old_y >= 0 && $old_y < $src_y ) {
1170
+    if ($old_x >= 0 && $old_x < $src_x
1171
+         && $old_y >= 0 && $old_y < $src_y) {
1172 1172
       if ($bicubic == true) {
1173 1173
         $sY  = $old_y + 1;
1174 1174
         $siY  = $old_y;
@@ -1182,11 +1182,11 @@  discard block
 block discarded – undo
1182 1182
         $c3 = imagecolorsforindex($src_img, imagecolorat($src_img, $siX2, $siY2));
1183 1183
         $c4 = imagecolorsforindex($src_img, imagecolorat($src_img, $siX2, $siY));
1184 1184
        
1185
-        $r = ($c1['red']  + $c2['red']  + $c3['red']  + $c4['red']  ) << 14;
1185
+        $r = ($c1['red'] + $c2['red'] + $c3['red'] + $c4['red']) << 14;
1186 1186
         $g = ($c1['green'] + $c2['green'] + $c3['green'] + $c4['green']) << 6;
1187
-        $b = ($c1['blue']  + $c2['blue']  + $c3['blue']  + $c4['blue'] ) >> 2;
1188
-        $a = ($c1['alpha']  + $c2['alpha']  + $c3['alpha']  + $c4['alpha'] ) >> 2;
1189
-        $color = imagecolorallocatealpha($src_img, $r,$g,$b,$a);
1187
+        $b = ($c1['blue'] + $c2['blue'] + $c3['blue'] + $c4['blue']) >> 2;
1188
+        $a = ($c1['alpha'] + $c2['alpha'] + $c3['alpha'] + $c4['alpha']) >> 2;
1189
+        $color = imagecolorallocatealpha($src_img, $r, $g, $b, $a);
1190 1190
       } else {
1191 1191
         $color = imagecolorat($src_img, $old_x, $old_y);
1192 1192
       }
Please login to merge, or discard this patch.
Braces   +59 added lines, -61 removed lines patch added patch discarded remove patch
@@ -108,14 +108,14 @@  discard block
 block discarded – undo
108 108
 			if(array_search(strtolower(getFileExt($filePath)), $validExts) !== false)
109 109
 			{
110 110
 				return true;
111
-			}else 
111
+			} else 
112 112
 			{
113 113
 				return false;
114 114
 			}
115
-		}elseif(array_search(strtolower(getFileExt($filePath)), $invalidExts) === false)
115
+		} elseif(array_search(strtolower(getFileExt($filePath)), $invalidExts) === false)
116 116
 		{
117 117
 			return true;
118
-		}else 
118
+		} else 
119 119
 		{
120 120
 			return false;
121 121
 		}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 			if(strpos($baseUrl, "?") !== false)
271 271
 			{
272 272
 				$output .= "&" . $extra;
273
-			}else
273
+			} else
274 274
 			{
275 275
 				$output .= "?" . $extra;
276 276
 			}			
@@ -369,14 +369,14 @@  discard block
 block discarded – undo
369 369
         	{
370 370
         		$thumbnailWidth =$originaleImageWidth;
371 371
         		$thumbnailHeight = $originalImageHeight;
372
-        	}elseif($thumbnailWidth < 1)
372
+        	} elseif($thumbnailWidth < 1)
373 373
         	{
374 374
         		$thumbnailWidth = floor($thumbnailHeight / $originalImageHeight * $originaleImageWidth);
375 375
 
376
-        	}elseif($thumbnailHeight < 1)
376
+        	} elseif($thumbnailHeight < 1)
377 377
         	{
378 378
         		$thumbnailHeight = floor($thumbnailWidth / $originaleImageWidth * $originalImageHeight);
379
-        	}else
379
+        	} else
380 380
         	{
381 381
         		$scale = min($thumbnailWidth/$originaleImageWidth, $thumbnailHeight/$originalImageHeight);
382 382
 				$thumbnailWidth = floor($scale*$originaleImageWidth);
@@ -395,8 +395,9 @@  discard block
 block discarded – undo
395 395
  * @return string
396 396
  */
397 397
 function getAbsPath($value) {
398
-	if (substr($value, 0, 1) == "/")
399
-		return slashToBackslash(DIR_AJAX_ROOT . $value);
398
+	if (substr($value, 0, 1) == "/") {
399
+			return slashToBackslash(DIR_AJAX_ROOT . $value);
400
+	}
400 401
 
401 402
 	return slashToBackslash(dirname(__FILE__) . "/" . $value);
402 403
 }
@@ -414,7 +415,7 @@  discard block
 block discarded – undo
414 415
 		if(false !== ($index = strrpos($value, "/")) )
415 416
 		{
416 417
 			return substr($value, $index + 1);
417
-		}else
418
+		} else
418 419
 		{
419 420
 			return $value;
420 421
 		}
@@ -438,7 +439,9 @@  discard block
 block discarded – undo
438 439
     $path=explode('/', $path);
439 440
     $newpath=array();
440 441
     for ($i=0; $i<sizeof($path); $i++) {
441
-        if ($path[$i]==='' || $path[$i]==='.') continue;
442
+        if ($path[$i]==='' || $path[$i]==='.') {
443
+            continue;
444
+        }
442 445
            if ($path[$i]==='..') {
443 446
               array_pop($newpath);
444 447
               continue;
@@ -451,9 +454,10 @@  discard block
 block discarded – undo
451 454
     // check then return valid path or filename
452 455
     if (file_exists($finalpath)) {
453 456
         return ($finalpath);
457
+    } else {
458
+        return FALSE;
459
+    }
454 460
     }
455
-    else return FALSE;
456
-}
457 461
 	/**
458 462
 	 * calcuate realpath for a relative path
459 463
 	 *
@@ -466,7 +470,7 @@  discard block
 block discarded – undo
466 470
  	 if(($path = realpath($value)) && $path != $value)
467 471
  	 {
468 472
  	 	$output = $path;
469
- 	 }else 
473
+ 	 } else 
470 474
  	 {
471 475
  	 	$output = myRealPath($value);
472 476
  	 }
@@ -492,7 +496,7 @@  discard block
 block discarded – undo
492 496
 		if ($pos !== false )
493 497
 		{
494 498
 			$output  = $urlprefix . substr($value, $pos + strlen($wwwroot)) . $urlsuffix;
495
-		}else 
499
+		} else 
496 500
 		{
497 501
 			$output = $value;
498 502
 		}
@@ -536,13 +540,13 @@  discard block
 block discarded – undo
536 540
 	if ($size > 1048576)
537 541
 	{
538 542
 		return round($size / 1048576, 1) . " MB";
539
-	}elseif ($size > 1024)
543
+	} elseif ($size > 1024)
540 544
 	{
541 545
 		return round($size / 1024, 1) . " KB";
542
-	}elseif($size == '')
546
+	} elseif($size == '')
543 547
 	{
544 548
 		return $size;
545
-	}else
549
+	} else
546 550
 	{
547 551
 		return $size . " b";
548 552
 	}	
@@ -581,15 +585,15 @@  discard block
 block discarded – undo
581 585
 		{
582 586
 
583 587
 			return $output;
584
-		}elseif(isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["SCRIPT_FILENAME"]) && ($output = str_replace(backslashToSlash($_SERVER["SCRIPT_NAME"]), '', backslashToSlash($_SERVER["SCRIPT_FILENAME"]))) && is_dir($output))
588
+		} elseif(isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["SCRIPT_FILENAME"]) && ($output = str_replace(backslashToSlash($_SERVER["SCRIPT_NAME"]), '', backslashToSlash($_SERVER["SCRIPT_FILENAME"]))) && is_dir($output))
585 589
 		{
586 590
 
587 591
 			return slashToBackslash($output);
588
-		}elseif(isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["PATH_TRANSLATED"]) && ($output = str_replace(backslashToSlash($_SERVER["SCRIPT_NAME"]), '', str_replace("//", "/", backslashToSlash($_SERVER["PATH_TRANSLATED"])))) && is_dir($output))
592
+		} elseif(isset($_SERVER["SCRIPT_NAME"]) && isset($_SERVER["PATH_TRANSLATED"]) && ($output = str_replace(backslashToSlash($_SERVER["SCRIPT_NAME"]), '', str_replace("//", "/", backslashToSlash($_SERVER["PATH_TRANSLATED"])))) && is_dir($output))
589 593
 		{
590 594
 
591 595
 			return $output;
592
-		}else 
596
+		} else 
593 597
 		{
594 598
 			return '';
595 599
 		}	
@@ -678,14 +682,13 @@  discard block
 block discarded – undo
678 682
     if(intval($output) < 0)
679 683
     {//unlimited
680 684
     	$output = 999999999999999999;
681
-    }
682
-    elseif(strpos('g', strtolower($output)) !== false)
685
+    } elseif(strpos('g', strtolower($output)) !== false)
683 686
     {
684 687
     	$output = intval($output) * 1024 * 1024 * 1024;
685
-    }elseif(strpos('k', strtolower($output)) !== false)
688
+    } elseif(strpos('k', strtolower($output)) !== false)
686 689
     {
687 690
     	$output = intval($output) * 1024 ;
688
-    }else
691
+    } else
689 692
     {
690 693
     	$output = intval($output) * 1024 * 1024;
691 694
     }
@@ -733,7 +736,7 @@  discard block
 block discarded – undo
733 736
                                                					
734 737
                                                         $outputs[$prefixNumber . $indexNumber . "." . $count . $prefixName . $file] = $newPath;
735 738
                                                         getFolderListing($newPath,  $prefixNumber . $indexNumber . "." . $count , $prefixNumber, $prefixName, $outputs);                                                 
736
-                                               }else 
739
+                                               } else 
737 740
                                                {//this is root folder
738 741
 
739 742
                                                         $outputs[$count . $prefixName . $file] = $newPath;
@@ -796,8 +799,7 @@  discard block
 block discarded – undo
796 799
             if(($pattern)=== '')
797 800
             {
798 801
                 return true;
799
-            }
800
-            else if (strpos($pattern,",")!==false)
802
+            } else if (strpos($pattern,",")!==false)
801 803
             {
802 804
                 $regExps = explode(',', $pattern);
803 805
                 foreach ($regExps as $regExp => $value)
@@ -807,8 +809,7 @@  discard block
 block discarded – undo
807 809
                         return true;
808 810
                     }
809 811
                 }               
810
-            }
811
-            else if(eregi($pattern, $string))
812
+            } else if(eregi($pattern, $string))
812 813
             {
813 814
                 return true;
814 815
             }
@@ -829,8 +830,7 @@  discard block
 block discarded – undo
829 830
             if(($pattern)=== '')
830 831
             {
831 832
                 return false;
832
-            }
833
-            else if (strpos($pattern,",")!==false)
833
+            } else if (strpos($pattern,",")!==false)
834 834
             {
835 835
                 $regExps = explode(',', $pattern);
836 836
                 foreach ($regExps as $regExp => $value)
@@ -840,8 +840,7 @@  discard block
 block discarded – undo
840 840
                         return true;
841 841
                     }
842 842
                 }               
843
-            }
844
-            else if(eregi($pattern, $string))
843
+            } else if(eregi($pattern, $string))
845 844
             {
846 845
                 return true;
847 846
             }
@@ -896,11 +895,11 @@  discard block
 block discarded – undo
896 895
       				if((!CONFIG_SYS_INC_DIR_PATTERN || (!($found_includeDir === FALSE))) && (!CONFIG_SYS_EXC_DIR_PATTERN || (($found_excludeDir === FALSE))))
897 896
       				{
898 897
       					return true;
899
-      				}else 
898
+      				} else 
900 899
       				{
901 900
       					return false;
902 901
       				}
903
-      			}elseif(is_file($path))
902
+      			} elseif(is_file($path))
904 903
       			{
905 904
 				$includeFile = trimlrm(CONFIG_SYS_INC_FILE_PATTERN);
906 905
 				$excludeFile = trimlrm(CONFIG_SYS_EXC_FILE_PATTERN);            				
@@ -909,12 +908,12 @@  discard block
 block discarded – undo
909 908
       				if((!CONFIG_SYS_INC_FILE_PATTERN || (!($found_includeFile === FALSE))) && (!CONFIG_SYS_EXC_FILE_PATTERN ||   (($found_excludeFile === FALSE))))
910 909
       				{
911 910
       					return true;
912
-      				}else 
911
+      				} else 
913 912
       				{
914 913
       					return false;
915 914
       				}
916 915
       			}
917
-         	}elseif(CONFIG_SYS_PATTERN_FORMAT == 'csv')
916
+         	} elseif(CONFIG_SYS_PATTERN_FORMAT == 'csv')
918 917
          	{//comma delimited file/folder name
919 918
          		
920 919
          		if(is_dir($path))
@@ -933,35 +932,35 @@  discard block
 block discarded – undo
933 932
 						if(array_search(basename($path), $validDir) !== false && array_search(basename($path), $invalidDir) === false)
934 933
 						{
935 934
 							return true;
936
-						}else 
935
+						} else 
937 936
 						{
938 937
 							return false;
939 938
 						}
940
-					}elseif(!empty($includeDir))
939
+					} elseif(!empty($includeDir))
941 940
 					{
942 941
 						$validDir = explode(',', $includeDir);
943 942
 						if(array_search(basename($path), $validDir) !== false)
944 943
 						{
945 944
 							return true;
946
-						}else 
945
+						} else 
947 946
 						{
948 947
 							return false;
949 948
 						}
950 949
 						
951
-					}elseif(!empty($excludeFile))
950
+					} elseif(!empty($excludeFile))
952 951
 					{
953 952
 						$invalidDir = explode(",", $excludeDir);
954 953
 						if(array_search(basename($path), $invalidDir) === false)
955 954
 						{
956 955
 							return true;
957
-						}else 
956
+						} else 
958 957
 						{
959 958
 							return false;
960 959
 						}
961 960
 					}
962 961
 					return true;
963 962
 					
964
-         		}elseif(is_file($path))
963
+         		} elseif(is_file($path))
965 964
          		{
966 965
 				$includeFile = trimlrm(CONFIG_SYS_INC_FILE_PATTERN);
967 966
 				$excludeFile = trimlrm(CONFIG_SYS_EXC_FILE_PATTERN);   
@@ -972,52 +971,51 @@  discard block
 block discarded – undo
972 971
 					if(array_search(basename($path), $validFile) !== false && array_search(basename($path), $invalidFile) === false)
973 972
 					{
974 973
 						return true;
975
-					}else 
974
+					} else 
976 975
 					{
977 976
 						return false;
978 977
 					}
979
-				}elseif(!empty($includeFile))
978
+				} elseif(!empty($includeFile))
980 979
 				{
981 980
 					$validFile = explode(',', $includeFile);
982 981
 					if(array_search(basename($path), $validFile) !== false)
983 982
 					{
984 983
 						return true;
985
-					}else 
984
+					} else 
986 985
 					{
987 986
 						return false;
988 987
 					}
989
-				}elseif(!empty($excludeFile))
988
+				} elseif(!empty($excludeFile))
990 989
 				{
991 990
 					$invalidFile = explode(',', $excludeFile);
992 991
 					if(array_search(basename($path), $invalidFile) === false)
993 992
 					{
994 993
 						return true;
995
-					}else 
994
+					} else 
996 995
 					{
997 996
 						return false;
998 997
 					}
999 998
 				}
1000 999
 				return true;
1001 1000
          		}
1002
-         	}
1003
-         	else 
1001
+         	} else 
1004 1002
          	{//regular expression
1005 1003
 	          	if(is_dir($path) )
1006 1004
 	         	{
1007 1005
 	         		if(isValidPattern(CONFIG_SYS_INC_DIR_PATTERN, $path) && !isInvalidPattern(CONFIG_SYS_EXC_DIR_PATTERN, $path))
1008 1006
 	         		{
1009 1007
 	         			 return true;	
1010
-	         		}else 
1008
+	         		} else 
1011 1009
 	         		{
1012 1010
 	         			return false;
1013 1011
 	         		}
1014 1012
 	         	
1015
-	         	}elseif(is_file($path))
1013
+	         	} elseif(is_file($path))
1016 1014
 	         	{
1017 1015
 	         		if(isValidPattern(CONFIG_SYS_INC_FILE_PATTERN, $path) && !isInvalidPattern(CONFIG_SYS_EXC_FILE_PATTERN, $path)  )
1018 1016
 	         		{
1019 1017
 	         			return true;
1020
-	         		}else 
1018
+	         		} else 
1021 1019
 	         		{
1022 1020
 	         			return false;
1023 1021
 	         		}
@@ -1046,7 +1044,7 @@  discard block
 block discarded – undo
1046 1044
 							@finfo_close($fp);
1047 1045
 						}
1048 1046
 						
1049
-					}elseif(($temMimeContentType = @mime_content_type($path)) && !empty($temMimeContentType))
1047
+					} elseif(($temMimeContentType = @mime_content_type($path)) && !empty($temMimeContentType))
1050 1048
 					{
1051 1049
 						$mimeContentType = $temMimeContentType;
1052 1050
 					}
@@ -1057,8 +1055,9 @@  discard block
 block discarded – undo
1057 1055
 
1058 1056
 			// START ANDR� SILVA DOWNLOAD CODE
1059 1057
 			// required for IE, otherwise Content-disposition is ignored
1060
-			if(ini_get('zlib.output_compression'))
1061
-			  ini_set('zlib.output_compression', 'Off');
1058
+			if(ini_get('zlib.output_compression')) {
1059
+						  ini_set('zlib.output_compression', 'Off');
1060
+			}
1062 1061
 			header("Pragma: public"); // required
1063 1062
 			header("Expires: 0");
1064 1063
 			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
@@ -1103,7 +1102,7 @@  discard block
 block discarded – undo
1103 1102
   	if(isUnderRoot($parentPath))
1104 1103
   	{
1105 1104
   		return $parentPath;
1106
-  	}else 
1105
+  	} else 
1107 1106
   	{
1108 1107
   		return CONFIG_SYS_DEFAULT_PATH;
1109 1108
   	}
@@ -1116,11 +1115,10 @@  discard block
 block discarded – undo
1116 1115
 		if(isset($_GET[$folderPathIndex]) && file_exists($_GET[$folderPathIndex]) && !is_file($_GET[$folderPathIndex]) )
1117 1116
 		{
1118 1117
 			$currentFolderPath = $_GET[$folderPathIndex];
1119
-		}
1120
-		elseif(isset($_SESSION[$lastVisitedFolderPathIndex]) && file_exists($_SESSION[$lastVisitedFolderPathIndex]) && !is_file($_SESSION[$lastVisitedFolderPathIndex]))
1118
+		} elseif(isset($_SESSION[$lastVisitedFolderPathIndex]) && file_exists($_SESSION[$lastVisitedFolderPathIndex]) && !is_file($_SESSION[$lastVisitedFolderPathIndex]))
1121 1119
 		{
1122 1120
 			$currentFolderPath = $_SESSION[$lastVisitedFolderPathIndex];
1123
-		}else
1121
+		} else
1124 1122
 		{
1125 1123
 			$currentFolderPath = CONFIG_SYS_DEFAULT_PATH;
1126 1124
 		}
Please login to merge, or discard this patch.
phpmyfaq/inc/Bootstrap.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -220,7 +220,7 @@
 block discarded – undo
220 220
  * @param  mixed  $context  It optionally contains an array of every variable
221 221
  *                          that existed in the scope the error was triggered in.
222 222
  *
223
- * @return bool
223
+ * @return boolean|null
224 224
  */
225 225
 function pmf_error_handler($level, $message, $filename, $line, $context)
226 226
 {
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     $i++;
51 51
 }
52 52
 if (!$foundCurrPath) {
53
-    ini_set('include_path', '.' . PATH_SEPARATOR . ini_get('include_path'));
53
+    ini_set('include_path', '.'.PATH_SEPARATOR.ini_get('include_path'));
54 54
 }
55 55
 
56 56
 //
@@ -63,23 +63,23 @@  discard block
 block discarded – undo
63 63
 //
64 64
 // Check if multisite/multisite.php exist for Multisite support
65 65
 //
66
-if (file_exists(__DIR__ . '/../multisite/multisite.php') && 'cli' !== PHP_SAPI) {
67
-    require __DIR__ . '/../multisite/multisite.php';
66
+if (file_exists(__DIR__.'/../multisite/multisite.php') && 'cli' !== PHP_SAPI) {
67
+    require __DIR__.'/../multisite/multisite.php';
68 68
 }
69 69
 
70 70
 //
71 71
 // The root directory
72 72
 //
73
-if (! defined('PMF_ROOT_DIR')) {
73
+if (!defined('PMF_ROOT_DIR')) {
74 74
     define('PMF_ROOT_DIR', dirname(__DIR__));
75 75
 }
76 76
 
77 77
 //
78 78
 // Read configuration and constants
79 79
 //
80
-if (! defined('PMF_MULTI_INSTANCE_CONFIG_DIR')) {
80
+if (!defined('PMF_MULTI_INSTANCE_CONFIG_DIR')) {
81 81
     // Single instance configuration
82
-    define('PMF_CONFIG_DIR', dirname(__DIR__) . '/config');
82
+    define('PMF_CONFIG_DIR', dirname(__DIR__).'/config');
83 83
 } else {
84 84
     // Multi instance configuration
85 85
     define('PMF_CONFIG_DIR', PMF_MULTI_INSTANCE_CONFIG_DIR);
@@ -88,17 +88,17 @@  discard block
 block discarded – undo
88 88
 //
89 89
 // Check if config/database.php exist -> if not, redirect to installer
90 90
 //
91
-if (!file_exists(PMF_CONFIG_DIR . '/database.php') && !file_exists(PMF_ROOT_DIR . '/inc/data.php')) {
91
+if (!file_exists(PMF_CONFIG_DIR.'/database.php') && !file_exists(PMF_ROOT_DIR.'/inc/data.php')) {
92 92
     header("Location: install/setup.php");
93 93
     exit();
94 94
 }
95 95
 
96
-if (file_exists(PMF_ROOT_DIR . '/inc/data.php')) {
97
-    require PMF_ROOT_DIR . '/inc/data.php';
96
+if (file_exists(PMF_ROOT_DIR.'/inc/data.php')) {
97
+    require PMF_ROOT_DIR.'/inc/data.php';
98 98
 } else {
99
-    require PMF_CONFIG_DIR . '/database.php';
99
+    require PMF_CONFIG_DIR.'/database.php';
100 100
 }
101
-require PMF_CONFIG_DIR . '/constants.php';
101
+require PMF_CONFIG_DIR.'/constants.php';
102 102
 
103 103
 /**
104 104
  * The include directory
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 /**
109 109
  * The directory where the translations reside
110 110
  */
111
-define('PMF_LANGUAGE_DIR', dirname(__DIR__) . '/lang');
111
+define('PMF_LANGUAGE_DIR', dirname(__DIR__).'/lang');
112 112
 
113 113
 //
114 114
 // Setting up PSR-0 autoloader for Symfony Components
115 115
 //
116
-require PMF_INCLUDE_DIR . '/libs/Symfony/Component/ClassLoader/UniversalClassLoader.php';
116
+require PMF_INCLUDE_DIR.'/libs/Symfony/Component/ClassLoader/UniversalClassLoader.php';
117 117
 
118 118
 $loader = new UniversalClassLoader();
119
-$loader->registerNamespace('Symfony', PMF_INCLUDE_DIR . '/libs');
119
+$loader->registerNamespace('Symfony', PMF_INCLUDE_DIR.'/libs');
120 120
 $loader->registerPrefix('PMF_', PMF_INCLUDE_DIR);
121 121
 $loader->register();
122 122
 
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 // We always need a valid session!
143 143
 //
144 144
 ini_set('session.use_only_cookies', 1); // Avoid any PHP version to move sessions on URLs
145
-ini_set('session.auto_start', 0);       // Prevent error to use session_start() if it's active in php.ini
145
+ini_set('session.auto_start', 0); // Prevent error to use session_start() if it's active in php.ini
146 146
 ini_set('session.use_trans_sid', 0);
147 147
 ini_set('url_rewriter.tags', '');
148 148
 
@@ -155,9 +155,9 @@  discard block
 block discarded – undo
155 155
 //
156 156
 // Connect to LDAP server, when LDAP support is enabled
157 157
 //
158
-if ($faqConfig->get('security.ldapSupport') && file_exists(PMF_CONFIG_DIR . '/ldap.php') && extension_loaded('ldap')) {
159
-    require PMF_CONFIG_DIR . '/constants_ldap.php';
160
-    require PMF_CONFIG_DIR . '/ldap.php';
158
+if ($faqConfig->get('security.ldapSupport') && file_exists(PMF_CONFIG_DIR.'/ldap.php') && extension_loaded('ldap')) {
159
+    require PMF_CONFIG_DIR.'/constants_ldap.php';
160
+    require PMF_CONFIG_DIR.'/ldap.php';
161 161
     $faqConfig->setLdapConfig($PMF_LDAP);
162 162
 } else {
163 163
     $ldap = null;
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     define('PMF_ATTACHMENTS_DIR', $confAttachmentsPath);
173 173
 } else {
174 174
     // otherwise build the absolute path
175
-    $tmp = dirname(__DIR__) . DIRECTORY_SEPARATOR . $confAttachmentsPath;
175
+    $tmp = dirname(__DIR__).DIRECTORY_SEPARATOR.$confAttachmentsPath;
176 176
 
177 177
     // Check that nobody is traversing
178 178
     if (0 === strpos((string)$tmp, dirname(__DIR__))) {
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 //
186 186
 // Fix if phpMyFAQ is running behind a proxy server
187 187
 //
188
-if (! isset($_SERVER['HTTP_HOST'])) {
188
+if (!isset($_SERVER['HTTP_HOST'])) {
189 189
     if (isset($_SERVER['HTTP_X_FORWARDED_SERVER'])) {
190 190
         $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_SERVER'];
191 191
     } else {
@@ -196,14 +196,14 @@  discard block
 block discarded – undo
196 196
 //
197 197
 // Fix undefined server variables in Windows IIS & CGI mode
198 198
 //
199
-if (! isset($_SERVER['SCRIPT_NAME'])) {
200
-    if(isset($_SERVER['SCRIPT_FILENAME'])) {
199
+if (!isset($_SERVER['SCRIPT_NAME'])) {
200
+    if (isset($_SERVER['SCRIPT_FILENAME'])) {
201 201
         $_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_FILENAME'];
202
-    } elseif(isset($_SERVER['PATH_TRANSLATED'])) {
202
+    } elseif (isset($_SERVER['PATH_TRANSLATED'])) {
203 203
         $_SERVER['SCRIPT_NAME'] = $_SERVER['PATH_TRANSLATED'];
204
-    } elseif(isset($_SERVER['PATH_INFO'])) {
204
+    } elseif (isset($_SERVER['PATH_INFO'])) {
205 205
         $_SERVER['SCRIPT_NAME'] = $_SERVER['PATH_INFO'];
206
-    } elseif(isset($_SERVER['SCRIPT_URL'])) {
206
+    } elseif (isset($_SERVER['SCRIPT_URL'])) {
207 207
         $_SERVER['SCRIPT_NAME'] = $_SERVER['SCRIPT_URL'];
208 208
     }
209 209
 }
Please login to merge, or discard this patch.