From c61e7e67d7f6d4ac166e22ef8c5a8e4fe5510f6a Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov Date: Fri, 26 Jun 2009 02:15:50 +0200 Subject: [PATCH] [svn r21622] FS#2867 - Introducing two new path types for the function api_get_path() - WEB_SERVER_ROOT_PATH and SYS_SERVER_ROOT_PATH in the main API. Some corrections about the same function have been done. Using a call api_get_path(SYS_SERVER_ROOT_PATH) that is neccessary for the FCKEditor, simple file manager (within the function GetRootPath()) and advanced file manager. --- .../editor/filemanager/connectors/php/io.php | 677 +++++++++--------- .../ajaxfilemanager/inc/config.base.php | 505 +++++++------ main/inc/lib/main_api.lib.php | 92 ++- 3 files changed, 652 insertions(+), 622 deletions(-) diff --git a/main/inc/lib/fckeditor/editor/filemanager/connectors/php/io.php b/main/inc/lib/fckeditor/editor/filemanager/connectors/php/io.php index f12611e1ac..e1fde0b3b8 100644 --- a/main/inc/lib/fckeditor/editor/filemanager/connectors/php/io.php +++ b/main/inc/lib/fckeditor/editor/filemanager/connectors/php/io.php @@ -1,341 +1,336 @@ - 0 ) - return $Config['QuickUploadAbsolutePath'][$resourceType] ; - - // Map the "UserFiles" path to a local directory. - return Server_MapPath( $Config['QuickUploadPath'][$resourceType] ) ; - } - else - { - if ( strlen( $Config['FileTypesAbsolutePath'][$resourceType] ) > 0 ) - return $Config['FileTypesAbsolutePath'][$resourceType] ; - - // Map the "UserFiles" path to a local directory. - return Server_MapPath( $Config['FileTypesPath'][$resourceType] ) ; - } -} - -/* - * This function is called to change the URL in the fckeditor source view. -*/ -function GetUrlFromPath( $resourceType, $folderPath, $sCommand ) -{ - $resourceType = strtolower($resourceType); - return $resourceType . $folderPath; -} - -function RemoveExtension( $fileName ) -{ - return substr( $fileName, 0, strrpos( $fileName, '.' ) ) ; -} - -function ServerMapFolder( $resourceType, $folderPath, $sCommand ) -{ - // Get the resource type directory. - $resourceType = strtolower($resourceType); - if ( $resourceType != 'file' ) - { - $sResourceTypePath = $GLOBALS["UserFilesDirectory"] . $resourceType . '/' ; - } - else - { - $sResourceTypePath = $GLOBALS["UserFilesDirectory"]; - } - - // Ensure that the directory exists. - if ( $resourceType != 'file' ) - { - CreateServerFolder( $sResourceTypePath ) ; - } - - // Return the resource type directory combined with the required path. - return $sResourceTypePath . RemoveFromStart( $folderPath, '/' ) ; -} - -function GetParentFolder( $folderPath ) -{ - $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ; - return preg_replace( $sPattern, '', $folderPath ) ; -} - -function CreateServerFolder( $folderPath, $lastFolder = null ) -{ - global $Config ; - $sParent = GetParentFolder( $folderPath ) ; - - // Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms - while ( strpos($folderPath, '//') !== false ) - { - $folderPath = str_replace( '//', '/', $folderPath ) ; - } - - // Check if the parent exists, or create it. - if ( !file_exists( $sParent ) ) - { - //prevents agains infinite loop when we can't create root folder - if ( !is_null( $lastFolder ) && $lastFolder === $sParent) { - return "Can't create $folderPath directory" ; - } - - $sErrorMsg = CreateServerFolder( $sParent, $folderPath ) ; - if ( $sErrorMsg != '' ) - return $sErrorMsg ; - } - - if ( !file_exists( $folderPath ) ) - { - // Turn off all error reporting. - error_reporting( 0 ) ; - - $php_errormsg = '' ; - // Enable error tracking to catch the error. - ini_set( 'track_errors', '1' ) ; - - if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] ) - { - mkdir( $folderPath ) ; - } - else - { - $permissions = 0777 ; - if ( isset( $Config['ChmodOnFolderCreate'] ) ) - { - $permissions = $Config['ChmodOnFolderCreate'] ; - } - // To create the folder with 0777 permissions, we need to set umask to zero. - $oldumask = umask(0) ; - mkdir( $folderPath, $permissions ) ; - umask( $oldumask ) ; - } - - // While we are in a course: Registering the newly created folder in the course's database. - if (api_is_in_course()) - { - global $_course, $_user; - $repository_path = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/'; - $to_group_id = 0; - - if (api_is_in_group()) - { - global $group_properties; - $to_group_id = $group_properties['id']; - } - - $folder_path = substr($folderPath, strpos($folderPath, $repository_path) + strlen($repository_path) - 1); - $folder_name = explode('/', $folder_path); - $folder_name = $folder_name[count($folder_name) - 1]; - $doc_id = add_document($_course, $folder_path, 'folder', 0, $folder_name); - api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id'], $to_group_id); - } - - $sErrorMsg = $php_errormsg ; - - // Restore the configurations. - ini_restore( 'track_errors' ) ; - ini_restore( 'error_reporting' ) ; - - return $sErrorMsg ; - } - else - return '' ; -} - -function GetRootPath() -{ - // First, let the system Dokeos tries to determine the system document root path. - - if (preg_match('@'.api_get_path(REL_PATH).'$@', api_get_path(SYS_PATH))) // Sanity check. - { - return str_replace('/', DIRECTORY_SEPARATOR, preg_replace('@'.api_get_path(REL_PATH).'$@', '', api_get_path(SYS_PATH))); - } - - // Next, the original algorithm will try alone to determine the system document root path. - - 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 ) ; -} - -// Emulate the asp Server.mapPath function. -// given an url path return the physical directory that it corresponds to -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 ; -} - -function IsAllowedExt( $sExtension, $resourceType ) -{ - global $Config ; - // Get the allowed and denied extensions arrays. - $arAllowed = $Config['AllowedExtensions'][$resourceType] ; - $arDenied = $Config['DeniedExtensions'][$resourceType] ; - - if ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) ) - return false ; - - if ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) ) - return false ; - - return true ; -} - -function IsAllowedType( $resourceType ) -{ - global $Config ; - if ( !in_array( $resourceType, $Config['ConfigAllowedTypes'] ) ) - return false ; - - return true ; -} - -function IsAllowedCommand( $sCommand ) -{ - global $Config ; - - if ( !in_array( $sCommand, $Config['ConfigAllowedCommands'] ) ) - return false ; - - return true ; -} - -function GetCurrentFolder() -{ - if (!isset($_GET)) { - global $_GET; - } - $sCurrentFolder = isset( $_GET['CurrentFolder'] ) ? $_GET['CurrentFolder'] : '/' ; - - // Check the current folder syntax (must begin and start with a slash). - if ( !preg_match( '|/$|', $sCurrentFolder ) ) - $sCurrentFolder .= '/' ; - if ( strpos( $sCurrentFolder, '/' ) !== 0 ) - $sCurrentFolder = '/' . $sCurrentFolder ; - - // Ensure the folder path has no double-slashes - while ( strpos ($sCurrentFolder, '//') !== false ) { - $sCurrentFolder = str_replace ('//', '/', $sCurrentFolder) ; - } - - // Check for invalid folder paths (..) - if ( strpos( $sCurrentFolder, '..' ) || strpos( $sCurrentFolder, "\\" )) - SendError( 102, '' ) ; - - return $sCurrentFolder ; -} - -// Do a cleanup of the folder name to avoid possible problems -function SanitizeFolderName( $sNewFolderName ) -{ - $sNewFolderName = stripslashes( $sNewFolderName ) ; - - // Remove . \ / | : ? * " < > - $sNewFolderName = preg_replace( '/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName ) ; - - return $sNewFolderName ; -} - -// Do a cleanup of the file name to avoid possible problems -function SanitizeFileName( $sNewFileName ) -{ - global $Config ; - - $sNewFileName = stripslashes( $sNewFileName ) ; - - // Replace dots in the name with underscores (only one dot can be there... security issue). - if ( $Config['ForceSingleExtension'] ) - $sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ) ; - - // Remove \ / | : ? * " < > - $sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName ) ; - - return $sNewFileName ; -} - -// This is the function that sends the results of the uploading process. -function SendUploadResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' ) -{ - // Minified version of the document.domain automatic fix script (#1919). - // The original script can be found at _dev/domain_fix_template.js - echo << -(function(){var d=document.domain;while (true){try{var A=window.parent.document.domain;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})(); -EOF; - - $search = array( '\\', '"' ); - $replace = array( '\\\\', '\\"' ); - echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . str_replace( $search, $replace, $fileUrl ) . '","' . str_replace( $search, $replace, $fileName ) . '", "' . str_replace( $search, $replace, $customMsg ) . '") ;' ; - echo '' ; - exit ; -} - -?> + 0 ) + return $Config['QuickUploadAbsolutePath'][$resourceType] ; + + // Map the "UserFiles" path to a local directory. + return Server_MapPath( $Config['QuickUploadPath'][$resourceType] ) ; + } + else + { + if ( strlen( $Config['FileTypesAbsolutePath'][$resourceType] ) > 0 ) + return $Config['FileTypesAbsolutePath'][$resourceType] ; + + // Map the "UserFiles" path to a local directory. + return Server_MapPath( $Config['FileTypesPath'][$resourceType] ) ; + } +} + +/* + * This function is called to change the URL in the fckeditor source view. +*/ +function GetUrlFromPath( $resourceType, $folderPath, $sCommand ) +{ + $resourceType = strtolower($resourceType); + return $resourceType . $folderPath; +} + +function RemoveExtension( $fileName ) +{ + return substr( $fileName, 0, strrpos( $fileName, '.' ) ) ; +} + +function ServerMapFolder( $resourceType, $folderPath, $sCommand ) +{ + // Get the resource type directory. + $resourceType = strtolower($resourceType); + if ( $resourceType != 'file' ) + { + $sResourceTypePath = $GLOBALS["UserFilesDirectory"] . $resourceType . '/' ; + } + else + { + $sResourceTypePath = $GLOBALS["UserFilesDirectory"]; + } + + // Ensure that the directory exists. + if ( $resourceType != 'file' ) + { + CreateServerFolder( $sResourceTypePath ) ; + } + + // Return the resource type directory combined with the required path. + return $sResourceTypePath . RemoveFromStart( $folderPath, '/' ) ; +} + +function GetParentFolder( $folderPath ) +{ + $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ; + return preg_replace( $sPattern, '', $folderPath ) ; +} + +function CreateServerFolder( $folderPath, $lastFolder = null ) +{ + global $Config ; + $sParent = GetParentFolder( $folderPath ) ; + + // Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms + while ( strpos($folderPath, '//') !== false ) + { + $folderPath = str_replace( '//', '/', $folderPath ) ; + } + + // Check if the parent exists, or create it. + if ( !file_exists( $sParent ) ) + { + //prevents agains infinite loop when we can't create root folder + if ( !is_null( $lastFolder ) && $lastFolder === $sParent) { + return "Can't create $folderPath directory" ; + } + + $sErrorMsg = CreateServerFolder( $sParent, $folderPath ) ; + if ( $sErrorMsg != '' ) + return $sErrorMsg ; + } + + if ( !file_exists( $folderPath ) ) + { + // Turn off all error reporting. + error_reporting( 0 ) ; + + $php_errormsg = '' ; + // Enable error tracking to catch the error. + ini_set( 'track_errors', '1' ) ; + + if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] ) + { + mkdir( $folderPath ) ; + } + else + { + $permissions = 0777 ; + if ( isset( $Config['ChmodOnFolderCreate'] ) ) + { + $permissions = $Config['ChmodOnFolderCreate'] ; + } + // To create the folder with 0777 permissions, we need to set umask to zero. + $oldumask = umask(0) ; + mkdir( $folderPath, $permissions ) ; + umask( $oldumask ) ; + } + + // While we are in a course: Registering the newly created folder in the course's database. + if (api_is_in_course()) + { + global $_course, $_user; + $repository_path = api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/'; + $to_group_id = 0; + + if (api_is_in_group()) + { + global $group_properties; + $to_group_id = $group_properties['id']; + } + + $folder_path = substr($folderPath, strpos($folderPath, $repository_path) + strlen($repository_path) - 1); + $folder_name = explode('/', $folder_path); + $folder_name = $folder_name[count($folder_name) - 1]; + $doc_id = add_document($_course, $folder_path, 'folder', 0, $folder_name); + api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $_user['user_id'], $to_group_id); + } + + $sErrorMsg = $php_errormsg ; + + // Restore the configurations. + ini_restore( 'track_errors' ) ; + ini_restore( 'error_reporting' ) ; + + return $sErrorMsg ; + } + else + return '' ; +} + +function GetRootPath() +{ + return str_replace('/', DIRECTORY_SEPARATOR, rtrim(api_get_path(SYS_SERVER_ROOT_PATH), '/')); + + /* + 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 ) ; + */ +} + +// Emulate the asp Server.mapPath function. +// given an url path return the physical directory that it corresponds to +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 ; +} + +function IsAllowedExt( $sExtension, $resourceType ) +{ + global $Config ; + // Get the allowed and denied extensions arrays. + $arAllowed = $Config['AllowedExtensions'][$resourceType] ; + $arDenied = $Config['DeniedExtensions'][$resourceType] ; + + if ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) ) + return false ; + + if ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) ) + return false ; + + return true ; +} + +function IsAllowedType( $resourceType ) +{ + global $Config ; + if ( !in_array( $resourceType, $Config['ConfigAllowedTypes'] ) ) + return false ; + + return true ; +} + +function IsAllowedCommand( $sCommand ) +{ + global $Config ; + + if ( !in_array( $sCommand, $Config['ConfigAllowedCommands'] ) ) + return false ; + + return true ; +} + +function GetCurrentFolder() +{ + if (!isset($_GET)) { + global $_GET; + } + $sCurrentFolder = isset( $_GET['CurrentFolder'] ) ? $_GET['CurrentFolder'] : '/' ; + + // Check the current folder syntax (must begin and start with a slash). + if ( !preg_match( '|/$|', $sCurrentFolder ) ) + $sCurrentFolder .= '/' ; + if ( strpos( $sCurrentFolder, '/' ) !== 0 ) + $sCurrentFolder = '/' . $sCurrentFolder ; + + // Ensure the folder path has no double-slashes + while ( strpos ($sCurrentFolder, '//') !== false ) { + $sCurrentFolder = str_replace ('//', '/', $sCurrentFolder) ; + } + + // Check for invalid folder paths (..) + if ( strpos( $sCurrentFolder, '..' ) || strpos( $sCurrentFolder, "\\" )) + SendError( 102, '' ) ; + + return $sCurrentFolder ; +} + +// Do a cleanup of the folder name to avoid possible problems +function SanitizeFolderName( $sNewFolderName ) +{ + $sNewFolderName = stripslashes( $sNewFolderName ) ; + + // Remove . \ / | : ? * " < > + $sNewFolderName = preg_replace( '/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName ) ; + + return $sNewFolderName ; +} + +// Do a cleanup of the file name to avoid possible problems +function SanitizeFileName( $sNewFileName ) +{ + global $Config ; + + $sNewFileName = stripslashes( $sNewFileName ) ; + + // Replace dots in the name with underscores (only one dot can be there... security issue). + if ( $Config['ForceSingleExtension'] ) + $sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ) ; + + // Remove \ / | : ? * " < > + $sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName ) ; + + return $sNewFileName ; +} + +// This is the function that sends the results of the uploading process. +function SendUploadResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' ) +{ + // Minified version of the document.domain automatic fix script (#1919). + // The original script can be found at _dev/domain_fix_template.js + echo << +(function(){var d=document.domain;while (true){try{var A=window.parent.document.domain;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})(); +EOF; + + $search = array( '\\', '"' ); + $replace = array( '\\\\', '\\"' ); + echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . str_replace( $search, $replace, $fileUrl ) . '","' . str_replace( $search, $replace, $fileName ) . '", "' . str_replace( $search, $replace, $customMsg ) . '") ;' ; + echo '' ; + exit ; +} + +?> 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 bb6b153623..e5980da7cc 100644 --- a/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.base.php +++ b/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/config.base.php @@ -1,257 +1,248 @@ - false - * by session => true - */ - define('CONFIG_ACCESS_CONTROL_MODE', false); - define("CONFIG_LOGIN_USERNAME", 'ajax'); - define('CONFIG_LOGIN_PASSWORD', '123456'); - define('CONFIG_LOGIN_PAGE', 'ajax_login.php'); //the url to the login page - - //SYSTEM MODE CONFIG - /** - * turn it on when you have this system for demo purpose - * that means changes made to each image is not physically applied to it - * and all uploaded files/created folders will be removed automatically - */ - define('CONFIG_SYS_DEMO_ENABLE', false); - define('CONFIG_SYS_VIEW_ONLY', false); //diabled the system, view only - define('CONFIG_SYS_THUMBNAIL_VIEW_ENABLE', true);//REMOVE THE thumbnail view if false - - //User Permissions - //Hack by Juan Carlos Raņa Trabado - if(empty($_course['path'])) - { - define('CONFIG_OPTIONS_DELETE', true); - define('CONFIG_OPTIONS_CUT', true); - define('CONFIG_OPTIONS_COPY', true); - define('CONFIG_OPTIONS_NEWFOLDER', true); - define('CONFIG_OPTIONS_RENAME', true); - define('CONFIG_OPTIONS_UPLOAD', true); // - define('CONFIG_OPTIONS_EDITABLE', false); //disable image editor and text editor - } - else - { - if(api_is_allowed_to_edit()) - { - //api_is_allowed_to_edit() from Dokeos - define('CONFIG_OPTIONS_DELETE', true); - define('CONFIG_OPTIONS_CUT', false); - define('CONFIG_OPTIONS_COPY', false); - define('CONFIG_OPTIONS_NEWFOLDER', true); - define('CONFIG_OPTIONS_RENAME', false); - define('CONFIG_OPTIONS_UPLOAD', true); // - define('CONFIG_OPTIONS_EDITABLE', false); //disable image editor and text editor - - } - else - { - define('CONFIG_OPTIONS_DELETE', true); - define('CONFIG_OPTIONS_CUT', false); - define('CONFIG_OPTIONS_COPY', false); - define('CONFIG_OPTIONS_NEWFOLDER', true); - define('CONFIG_OPTIONS_RENAME', false); - define('CONFIG_OPTIONS_UPLOAD', true); // - define('CONFIG_OPTIONS_EDITABLE', false); //disable image editor and text editor - } - } - - - //FILESYSTEM CONFIG - /* - * CONFIG_SYS_DEFAULT_PATH is the default folder where the files would be uploaded to - and it must be a folder under the CONFIG_SYS_ROOT_PATH or the same folder - these two paths accept relative path only, don't use absolute path - */ - //define('CONFIG_SYS_DEFAULT_PATH', '../uploaded/'); //accept relative path only - //define('CONFIG_SYS_ROOT_PATH', '../uploaded/'); //accept relative path only - - /////////////// Integration for Dokeos - - if(!empty($_course['path'])) - { - if(!empty($group_properties['directory'])) - { - $PathDokeosAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document'.$group_properties['directory'].'/'; - } - else - { - if(api_is_allowed_to_edit()) - { - $PathDokeosAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document/'; - } - else - { - $PathDokeosAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document/shared_folder/sf_user_'.api_get_user_id().'/'; - } - } - } - else - { - if (api_is_platform_admin() && $_SESSION['this_section']=='platform_admin') - { - //home page portal - $PathDokeosAjaxFileManager='../../../../../../../home/default_platform_document/'; - } - else - { - //my profile - $PathDokeosAjaxFileManager='../../../../../../../main/upload/users/'.api_get_user_id().'/my_files/'; - } - - } - - define('CONFIG_SYS_DEFAULT_PATH', $PathDokeosAjaxFileManager); - define('CONFIG_SYS_ROOT_PATH', $PathDokeosAjaxFileManager); - - ////////////// end dokeos - - define('CONFIG_SYS_FOLDER_SHOWN_ON_TOP', true); //show your folders on the top of list if true or order by name - - - define("CONFIG_SYS_DIR_SESSION_PATH", session_save_path()); // Hack by Juan Carlos Raņa - - - define("CONFIG_SYS_PATTERN_FORMAT", 'list'); //three options: reg ,csv, list, this option define the parttern format for the following patterns - /** - * reg => regulare expression - * csv => a list of comma separated file/folder name, (exactly match the specified file/folders) - * list => a list of comma spearated vague file/folder name (partially match the specified file/folders) - * - */ - //more details about regular expression please visit http://nz.php.net/manual/en/function.eregi.php - define('CONFIG_SYS_INC_DIR_PATTERN', ''); //force listing of folders with such pattern(s). separated by , if multiple - define('CONFIG_SYS_EXC_DIR_PATTERN', ''); //will prevent listing of folders with such pattern(s). separated by , if multiple - define('CONFIG_SYS_INC_FILE_PATTERN', ''); //force listing of fiels with such pattern(s). separated by , if multiple - define('CONFIG_SYS_EXC_FILE_PATTERN', ''); //will prevent listing of files with such pattern(s). separated by , if multiple - define('CONFIG_SYS_DELETE_RECURSIVE', 1); //delete all contents within a specific folder if set to be 1 - - //UPLOAD OPTIONS CONFIG - define('CONFIG_UPLOAD_MAXSIZE', 50000 * 1024 ); //by bytes For Dokeos upgrade from 50 to 50000 (50MB) - - define('CONFIG_EDITABLE_VALID_EXTS', 'txt,htm,html'); //make you include all these extension in CONFIG_UPLOAD_VALID_EXTS if you want all valid. For Dokeos exclude original xml, js and css - - define('CONFIG_OVERWRITTEN', false); //overwirte when processing paste - define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,bmp,tif,psd,zip,sit,rar,gz,tar,htm,html,mov,mpg,avi,asf,mpeg,wmv,aif,aiff,wav,mp3,swf, flv, mp4, aac, ppt,rtf,doc, pdf,xls,txt,flv,odt,ods,odp,odg,odc,odf,odb,odi,pps,docx,pptx,xlsx,accdb,xml');//For Dokeos updated - define("CONFIG_VIEWABLE_VALID_EXTS", 'gif,bmp,txt,jpg,png,tif,html,htm,mp3, wav,wmv,wma,rm,rmvb,mov,swf,flv,mp4,aac,avi,mpg,mpeg,asf');//For Dokeos updated - define('CONFIG_UPLOAD_INVALID_EXTS', 'php,jar,sh,cgi,js,exe,com,bat,pif,scr,msi,ws,wsc,wsf,vb,vbe,vbs,reg,dll'); //For Dokeos added. - //Preview - define('CONFIG_IMG_THUMBNAIL_MAX_X', 100); - define('CONFIG_IMG_THUMBNAIL_MAX_Y', 100); - define('CONFIG_THICKBOX_MAX_WIDTH', 700); - define('CONFIG_THICKBOX_MAX_HEIGHT', 430); - - - /** - * CONFIG_URL_PREVIEW_ROOT was replaced by CONFIG_WEBSITE_DOCUMENT_ROOT since v0.8 - * Normally, you don't need to bother with CONFIG_WEBSITE_DOCUMENT_ROOT - * Howerver, some Web Hosts do not have standard php.ini setting - * which you will find the file manager can not locate your files correctly - * if you do have such issue, please change it to fit your system. - * so what should you to do get it - * 1. create a php script file (let's call it document_root.php) - * 2. add the following codes in in - * - * 3. upload document_root.php to you website root folder which will only be reached when you visit http://www.domain-name.com or http://localhost/ at localhost computer - * 4. run it via http://www.domain-name.com/document_root.php or http://localhost/docuent_root.php if localhost computer, the url has to be exactly like that - * 5. the value shown on the screen is CONFIG_WEBSITE_DOCUMENT_ROOT should be - * 6. enjoy it - - - * - */ - - // Modified by Ivan Tcholakov. - //define('CONFIG_WEBSITE_DOCUMENT_ROOT', ''); - if (preg_match('@'.api_get_path(REL_PATH).'$@', api_get_path(SYS_PATH))) // Sanity check. - { - define('CONFIG_WEBSITE_DOCUMENT_ROOT', preg_replace('@'.api_get_path(REL_PATH).'$@', '', api_get_path(SYS_PATH))); - } - else - { - define('CONFIG_WEBSITE_DOCUMENT_ROOT', ''); // Let the ajaxfilemanager try alone to find the document root. - } - - //theme related setting - /* - * options avaialbe for CONFIG_EDITOR_NAME are: - stand_alone - tinymce - fckeditor - */ - //CONFIG_EDITOR_NAME replaced CONFIG_THEME_MODE since @version 0.8 - define('CONFIG_EDITOR_NAME', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['editor'])?secureFileName($_GET['editor']):'fckeditor')); // run mode fckeditor (Dokeos editor) - define('CONFIG_THEME_NAME', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['theme'])?secureFileName($_GET['theme']):'default')); //change the theme to your custom theme rather than default - define('CONFIG_DEFAULT_VIEW', (CONFIG_SYS_THUMBNAIL_VIEW_ENABLE?'detail':'detail')); //thumnail or detail - define('CONFIG_DEFAULT_PAGINATION_LIMIT', 10); - define('CONFIG_LOAD_DOC_LATTER', false); //all documents will be loaded up after the template has been loaded to the client - - - //General Option Declarations - //LANGAUGAE DECLARATIONNS - /* - $langdoktoajaxfile= api_get_language_isocode(); //from dokeos. return, en, es... - if ($langdoktoajaxfile=='en' || $langdoktoajaxfile=='zh' || $langdoktoajaxfile=='es') // ajaxfilemanager full translations (only with all variables translated). - { - $langajaxfilemanager=$langdoktoajaxfile; - } - else - { - $langajaxfilemanager='en';//default - } - */ - - @ $langajaxfilemanager = Database :: get_language_isocode($language_interface); - - // Some code translations are needed. - $langajaxfilemanager = strtolower(str_replace('_', '-', $langajaxfilemanager)); - if (empty ($langajaxfilemanager)) - { - $langajaxfilemanager = 'en'; - } - switch ($langajaxfilemanager) - { - case 'uk': - $langajaxfilemanager = 'ukr'; - break; - case 'pt': - $langajaxfilemanager = 'pt_pt'; - break; - case 'pt-br': - $langajaxfilemanager = 'pt_br'; - break; - // Code here other noticed exceptions. - } - - - // Checking for availability of a corresponding language file. - if (!file_exists(api_get_path(SYS_PATH).'main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/langs/'.$langajaxfilemanager.'.php')) - { - // If there was no language file, use the english one. - $langajaxfilemanager = 'en'; - } - - 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 -?> + false + * by session => true + */ + define('CONFIG_ACCESS_CONTROL_MODE', false); + define("CONFIG_LOGIN_USERNAME", 'ajax'); + define('CONFIG_LOGIN_PASSWORD', '123456'); + define('CONFIG_LOGIN_PAGE', 'ajax_login.php'); //the url to the login page + + //SYSTEM MODE CONFIG + /** + * turn it on when you have this system for demo purpose + * that means changes made to each image is not physically applied to it + * and all uploaded files/created folders will be removed automatically + */ + define('CONFIG_SYS_DEMO_ENABLE', false); + define('CONFIG_SYS_VIEW_ONLY', false); //diabled the system, view only + define('CONFIG_SYS_THUMBNAIL_VIEW_ENABLE', true);//REMOVE THE thumbnail view if false + + //User Permissions + //Hack by Juan Carlos Raņa Trabado + if(empty($_course['path'])) + { + define('CONFIG_OPTIONS_DELETE', true); + define('CONFIG_OPTIONS_CUT', true); + define('CONFIG_OPTIONS_COPY', true); + define('CONFIG_OPTIONS_NEWFOLDER', true); + define('CONFIG_OPTIONS_RENAME', true); + define('CONFIG_OPTIONS_UPLOAD', true); // + define('CONFIG_OPTIONS_EDITABLE', false); //disable image editor and text editor + } + else + { + if(api_is_allowed_to_edit()) + { + //api_is_allowed_to_edit() from Dokeos + define('CONFIG_OPTIONS_DELETE', true); + define('CONFIG_OPTIONS_CUT', false); + define('CONFIG_OPTIONS_COPY', false); + define('CONFIG_OPTIONS_NEWFOLDER', true); + define('CONFIG_OPTIONS_RENAME', false); + define('CONFIG_OPTIONS_UPLOAD', true); // + define('CONFIG_OPTIONS_EDITABLE', false); //disable image editor and text editor + + } + else + { + define('CONFIG_OPTIONS_DELETE', true); + define('CONFIG_OPTIONS_CUT', false); + define('CONFIG_OPTIONS_COPY', false); + define('CONFIG_OPTIONS_NEWFOLDER', true); + define('CONFIG_OPTIONS_RENAME', false); + define('CONFIG_OPTIONS_UPLOAD', true); // + define('CONFIG_OPTIONS_EDITABLE', false); //disable image editor and text editor + } + } + + + //FILESYSTEM CONFIG + /* + * CONFIG_SYS_DEFAULT_PATH is the default folder where the files would be uploaded to + and it must be a folder under the CONFIG_SYS_ROOT_PATH or the same folder + these two paths accept relative path only, don't use absolute path + */ + //define('CONFIG_SYS_DEFAULT_PATH', '../uploaded/'); //accept relative path only + //define('CONFIG_SYS_ROOT_PATH', '../uploaded/'); //accept relative path only + + /////////////// Integration for Dokeos + + if(!empty($_course['path'])) + { + if(!empty($group_properties['directory'])) + { + $PathDokeosAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document'.$group_properties['directory'].'/'; + } + else + { + if(api_is_allowed_to_edit()) + { + $PathDokeosAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document/'; + } + else + { + $PathDokeosAjaxFileManager='../../../../../../../courses/'.$_course['path'].'/document/shared_folder/sf_user_'.api_get_user_id().'/'; + } + } + } + else + { + if (api_is_platform_admin() && $_SESSION['this_section']=='platform_admin') + { + //home page portal + $PathDokeosAjaxFileManager='../../../../../../../home/default_platform_document/'; + } + else + { + //my profile + $PathDokeosAjaxFileManager='../../../../../../../main/upload/users/'.api_get_user_id().'/my_files/'; + } + + } + + define('CONFIG_SYS_DEFAULT_PATH', $PathDokeosAjaxFileManager); + define('CONFIG_SYS_ROOT_PATH', $PathDokeosAjaxFileManager); + + ////////////// end dokeos + + define('CONFIG_SYS_FOLDER_SHOWN_ON_TOP', true); //show your folders on the top of list if true or order by name + + + define("CONFIG_SYS_DIR_SESSION_PATH", session_save_path()); // Hack by Juan Carlos Raņa + + + define("CONFIG_SYS_PATTERN_FORMAT", 'list'); //three options: reg ,csv, list, this option define the parttern format for the following patterns + /** + * reg => regulare expression + * csv => a list of comma separated file/folder name, (exactly match the specified file/folders) + * list => a list of comma spearated vague file/folder name (partially match the specified file/folders) + * + */ + //more details about regular expression please visit http://nz.php.net/manual/en/function.eregi.php + define('CONFIG_SYS_INC_DIR_PATTERN', ''); //force listing of folders with such pattern(s). separated by , if multiple + define('CONFIG_SYS_EXC_DIR_PATTERN', ''); //will prevent listing of folders with such pattern(s). separated by , if multiple + define('CONFIG_SYS_INC_FILE_PATTERN', ''); //force listing of fiels with such pattern(s). separated by , if multiple + define('CONFIG_SYS_EXC_FILE_PATTERN', ''); //will prevent listing of files with such pattern(s). separated by , if multiple + define('CONFIG_SYS_DELETE_RECURSIVE', 1); //delete all contents within a specific folder if set to be 1 + + //UPLOAD OPTIONS CONFIG + define('CONFIG_UPLOAD_MAXSIZE', 50000 * 1024 ); //by bytes For Dokeos upgrade from 50 to 50000 (50MB) + + define('CONFIG_EDITABLE_VALID_EXTS', 'txt,htm,html'); //make you include all these extension in CONFIG_UPLOAD_VALID_EXTS if you want all valid. For Dokeos exclude original xml, js and css + + define('CONFIG_OVERWRITTEN', false); //overwirte when processing paste + define('CONFIG_UPLOAD_VALID_EXTS', 'gif,jpg,png,bmp,tif,psd,zip,sit,rar,gz,tar,htm,html,mov,mpg,avi,asf,mpeg,wmv,aif,aiff,wav,mp3,swf, flv, mp4, aac, ppt,rtf,doc, pdf,xls,txt,flv,odt,ods,odp,odg,odc,odf,odb,odi,pps,docx,pptx,xlsx,accdb,xml');//For Dokeos updated + define("CONFIG_VIEWABLE_VALID_EXTS", 'gif,bmp,txt,jpg,png,tif,html,htm,mp3, wav,wmv,wma,rm,rmvb,mov,swf,flv,mp4,aac,avi,mpg,mpeg,asf');//For Dokeos updated + define('CONFIG_UPLOAD_INVALID_EXTS', 'php,jar,sh,cgi,js,exe,com,bat,pif,scr,msi,ws,wsc,wsf,vb,vbe,vbs,reg,dll'); //For Dokeos added. + //Preview + define('CONFIG_IMG_THUMBNAIL_MAX_X', 100); + define('CONFIG_IMG_THUMBNAIL_MAX_Y', 100); + define('CONFIG_THICKBOX_MAX_WIDTH', 700); + define('CONFIG_THICKBOX_MAX_HEIGHT', 430); + + + /** + * CONFIG_URL_PREVIEW_ROOT was replaced by CONFIG_WEBSITE_DOCUMENT_ROOT since v0.8 + * Normally, you don't need to bother with CONFIG_WEBSITE_DOCUMENT_ROOT + * Howerver, some Web Hosts do not have standard php.ini setting + * which you will find the file manager can not locate your files correctly + * if you do have such issue, please change it to fit your system. + * so what should you to do get it + * 1. create a php script file (let's call it document_root.php) + * 2. add the following codes in in + * + * 3. upload document_root.php to you website root folder which will only be reached when you visit http://www.domain-name.com or http://localhost/ at localhost computer + * 4. run it via http://www.domain-name.com/document_root.php or http://localhost/docuent_root.php if localhost computer, the url has to be exactly like that + * 5. the value shown on the screen is CONFIG_WEBSITE_DOCUMENT_ROOT should be + * 6. enjoy it + * + */ + + // Modified by Ivan Tcholakov, JUN-2009. + //define('CONFIG_WEBSITE_DOCUMENT_ROOT', ''); + define('CONFIG_WEBSITE_DOCUMENT_ROOT', rtrim(api_get_path(SYS_SERVER_ROOT_PATH), '/')); + + //theme related setting + /* + * options avaialbe for CONFIG_EDITOR_NAME are: + stand_alone + tinymce + fckeditor + */ + //CONFIG_EDITOR_NAME replaced CONFIG_THEME_MODE since @version 0.8 + define('CONFIG_EDITOR_NAME', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['editor'])?secureFileName($_GET['editor']):'fckeditor')); // run mode fckeditor (Dokeos editor) + define('CONFIG_THEME_NAME', (CONFIG_QUERY_STRING_ENABLE && !empty($_GET['theme'])?secureFileName($_GET['theme']):'default')); //change the theme to your custom theme rather than default + define('CONFIG_DEFAULT_VIEW', (CONFIG_SYS_THUMBNAIL_VIEW_ENABLE?'detail':'detail')); //thumnail or detail + define('CONFIG_DEFAULT_PAGINATION_LIMIT', 10); + define('CONFIG_LOAD_DOC_LATTER', false); //all documents will be loaded up after the template has been loaded to the client + + + //General Option Declarations + //LANGAUGAE DECLARATIONNS + /* + $langdoktoajaxfile= api_get_language_isocode(); //from dokeos. return, en, es... + if ($langdoktoajaxfile=='en' || $langdoktoajaxfile=='zh' || $langdoktoajaxfile=='es') // ajaxfilemanager full translations (only with all variables translated). + { + $langajaxfilemanager=$langdoktoajaxfile; + } + else + { + $langajaxfilemanager='en';//default + } + */ + + @ $langajaxfilemanager = Database :: get_language_isocode($language_interface); + + // Some code translations are needed. + $langajaxfilemanager = strtolower(str_replace('_', '-', $langajaxfilemanager)); + if (empty ($langajaxfilemanager)) + { + $langajaxfilemanager = 'en'; + } + switch ($langajaxfilemanager) + { + case 'uk': + $langajaxfilemanager = 'ukr'; + break; + case 'pt': + $langajaxfilemanager = 'pt_pt'; + break; + case 'pt-br': + $langajaxfilemanager = 'pt_br'; + break; + // Code here other noticed exceptions. + } + + + // Checking for availability of a corresponding language file. + if (!file_exists(api_get_path(SYS_PATH).'main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/langs/'.$langajaxfilemanager.'.php')) + { + // If there was no language file, use the english one. + $langajaxfilemanager = 'en'; + } + + 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 +?> diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index b881ed7fc8..00b237bf06 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -84,6 +84,8 @@ define('UNSUBSCRIBE_ALLOWED', 1); define('UNSUBSCRIBE_NOT_ALLOWED', 0); //CONSTANTS FOR api_get_path FUNCTION +define('WEB_SERVER_ROOT_PATH', 'WEB_SERVER_ROOT_PATH'); +define('SYS_SERVER_ROOT_PATH', 'SYS_SERVER_ROOT_PATH'); define('WEB_PATH', 'WEB_PATH'); define('SYS_PATH', 'SYS_PATH'); define('REL_PATH', 'REL_PATH'); @@ -98,7 +100,7 @@ define('WEB_IMG_PATH', 'WEB_IMG_PATH'); define('WEB_CSS_PATH', 'WEB_CSS_PATH'); define('GARBAGE_PATH', 'GARBAGE_PATH'); define('SYS_PLUGIN_PATH', 'SYS_PLUGIN_PATH'); -define('PLUGIN_PATH', 'PLUGIN_PATH'); +define('PLUGIN_PATH', 'SYS_PLUGIN_PATH'); // deprecated define('WEB_PLUGIN_PATH', 'WEB_PLUGIN_PATH'); define('SYS_ARCHIVE_PATH', 'SYS_ARCHIVE_PATH'); define('WEB_ARCHIVE_PATH', 'WEB_ARCHIVE_PATH'); @@ -218,7 +220,7 @@ function api_protect_course_script($print_headers=false) { } } - /** +/** * Function used to protect an admin script. * The function blocks access when the user has no platform admin rights. * This is only the first proposal, test and improve! @@ -302,33 +304,40 @@ function api_is_self_registration_allowed() { * to alter the WEB_COURSE_PATH and SYS_COURSE_PATH parameters. * * @param one of the following constants: +* WEB_SERVER_ROOT_PATH, SYS_SERVER_ROOT_PATH, * WEB_PATH, SYS_PATH, REL_PATH, WEB_COURSE_PATH, SYS_COURSE_PATH, * REL_COURSE_PATH, REL_CODE_PATH, WEB_CODE_PATH, SYS_CODE_PATH, -* SYS_LANG_PATH, WEB_IMG_PATH, GARBAGE_PATH, PLUGIN_PATH, SYS_ARCHIVE_PATH, -* INCLUDE_PATH, LIBRARY_PATH, CONFIGURATION_PATH +* SYS_LANG_PATH, WEB_IMG_PATH, GARBAGE_PATH, WEB_PLUGIN_PATH, SYS_PLUGIN_PATH, WEB_ARCHIVE_PATH, SYS_ARCHIVE_PATH, +* INCLUDE_PATH, WEB_LIBRARY_PATH, LIBRARY_PATH, CONFIGURATION_PATH * * @example assume that your server root is /var/www/ dokeos is installed in a subfolder dokeos/ and the URL of your campus is http://www.mydokeos.com * The other configuration paramaters have not been changed. * The different api_get_paths will give -* WEB_PATH http://www.mydokeos.com -* SYS_PATH /var/www/ +* WEB_SERVER_ROOT_PATH http://www.mydokeos.com/ +* SYS_SERVER_ROOT_PATH /var/www/ - This is the physical folder where the system Dokeos has been placed. It is not always equal to $_SERVER['DOCUMENT_ROOT']. +* WEB_PATH http://www.mydokeos.com/dokeos/ +* SYS_PATH /var/www/dokeos/ * REL_PATH dokeos/ -* WEB_COURSE_PATH http://www.mydokeos.com/courses/ +* WEB_COURSE_PATH http://www.mydokeos.com/dokeos/courses/ * SYS_COURSE_PATH /var/www/dokeos/courses/ -* REL_COURSE_PATH -* REL_CODE_PATH -* WEB_CODE_PATH -* SYS_CODE_PATH -* SYS_LANG_PATH -* WEB_IMG_PATH +* REL_COURSE_PATH /dokeos/courses/ +* REL_CODE_PATH /dokeos/main/ +* WEB_CODE_PATH http://www.mydokeos.com/dokeos/main/ +* SYS_CODE_PATH /var/www/dokeos/main/ +* SYS_LANG_PATH /var/www/dokeos/main/lang/ +* WEB_IMG_PATH http://www.mydokeos.com/dokeos/main/img/ * GARBAGE_PATH -* PLUGIN_PATH -* SYS_ARCHIVE_PATH -* INCLUDE_PATH -* LIBRARY_PATH -* CONFIGURATION_PATH +* WEB_PLUGIN_PATH http://www.mydokeos.com/dokeos/plugin/ +* SYS_PLUGIN_PATH /var/www/dokeos/plugin/ +* WEB_ARCHIVE_PATH http://www.mydokeos.com/dokeos/archive/ +* SYS_ARCHIVE_PATH /var/www/dokeos/archive/ +* INCLUDE_PATH /var/www/dokeos/main/inc/ +* WEB_LIBRARY_PATH http://www.mydokeos.com/dokeos/main/inc/lib/ +* LIBRARY_PATH /var/www/dokeos/main/inc/lib/ +* CONFIGURATION_PATH /var/www/dokeos/main/inc/conf/ */ function api_get_path($path_type) { + global $_configuration; if (!isset($_configuration['access_url']) || $_configuration['access_url']==1 || $_configuration['access_url']=='') { //by default we call the $_configuration['root_web'] we don't query to the DB @@ -347,8 +356,28 @@ function api_get_path($path_type) { } switch ($path_type) { + + case WEB_SERVER_ROOT_PATH: + // example: http://www.mydokeos.com/ + $result = preg_replace('@'.api_get_path(REL_PATH).'$@', '', api_get_path(WEB_PATH)); + if (substr($result, -1) == '/') { + return $result; + } else { + return $result.'/'; + } + break; + + case SYS_SERVER_ROOT_PATH: + $result = preg_replace('@'.api_get_path(REL_PATH).'$@', '', api_get_path(SYS_PATH)); + if (substr($result, -1) == '/') { + return $result; + } else { + return $result.'/'; + } + break; + case WEB_PATH : - // example: http://www.mydokeos.com/ or http://www.mydokeos.com/portal/ if you're using + // example: http://www.mydokeos.com/ or http://www.mydokeos.com/dokeos/ if you're using // a subdirectory of your document root for Dokeos if (substr($root_web,-1) == '/') { return $root_web; @@ -358,7 +387,7 @@ function api_get_path($path_type) { break; case SYS_PATH : - // example: /var/www/ + // example: /var/www/dokeos/ if (substr($_configuration['root_sys'],-1) == '/') { return $_configuration['root_sys']; } else { @@ -389,64 +418,79 @@ function api_get_path($path_type) { // example: courses/ or dokeos/courses/ return api_get_path(REL_PATH).$_configuration['course_folder']; break; + case REL_CODE_PATH : // example: main/ or dokeos/main/ return api_get_path(REL_PATH).$_configuration['code_append']; break; + case WEB_CODE_PATH : // example: http://www.mydokeos.com/main/ //return $GLOBALS['clarolineRepositoryWeb']; // this was changed return $root_web.$_configuration['code_append']; break; + case SYS_CODE_PATH : // example: /var/www/dokeos/main/ return $GLOBALS['clarolineRepositorySys']; break; + case SYS_LANG_PATH : // example: /var/www/dokeos/main/lang/ return api_get_path(SYS_CODE_PATH).'lang/'; break; + case WEB_IMG_PATH : // example: http://www.mydokeos.com/main/img/ return api_get_path(WEB_CODE_PATH).'img/'; break; + case GARBAGE_PATH : // example: /var/www/dokeos/main/garbage/ return $GLOBALS['garbageRepositorySys']; break; + case SYS_PLUGIN_PATH : // example: /var/www/dokeos/plugin/ return api_get_path(SYS_PATH).'plugin/'; break; + case WEB_PLUGIN_PATH : // example: http://www.mydokeos.com/plugin/ return api_get_path(WEB_PATH).'plugin/'; break; + case SYS_ARCHIVE_PATH : // example: /var/www/dokeos/archive/ return api_get_path(SYS_PATH).'archive/'; break; - case WEB_ARCHIVE_PATH : - // example: http://www.mydokeos.com/archive/ - return api_get_path(WEB_PATH).'archive/'; - break; + + case WEB_ARCHIVE_PATH : + // example: http://www.mydokeos.com/archive/ + return api_get_path(WEB_PATH).'archive/'; + break; + case INCLUDE_PATH : // Generated by main/inc/global.inc.php // example: /var/www/dokeos/main/inc/ return str_replace('\\', '/', $GLOBALS['includePath']).'/'; break; + case LIBRARY_PATH : // example: /var/www/dokeos/main/inc/lib/ return api_get_path(INCLUDE_PATH).'lib/'; break; + case WEB_LIBRARY_PATH : // example: http://www.mydokeos.com/main/inc/lib/ return api_get_path(WEB_CODE_PATH).'inc/lib/'; break; + case CONFIGURATION_PATH : // example: /var/www/dokeos/main/inc/conf/ return api_get_path(INCLUDE_PATH).'conf/'; break; + default : return; break;