Source for file path_functions.php

Documentation is available at path_functions.php

  1. <?php
  2. /**
  3.  * CodeIgniter
  4.  *
  5.  * An open source application development framework for PHP 4.3.2 or newer
  6.  *
  7.  * @package        CodeIgniter
  8.  * @subpackage     Helpers
  9.  * @author        ExpressionEngine Dev Team
  10.  * @copyright    Copyright (c) 2006, EllisLab, Inc.
  11.  * @license        http://codeigniter.com/user_guide/license.html
  12.  * @link        http://codeigniter.com
  13.  * @since        Version 1.0
  14.  * @filesource
  15.  */
  16.  
  17. // ------------------------------------------------------------------------
  18.  
  19. /**
  20.  * CodeIgniter Path Helpers
  21.  *
  22.  * @author        ExpressionEngine Dev Team
  23.  * @link        http://codeigniter.com/user_guide/helpers/xml_helper.html
  24.  */
  25.  
  26. // ------------------------------------------------------------------------
  27.  
  28. if (function_exists('set_realpath')) {
  29.     /**
  30.      * Set Realpath
  31.      *
  32.      * @access    public
  33.      * @param    string 
  34.      * @param    bool    checks to see if the path exists
  35.      * @return    string 
  36.      */    
  37.     function set_realpath($path$check_existance TRUE)
  38.     {
  39.         // Security check to make sure the path is NOT a URL.  No remote file inclusion!
  40.         if (preg_match("#^(http:\/\/|https:\/\/|www\.|ftp|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})#i"$path))
  41.         {
  42.             show_error('The path you submitted must be a local server path, not a URL');
  43.         }
  44.     
  45.         // Resolve the path
  46.         if (function_exists('realpath'AND @realpath($path!== FALSE)
  47.         {
  48.             $path realpath($path).'/';
  49.         }
  50.     
  51.         // Add a trailing slash
  52.         $path preg_replace("#([^/])/*$#""\\1/"$path);
  53.     
  54.         // Make sure the path exists
  55.         if ($check_existance == TRUE)
  56.         {
  57.             if is_dir($path))
  58.             {
  59.                 show_error('Not a valid path: '.$path);
  60.             }
  61.         }
  62.     
  63.         return $path;
  64.     }
  65. }
  66.  
  67. ?>

Documentation generated on Tue, 22 Nov 2011 13:28:58 -0200 by phpDocumentor 1.4.3