blob: 8136dd24d5c1ea18e97b3e3cd2bf2dc4666ab6ae [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 Andreevcce6bd12018-01-09 11:32:02 +02009 * Copyright (c) 2014 - 2018, 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
Andrey Andreev1924e872016-01-11 12:55:34 +020031 * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
Andrey Andreevcce6bd12018-01-09 11:32:02 +020032 * @copyright Copyright (c) 2014 - 2018, British Columbia Institute of Technology (http://bcit.ca/)
Andrey Andreevbdb96ca2014-10-28 00:13:31 +020033 * @license http://opensource.org/licenses/MIT MIT License
Andrey Andreevbd202c92016-01-11 12:50:18 +020034 * @link https://codeigniter.com
Andrey Andreevbdb96ca2014-10-28 00:13:31 +020035 * @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
Andrey Andreevbd202c92016-01-11 12:50:18 +020049 * @link https://codeigniter.com/user_guide/libraries/config.html
Derek Allard2067d1a2008-11-13 22:59:24 +000050 */
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 Andreev0a6b0662015-10-26 15:31:38 +020091 if (isset($_SERVER['SERVER_ADDR']))
vlakoff7ead65b2014-04-01 02:09:25 +020092 {
Andrey Andreev20edad82015-11-09 10:56:30 +020093 if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE)
94 {
95 $server_addr = '['.$_SERVER['SERVER_ADDR'].']';
96 }
97 else
98 {
99 $server_addr = $_SERVER['SERVER_ADDR'];
100 }
101
102 $base_url = (is_https() ? 'https' : 'http').'://'.$server_addr
Andrey Andreevf35ae5e2014-10-10 15:40:56 +0300103 .substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
vlakoff7ead65b2014-04-01 02:09:25 +0200104 }
105 else
106 {
107 $base_url = 'http://localhost/';
108 }
Phil Sturgeon4df8b222010-12-15 14:23:14 +0000109
110 $this->set_item('base_url', $base_url);
111 }
Andrey Andreev90726b82015-01-20 12:39:22 +0200112
113 log_message('info', 'Config Class Initialized');
Derek Allard2067d1a2008-11-13 22:59:24 +0000114 }
Barry Mienydd671972010-10-04 16:33:58 +0200115
Derek Allard2067d1a2008-11-13 22:59:24 +0000116 // --------------------------------------------------------------------
117
118 /**
119 * Load Config File
120 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300121 * @param string $file Configuration file name
122 * @param bool $use_sections Whether configuration values should be loaded into their own section
123 * @param bool $fail_gracefully Whether to just return FALSE or display an error message
124 * @return bool TRUE if the file was loaded correctly or FALSE on failure
Barry Mienydd671972010-10-04 16:33:58 +0200125 */
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200126 public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000127 {
Alex Bilbieed944a32012-06-02 11:07:47 +0100128 $file = ($file === '') ? 'config' : str_replace('.php', '', $file);
Fu Xub3355192014-06-12 16:45:00 +0800129 $loaded = FALSE;
Andrey Andreev9438e262012-10-05 13:16:27 +0300130
Pascal Kriete5d5895f2011-02-14 13:27:07 -0500131 foreach ($this->_config_paths as $path)
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100132 {
Andrey Andreev7f310d62015-03-15 19:03:43 +0200133 foreach (array($file, ENVIRONMENT.DIRECTORY_SEPARATOR.$file) as $location)
Derek Jones6d743e22010-03-02 13:22:03 -0600134 {
Andrey Andreevd52b2422012-01-07 21:28:32 +0200135 $file_path = $path.'config/'.$location.'.php';
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100136 if (in_array($file_path, $this->is_loaded, TRUE))
137 {
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200138 return TRUE;
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100139 }
140
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200141 if ( ! file_exists($file_path))
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100142 {
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200143 continue;
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100144 }
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100145
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200146 include($file_path);
Derek Allard2067d1a2008-11-13 22:59:24 +0000147
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200148 if ( ! isset($config) OR ! is_array($config))
Derek Jones6d743e22010-03-02 13:22:03 -0600149 {
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200150 if ($fail_gracefully === TRUE)
151 {
152 return FALSE;
153 }
154
155 show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.');
Derek Jones6d743e22010-03-02 13:22:03 -0600156 }
Barry Mienydd671972010-10-04 16:33:58 +0200157
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200158 if ($use_sections === TRUE)
Derek Jones6d743e22010-03-02 13:22:03 -0600159 {
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200160 $this->config[$file] = isset($this->config[$file])
161 ? array_merge($this->config[$file], $config)
162 : $config;
Derek Jones6d743e22010-03-02 13:22:03 -0600163 }
164 else
165 {
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200166 $this->config = array_merge($this->config, $config);
Derek Jones6d743e22010-03-02 13:22:03 -0600167 }
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200168
169 $this->is_loaded[] = $file_path;
170 $config = NULL;
171 $loaded = TRUE;
172 log_message('debug', 'Config file loaded: '.$file_path);
Derek Jones6d743e22010-03-02 13:22:03 -0600173 }
Derek Jones6d743e22010-03-02 13:22:03 -0600174 }
Barry Mienydd671972010-10-04 16:33:58 +0200175
Andrey Andreev137aa202015-03-05 11:36:25 +0200176 if ($loaded === TRUE)
177 {
178 return TRUE;
179 }
180 elseif ($fail_gracefully === TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000181 {
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200182 return FALSE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000183 }
Phil Sturgeon05fa6112011-04-06 22:57:43 +0100184
Andrey Andreev42bc6d52014-12-16 16:16:45 +0200185 show_error('The configuration file '.$file.'.php does not exist.');
Derek Allard2067d1a2008-11-13 22:59:24 +0000186 }
Barry Mienydd671972010-10-04 16:33:58 +0200187
Derek Allard2067d1a2008-11-13 22:59:24 +0000188 // --------------------------------------------------------------------
189
190 /**
191 * Fetch a config file item
192 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300193 * @param string $item Config item name
194 * @param string $index Index name
vlakoff90f316a2013-07-25 04:33:56 +0200195 * @return string|null The configuration item or NULL if the item doesn't exist
Derek Allard2067d1a2008-11-13 22:59:24 +0000196 */
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200197 public function item($item, $index = '')
Barry Mienydd671972010-10-04 16:33:58 +0200198 {
Andrey Andreev9ba661b2012-06-04 14:44:34 +0300199 if ($index == '')
Barry Mienydd671972010-10-04 16:33:58 +0200200 {
vlakoff184cf1b2013-07-24 03:43:39 +0200201 return isset($this->config[$item]) ? $this->config[$item] : NULL;
Derek Allard2067d1a2008-11-13 22:59:24 +0000202 }
203
vlakoff184cf1b2013-07-24 03:43:39 +0200204 return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : NULL;
Derek Allard2067d1a2008-11-13 22:59:24 +0000205 }
Barry Mienydd671972010-10-04 16:33:58 +0200206
207 // --------------------------------------------------------------------
Derek Allard2067d1a2008-11-13 22:59:24 +0000208
209 /**
Andrey Andreev5232ba02012-10-27 15:25:05 +0300210 * Fetch a config file item with slash appended (if not empty)
Derek Allard2067d1a2008-11-13 22:59:24 +0000211 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300212 * @param string $item Config item name
vlakoffc1044cb2013-07-25 12:18:43 +0200213 * @return string|null The configuration item or NULL if the item doesn't exist
Derek Allard2067d1a2008-11-13 22:59:24 +0000214 */
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200215 public function slash_item($item)
Derek Allard2067d1a2008-11-13 22:59:24 +0000216 {
217 if ( ! isset($this->config[$item]))
218 {
vlakoffc1044cb2013-07-25 12:18:43 +0200219 return NULL;
Derek Allard2067d1a2008-11-13 22:59:24 +0000220 }
Alex Bilbieed944a32012-06-02 11:07:47 +0100221 elseif (trim($this->config[$item]) === '')
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800222 {
223 return '';
224 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000225
Phil Sturgeon4df8b222010-12-15 14:23:14 +0000226 return rtrim($this->config[$item], '/').'/';
Derek Allard2067d1a2008-11-13 22:59:24 +0000227 }
Barry Mienydd671972010-10-04 16:33:58 +0200228
Derek Allard2067d1a2008-11-13 22:59:24 +0000229 // --------------------------------------------------------------------
230
231 /**
232 * Site URL
Andrey Andreev5232ba02012-10-27 15:25:05 +0300233 *
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800234 * Returns base_url . index_page [. uri_string]
Derek Allard2067d1a2008-11-13 22:59:24 +0000235 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300236 * @uses CI_Config::_uri_string()
237 *
238 * @param string|string[] $uri URI string or an array of segments
vlakoff4c07fce2013-10-25 01:20:32 +0200239 * @param string $protocol
Derek Allard2067d1a2008-11-13 22:59:24 +0000240 * @return string
241 */
vlakoff4c07fce2013-10-25 01:20:32 +0200242 public function site_url($uri = '', $protocol = NULL)
Derek Allard2067d1a2008-11-13 22:59:24 +0000243 {
vlakoff4c07fce2013-10-25 01:20:32 +0200244 $base_url = $this->slash_item('base_url');
245
246 if (isset($protocol))
247 {
Andrey Andreev392f8da2015-09-14 14:52:48 +0300248 // For protocol-relative links
249 if ($protocol === '')
250 {
251 $base_url = substr($base_url, strpos($base_url, '//'));
252 }
253 else
254 {
255 $base_url = $protocol.substr($base_url, strpos($base_url, '://'));
256 }
vlakoff4c07fce2013-10-25 01:20:32 +0200257 }
258
Andrey Andreev1764dd72012-06-16 18:48:19 +0300259 if (empty($uri))
Derek Allard2067d1a2008-11-13 22:59:24 +0000260 {
vlakoff4c07fce2013-10-25 01:20:32 +0200261 return $base_url.$this->item('index_page');
Derek Jones6d743e22010-03-02 13:22:03 -0600262 }
263
Andrey Andreev95d78cf2012-06-16 19:54:33 +0300264 $uri = $this->_uri_string($uri);
265
Alex Bilbieed944a32012-06-02 11:07:47 +0100266 if ($this->item('enable_query_strings') === FALSE)
Derek Jones6d743e22010-03-02 13:22:03 -0600267 {
vlakoff4d9fd192012-12-03 11:31:00 +0100268 $suffix = isset($this->config['url_suffix']) ? $this->config['url_suffix'] : '';
Andrey Andreev95d78cf2012-06-16 19:54:33 +0300269
vlakoff66cb4132012-12-03 10:43:44 +0100270 if ($suffix !== '')
Andrey Andreev95d78cf2012-06-16 19:54:33 +0300271 {
vlakoff66cb4132012-12-03 10:43:44 +0100272 if (($offset = strpos($uri, '?')) !== FALSE)
273 {
274 $uri = substr($uri, 0, $offset).$suffix.substr($uri, $offset);
275 }
276 else
277 {
278 $uri .= $suffix;
279 }
Andrey Andreev95d78cf2012-06-16 19:54:33 +0300280 }
281
vlakoff4c07fce2013-10-25 01:20:32 +0200282 return $base_url.$this->slash_item('index_page').$uri;
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800283 }
Andrey Andreev95d78cf2012-06-16 19:54:33 +0300284 elseif (strpos($uri, '?') === FALSE)
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800285 {
Andrey Andreev95d78cf2012-06-16 19:54:33 +0300286 $uri = '?'.$uri;
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800287 }
Andrey Andreev1764dd72012-06-16 18:48:19 +0300288
vlakoff4c07fce2013-10-25 01:20:32 +0200289 return $base_url.$this->item('index_page').$uri;
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800290 }
David Behler2d2c9c62011-08-14 20:03:08 +0200291
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800292 // -------------------------------------------------------------
David Behler2d2c9c62011-08-14 20:03:08 +0200293
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800294 /**
295 * Base URL
Andrey Andreev5232ba02012-10-27 15:25:05 +0300296 *
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800297 * Returns base_url [. uri_string]
David Behler2d2c9c62011-08-14 20:03:08 +0200298 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300299 * @uses CI_Config::_uri_string()
300 *
301 * @param string|string[] $uri URI string or an array of segments
vlakoff4c07fce2013-10-25 01:20:32 +0200302 * @param string $protocol
Andrey Andreev92ebfb62012-05-17 12:49:24 +0300303 * @return string
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800304 */
vlakoff4c07fce2013-10-25 01:20:32 +0200305 public function base_url($uri = '', $protocol = NULL)
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800306 {
vlakoff4c07fce2013-10-25 01:20:32 +0200307 $base_url = $this->slash_item('base_url');
308
309 if (isset($protocol))
310 {
Andrey Andreev392f8da2015-09-14 14:52:48 +0300311 // For protocol-relative links
312 if ($protocol === '')
313 {
314 $base_url = substr($base_url, strpos($base_url, '//'));
315 }
316 else
317 {
318 $base_url = $protocol.substr($base_url, strpos($base_url, '://'));
319 }
vlakoff4c07fce2013-10-25 01:20:32 +0200320 }
321
Andrey Andreev4ac24c22016-04-28 14:28:07 +0300322 return $base_url.$this->_uri_string($uri);
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800323 }
David Behler2d2c9c62011-08-14 20:03:08 +0200324
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800325 // -------------------------------------------------------------
David Behler2d2c9c62011-08-14 20:03:08 +0200326
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800327 /**
Andrey Andreev5232ba02012-10-27 15:25:05 +0300328 * Build URI string
David Behler2d2c9c62011-08-14 20:03:08 +0200329 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300330 * @used-by CI_Config::site_url()
331 * @used-by CI_Config::base_url()
332 *
333 * @param string|string[] $uri URI string or an array of segments
Andrey Andreev92ebfb62012-05-17 12:49:24 +0300334 * @return string
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800335 */
336 protected function _uri_string($uri)
337 {
Alex Bilbieed944a32012-06-02 11:07:47 +0100338 if ($this->item('enable_query_strings') === FALSE)
anaxamaxan@blackdog.locald09c51a2011-02-02 23:00:16 -0800339 {
Andrey Andreev4ac24c22016-04-28 14:28:07 +0300340 is_array($uri) && $uri = implode('/', $uri);
341 return ltrim($uri, '/');
Derek Allard2067d1a2008-11-13 22:59:24 +0000342 }
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200343 elseif (is_array($uri))
Derek Allard2067d1a2008-11-13 22:59:24 +0000344 {
Andrey Andreev1764dd72012-06-16 18:48:19 +0300345 return http_build_query($uri);
Derek Allard2067d1a2008-11-13 22:59:24 +0000346 }
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200347
Greg Aker03abee32011-12-25 00:31:29 -0600348 return $uri;
Derek Allard2067d1a2008-11-13 22:59:24 +0000349 }
Barry Mienydd671972010-10-04 16:33:58 +0200350
Derek Allard2067d1a2008-11-13 22:59:24 +0000351 // --------------------------------------------------------------------
David Behler2d2c9c62011-08-14 20:03:08 +0200352
Derek Allard2067d1a2008-11-13 22:59:24 +0000353 /**
354 * System URL
355 *
Andrey Andreeve4e10912014-02-08 19:58:48 +0200356 * @deprecated 3.0.0 Encourages insecure practices
Derek Allard2067d1a2008-11-13 22:59:24 +0000357 * @return string
358 */
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200359 public function system_url()
Derek Allard2067d1a2008-11-13 22:59:24 +0000360 {
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200361 $x = explode('/', preg_replace('|/*(.+?)/*$|', '\\1', BASEPATH));
Derek Allard2067d1a2008-11-13 22:59:24 +0000362 return $this->slash_item('base_url').end($x).'/';
363 }
Barry Mienydd671972010-10-04 16:33:58 +0200364
Derek Allard2067d1a2008-11-13 22:59:24 +0000365 // --------------------------------------------------------------------
366
367 /**
368 * Set a config file item
369 *
Andrey Andreev5232ba02012-10-27 15:25:05 +0300370 * @param string $item Config item key
371 * @param string $value Config item value
Derek Allard2067d1a2008-11-13 22:59:24 +0000372 * @return void
373 */
Andrey Andreevccabcfd2012-01-07 19:30:47 +0200374 public function set_item($item, $value)
Derek Allard2067d1a2008-11-13 22:59:24 +0000375 {
376 $this->config[$item] = $value;
377 }
Barry Mienydd671972010-10-04 16:33:58 +0200378
Derek Allard2067d1a2008-11-13 22:59:24 +0000379}