@@ -21,10 +21,17 @@ discard block |
||
| 21 | 21 | * \brief File to load contacts combobox |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
| 25 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
| 24 | +if (! defined('NOTOKENRENEWAL')) { |
|
| 25 | + define('NOTOKENRENEWAL','1'); |
|
| 26 | +} |
|
| 27 | +// Disables token renewal |
|
| 28 | +if (! defined('NOREQUIREMENU')) { |
|
| 29 | + define('NOREQUIREMENU','1'); |
|
| 30 | +} |
|
| 26 | 31 | //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
| 27 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
| 32 | +if (! defined('NOREQUIREAJAX')) { |
|
| 33 | + define('NOREQUIREAJAX','1'); |
|
| 34 | +} |
|
| 28 | 35 | //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
| 29 | 36 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
| 30 | 37 | |
@@ -49,7 +56,9 @@ discard block |
||
| 49 | 56 | $form = new Form($db); |
| 50 | 57 | |
| 51 | 58 | $return=array(); |
| 52 | - if (empty($showempty)) $showempty=0; |
|
| 59 | + if (empty($showempty)) { |
|
| 60 | + $showempty=0; |
|
| 61 | + } |
|
| 53 | 62 | |
| 54 | 63 | $return['value'] = $form->selectcontacts($id,'',$htmlname,$showempty,'','',0,'',true); |
| 55 | 64 | $return['num'] = $form->num; |
@@ -20,10 +20,17 @@ discard block |
||
| 20 | 20 | * \brief File to load vat rates combobox |
| 21 | 21 | */ |
| 22 | 22 | |
| 23 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal |
|
| 24 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); |
|
| 23 | +if (! defined('NOTOKENRENEWAL')) { |
|
| 24 | + define('NOTOKENRENEWAL','1'); |
|
| 25 | +} |
|
| 26 | +// Disables token renewal |
|
| 27 | +if (! defined('NOREQUIREMENU')) { |
|
| 28 | + define('NOREQUIREMENU','1'); |
|
| 29 | +} |
|
| 25 | 30 | //if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); |
| 26 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
| 31 | +if (! defined('NOREQUIREAJAX')) { |
|
| 32 | + define('NOREQUIREAJAX','1'); |
|
| 33 | +} |
|
| 27 | 34 | //if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
| 28 | 35 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); |
| 29 | 36 | |
@@ -55,8 +62,7 @@ discard block |
||
| 55 | 62 | { |
| 56 | 63 | $seller = $mysoc; |
| 57 | 64 | $buyer = $soc; |
| 58 | - } |
|
| 59 | - else |
|
| 65 | + } else |
|
| 60 | 66 | { |
| 61 | 67 | $buyer = $mysoc; |
| 62 | 68 | $seller = $soc; |
@@ -18,13 +18,27 @@ |
||
| 18 | 18 | * Library javascript to enable Browser notifications |
| 19 | 19 | */ |
| 20 | 20 | |
| 21 | -if (!defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); |
|
| 22 | -if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); |
|
| 23 | -if (!defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); |
|
| 24 | -if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); |
|
| 25 | -if (!defined('NOLOGIN')) define('NOLOGIN', 1); |
|
| 26 | -if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); |
|
| 27 | -if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); |
|
| 21 | +if (!defined('NOREQUIREUSER')) { |
|
| 22 | + define('NOREQUIREUSER', '1'); |
|
| 23 | +} |
|
| 24 | +if (!defined('NOREQUIRESOC')) { |
|
| 25 | + define('NOREQUIRESOC', '1'); |
|
| 26 | +} |
|
| 27 | +if (!defined('NOCSRFCHECK')) { |
|
| 28 | + define('NOCSRFCHECK', 1); |
|
| 29 | +} |
|
| 30 | +if (!defined('NOTOKENRENEWAL')) { |
|
| 31 | + define('NOTOKENRENEWAL', 1); |
|
| 32 | +} |
|
| 33 | +if (!defined('NOLOGIN')) { |
|
| 34 | + define('NOLOGIN', 1); |
|
| 35 | +} |
|
| 36 | +if (!defined('NOREQUIREMENU')) { |
|
| 37 | + define('NOREQUIREMENU', 1); |
|
| 38 | +} |
|
| 39 | +if (!defined('NOREQUIREHTML')) { |
|
| 40 | + define('NOREQUIREHTML', 1); |
|
| 41 | +} |
|
| 28 | 42 | |
| 29 | 43 | require_once '../../main.inc.php'; |
| 30 | 44 | |
@@ -23,14 +23,28 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language |
| 25 | 25 | //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
| 26 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
| 26 | +if (! defined('NOREQUIRESOC')) { |
|
| 27 | + define('NOREQUIRESOC','1'); |
|
| 28 | +} |
|
| 27 | 29 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations |
| 28 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); |
|
| 29 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); |
|
| 30 | -if (! defined('NOLOGIN')) define('NOLOGIN',1); |
|
| 31 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); |
|
| 32 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); |
|
| 33 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
| 30 | +if (! defined('NOCSRFCHECK')) { |
|
| 31 | + define('NOCSRFCHECK',1); |
|
| 32 | +} |
|
| 33 | +if (! defined('NOTOKENRENEWAL')) { |
|
| 34 | + define('NOTOKENRENEWAL',1); |
|
| 35 | +} |
|
| 36 | +if (! defined('NOLOGIN')) { |
|
| 37 | + define('NOLOGIN',1); |
|
| 38 | +} |
|
| 39 | +if (! defined('NOREQUIREMENU')) { |
|
| 40 | + define('NOREQUIREMENU',1); |
|
| 41 | +} |
|
| 42 | +if (! defined('NOREQUIREHTML')) { |
|
| 43 | + define('NOREQUIREHTML',1); |
|
| 44 | +} |
|
| 45 | +if (! defined('NOREQUIREAJAX')) { |
|
| 46 | + define('NOREQUIREAJAX','1'); |
|
| 47 | +} |
|
| 34 | 48 | |
| 35 | 49 | session_cache_limiter(FALSE); |
| 36 | 50 | |
@@ -39,8 +53,11 @@ discard block |
||
| 39 | 53 | // Define javascript type |
| 40 | 54 | top_httphead('text/javascript; charset=UTF-8'); |
| 41 | 55 | // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. |
| 42 | -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); |
|
| 43 | -else header('Cache-Control: no-cache'); |
|
| 56 | +if (empty($dolibarr_nocache)) { |
|
| 57 | + header('Cache-Control: max-age=3600, public, must-revalidate'); |
|
| 58 | +} else { |
|
| 59 | + header('Cache-Control: no-cache'); |
|
| 60 | +} |
|
| 44 | 61 | |
| 45 | 62 | |
| 46 | 63 | // Define tradMonths javascript array (we define this in datepicker AND in parent page to avoid errors with IE8) |
@@ -148,4 +165,6 @@ discard block |
||
| 148 | 165 | |
| 149 | 166 | |
| 150 | 167 | <?php |
| 151 | -if (is_object($db)) $db->close(); |
|
| 168 | +if (is_object($db)) { |
|
| 169 | + $db->close(); |
|
| 170 | +} |
|
@@ -23,14 +23,28 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language |
| 25 | 25 | //if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); |
| 26 | -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); |
|
| 26 | +if (! defined('NOREQUIRESOC')) { |
|
| 27 | + define('NOREQUIRESOC','1'); |
|
| 28 | +} |
|
| 27 | 29 | //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations |
| 28 | -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); |
|
| 29 | -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); |
|
| 30 | -if (! defined('NOLOGIN')) define('NOLOGIN',1); |
|
| 31 | -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); |
|
| 32 | -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); |
|
| 33 | -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); |
|
| 30 | +if (! defined('NOCSRFCHECK')) { |
|
| 31 | + define('NOCSRFCHECK',1); |
|
| 32 | +} |
|
| 33 | +if (! defined('NOTOKENRENEWAL')) { |
|
| 34 | + define('NOTOKENRENEWAL',1); |
|
| 35 | +} |
|
| 36 | +if (! defined('NOLOGIN')) { |
|
| 37 | + define('NOLOGIN',1); |
|
| 38 | +} |
|
| 39 | +if (! defined('NOREQUIREMENU')) { |
|
| 40 | + define('NOREQUIREMENU',1); |
|
| 41 | +} |
|
| 42 | +if (! defined('NOREQUIREHTML')) { |
|
| 43 | + define('NOREQUIREHTML',1); |
|
| 44 | +} |
|
| 45 | +if (! defined('NOREQUIREAJAX')) { |
|
| 46 | + define('NOREQUIREAJAX','1'); |
|
| 47 | +} |
|
| 34 | 48 | |
| 35 | 49 | session_cache_limiter(FALSE); |
| 36 | 50 | |
@@ -39,8 +53,11 @@ discard block |
||
| 39 | 53 | // Define javascript type |
| 40 | 54 | top_httphead('text/javascript; charset=UTF-8'); |
| 41 | 55 | // Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. |
| 42 | -if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate'); |
|
| 43 | -else header('Cache-Control: no-cache'); |
|
| 56 | +if (empty($dolibarr_nocache)) { |
|
| 57 | + header('Cache-Control: max-age=3600, public, must-revalidate'); |
|
| 58 | +} else { |
|
| 59 | + header('Cache-Control: no-cache'); |
|
| 60 | +} |
|
| 44 | 61 | ?> |
| 45 | 62 | |
| 46 | 63 | // For JQuery Timepicker |
@@ -64,4 +81,6 @@ discard block |
||
| 64 | 81 | }); |
| 65 | 82 | |
| 66 | 83 | <?php |
| 67 | -if (is_object($db)) $db->close(); |
|
| 84 | +if (is_object($db)) { |
|
| 85 | + $db->close(); |
|
| 86 | +} |
|
@@ -44,11 +44,12 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | global $Config ; |
| 46 | 46 | |
| 47 | - if ($sCommand == "QuickUpload") |
|
| 48 | - return $Config['QuickUploadPath'][$resourceType] ; |
|
| 49 | - else |
|
| 50 | - return $Config['FileTypesPath'][$resourceType] ; |
|
| 51 | -} |
|
| 47 | + if ($sCommand == "QuickUpload") { |
|
| 48 | + return $Config['QuickUploadPath'][$resourceType] ; |
|
| 49 | + } else { |
|
| 50 | + return $Config['FileTypesPath'][$resourceType] ; |
|
| 51 | + } |
|
| 52 | + } |
|
| 52 | 53 | |
| 53 | 54 | /** |
| 54 | 55 | * GetResourceTypeDirectory |
@@ -62,16 +63,17 @@ discard block |
||
| 62 | 63 | global $Config ; |
| 63 | 64 | if ($sCommand == "QuickUpload") |
| 64 | 65 | { |
| 65 | - if ( strlen($Config['QuickUploadAbsolutePath'][$resourceType]) > 0) |
|
| 66 | - return $Config['QuickUploadAbsolutePath'][$resourceType] ; |
|
| 66 | + if ( strlen($Config['QuickUploadAbsolutePath'][$resourceType]) > 0) { |
|
| 67 | + return $Config['QuickUploadAbsolutePath'][$resourceType] ; |
|
| 68 | + } |
|
| 67 | 69 | |
| 68 | 70 | // Map the "UserFiles" path to a local directory. |
| 69 | 71 | return Server_MapPath($Config['QuickUploadPath'][$resourceType]); |
| 70 | - } |
|
| 71 | - else |
|
| 72 | + } else |
|
| 72 | 73 | { |
| 73 | - if ( strlen($Config['FileTypesAbsolutePath'][$resourceType]) > 0) |
|
| 74 | - return $Config['FileTypesAbsolutePath'][$resourceType] ; |
|
| 74 | + if ( strlen($Config['FileTypesAbsolutePath'][$resourceType]) > 0) { |
|
| 75 | + return $Config['FileTypesAbsolutePath'][$resourceType] ; |
|
| 76 | + } |
|
| 75 | 77 | |
| 76 | 78 | // Map the "UserFiles" path to a local directory. |
| 77 | 79 | return Server_MapPath($Config['FileTypesPath'][$resourceType]); |
@@ -116,8 +118,9 @@ discard block |
||
| 116 | 118 | |
| 117 | 119 | // Ensure that the directory exists. |
| 118 | 120 | $sErrorMsg = CreateServerFolder($sResourceTypePath); |
| 119 | - if ( $sErrorMsg != '' ) |
|
| 120 | - SendError(1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})"); |
|
| 121 | + if ( $sErrorMsg != '' ) { |
|
| 122 | + SendError(1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})"); |
|
| 123 | + } |
|
| 121 | 124 | |
| 122 | 125 | // Return the resource type directory combined with the required path. |
| 123 | 126 | return CombinePaths($sResourceTypePath, $folderPath); |
@@ -162,8 +165,9 @@ discard block |
||
| 162 | 165 | } |
| 163 | 166 | |
| 164 | 167 | $sErrorMsg = CreateServerFolder($sParent, $folderPath); |
| 165 | - if ( $sErrorMsg != '' ) |
|
| 166 | - return $sErrorMsg ; |
|
| 168 | + if ( $sErrorMsg != '' ) { |
|
| 169 | + return $sErrorMsg ; |
|
| 170 | + } |
|
| 167 | 171 | } |
| 168 | 172 | |
| 169 | 173 | if ( !file_exists($folderPath)) |
@@ -178,8 +182,7 @@ discard block |
||
| 178 | 182 | if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] ) |
| 179 | 183 | { |
| 180 | 184 | mkdir($folderPath); |
| 181 | - } |
|
| 182 | - else |
|
| 185 | + } else |
|
| 183 | 186 | { |
| 184 | 187 | $permissions = '0777'; |
| 185 | 188 | if ( isset( $Config['ChmodOnFolderCreate'] ) && $Config['ChmodOnFolderCreate']) |
@@ -202,10 +205,10 @@ discard block |
||
| 202 | 205 | ini_restore('error_reporting'); |
| 203 | 206 | |
| 204 | 207 | return $sErrorMsg ; |
| 208 | + } else { |
|
| 209 | + return '' ; |
|
| 210 | + } |
|
| 205 | 211 | } |
| 206 | - else |
|
| 207 | - return '' ; |
|
| 208 | -} |
|
| 209 | 212 | |
| 210 | 213 | /** |
| 211 | 214 | * Get Root Path |
@@ -230,8 +233,9 @@ discard block |
||
| 230 | 233 | |
| 231 | 234 | // This can check only that this script isn't run from a virtual dir |
| 232 | 235 | // But it avoids the problems that arise if it isn't checked |
| 233 | - if ( $position === false || $position <> strlen($sRealPath) - strlen($sSelfPath) ) |
|
| 234 | - SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".'); |
|
| 236 | + if ( $position === false || $position <> strlen($sRealPath) - strlen($sSelfPath) ) { |
|
| 237 | + SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".'); |
|
| 238 | + } |
|
| 235 | 239 | |
| 236 | 240 | return substr($sRealPath, 0, $position); |
| 237 | 241 | } |
@@ -265,11 +269,13 @@ discard block |
||
| 265 | 269 | $arAllowed = $Config['AllowedExtensions'][$resourceType] ; |
| 266 | 270 | $arDenied = $Config['DeniedExtensions'][$resourceType] ; |
| 267 | 271 | |
| 268 | - if ( count($arAllowed) > 0 && !in_array($sExtension, $arAllowed)) |
|
| 269 | - return false ; |
|
| 272 | + if ( count($arAllowed) > 0 && !in_array($sExtension, $arAllowed)) { |
|
| 273 | + return false ; |
|
| 274 | + } |
|
| 270 | 275 | |
| 271 | - if ( count($arDenied) > 0 && in_array($sExtension, $arDenied)) |
|
| 272 | - return false ; |
|
| 276 | + if ( count($arDenied) > 0 && in_array($sExtension, $arDenied)) { |
|
| 277 | + return false ; |
|
| 278 | + } |
|
| 273 | 279 | |
| 274 | 280 | return true ; |
| 275 | 281 | } |
@@ -283,8 +289,9 @@ discard block |
||
| 283 | 289 | function IsAllowedType($resourceType) |
| 284 | 290 | { |
| 285 | 291 | global $Config ; |
| 286 | - if ( !in_array($resourceType, $Config['ConfigAllowedTypes'])) |
|
| 287 | - return false ; |
|
| 292 | + if ( !in_array($resourceType, $Config['ConfigAllowedTypes'])) { |
|
| 293 | + return false ; |
|
| 294 | + } |
|
| 288 | 295 | |
| 289 | 296 | return true ; |
| 290 | 297 | } |
@@ -299,8 +306,9 @@ discard block |
||
| 299 | 306 | { |
| 300 | 307 | global $Config ; |
| 301 | 308 | |
| 302 | - if (! in_array($sCommand, $Config['ConfigAllowedCommands'])) |
|
| 303 | - return false ; |
|
| 309 | + if (! in_array($sCommand, $Config['ConfigAllowedCommands'])) { |
|
| 310 | + return false ; |
|
| 311 | + } |
|
| 304 | 312 | |
| 305 | 313 | return true ; |
| 306 | 314 | } |
@@ -318,10 +326,12 @@ discard block |
||
| 318 | 326 | $sCurrentFolder = isset( $_GET['CurrentFolder'] ) ? GETPOST('CurrentFolder', '', 1) : '/' ; |
| 319 | 327 | |
| 320 | 328 | // Check the current folder syntax (must begin and start with a slash). |
| 321 | - if (!preg_match('|/$|', $sCurrentFolder)) |
|
| 322 | - $sCurrentFolder .= '/' ; |
|
| 323 | - if (strpos($sCurrentFolder, '/') !== 0) |
|
| 324 | - $sCurrentFolder = '/' . $sCurrentFolder ; |
|
| 329 | + if (!preg_match('|/$|', $sCurrentFolder)) { |
|
| 330 | + $sCurrentFolder .= '/' ; |
|
| 331 | + } |
|
| 332 | + if (strpos($sCurrentFolder, '/') !== 0) { |
|
| 333 | + $sCurrentFolder = '/' . $sCurrentFolder ; |
|
| 334 | + } |
|
| 325 | 335 | |
| 326 | 336 | // Ensure the folder path has no double-slashes |
| 327 | 337 | while ( strpos($sCurrentFolder, '//') !== false ) { |
@@ -329,11 +339,13 @@ discard block |
||
| 329 | 339 | } |
| 330 | 340 | |
| 331 | 341 | // Check for invalid folder paths (..) |
| 332 | - if ( strpos($sCurrentFolder, '..') || strpos($sCurrentFolder, "\\")) |
|
| 333 | - SendError(102, ''); |
|
| 342 | + if ( strpos($sCurrentFolder, '..') || strpos($sCurrentFolder, "\\")) { |
|
| 343 | + SendError(102, ''); |
|
| 344 | + } |
|
| 334 | 345 | |
| 335 | - if ( preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder)) |
|
| 336 | - SendError(102, ''); |
|
| 346 | + if ( preg_match(",(/\.)|[[:cntrl:]]|(//)|(\\\\)|([\:\*\?\"\<\>\|]),", $sCurrentFolder)) { |
|
| 347 | + SendError(102, ''); |
|
| 348 | + } |
|
| 337 | 349 | |
| 338 | 350 | return $sCurrentFolder ; |
| 339 | 351 | } |
@@ -357,8 +369,9 @@ discard block |
||
| 357 | 369 | $sNewFileName = stripslashes($sNewFileName); |
| 358 | 370 | |
| 359 | 371 | // Replace dots in the name with underscores (only one dot can be there... security issue). |
| 360 | - if ( $Config['ForceSingleExtension'] ) |
|
| 361 | - $sNewFileName = preg_replace('/\\.(?![^.]*$)/', '_', $sNewFileName); |
|
| 372 | + if ( $Config['ForceSingleExtension'] ) { |
|
| 373 | + $sNewFileName = preg_replace('/\\.(?![^.]*$)/', '_', $sNewFileName); |
|
| 374 | + } |
|
| 362 | 375 | |
| 363 | 376 | // Remove \ / | : ? * " < > |
| 364 | 377 | $sNewFileName = preg_replace('/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName); |
@@ -90,15 +90,15 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | function SendError($number, $text) |
| 92 | 92 | { |
| 93 | - if ( $_GET['Command'] == 'FileUpload' ) |
|
| 94 | - SendUploadResults($number, "", "", $text); |
|
| 93 | + if ( $_GET['Command'] == 'FileUpload' ) { |
|
| 94 | + SendUploadResults($number, "", "", $text); |
|
| 95 | + } |
|
| 95 | 96 | |
| 96 | 97 | if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] ) |
| 97 | 98 | { |
| 98 | 99 | SendErrorNode($number, $text); |
| 99 | 100 | CreateXmlFooter(); |
| 100 | - } |
|
| 101 | - else |
|
| 101 | + } else |
|
| 102 | 102 | { |
| 103 | 103 | SetXmlHeaders(); |
| 104 | 104 | |
@@ -125,8 +125,9 @@ discard block |
||
| 125 | 125 | */ |
| 126 | 126 | function SendErrorNode($number, $text) |
| 127 | 127 | { |
| 128 | - if ($text) |
|
| 129 | - echo '<Error number="' . $number . '" text="' . htmlspecialchars($text) . '" />' ; |
|
| 130 | - else |
|
| 131 | - echo '<Error number="' . $number . '" />' ; |
|
| 132 | -} |
|
| 128 | + if ($text) { |
|
| 129 | + echo '<Error number="' . $number . '" text="' . htmlspecialchars($text) . '" />' ; |
|
| 130 | + } else { |
|
| 131 | + echo '<Error number="' . $number . '" />' ; |
|
| 132 | + } |
|
| 133 | + } |
|
@@ -43,8 +43,9 @@ discard block |
||
| 43 | 43 | { |
| 44 | 44 | while ( $sFile = readdir($oCurrentFolder) ) |
| 45 | 45 | { |
| 46 | - if ( $sFile != '.' && $sFile != '..' && is_dir($sServerDir . $sFile) ) |
|
| 47 | - $aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ; |
|
| 46 | + if ( $sFile != '.' && $sFile != '..' && is_dir($sServerDir . $sFile) ) { |
|
| 47 | + $aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ; |
|
| 48 | + } |
|
| 48 | 49 | } |
| 49 | 50 | closedir($oCurrentFolder); |
| 50 | 51 | } |
@@ -53,8 +54,9 @@ discard block |
||
| 53 | 54 | echo "<Folders>" ; |
| 54 | 55 | |
| 55 | 56 | natcasesort($aFolders); |
| 56 | - foreach ( $aFolders as $sFolder ) |
|
| 57 | - echo $sFolder ; |
|
| 57 | + foreach ( $aFolders as $sFolder ) { |
|
| 58 | + echo $sFolder ; |
|
| 59 | + } |
|
| 58 | 60 | |
| 59 | 61 | // Close the "Folders" node. |
| 60 | 62 | echo "</Folders>" ; |
@@ -84,9 +86,9 @@ discard block |
||
| 84 | 86 | { |
| 85 | 87 | if ( $sFile != '.' && $sFile != '..' ) |
| 86 | 88 | { |
| 87 | - if ( is_dir($sServerDir . $sFile) ) |
|
| 88 | - $aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ; |
|
| 89 | - else |
|
| 89 | + if ( is_dir($sServerDir . $sFile) ) { |
|
| 90 | + $aFolders[] = '<Folder name="' . ConvertToXmlAttribute($sFile) . '" />' ; |
|
| 91 | + } else |
|
| 90 | 92 | { |
| 91 | 93 | $iFileSize = @filesize($sServerDir . $sFile); |
| 92 | 94 | if ( !$iFileSize ) { |
@@ -95,8 +97,9 @@ discard block |
||
| 95 | 97 | if ( $iFileSize > 0 ) |
| 96 | 98 | { |
| 97 | 99 | $iFileSize = round($iFileSize / 1024); |
| 98 | - if ( $iFileSize < 1 ) |
|
| 99 | - $iFileSize = 1 ; |
|
| 100 | + if ( $iFileSize < 1 ) { |
|
| 101 | + $iFileSize = 1 ; |
|
| 102 | + } |
|
| 100 | 103 | } |
| 101 | 104 | |
| 102 | 105 | $aFiles[] = '<File name="' . ConvertToXmlAttribute($sFile) . '" size="' . $iFileSize . '" />' ; |
@@ -110,8 +113,9 @@ discard block |
||
| 110 | 113 | natcasesort($aFolders); |
| 111 | 114 | echo '<Folders>' ; |
| 112 | 115 | |
| 113 | - foreach ( $aFolders as $sFolder ) |
|
| 114 | - echo $sFolder ; |
|
| 116 | + foreach ( $aFolders as $sFolder ) { |
|
| 117 | + echo $sFolder ; |
|
| 118 | + } |
|
| 115 | 119 | |
| 116 | 120 | echo '</Folders>' ; |
| 117 | 121 | |
@@ -119,8 +123,9 @@ discard block |
||
| 119 | 123 | natcasesort($aFiles); |
| 120 | 124 | echo '<Files>' ; |
| 121 | 125 | |
| 122 | - foreach ( $aFiles as $sFiles ) |
|
| 123 | - echo $sFiles ; |
|
| 126 | + foreach ( $aFiles as $sFiles ) { |
|
| 127 | + echo $sFiles ; |
|
| 128 | + } |
|
| 124 | 129 | |
| 125 | 130 | echo '</Files>' ; |
| 126 | 131 | } |
@@ -145,8 +150,10 @@ discard block |
||
| 145 | 150 | $sNewFolderName = $_GET['NewFolderName'] ; |
| 146 | 151 | $sNewFolderName = SanitizeFolderName($sNewFolderName); |
| 147 | 152 | |
| 148 | - if (strpos($sNewFolderName, '..') !== FALSE) |
|
| 149 | - $sErrorNumber = '102' ; // Invalid folder name. |
|
| 153 | + if (strpos($sNewFolderName, '..') !== FALSE) { |
|
| 154 | + $sErrorNumber = '102' ; |
|
| 155 | + } |
|
| 156 | + // Invalid folder name. |
|
| 150 | 157 | else |
| 151 | 158 | { |
| 152 | 159 | // Map the virtual path to the local server path of the current folder. |
@@ -171,13 +178,13 @@ discard block |
||
| 171 | 178 | $sErrorNumber = '110' ; |
| 172 | 179 | break ; |
| 173 | 180 | } |
| 181 | + } else { |
|
| 182 | + $sErrorNumber = '103' ; |
|
| 174 | 183 | } |
| 175 | - else |
|
| 176 | - $sErrorNumber = '103' ; |
|
| 177 | 184 | } |
| 185 | + } else { |
|
| 186 | + $sErrorNumber = '102' ; |
|
| 178 | 187 | } |
| 179 | - else |
|
| 180 | - $sErrorNumber = '102' ; |
|
| 181 | 188 | |
| 182 | 189 | // Create the "Error" node. |
| 183 | 190 | echo '<Error number="' . $sErrorNumber . '" />' ; |
@@ -254,8 +261,7 @@ discard block |
||
| 254 | 261 | $iCounter++ ; |
| 255 | 262 | $sFileName = RemoveExtension($sOriginalFileName) . '(' . $iCounter . ').' . $sExtension ; |
| 256 | 263 | $sErrorNumber = '201' ; |
| 257 | - } |
|
| 258 | - else |
|
| 264 | + } else |
|
| 259 | 265 | { |
| 260 | 266 | move_uploaded_file($oFile['tmp_name'], $sFilePath); |
| 261 | 267 | |
@@ -289,19 +295,18 @@ discard block |
||
| 289 | 295 | { |
| 290 | 296 | @unlink($sFilePath); |
| 291 | 297 | $sErrorNumber = '202' ; |
| 292 | - } |
|
| 293 | - else if ( isset( $detectHtml ) && $detectHtml === -1 && DetectHtml($sFilePath) === true ) |
|
| 298 | + } else if ( isset( $detectHtml ) && $detectHtml === -1 && DetectHtml($sFilePath) === true ) |
|
| 294 | 299 | { |
| 295 | 300 | @unlink($sFilePath); |
| 296 | 301 | $sErrorNumber = '202' ; |
| 297 | 302 | } |
| 298 | 303 | } |
| 304 | + } else { |
|
| 305 | + $sErrorNumber = '202' ; |
|
| 299 | 306 | } |
| 300 | - else |
|
| 307 | + } else { |
|
| 301 | 308 | $sErrorNumber = '202' ; |
| 302 | 309 | } |
| 303 | - else |
|
| 304 | - $sErrorNumber = '202' ; |
|
| 305 | 310 | |
| 306 | 311 | |
| 307 | 312 | $sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder); |
@@ -314,8 +319,7 @@ discard block |
||
| 314 | 319 | { |
| 315 | 320 | // this line already exists so wrap the if block around it |
| 316 | 321 | SendUploadResults($sErrorNumber, $sFileUrl, $sFileName); |
| 317 | - } |
|
| 318 | - else |
|
| 322 | + } else |
|
| 319 | 323 | { |
| 320 | 324 | //issue the CKEditor Callback |
| 321 | 325 | SendCKEditorResults( |
@@ -30,8 +30,9 @@ discard block |
||
| 30 | 30 | require 'basexml.php'; |
| 31 | 31 | require 'commands.php'; |
| 32 | 32 | |
| 33 | -if ( !$Config['Enabled'] ) |
|
| 33 | +if ( !$Config['Enabled'] ) { |
|
| 34 | 34 | SendError(1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.php" file'); |
| 35 | +} |
|
| 35 | 36 | |
| 36 | 37 | DoResponse(); |
| 37 | 38 | |
@@ -45,8 +46,9 @@ discard block |
||
| 45 | 46 | if (!isset($_GET)) { |
| 46 | 47 | global $_GET; |
| 47 | 48 | } |
| 48 | - if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) ) |
|
| 49 | - return; |
|
| 49 | + if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) ) { |
|
| 50 | + return; |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | // Get the main request informaiton. |
| 52 | 54 | $sCommand = $_GET['Command'] ; |
@@ -59,8 +61,9 @@ discard block |
||
| 59 | 61 | SendError(1, 'The "' . $sCommand . '" command isn\'t allowed'); |
| 60 | 62 | } |
| 61 | 63 | // Check if it is an allowed type. |
| 62 | - if (! IsAllowedType($sResourceType)) |
|
| 63 | - SendError(1, 'Invalid type specified'); |
|
| 64 | + if (! IsAllowedType($sResourceType)) { |
|
| 65 | + SendError(1, 'Invalid type specified'); |
|
| 66 | + } |
|
| 64 | 67 | |
| 65 | 68 | // File Upload doesn't have to Return XML, so it must be intercepted before anything. |
| 66 | 69 | if ( $sCommand == 'FileUpload' ) |