diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php index fc8665d420..74bb409523 100755 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/ajaxfilemanager.php @@ -44,7 +44,7 @@ switch($_GET['view']) { case 'detail': case 'thumbnail': - $view = $_GET['view']; + $view = Security::remove_XSS($_GET['view']); break; default: $view = CONFIG_DEFAULT_VIEW; @@ -52,6 +52,7 @@ } else { $view = CONFIG_DEFAULT_VIEW; } + ?> @@ -80,10 +81,10 @@ oEditor = window.parent.InnerDialogLoaded() ; } //end hack - } - var globalSettings = {'upload_init':false}; - var queryString = ''; - var paths = {'root':'', 'root_title':''}; + } + var globalSettings = {'upload_init':false}; + var queryString = ''; + var paths = {'root':'', 'root_title':''}; var shared_folder = ''; @@ -158,9 +159,10 @@ var searchRequired = false; var supporedPreviewExts = ''; var supportedUploadExts = '' - var elementId = ; + var elementId = ; var files = {}; -$(document).ready( + + $(document).ready( function() { jQuery(document).bind('keypress', function(event) { @@ -203,9 +205,8 @@ $(document).ready( //addMoreFile(); } ); - - + folderPathIndex]) && file_exists($_GET[$this->folderPathIndex]) && !is_file($_GET[$this->folderPathIndex]) ) { - $this->currentFolderPath = $_GET[$this->folderPathIndex]; + $this->currentFolderPath = api_htmlentities(Security::remove_XSS($_GET[$this->folderPathIndex])); } elseif(isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex])) { diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.base.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.base.php index 9b0cde3dcd..558aed10b0 100755 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.base.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.base.php @@ -11,11 +11,9 @@ * @since 31/December/2008 */ - -//error_reporting(E_ALL); -//error_reporting(E_ALL ^ E_NOTICE); - - + + //error_reporting(E_ALL); + //error_reporting(E_ALL ^ E_NOTICE); //Access Control Setting /** @@ -241,6 +239,4 @@ define('CONFIG_LANG_INDEX', 'language'); //the index in the session define('CONFIG_LANG_DEFAULT', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['language']) && file_exists(DIR_LANG . secureFileName($_GET['language']) . '.php')?secureFileName($_GET['language']):$langajaxfilemanager)); //change it to be your language file base name, such en // Language text direction. - define('CONFIG_LANG_TEXT_DIRECTION_DEFAULT', in_array(CONFIG_LANG_DEFAULT, array('ar', 'prs', 'he', 'ps', 'fa')) ? 'rtl' : 'ltr'); - -?> + define('CONFIG_LANG_TEXT_DIRECTION_DEFAULT', in_array(CONFIG_LANG_DEFAULT, array('ar', 'prs', 'he', 'ps', 'fa')) ? 'rtl' : 'ltr'); \ No newline at end of file diff --git a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/function.base.php b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/function.base.php index 4223da9970..66bf333a2e 100755 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/function.base.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/function.base.php @@ -6,7 +6,8 @@ * @since 22/April/2007 * */ -require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . "config.php"); +require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "config.php"; + /** * force to ensure existence of stripos */ @@ -23,17 +24,14 @@ if (!function_exists("stripos")) * @param array $excls specify those unwanted query string * @return string */ - function getCurrentUrl($excls=array()) - { + function getCurrentUrl($excls=array()) { $output = $_SERVER['PHP_SELF']; $count = 1; - foreach($_GET as $k=>$v) - { - if(array_search($k, $excls) ===false) - { + foreach($_GET as $k=>$v) { + if(array_search($k, $excls) ===false) { + $v = api_htmlentities(Security::remove_XSS($v)); $strAppend = "&"; - if($count == 1) - { + if($count == 1) { $strAppend = "?"; $count++; } @@ -42,20 +40,20 @@ if (!function_exists("stripos")) } return $output; } - -/** - * print out an array - * - * @param array $array - */ -function displayArray($array, $comments="") -{ - echo "
"; - echo $comments; - print_r($array); - echo $comments; - echo ""; -} + + /** + * print out an array + * + * @param array $array + */ + function displayArray($array, $comments="") + { + echo "
"; + echo $comments; + print_r($array); + echo $comments; + echo ""; + } @@ -116,20 +114,16 @@ function displayArray($array, $comments="") } } - - - - -/** - * transform file relative path to absolute path - * @param string $value the path to the file - * @return string - */ -function relToAbs($value) -{ - return backslashToSlash(preg_replace("/(\\\\)/","\\", getRealPath($value))); - -} + /** + * transform file relative path to absolute path + * @param string $value the path to the file + * @return string + */ + function relToAbs($value) + { + return backslashToSlash(preg_replace("/(\\\\)/","\\", getRealPath($value))); + + } function getRelativeFileUrl($value, $relativeTo) { @@ -144,85 +138,87 @@ function relToAbs($value) $output = $urlprefix . substr($value, strlen($wwwroot)) . $urlsuffix; } } -/** - * replace slash with backslash - * - * @param string $value the path to the file - * @return string - */ -function slashToBackslash($value) { - return str_replace("/", DIRECTORY_SEPARATOR, $value); -} - -/** - * replace backslash with slash - * - * @param string $value the path to the file - * @return string - */ -function backslashToSlash($value) { - return str_replace(DIRECTORY_SEPARATOR, "/", $value); -} - -/** - * removes the trailing slash - * - * @param string $value - * @return string - */ -function removeTrailingSlash($value) { - if(preg_match('@^.+/$@i', $value)) - { - $value = substr($value, 0, strlen($value)-1); + + /** + * replace slash with backslash + * + * @param string $value the path to the file + * @return string + */ + function slashToBackslash($value) { + return str_replace("/", DIRECTORY_SEPARATOR, $value); } - return $value; -} - -/** - * append a trailing slash - * - * @param string $value - * @return string - */ -function addTrailingSlash($value) -{ - if(preg_match('@^.*[^/]{1}$@i', $value)) - { - $value .= '/'; + + /** + * replace backslash with slash + * + * @param string $value the path to the file + * @return string + */ + function backslashToSlash($value) { + return str_replace(DIRECTORY_SEPARATOR, "/", $value); } - return $value; -} - -/** - * transform a file path to user friendly - * - * @param string $value - * @return string - */ -function transformFilePath($value) { - $rootPath = addTrailingSlash(backslashToSlash(getRealPath(CONFIG_SYS_ROOT_PATH))); - $value = addTrailingSlash(backslashToSlash(getRealPath($value))); - if(!empty($rootPath) && ($i = strpos($value, $rootPath)) !== false) + + /** + * removes the trailing slash + * + * @param string $value + * @return string + */ + function removeTrailingSlash($value) { + if(preg_match('@^.+/$@i', $value)) + { + $value = substr($value, 0, strlen($value)-1); + } + return $value; + } + + /** + * append a trailing slash + * + * @param string $value + * @return string + */ + function addTrailingSlash($value) { - $value = ($i == 0?substr($value, strlen($rootPath)):"/"); + if(preg_match('@^.*[^/]{1}$@i', $value)) + { + $value .= '/'; + } + return $value; } - $value = prependSlash($value); - return $value; -} -/** - * prepend slash - * - * @param string $value - * @return string - */ -function prependSlash($value) -{ - if (($value && $value[0] != '/') || !$value ) + + /** + * transform a file path to user friendly + * + * @param string $value + * @return string + */ + function transformFilePath($value) { + $rootPath = addTrailingSlash(backslashToSlash(getRealPath(CONFIG_SYS_ROOT_PATH))); + $value = addTrailingSlash(backslashToSlash(getRealPath($value))); + if(!empty($rootPath) && ($i = strpos($value, $rootPath)) !== false) { - $value = "/" . $value; + $value = ($i == 0?substr($value, strlen($rootPath)):"/"); } + $value = prependSlash($value); return $value; -} + } + + /** + * prepend slash + * + * @param string $value + * @return string + */ + function prependSlash($value) + { + if (($value && $value[0] != '/') || !$value ) + { + $value = "/" . $value; + } + return $value; + } function writeInfo($data, $die = false) @@ -238,26 +234,25 @@ function prependSlash($value) } -/** - * no cachable header - */ -function addNoCacheHeaders() { - header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); - header("Cache-Control: no-store, no-cache, must-revalidate"); - header("Cache-Control: post-check=0, pre-check=0", false); - header("Pragma: no-cache"); -} + /** + * no cachable header + */ + function addNoCacheHeaders() { + header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); + header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); + header("Cache-Control: no-store, no-cache, must-revalidate"); + header("Cache-Control: post-check=0, pre-check=0", false); + header("Pragma: no-cache"); + } + /** * add extra query stiring to a url * @param string $baseUrl * @param string $extra the query string added to the base url */ - function appendQueryString($baseUrl, $extra) - { + function appendQueryString($baseUrl, $extra) { $output = $baseUrl; - if(!empty($extra)) - { + if(!empty($extra)) { if(strpos($baseUrl, "?") !== false) { $output .= "&" . $extra; @@ -275,18 +270,16 @@ function addNoCacheHeaders() { * @param array $excluded * @return string */ - function makeQueryString($excluded=array()) - { + function makeQueryString($excluded=array()) { $output = ''; $count = 1; - foreach($_GET as $k=>$v) - { - if(array_search($k, $excluded) === false) - { + foreach($_GET as $k=>$v) { + if (array_search($k, $excluded) === false) { + $v = api_htmlentities(Security::remove_XSS($v)); $output .= ($count>1?'&':'') . ($k . "=" . $v); $count++; } - } + } return $output; } /** @@ -379,18 +372,19 @@ function addNoCacheHeaders() { return $outputs; } -/** - * turn to absolute path from relative path - * - * @param string $value - * @return string - */ -function getAbsPath($value) { - if (substr($value, 0, 1) == "/") - return slashToBackslash(DIR_AJAX_ROOT . $value); - - return slashToBackslash(dirname(__FILE__) . "/" . $value); -} + + /** + * turn to absolute path from relative path + * + * @param string $value + * @return string + */ + function getAbsPath($value) { + if (substr($value, 0, 1) == "/") + return slashToBackslash(DIR_AJAX_ROOT . $value); + + return slashToBackslash(dirname(__FILE__) . "/" . $value); + } /** * get file/folder base name @@ -411,59 +405,60 @@ function getAbsPath($value) { } } -function myRealPath($path) { + function myRealPath($path) { if(strpos($path, ':/') !== false) { return $path; } - // check if path begins with "/" ie. is absolute - // if it isnt concat with script path - - if (strpos($path,"/") !== 0 ) { - $base=dirname($_SERVER['SCRIPT_FILENAME']); - $path=$base."/".$path; - } - - // canonicalize - $path=explode('/', $path); - $newpath=array(); - for ($i=0; $i