path_helper.php
Go to the documentation of this file.00001 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 if ( ! function_exists('set_realpath'))
00039 {
00040 function set_realpath($path, $check_existance = TRUE)
00041 {
00042
00043 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))
00044 {
00045 show_error('The path you submitted must be a local server path, not a URL');
00046 }
00047
00048
00049 if (function_exists('realpath') AND @realpath($path) !== FALSE)
00050 {
00051 $path = realpath($path).'/';
00052 }
00053
00054
00055 $path = preg_replace("#([^/])/*$#", "\\1/", $path);
00056
00057
00058 if ($check_existance == TRUE)
00059 {
00060 if ( ! is_dir($path))
00061 {
00062 show_error('Not a valid path: '.$path);
00063 }
00064 }
00065
00066 return $path;
00067 }
00068 }
00069
00070
00071
00072