source: trunk/admin/inc/FCKeditor/editor/filemanager/browser/default/connectors/php/io.php@ 2

Last change on this file since 2 was 2, checked in by root, 15 years ago

importo il progetto

File size: 2.5 KB
Line 
1<?php
2/*
3 * FCKeditor - The text editor for internet
4 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
5 *
6 * Licensed under the terms of the GNU Lesser General Public License:
7 * http://www.opensource.org/licenses/lgpl-license.php
8 *
9 * For further information visit:
10 * http://www.fckeditor.net/
11 *
12 * "Support Open Source software. What about a donation today?"
13 *
14 * File Name: io.php
15 * This is the File Manager Connector for ASP.
16 *
17 * File Authors:
18 * Frederico Caldeira Knabben (fredck@fckeditor.net)
19 */
20
21function GetUrlFromPath( $resourceType, $folderPath )
22{
23 if ( $resourceType == '' )
24 return RemoveFromEnd( $GLOBALS["UserFilesPath"], '/' ) . $folderPath ;
25 else
26 return $GLOBALS["UserFilesPath"] . $resourceType . $folderPath ;
27}
28
29function RemoveExtension( $fileName )
30{
31 return substr( $fileName, 0, strrpos( $fileName, '.' ) ) ;
32}
33
34function ServerMapFolder( $resourceType, $folderPath )
35{
36 // Get the resource type directory.
37 $sResourceTypePath = $GLOBALS["UserFilesDirectory"] . $resourceType . '/' ;
38
39 // Ensure that the directory exists.
40 CreateServerFolder( $sResourceTypePath ) ;
41
42 // Return the resource type directory combined with the required path.
43 return $sResourceTypePath . RemoveFromStart( $folderPath, '/' ) ;
44}
45
46function GetParentFolder( $folderPath )
47{
48 $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ;
49 return preg_replace( $sPattern, '', $folderPath ) ;
50}
51
52function CreateServerFolder( $folderPath )
53{
54 $sParent = GetParentFolder( $folderPath ) ;
55
56 // Check if the parent exists, or create it.
57 if ( !file_exists( $sParent ) )
58 {
59 $sErrorMsg = CreateServerFolder( $sParent ) ;
60 if ( $sErrorMsg != '' )
61 return $sErrorMsg ;
62 }
63
64 if ( !file_exists( $folderPath ) )
65 {
66 // Turn off all error reporting.
67 error_reporting( 0 ) ;
68 // Enable error tracking to catch the error.
69 ini_set( 'track_errors', '1' ) ;
70
71 // To create the folder with 0777 permissions, we need to set umask to zero.
72 $oldumask = umask(0) ;
73 mkdir( $folderPath, 0777 ) ;
74 umask( $oldumask ) ;
75
76 $sErrorMsg = $php_errormsg ;
77
78 // Restore the configurations.
79 ini_restore( 'track_errors' ) ;
80 ini_restore( 'error_reporting' ) ;
81
82 return $sErrorMsg ;
83 }
84 else
85 return '' ;
86}
87
88function GetRootPath()
89{
90 $sRealPath = realpath( './' ) ;
91
92 $sSelfPath = $_SERVER['PHP_SELF'] ;
93 $sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ) ;
94
95 return substr( $sRealPath, 0, strlen( $sRealPath ) - strlen( $sSelfPath ) ) ;
96}
97?>
Note: See TracBrowser for help on using the repository browser.