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