1 | <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
---|
2 | /** |
---|
3 | * CodeIgniter |
---|
4 | * |
---|
5 | * An open source application development framework for PHP 5.1.6 or newer |
---|
6 | * |
---|
7 | * @package CodeIgniter |
---|
8 | * @author ExpressionEngine Dev Team |
---|
9 | * @copyright Copyright (c) 2008 - 2011, 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 | */ |
---|
38 | if ( ! 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 */ |
---|
72 | /* Location: ./system/helpers/path_helper.php */ |
---|