blob: feea7c85a461e0d5115c330f1a2c41df84f1d6b3 [file] [log] [blame]
Andrey Andreevc5536aa2012-11-01 17:33:58 +02001<?php
Derek Allard2067d1a2008-11-13 22:59:24 +00002/**
3 * CodeIgniter
4 *
Andrey Andreevfe9309d2015-01-09 17:48:58 +02005 * An open source application development framework for PHP
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
Andrey Andreevbdb96ca2014-10-28 00:13:31 +02007 * This content is released under the MIT License (MIT)
Andrey Andreevccabcfd2012-01-07 19:30:47 +02008 *
Andrey Andreevfe9309d2015-01-09 17:48:58 +02009 * Copyright (c) 2014 - 2015, British Columbia Institute of Technology
Andrey Andreevccabcfd2012-01-07 19:30:47 +020010 *
Andrey Andreevbdb96ca2014-10-28 00:13:31 +020011 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
Derek Jonesf4a4bd82011-10-20 12:18:42 -050017 *
Andrey Andreevbdb96ca2014-10-28 00:13:31 +020018 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 * THE SOFTWARE.
28 *
29 * @package CodeIgniter
30 * @author EllisLab Dev Team
darwinel871754a2014-02-11 17:34:57 +010031 * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
Andrey Andreevfe9309d2015-01-09 17:48:58 +020032 * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
Andrey Andreevbdb96ca2014-10-28 00:13:31 +020033 * @license http://opensource.org/licenses/MIT MIT License
34 * @link http://codeigniter.com
35 * @since Version 1.0.0
Derek Allard2067d1a2008-11-13 22:59:24 +000036 * @filesource
37 */
Andrey Andreevc5536aa2012-11-01 17:33:58 +020038defined('BASEPATH') OR exit('No direct script access allowed');
Derek Allard2067d1a2008-11-13 22:59:24 +000039
Derek Allard2067d1a2008-11-13 22:59:24 +000040/**
Andrey Andreev5232ba02012-10-27 15:25:05 +030041 * Config Class
Derek Allard2067d1a2008-11-13 22:59:24 +000042 *
43 * This class contains functions that enable config files to be managed
44 *
45 * @package CodeIgniter
46 * @subpackage Libraries
47 * @category Libraries
Derek Jonesf4a4bd82011-10-20 12:18:42 -050048 * @author EllisLab Dev Team
Derek Allard2067d1a2008-11-13 22:59:24 +000049 * @link http://codeigniter.com/user_guide/libraries/config.html
50 */
51class CI_Config {
52
David Behler2d2c9c62011-08-14 20:03:08 +020053 /**
54 * List of all loaded config values
55 *
Andrey Andreev5232ba02012-10-27 15:25:05 +030056 * @var array
David Behler2d2c9c62011-08-14 20:03:08 +020057 */
Eric Robertsaa141a52012-07-04 02:13:56 -050058 public $config = array();
Andrey Andreev92ebfb62012-05-17 12:49:24 +030059
David Behler2d2c9c62011-08-14 20:03:08 +020060 /**
61 * List of all loaded config files
62 *
Andrey Andreev5232ba02012-10-27 15:25:05 +030063 * @var array
David Behler2d2c9c62011-08-14 20:03:08 +020064 */
Timothy Warren48a7fbb2012-04-23 11:58:16 -040065 public $is_loaded = array();
Andrey Andreev92ebfb62012-05-17 12:49:24 +030066
David Behler2d2c9c62011-08-14 20:03:08 +020067 /**
Andrey Andreevccabcfd2012-01-07 19:30:47 +020068 * List of paths to search when trying to load a config file.
David Behler2d2c9c62011-08-14 20:03:08 +020069 *
Andrey Andreev1887ec62012-10-27 16:22:07 +030070 * @used-by CI_Loader
Andrey Andreev5232ba02012-10-27 15:25:05 +030071 * @var array
David Behler2d2c9c62011-08-14 20:03:08 +020072 */
Timothy Warren48a7fbb2012-04-23 11:58:16 -040073 public $_config_paths = array(APPPATH);
Derek Allard2067d1a2008-11-13 22:59:24 +000074
Andrey Andreev90726b82015-01-20 12:39:22 +020075 // --------------------------------------------------------------------
76
Derek Allard2067d1a2008-11-13 22:59:24 +000077 /**
Andrey Andreev5232ba02012-10-27 15:25:05 +030078 * Class constructor
Derek Allard2067d1a2008-11-13 22:59:24 +000079 *
Andrey Andreev5232ba02012-10-27 15:25:05 +030080 * Sets the $config data from the primary config.php file as a class variable.
81 *
82 * @return void
Derek Allard2067d1a2008-11-13 22:59:24 +000083 */
Andrey Andreevccabcfd2012-01-07 19:30:47 +020084 public function __construct()
Derek Allard2067d1a2008-11-13 22:59:24 +000085 {
Barry Mienydd671972010-10-04 16:33:58 +020086 $this->config =& get_config();
Phil Sturgeon4df8b222010-12-15 14:23:14 +000087
88 // Set the base_url automatically if none was provided
Taufan Aditya8749bc72012-03-11 05:43:45 +070089 if (empty($this->config['base_url']))
Phil Sturgeon4df8b222010-12-15 14:23:14 +000090 {
Andrey Andreev815ac8a2014-10-28 21:32:20 +020091 // The regular expression is only a basic validation for a valid "Host" header.
92 // It's not exhaustive, only checks for valid characters.
93 if (isset($_SERVER['HTTP_HOST']) && preg_match('/^((\[[0-9a-f:]+\])|(\d{1,3}(\.\d{1,3}){3})|[a-z0-9\-\.]+)(:\d+)?$/i', $_SERVER['HTTP_HOST']))
vlakoff7ead65b2014-04-01 02:09:25 +020094 {
Andrey Andreevf35ae5e2014-10-10 15:40:56 +030095 $base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST']
96 .substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
vlakoff7ead65b2014-04-01 02:09:25 +020097 }
98 else
99 {
100 $base_url = 'http://localhost/';
101 }
Phil Sturgeon4df8b222010-12-15 14:23:14 +0000102
103 $this->set_item('base_url', $base_url);
104 }
Andrey Andreev90726b82015-01-20 12:39:22 +0200105
106 log_message('info', 'Config Class Initialized');
Derek Allard2067d1a2008-11-13 22:59:24 +0000107 }
Barry Mienydd671972010-10-04 16:33:58 +0200108
Derek Allard2067d1a2008-11-13 22:59:24 +0000109 // --------------------------------------------------------------------
110
111 /**
112 * Load Config File
113 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300114 * @param string $file Configuration file name
115 * @param bool $use_sections Whether configuration values should be loaded into their own section
116 * @param bool $fail_gracefully Whether to just return FALSE or display an error message
117 * @return bool TRUE if the file was loaded correctly or FALSE on failure
Barry Mienydd671972010-10-04 16:33:58 +0200118 */
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200119 public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000120 {
Alex Bilbieed944a32012-06-02 11:07:47 +0100121 $file = ($file === '') ? 'config' : str_replace('.php', '', $file);
Fu Xub3355192014-06-12 16:45:00 +0800122 $loaded = FALSE;
Andrey Andreev9438e262012-10-05 13:16:27 +0300123
Pascal Kriete5d5895f2011-02-14 13:27:07 -0500124 foreach ($this->_config_paths as $path)
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100125 {
Andrey Andreev7f310d62015-03-15 19:03:43 +0200126 foreach (array($file, ENVIRONMENT.DIRECTORY_SEPARATOR.$file) as $location)
Derek Jones6d743e22010-03-02 13:22:03 -0600127 {
Andrey Andreevd52b2422012-01-07 21:28:32 +0200128 $file_path = $path.'config/'.$location.'.php';
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100129 if (in_array($file_path, $this->is_loaded, TRUE))
130 {
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200131 return TRUE;
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100132 }
133
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200134 if ( ! file_exists($file_path))
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100135 {
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200136 continue;
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100137 }
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100138
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200139 include($file_path);
Derek Allard2067d1a2008-11-13 22:59:24 +0000140
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200141 if ( ! isset($config) OR ! is_array($config))
Derek Jones6d743e22010-03-02 13:22:03 -0600142 {
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200143 if ($fail_gracefully === TRUE)
144 {
145 return FALSE;
146 }
147
148 show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
Derek Jones6d743e22010-03-02 13:22:03 -0600149 }
Barry Mienydd671972010-10-04 16:33:58 +0200150
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200151 if ($use_sections === TRUE)
Derek Jones6d743e22010-03-02 13:22:03 -0600152 {
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200153 $this->config[$file] = isset($this->config[$file])
154 ? array_merge($this->config[$file], $config)
155 : $config;
Derek Jones6d743e22010-03-02 13:22:03 -0600156 }
157 else
158 {
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200159 $this->config = array_merge($this->config, $config);
Derek Jones6d743e22010-03-02 13:22:03 -0600160 }
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200161
162 $this->is_loaded[] = $file_path;
163 $config = NULL;
164 $loaded = TRUE;
165 log_message('debug', 'Config file loaded: '.$file_path);
Derek Jones6d743e22010-03-02 13:22:03 -0600166 }
Derek Jones6d743e22010-03-02 13:22:03 -0600167 }
Barry Mienydd671972010-10-04 16:33:58 +0200168
Andrey Andreev137aa202015-03-05 11:36:25 +0200169 if ($loaded === TRUE)
170 {
171 return TRUE;
172 }
173 elseif ($fail_gracefully === TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000174 {
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200175 return FALSE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000176 }
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100177
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200178 show_error('The configuration file '.$file.'.php does not exist.');
Derek Allard2067d1a2008-11-13 22:59:24 +0000179 }
Barry Mienydd671972010-10-04 16:33:58 +0200180
Derek Allard2067d1a2008-11-13 22:59:24 +0000181 // --------------------------------------------------------------------
182
183 /**
184 * Fetch a config file item
185 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300186 * @param string $item Config item name
187 * @param string $index Index name
vlakoff90f316a2013-07-25 04:33:56 +0200188 * @return string|null The configuration item or NULL if the item doesn't exist
Derek Allard2067d1a2008-11-13 22:59:24 +0000189 */
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200190 public function item($item, $index = '')
Barry Mienydd671972010-10-04 16:33:58 +0200191 {
Andrey Andreev9ba661b2012-06-04 14:44:34 +0300192 if ($index == '')
Barry Mienydd671972010-10-04 16:33:58 +0200193 {
vlakoff184cf1b2013-07-24 03:43:39 +0200194 return isset($this->config[$item]) ? $this->config[$item] : NULL;
Derek Allard2067d1a2008-11-13 22:59:24 +0000195 }
196
vlakoff184cf1b2013-07-24 03:43:39 +0200197 return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : NULL;
Derek Allard2067d1a2008-11-13 22:59:24 +0000198 }
Barry Mienydd671972010-10-04 16:33:58 +0200199
200 // --------------------------------------------------------------------
Derek Allard2067d1a2008-11-13 22:59:24 +0000201
202 /**
Andrey Andreev5232ba02012-10-27 15:25:05 +0300203 * Fetch a config file item with slash appended (if not empty)
Derek Allard2067d1a2008-11-13 22:59:24 +0000204 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300205 * @param string $item Config item name
vlakoffc1044cb2013-07-25 12:18:43 +0200206 * @return string|null The configuration item or NULL if the item doesn't exist
Derek Allard2067d1a2008-11-13 22:59:24 +0000207 */
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200208 public function slash_item($item)
Derek Allard2067d1a2008-11-13 22:59:24 +0000209 {
210 if ( ! isset($this->config[$item]))
211 {
vlakoffc1044cb2013-07-25 12:18:43 +0200212 return NULL;
Derek Allard2067d1a2008-11-13 22:59:24 +0000213 }
Alex Bilbieed944a32012-06-02 11:07:47 +0100214 elseif (trim($this->config[$item]) === '')
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800215 {
216 return '';
217 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000218
Phil Sturgeon4df8b222010-12-15 14:23:14 +0000219 return rtrim($this->config[$item], '/').'/';
Derek Allard2067d1a2008-11-13 22:59:24 +0000220 }
Barry Mienydd671972010-10-04 16:33:58 +0200221
Derek Allard2067d1a2008-11-13 22:59:24 +0000222 // --------------------------------------------------------------------
223
224 /**
225 * Site URL
Andrey Andreev5232ba02012-10-27 15:25:05 +0300226 *
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800227 * Returns base_url . index_page [. uri_string]
Derek Allard2067d1a2008-11-13 22:59:24 +0000228 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300229 * @uses CI_Config::_uri_string()
230 *
231 * @param string|string[] $uri URI string or an array of segments
vlakoff4c07fce2013-10-25 01:20:32 +0200232 * @param string $protocol
Derek Allard2067d1a2008-11-13 22:59:24 +0000233 * @return string
234 */
vlakoff4c07fce2013-10-25 01:20:32 +0200235 public function site_url($uri = '', $protocol = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000236 {
vlakoff4c07fce2013-10-25 01:20:32 +0200237 $base_url = $this->slash_item('base_url');
238
239 if (isset($protocol))
240 {
Andrey Andreev392f8da2015-09-14 14:52:48 +0300241 // For protocol-relative links
242 if ($protocol === '')
243 {
244 $base_url = substr($base_url, strpos($base_url, '//'));
245 }
246 else
247 {
248 $base_url = $protocol.substr($base_url, strpos($base_url, '://'));
249 }
vlakoff4c07fce2013-10-25 01:20:32 +0200250 }
251
Andrey Andreev1764dd72012-06-16 18:48:19 +0300252 if (empty($uri))
Derek Allard2067d1a2008-11-13 22:59:24 +0000253 {
vlakoff4c07fce2013-10-25 01:20:32 +0200254 return $base_url.$this->item('index_page');
Derek Jones6d743e22010-03-02 13:22:03 -0600255 }
256
Andrey Andreev95d78cf2012-06-16 19:54:33 +0300257 $uri = $this->_uri_string($uri);
258
Alex Bilbieed944a32012-06-02 11:07:47 +0100259 if ($this->item('enable_query_strings') === FALSE)
Derek Jones6d743e22010-03-02 13:22:03 -0600260 {
vlakoff4d9fd192012-12-03 11:31:00 +0100261 $suffix = isset($this->config['url_suffix']) ? $this->config['url_suffix'] : '';
Andrey Andreev95d78cf2012-06-16 19:54:33 +0300262
vlakoff66cb4132012-12-03 10:43:44 +0100263 if ($suffix !== '')
Andrey Andreev95d78cf2012-06-16 19:54:33 +0300264 {
vlakoff66cb4132012-12-03 10:43:44 +0100265 if (($offset = strpos($uri, '?')) !== FALSE)
266 {
267 $uri = substr($uri, 0, $offset).$suffix.substr($uri, $offset);
268 }
269 else
270 {
271 $uri .= $suffix;
272 }
Andrey Andreev95d78cf2012-06-16 19:54:33 +0300273 }
274
vlakoff4c07fce2013-10-25 01:20:32 +0200275 return $base_url.$this->slash_item('index_page').$uri;
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800276 }
Andrey Andreev95d78cf2012-06-16 19:54:33 +0300277 elseif (strpos($uri, '?') === FALSE)
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800278 {
Andrey Andreev95d78cf2012-06-16 19:54:33 +0300279 $uri = '?'.$uri;
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800280 }
Andrey Andreev1764dd72012-06-16 18:48:19 +0300281
vlakoff4c07fce2013-10-25 01:20:32 +0200282 return $base_url.$this->item('index_page').$uri;
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800283 }
David Behler2d2c9c62011-08-14 20:03:08 +0200284
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800285 // -------------------------------------------------------------
David Behler2d2c9c62011-08-14 20:03:08 +0200286
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800287 /**
288 * Base URL
Andrey Andreev5232ba02012-10-27 15:25:05 +0300289 *
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800290 * Returns base_url [. uri_string]
David Behler2d2c9c62011-08-14 20:03:08 +0200291 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300292 * @uses CI_Config::_uri_string()
293 *
294 * @param string|string[] $uri URI string or an array of segments
vlakoff4c07fce2013-10-25 01:20:32 +0200295 * @param string $protocol
Andrey Andreev92ebfb62012-05-17 12:49:24 +0300296 * @return string
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800297 */
vlakoff4c07fce2013-10-25 01:20:32 +0200298 public function base_url($uri = '', $protocol = NULL)
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800299 {
vlakoff4c07fce2013-10-25 01:20:32 +0200300 $base_url = $this->slash_item('base_url');
301
302 if (isset($protocol))
303 {
Andrey Andreev392f8da2015-09-14 14:52:48 +0300304 // For protocol-relative links
305 if ($protocol === '')
306 {
307 $base_url = substr($base_url, strpos($base_url, '//'));
308 }
309 else
310 {
311 $base_url = $protocol.substr($base_url, strpos($base_url, '://'));
312 }
vlakoff4c07fce2013-10-25 01:20:32 +0200313 }
314
315 return $base_url.ltrim($this->_uri_string($uri), '/');
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800316 }
David Behler2d2c9c62011-08-14 20:03:08 +0200317
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800318 // -------------------------------------------------------------
David Behler2d2c9c62011-08-14 20:03:08 +0200319
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800320 /**
Andrey Andreev5232ba02012-10-27 15:25:05 +0300321 * Build URI string
David Behler2d2c9c62011-08-14 20:03:08 +0200322 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300323 * @used-by CI_Config::site_url()
324 * @used-by CI_Config::base_url()
325 *
326 * @param string|string[] $uri URI string or an array of segments
Andrey Andreev92ebfb62012-05-17 12:49:24 +0300327 * @return string
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800328 */
329 protected function _uri_string($uri)
330 {
Alex Bilbieed944a32012-06-02 11:07:47 +0100331 if ($this->item('enable_query_strings') === FALSE)
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800332 {
Derek Jones6d743e22010-03-02 13:22:03 -0600333 if (is_array($uri))
334 {
335 $uri = implode('/', $uri);
336 }
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200337 return trim($uri, '/');
Derek Allard2067d1a2008-11-13 22:59:24 +0000338 }
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200339 elseif (is_array($uri))
Derek Allard2067d1a2008-11-13 22:59:24 +0000340 {
Andrey Andreev1764dd72012-06-16 18:48:19 +0300341 return http_build_query($uri);
Derek Allard2067d1a2008-11-13 22:59:24 +0000342 }
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200343
Greg Aker03abee32011-12-25 00:31:29 -0600344 return $uri;
Derek Allard2067d1a2008-11-13 22:59:24 +0000345 }
Barry Mienydd671972010-10-04 16:33:58 +0200346
Derek Allard2067d1a2008-11-13 22:59:24 +0000347 // --------------------------------------------------------------------
David Behler2d2c9c62011-08-14 20:03:08 +0200348
Derek Allard2067d1a2008-11-13 22:59:24 +0000349 /**
350 * System URL
351 *
Andrey Andreeve4e10912014-02-08 19:58:48 +0200352 * @deprecated 3.0.0 Encourages insecure practices
Derek Allard2067d1a2008-11-13 22:59:24 +0000353 * @return string
354 */
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200355 public function system_url()
Derek Allard2067d1a2008-11-13 22:59:24 +0000356 {
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200357 $x = explode('/', preg_replace('|/*(.+?)/*$|', '\\1', BASEPATH));
Derek Allard2067d1a2008-11-13 22:59:24 +0000358 return $this->slash_item('base_url').end($x).'/';
359 }
Barry Mienydd671972010-10-04 16:33:58 +0200360
Derek Allard2067d1a2008-11-13 22:59:24 +0000361 // --------------------------------------------------------------------
362
363 /**
364 * Set a config file item
365 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300366 * @param string $item Config item key
367 * @param string $value Config item value
Derek Allard2067d1a2008-11-13 22:59:24 +0000368 * @return void
369 */
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200370 public function set_item($item, $value)
Derek Allard2067d1a2008-11-13 22:59:24 +0000371 {
372 $this->config[$item] = $value;
373 }
Barry Mienydd671972010-10-04 16:33:58 +0200374
Derek Allard2067d1a2008-11-13 22:59:24 +0000375}