[ Index ]

PHP Cross Reference of Limb3

title

Body

[close]

/wysiwyg/shared/fckeditor/editor/filemanager/browser/default/connectors/php/ -> io.php (source)

   1  <?php
   2  /*

   3   * FCKeditor - The text editor for Internet - http://www.fckeditor.net

   4   * Copyright (C) 2003-2007 Frederico Caldeira Knabben

   5   *

   6   * == BEGIN LICENSE ==

   7   *

   8   * Licensed under the terms of any of the following licenses at your

   9   * choice:

  10   *

  11   *  - GNU General Public License Version 2 or later (the "GPL")

  12   *    http://www.gnu.org/licenses/gpl.html

  13   *

  14   *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")

  15   *    http://www.gnu.org/licenses/lgpl.html

  16   *

  17   *  - Mozilla Public License Version 1.1 or later (the "MPL")

  18   *    http://www.mozilla.org/MPL/MPL-1.1.html

  19   *

  20   * == END LICENSE ==

  21   *

  22   * This is the File Manager Connector for PHP.

  23   */
  24  
  25  function GetUrlFromPath( $resourceType, $folderPath )
  26  {
  27      if ( $resourceType == '' )
  28          return RemoveFromEnd( $GLOBALS["UserFilesPath"], '/' ) . $folderPath ;
  29      else
  30          return $GLOBALS["UserFilesPath"] . strtolower( $resourceType ) . $folderPath ;
  31  }
  32  
  33  function RemoveExtension( $fileName )
  34  {
  35      return substr( $fileName, 0, strrpos( $fileName, '.' ) ) ;
  36  }
  37  
  38  function ServerMapFolder( $resourceType, $folderPath )
  39  {
  40      // Get the resource type directory.

  41      $sResourceTypePath = $GLOBALS["UserFilesDirectory"] . strtolower( $resourceType ) . '/' ;
  42  
  43      // Ensure that the directory exists.

  44      CreateServerFolder( $sResourceTypePath ) ;
  45  
  46      // Return the resource type directory combined with the required path.

  47      return $sResourceTypePath . RemoveFromStart( $folderPath, '/' ) ;
  48  }
  49  
  50  function GetParentFolder( $folderPath )
  51  {
  52      $sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ;
  53      return preg_replace( $sPattern, '', $folderPath ) ;
  54  }
  55  
  56  function CreateServerFolder( $folderPath )
  57  {
  58      $sParent = GetParentFolder( $folderPath ) ;
  59  
  60      // Check if the parent exists, or create it.

  61      if ( !file_exists( $sParent ) )
  62      {
  63          $sErrorMsg = CreateServerFolder( $sParent ) ;
  64          if ( $sErrorMsg != '' )
  65              return $sErrorMsg ;
  66      }
  67  
  68      if ( !file_exists( $folderPath ) )
  69      {
  70          // Turn off all error reporting.

  71          error_reporting( 0 ) ;
  72          // Enable error tracking to catch the error.

  73          ini_set( 'track_errors', '1' ) ;
  74  
  75          // To create the folder with 0777 permissions, we need to set umask to zero.

  76          $oldumask = umask(0) ;
  77          mkdir( $folderPath, 0777 ) ;
  78          umask( $oldumask ) ;
  79  
  80          $sErrorMsg = $php_errormsg ;
  81  
  82          // Restore the configurations.

  83          ini_restore( 'track_errors' ) ;
  84          ini_restore( 'error_reporting' ) ;
  85  
  86          return $sErrorMsg ;
  87      }
  88      else
  89          return '' ;
  90  }
  91  
  92  function GetRootPath()
  93  {
  94      $sRealPath = realpath( './' ) ;
  95  
  96      $sSelfPath = $_SERVER['PHP_SELF'] ;
  97      $sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ) ;
  98  
  99      return substr( $sRealPath, 0, strlen( $sRealPath ) - strlen( $sSelfPath ) ) ;
 100  }
 101  ?>


Generated: Mon Dec 1 03:56:46 2008 Cross-referenced by PHPXref 0.7