--- /tmp/dsg/dolibarr/htdocs/core/filemanagerdol/connectors/php/github_basexml.php +++ /tmp/dsg/dolibarr/htdocs/core/filemanagerdol/connectors/php/client_basexml.php @@ -84,8 +84,8 @@ /** * SendError * - * @param integer $number Number - * @param string $text Text + * @param integer $number Number + * @param unknown_type $text Text * @return void */ function SendError($number, $text) @@ -97,7 +97,9 @@ { SendErrorNode($number, $text); CreateXmlFooter(); - } else { + } + else + { SetXmlHeaders(); dol_syslog('Error: '.$number.' '.$text, LOG_ERR); @@ -125,5 +127,6 @@ { if ($text) echo ''; - else echo ''; + else + echo ''; } --- /tmp/dsg/dolibarr/htdocs/core/filemanagerdol/connectors/php/github_commands.php +++ /tmp/dsg/dolibarr/htdocs/core/filemanagerdol/connectors/php/client_commands.php @@ -86,7 +86,8 @@ { if (is_dir($sServerDir.$sFile)) $aFolders[] = ''; - else { + else + { $iFileSize = @filesize($sServerDir.$sFile); if (!$iFileSize) { $iFileSize = 0; @@ -146,7 +147,8 @@ if (strpos($sNewFolderName, '..') !== false) $sErrorNumber = '102'; // Invalid folder name. - else { + else + { // Map the virtual path to the local server path of the current folder. $sServerDir = ServerMapFolder($resourceType, $currentFolder, 'CreateFolder'); @@ -169,9 +171,13 @@ $sErrorNumber = '110'; break; } - } else $sErrorNumber = '103'; - } - } else $sErrorNumber = '102'; + } + else + $sErrorNumber = '103'; + } + } + else + $sErrorNumber = '102'; // Create the "Error" node. echo ''; @@ -197,8 +203,8 @@ $sFileName = ''; if (isset($_FILES['NewFile']) && !is_null($_FILES['NewFile']['tmp_name']) - // This is for the QuickUpload tab box - or (isset($_FILES['upload']) && !is_null($_FILES['upload']['tmp_name']))) + // This is for the QuickUpload tab box + or (isset($_FILES['upload']) && !is_null($_FILES['upload']['tmp_name']))) { global $Config; @@ -248,7 +254,9 @@ $iCounter++; $sFileName = RemoveExtension($sOriginalFileName).'('.$iCounter.').'.$sExtension; $sErrorNumber = '201'; - } else { + } + else + { move_uploaded_file($oFile['tmp_name'], $sFilePath); if (is_file($sFilePath)) @@ -281,14 +289,19 @@ { @unlink($sFilePath); $sErrorNumber = '202'; - } elseif (isset($detectHtml) && $detectHtml === -1 && DetectHtml($sFilePath) === true) + } + elseif (isset($detectHtml) && $detectHtml === -1 && DetectHtml($sFilePath) === true) { @unlink($sFilePath); $sErrorNumber = '202'; } } - } else $sErrorNumber = '202'; - } else $sErrorNumber = '202'; + } + else + $sErrorNumber = '202'; + } + else + $sErrorNumber = '202'; $sFileUrl = CombinePaths(GetResourceTypePath($resourceType, $sCommand), $currentFolder); @@ -298,16 +311,18 @@ // @CHANGE //SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName ); if ($CKEcallback == '') - { - // this line already exists so wrap the if block around it - SendUploadResults($sErrorNumber, $sFileUrl, $sFileName); - } else { - //issue the CKEditor Callback - SendCKEditorResults( + { + // this line already exists so wrap the if block around it + SendUploadResults($sErrorNumber, $sFileUrl, $sFileName); + } + else + { + //issue the CKEditor Callback + SendCKEditorResults( $CKEcallback, $sFileUrl, ($sErrorNumber != 0 ? 'Error '.$sErrorNumber.' upload failed.' : 'Upload Successful') - ); + ); } exit; --- /tmp/dsg/dolibarr/htdocs/core/filemanagerdol/connectors/php/github_connector.php +++ /tmp/dsg/dolibarr/htdocs/core/filemanagerdol/connectors/php/client_connector.php @@ -42,9 +42,9 @@ */ function DoResponse() { - if (!isset($_GET)) { - global $_GET; - } + if (!isset($_GET)) { + global $_GET; + } if (!isset($_GET['Command']) || !isset($_GET['Type']) || !isset($_GET['CurrentFolder'])) return; --- /tmp/dsg/dolibarr/htdocs/core/filemanagerdol/connectors/php/github_io.php +++ /tmp/dsg/dolibarr/htdocs/core/filemanagerdol/connectors/php/client_io.php @@ -46,7 +46,8 @@ if ($sCommand == "QuickUpload") return $Config['QuickUploadPath'][$resourceType]; - else return $Config['FileTypesPath'][$resourceType]; + else + return $Config['FileTypesPath'][$resourceType]; } /** @@ -66,7 +67,9 @@ // Map the "UserFiles" path to a local directory. return Server_MapPath($Config['QuickUploadPath'][$resourceType]); - } else { + } + else + { if (strlen($Config['FileTypesAbsolutePath'][$resourceType]) > 0) return $Config['FileTypesAbsolutePath'][$resourceType]; @@ -128,8 +131,8 @@ */ function GetParentFolder($folderPath) { - $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-"; - return preg_replace($sPattern, '', $folderPath); + $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-"; + return preg_replace($sPattern, '', $folderPath); } /** @@ -175,7 +178,9 @@ if (isset($Config['ChmodOnFolderCreate']) && !$Config['ChmodOnFolderCreate']) { mkdir($folderPath); - } else { + } + else + { $permissions = '0777'; if (isset($Config['ChmodOnFolderCreate']) && $Config['ChmodOnFolderCreate']) { @@ -197,7 +202,9 @@ ini_restore('error_reporting'); return $sErrorMsg; - } else return ''; + } + else + return ''; } /** @@ -207,26 +214,26 @@ */ function GetRootPath() { - if (!isset($_SERVER)) { - global $_SERVER; - } - $sRealPath = realpath('./'); - // #2124 ensure that no slash is at the end - $sRealPath = rtrim($sRealPath, "\\/"); - - $sSelfPath = $_SERVER['PHP_SELF']; - $sSelfPath = substr($sSelfPath, 0, strrpos($sSelfPath, '/')); - - $sSelfPath = str_replace('/', DIRECTORY_SEPARATOR, $sSelfPath); - - $position = strpos($sRealPath, $sSelfPath); - - // This can check only that this script isn't run from a virtual dir - // But it avoids the problems that arise if it isn't checked - if ($position === false || $position <> strlen($sRealPath) - strlen($sSelfPath)) - SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".'); - - return substr($sRealPath, 0, $position); + if (!isset($_SERVER)) { + global $_SERVER; + } + $sRealPath = realpath('./'); + // #2124 ensure that no slash is at the end + $sRealPath = rtrim($sRealPath, "\\/"); + + $sSelfPath = $_SERVER['PHP_SELF']; + $sSelfPath = substr($sSelfPath, 0, strrpos($sSelfPath, '/')); + + $sSelfPath = str_replace('/', DIRECTORY_SEPARATOR, $sSelfPath); + + $position = strpos($sRealPath, $sSelfPath); + + // This can check only that this script isn't run from a virtual dir + // But it avoids the problems that arise if it isn't checked + if ($position === false || $position <> strlen($sRealPath) - strlen($sSelfPath)) + SendError(1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".'); + + return substr($sRealPath, 0, $position); } /** @@ -236,15 +243,15 @@ */ function Server_MapPath($path) { - // This function is available only for Apache - if (function_exists('apache_lookup_uri')) { - $info = apache_lookup_uri($path); - return $info->filename.$info->path_info; - } - - // This isn't correct but for the moment there's no other solution - // If this script is under a virtual directory or symlink it will detect the problem and stop - return GetRootPath().$path; + // This function is available only for Apache + if (function_exists('apache_lookup_uri')) { + $info = apache_lookup_uri($path); + return $info->filename.$info->path_info; + } + + // This isn't correct but for the moment there's no other solution + // If this script is under a virtual directory or symlink it will detect the problem and stop + return GetRootPath().$path; } /** @@ -415,11 +422,11 @@ */ function SendCKEditorResults($callback, $sFileUrl, $customMsg = '') { - echo ''; -} + echo ''; +} --- /tmp/dsg/dolibarr/htdocs/core/filemanagerdol/connectors/php/github_util.php +++ /tmp/dsg/dolibarr/htdocs/core/filemanagerdol/connectors/php/client_util.php @@ -59,7 +59,7 @@ $regex = '([\x00-\x7F]|[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]'; $regex .= '|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2}|(.{1}))'; - $matches = array(); + $matches =array(); while (preg_match('/'.$regex.'/S', $string, $matches)) { if (isset($matches[2])) { return true; @@ -81,14 +81,18 @@ if (defined('PHP_OS')) { $os = PHP_OS; - } else { + } + else + { $os = php_uname(); } if (strtoupper(substr($os, 0, 3)) === 'WIN' || FindBadUtf8($value)) { return (utf8_encode(htmlspecialchars($value))); - } else { + } + else + { return (htmlspecialchars($value)); } }